query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Never trust parameters from the scary internet, only allow the white list through.
def spent_params params.require(:spent).permit(:category, :value, :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 valid_params_request?; end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def filtering_params\n params.permit(:email)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def 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 url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def 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 backend_user_params\n params.permit!\n end", "def url_params\n params[:url].permit(:full)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62909746", "0.62904227", "0.62837297", "0.6240993", "0.6239739", "0.6217764", "0.6214983", "0.62112504", "0.6194765", "0.6178", "0.61755055", "0.61729854", "0.61636627", "0.6153461", "0.6151674", "0.61478525", "0.6122671", "0.61188513", "0.61075556", "0.6105721", "0.6092412", "0.6081011", "0.6071054", "0.6064436", "0.6022111", "0.6018135", "0.60151577", "0.60108894", "0.60070235", "0.60070235", "0.6000806", "0.6000464", "0.5998811", "0.59926987", "0.5992257", "0.5991173", "0.5980311", "0.59660876", "0.59596545", "0.5959415", "0.59589994", "0.5957478", "0.5953214", "0.5952233", "0.5944033", "0.59396756", "0.59396756", "0.59386414", "0.59345603", "0.5931261", "0.5926345", "0.5925795", "0.59174526", "0.59108645", "0.5909469", "0.5908263", "0.59053195", "0.58980685", "0.5897738", "0.589657", "0.5895971", "0.58942044", "0.5892847", "0.588742", "0.58834344", "0.5880024", "0.58739793", "0.5868253", "0.5867907", "0.58670515", "0.58668053", "0.5865756", "0.5863549", "0.5863236", "0.5862728", "0.5861283", "0.58591247", "0.5855159", "0.5854291", "0.58512247", "0.58498096" ]
0.0
-1
=== Description Your application should override this method. Define application command line options. === Parameters opt:: (OptionParser) use this to define options
def define_options(opt) # override this; no additional options by default end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options(opt); end", "def options(opt); end", "def options(opt)\n end", "def common_opts(opt)\n opt.on_tail(\"-h\", \"-?\", \"--help\", \"Show this help message.\") do\n puts opt\n exit\n end\n opt.on_tail(\"-v\", \"--version\", \"Show the version.\") do\n puts \"Taverna 2 Server Ruby Gem version: #{T2Server::Version::STRING}\"\n exit\n end\n end", "def options() end", "def process_options\n options.delete_if { |x,y| y.nil? }\n if options.empty?\n puts @optparse \n exit 0\n end\n options.each do |x,y|\n begin\n if y.to_s.match('^-')\n raise BoilerMakerErr.new(\"Bad args: \\\"#{y}\\\" is not a valid arg to option, \\\"--#{x}\\\". Use the -h flag for syntax help.\")\n end\n rescue => error\n puts error.message + \"\\n\"\n exit 1\n end\n end\n end", "def options; @opts end", "def handle_options\n parse_options(argv)\n if config[:version]\n show_version\n else\n show_help\n end\n exit 0\n end", "def setup_options\n parser = OptionParser.new do |o|\n o.banner = 'Usage: bundle exec qpush-server [options]'\n\n o.on('-c', '--config PATH', 'Load PATH for config file') do |arg|\n load(arg)\n Server.log.info(\"* Server config: #{arg}\")\n end\n\n o.on('-h', '--help', 'Prints this help') { puts o && exit }\n end\n parser.parse!(@argv)\n end", "def program_options\n [\n # The values of the array are,\n # [long_option, short_option and parameter, description, code to execute] \n ['--to', '-t TO', \"Send email to recipent\",\n lambda { |value| options.to = value }\n ],\n ['--message', '-m MESSAGE', \"Include the message.\",\n lambda { |value| options.message = value }\n ],\n ['--subject', '-s SUBJECT', \"Include the subject.\",\n lambda { |value| options.subject = value }\n ],\n ['--verbose', '-v', \"Log to standard output.\",\n lambda { |value| options.verbose = true }\n ],\n ['--version', '-V', \"Display the program version.\",\n lambda { |value|\n puts \"#{program_name}, version #{PROGRAM_VERSION}\"\n exit\n }\n ]\n ]\nend", "def parsed_options?\n @optparse = OptionParser.new do |opts|\n \n # A usage banner\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n \n # Returns the current version of the tool\n opts.on_tail('-v', '--version', \"Display version\") { output_version ; exit 0 }\n \n # Quick distribution\n options[:quickpkg] = nil\n opts.on( '-Q', '--quickpkg <app>', 'Create a quick application distribution (simple)' ) do |app|\n options[:quickpkg] = app\n end\n \n # Create a new project\n options[:createproj] = nil\n opts.on_head( '-C', '--createproj <dir>', String, 'Create a project directory (advanced)' ) do |proj|\n options[:createproj] = proj\n end\n \n # Specify an existing project\n options[:projectdir] = nil\n opts.on_head( '-D', '--projectdir <dir>', String, 'Specify a project directory to work with' ) do |dir|\n options[:projectdir] = dir\n end\n \n # Update the Radmind command file\n options[:ktcheck] = nil\n opts.on( '-K', '--ktcheck', 'Update the Radmind client command file' ) do |check|\n options[:ktcheck] = check\n # puts \"Updating the client's command file: #{options[:ktcheck]}\"\n end\n\n # Convert a Radmind transcript\n options[:convert] = nil\n opts.on( '-t', '--tconvert <transcript>', 'Convert a createable transcript to an appliable transcript' ) do |transcript|\n options[:tconvert] = transcript\n end\n\n # Fetch a converted Radmind loadset\n options[:fetch] = nil\n opts.on( '-f', '--fetch <transcript>', 'Fetch a converted Radmind transcript' ) do |transcript|\n options[:fetch] = transcript\n end\n \n # Specify a radmind host\n options[:radhost] = nil\n opts.on( '-h', '--radhost <host>', 'Specify the Radmind server host' ) do |host|\n options[:radhost] = host\n end\n\n # Generate the boilerplate\n options[:boil] = nil\n opts.on( '-b', '--boil', 'Generate boilerplate ' ) do |boil|\n options[:boil] = boil\n end\n \n # Package up the project's pkgroot\n options[:package] = nil\n opts.on('-p', '--package', 'Package your project ') do |package|\n options[:package] = package\n end\n\n # Archive the package inside a disk image\n options[:rollup] = nil\n opts.on('-r', '--rollup', 'Create a disk image of your package ') do |rollup|\n options[:rollup] = rollup\n end\n \n # Use Radmind security?\n options[:security] = nil\n opts.on( '-w', '--secure <level>', 'Use security level 0, 1 or 2 for Radmind operations' ) do |level|\n options[:secure] = level\n end\n\n # Use Radmind checksums\n options[:cksum] = nil\n opts.on( '-c', '--cksum <hash>', 'Update the Radmind client command file' ) do |hash|\n options[:cksum] = hash\n end\n \n # Prints a detailed help message\n opts.on_tail('--help', 'Show detailed help and information') do\n output_version\n output_help\n end\n \n end\n \n # Parse the options\n # * A non-successful parse operation presents a list of the acceptable options\n begin\n @optparse.parse!\n rescue => error\n puts error.message + \"\\n\"\n puts @optparse\n exit 1\n end\n\n # Pre-process the options before we validate them\n process_options\n true\n \n end", "def initialize(options = {})\n @appname = File.basename($0)\n @description = []\n @examples = []\n @options = {}\n @parser = OptionParser.new do |opts|\n opts.summary_width = 10\n opts.banner = ''\n opts.on('-h', '--help', 'Display this help text.') do\n @help = true\n end\n end\n self.description = options[:description] if options[:description]\n self.examples = options[:examples] if options[:examples]\n end", "def get_options\n ARGV.options { |opt|\n opt.banner = \"Usage: ruby #{__FILE__} [options] \"\n\n opt.on(\"--help\", \"What you see right now\"){ puts opt; exit 0}\n\n #Try testing with this\n #ruby __FILE__ -x -c -s test\n opt.on(\"-x\", \"parse arguments and show Usage\") {|@quit|}\n\n opt.on(\"--doc=DIRECTORY\", String, \"Output rdoc (Ruby HTML documentation) into directory\"){|dir|\n system(\"rdoc -o #{dir} #{__FILE__}\")\n }\n\n opt.on(\"--verbose\", \"-v\", \"print intermediate steps to STDERR\"){|@verbose|}\n\n opt.on(\"--schema\", \"-S\", \"Use Schema i.e. XSD rather than XML document\"){|@opt_schema|}\n\n opt.on_tail(\"By default splits data according to opt_filter, \",\n \"Subset plots on #{@opt_subset}. Will not create histograms\")\n\n opt.parse!\n } or exit(1);\n\n if @quit\n pp self\n (print ARGV.options; exit)\n end\n\n rescue NameError => err\n STDERR.puts \"ERROR: #{err}\"\n exit 1\n rescue => err\n STDERR.puts \"ERROR: #{err}\"\n exit 1\n end", "def option_missing(opt, argv)\n raise NoOptionError, opt\n end", "def program_options\n [\n ['--format', '-f FORMAT', 'Format as html or text(default)',\n lambda { |value| options.format = value }\n ],\n ['--coffee', '-c', 'Show code as coffeescript',\n lambda { |value| options.coffee = true }\n ]\n ]\nend", "def opts\n @opts ||= OptionParser.new do |opts|\n opts.program_name = File.basename($PROGRAM_NAME)\n opts.banner = \"Usage: #{opts.program_name}\"\n\n opts.separator ''\n opts.separator 'Actions:'\n\n names = @actions.map(&:name)\n padding = names.map(&:size).max\n @actions.each do |action|\n opts.separator \" #{action.name.ljust(padding)} #{action.description}\\n\"\n end\n\n opts.separator ''\n opts.separator 'Tasks:'\n\n @processor_class.tasks.each do |task_name|\n opts.separator \" #{task_name}\"\n end\n\n opts.separator ''\n opts.separator 'Specific options:'\n opts.on('-a', '--action ACTION', names, 'Select an action to run (you may give this switch multiple times)', \" (#{names.join(', ')})\") do |v|\n options.actions << v\n end\n opts.on('-t', '--task TASK', @processor_class.tasks, 'Select a scraping task to run (you may give this switch multiple times)', \" (#{@processor_class.tasks.join(', ')})\") do |v|\n options.tasks << v\n end\n opts.on('-o', '--output_dir PATH', 'The directory or Redis address (e.g. redis://localhost:6379/0) in which to dump JSON documents') do |v|\n options.output_dir = v\n end\n opts.on('--pipelined', 'Dump JSON documents all at once') do |v|\n options.pipelined = v\n end\n opts.on('-c', '--cache_dir PATH', 'The directory or Memcached address (e.g. memcached://localhost:11211) in which to cache HTTP requests') do |v|\n options.cache_dir = v\n end\n opts.on('--no-cache', 'Disable HTTP request caching') do |v|\n options.cache_dir = nil\n end\n opts.on('-e', '--expires_in SECONDS', \"The cache's expiration time in seconds\") do |v|\n options.expires_in = v\n end\n opts.on('--value_max_bytes BYTES', \"The maximum Memcached item size\") do |v|\n options.value_max_bytes = v\n end\n opts.on('--memcached_username USERNAME', \"The Memcached username\") do |v|\n options.memcached_username = v\n end\n opts.on('--memcached_password USERNAME', \"The Memcached password\") do |v|\n options.memcached_password = v\n end\n opts.on('-d', '--database_url', 'The database URL (e.g. mongodb://USER:PASSWORD@localhost:27017/pupa or postgres://USER:PASSWORD@localhost:5432/pupa') do |v|\n options.database_url = v\n end\n opts.on('--[no-]validate', 'Validate JSON documents') do |v|\n options.validate = v\n end\n opts.on('-v', '--verbose', 'Show all messages') do\n options.level = 'DEBUG'\n end\n opts.on('-q', '--quiet', 'Show only warning and error messages') do\n options.level = 'WARN'\n end\n opts.on('-s', '--silent', 'Show no messages') do\n options.level = 'UNKNOWN'\n end\n opts.on('-n', '--dry-run', 'Show the plan without running any actions') do\n options.dry_run = true\n end\n\n opts.separator ''\n opts.separator 'Common options:'\n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n exit\n end\n opts.on_tail('-v', '--version', 'Show version') do\n puts Pupa::VERSION\n exit\n end\n end\n end", "def process_command_line_options\r\n begin\r\n defer, found = \"\", false\r\n opts = GetoptLong.new(\r\n [ \"--help\", \"-h\", \"-?\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--load\", \"-l\", GetoptLong::REQUIRED_ARGUMENT ],\r\n [ \"--debug\", \"-d\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--quit\", \"-q\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--words\", \"-w\", GetoptLong::NO_ARGUMENT ])\r\n\r\n # Process the parsed options\r\n opts.each do |opt, arg|\r\n unless found\r\n puts; found = true\r\n end\r\n\r\n case opt\r\n when \"--debug\"\r\n @debug = true\r\n when \"--load\"\r\n defer << \"load\\\"#{arg}\\\" \"\r\n when \"--quit\"\r\n defer << \")quit \"\r\n when \"--words\"\r\n defer << \")words \"\r\n else\r\n fail SilentExit\r\n end\r\n end\r\n\r\n puts if found\r\n rescue Exception => e\r\n puts\r\n puts \"fOOrth available options:\"\r\n puts\r\n puts \"--help -h -? Display this message and exit.\"\r\n puts \"--load -l <filename> Load the specified fOOrth source file.\"\r\n puts \"--debug -d Default to debug ON.\"\r\n puts \"--quit -q Quit after processing the command line.\"\r\n puts \"--words -w List the current vocabulary.\"\r\n puts\r\n raise SilentExit\r\n end\r\n\r\n defer\r\n end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def parse_options(opts, args); end", "def set_options(opts)\n opts.version = AutoExpreso::VERSION\n opts.banner = <<MSG\nUsage: autoexpreso [OPTION]\nDescription:\n Autoexpreso, Scrapes autoexpreso.com for your account status.\n\nOptions:\nMSG\n opts.set_program_name 'AutoExpreso'\n opts.on_head('-l', '--login', 'Log into AutoExpreso') do\n @login = true\n end\n\n opts.on_head('-j', '--json', 'Return account details as json') do\n @json = true\n end\n\n opts.on_tail('-v', '--version', 'Display the version of AutoExpreso and exit') do\n puts opts.version\n exit\n end\n\n opts.on_tail('-h', '--help', 'Print this help') do\n puts opts.help\n exit\n end\n end", "def parse_option(obj, opt, argv)\n x = opt.sub(/^--/, '')\n #if obj.respond_to?(\"#{x}=\")\n obj.send(\"#{x}=\", true)\n #else\n # obj.option_missing(x, true)\n #end\n end", "def common_options(opts)\n opts.separator ''\n opts.separator 'Other options:'\n opts.on('--[no-]color', 'Run without color') do |v|\n Term::ANSIColor.coloring = v\n end\n opts.on_tail('-v', '--version', 'Show version.') do\n ui.trace \"inch #{Inch::VERSION}\"\n exit\n end\n opts.on_tail('-l', '--language [LANGUAGE]',\n 'Set language (elixir|javascript|ruby).') do |language|\n @language = language\n end\n opts.on_tail('-r', '--read-from-dump [FILE]',\n 'Read objects from dump.') do |file|\n @read_dump_file = file\n end\n opts.on_tail('-h', '--help', 'Show this help.') do\n ui.trace opts\n exit\n end\n end", "def program_options\n [\n # The values of the array are,\n # [long_option, short_option and parameter, description, code to execute]\n ['--google', '-g', \"Format for Google blogger.\",\n lambda { |value| options.google = true }\n ],\n ['--jayway', '-j', \"Format for Jayway blog.\",\n lambda { |value| options.jayway = true }\n ],\n ['--utf', '-u', \"Include meta charset utf8\",\n lambda { |value| options.utf = true }\n ],\n ['--stylesheet', '-s', \"Add a stylesheet, md.css\",\n lambda { |value| options.stylesheet = true }\n ],\n ['--verbose', '-v', \"Log to standard output.\",\n lambda { |value| options.verbose = true }\n ],\n ['--version', '-V', \"Display the program version.\",\n lambda { |value|\n puts \"#{program_name}, version #{PROGRAM_VERSION}\"\n exit\n }\n ]\n ]\nend", "def option_parser\n OptionParser.new do |op|\n op.banner << \" project\"\n\n op.on(\"-f\", \"--force\", \"force the overwriting of existing files\") do\n self.options.force = true\n end\n op.separator \"\"\n op.separator \"common options:\"\n op.on_tail( \"-h\", \"--help\", \"show this message\") do\n puts op\n exit 0\n end\n\n op.on_tail( \"--version\", \"show version\" ) do\n puts \"Crate #{::Crate::VERSION}\"\n exit 0\n end\n end\n end", "def parse_options(args)\n\t\t\t\tbegin\n\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t@options['verbose'] = false\n\t\t\t\t\t@options['rescan'] = false\n\t\t\t\t\t@options[:timeout] = 25\n\t\t\t\t\t@options[:directory] = nil\n\n\t\t\t\t\topts = OptionParser.new do |opt|\n\t\t\t\t\t\topt.banner = \"#{APP_NAME} v#{VERSION}\\nJacob Hammack\\n#{HOME_PAGE}\\n\\n\"\n\t\t\t\t\t\topt.banner << \"Usage: #{APP_NAME} <options>\"\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('File Options')\n\n\t\t\t\t\t\topt.on('-h HASH', '--search-hash HASH', 'Searches a single hash on virustotal.com') do |hash|\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-r HASH[,HASH]', '--rescan-hash HASH[,HASH]', 'Requests a rescan of a single hash, or multiple hashes (comma separated), by virustotal.com') do |hash|\n\t\t\t\t\t\t\t@options['rescan'] = true\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@files_of_hashes.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@uploads.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator(\"Url Options\")\n\n\t\t\t\t\t\topt.on('-s SITE', '--search-site SITE', 'Searches for a single url on virustotal.com') { |site|\n\t\t\t\t\t\t\t@sites.push(site)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('Output Options')\n\n\t\t\t\t\t\topt.on('-j', '--json-output', 'Print results as json to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :json\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-x', '--xml-output', 'Print results as xml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :xml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-y', '--yaml-output', 'Print results as yaml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :yaml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--stdout-output', 'Print results as normal text line to stdout, this is default') do\n\t\t\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Advanced Options'\n\n\t\t\t\t\t\topt.on('-c', '--create-config', 'Creates a skeleton config file to use') do\n\t\t\t\t\t\t\tcreate_config\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-d DIRECTORY', '--directory', 'Scans a directory recursively for files and submits the hashes') do |directory|\n\t\t\t\t\t\t\t@options[:directory] = directory\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-p PROXY', '--proxy-server', 'Uses a specified proxy server') do |proxy|\n\t\t\t\t\t\t\t@options['proxy'] = proxy\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--[no-]verbose', 'Print verbose information') do |v|\n\t\t\t\t\t\t\t@options['verbose'] = v\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Other Options'\n\n\t\t\t\t\t\topt.on('-v', '--version', 'Shows application version information') do\n\t\t\t\t\t\t\tputs \"#{APP_NAME} - #{VERSION}\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on_tail('-?', '--help', 'Show this message') { |help|\n\t\t\t\t\t\t\tputs opt.to_s + \"\\n\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\n\t\t\t\t\tif ARGV.length != 0\n\t\t\t\t\t\topts.parse!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\trescue OptionParser::MissingArgument\n\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend", "def process_option( opt, arg)\n case opt\n when '--ec2-user-id': @ec2_user_id = arg\n when '--aws-access-key-id': @aws_access_key_id = arg\n when '--aws-secret-access-key': @aws_secret_access_key = arg\n when '--snapshot': @do_snapshot = true\n when '--restore-most-recent': @do_restore = true\n when '--host-role': @host_role = arg\n when '--volume-size': @volume_size = arg\n when '--tell': @do_tell = true\n when '--debug': @do_debug = true\n end\n end", "def command_run_options(c, str_opts)\n c.option '-c', '--categories [string]', String, str_opts.categories\n c.option '-d', '--dl-method [string]', String, str_opts.dl_method\n c.option '-n', '--number [integer]', Integer, str_opts.number\n c.option '-p', '--player [string]', String, str_opts.player\n c.option '-r', '--rng [string]', String, str_opts.rng\n end", "def initialize\n @options = OptionParser.new do |opt|\n opt.banner = Banner\n opt.summary_indent = ' '\n\n opt.separator \"\\nOptions:\\n\"\n\n opt.on('-h', '--help', 'Shows this help message') do\n puts @options\n exit\n end\n\n opt.on(\n '-P',\n '--pid FILE',\n 'Uses the PID to kill the application'\n ) do |pid|\n @pid = pid\n end\n end\n end", "def handle_options\n OptionParser.new do |opts|\n opts.banner = 'Travis CI Command Line Client'\n\n setup_help(opts) {|opts|\n opts.separator ''\n opts.separator 'Supported Options:'\n client_options().each {|option| opts.on(*option)}\n opts.on_tail('--help', '-h', '-H', 'display this help message.') do\n $stdout.print opts\n exit\n end\n }\n end.parse!\n end", "def options\n @options ||= OptionParser.new do |opt|\n opt.program_name = File.basename $0\n opt.version = DbAgile::VERSION\n opt.release = nil\n opt.summary_indent = ' ' * 2\n opt.banner = self.banner\n add_options(opt)\n end\n end", "def options_other opts, colors\n\t\t\t\topts.separator \"\"\n\t\t\t\topts.separator \"Other Options: \".colorize(colors[:green])\n\n\t\t\t\t#todo -h\n\t\t\t\topts.on('-h', '--help', 'displays this screen' ) do\n\t\t\t\t\tputs opts\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\t\t#todo -w\n\t\t\t\topts.on('-w', \"displays the name of the current list\") do\n\t\t\t\t\tputs \"Working list is #{Config[:working_list_name]}\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend", "def options(opt)\n []\n end", "def program_options\n [\n # The values of the array are,\n # [long_option, short_option and parameter, description, code to execute]\n ['--verbose', '-v', \"Log to standard output.\",\n lambda { |value| options.verbose = true }\n ],\n ['--version', '-V', \"Display the program version.\",\n lambda { |value|\n puts \"#{program_name}, version #{PROGRAM_VERSION}\"\n exit\n }\n ]\n ]\nend", "def process_options\n \n end", "def process_options\n \n end", "def process_options\n \n end", "def options(argv = ARGV)\n return @options if @options\n\n @options = Options::DEFAULT.dup\n\n opts = OptionParser.new do |opts|\n opts.banner =\n \"nopaste.rb - send text to http://rafb.net/paste\\n\" \\\n \"Usage: nopaste.rb [options] [file(s)]\"\n\n opts.separator \"Options:\"\n\n opts.on(\"-l\", \"--lang LANGUAGE\", Options::LIST[:lang],\n \"Language of snippet (default #{Options::DEFAULT[:lang]})\",\n *Options::LIST[:lang].join(\", \").split(/(?=PL)/)) do |lang|\n @options[:lang] = lang\n end\n opts.on(\"-n\", \"--nick NICKNAME\", \"Your nickname (9 char max)\") do |nick|\n @options[:nick] = nick[0, 9]\n end\n opts.on(\"-d\", \"--desc DESCRIPTION\",\n \"Description of the snippet (50 char max)\") do |desc|\n @options[:desc] = desc[0, 50]\n end\n opts.on(\"-t\", \"--cvt-tabs [SPACES]\", Options::LIST[:cvt_tabs],\n \"Convert tabs to spaces (default #{Options::DEFAULT[:cvt_tabs]})\",\n *Options::LIST[:cvt_tabs].join(\", \")) do |spaces|\n @options[:cvt_tabs] = spaces || \"8\"\n end\n opts.on(\"-u\", \"--rubyurl\",\n \"Shorten the URL using rubyurl.com\") do |rubyurl|\n @options[:rubyurl] = rubyurl\n end\n opts.on(\"-a\", \"--agree-to-terms\",\n \"Agree to the Terms of Use (mandatory)\") do |agree|\n @options[:agree_to_terms] = agree\n end\n opts.on_tail(\"-s\", \"--show-terms\", \"Show the Terms of Use\") do\n puts terms\n exit\n end\n opts.on_tail(\"-h\", \"--help\", \"Show this message\") do\n puts opts\n exit\n end\n end\n\n begin\n opts.parse! argv\n rescue OptionParser::ParseError => e\n STDERR.puts e, opts\n exit\n end\n\n unless @options[:agree_to_terms]\n STDERR.puts \"missing mandatory argument: --agree-to-terms\", opts\n exit\n end\n\n @options\n end", "def set_options(opts)\n @total_news = 25\n opts.version = EndiFeed::VERSION\n opts.banner = <<MSG\nUsage: endifeed [options] [arguments]\nDescription:\n EndiFeed, get the latest news from endi.com / El Nuevo Dia Newspaper.\n\nOptions:\nMSG\n opts.set_program_name 'EndiFeed'\n opts.on('-n [total]', Integer, '--news', 'total of news to fetch') do |total|\n @total_news = total\n end\n\n opts.on_tail('-v', '--version', 'display the version of EndiFeed') do\n puts opts.version\n exit\n end\n\n opts.on_tail('-h', '--help', 'print this help') do\n puts opts.help\n exit\n end\n end", "def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end", "def optparse!(argv) # rubocop:disable Metrics/MethodLength\n options = Options.new\n option_parser = OptionParser.new do |parser|\n parser.banner = \"Usage: #{parser.program_name} [options]\"\n parser.on('-hHOST', '--host=HOST', 'Coursemology host to connect to') do |host|\n options.host = host\n end\n\n parser.on('-tTOKEN', '--api-token=TOKEN') do |token|\n options.api_token = token\n end\n\n parser.on('-uUSER', '--api-user-email=USER') do |user|\n options.api_user_email = user\n end\n\n parser.on('-o', '--one-shot') do\n options.one_shot = true\n end\n end\n\n option_parser.parse!(argv)\n options\n end" ]
[ "0.7118333", "0.7117604", "0.70960796", "0.6870463", "0.6639433", "0.6578563", "0.6551517", "0.64392525", "0.6408635", "0.63547367", "0.6349535", "0.63261074", "0.63260627", "0.63227546", "0.6310772", "0.6281424", "0.6280924", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.62721825", "0.6251241", "0.62126106", "0.62086207", "0.62030315", "0.61814237", "0.6133626", "0.6126811", "0.6095026", "0.60941184", "0.60773206", "0.6077311", "0.60704577", "0.6053529", "0.60482454", "0.60477155", "0.60366976", "0.60366976", "0.60366976", "0.6036285", "0.60150665", "0.60126996", "0.6010016" ]
0.70181286
3
=== Description Your application should override this method. Implement the main entry point. === Parameters argv:: (Array) of positional arguments Basically left over after processing command line options starting with dash(s) as defined in get_options. === Returns (Integer) exit code
def main(argv) # override this; no default action in main end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(argv = ARGV)\n #p [:argv, argv]\n begin\n # cheating\n if argv.include?('-h') or argv.include?('--help')\n puts help_text\n else\n app = from_argv(argv)\n app.run\n end\n rescue Exception => e\n if exit_status == 0\n exit_status 1\n end\n puts \"\\nERROR: #{e}\"\n ensure\n exit(exit_status)\n end\n end", "def handle_options\n parse_options(argv)\n if config[:version]\n show_version\n else\n show_help\n end\n exit 0\n end", "def run(argv)\n options = parse(argv)\n invoke!(options.to_h)\n end", "def go(argv)\n logger.debug(\"Using args passed in: #{argv.inspect}\")\n\n cmd = nil\n\n @optparse = OptionParser.new do |opts|\n cmd = super(argv, opts, @config)\n\n opts.on('-v', '--version', 'Print the version') do\n puts \"#{name} #{version}\"\n abort\n end\n end\n\n @optparse.parse!(argv)\n\n logger.debug(\"Parsed config: #{@config.inspect}\")\n\n cmd.execute(argv, @config)\n end", "def run\n code = 0\n opt = OptionParser.new\n define_options(opt)\n default_options(opt)\n define_exit_codes(opt)\n argv = opt.parse!\n\n if @help\n puts_msg(opt.help)\n\n else\n begin\n main(argv)\n rescue Exception => e\n arr = @@exit_code_map[e.class]\n code = arr ? arr[0] : 1\n puts_err e.to_s\n puts_err \"[ERROR]\"\n end\n end\n\n exit(code)\n end", "def args(argv)\n Docopt.docopt(docopt, version: @version, argv:argv)\n end", "def _run(argv = [])\n execute(parse_options(argv))\n end", "def initialize(argv = [])\n @debug = $DEBUG\n @verbose = $VERBOSE\n @version_requested = false\n\n opt = OptionParser.new\n opt.banner = 'Usage: peeek [switches] [--] [programfile] [arguments]'\n opt.summary_indent = ' ' * 2\n opt.summary_width = 15\n\n @working_directory = nil\n\n opt.on('-Cdirectory', 'cd to directory before executing your script') do |directory|\n @working_directory = directory\n end\n\n opt.on('-d', '--debug', 'set debugging flags (set $DEBUG to true)') do\n @debug = true\n @verbose = verbose_by(VERBOSE)\n end\n\n commands = []\n\n opt.on(\"-e 'command'\", \"one line of script. Several -e's allowed. Omit [programfile]\") do |command|\n commands << command\n end\n\n if self.class.encoding_options_enabled?\n @external_encoding = Encoding.default_external\n @internal_encoding = Encoding.default_internal\n\n opt.on('-Eex[:in]', '--encoding=ex[:in]', 'specify the default external and internal character encodings') do |encodings|\n external_encoding, internal_encoding = parse_encodings(encodings)\n @external_encoding = external_encoding if external_encoding\n @internal_encoding = internal_encoding\n end\n end\n\n @hook_targets = []\n\n opt.on('-Hstring', 'object and method name that is target of hook') do |string|\n hook_spec = Hook::Specifier.parse(string)\n @hook_targets << hook_spec unless @hook_targets.include?(hook_spec)\n end\n\n @directories_to_load = []\n\n opt.on('-Idirectory', 'specify $LOAD_PATH directory (may be used more than once)') do |directory|\n @directories_to_load << directory unless @directories_to_load.include?(directory)\n end\n\n @required_libraries = []\n\n opt.on('-rlibrary', 'require the library before executing your script') do |library|\n @required_libraries << library unless @required_libraries.include?(library)\n end\n\n opt.on('-v', 'print version number, then turn on verbose mode') do\n @version_requested = true\n @verbose = verbose_by(VERBOSE)\n end\n\n opt.on('-w', '--verbose', 'turn warnings on for your script') do\n @verbose = verbose_by(VERBOSE)\n end\n\n level_strings = [:SILENCE, :MEDIUM, :VERBOSE].map do |const_name|\n \"#{self.class.const_get(const_name)}=#{const_name.to_s.downcase}\"\n end\n\n opt.on(\"-W[level=#{VERBOSE}]\", \"set warning level; #{level_strings * ', '}\", Integer) do |level|\n @verbose = verbose_by(level || VERBOSE)\n end\n\n @continued = true\n\n opt.on('--version', 'print the version') do\n @version_requested = true\n @continued = false\n end\n\n opt.on_tail('-h', '--help', 'show this message') do\n raise Help, opt.help\n end\n\n @arguments = opt.order(argv)\n @command = commands * '; '\n end", "def run(argv = ARGV)\n # => Parse CLI Configuration\n cli = Options.new\n cli.parse_options(argv)\n\n # => Parse JSON Config File (If Specified and Exists)\n json_config = Util.parse_json_config(cli.config[:config_file] || Config.config_file)\n\n # => Grab the Default Values\n default = Config.options\n\n # => Merge Configuration (CLI Wins)\n config = [default, json_config, cli.config].compact.reduce(:merge)\n\n # => Apply Configuration\n Config.setup do |cfg|\n cfg.config_file = config[:config_file]\n cfg.cache_timeout = config[:cache_timeout].to_i\n cfg.bind = config[:bind]\n cfg.port = config[:port]\n cfg.environment = config[:environment].to_sym.downcase\n cfg.do_api_key = config[:do_api_key]\n end\n\n # => Launch the API\n API.run!\n end", "def go_with_args(argv=[])\n catch(:exit_err) { catch(:exit_zero) { @cli_obj.go(argv) } }\n end", "def argv; end", "def parse_args(argv)\n @args ||= nil\n raise \"#{class_name}.initialize failed to call super!\" unless\n args.is_a?(Hash)\n\n #\n # if this CLI has boolean arguments which can immediately\n # precede the non-option arguments (ie those arguments which\n # don't begin with '--'), those booleans need to be declared.\n # otherwise when parsing the boolean argument, we'll mistake\n # the boolean as an option with a value:\n #\n # foo.rb --boolean firstnonoption\n #\n # becomes args = {:boolean => 'firstnonoption'}.\n #\n booleans = {}\n booleans = Hash[*(boolean_args.map { |a| [a,1] }.flatten)] if\n self.respond_to? :boolean_args\n\n skipped = []\n while argv.length > 0 do\n unless argv[0] =~ /^--?/\n skipped.push argv.shift\n\n else\n # shift the argument name out of argv\n argname = argv.shift.sub(/^--?/, '').downcase\n raise ArgumentError, \"expected: --ARGNAME; got: '#{argname.inspect}'\" unless\n argname.is_str?\n\n # strip trailing '-' then convert remaining '-' to '_'\n argsym = argname.sub(/-+$/, '').gsub(/-+/, '_').to_sym\n\n if booleans[argsym] or (argv.length < 1) or (argv[0] =~ /^--?/)\n # a boolean argument whose value is false when the argument ends with '-'\n args[argsym] = (argname =~ /-$/) ? false : true\n else\n # named argument\n args[argsym] = argv.shift\n end\n end\n end\n\n self.argv = skipped || []\n\n usage if args[:help] or args[:usage]\n end", "def initialize(argv = [])\n @arguments ||= argv\n end", "def main(*args)\n #puts self.class # TODO: fix help\n raise NoCommandError\n end", "def parse( argv )\n self.data = ::Crate.data_path\n opts = option_parser\n begin\n opts.parse!( argv )\n self.project = argv.shift\n\n if project.nil?\n puts opts\n exit 1\n end\n rescue ::OptionParser::ParseError => pe\n puts \"#{opts.program_name}: #{pe}\"\n puts \"Try `#{opts.program_name} --help` for more information\"\n exit 1\n end\n end", "def initialize(argv = nil)\n\t\t\targv ||= ARGV.drop(1)\n\n\t\t\traise \"Not enough arguments\" if argv.empty?\n\t\t\t@argv = argv\n\t\tend", "def go(argv=nil)\n @exit_status = nil\n @argv = argv if argv \n\n parse\n\n # the overriding class implements actual functionality beyond here\n end", "def initialize(argv=ARGV)\n @options = {}\n end", "def run\n @action = @argv[0] || @app_default_action\n @action = @action.downcase\n init_defaults\n\n\n ret = 0\n @argv.shift\n if respond_to? @action\n ret = send(@action, @argv)\n else\n # check aliases\n if check_aliases @action, @argv\n ret = send(@action, @argv)\n else\n help @argv\n ret = ERRCODE\n end\n end\n ret ||= 0\n ret = 0 if ret != ERRCODE\n return ret\n end", "def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n raise e if e.is_a?(SystemExit)\n\n $stderr.puts e.message\n exit 1\n end\n exit 0\n end", "def run\n begin\n raise TooManyArgumentsError.new(@arguments) if @arguments.length > 1\n \n print_version if @options.version?\n scan if @options.scan?\n rename_given_file unless @arguments.empty?\n run_gui if @arguments.empty?\n \n raise Error\n rescue => e\n puts e.to_s\n \n exit(1)\n end\n end", "def work(argv)\n # all -h equivalent to --help\n argv = argv.map { |a| a == '-h' ? '--help' : a }\n idx = argv.index { |c| !c.start_with?('-') }\n preoption = idx.nil? ? argv.shift(argv.size) : argv.shift(idx)\n\n # handle --version or --help or nothing\n return show(\"SeccompTools Version #{SeccompTools::VERSION}\") if preoption.include?('--version')\n return show(USAGE) if idx.nil?\n\n # let's handle commands\n cmd = argv.shift\n argv = %w[--help] if preoption.include?('--help')\n return show(invalid(cmd)) if COMMANDS[cmd].nil?\n\n COMMANDS[cmd].new(argv).handle\n end", "def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end", "def execute(sub_argv)\n\n $logger.info \"RubyVersion, sub_argv = #{sub_argv}\"\n\n options = {}\n\n opts = OptionParser.new do |o|\n o.banner = 'Usage: openstudio ruby_version'\n end\n\n # Parse the options\n argv = parse_options(opts, sub_argv)\n return 0 if argv == nil\n\n $logger.debug(\"RubyVersion command: #{argv.inspect} #{options.inspect}\")\n\n unless argv == []\n $logger.error 'Arguments passed to the ruby_version command.'\n return 1\n end\n\n safe_puts RUBY_VERSION\n\n 0\n end", "def gentest argv\n argv = argv.dup\n @both = false\n process_opts(argv) if /^-/ =~ argv.first\n\n @service_controller = deduce_services_controller\n @ui = Hipe::IndentingStream.new($stdout,'')\n file = argv.shift\n mod = deduce_module_from_file file\n mod.spec.invocation_name = File.basename(file)\n get_actuals mod, argv\n @ui.indent!.indent!\n go_app(mod, file)\n go_desc(mod, file) do\n go_exp\n go_act(mod, argv)\n end\n exit(0) # rake is annoying\n end", "def run_argv\n first, *other = ARGV\n ARGV.clear\n case first\n when 'favs', \"f\"\n display_favorites\n when '-new', \"-n\"\n \n add_to_favorites(other.join(' '))\n puts \"#{other.join(' ')} has been added to the list\"\n process_favorites\n when '-today', '-t'\n raise StandardError, \"Currently offline, connect the internet to see todays activities - check if online '-online' '-o'\" if @alive == false\n display_today_activity_name\n when '-weekend', '-w'\n raise StandardError, \"Currently offline, connect the internet to see the weekends activities - check if online '-online' '-o'\" if @alive == false\n display_weekend_activity_name\n when '-all', '-a'\n raise StandardError, \"Currently offline, connect the internet to see the list of activities - check if online '-online' '-o'\" if @alive == false\n display_today_activity_name\n display_today_activity_name\n when '-online', '-o'\n puts @alive\n when '-help', '-h'\n puts \"-today, -t Displays todays activities\"\n puts \"-weekend, -w Displays weekend activities\"\n puts \"-all, -a Displays all activities\"\n puts \"-new, -n Add your own favourite\"\n puts \"-online, -o Checks internet connection\"\n else\n puts 'Not a valid argument!'\n end\n File.write(@file_path, @processed_favs.uniq.to_json) \n end", "def validate_argv\n if ARGV.empty? then\n ARGV << \"start\"\n else\n if not %w{start stop restart zap status}.include? ARGV.first then\n $stderr.puts \"ERROR: invalid command '#{ARGV.first}'\"\n $stderr.puts\n $stderr.puts @opt_parser.help()\n exit 1\n end\n end\n end", "def run(argv = [])\n @opts.parse!(argv)\n\n path = argv.delete_at(0)\n proto = __DIR__('../../proto')\n\n abort 'You need to specify a name for your application' if path.nil?\n\n if File.directory?(path) and @options[:force] === false\n abort 'The specified application already exists, use -f to overwrite it'\n end\n\n if File.directory?(path) and @options[:force] === true\n FileUtils.rm_rf(path)\n end\n\n begin\n FileUtils.cp_r(proto, path)\n puts \"The application has been generated and saved in #{path}\"\n rescue\n abort 'The application could not be generated'\n end\n end", "def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end", "def run\n input = OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n\n opts.on(\"--debug\", \"Turn on debugging output.\") do |debug|\n $DEBUG = @options[:debug] = debug\n end\n\n opts.on(\"-n <path>\", \"--new\", \"Create a new Corrupt application.\") do |path|\n @options[:path] = path\n end\n\n opts.on(\"-v\", \"--version\", \"Print the version.\") do |v|\n output(Corrupt.to_version)\n exit\n end\n end\n\n begin\n @argv << '--help' if @argv.empty?\n input.parse!(@argv)\n take_action!\n rescue OptionParser::InvalidOption => error\n error(\"#{error}\\nTry passing '--help'\")\n rescue OptionParser::MissingArgument => error\n error(\"#{error}\\nTry passing '--help'\")\n end\n end", "def main\n if system(ARGV.join(\" \"))\n exit 0\n else\n main\n end\nend", "def process_arguments\n @args << \"-h\" if(@args.length < 1)\n \n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE','use the following local file') {|file| @options.file = File.expand_path(file)}\n opts.on('-p','--parse PARSE',\"sets which set of sider files to download #{@@sections.join(\"|\")}\") {|parse| @options.parse = parse}\n opts.on('-d','--download','download the file to be parsed') {@options.download = true}\n opts.on('-o','--output DIR','set the output directory') {|directory| @options.output = File.expand_path(directory)}\n opts.on('-h','--help',\"prints the help\"){puts opts; exit!}\n end\n \n opts_parse.parse!(@args) rescue raise \"There was an error processing command line arguments use -h to see help\"\n end", "def handle_argv\n opt = OptionParser.new(BANNER)\n opt.on( '--[no-]preserve_paragraph', sprintf(\"Preserved paragraph structures? (Def: %s)\", OPTS[:preserve_paragraph].inspect), TrueClass) {|v| OPTS[:preserve_paragraph] = v}\n opt.on( '--lbs-style=STYLE', sprintf(\"One of (t(runcate)|d(elete)|n(one)) (Def: truncate).\", Symbol)) { |v| OPTS[:lbs_style]=v.strip[0].to_sym }\n # opt.on( '--version', \"Display the version and exits.\", TrueClass) {|v| OPTS[:version] = v} # Consider opts.on_tail\n opt.on( '--[no-]debug', \"Debug (Def: false)\", TrueClass) {|v| OPTS[:debug] = v}\n opt.separator \"\" # Way to control a help message.\n opt.separator \"Note:\"\n opt.separator \" Spaces are truncated in default.\"\n\n opt.parse!(ARGV)\n\n OPTS[:lbs_style] = OPTS[:lbs_style].to_s[0].to_sym\n unless %i(t d n).include? OPTS[:lbs_style]\n warn \"ERROR: --lbs-style must be one of (t(runcate)|d(elete)|n(one)), but given (#{OPTS[:lbs_style].inspect})\"; exit 1\n end\n\n OPTS\nend", "def initialize(args)\n\t\t\t\t# Initialize types\n\t\t\t\t@@valid_types = {bool: [], string: [String, \"\"], int: [Integer, 0], float: [Float, 0.0], choice: [String, \"\"], list: [Array, []], action: []}\n\n\t\t\t\t# Copy arguments\n\t\t\t\t@app_name = args[:name]\n\t\t\t\t@app_version = args[:version]\n\t\t\t\t@description = args[:description]\n\t\t\t\t@usage = args[:usage]\n\n\t\t\t\t# Copy messages\n\t\t\t\tmessages = args[:messages] || {}\n\t\t\t\tif messages.is_a?(Hash) then\n\t\t\t\t\t@messages = messages\n\t\t\t\telse\n\t\t\t\t\t@console.fatal(msg: \"CowtechLib::OptionParser::initialize msgs argument must be an hash.\")\n\t\t\t\tend\n\n\t\t\t\t# Initialize variables\n\t\t\t\t@console = Console.new\n\t\t\t\t@inserted = {name: [], short: [], long: []}\n\t\t\t\t@options = {}\n\t\t\t\t@options_map = {}\n\t\t\t\t@args = []\n\t\t\t\t@cmdline = ARGV.clone\n\n\t\t\t\tself << {name: \"help\", short: \"-h\", long: \"--help\", type: :bool, help: \"Show this message.\", priority: 1000}\n\t\t\tend", "def parse(argv)\n parser, options = parse_main(argv)\n\n # Options that are mutually-exclusive with everything else.\n options = {:help => true} if options[:help]\n options = {:version => true} if options[:version]\n\n validate_options!(options)\n\n @options = options\n @help_text = parser.to_s\n\n self\n end", "def check_command_line\n if (!ARGV[0].nil? && ARGV[0].downcase == \"test\")\n @test = true\n elsif(ARGV.length < 2)\n puts \"USAGE: ruby main.rb <users_csv_file> <businesses_csv_file>\"\n puts \"OR\"\n puts \"USAGE: ruby main.rb test\"\n exit 1\n end\nend", "def interpret(argv)\n handle_exceptions { \n @argv = argv.dup\n @program, @args = Interpreter.interpret(grammar, argv, float: float, exception: exception)\n\n # Process standard options (that may have been renamed)\n if @program.__send__(:\"#{@help_option.ident}?\")\n if @program[:help].name =~ /^--/\n ShellOpts.help\n else\n ShellOpts.brief\n end\n exit\n elsif @program.__send__(:\"#{@version_option.ident}?\")\n puts version_number\n exit\n else\n @program.__quiet__ = @program.__send__(:\"#{@quiet_option.ident}?\") if @quiet\n @program.__verbose__ = @program.__send__(:\"#{@verbose_option.ident}\") if @verbose\n @program.__debug__ = @program.__send__(:\"#{@debug_option.ident}?\") if @debug\n end\n }\n self\n end", "def run\n @action = @argv[0] || @app_default_action\n @action = @action.downcase\n\n\n ret = 0\n @argv.shift\n if respond_to? @action\n ret = send(@action, @argv)\n else\n # check aliases\n if check_aliases @action, @argv\n ret = send(@action, @argv)\n else\n help @argv\n ret = ERRCODE\n end\n end\n ret ||= 0\n ret = 0 if ret != ERRCODE\n return ret\n end", "def checkCommandLine\r\n if ARGV.length != 2\r\n puts \"\\nUsage: sum <fileName> <numThreads>\\n\\n\"\r\n exit(1)\r\n end\r\nend", "def run(argv)\n Bgo::Application::Service.startup_services(self)\n\n rv = 0\n if @interactive\n run_interactive\n else\n cmd_name = argv.shift\n cmd = get_command cmd_name\n rv = cmd ? run_command( cmd, argv ) : -1\n end\n\n Bgo::Application::Service.shutdown_services(self)\n exit rv\n end", "def parse_command_line args\n args.options do |opt|\n opt.on(\"rutema v#{Version::STRING}\")\n opt.on(\"Options:\")\n opt.on(\"--config FILE\", \"-c FILE\",String,\"Loads the configuration from FILE\") { |config_file| @config_file=config_file}\n opt.on(\"--check\",\"Runs just the suite setup test\"){@check=true}\n #opt.on(\"--step\",\"Runs test cases step by step\"){@step=true}\n opt.on(\"--silent\",\"Suppresses console output (only for the default reporters)\") { @silent=true}\n opt.on(\"--bare\",\"No default reporters whatsoever\") { @bare=true}\n #opt.on(\"--color\",\"Adds color to the Console reporter\") { @color=true}\n opt.on(\"-v\", \"--version\",\"Displays the version\") { $stdout.puts(\"rutema v#{Version::STRING}\");exit 0 }\n opt.on(\"--help\", \"-h\", \"-?\", \"This text\") { $stdout.puts opt; exit 0 }\n opt.on(\"--debug\", \"-d\", \"Turn on debug messages\") { $DEBUG=true }\n opt.on(\"You can provide a specification filename in order to run a single test\")\n opt.parse!\n #and now the rest\n unless @config_file\n puts \"No configuration file defined!\\n\"\n $stdout.puts opt \n exit 1\n end\n if !args.empty?\n @test_identifier=args.shift\n end\n end\n end", "def process_argv!\n args = ARGV.dup\n self.rest = []\n until args.empty? do\n arg = args.shift\n case\n when arg == '--'\n self.rest += args\n break\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n param.gsub!(/\\-/, '.') # translate --scoped-flag to --scoped.flag\n param = param.to_sym unless (param =~ /\\./) # symbolize non-scoped keys\n if val == nil then val = true # --flag option on its own means 'set that option'\n elsif val == '' then val = nil end # --flag='' the explicit empty string means nil\n self[param] = val\n when arg =~ /\\A-(\\w+)\\z/\n $1.each_char do |flag|\n param = param_with_flag(flag)\n self[param] = true if param\n end\n else\n self.rest << arg\n end\n end\n end", "def run(argv = ARGV)\n parser.parse(argv)\n end", "def main(command_line_options=ARGV)\n parser = Slop::Parser.new cli_flags\n arguments = parse_arguments(command_line_options, parser)\n\n if arguments.key?(:ce) || arguments.key?(:ci) || arguments.key?(:h)\n if arguments.key?(:ci)\n\n end\n if arguments.key?(:ce)\n\n end\n if arguments.key?(:h)\n puts cli_flags\n end\n exit\n end\n\n elsif set?(arguments, :port)\n puts portquiz arguments[:port]\n elsif set?(arguments, :down)\n puts is_it_up arguments[:down]\n end", "def parse!(argv=ARGV, opts={})\n command = argv.shift\n case command\n when '--version', '-v'\n puts \"Aladdin #{Aladdin::VERSION}\"\n exit 0\n when nil, '--help', '-h'\n puts File.read USAGE\n exit 0\n else\n require_relative 'commands/new'\n require_relative 'commands/server'\n send command, argv, opts\n end\n rescue => e\n puts e.message\n puts File.read USAGE\n exit 1\n end", "def run(argv = [])\n @options.parse!(argv)\n\n @rackup = argv.delete_at(0)\n @rackup = File.join(Dir.pwd, 'config.ru') if @rackup.nil?\n\n if File.directory?(@rackup)\n @rackup = File.join(@rackup, 'config.ru')\n end\n\n if !File.exist?(@rackup)\n abort \"The Rackup file #{@rackup} does not exist\"\n end\n\n stop = Ramaze::Bin::Runner::Commands[:stop].new\n start = Ramaze::Bin::Runner::Commands[:start].new\n params = [@rackup]\n\n unless @pid.nil?\n params.push(\"-P #{@pid}\")\n end\n\n stop.run([@pid])\n start.run(params)\n end", "def parse!(argv)\n\t\t$log.debug(\"#{self.class}.#{__method__}('#{argv.join(\" \")}'#{block_given? ? ',&block' : ''})\")\n\t\tif (argv.size == 0)\n\t\t\traise OptionParser::InvalidArgument, \"No arguments specified.\"\n\t\tend\n\n\t\t# @options is used to store recognized command-line args\n\t\t@options = Hash.new\n\t\twhile arg = argv.shift\n\t\t\tcase arg\n\t\t\twhen \"-cmd\"\n\t\t\t\t@command = argv.shift\n\t\t\twhen \"-debug\"\n\t\t\t\t$log.level = Logger::DEBUG\n\t\t\t\t$logerr.level = Logger::DEBUG\n\t\t\twhen \"-opt\"\n\t\t\t\t@options[:dataset] = argv.shift\n\t\t\twhen \"-path\"\n\t\t\t\t@options[:path] = argv.shift\n\t\t\twhen \"-target\"\n\t\t\t\t@options[:target] = argv.shift\n\t\t\twhen \"-log\"\n\t\t\t\tlevel = $log.level\n\t\t\t\tlog_path = argv.shift\n\t\t\t\t$log = Logger.new(log_path)\n\t\t\t\t$log.level = level\n\t\t\t\t$logerr = Logger.new(log_path)\n\t\t\t\t$logerr.level = level\n\t\t\telse\n\t\t\t\targv.unshift(arg)\n\t\t\t\tif block_given?\n\t\t\t\t\tunless (argv = yield(argv))\n\t\t\t\t\t\traise OptionParser::InvalidArgument, \"Unknown argument.\"\n\t\t\t\t\tend\n\t\t\t\telse break\n\t\t\t\tend\n\t\t\tend\t\t\n\t\tend\n\t\traise OptionParser::InvalidArgument, \"No command specified.\" unless @command\n\t\tunless (self.class::COMMANDS.include?(@command) && self.respond_to?(@command))\n\t\t\traise OptionParser::InvalidArgument, \"Unknown command '#{@command}' specified.\"\n\t\tend\n\t\treturn argv\n\tend", "def parse_main(argv)\n defaults = {\n report: Inq::DEFAULT_REPORT_FILE,\n }\n\n opts = Okay::SimpleOpts.new(defaults: defaults)\n\n opts.banner = <<~EOF\n Usage: inq --repository REPOSITORY --date REPORT_DATE [--output REPORT_FILE]\n inq --config CONFIG_FILE --date REPORT_DATE\n EOF\n\n opts.separator \"\\nOptions:\"\n\n opts.simple(\"--config CONFIG_FILE\",\n \"YAML config file for automated reports.\",\n :config)\n\n opts.simple(\"--no-user-config\",\n \"Don't load user configuration file.\",\n :no_user_config)\n\n opts.simple(\"--env-config\",\n \"Use environment variables for configuration.\",\n \"Read this first: https://inqrb.com/config\",\n :env_login)\n\n opts.simple(\"--repository USER/REPO\", REPO_REGEXP,\n \"Repository to generate a report for.\",\n :repository)\n\n opts.simple(\"--date YYYY-MM-DD\", DATE_REGEXP, \"Last date of the report.\",\n :date)\n\n opts.simple(\"--start-date YYYY-MM-DD\", DATE_REGEXP, \"Start date of the report.\",\n :start_date)\n\n opts.simple(\"--end-date YYYY-MM-DD\", DATE_REGEXP, \"Last date of the report.\",\n :end_date)\n\n opts.simple(\"--output REPORT_FILE\", format_regexp,\n \"Output file for the report.\",\n \"Supported file formats: #{formats}.\",\n :report)\n\n opts.simple(\"--verbose\", \"Print debug information.\", :verbose)\n opts.simple(\"-v\", \"--version\", \"Prints version information.\", :version)\n opts.simple(\"-h\", \"--help\", \"Print help text.\", :help)\n\n [opts, opts.parse(argv)]\n end", "def run(argv)\n _run(argv)\n rescue Quickl::Error => ex\n handle_error(ex)\n end", "def parse_args(argv = ARGV)\n @configuration ||= {}\n # Our primary configuration hash for the length of this method\n options = {}\n\n # Environment variables always win\n options[:environment] = ENV[\"MERB_ENV\"] if ENV[\"MERB_ENV\"]\n \n # Build a parser for the command line arguments\n opts = OptionParser.new do |opts|\n opts.version = Merb::VERSION\n\n opts.banner = \"Usage: merb [uGdcIpPhmailLerkKX] [argument]\"\n opts.define_head \"Merb. Pocket rocket web framework\"\n opts.separator '*' * 80\n opts.separator \"If no flags are given, Merb starts in the \" \\\n \"foreground on port 4000.\"\n opts.separator '*' * 80\n\n opts.on(\"-u\", \"--user USER\", \"This flag is for having merb run \" \\\n \"as a user other than the one currently logged in. Note: \" \\\n \"if you set this you must also provide a --group option \" \\\n \"for it to take effect.\") do |user|\n options[:user] = user\n end\n\n opts.on(\"-G\", \"--group GROUP\", \"This flag is for having merb run \" \\\n \"as a group other than the one currently logged in. Note: \" \\\n \"if you set this you must also provide a --user option \" \\\n \"for it to take effect.\") do |group|\n options[:group] = group\n end\n\n opts.on(\"-d\", \"--daemonize\", \"This will run a single merb in the \" \\\n \"background.\") do |daemon|\n options[:daemonize] = true\n end\n \n opts.on(\"-N\", \"--no-daemonize\", \"This will allow you to run a \" \\\n \"cluster in console mode\") do |no_daemon|\n options[:daemonize] = false\n end\n\n opts.on(\"-c\", \"--cluster-nodes NUM_MERBS\", Integer, \n \"Number of merb daemons to run.\") do |nodes|\n options[:daemonize] = true unless options.key?(:daemonize)\n options[:cluster] = nodes\n end\n\n opts.on(\"-I\", \"--init-file FILE\", \"File to use for initialization \" \\\n \"on load, defaults to config/init.rb\") do |init_file|\n options[:init_file] = init_file\n end\n\n opts.on(\"-p\", \"--port PORTNUM\", Integer, \"Port to run merb on, \" \\\n \"defaults to 4000.\") do |port|\n options[:port] = port\n end\n\n opts.on(\"-o\", \"--socket-file FILE\", \"Socket file to run merb on, \" \\\n \"defaults to [Merb.root]/log/merb.sock. This is for \" \\\n \"web servers, like thin, that use sockets.\" \\\n \"Specify this *only* if you *must*.\") do |port|\n options[:socket_file] = port\n end\n\n opts.on(\"-s\", \"--socket SOCKNUM\", Integer, \"Socket number to run \" \\\n \"merb on, defaults to 0.\") do |port|\n options[:socket] = port\n end\n\n opts.on(\"-n\", \"--name NAME\", String, \"Set the name of the application. \"\\\n \"This is used in the process title and log file names.\") do |name|\n options[:name] = name\n end\n\n opts.on(\"-P\", \"--pid PIDFILE\", \"PID file, defaults to \" \\\n \"[Merb.root]/log/merb.main.pid for the master process and\" \\\n \"[Merb.root]/log/merb.[port number].pid for worker \" \\\n \"processes. For clusters, use %s to specify where \" \\\n \"in the file merb should place the port number. For \" \\\n \"instance: -P myapp.%s.pid\") do |pid_file|\n options[:pid_file] = pid_file\n end\n\n opts.on(\"-h\", \"--host HOSTNAME\", \"Host to bind to \" \\\n \"(default is 0.0.0.0).\") do |host|\n options[:host] = host\n end\n\n opts.on(\"-m\", \"--merb-root /path/to/approot\", \"The path to the \" \\\n \"Merb.root for the app you want to run \" \\\n \"(default is current working directory).\") do |root|\n options[:merb_root] = File.expand_path(root)\n end\n\n adapters = [:mongrel, :emongrel, :thin, :ebb, :fastcgi, :webrick]\n\n opts.on(\"-a\", \"--adapter ADAPTER\",\n \"The rack adapter to use to run merb (default is mongrel)\" \\\n \"[#{adapters.join(', ')}]\") do |adapter|\n options[:adapter] ||= adapter\n end\n\n opts.on(\"-R\", \"--rackup FILE\", \"Load an alternate Rack config \" \\\n \"file (default is config/rack.rb)\") do |rackup|\n options[:rackup] = rackup\n end\n\n opts.on(\"-i\", \"--irb-console\", \"This flag will start merb in \" \\\n \"irb console mode. All your models and other classes will \" \\\n \"be available for you in an irb session.\") do |console|\n options[:adapter] = 'irb'\n end\n\n opts.on(\"-S\", \"--sandbox\", \"This flag will enable a sandboxed irb \" \\\n \"console. If your ORM supports transactions, all edits will \" \\\n \"be rolled back on exit.\") do |sandbox|\n options[:sandbox] = true\n end\n\n opts.on(\"-l\", \"--log-level LEVEL\", \"Log levels can be set to any of \" \\\n \"these options: debug < info < warn < error < \" \\\n \"fatal (default is info)\") do |log_level|\n options[:log_level] = log_level.to_sym\n options[:force_logging] = true\n end\n\n opts.on(\"-L\", \"--log LOGFILE\", \"A string representing the logfile to \" \\\n \"use. Defaults to [Merb.root]/log/merb.[main].log for the \" \\\n \"master process and [Merb.root]/log/merb[port number].log\" \\\n \"for worker processes\") do |log_file|\n options[:log_file] = log_file\n options[:force_logging] = true\n end\n\n opts.on(\"-e\", \"--environment STRING\", \"Environment to run Merb \" \\\n \"under [development, production, testing] \" \\\n \"(default is development)\") do |env|\n options[:environment] = env\n end\n\n opts.on(\"-r\", \"--script-runner ['RUBY CODE'| FULL_SCRIPT_PATH]\",\n \"Command-line option to run scripts and/or code in the \" \\\n \"merb app.\") do |code_or_file|\n options[:runner_code] = code_or_file\n options[:adapter] = 'runner'\n end\n\n opts.on(\"-K\", \"--graceful PORT or all\", \"Gracefully kill one \" \\\n \"merb proceses by port number. Use merb -K all to \" \\\n \"gracefully kill all merbs.\") do |ports|\n options[:action] = :kill\n ports = \"main\" if ports == \"all\"\n options[:port] = ports\n end\n\n opts.on(\"-k\", \"--kill PORT\", \"Force kill one merb worker \" \\\n \"by port number. This will cause the worker to\" \\\n \"be respawned.\") do |port|\n options[:action] = :kill_9\n port = \"main\" if port == \"all\"\n options[:port] = port\n end\n \n opts.on(\"--fast-deploy\", \"Reload the code, but not your\" \\\n \"init.rb or gems\") do\n options[:action] = :fast_deploy\n end\n\n # @todo Do we really need this flag? It seems unlikely to want to\n # change the mutex from the command-line.\n opts.on(\"-X\", \"--mutex on/off\", \"This flag is for turning the \" \\\n \"mutex lock on and off.\") do |mutex|\n if mutex == \"off\"\n options[:use_mutex] = false\n else\n options[:use_mutex] = true\n end\n end\n\n opts.on(\"-D\", \"--debugger\", \"Run merb using rDebug.\") do\n begin\n require \"ruby-debug\"\n Debugger.start\n\n # Load up any .rdebugrc files we find\n [\".\", ENV[\"HOME\"], ENV[\"HOMEPATH\"]].each do |script_dir|\n script_file = \"#{script_dir}/.rdebugrc\"\n Debugger.run_script script_file, StringIO.new if File.exists?(script_file)\n end\n\n if Debugger.respond_to?(:settings)\n Debugger.settings[:autoeval] = true\n end\n puts \"Debugger enabled\"\n rescue LoadError\n puts \"You need to install ruby-debug to run the server in \" \\\n \"debugging mode. With gems, use `gem install ruby-debug'\"\n exit\n end\n end\n\n opts.on(\"-V\", \"--verbose\", \"Print extra information\") do\n options[:verbose] = true\n end\n\n opts.on(\"-C\", \"--console-trap\", \"Enter an irb console on ^C\") do\n options[:console_trap] = true\n end\n\n opts.on(\"-?\", \"-H\", \"--help\", \"Show this help message\") do\n puts opts\n exit\n end\n end\n\n # Parse what we have on the command line\n begin\n opts.parse!(argv)\n rescue OptionParser::InvalidOption => e\n Merb.fatal! e.message, e\n end\n Merb::Config.setup(options)\n end", "def initialize(argv)\n @options = {\n :command => 'execute',\n :rpcname => nil,\n :verbose => false\n }\n @argv = argv.clone\n if @argv.first =~ /^[a-z0-9][a-z0-9_-]*$/i\n self.options[:command] = @argv.shift\n end\n if @argv.first =~ /^[a-z0-9_-]+\\.[a-z0-9_\\.-]+$/i\n self.options[:rpcname] = @argv.shift\n end\n end", "def process_options\n options.delete_if { |x,y| y.nil? }\n if options.empty?\n puts @optparse \n exit 0\n end\n options.each do |x,y|\n begin\n if y.to_s.match('^-')\n raise BoilerMakerErr.new(\"Bad args: \\\"#{y}\\\" is not a valid arg to option, \\\"--#{x}\\\". Use the -h flag for syntax help.\")\n end\n rescue => error\n puts error.message + \"\\n\"\n exit 1\n end\n end\n end", "def process_argv!\n args = ARGV.dup\n self.rest = []\n @unknown_argvs = []\n until args.empty? do\n arg = args.shift\n case\n # end of options parsing\n when arg == '--'\n self.rest += args\n break\n # --param=val or --param\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n warn \"Configliere uses _underscores not dashes for params\" if param.include?('-')\n @unknown_argvs << param.to_sym if (not has_definition?(param))\n self[param] = parse_value(val)\n # -abc\n when arg =~ /\\A-(\\w\\w+)\\z/\n $1.each_char do |flag|\n param = find_param_for_flag(flag)\n unless param then @unknown_argvs << flag ; next ; end\n self[param] = true\n end\n # -a val\n when arg =~ /\\A-(\\w)\\z/\n flag = find_param_for_flag($1)\n unless flag then @unknown_argvs << flag ; next ; end\n if (not args.empty?) && (args.first !~ /\\A-/)\n val = args.shift\n else\n val = nil\n end\n self[flag] = parse_value(val)\n # -a=val\n when arg =~ /\\A-(\\w)=(.*)\\z/\n flag, val = [find_param_for_flag($1), $2]\n unless flag then @unknown_argvs << flag ; next ; end\n self[flag] = parse_value(val)\n else\n self.rest << arg\n end\n end\n @unknown_argvs.uniq!\n end", "def run\n @arguments = ArgumentParser.get_arguments VALID_ARGUMENTS\n print_help if (@arguments[:options][:help])\n print_version if (@arguments[:options][:version])\n if (@arguments[:keywords][:export])\n handle_export\n elsif (@arguments[:keywords][:import])\n handle_import\n else\n print_help\n end\n end", "def initialize(argv)\n @metadata_files, @new_files, @existing_files = nil, nil, nil\n @invalid_metadata_files = []\n @invalid_packages = []\n @argv = argv\n @options = {}\n @exception = nil\n end", "def run \n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\"\n process_arguments(@validoptions.args)\n puts \"Finished at #{DateTime.now}\"\n else\n raise BoilerMakerErr.new(\"Could not parse options. An unknown error has ocurred.\")\n exit $!\n end\n end", "def initialize(argv)\n @max = 65535\n @ceil = nil\n @num = 3\n\n args = cli argv,\n '-n --num' => lambda{ |d| @num = d.to_i },\n '-m --max' => lambda{ |m| @max = m.to_i },\n '-s --sort' => lambda{ @sort = true },\n '-a --abs' => lambda{ @abs = true },\n '-c --ceil' => lambda{ |c| @ceil = c.to_i },\n '-d --debug' => lambda{ $DEBUG = true },\n '-h --help' => lambda{ show_help }\n\n @directory = args.first\n end", "def initialize(argv)\n $main_args, $sub_command, $sub_args = split_main_and_subcommand(argv, command_list)\n\n if $main_args.include? '--verbose'\n $logger.level = Logger::DEBUG\n end\n\n $logger.info(\"CLI Parsed Inputs: #{$main_args.inspect} #{$sub_command.inspect} #{$sub_args.inspect}\")\n end", "def initialize(argv=[])\n super()\n #@text = Text.new(STDOUT, STDERR, STDIN, config)\n @text ||= Megam::Text.new(STDOUT, STDERR, STDIN, config)\n command_name_words = self.class.snake_case_name.split('_')\n\n # Mixlib::CLI ignores the embedded name_args\n\n @name_args = parse_options(argv)\n\n @name_args.delete(command_name_words.join('-'))\n\n @name_args.reject! { |name_arg| command_name_words.delete(name_arg) }\n\n # meg node run_list add requires that we have extra logic to handle\n # the case that command name words could be joined by an underscore :/\n command_name_words = command_name_words.join('_')\n @name_args.reject! { |name_arg| command_name_words == name_arg }\n if config[:help]\n msg opt_parser\n exit 1\n end\n\n # copy Mixlib::CLI over so that it cab be configured in meg.rb\n # config file\n Meggy::Config[:verbosity] = config[:verbosity]\n end", "def initialize(*args)\n super(args.find{|s| s.is_a?(String)} || \"\")\n @exit_code = args.find{|s| s.is_a?(Integer)} || nil\n end", "def run(argv = ARGV)\n # => Parse the Params\n configure(argv)\n\n # => Launch the Controller\n Controller.run\n end", "def parse_options(argv)\n arguments = [\n [:rspec, \"--rspec\", \"RSpec mode\"],\n [:helper, \"--helper\", \"Helper file to load before tests start\", String],\n [:quiet, \"--quiet\", \"Quiet\"],\n [:no_fixtures, \"--no-fixtures\", \"Do not load fixtures\"],\n [:no_ar, \"--no-ar\", \"Disable ActiveRecord logic\"],\n [:merge_coverage, \"--merge-coverage\", \"Merge base code coverage into indvidual files coverage, great for SingleCov\"],\n [\n :record_runtime,\n \"--record-runtime=MODE\",\n \"\\n Record test runtime:\\n\" <<\n \" simple = write to disk at --runtime-log)\\n\" <<\n \" amend = write from multiple remote workers via http://github.com/grosser/amend, needs TRAVIS_REPO_SLUG & TRAVIS_BUILD_NUMBER\",\n String\n ],\n [:runtime_log, \"--runtime-log=FILE\", \"File to store runtime log in or runtime.log\", String],\n [:group, \"--group=NUM\", \"What group this is (use with --groups / starts at 1)\", Integer],\n [:groups, \"--groups=NUM\", \"How many groups there are in total (use with --group)\", Integer],\n [:version, \"--version\", \"Show version\"],\n [:help, \"--help\", \"Show help\"]\n ]\n\n options = arguments.each_with_object({}) do |(setting, flag, _, type), all|\n all[setting] = delete_argv(flag.split('=', 2)[0], argv, type: type)\n end\n\n # show version\n if options.fetch(:version)\n puts VERSION\n exit 0\n end\n\n # # show help\n if options[:help]\n parser = OptionParser.new(\"forking-test-runner folder [options]\", 32, '') do |opts|\n arguments.each do |_, flag, desc, type|\n opts.on(flag, desc, type)\n end\n end\n puts parser\n exit 0\n end\n\n # check if we can use merge_coverage\n if options.fetch(:merge_coverage)\n require 'coverage'\n abort \"merge_coverage does not work on Ruby prior to 2.3 due to the lack of the Coverage.peek_result method\" unless Coverage.method_defined?(:peek_result)\n klass = (class << Coverage; self; end)\n klass.prepend CoverageCapture\n end\n\n # all remaining non-flag options until the next flag must be tests\n next_flag = argv.index { |arg| arg.start_with?(\"-\") } || argv.size\n tests = argv.slice!(0, next_flag)\n abort \"No tests or folders found in arguments\" if tests.empty?\n tests.each { |t| abort \"Unable to find #{t}\" unless File.exist?(t) }\n\n [options, tests]\n end", "def run\n if !options_parsed?() || !options_valid?()\n @stderr.puts(\"\")\n output_usage(@stderr)\n return 1\n end\n return run_real()\nend", "def execute(opt, argv)\n fail \"#{self.class.command} not implemented\"\n end", "def run(arguments)\n config = Configuration.load_applicable\n run_command(config, arguments)\n\n ExitCodes::OK\n rescue => ex\n ErrorHandler.new(@ui).handle(ex)\n end", "def start(mode, argv = ARGV)\n # Set a cleaner process title\n Process.setproctitle(\"#{mode} #{argv.join(' ')}\")\n\n # Parse CLI arguments\n OptionParser.new do |parser|\n parser.banner = \"Usage: #{mode} [options]\"\n\n case mode\n when 'generate'\n add_generate_opt_parser_attrs(parser)\n when 'update_ood_portal'\n add_update_opt_parser_attrs(parser)\n end\n\n add_shared_opt_parser_attrs(parser)\n\n parser.separator ''\n parser.separator 'Default:'\n parser.separator \" #{mode} -c #{config} -t #{template}\"\n end.parse!(argv)\n\n # Render Apache portal config\n case mode\n when 'generate'\n generate\n when 'update_ood_portal'\n exitcode = update_ood_portal\n exit!(exitcode)\n end\n rescue StandardError => e\n warn \"#{e.class}:#{e.message}\"\n warn e.backtrace\n warn \"Run '#{mode} --help' to see a full list of available options.\"\n exit!(false)\n end", "def run(argv)\n arguments = parse(argv)\n return if @quit\n\n Wright.activate_dry_run if @dry_run\n Wright.log.level = @log_level if @log_level\n @main.extend Wright::DSL\n\n run_script(arguments)\n end", "def optparse!(argv) # rubocop:disable Metrics/MethodLength\n options = Options.new\n option_parser = OptionParser.new do |parser|\n parser.banner = \"Usage: #{parser.program_name} [options]\"\n parser.on('-hHOST', '--host=HOST', 'Coursemology host to connect to') do |host|\n options.host = host\n end\n\n parser.on('-tTOKEN', '--api-token=TOKEN') do |token|\n options.api_token = token\n end\n\n parser.on('-uUSER', '--api-user-email=USER') do |user|\n options.api_user_email = user\n end\n\n parser.on('-o', '--one-shot') do\n options.one_shot = true\n end\n end\n\n option_parser.parse!(argv)\n options\n end", "def parse(argv = [])\n @option_parser.parse!(argv)\n\n options.each do |option|\n if option.required? and !option.has_value?\n Shebang.error(\"The -#{option.short} option is required\")\n end\n end\n\n return argv\n end", "def initialize(argv)\n op = option_parser\n op.parse!(argv)\n check_options\n end", "def parse!(argv)\n begin \n @global_opts = @global_parser.parse(argv)\n rescue Trollop::HelpNeeded\n @global_parser.educate && exit \n end\n @global_parser.educate && exit unless argv.size > 0\n argv\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n process_arguments \n start\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end \n end", "def process_argv!\n super\n if raw_script_name =~ /(\\w+)-([\\w\\-]+)/\n self.command = $2\n else\n self.command = rest.shift\n end\n end", "def parse_opts\n if parse_argv\n apply_options\n true\n end\n end", "def parse_options!(argv)\n HighLine.use_color = false if !STDOUT.tty? && !ENV.has_key?(\"AUTOTEST\")\n\n OptionParser.new do |opts|\n opts.banner = \"Usage: montage [config file path] [options]\"\n\n opts.on('-c', '--[no-]color', '--[no-]colour',\n 'Enables and disables colour output.') do |color|\n HighLine.use_color = color\n end\n\n opts.on('-f', '--force',\n 'Regenerate sprites even if no changes have been made.') do\n Montage::Commands.config[:force] = true\n end\n\n # opts.on('-q', '--quiet',\n # 'Tell Montage to shut up. No messages sent to STDOUT.') do\n # Montage::Commands.config[:quiet] = true\n # end\n\n opts.on_tail(\"-h\", \"--help\", \"Shows this message.\") do\n say BLANK\n say opts.to_s\n exit\n end\n\n opts.on_tail(\"--version\", \"Print the current Montage version.\") do\n say BLANK\n say \"Montage v#{Montage::VERSION}\"\n exit\n end\n end.parse!(argv)\n\n argv\n end", "def command_line_info\n puts \"\\nCommand line arguments:\\n\\n\"\n puts \"This program will accept a single command line argument on launch. Arguments can be passed to draughts_app.rb directly or to draughts.sh\\n\"\n puts \"Example: draughts.sh --help\\n\\n\"\n puts \"-h or --help Display all command line arguments\"\n puts \"-i or --info Display instructions on how to play\"\n puts \"-v or --version Display current application and Ruby version\"\n puts \"start Skip menu and immediately start a new game\"\n puts \"wins Print win counts\"\n puts \"\"\nend", "def call(*args)\n puts parser.help\n exit 1\n end", "def initialize(argv = [])\n super() # having to call super in initialize is the most annoying anti-pattern :(\n @ui = Chef::Knife::UI.new(STDOUT, STDERR, STDIN, config)\n\n command_name_words = self.class.snake_case_name.split(\"_\")\n\n # Mixlib::CLI ignores the embedded name_args\n @name_args = parse_options(argv)\n @name_args.delete(command_name_words.join(\"-\"))\n @name_args.reject! { |name_arg| command_name_words.delete(name_arg) }\n\n # knife node run_list add requires that we have extra logic to handle\n # the case that command name words could be joined by an underscore :/\n command_name_joined = command_name_words.join(\"_\")\n @name_args.reject! { |name_arg| command_name_joined == name_arg }\n\n # Similar handling for hyphens.\n command_name_joined = command_name_words.join(\"-\")\n @name_args.reject! { |name_arg| command_name_joined == name_arg }\n\n if config[:help]\n msg opt_parser\n exit 1\n end\n\n # Grab a copy before config merge occurs, so that we can later identify\n # where a given config value is sourced from.\n @original_config = config.dup\n\n # copy Mixlib::CLI over so that it can be configured in config.rb/knife.rb\n # config file\n Chef::Config[:verbosity] = config[:verbosity] if config[:verbosity]\n end", "def initialize(argv = [])\n @arguments ||= argv\n @theme ||= cli.ec2_tag_theme\n @host ||= cli.host\n @domain ||= cli.domain\n end", "def validate_arguments()\n usage unless ARGV.count > 0\nend", "def initialize(argv=ARGV)\n #begin\n # require 'dotopts'\n #rescue LoadError\n #end\n\n @argv = Array(argv || ARGV)\n\n @script = nil\n @watch = nil\n @fresh = false\n end", "def run(args)\n ret = DEFAULTS.merge({})\n\n # create option parser\n o = ::OptionParser.new do |o|\n o.banner = \"Usage: #@app [options]\"\n o.separator \" \"\n\n # add command-line options\n o.separator \"Options:\"\n\n o.on('-A', '--allow USER', 'Allow Jabber subscription from USER.') do |v|\n add_allowed(ret, v)\n end\n\n o.on('-c', '--config FILE', 'Use configuration file FILE.') do |v|\n Joggle::ConfigParser.run(v) do |key, val|\n if key == 'engine.allow'\n add_allowed(ret, val)\n elsif key == 'engine.update.range'\n add_update_range(ret, val)\n else\n ret[key] = val\n end\n end\n end\n\n o.on('-D', '--daemon', 'Run as daemon (in background).') do |v|\n ret['cli.daemon'] = true\n end\n\n o.on('--foreground', 'Run in foreground (the default).') do |v|\n ret['cli.daemon'] = false\n end\n\n o.on('-L', '--log-level LEVEL', 'Set log level to LEVEL.') do |v|\n ret['runner.log.level'] = v\n end\n\n o.on('-l', '--log FILE', 'Log to FILE.') do |v|\n ret['runner.log.path'] = v\n end\n\n o.on('-p', '--password PASS', 'Jabber password (INSECURE!).') do |v|\n ret['jabber.pass'] = v\n end\n\n o.on('-s', '--store FILE', 'Use FILE as backing store.') do |v|\n ret['runner.store.path'] = v\n end\n\n o.on('-u', '--username USER', 'Jabber username.') do |v|\n ret['jabber.user'] = v\n end\n\n o.separator ' '\n\n o.on_tail('-v', '--version', 'Print version string.') do\n puts \"Joggle %s, by %s\" % [\n Joggle::VERSION,\n 'Paul Duncan <pabs@pablotron.org>',\n ]\n exit\n end\n\n o.on_tail('-h', '--help', 'Print help information.') do\n puts o\n exit\n end\n end\n\n # parse arguments\n o.parse(args)\n\n # return results\n ret\n end", "def run(argv)\n arguments = parse(argv)\n return if quit\n\n Wright.activate_dry_run if dry_run\n Wright.log.level = log_level if log_level\n main.extend Wright::DSL\n requires.each { |r| require r }\n\n run_script(arguments)\n end", "def processCommandLineOptions\n if ARGV\n ARGV.each do |arg|\n if arg.index('=')\n setting, value = arg.split('=')\n setting = setting.chomp\n value = value.chomp.strip\n if setting == 'logLevel'\n value = value.upcase.gsub(/\\'/,'')\n level = LEVELS_TEXT.index(value.upcase)\n @currentLogLevel = level if level\n elsif setting == 'consoleLogging'\n @consoleLogging = value.downcase == 'true'\n elsif setting == 'logfile'\n @currentFileName = File.expand_path(value)\n end\n end\n end\n end\n end", "def run\n if arguments = parse_arguments\n begin\n process(arguments)\n rescue RuntimeError => ex\n Console.puts ex.message, :red\n exit 1\n end\n else\n if show_help?\n show_help(nil, Console.width).each do |line|\n Console.puts line, :cyan\n end\n else\n show_usage(nil, Console.width).each do |line|\n Console.puts line, :yellow\n end\n end\n exit 2\n end\n end", "def parse_catchall\n bail_args(@argv.join(' ')) if(@argv.length != 0)\n end", "def options(argv = ARGV)\n return @options if @options\n\n @options = Options::DEFAULT.dup\n\n opts = OptionParser.new do |opts|\n opts.banner =\n \"nopaste.rb - send text to http://rafb.net/paste\\n\" \\\n \"Usage: nopaste.rb [options] [file(s)]\"\n\n opts.separator \"Options:\"\n\n opts.on(\"-l\", \"--lang LANGUAGE\", Options::LIST[:lang],\n \"Language of snippet (default #{Options::DEFAULT[:lang]})\",\n *Options::LIST[:lang].join(\", \").split(/(?=PL)/)) do |lang|\n @options[:lang] = lang\n end\n opts.on(\"-n\", \"--nick NICKNAME\", \"Your nickname (9 char max)\") do |nick|\n @options[:nick] = nick[0, 9]\n end\n opts.on(\"-d\", \"--desc DESCRIPTION\",\n \"Description of the snippet (50 char max)\") do |desc|\n @options[:desc] = desc[0, 50]\n end\n opts.on(\"-t\", \"--cvt-tabs [SPACES]\", Options::LIST[:cvt_tabs],\n \"Convert tabs to spaces (default #{Options::DEFAULT[:cvt_tabs]})\",\n *Options::LIST[:cvt_tabs].join(\", \")) do |spaces|\n @options[:cvt_tabs] = spaces || \"8\"\n end\n opts.on(\"-u\", \"--rubyurl\",\n \"Shorten the URL using rubyurl.com\") do |rubyurl|\n @options[:rubyurl] = rubyurl\n end\n opts.on(\"-a\", \"--agree-to-terms\",\n \"Agree to the Terms of Use (mandatory)\") do |agree|\n @options[:agree_to_terms] = agree\n end\n opts.on_tail(\"-s\", \"--show-terms\", \"Show the Terms of Use\") do\n puts terms\n exit\n end\n opts.on_tail(\"-h\", \"--help\", \"Show this message\") do\n puts opts\n exit\n end\n end\n\n begin\n opts.parse! argv\n rescue OptionParser::ParseError => e\n STDERR.puts e, opts\n exit\n end\n\n unless @options[:agree_to_terms]\n STDERR.puts \"missing mandatory argument: --agree-to-terms\", opts\n exit\n end\n\n @options\n end", "def parse argv\n parse_args argv do |argv, remaining_args, arg|\n remaining_args << arg\n end\n end", "def execute(args)\n raise BadUsageError.new(self) unless (args.length == 1) \n\n puts \"Adding [#{args.first}] to Railcar...\"\n if RCApplicationManager.new.add(args.first)\n puts \"Done!\"\n else\n puts\n puts \"That path (#{args.first}) doesn't appear to exist or be a Rails application.\"\n puts \"Make sure you've got the path right!\"\n puts\n end\n end", "def parse_argv(argv)\n # command line\n options = {}\n OptionParser.new do |opts|\n options[:queue_name] = nil\n opts.banner = \"Usage: #{__FILE__} [options]\"\n\n opts.on('-c', '--config CONFIG_FILE', 'config file') do |c|\n options[:file_name] = c\n end\n opts.on('-q', '--queue QUEUE', 'queue to be consumed') do |q|\n options[:queue_name] = q\n end\n end.parse!\n @options = options\n end", "def parse!(argv)\n # Set default values from the environment\n opts = Options.from_env(ENV)\n\n parser = OptionParser.new do |p|\n p.banner = \"Usage: #{$PROGRAM_NAME} [options]\"\n\n p.on(\"--help\", \"Display this help\") do\n puts p\n exit 0\n end\n\n p.on(\"--debug\", \"Enable debug level logging\") do\n opts.debug = true\n end\n\n p.on(\"--foreman-username=NAME\", \"The foreman username, default: env FOREMAN_USERNAME\") do |name|\n opts.foreman[:foreman_username] = name\n end\n\n p.on(\"--foreman-password=PASSWORD\", \"The foreman password, default: env FOREMAN_PASSWORD\") do |password|\n opts.foreman[:foreman_password] = password\n end\n\n p.on(\"--foreman-url=NAME\", \"The foreman base URL, default: env FOREMAN_URL\") do |url|\n opts.foreman[:foreman_url] = url\n end\n\n p.on(\"--ssl-ca-file=FILE\", \"The Foreman CA certificate bundle, default: env SSL_CA_FILE\") do |file|\n opts.foreman[:ssl_ca_file] = file\n end\n\n p.on(\"--k8s-credentials=CREDENTIALS\", \"The Kubernetes credentials source\") do |value|\n opts.k8s[:k8s_credentials] = value\n end\n\n p.on(\"--k8s-namespace=NAMESPACE\", \"The Kubernetes namespace\") do |value|\n opts.k8s[:k8s_namespace] = value\n end\n\n p.on(\"--k8s-configmap=CONFIGMAP\", \"The Kubernetes configmap\") do |value|\n opts.k8s[:k8s_configmap] = value\n end\n\n p.on(\"--k8s-configmap-key=KEY\", \"The Kubernetes configmap key\") do |value|\n opts.k8s[:k8s_configmap_key] = value\n end\n\n p.on(\"--k8s-deployment=DEPLOYMENT\", \"The Kubernetes deployment\") do |value|\n opts.k8s[:k8s_deployment] = value\n end\n\n p.on(\"--k8s-volume=VOLUME\", \"The Kubernetes deployment volume\") do |value|\n opts.k8s[:k8s_volume] = value\n end\n\n p.on(\"--formatter-name=FORMATTER\", \"The telegraf config formatter\") do |value|\n opts.formatter[:formatter_name] = value\n end\n\n p.on(\"--formatter-options=FORMATTER\", \"The telegraf config formatter options\") do |value|\n opts.formatter[:formatter_options] = value\n end\n end\n\n # Populate values from the CLI\n parser.parse!(argv)\n\n if (errors = opts.validate!).any?\n abort \"Missing configuration:\\n#{errors.map { |e| \" #{e}\" }.join(\"\\n\")}\"\n end\n opts\nend", "def command_parse(argv)\n end", "def run!(options = {})\n run_option_parser.parse!(ARGV.dup) unless ARGV.empty?\n @running = true\n super(options)\n end", "def run\n begin\n process_arguments\n rescue ArgumentError\n output_usage\n end\n end", "def parse arguments\n begin\n @option_parser.parse! arguments\n rescue StandardError => e\n puts @option_parser\n puts\n puts e.message\n exit(-1)\n end\n\n @options\n end", "def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end", "def execute(sub_argv)\n require 'rubygems'\n\n $logger.info \"GemList, sub_argv = #{sub_argv}\"\n\n options = {}\n\n # Parse the options\n opts = OptionParser.new do |o|\n o.banner = 'Usage: openstudio gem_list'\n end\n argv = parse_options(opts, sub_argv)\n return 0 if argv == nil\n\n $logger.debug(\"GemList command: #{argv.inspect} #{options.inspect}\")\n\n unless argv == []\n $logger.error 'Extra arguments passed to the gem_list command. Please refer to the help documentation.'\n return 1\n end\n\n begin\n embedded = []\n user = []\n Gem::Specification.find_all.each do |spec|\n if spec.gem_dir.chars.first == ':'\n embedded << spec\n else\n user << spec\n end\n end\n\n embedded.each do |spec|\n safe_puts \"#{spec.name} (#{spec.version}) '#{spec.gem_dir}'\"\n end\n\n user.each do |spec|\n safe_puts \"#{spec.name} (#{spec.version}) '#{spec.gem_dir}'\"\n end\n\n rescue => e\n $logger.error \"Error listing gems: #{e.message} in #{e.backtrace.join(\"\\n\")}\"\n exit e.exit_code\n end\n\n 0\n end", "def parse_initial_options argv\n parse_args argv do |argv, remaining_args, arg|\n argv.unshift arg\n :break\n end\n end", "def initialize(*args, &block)\n @appconf = TSC::Dataset[\n :script => $0,\n :subcommand => nil,\n :arguments => TSC::Dataset[ :usage => nil, :description => nil ],\n :options => [],\n :description => nil,\n :examples => nil,\n :verbose => nil,\n :backtrace => nil\n ]\n block.call @appconf if block\n\n location, name = File.split File.expand_path(@appconf.script)\n @script_location = location\n @script_name = name.sub %r{[.]rb.*$}i, ''\n\n $: << script_location\n\n if String === args.first && TSC::Dataset === @appconf.arguments && @appconf.arguments.usage.nil?\n @appconf.arguments.usage = args.shift\n end\n\n @registry = OptionRegistry.new\n @subregistry = OptionRegistry.new\n\n @registry.add 'verbose', 'Turns verbose mode on', nil, 'v'\n @registry.add 'backtrace', 'Outputs exception backtrace on error', nil, '--bt'\n @registry.add 'help', 'Prints out this help message', nil, 'h', '?'\n @registry.add 'debug', 'Starts the interactive debugger', nil\n\n @registry.add_bulk *args\n @registry.add_bulk *Array(@appconf.options)\n\n @options = TSC::Options.new @registry.entries\n\n ENV['TRACE'].to_s.split.include?(script_name).tap do |_trace|\n options.verbose = @appconf.verbose || _trace\n options.backtrace = @appconf.backtrace || _trace\n end\n end", "def invoke(argv)\n system(\n argv.join(' ')\n )\n end" ]
[ "0.7565795", "0.69048387", "0.68647856", "0.68382984", "0.67724186", "0.6733345", "0.6711474", "0.66102684", "0.65572083", "0.6534257", "0.65159637", "0.6473957", "0.6469824", "0.6443771", "0.6437997", "0.64216685", "0.64182794", "0.64128083", "0.64062244", "0.6402456", "0.63873273", "0.6364523", "0.6357478", "0.63526165", "0.63399076", "0.6339888", "0.6267409", "0.62666583", "0.62658584", "0.6256061", "0.6253741", "0.62514925", "0.62476546", "0.62331325", "0.6213781", "0.6213311", "0.6202342", "0.6200519", "0.61986613", "0.6163088", "0.61575705", "0.61520255", "0.61482257", "0.614296", "0.6127451", "0.6113849", "0.61106193", "0.61105263", "0.610933", "0.61074615", "0.61011827", "0.60967964", "0.6093944", "0.6089882", "0.6077659", "0.6070908", "0.6061322", "0.6059705", "0.6043224", "0.6038664", "0.60368556", "0.6036657", "0.6031634", "0.6015623", "0.60037154", "0.6003666", "0.5994529", "0.59911805", "0.59836966", "0.597721", "0.59742826", "0.5971429", "0.59690475", "0.59591067", "0.5959072", "0.5957145", "0.59480804", "0.593535", "0.5925119", "0.5920294", "0.59082323", "0.59063315", "0.5901455", "0.5900197", "0.58879286", "0.5884133", "0.58841044", "0.5880765", "0.58787066", "0.5870847", "0.586638", "0.5862397", "0.58299935", "0.58291286", "0.58219576", "0.5816419", "0.5812573", "0.5812156", "0.5809906", "0.58006644" ]
0.7791449
0
=== Description Parse options, and run the main method === Returns (Integer) exit code
def run code = 0 opt = OptionParser.new define_options(opt) default_options(opt) define_exit_codes(opt) argv = opt.parse! if @help puts_msg(opt.help) else begin main(argv) rescue Exception => e arr = @@exit_code_map[e.class] code = arr ? arr[0] : 1 puts_err e.to_s puts_err "[ERROR]" end end exit(code) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n if !options_parsed?() || !options_valid?()\n @stderr.puts(\"\")\n output_usage(@stderr)\n return 1\n end\n return run_real()\nend", "def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n raise e if e.is_a?(SystemExit)\n\n $stderr.puts e.message\n exit 1\n end\n exit 0\n end", "def main(command_line_options=ARGV)\n parser = Slop::Parser.new cli_flags\n arguments = parse_arguments(command_line_options, parser)\n\n if arguments.key?(:ce) || arguments.key?(:ci) || arguments.key?(:h)\n if arguments.key?(:ci)\n\n end\n if arguments.key?(:ce)\n\n end\n if arguments.key?(:h)\n puts cli_flags\n end\n exit\n end\n\n elsif set?(arguments, :port)\n puts portquiz arguments[:port]\n elsif set?(arguments, :down)\n puts is_it_up arguments[:down]\n end", "def run\n input = OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n\n opts.on(\"--debug\", \"Turn on debugging output.\") do |debug|\n $DEBUG = @options[:debug] = debug\n end\n\n opts.on(\"-n <path>\", \"--new\", \"Create a new Corrupt application.\") do |path|\n @options[:path] = path\n end\n\n opts.on(\"-v\", \"--version\", \"Print the version.\") do |v|\n output(Corrupt.to_version)\n exit\n end\n end\n\n begin\n @argv << '--help' if @argv.empty?\n input.parse!(@argv)\n take_action!\n rescue OptionParser::InvalidOption => error\n error(\"#{error}\\nTry passing '--help'\")\n rescue OptionParser::MissingArgument => error\n error(\"#{error}\\nTry passing '--help'\")\n end\n end", "def run \n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\"\n process_arguments(@validoptions.args)\n puts \"Finished at #{DateTime.now}\"\n else\n raise BoilerMakerErr.new(\"Could not parse options. An unknown error has ocurred.\")\n exit $!\n end\n end", "def parse_command_line args\n args.options do |opt|\n opt.on(\"rutema v#{Version::STRING}\")\n opt.on(\"Options:\")\n opt.on(\"--config FILE\", \"-c FILE\",String,\"Loads the configuration from FILE\") { |config_file| @config_file=config_file}\n opt.on(\"--check\",\"Runs just the suite setup test\"){@check=true}\n #opt.on(\"--step\",\"Runs test cases step by step\"){@step=true}\n opt.on(\"--silent\",\"Suppresses console output (only for the default reporters)\") { @silent=true}\n opt.on(\"--bare\",\"No default reporters whatsoever\") { @bare=true}\n #opt.on(\"--color\",\"Adds color to the Console reporter\") { @color=true}\n opt.on(\"-v\", \"--version\",\"Displays the version\") { $stdout.puts(\"rutema v#{Version::STRING}\");exit 0 }\n opt.on(\"--help\", \"-h\", \"-?\", \"This text\") { $stdout.puts opt; exit 0 }\n opt.on(\"--debug\", \"-d\", \"Turn on debug messages\") { $DEBUG=true }\n opt.on(\"You can provide a specification filename in order to run a single test\")\n opt.parse!\n #and now the rest\n unless @config_file\n puts \"No configuration file defined!\\n\"\n $stdout.puts opt \n exit 1\n end\n if !args.empty?\n @test_identifier=args.shift\n end\n end\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n process_arguments \n start\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end \n end", "def run\n setup_options\n\n if parse_options?\n\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n show_effective_options if @options.verbose\n\n # do_work(WordAnalyzer)\n\n # example alternate analyzer implementation\n do_work(AdaptiveWordAnalyzer)\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n 0 # happy shell exit code\n else\n show_help\n end\n end", "def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end", "def main\n if system(ARGV.join(\" \"))\n exit 0\n else\n main\n end\nend", "def handle_options\n parse_options(argv)\n if config[:version]\n show_version\n else\n show_help\n end\n exit 0\n end", "def run\n # puts arguments_valid?\n if parsed_options?\n puts \"Start at #{DateTime.now}\" if verbose?\n\n output_options if verbose?\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if verbose?\n else\n puts 'The options passed are not valid!'\n end\n end", "def run\n if options_valid? && option_combinations_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\n\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n os \n process_command\n \n puts \"\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def execute\n setup\n begin\n data = main\n rescue ArgumentError => e\n warn e.message\n exit 1\n end\n puts format_data(data)\n end", "def run\n begin\n raise TooManyArgumentsError.new(@arguments) if @arguments.length > 1\n \n print_version if @options.version?\n scan if @options.scan?\n rename_given_file unless @arguments.empty?\n run_gui if @arguments.empty?\n \n raise Error\n rescue => e\n puts e.to_s\n \n exit(1)\n end\n end", "def run(argv = ARGV)\n #p [:argv, argv]\n begin\n # cheating\n if argv.include?('-h') or argv.include?('--help')\n puts help_text\n else\n app = from_argv(argv)\n app.run\n end\n rescue Exception => e\n if exit_status == 0\n exit_status 1\n end\n puts \"\\nERROR: #{e}\"\n ensure\n exit(exit_status)\n end\n end", "def run\n unless parsed_options? && arguments_valid? \n output_usage and return\n end\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n end", "def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end", "def run(args = ARGV)\n trap_interrupt\n\n @options, remaining_args = Options.new.parse(args)\n target_files = target_finder.find(remaining_args)\n\n act_on_options(remaining_args)\n\n any_failed = process_files(target_files)\n\n display_error_summary(@errors)\n\n !any_failed && !wants_to_quit ? 0 : 1\n rescue => e\n $stderr.puts e.message\n return 1\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n if arguments = parse_arguments\n begin\n process(arguments)\n rescue RuntimeError => ex\n Console.puts ex.message, :red\n exit 1\n end\n else\n if show_help?\n show_help(nil, Console.width).each do |line|\n Console.puts line, :cyan\n end\n else\n show_usage(nil, Console.width).each do |line|\n Console.puts line, :yellow\n end\n end\n exit 2\n end\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n process_arguments \n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end", "def run\n\n if parsed_options? && arguments_valid? \n\n puts \"Start at #{Time.new.to_s}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n\n puts \"\\nFinished at #{Time.new.to_s}\" if @options.verbose\n\n else\n output_usage\n end\n\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n if process_arguments == false\n return\n end\n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n\n end", "def call(*args)\n puts parser.help\n exit 1\n end", "def main(*args)\n #puts self.class # TODO: fix help\n raise NoCommandError\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n\n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n\t\tif parsed_options? && arguments_valid?\n\t\t\toutput_options if @options[:verbose]\n\t\t\toutput_arguments if @options[:verbose]\n\t\t\tprocess_arguments\n\t\t\tprocess_command\n\t\telse\n\t\t\toutput_usage\n\t\tend\n\tend", "def usage()\n $stderr.puts option_parser\n exit 1\n end", "def run!\n trace = false\n require_program :version, :description\n\n global_option('-h', '--help', 'Help on any command', :hide => true)\n global_option('--version', 'Display version information', :hide => true)\n\n # special case --debug so all commands can output relevant info on it\n $terminal.debug = options_parse_debug\n\n # special case --trace because we need to use it in the runner\n trace = options_parse_trace\n\n # special case --version so it is processed before an invalid command\n options_parse_version\n\n # help is a special branch prior to command execution\n options_parse_help\n\n unless trace\n begin\n run_active_command\n rescue InvalidCommandError => e\n run_help(provided_arguments)\n rescue \\\n OptionParser::InvalidOption => e\n RHC::Helpers.error e.message\n 1\n rescue \\\n ArgumentError,\n OptionParser::ParseError => e\n\n help_bindings = CommandHelpBindings.new(active_command, commands, self)\n usage = RHC::HelpFormatter.new(self).render_command_syntax(help_bindings)\n message = case e\n when OptionParser::AmbiguousOption\n \"The option #{e.args.join(' ')} is ambiguous. You will need to specify the entire option.\"\n else\n e.message\n end\n\n RHC::Helpers.error message\n say \"#{usage}\"\n 1\n rescue RHC::Exception, RHC::Rest::Exception => e\n RHC::Helpers.error e.message\n e.code.nil? ? 128 : [1, (e.code || 1).to_i].max\n end\n else\n run_active_command\n end\n end", "def run\n if parsed_options? && arguments_valid?\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end", "def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end", "def run\n standard_exception_handling do\n handle_env(ENV)\n handle_options(ARGV)\n config.cmdline = CmdlineBuilder.new(config, Dir.pwd, $0, ENV)\n @output_stream.puts config.output\n end\n end", "def run\n\n if parsed_options? && arguments_valid? && client_configured?\n\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n\n process_arguments\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n\n end", "def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n\n process_arguments\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end", "def run\n \n # Define options\n opts = OptionParser.new\n opts.banner = \"Usage: #{File.basename($0)} [options] {setup|restore}\"\n opts.on('-h', '--help') do\n @options[:usage] = true\n end\n opts.on( '-v', '--verbose', 'Print progress to STDERR' ) do\n @options[:verbose] = true\n end\n opts.on( '-d', '--debug', 'Print debug output to STDERR' ) do\n @options[:verbose] = true\n @options[:debug] = true\n end\n opts.on( '-w', '--wait', \n 'Wait [30] seconds for network interfaces' ) do |a|\n @options[:wait] = a\n end\n opts.on( '--corporate INTERFACE', \n 'Select INTERFACE for corporate network' ) do |a|\n @network_map[:corporate][:pattern] = /#{a}/\n end\n opts.on( '--other INTERFACE', \n 'Select INTERFACE for other network' ) do |a|\n @network_map[:other][:pattern] = /#{a}/\n end\n opts.on( '--vpn', 'Enable VPN' ) do |a|\n @options[:vpn] = a\n end\n if CORPORATE_NET.include?('255.255.255.255/16') ||\n ! PARAMETERS_ADAPTED\n RDoc::usage_no_exit()\n puts opts\n puts \"\\n###\\n### YOU NEED TO READ, UNDERSTAND,\\n\"\\\n \"### AND FINALLY EDIT THIS SCRIPT\\n\"\\\n \"### BEFORE YOU CAN USE IT\\n###\\n\\n\"\n return false\n end\n begin\n opts.parse!(@arguments)\n rescue OptionParser::InvalidOption => e\n RDoc::usage_no_exit()\n puts e\n puts opts\n return false\n end\n if @options[:usage]\n RDoc::usage_no_exit()\n puts opts\n return false\n end\n if parsed_arguments? \n process_command\n else\n puts \"#{File.basename(__FILE__)} version #{VERSION}\"\n RDoc::usage_no_exit()\n puts opts\n exit 1\n end\n \n end", "def run\n\n\t\tif parsed_options? && arguments_valid?\n\n\t\t puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n\t\t output_options if @options.verbose # [Optional]\n\n\t\t process_arguments\n\t\t process_command\n\n\t\t puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n\t\telse\n\t\t output_usage\n\t\tend\n\n\tend", "def check_command_line\n if (!ARGV[0].nil? && ARGV[0].downcase == \"test\")\n @test = true\n elsif(ARGV.length < 2)\n puts \"USAGE: ruby main.rb <users_csv_file> <businesses_csv_file>\"\n puts \"OR\"\n puts \"USAGE: ruby main.rb test\"\n exit 1\n end\nend", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\" if @options.verbose\n output_options if @options.verbose # [Optional]\n process_arguments\n # add parameters\n args = {}\n # TODO: use correct syntax for set\n args[:verbose] = @options.verbose if @options.verbose\n args[:input] = @options.input if @options.input\n args[:output] = @options.output if @options.output\n args[:map_name] = @options.map_name if @options.map_name\n args[:not_installed] = @options.cwd if @options.cwd\n \n program = Guy.new args\n program.work\n puts \"Finished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end \n end", "def parse\n parser.parse(ARGV)\n @options\n rescue OptionParser::InvalidOption => e\n puts e\n puts parser\n #p @options\n exit(1)\n end", "def main\n OptionParser.new do |opts|\n opts.banner = 'Usage: xcode_tool.rb [options]'\n opts.on('-d', '--XCodeCPP.xcodeProjectDir [dir]',\n 'XCode project directory (required)') do |xcode_project_dir|\n @xcode_project_dir = xcode_project_dir\n end\n opts.on('-t', '--XCodeCPP.target [target]',\n 'Assume target to match the .xcodeproj name. (required)') do |target|\n @target_name = target\n end\n opts.on('-f', '--XCodeCPP.frameworks [frameworks]',\n 'Paths to the custom frameworks. (required)') do |frameworks|\n @frameworks = frameworks.split(\",\")\n end\n opts.on('-e', '--XCodeCPP.entitlement [entitlement_path]',\n 'Path to entitlements (optional)') do |entitlement_path|\n @entitlement_path = entitlement_path\n end\n opts.on('-i', '--XCodeCPP.include [include_path]',\n 'Path to additional include files (optional)') do |include_path|\n @include_path = include_path\n end\n end.parse!\n\n raise OptionParser::MissingArgument,'-d' if @xcode_project_dir.nil?\n raise OptionParser::MissingArgument,'-t' if @target_name.nil?\n raise OptionParser::MissingArgument,'-f' if @frameworks.nil?\n\n project_path = \"#@xcode_project_dir/integration_test.xcodeproj\"\n @project = Xcodeproj::Project.open(project_path)\n for t in @project.targets\n if t.name == @target_name\n @target = t\n puts \"Find target #@target\"\n break\n end \n end\n\n # Examine components rather than substrings to minimize false positives.\n # Note: this is not ideal. This tool should not be responsible for figuring\n # out which project it's modifying. That responsibility should belong to\n # the Python tool invoking this.\n path_components = project_path.split('/')\n if path_components.include?('FirebaseAuth')\n make_changes_for_auth\n elsif path_components.include?('FirebaseMessaging')\n make_changes_for_messaging\n elsif path_components.include?('FirebaseDynamicLinks')\n make_changes_for_dynamiclinks\n end\n\n framework_dir = \"#@xcode_project_dir/Frameworks\"\n set_build_setting('FRAMEWORK_SEARCH_PATHS', ['${inherited}', framework_dir])\n if !@include_path.nil?\n append_to_build_setting('HEADER_SEARCH_PATHS', @include_path)\n end\n\n @frameworks.each do |framework|\n add_custom_framework(framework)\n end\n\n # Bitcode is unnecessary, as we are not submitting these to the Apple store.\n # Disabling bitcode significantly speeds up builds.\n set_build_setting('ENABLE_BITCODE', 'NO')\n\n @project.save\nend", "def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end", "def _run(argv = [])\n execute(parse_options(argv))\n end", "def run(argv)\n options = parse(argv)\n invoke!(options.to_h)\n end", "def checkCommandLine\r\n if ARGV.length != 2\r\n puts \"\\nUsage: sum <fileName> <numThreads>\\n\\n\"\r\n exit(1)\r\n end\r\nend", "def __main__(args)\n Fifa::Task.new($opts = parse(args[1..-1])).exec\n exit(1) if Fifa::Logger.errors?\nend", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose # [Optional]\n process_arguments \n process_command\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n Trollop::die \"user error, replace user and continue\"\n end\n end", "def validate_run_options(args, options)\n\n if (options.machine.empty?)\n $stderr.puts(\"You have to tag your benchmark data with the --machine flag.\\n\")\n exit!\n end\n\n if (options.experiment.empty?)\n $stderr.puts(\"You have to tag your benchmark data with the --experiment flag.\\n\")\n exit!\n end\n\n if options.coverage < 0 || options.coverage > 1.0\n $stderr.puts(\"Error in --coverage flag: Coverage must be in [0..1.0]\\n\")\n exit!\n end\n\n if options.repetitions < 1\n $stderr.puts(\"Error in --repetitions flag: Repetitions must be >= 1\\n\")\n exit!\n end\n\n if options.concurrency < 1\n $stderr.puts(\"Error in --concurrency flag: Concurrency must be >= 1\\n\")\n exit!\n end\n\n if options.timeout < 1\n $stderr.puts(\"Error in --timeout flag: Timeout must be >= 1 seconds\\n\")\n exit!\n end\n\n if args.empty?\n $stderr.puts(\"You have to specify a log file.\\n\")\n exit!\n end\n\n if args.length > 1\n $stderr.puts(\"You should only specify one log file. You specified #{args.length} logfiles.\\n\")\n exit!\n end\n\n if File.exist?(args[0])\n $stderr.puts(\"Logfile #{args[0]} already exists. You do not want to overwrite collected benchmark data.\\n\")\n exit!\n end\n\nend", "def run(filename, options) end", "def run\n # puts \"parsed_options? >>> #{parsed_options?}\"\n # puts \"arguments_valid? >>> #{arguments_valid?}\"\n if parsed_options? && arguments_valid?\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n process_arguments\n \n output_options if @options.verbose # [Optional]\n \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n @action = @argv[0] || @app_default_action\n @action = @action.downcase\n init_defaults\n\n\n ret = 0\n @argv.shift\n if respond_to? @action\n ret = send(@action, @argv)\n else\n # check aliases\n if check_aliases @action, @argv\n ret = send(@action, @argv)\n else\n help @argv\n ret = ERRCODE\n end\n end\n ret ||= 0\n ret = 0 if ret != ERRCODE\n return ret\n end", "def main\n options = {}\n OptionParser.new do |opts|\n\n opts.on('--domains domain1, domain2, domain3', Array, 'Use multiple domains') do |d|\n options[:domains] = d\n end\n\n opts.on('-e', '--email email', Array, 'Search for a single email') do |e|\n options[:email] = e\n end\n end.parse!\n\n # given a single email or a names and domains\n if options[:email]\n find_valid_email options[:email]\n # list of domains\n elsif options[:domains]\n find_email ARGV[0], ARGV[1], options[:domains]\n # single domain\n else\n find_email ARGV[0], ARGV[1], ARGV[2]\n end\nend", "def show_usage_and_exit\n puts 'Usage:'\n puts 'ruby gold_rush.rb'\n puts 'Arguments should be two valid integers'\n exit 1\n end", "def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [options...]\"\n\n options[:tests] = []\n opts.on( '-t', '--tests DIR/FILE', 'Execute tests in DIR or FILE (defaults to \"./tests\")' ) do|dir|\n options[:tests] << dir\n end\n\n options[:type] = 'skip'\n opts.on('--type TYPE', 'Select puppet install type (pe, git, skip) - default \"skip\"') do\n |type|\n unless File.directory?(\"setup/#{type}\") then\n puts \"Sorry, #{type} is not a known setup type!\"\n exit 1\n end\n options[:type] = type\n end\n\n options[:puppet] = 'git://github.com/puppetlabs/puppet.git#HEAD'\n opts.on('-p', '--puppet URI', 'Select puppet git install URI',\n \" #{options[:puppet]}\",\n \" - URI and revision, default HEAD\",\n \" just giving the revision is also supported\"\n ) do |value|\n options[:type] = 'git'\n options[:puppet] = value\n end\n\n options[:facter] = 'git://github.com/puppetlabs/facter.git#HEAD'\n opts.on('-f', '--facter URI', 'Select facter git install URI',\n \" #{options[:facter]}\",\n \" - otherwise, as per the puppet argument\"\n ) do |value|\n options[:type] = 'git'\n options[:facter] = value\n end\n\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-d', '--dry-run', \"Just report what would be done on the targets\" ) do |file|\n $dry_run = true\n end\n\n options[:mrpropper] = FALSE\n opts.on( '--mrpropper', 'Clean hosts' ) do\n puts \"Cleaning Hosts of old install\"\n options[:mrpropper] = TRUE\n end\n\n options[:stdout_only] = FALSE\n opts.on('-s', '--stdout-only', 'log output to STDOUT but no files') do\n puts \"Will log to STDOUT, not files...\"\n options[:stdout_only] = TRUE\n end\n\n options[:quiet] = false\n opts.on('-q', '--quiet', 'don\\'t log output to STDOUT') do\n options[:quiet] = true\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend", "def main(argv)\n # override this; no default action in main\n end", "def parse_options(args)\n\t\t\t\tbegin\n\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t@options['verbose'] = false\n\t\t\t\t\t@options['rescan'] = false\n\t\t\t\t\t@options[:timeout] = 25\n\t\t\t\t\t@options[:directory] = nil\n\n\t\t\t\t\topts = OptionParser.new do |opt|\n\t\t\t\t\t\topt.banner = \"#{APP_NAME} v#{VERSION}\\nJacob Hammack\\n#{HOME_PAGE}\\n\\n\"\n\t\t\t\t\t\topt.banner << \"Usage: #{APP_NAME} <options>\"\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('File Options')\n\n\t\t\t\t\t\topt.on('-h HASH', '--search-hash HASH', 'Searches a single hash on virustotal.com') do |hash|\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-r HASH[,HASH]', '--rescan-hash HASH[,HASH]', 'Requests a rescan of a single hash, or multiple hashes (comma separated), by virustotal.com') do |hash|\n\t\t\t\t\t\t\t@options['rescan'] = true\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@files_of_hashes.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@uploads.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator(\"Url Options\")\n\n\t\t\t\t\t\topt.on('-s SITE', '--search-site SITE', 'Searches for a single url on virustotal.com') { |site|\n\t\t\t\t\t\t\t@sites.push(site)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('Output Options')\n\n\t\t\t\t\t\topt.on('-j', '--json-output', 'Print results as json to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :json\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-x', '--xml-output', 'Print results as xml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :xml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-y', '--yaml-output', 'Print results as yaml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :yaml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--stdout-output', 'Print results as normal text line to stdout, this is default') do\n\t\t\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Advanced Options'\n\n\t\t\t\t\t\topt.on('-c', '--create-config', 'Creates a skeleton config file to use') do\n\t\t\t\t\t\t\tcreate_config\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-d DIRECTORY', '--directory', 'Scans a directory recursively for files and submits the hashes') do |directory|\n\t\t\t\t\t\t\t@options[:directory] = directory\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-p PROXY', '--proxy-server', 'Uses a specified proxy server') do |proxy|\n\t\t\t\t\t\t\t@options['proxy'] = proxy\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--[no-]verbose', 'Print verbose information') do |v|\n\t\t\t\t\t\t\t@options['verbose'] = v\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Other Options'\n\n\t\t\t\t\t\topt.on('-v', '--version', 'Shows application version information') do\n\t\t\t\t\t\t\tputs \"#{APP_NAME} - #{VERSION}\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on_tail('-?', '--help', 'Show this message') { |help|\n\t\t\t\t\t\t\tputs opt.to_s + \"\\n\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\n\t\t\t\t\tif ARGV.length != 0\n\t\t\t\t\t\topts.parse!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\trescue OptionParser::MissingArgument\n\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend", "def run!(options = {})\n run_option_parser.parse!(ARGV.dup) unless ARGV.empty?\n @running = true\n super(options)\n end", "def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_options\n end\n end", "def main\n VoteParser.vote_arg_count_validator ARGV\n input = VoteParser.init(ARGV[0], ARGV[1])\n # noinspection RubyMismatchedParameterType\n # @type [Hash{Symbol=>Integer,String,Hash{String}]\n processed_values = VoteParser.process_votes(input[:Votes], input[:TokenMapping])\n # noinspection RubyMismatchedParameterType\n election_report = OutputPrinter.vote_report(\n processed_values[:TotalVoterCount],\n input[:Cols],\n processed_values[:VoteCounts]\n )\n OutputPrinter.write_output(election_report, processed_values[:Warning], ARGV[2])\nend", "def print_usage(options)\n puts\n puts \"Usage: \"+$0+\" -[\"+options+\"]\"\n puts\n puts \"-V:\\tDisplay version information\"\n puts \"-h:\\tDisplay usage information\"\n puts \"-v:\\tVerbose output\"\n puts \"-d:\\tDownload latest build but don't install\"\n puts \"-i:\\tDownload and install latest build\"\n puts \"-u:\\tUpdate application to latest build\"\n puts \"-l:\\tGet local build date for application\"\n puts \"-r:\\tGet remote build date for application\"\n puts \"-p:\\tGet URL of download for latest package\"\n puts \"-c:\\tCompare local and remote build dates\"\n puts \"-a:\\tShow available packages\"\n puts \"-g:\\tUpdate Gatekeeper and Quarantine information so application can run\"\n puts \"-z:\\tClean up temporary directory (delete files older than \"+$mtime+\" days)\"\n puts \"-Z:\\tRemove existing application\"\n puts \"-C:\\tRemove crash reporter file\"\n puts \"-P:\\tPerform post install\"\n puts \"-q:\\tQuit application\"\n puts \"-s:\\tStart application\"\n puts\nend", "def run(args)\n ret = DEFAULTS.merge({})\n\n # create option parser\n o = ::OptionParser.new do |o|\n o.banner = \"Usage: #@app [options]\"\n o.separator \" \"\n\n # add command-line options\n o.separator \"Options:\"\n\n o.on('-A', '--allow USER', 'Allow Jabber subscription from USER.') do |v|\n add_allowed(ret, v)\n end\n\n o.on('-c', '--config FILE', 'Use configuration file FILE.') do |v|\n Joggle::ConfigParser.run(v) do |key, val|\n if key == 'engine.allow'\n add_allowed(ret, val)\n elsif key == 'engine.update.range'\n add_update_range(ret, val)\n else\n ret[key] = val\n end\n end\n end\n\n o.on('-D', '--daemon', 'Run as daemon (in background).') do |v|\n ret['cli.daemon'] = true\n end\n\n o.on('--foreground', 'Run in foreground (the default).') do |v|\n ret['cli.daemon'] = false\n end\n\n o.on('-L', '--log-level LEVEL', 'Set log level to LEVEL.') do |v|\n ret['runner.log.level'] = v\n end\n\n o.on('-l', '--log FILE', 'Log to FILE.') do |v|\n ret['runner.log.path'] = v\n end\n\n o.on('-p', '--password PASS', 'Jabber password (INSECURE!).') do |v|\n ret['jabber.pass'] = v\n end\n\n o.on('-s', '--store FILE', 'Use FILE as backing store.') do |v|\n ret['runner.store.path'] = v\n end\n\n o.on('-u', '--username USER', 'Jabber username.') do |v|\n ret['jabber.user'] = v\n end\n\n o.separator ' '\n\n o.on_tail('-v', '--version', 'Print version string.') do\n puts \"Joggle %s, by %s\" % [\n Joggle::VERSION,\n 'Paul Duncan <pabs@pablotron.org>',\n ]\n exit\n end\n\n o.on_tail('-h', '--help', 'Print help information.') do\n puts o\n exit\n end\n end\n\n # parse arguments\n o.parse(args)\n\n # return results\n ret\n end", "def parse!\n begin\n parse\n rescue StandardError => e\n raise e if @options[:trace] || e.is_a?(SystemExit)\n $stderr.puts \"#{e.class}: \" + e.message.to_s\n exit 1\n end\n exit 0\n end", "def go_with_args(argv=[])\n catch(:exit_err) { catch(:exit_zero) { @cli_obj.go(argv) } }\n end", "def parse_command_line(args)\n test_configuration = {}\n\n option_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: run-tests.rb [options]'\n opts.separator 'Specific options:'\n\n opts.on('--blinkr', 'Execute broken link checks') do |opt|\n test_configuration[:blinkr] = opt\n end\n\n opts.on('--dcp', 'Execute dcp broken link checks') do |opt|\n test_configuration[:dcp] = opt\n end\n\n opts.on('--base-url RHD_BASE_URL', String, 'Run the tests against the specified host e.g http://developers.stage.redhat.com') do |host|\n test_configuration[:base_url] = host\n end\n\n opts.on('-c CONFIG_FILE', 'specify the config.yaml file for broken link checks') do |opt|\n test_configuration[:config] = opt\n end\n\n opts.on('--ignore-internal', \"Ignore internal URL's\") do |opt|\n test_configuration[:ignore_internal] = opt\n end\n\n opts.on('--ignore-external', \"Ignore external URL's\") do |opt|\n test_configuration[:ignore_external] = opt\n end\n\n opts.on('--ignore-ssl', 'Disable SSL certificate checking for staging environments') do |opt|\n test_configuration[:ignore_ssl] = opt\n end\n\n #\n # Options supporting the execution of the tests within Docker\n #\n opts.on('--use-docker', 'Run the specified test type using Docker') do\n test_configuration[:docker] = true\n end\n\n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n Kernel.exit(1)\n end\n end\n\n begin\n option_parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e\n option_parser.parse(%w(-h))\n end\n bind_test_type_environment_variable(test_configuration)\n build_test_execution_command(test_configuration)\n test_configuration\n end", "def options_parse\n # first, deal with all options\n opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{COMMAND} [options] <cn_tracker_export>\\n\"\n opts.banner += \"Convert CollabNet project tracker artifacts to Pivotal Tracker format\"\n\n opts.on(\"-h\", \"Show this message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"Display this application's version and exit\") do\n puts \"#{COMMAND} version #{VERSION}\"\n exit\n end\n \n opts.on(\"-o <filename>\", \"Direct output to <filename> rather than the console\") do |filename|\n if File.exists?(filename) && (!File.writable?(filename) || File.directory?(filename))\n puts \"Specified filename '#{filename}' is not writable\\n\\n#{opts}\"\n exit\n elsif !File.exists?(filename) && !File.writable?(File.dirname(filename))\n puts \"Location of specified filename '#{filename}' is not writable\\n\\n#{opts}\"\n exit\n end\n \n @options[:out] = filename\n end\n \n opts.on(\"-t < feature | chore | bug >\", \"The type of story to generate\") do |type|\n unless [ 'feature', 'chore', 'bug' ].include?(type)\n puts \"Type '#{type}' is invalid. Only 'feature', 'chore', or 'bug' are allowed.\"\n puts \"\\n#{opts}\"\n exit\n end\n @options[:story_type] = type\n end\n end\n \n # try parsing options, rescuing certain errors and printing friendly messages\n begin\n opts.parse!\n rescue OptionParser::InvalidOption => e\n puts \"#{e}\\n\\n#{opts}\"\n exit\n end\n \n # now, make sure that there are enough arguments left for required parameters\n case\n when ARGV.length < 1\n puts \"You must specify a CollabNet project tracker export (<cn_tracker_export>)\\n\\n#{opts}\"\n exit\n when !File.exists?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' does not exist\\n\\n#{opts}\"\n exit\n when !File.readable?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' is not readable\\n\\n#{opts}\"\n exit\n when File.directory?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' is a directory, not a file\\n\\n#{opts}\"\n exit\n end\n \n @options[:in] = ARGV[0]\n end", "def parse_main(argv)\n defaults = {\n report: Inq::DEFAULT_REPORT_FILE,\n }\n\n opts = Okay::SimpleOpts.new(defaults: defaults)\n\n opts.banner = <<~EOF\n Usage: inq --repository REPOSITORY --date REPORT_DATE [--output REPORT_FILE]\n inq --config CONFIG_FILE --date REPORT_DATE\n EOF\n\n opts.separator \"\\nOptions:\"\n\n opts.simple(\"--config CONFIG_FILE\",\n \"YAML config file for automated reports.\",\n :config)\n\n opts.simple(\"--no-user-config\",\n \"Don't load user configuration file.\",\n :no_user_config)\n\n opts.simple(\"--env-config\",\n \"Use environment variables for configuration.\",\n \"Read this first: https://inqrb.com/config\",\n :env_login)\n\n opts.simple(\"--repository USER/REPO\", REPO_REGEXP,\n \"Repository to generate a report for.\",\n :repository)\n\n opts.simple(\"--date YYYY-MM-DD\", DATE_REGEXP, \"Last date of the report.\",\n :date)\n\n opts.simple(\"--start-date YYYY-MM-DD\", DATE_REGEXP, \"Start date of the report.\",\n :start_date)\n\n opts.simple(\"--end-date YYYY-MM-DD\", DATE_REGEXP, \"Last date of the report.\",\n :end_date)\n\n opts.simple(\"--output REPORT_FILE\", format_regexp,\n \"Output file for the report.\",\n \"Supported file formats: #{formats}.\",\n :report)\n\n opts.simple(\"--verbose\", \"Print debug information.\", :verbose)\n opts.simple(\"-v\", \"--version\", \"Prints version information.\", :version)\n opts.simple(\"-h\", \"--help\", \"Print help text.\", :help)\n\n [opts, opts.parse(argv)]\n end", "def run\n @action = @argv[0] || @app_default_action\n @action = @action.downcase\n\n\n ret = 0\n @argv.shift\n if respond_to? @action\n ret = send(@action, @argv)\n else\n # check aliases\n if check_aliases @action, @argv\n ret = send(@action, @argv)\n else\n help @argv\n ret = ERRCODE\n end\n end\n ret ||= 0\n ret = 0 if ret != ERRCODE\n return ret\n end", "def main()\n case ARGV[0]\n when \"--list\"\n cd_source = CDSource.new CACHE_FILE, SOURCE_DIRS, nil, MAX_LEVEL\n cd_source.list()\n when \"--delete\"\n cd_source = CDSource.new CACHE_FILE, SOURCE_DIRS, nil, MAX_LEVEL\n cd_source.delete(ARGV[1])\n when \"--set\"\n cd_source = CDSource.new CACHE_FILE, SOURCE_DIRS, nil, MAX_LEVEL\n cd_source.set(ARGV[1], ARGV[2])\n when \"--help\", \"-h\"\n puts HELP_INFO\n exit 1\n else\n cd_source = CDSource.new CACHE_FILE, SOURCE_DIRS, ARGV[0], MAX_LEVEL\n cd_source.search()\n end\nend", "def run\n @arguments = ArgumentParser.get_arguments VALID_ARGUMENTS\n print_help if (@arguments[:options][:help])\n print_version if (@arguments[:options][:version])\n if (@arguments[:keywords][:export])\n handle_export\n elsif (@arguments[:keywords][:import])\n handle_import\n else\n print_help\n end\n end", "def main\n cmd_given = false\n\n OptionParser.new do |opts|\n opts.banner = \"\nSonge | dead simple signing file utility\nMIT License (https://mit-license.org/)\n\nSonge is a naive file signer, adapted to sign files in a per-project context: each project\ndirectory can have its own keys to directly sign project files. Songev version uses Ed25519\n(github.com/RubyCrypto/ed25519).\n\nVerify and signing use thus Ed25519 32-bytes keys. The verify key (starting with 'P') is\njoined to all signatures (so to verify a file, you just need the file and the signature\n`.sgsig` file).\n\nTrusted recipients' verify keys may be added to a trusted keys list saved to `.songe.trust`\nto add confidence when verifiyng files signed by them. The trusted keystore's signature is\nnot checked, so it is up to the user to check the recipient's key.\n\nUsage:\n $ songev [options]\n\nExamples:\n Verify a downloaded file (assume the signature is `./myfile.txt.sgsig`)\n $ songe --verify myfile.txt\n\nOptions/commands:\"\n\n # options\n\n opts.on(\"-b\", \"--[no-]verbose\", \"Run verbosely\") do |v|\n @options[:verbose] = v\n end\n\n # misc commands\n\n opts.on(\"-h\", \"--help\", \"Print this help\") do\n puts opts\n exit\n end\n\n opts.on(\"-n\", \"--version\", \"Print version info\") do\n puts \"🎖 songe\\n dead simple signing file utility\"\n puts \" version #{VERSION}\\n M.P. - Esprit Libre {dev}\"\n exit\n end\n\n end.parse!\n\n raise ArgumentError, 'One command is required (see help)' unless ARGV.size > 0\n verify ARGV[0]\nend", "def run\n \n if parsed_options? && arguments_valid?\n \n output_options if @options.verbose # [Optional]\n \n process_arguments\n \n # run as import_nsw_candidates -p \"data/postcodes_2010nsw.csv\" -c\n postcode_parser = ParsePostcodeNSW.new()\n postcode_parser.parse(@options.postcodes)\n \n candidate_parser = ParseCandidateNSW.new()\n candidate_parser.parse(@options.candidates)\n \n else\n output_usage\n end\n \n end", "def execute\n cli_options = OptionManager.new.execute\n argv = parse_options(cli_options[:parser])\n \n return unless argv\n \n if [nil, ''].include? cli_options[:values][:cmd]\n env.ui.info cli_options[:parser]\n else\n with_target_vms(argv) do |machine|\n manage_machine(machine, cli_options) \n end\n end\n 0\n end", "def run(argv = ARGV)\n # => Parse CLI Configuration\n cli = Options.new\n cli.parse_options(argv)\n\n # => Parse JSON Config File (If Specified and Exists)\n json_config = Util.parse_json_config(cli.config[:config_file] || Config.config_file)\n\n # => Grab the Default Values\n default = Config.options\n\n # => Merge Configuration (CLI Wins)\n config = [default, json_config, cli.config].compact.reduce(:merge)\n\n # => Apply Configuration\n Config.setup do |cfg|\n cfg.config_file = config[:config_file]\n cfg.cache_timeout = config[:cache_timeout].to_i\n cfg.bind = config[:bind]\n cfg.port = config[:port]\n cfg.environment = config[:environment].to_sym.downcase\n cfg.do_api_key = config[:do_api_key]\n end\n\n # => Launch the API\n API.run!\n end", "def parsed_args\n args = Options.new('binnacle - Simple Test and Infra automation Framework')\n args.verbose = 0\n args.runner = false\n args.result_json = ''\n\n opt_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: binnacle [options] <testfile>'\n\n opts.on('-w', '--wide', 'Do not crop the task line') { args.wide = true }\n opts.on('-v', '--verbose', 'Verbose output') { args.verbose += 1 }\n opts.on('-r', '--runner', 'Run the tasks from a file (Internal use only)') { args.runner = true }\n opts.on('--results-json=FILE', 'Results JSON file') do |json_file|\n args.result_json = json_file\n end\n\n opts.on('-h', '--help', 'Prints this help') do\n puts opts\n exit\n end\n\n opts.on('--version', 'Show Version information') do\n puts \"Binnacle #{Binnacle::VERSION}\"\n exit\n end\n end\n\n opt_parser.parse!(ARGV)\n\n if ARGV.empty?\n warn 'Task file is not specified'\n exit EXIT_INVALID_ARGS\n end\n\n args.task_files = ARGV\n args\nend", "def parse( argv )\n self.data = ::Crate.data_path\n opts = option_parser\n begin\n opts.parse!( argv )\n self.project = argv.shift\n\n if project.nil?\n puts opts\n exit 1\n end\n rescue ::OptionParser::ParseError => pe\n puts \"#{opts.program_name}: #{pe}\"\n puts \"Try `#{opts.program_name} --help` for more information\"\n exit 1\n end\n end", "def run(args)\n safely_mkdir(MAIN_DIR)\n safely_mkdir(MOD_DIR)\n safely_mkdir(PACK_DIR)\n\n return HELP_TEXT if args.include?('-h') || args.include?('--help')\n return VERSION if args.include?('-v') || args.include?('--version')\n\n case args[0]\n when 'help'\n return HELP_COMMANDS[args[1].to_sym] if HELP_COMMANDS.key?(args[1].to_sym)\n return HELP_TEXT\n when 'fetch'\n return CommandFetch.run(args[1])\n when 'manifest'\n return CommandFetch.install_manifest(args[1])\n when 'installmod'\n return CommandInstall.run_mod(args[1])\n when 'installpack'\n return CommandInstall.run_pack(args[1]).to_s # remove\n else\n end\n end", "def parse_command_line(args)\n test_configuration = {}\n\n option_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: run-tests.rb [options]'\n opts.separator 'Specific options:'\n\n opts.on('--unit', 'Execute frontend unit-tests') do |opt|\n test_configuration[:unit] = opt\n end\n\n opts.on('--e2e', 'Execute frontend end-to-end tests') do |opt|\n test_configuration = create_default_test_configuration\n test_configuration[:e2e] = opt\n end\n\n opts.on('--blc', 'Execute broken link checks') do |opt|\n test_configuration[:blc] = opt\n end\n\n #\n # e2e and broken link testing commandline options\n #\n opts.on('--base-url RHD_BASE_URL', String, 'Run the tests against the specified host e.g http://developers.stage.redhat.com') do |host|\n test_configuration[:base_url] = host\n end\n\n opts.on('--verbose', 'Verbose output for debugging') do |opt|\n bind_environment_variable('RHD_VERBOSE_OUTPUT', 'true')\n test_configuration[:verbose] = opt\n end\n\n #\n # e2e commandline options\n #\n opts.on('--browser BROWSER', String, 'The driver to use when running the tests. [default=chrome]') do |browser|\n check_supported_browser(browser)\n test_configuration[:browser] = browser\n end\n\n opts.on('--use-browserstack', 'Run the specified test type using Docker') do\n test_configuration[:browserstack] = true\n end\n\n opts.on('--browser-count BROWSER_COUNT', String, 'The number of browsers to launch when running the tests with Docker [default=2]') do |browser_count|\n test_configuration[:browser_count] = browser_count.to_i\n end\n\n opts.on('--reporters REPORT', String, 'Type of report you wish to generate. Will mostly be used for Jenkins config, i.e. junit report') do |report|\n test_configuration[:report] = report\n end\n\n opts.on('--cucumber-tags CUCUMBER_TAGS', String, 'The cucumber tags to use') do |cucumber_tags|\n test_configuration[:cucumber_tags] = cucumber_tags\n end\n\n opts.on('--kc', 'Run the KeyCloak e2e tests') do\n test_configuration[:keycloak] = true\n end\n\n #\n # Broken link checking commandline options\n #\n opts.on('-c CONFIG_FILE', 'specify the config.yaml file for broken link checks') do |opt|\n test_configuration[:config] = opt\n end\n\n opts.on('-s SINGLE_URL', 'test a single URL, outputting the response to the console') do |opt|\n test_configuration[:single_url] = opt\n test_configuration[:base_url] = opt\n end\n\n opts.on('--ignore-internal', \"Ignore internal URL's\") do |opt|\n test_configuration[:ignore_internal] = opt\n end\n\n opts.on('--ignore-external', \"Ignore external URL's\") do |opt|\n test_configuration[:ignore_external] = opt\n end\n\n opts.on('--ignore-ssl', 'Disable SSL certificate checking for staging environments') do |opt|\n test_configuration[:ignore_ssl] = opt\n end\n\n #\n # Options supporting the execution of the tests within Docker\n #\n opts.on('--use-docker', 'Run the specified test type using Docker') do\n test_configuration[:docker] = true\n end\n\n opts.on('--update-github-status SHA1', String, 'The SHA to report test results for on GitHub') do |sha1|\n test_configuration[:github_sha1] = sha1\n end\n\n opts.on('--profile PROFILE', String, 'Used to determine the git status context for e2e tests') do |profile|\n test_configuration[:profile] = profile\n end\n\n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n Kernel.exit(1)\n end\n end\n\n begin\n option_parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e\n option_parser.parse(%w(-h))\n end\n bind_test_type_environment_variable(test_configuration)\n bind_github_status_environment_variables(test_configuration[:github_sha1], ENV['rhd_test'].to_s, test_configuration[:profile])\n bind_browser_environment_variables(test_configuration[:docker], test_configuration[:browser], test_configuration) if test_configuration[:e2e]\n build_test_execution_command(test_configuration)\n test_configuration\n end", "def run(args)\n opts = parse_options(args)\n unless @end_program\n crawler = Spiderman::Crawler.new(opts)\n crawler.crawl\n end\n end", "def run(argv = ARGV)\n parser.parse(argv)\n end", "def run!\n @application.load_configuration_file_or_read_the_options!(@options)\n case\n when options.include?(:show_heuristics?)\n list_heuristics!\n when options.include?(:generate_file)\n Generator.new(options)\n else\n @application.run_global_commands!\n start_continuous_testing!\n end\n end", "def parse_options(args)\n opt_parser = OptionParser.new do |opts|\n # Set a banner, displayed at the top\n # of the help screen.\n opts.banner = 'Usage: k9 [options] [<filename.rb>]'\n # Define the options, and what they do\n\n opts.on('-v', '--version', 'JRubyArt Version') do\n options[:version] = true\n end\n\n opts.on('-?', '--check', 'Prints configuration') do\n options[:check] = true\n end\n\n opts.on('-i', '--install', INSTALL) do\n options[:install] = true\n end\n\n opts.on('-f', '--force', 'Force removal of old Config') do\n options[:force] = true\n end\n\n opts.on('-c', '--create', 'Create new outline sketch') do\n options[:create] = true\n end\n\n opts.on('-r', '--run', 'Run the sketch') do\n options[:run] = true\n end\n\n opts.on('-w', '--watch', 'Watch/run the sketch') do\n options[:watch] = true\n end\n\n opts.on('-l', '--live', 'As above, with pry console bound to Processing.app') do\n options[:live] = true\n end\n\n opts.on('-a', '--app', 'Export as app NOT IMPLEMENTED YET') do\n options[:export] = true\n end\n\n opts.on_tail('-h', '--help', 'Display this screen') do\n puts opts\n exit\n end\n end\n @argc = opt_parser.parse(args)\n @filename = argc.shift\n end", "def exit_code\n self.__options[:exit_code]\n end", "def parse_options(args)\n opt_parser = OptionParser.new do |opts|\n # Set a banner, displayed at the top\n # of the help screen.\n opts.banner = 'Usage: k9 [options] [<filename.rb>]'\n # Define the options, and what they do\n options[:version] = false\n opts.on('-v', '--version', 'JRubyArt Version') do\n options[:version] = true\n end\n\n options[:install] = false\n opts.on('-i', '--install', 'Installs jruby-complete and examples') do\n options[:install] = true\n end\n\n options[:check] = false\n opts.on('-?', '--check', 'Prints configuration') do\n options[:check] = true\n end\n\n options[:app] = false\n opts.on('-a', '--app', 'Export as app NOT IMPLEMENTED YET') do\n options[:export] = true\n end\n\n options[:watch] = false\n opts.on('-w', '--watch', 'Watch/run the sketch') do\n options[:watch] = true\n end\n\n options[:run] = false\n opts.on('-r', '--run', 'Run the sketch') do\n options[:run] = true\n end\n\n options[:live] = false\n opts.on('-l', '--live', 'As above, with pry console bound to Processing.app') do\n options[:live] = true\n end\n\n options[:create] = false\n opts.on('-c', '--create', 'Create new outline sketch') do\n options[:create] = true\n end\n\n # This displays the help screen, all programs are\n # assumed to have this option.\n opts.on('-h', '--help', 'Display this screen') do\n puts opts\n exit\n end\n end\n @argc = opt_parser.parse(args)\n @filename = argc.shift\n end", "def parse_options(argv)\n arguments = [\n [:rspec, \"--rspec\", \"RSpec mode\"],\n [:helper, \"--helper\", \"Helper file to load before tests start\", String],\n [:quiet, \"--quiet\", \"Quiet\"],\n [:no_fixtures, \"--no-fixtures\", \"Do not load fixtures\"],\n [:no_ar, \"--no-ar\", \"Disable ActiveRecord logic\"],\n [:merge_coverage, \"--merge-coverage\", \"Merge base code coverage into indvidual files coverage, great for SingleCov\"],\n [\n :record_runtime,\n \"--record-runtime=MODE\",\n \"\\n Record test runtime:\\n\" <<\n \" simple = write to disk at --runtime-log)\\n\" <<\n \" amend = write from multiple remote workers via http://github.com/grosser/amend, needs TRAVIS_REPO_SLUG & TRAVIS_BUILD_NUMBER\",\n String\n ],\n [:runtime_log, \"--runtime-log=FILE\", \"File to store runtime log in or runtime.log\", String],\n [:group, \"--group=NUM\", \"What group this is (use with --groups / starts at 1)\", Integer],\n [:groups, \"--groups=NUM\", \"How many groups there are in total (use with --group)\", Integer],\n [:version, \"--version\", \"Show version\"],\n [:help, \"--help\", \"Show help\"]\n ]\n\n options = arguments.each_with_object({}) do |(setting, flag, _, type), all|\n all[setting] = delete_argv(flag.split('=', 2)[0], argv, type: type)\n end\n\n # show version\n if options.fetch(:version)\n puts VERSION\n exit 0\n end\n\n # # show help\n if options[:help]\n parser = OptionParser.new(\"forking-test-runner folder [options]\", 32, '') do |opts|\n arguments.each do |_, flag, desc, type|\n opts.on(flag, desc, type)\n end\n end\n puts parser\n exit 0\n end\n\n # check if we can use merge_coverage\n if options.fetch(:merge_coverage)\n require 'coverage'\n abort \"merge_coverage does not work on Ruby prior to 2.3 due to the lack of the Coverage.peek_result method\" unless Coverage.method_defined?(:peek_result)\n klass = (class << Coverage; self; end)\n klass.prepend CoverageCapture\n end\n\n # all remaining non-flag options until the next flag must be tests\n next_flag = argv.index { |arg| arg.start_with?(\"-\") } || argv.size\n tests = argv.slice!(0, next_flag)\n abort \"No tests or folders found in arguments\" if tests.empty?\n tests.each { |t| abort \"Unable to find #{t}\" unless File.exist?(t) }\n\n [options, tests]\n end", "def run!\n\t\t\topts=OptionParser.new\n\n\t\t\topts.banner = \"Usage: #{$0} [options] action\\n action is one of init, build, install, uninstall, info, status, diff\"\n\n\t\t\topts.separator \"\"\n\t\t\topts.separator \"install options:\"\n\n\t\t\topts.on(\"-o\", \"--[no-]overwrite\", \"Overwrite existing files (a backup will be created)\") { |v| @options[:overwrite] = v }\n\n\t\t\topts.separator \"\"\n\t\t\topts.separator \"build options:\"\n\n\t\t\topts.on(\"-r\", \"--[no-]rebuild\", \"Build even if the built file is current\") { |v| @options[:rebuild] = v }\n\n\t\t\topts.separator \"\"\n\t\t\topts.separator \"Common options:\"\n\n\t\t\topts.on(\"-h\", \"--help\" , \"Show this message\") { puts opts ; exit }\n\t\t\topts.on( \"--version\", \"Show version\" ) { puts VERSION; exit }\n\n\t\t\tbegin\n\t\t\t\topts.parse!\n\t\t\trescue OptionParser::InvalidOption => ex\n\t\t\t\tputs ex.message\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\taction=ARGV[0]||\"\"\n\n\t\t\tcase action.downcase\n\t\t\t\twhen \"init\" then Coffle.init! @repository, @options\n\t\t\t\twhen \"build\" then instance_action=:build\n\t\t\t\twhen \"install\" then instance_action=:install\n\t\t\t\twhen \"uninstall\"then instance_action=:uninstall\n\t\t\t\twhen \"info\" then instance_action=:info\n\t\t\t\twhen \"status\" then instance_action=:status\n\t\t\t\twhen \"diff\" then instance_action=:diff\n\t\t\t\telse puts opts # Output the options help message\n\n\t\t\tend\n\n\t\t\tif instance_action\n\t\t\t\tcoffle=Coffle.new(@repository, @target, @options)\n\n\t\t\t\tcase instance_action\n\t\t\t\twhen :build then coffle.build! @options\n\t\t\t\twhen :install then coffle.install! @options\n\t\t\t\twhen :uninstall then coffle.uninstall! @options\n\t\t\t\twhen :info then coffle.info! @options\n\t\t\t\twhen :status then coffle.status! @options\n\t\t\t\twhen :diff then coffle.diff! @options\n\t\t\t\tend\n\n\t\t\t\tcoffle.write_status\n\t\t\t\tcoffle.write_target_status\n\t\t\tend\n\t\tend", "def command_line\r\n ARGV.each do |arg|\r\n if arg == \"instructions\"\r\n instructions\r\n elsif arg == \"calculator\"\r\n ask_for_digits\r\n else\r\n \r\n end\r\n end\r\n \r\n end", "def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [-c || --config ] FILE [-d || --testdir] DIR\"\n\n options[:testdir] = nil\n opts.on( '-d', '--testdir DIR', 'Execute tests in DIR' ) do|dir|\n options[:testdir] = dir\n end\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend", "def main()\n\n host = nil\n do_ipv4 = true\n installer_options = Installer::parse_options(\n [ '--host', '-h', GetoptLong::REQUIRED_ARGUMENT ],\n [ '--no-ipv4', '-4', GetoptLong::NO_ARGUMENT ]\n ) {\n\n |opt, arg|\n puts(\"Handling external #{opt}\")\n case opt\n when '--host'\n host = arg.dup()\n when '--no-ipv4'\n do_ipv4 = false\n else\n # GetoptLong will raise an exception for a real error, so this is an extra option that the code has forgotten to parse.\n $stderr.puts(\"Unknown option: #{opt} #{arg}\")\n end\n }\n\n # Perform the installation and configuration as required.\n InstallMinimalSystem::install(installer_options) if installer_options.install?()\n InstallMinimalSystem::configure(installer_options, host, do_ipv4) if installer_options.configure?()\n\nend", "def run(args) #:nodoc:\n rdoc = RDocCommand.new\n commands[:rdoc] = rdoc if !commands[:rdoc]\n commands[:help] = DefaultHelpCommand.new(@@version,rdoc) if !commands[:help]\n exit_code = 0\n begin\n config = parse_config\n override_defaults_based_on_config(config)\n global_options,command,options,arguments = parse_options(args)\n copy_options_to_aliased_versions(global_options,command,options)\n global_options = convert_to_openstruct?(global_options)\n options = convert_to_openstruct?(options)\n if proceed?(global_options,command,options,arguments)\n command = commands[@@default_command] if !command\n command.execute(global_options,options,arguments)\n if !command.skips_post && @@post_block\n @@post_block.call(global_options,command,options,arguments)\n end\n end\n rescue Exception => ex\n\n @@stderr.puts error_message(ex) if regular_error_handling?(ex)\n\n exit_code = if ex.respond_to? :exit_code\n ex.exit_code\n else\n -2\n end\n raise ex if ENV['GLI_DEBUG'] == 'true'\n end\n exit_code\n end", "def parse_args\n opt = {}\n opt_parser = OptionParser.new do |opts|\n opts.banner = \"Usage: testLogin.rb [options]\"\n opts.separator('')\n opts.on('-b', '--browser [BROWSER]', \"Default is Chrome\") do |driver|\n opt[:browser] = driver\n end\n opts.on('-v', '--version [BUILDNO]', 'CODAP build number (build_0xxx). Default is latest') do |build|\n opt[:version] = build\n end\n opts.on('-r', '--root_dir [ROOTDIR]', 'Root directory of CODAP. Default is localhost:4020/dg') do |root|\n opt[:root]=root\n end\n opts.on('-t', '--trials [NUMBER OF TRIALS]') do |num_trials|\n opt[:num_trials]=num_trials\n end\n opts.on('-c', '--cases [NUMBER OF CASES]') do |cases|\n opt[:num_cases]=cases\n end\n opts.on('-d', '--delay [DELAY BETWEEN TRIALS (ms)]') do |delay|\n opt[:delay]=delay\n end\n opts.on('-f', '--filename [FILENAME where to save results]','Must be specified if writing to a new file') do |filename|\n opt[:filename]=filename\n end\n opts.on('-p', '--path [PATH where to save results, do not include home in path]') do |path|\n opt[:path]=path\n end\n opts.on('-s', '--sleep [SLEEP time between runs (s)]') do |sleep_time|\n opt[:sleep_time]=sleep_time\n end\n opts.on('-w', '--[no-]write [WRITE]', 'write to a new file-> must specify filename, default is append (no-write). If no file name is specified, results will be appended.') do |write|\n opt[:write]=write\n end\n\n end\n opt_parser.parse!(ARGV)\n return opt\nend", "def run(args = [], runtime_options = {})\r\n begin\r\n parse!(args.dup, runtime_options)\r\n rescue OptionParser::InvalidOption => e\r\n # Don't cry, script. Generators want what you think is invalid.\r\n end\r\n\r\n # Generator name is the only required option.\r\n unless options[:generator]\r\n usage if args.empty?\r\n options[:generator] ||= args.shift\r\n end\r\n\r\n # Look up generator instance and invoke command on it.\r\n Rails::Generator::Base.instance(options[:generator], args, options).command(options[:command]).invoke!\r\n rescue => e\r\n puts e\r\n puts \" #{e.backtrace.join(\"\\n \")}\\n\" if options[:backtrace]\r\n raise SystemExit\r\n end", "def parse!\n begin\n parse\n rescue Exception => e\n raise e if @options[:trace] || e.is_a?(SystemExit)\n\n $stderr.print \"#{e.class}: \" unless e.class == RuntimeError\n $stderr.puts \"#{e.message}\"\n exit 1\n end \n exit 0\n end" ]
[ "0.767985", "0.74173754", "0.71463656", "0.7116004", "0.705908", "0.70411134", "0.7036456", "0.6995846", "0.6971928", "0.69436526", "0.6931246", "0.6906994", "0.6893284", "0.6886774", "0.6882564", "0.68564314", "0.6835208", "0.68287444", "0.6809437", "0.6796433", "0.6790949", "0.6790949", "0.6790949", "0.6790949", "0.6790949", "0.6790949", "0.67828023", "0.6782513", "0.6766386", "0.6758998", "0.67557466", "0.67543554", "0.67464954", "0.6731792", "0.6720772", "0.6718823", "0.6704486", "0.6699307", "0.66878647", "0.6687357", "0.6683952", "0.6678493", "0.66755986", "0.66711336", "0.66652083", "0.66553617", "0.66515774", "0.66406876", "0.6640071", "0.66297793", "0.66088533", "0.6601325", "0.65829664", "0.65607053", "0.65603906", "0.6551518", "0.654737", "0.6544605", "0.6528091", "0.6526687", "0.6511459", "0.6498597", "0.6477183", "0.64491844", "0.6443777", "0.6442699", "0.64249367", "0.6409581", "0.63748527", "0.63700294", "0.6369888", "0.6353176", "0.6352004", "0.63402987", "0.6298672", "0.62979233", "0.62968916", "0.6291317", "0.6271322", "0.626289", "0.6258301", "0.62541133", "0.62540674", "0.6250345", "0.6248672", "0.62474215", "0.6241715", "0.62229615", "0.62188876", "0.62165445", "0.6213659", "0.6198138", "0.61904514", "0.6186688", "0.6183035", "0.6176189", "0.6173287", "0.6167628", "0.61666596", "0.6161623" ]
0.8654356
0
=== Description Print out msg to STDOUT
def puts_msg(msg) STDOUT.puts(msg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_message(msg)\n print \">> #{msg.to_s} \\n\"\n end", "def message(msg)\n STDOUT.puts msg\n end", "def out(msg)\n io.print(msg) if io\n end", "def msg(message)\n stdout.puts message\n end", "def print_stdout(msg)\n puts \" #{msg}\"\n end", "def print(msg)\n out_stream.print(msg) if out_stream\n end", "def print(msg)\n Java::OrgFusesourceJansi::AnsiConsole::out.print msg\n end", "def print(msg)\n info(msg)\n end", "def puts(msg)\n info(msg)\n end", "def puts (msg)\n $stderr.puts msg\n end", "def display(msg)\n stdout.puts msg\n return \"#{msg}\\n\"\n end", "def puts(msg)\n @out.puts msg unless @silent\n end", "def print(msg = '')\n clear_line\n print_no_newline(msg)\n end", "def puts(msg) # rubocop:disable Lint/UnusedMethodArgument\n info(msg)\n end", "def output(msg)\n puts \"*****#{msg}*****\"\nend", "def info_msg(msg=\"\")\n puts(msg)\n @file.puts(msg)\n end", "def puts(msg = '')\n print(\"#{msg}\\n\")\n end", "def out(msg = nil)\n if msg.nil?\n @out\n else\n @out.puts msg\n end\n end", "def say(msg)\n print msg + \"\\r\\n\"\n end", "def info(msg)\n puts msg\n end", "def info(msg)\n if Dotgpg.interactive?\n $stdout.puts msg\n end\n end", "def output_message msg\n puts \"***** #{msg} *****\"\nend", "def display(msg)\n puts\n puts msg\n end", "def print_raw(msg = '')\n\t\t$stdout.print(msg)\n\t\t$stdout.flush\n\n\t\tmsg\n\tend", "def print(msg) # rubocop:disable Lint/UnusedMethodArgument\n info(msg)\n end", "def putsNow(msg)\n\t\tprintState = @out.sync\n\t\t@out.sync = true\n\t\t@out.print(msg)\n\t\t@out.sync = printState\n\tend", "def emit(msg)\n print msg\n $stdout.flush\n end", "def write(msg)\n\t\tinfo(msg)\n\tend", "def v_puts(msg)\n puts msg if @options[:verbose]\n end", "def message cmd, msg\n print_message cmd, 'INFO', msg\nend", "def log(msg)\n puts msg\n $stdout.flush\n end", "def puts(msg)\n @buffer << \"#{msg}\\n\"\n end", "def msg(text)\n print text if VERBOSE\n STDOUT.flush\nend", "def log(msg)\n # puts msg\n $stdout.write(\"#{msg}\\n\")\n end", "def log(msg)\n puts msg\n $stdout.flush\n end", "def info(msg)\n if verbose?\n verbose_io << msg << \"\\n\"\n verbose_io.flush\n end\n end", "def print_status(msg)\n puts \"\" if verbose_mode?\n puts \"#{color('----->', 32)} #{msg}\"\n end", "def write(msg)\n @handle.puts(msg)\n end", "def message( *parts )\n\t\t$stdout.puts( *parts )\n\tend", "def puts(message)\n @out.puts message\n end", "def output(msg = @message)\n @output ||= self.class.check_name + (msg ? \": #{msg}\" : '')\n end", "def print(message)\n output.print(message)\n end", "def disp_msg(msg_in)\n puts \"=> #{msg_in}\"\nend", "def echo msg\n $stdout.puts msg\nend", "def print(msg)\n message = msg['message']\n @logger.debug(\"Printing msg #{message}\")\n print_raw(message)\n end", "def tell_user(message, stdout: $stdout)\n stdout.puts message\n end", "def print_status(msg = '')\n $stderr.puts \"[*] #{msg}\"\n end", "def out(msg)\n puts \"#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")} #{msg}\" if DEBUG_OUTPUT\nend", "def output(msg, options={})\n self.client_class.otm_output(\"[#{self.class.to_s}]#{msg}\",options)\n end", "def message(message)\n Kernel.puts(message.to_s)\nend", "def normal(msg)\n print \"#{@yel} -> #{msg}...#{@ncl}\"\n print \"\\r\"\n @lastMsg = msg\n end", "def report(msg, stdout) \n\t\t@file.print msg\n\t\tif (stdout==1)\n\t\t\t# puts \"entrei\"\n\t\t\tprint msg\n\t\tend\n\tend", "def puts(message); end", "def print_command(msg)\n puts \" #{color(\"$\", 32)} #{color(msg, 32)}\"\n end", "def show(msg)\n puts msg\n false\n end", "def log(msg)\n STDERR.print \"** \", msg, \"\\n\"\n end", "def print_error_message(msg)\n print \"<< ERROR: #{msg.to_s} !!\\n\"\n end", "def print(message); end", "def print(message); end", "def info_msg(msg)\n @log.puts(msg)\n puts msg\nend", "def otm_output(msg, options={})\n puts \"[#{Time.now.to_s}][#{self.to_s}]#{msg}\"\n end", "def print(msg)\r\n puts msg\r\n exit(0)\r\n end", "def output(msg,level=0)\n if level < 2 && !@debug\n return\n elsif level < 1 && !@verbose\n return\n end\n color = $default\n case level\n when 0\n color = $info\n when 1\n color = $warn\n when 2\n color = $error\n when 3\n color = $success\n else\n color = $default\n end\n\n $stderr.printf(\"%s%s%s\\n\" % [color, msg, $default])\n end", "def info(msg)\n puts \"\\n ==> #{msg}\"\nend", "def display(msg)\n puts \"=\" * 15 + \" REQUEST \" + \"=\" * 15 \n puts msg\n puts \"=\" * 15 + \" EOF REQUEST \" + \"=\" * 15\n end", "def puts(msg)\n msg = msg.to_s\n @logger.unknown(msg)\n msg\n end", "def puts message\n print \">> \" + message +\"\\n\"\nend", "def real_puts message = \"\"\n $stdout.puts message\n end", "def puts(msg, caller_depth = 0)\r\n SAF.info(message: msg, caller_depth: caller_depth)\r\n end", "def print_raw(msg = '')\n $stdout.print(msg)\n $stdout.flush\n\n return if not self.fd\n self.fd.write(msg)\n self.fd.flush\n msg\n end", "def log(msg)\n puts msg\n end", "def message text\n $stderr.puts text\n end", "def message text\n $stderr.puts text\n end", "def error_message(msg)\n STDERR.puts msg\n end", "def internal_puts( *msg )\n puts *msg if verbose\n end", "def message(message)\n Kernel.puts(\"=> #{message}\")\nend", "def print_stderr(msg)\n puts \" #{color(msg, 31)}\"\n end", "def tell(message)\n puts message\n end", "def msg(message)\n stdout.puts message\n rescue Errno::EPIPE => e\n raise e if @config[:verbosity] >= 2\n\n exit 0\n end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def puts(message)\n output.puts(message)\n end", "def print_ok(msg)\n tag = '[ OK ]'\n print_formatted(tag,msg)\n end", "def add_msg(msg, type = nil)\n ##### local message event\n puts msg\n $stdout.flush\n end", "def write_output(message)\n STDOUT.puts(message)\n end", "def write_output(message)\n STDOUT.puts(message)\n end", "def message(output)\n puts \"\"\n puts output\nend", "def print_line(msg = '')\n # TODO: there are unhandled quirks in async output buffering that\n # we have not solved yet, for instance when loading meterpreter\n # extensions, supporting Windows, printing output from commands, etc.\n # Remove this guard when issues are resolved.\n=begin\n if (/mingw/ =~ RUBY_PLATFORM)\n print(msg + \"\\n\")\n return\n end\n print(\"\\033[s\") # Save cursor position\n print(\"\\r\\033[K\" + msg + \"\\n\")\n if input and input.prompt\n print(\"\\r\\033[K\")\n print(input.prompt.tr(\"\\001\\002\", ''))\n print(input.line_buffer.tr(\"\\001\\002\", ''))\n print(\"\\033[u\\033[B\") # Restore cursor, move down one line\n end\n=end\n\n print(msg + \"\\n\")\n end", "def message(msg)\n $stdout.puts(msg) unless $options['quiet']\nend", "def print_info(msg)\n tag = '[ INFO ]'\n print_formatted(tag,msg)\n end", "def print_raw(msg = '')\n if (Rex::Compat.is_windows and supports_color?)\n WindowsConsoleColorSupport.new(io).write(msg)\n else\n io.print(msg)\n end\n\n io.flush\n\n msg\n end", "def print_verbose(msg)\n puts msg if (@verbose) \n STDOUT.flush\n end", "def log_action msg\n\t\t\t\tputs '=> ' + msg\n\t\t\tend", "def msg(msg)\n if @name\n \"[#{name}] #{msg}\"\n else\n msg\n end\n end", "def topic(message)\n Kernel.puts \"-----> #{message}\"\n $stdout.flush\nend", "def print_verbose(msg = '')\n $stderr.puts \"[*] #{msg}\" if self.verbose\n end" ]
[ "0.8586264", "0.85794103", "0.8359861", "0.83237344", "0.82765245", "0.8213711", "0.8157286", "0.8143191", "0.81098366", "0.7982241", "0.79725975", "0.79621303", "0.7821825", "0.7745828", "0.77333415", "0.76939815", "0.76923054", "0.7665979", "0.76278186", "0.76264846", "0.7611473", "0.76102394", "0.75766987", "0.75626385", "0.75373846", "0.75168127", "0.74869925", "0.74648273", "0.7455296", "0.7453644", "0.7439074", "0.74350077", "0.7396451", "0.73928785", "0.73703", "0.7364878", "0.7324884", "0.7302351", "0.7302179", "0.7293055", "0.72884935", "0.7285939", "0.7232537", "0.72191703", "0.7180746", "0.7166353", "0.71489257", "0.7145709", "0.7116593", "0.7114478", "0.7110442", "0.7106082", "0.71045333", "0.7071362", "0.7053215", "0.7051676", "0.70474476", "0.70385474", "0.70385474", "0.70179844", "0.701392", "0.70103544", "0.7003342", "0.69921076", "0.6990772", "0.69767267", "0.69754124", "0.69733423", "0.69715834", "0.69715077", "0.6967022", "0.6964911", "0.6964911", "0.6959966", "0.6956429", "0.6949706", "0.69425774", "0.69399816", "0.6934747", "0.69265294", "0.69265294", "0.69265294", "0.69265294", "0.69265294", "0.69265294", "0.6926438", "0.69211423", "0.6899384", "0.6895057", "0.6895057", "0.6888701", "0.68871135", "0.6878156", "0.68771124", "0.6873165", "0.6872924", "0.6857463", "0.68432283", "0.6835974", "0.682845" ]
0.8524942
2
=== Description Print out msg to STDERR in red color
def puts_err(msg) STDERR.puts(msg.to_s.red) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_stderr(msg)\n puts \" #{color(msg, 31)}\"\n end", "def error_message( msg, details='' )\n\t\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details\n\t\tend", "def error_message( msg, details='' )\n\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + ' ' + details\n\tend", "def print_error(msg)\n puts \" #{color(\"!\", 33)} #{color(msg, 31)}\"\n end", "def error(msg)\n puts \"\\e[0;31m#{ msg }\\e[0m\"\n end", "def error(message)\n message = message.red unless message.color?\n puts(stderr, message)\n end", "def error(msg)\n puts red(bold(\"[!] #{msg}\"))\n end", "def error(message)\n STDERR.puts red(message)\n end", "def err(msg)\n puts msg.red\n exit(1)\n end", "def log( *msg )\n\t\t\toutput = colorize( msg.flatten.join(' '), 'cyan' )\n\t\t\t$stderr.puts( output )\n\t\tend", "def error(msg)\n puts \"\\n#{@red}[Error] #{msg}!#{@ncl}\\n\"\n end", "def error_message(msg)\n STDERR.puts msg\n end", "def error(message)\n $stderr.puts colorize(message, :error)\n end", "def error(*args); say $terminal.color(format(*args), :red); end", "def err(message)\n stderr.puts message\n end", "def error(msg) $stderr.puts(\"Error: #{msg}\") end", "def trace( *msg )\n\t\t\treturn unless Rake.application.options.trace\n\t\t\toutput = colorize( msg.flatten.join(' '), 'yellow' )\n\t\t\t$stderr.puts( output )\n\t\tend", "def display_error(message)\n puts \"\\e[31;1m[ERROR]\\e[0m #{message}\"\n end", "def error(message, options = {})\n options[:prefix] ||= \" - \"\n options[:color] ||= :red\n output message, options\n end", "def error(*args)\n color(31, *args)\n end", "def err(input)\n puts \"[#{Time.now.strftime(\"%T\").purple} \" + \"ERROR\".red + \"] \" + \"#{input.red}\"\n end", "def bold_error(*args)\n color('1;31', *args)\n end", "def err(message = '')\n @out_sections = [] unless defined?(@out_sections)\n message = \"#{' ' * @out_sections.size}#{message}\"\n # log_debug \"<Output> - #{message}\"\n message = \"#{message}\\n\" unless message.end_with?(\"\\n\")\n @logger_stderr << message\n end", "def print_err(err)\n Weechat.print '', \"%sTTS\\t%s - %s\" % [\n Weechat.color('red'),\n err.class.name,\n err.message\n ]\n end", "def error(message)\n err(\"#{color('ERROR:', :red, :bold)} #{message}\")\n end", "def warn(message)\n $stdout.puts(message.red)\nend", "def err(dir, msg)\n msglen = msg.length + 6\n warn(format(\"%-#{TW - msglen}<dir>s %<msg>s\", dir: dir, msg: msg))\n end", "def puts_error(msg)\n warn \"\\e[31m[ERROR] #{msg}\\e[0m\" if Calamum::Config[:debug]\n exit(1)\nend", "def output(msg,level=0)\n if level < 2 && !@debug\n return\n elsif level < 1 && !@verbose\n return\n end\n color = $default\n case level\n when 0\n color = $info\n when 1\n color = $warn\n when 2\n color = $error\n when 3\n color = $success\n else\n color = $default\n end\n\n $stderr.printf(\"%s%s%s\\n\" % [color, msg, $default])\n end", "def error(text)\n STDERR.puts red_term_text(text)\n end", "def say_error(*args)\n args.each do |arg|\n say HighLine.default_instance.color(arg, :red)\n end\n end", "def print_status(msg = '')\n $stderr.puts \"[*] #{msg}\"\n end", "def fail(text)\n puts \"#{text}\".foreground(:red)\n end", "def print_error_message(msg)\n print \"<< ERROR: #{msg.to_s} !!\\n\"\n end", "def warn(*args); say $terminal.color(format(*args), :magenta); end", "def print_error(msg)\n tag = '[ ERROR ]'\n print_formatted(tag,msg)\n end", "def print_error(msg = '')\n $stderr.puts \"[ERROR] #{msg}\"\n 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 stderr(*msgs)\n STDERR.puts(*msgs)\n end", "def error(msg)\n stderr(\"error: #{msg}\")\n end", "def error(msg)\n STDERR.puts \"#{@progname}: FAIL: #{msg}\"\n end", "def red(msg)\n \"\\033[31m#{msg}\\033[39m\"\nend", "def show_error_encountered(error)\n print \"\\033[31mError encountered:\\033[0m\\n\"\n print error.inspect\n end", "def warning(msg) $stderr.puts(\"Warning: #{msg}\") end", "def warning(msg) $stderr.puts(\"Warning: #{msg}\") end", "def warning(msg) $stderr.puts(\"Warning: #{msg}\") end", "def error_color(text)\r\n \"<font color=red>#{text}</font>\"\r\n end", "def warning(*args)\n color(33, *args)\n end", "def outputs(type, msg, style = :plain)\n line = \"#{type}> #{msg}\"\n line = line.color(:red) if (style == :err) || (style == :error)\n line = line.color(:green) if style == :ok\n line = line.color(:cyan) if style == :ok2\n\n $stdout.puts line\n end", "def puts_color( msg, color=nil )\n color_set( color ); puts msg; color_end\n end", "def puts (msg)\n $stderr.puts msg\n end", "def print_status(msg)\n puts \"\" if verbose_mode?\n puts \"#{color('----->', 32)} #{msg}\"\n end", "def warning(text)\n puts color.colorize(text, :yellow)\n end", "def red(output)\n color(31, output)\n end", "def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end", "def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end", "def output_terminal_errors\n errors.each { |error| plain_output(error.to_s, 'red') }\n plain_output(\"\\nPlease go to https://rails-bestpractices.com to see more useful Rails Best Practices.\", 'green')\n if errors.empty?\n plain_output(\"\\nNo warning found. Cool!\", 'green')\n else\n plain_output(\"\\nFound #{errors.size} warnings.\", 'red')\n end\n end", "def err(message)\n warn \" > #{message}\"\nend", "def error(msg = '')\n\t\toutput.print_error(msg)\n\tend", "def print_error(text)\n\tif STDOUT.tty?\n\t\tputs \"\\e[31m[!]\\e[0m #{text}\"\n\telse\n\t\tputs \"[!] #{text}\"\n\tend\nend", "def error message\n message = \"ERROR: \" + process_message(message)\n output_message message, @error_color if valid_conditions 3\n end", "def msg(text, level = :info)\n case level\n when :warn\n puts \"\\e[31m#{text}\\e[0m\"\n else\n puts \"\\e[33m#{text}\\e[0m\"\n end\nend", "def msg(text, level = :info)\n case level\n when :warn\n puts \"\\e[31m#{text}\\e[0m\"\n else\n puts \"\\e[33m#{text}\\e[0m\"\n end\nend", "def pretty_print(msg)\n if logger.level == Logger::IMPORTANT\n errors\n print '✔'+ msg.green + \"\\n\\r\"\n else\n puts '✔'+ msg.green\n end\nend", "def error(message)\n $stderr.puts message\n end", "def debug_msg *msg\n return unless $DEBUG_RDOC\n $stderr.puts(*msg)\n end", "def debug_msg *msg\n return unless $DEBUG_RDOC\n $stderr.puts(*msg)\n end", "def printerr *s\n s.each do |_|\n Lib.g_application_command_line_printerr self.ffi_pointer, _.to_s+\"\\n\"\n end\n end", "def debug_msg(msg)\n $stderr.puts(msg) if $DEBUG_RDOC\n end", "def status(text)\n STDERR.puts blue_term_text(text)\n end", "def puts_warning(msg)\n $stdout.puts \"\\e[33m[WARNING] #{msg}\\e[0m\" if Calamum::Config[:debug]\nend", "def error_message(message)\n Format(:red, bold_message(message))\n end", "def html_out(msg, color_name=\"black\")\n\t\t\trgb = Color::RGB::by_name color_name\n\t\t\tputs \"<span style='color:#{rgb.css_rgb};'>#{msg}</span>\"\n\t\tend", "def err(message)\n STDERR.puts(message)\n exit 1\n end", "def message text\n $stderr.puts text\n end", "def message text\n $stderr.puts text\n end", "def warning(text)\n STDERR.puts yellow_term_text(text)\n end", "def error(msg)\n return if @nolog\n puts msg\n exit 5\n end", "def warn(msg)\n stderr \"warning: #{msg}\"\n end", "def error(message, color = :red)\n Strainer.log.error(message)\n\n return if quiet?\n message = set_color(message, *color) if color\n super(message)\n end", "def log_stderr(type: :info, message:)\n $stderr.puts log_entry(type, message)\n end", "def error(message)\n STDERR.puts message\nend", "def display_error_message(ex)\n $stderr.puts self.to_s()\n super(ex) \n end", "def invalid_color_msg(_clr)\n ''\n end", "def invalid_color_msg(_clr)\n ''\n end", "def log(msg)\n STDERR.puts msg\n end", "def log(msg)\r\n STDERR.puts msg\r\n end", "def stderr_log(lines)\n Array(lines).each do |line|\n $stderr.puts(Core::Color.colorize(\">>>>>> #{line}\", :red))\n end\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end", "def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end", "def error_style(error)\n red_style(error)\nend", "def log(msg)\n STDERR.print \"** \", msg, \"\\n\"\n end", "def errmsg(message)\n print(\"*** #{message}\\n\")\n end", "def say_error(string)\n HighLine.new.say(\"\\n<%= color('#{string}', :error ) %>\\n\")\n end", "def warn(message)\n err(\"#{color('WARNING:', :yellow, :bold)} #{message}\")\n end", "def error(message)\n log.error(message.to_s.red)\n end", "def errmsg(message)\n error.print(\"*** #{message}\\n\")\n end", "def stderr; end", "def stderr; end" ]
[ "0.87337965", "0.82728803", "0.8242551", "0.82000345", "0.8098276", "0.8080287", "0.78530663", "0.780545", "0.7705156", "0.76129603", "0.7535064", "0.741853", "0.73221236", "0.7239498", "0.7171502", "0.71554863", "0.71274287", "0.7108954", "0.70611954", "0.7034199", "0.701279", "0.69998443", "0.69611394", "0.6957533", "0.69574744", "0.69556916", "0.69416046", "0.69255894", "0.69252574", "0.6909174", "0.6892773", "0.68813074", "0.6846376", "0.684582", "0.6844324", "0.68299335", "0.6807412", "0.6782445", "0.67693645", "0.6760822", "0.67432", "0.6723188", "0.6723064", "0.6669934", "0.6669934", "0.6669934", "0.66639924", "0.6649386", "0.6645586", "0.6616722", "0.6597232", "0.6595084", "0.65932226", "0.6591425", "0.6585161", "0.6585161", "0.65829146", "0.65663224", "0.65637994", "0.6561281", "0.65374815", "0.6530324", "0.6530324", "0.6515506", "0.64974463", "0.6460325", "0.6460325", "0.6453051", "0.6449541", "0.6444212", "0.6442032", "0.64323235", "0.64296955", "0.6421063", "0.6418044", "0.6418044", "0.64046764", "0.64041996", "0.6392054", "0.63901013", "0.6385006", "0.63748735", "0.6362775", "0.63496417", "0.63496417", "0.6330956", "0.6321858", "0.63095504", "0.63086766", "0.63086766", "0.63086766", "0.62997055", "0.629043", "0.62805396", "0.6274114", "0.6270653", "0.62586963", "0.6248618", "0.622997", "0.622997" ]
0.8678974
1
Write a method that returns true if its integer is palindromic, false otherwise. A palindromic number reads the same forwards and backwards.
def palindromic_number?(num) num.to_s == num.to_s.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palindromic_number?(int)\r\n int.to_s == int.to_s.reverse\r\nend", "def palindromic_number?(int)\n int.to_s == int.to_s.reverse\nend", "def palindromic_number?(integer)\n integer.to_s == integer.to_s.reverse!\nend", "def palindromic_number?(integer)\n integer.to_s == integer.to_s.reverse\nend", "def palindromic_number?(n)\n n.to_s == n.to_s.reverse\nend", "def palindromic?(number)\n if number.to_s == number.to_s.reverse\n return true\n end\nend", "def palindromic_number?(int)\n str = int.to_s\n str == str.reverse\nend", "def palindromic_number?(num)\n num == num.to_s.reverse.to_i\nend", "def palindromic_number?(num)\n num == num.to_s.reverse.to_i\nend", "def palindromic_number?(integer)\n string = integer.to_s\n string == string.reverse\nend", "def palindromic?(number)\n number.to_s == number.to_s.reverse\nend", "def palindromic_number?(int)\n new_int = int.to_s\n new_int = new_int.reverse\n new_int = new_int.to_i\n int == new_int\nend", "def palindromic_number?(integer)\n digits = integer.to_s\n digits == digits.reverse\nend", "def palindromic_number?(num)\n num.to_s == num.to_s.reverse\nend", "def palindromic_number?(int)\n new_integer = int.to_s.reverse\n new_integer == int.to_s\nend", "def palindromic_number?(int)\n arr = int.to_s\n if arr == arr.reverse\n p true\n else\n p false\n end\n\nend", "def palindromic_number?(integer)\n int_to_string = integer.to_s\n if integer == int_to_string.to_i\n true\n else\n false\n end\nend", "def palindromic_number?(number)\n number.to_s.reverse.to_i\nend", "def IsPalindromic(value)\r\n @value = value\r\n @n = @value\r\n @rev = 0\r\n \r\n while @value > 0\r\n @digit = @value % 10\r\n \r\n @rev = @rev * 10 + @digit\r\n @value = @value / 10\r\n end\r\n \r\n return (@n == @rev)\r\n end", "def palindromic_number?(num)\n num.to_s.chars.join(\"\").reverse.to_i == num\nend", "def palindromic_number?(num)\n\tstr = num.to_s\n\n\tnum == str.reverse.to_i\nend", "def palindromic_number?(int)\n string_num = int.abs.to_s\n string_num == string_num.reverse\nend", "def palindromic_number?(num)\n num = num.to_s\n num == num.reverse\nend", "def palindromic_number?(num)\n string = num.to_s\n string == string.reverse\nend", "def palindromic?(number)\n num = number.to_s.split('')\n (1..(num.size/2)).all? do |index|\n num[index-1] == num[index*(-1)]\n end\nend", "def palindromic_number?(number)\n palindrome?(number.to_s)\nend", "def palindromic?(input)\n input == input.reverse\nend", "def palindromic_number?(num)\n num.to_s \nend", "def palindromic_number?(number)\n index = -1\n rev_array = Array.new(\"#{number}\".length)\n \"#{number}\".chars.each do |char|\n rev_array[index] = char.to_i\n index -= 1\n end\n number == rev_array.join.to_i\nend", "def palindromic?(i)\n i.to_s == i.to_s.reverse\nend", "def palindromic_number?(num)\n palindrome?(num.to_s)\nend", "def palindromic?(x)\n x.to_s == x.to_s.reverse\nend", "def is_palindrome? number\n num_string = number.to_s\n counter = num_string.length / 2\n\n palindromic = true\n counter.times {|n| palindromic &&= ( num_string[n] == num_string[-n-1])}\n\n palindromic\nend", "def palindromic(num) \n if num.to_s.split(\"\") == num.to_s.split(\"\").reverse\n true \n else \n false \n end \nend", "def palindromic_number?(number, zeros=0)\n number = \"#{'0' * zeros}%o\" % number if zeros > 0\n palindrome?(number.to_s)\nend", "def palindrom?(string)\n string == string.reverse\nend", "def palindrome?( num )\n num.to_s == num.to_s.reverse\nend", "def palindrome?\n n = self\n\n digit_array = n.to_s.each_char.map(&:to_i)\n digit_array.shift if n < 0\n\n start_index = 0\n end_index = digit_array.length - 1\n\n palindrome = true\n loop do\n break if end_index < start_index\n\n if digit_array[start_index] == digit_array[end_index]\n start_index += 1\n end_index -= 1\n\n break if end_index == start_index\n else\n palindrome = false\n break\n end\n end\n\n return palindrome\n end", "def is_palindrome (n) #Checks to see if the number is a palindrome\n if n == n.reverse\n return true\n end\nend", "def palindrome?(num)\n num.to_s == num.to_s.reverse\nend", "def palindrome_integer(num)\n if num > 0 \n str_num = num.to_s\n return true if str_num == str_num.reverse\n end \n false \n \nend", "def is_palindrome?(num)\n binary = num.to_s(2)\n num = num.to_s\n\n num.reverse == num && binary == binary.reverse\nend", "def isPalindromic(val)\n\tln = val.length\n\tmiddle = ln / 2.0\n\tarr = val.split('')\n\t0.upto(middle) do |x|\n\t\tif(arr[x] != arr[ln - x - 1]) then return false end\n\tend\n\treturn true\nend", "def is_palandrome?(number)\n return number.to_s == number.to_s.reverse\nend", "def is_palindrome?(num)\n characters = num.to_s\n return true if characters == characters.reverse\n false\nend", "def palindrome?(n)\n n.to_s == n.to_s.reverse\nend", "def is_palindrome?(num)\n num.to_s == num.to_s.reverse\nend", "def is_palindrome?(number)\n\tnumber.to_s.reverse == number.to_s\nend", "def is_palindrome(number)\n return false if number == nil || number < 0\n i = 10\n while (number % (i)) != number\n i *= 10\n end\n i /= 10\n while i > 10\n if (number / i) == (number % 10)\n number = (number % i) / 10\n i /= 100\n else\n return false\n end\n end\n return true\nend", "def is_palindrome(number)\n return false if number == nil || number < 0\n i = 0\n placeholder = number\n until placeholder == 0\n placeholder /= 10\n i += 1\n end\n until i <= 0\n i -= 1\n\n if number % 10 != number / 10 ** i\n return false\n end\n\n number -= (number / 10 ** i) * 10 ** i\n number /= 10\n\n i -= 1\n end\n return true\nend", "def is_palindrome?(n)\n n.to_s == n.to_s.reverse!\nend", "def is_palindrome?(n)\n n.to_s == n.to_s.reverse\n end", "def is_palindrome(number)\n return false if number == nil || number < 0\n\n num = number\n reverse = 0\n\n while num > 0\n last = num % 10\n reverse = (reverse * 10) + last\n num /= 10\n end\n\n reverse == number ? true : false\n\nend", "def is_palindrome?(number)\n number.to_s == number.to_s.reverse\nend", "def is_palindrome?(number) # step 2\n digit_array = number.to_s.split('')\n return true if digit_array.reverse == digit_array\nend", "def is_palindrome(number)\n return true if number.to_s == number.to_s.reverse\n return false\nend", "def is_palindrome(number)\n return false if number == nil\n return true if number == 0\n reverse = 0\n while number > 0\n temp = number # can check if temp = reverse\n digit = number % 10\n reverse = reverse * 10 + digit\n number = number / 10\n # number_even = number * 10 + digit\n p \"temp: #{temp}\"\n p \"digit: #{digit}\"\n p \"reverse: #{reverse}\"\n p \"number: #{number}\"\n\n return true if number == reverse || temp == reverse\n # return true if number == reverse\n end\n return false\nend", "def is_palindrome(number)\n number.to_s.reverse == number.to_s\nend", "def is_palindrome(number)\n if number.nil?\n return false\n end\n\n if number < 0\n return false\n end\n\n if number % 10 == 0 && number != 0\n return false\n end\n\n reverted = 0\n while number > reverted\n reverted = reverted * 10 + number % 10\n number /= 10\n end\n\n return number == reverted || number == reverted / 10\nend", "def pallindrome? n\n n.to_s == n.to_s.reverse\nend", "def is_palindrome(number)\n if (number.to_s == number.to_s.reverse)\n return true\n else\n return false\n end\nend", "def is_palindrome(number)\n return false if number == nil || number < 0\n\n k = 0\n clone_number = number\n\n until clone_number == 0\n clone_number /= 10\n k += 1\n end\n\n return true if k == 1\n\n i = 1\n\n until i > k / 2\n a = number % 10 ** (k + 1 - i) / 10 ** (k - i)\n b = (number / 10 ** (i - 1)) % 10\n return false if a != b\n i += 1\n end\n\n return true\nend", "def is_palindrome?(num)\n\tdigit_array = num.to_s.chars.map(&:to_i)\n\tlength = digit_array.length\n\teach_half = digit_array.each_slice(length/2).map(&:to_a)\n\treturn each_half[0] == each_half[1].reverse\nend", "def palin?(n)\n n.to_s == n.to_s.reverse\nend", "def is_palindrome(number)\n return false if !number || number < 0\n length = 1\n until number / (10 ** length) == 0\n length += 1\n end\n (length / 2).times do |i|\n return false if (number / (10 ** (length - i - 1))) % 10 != (number % (10 ** (i + 1))) / (10 ** i)\n end\n return true\nend", "def palindromic_number?(int)\n int_arr = []\n \nend", "def isPalidrome(str)\n str == str.reverse\nend", "def is_palindrome(n)\n string = n.to_s\n string == string.reverse\nend", "def check_palindromic(variable)\n if variable == variable.reverse\n puts \"#{ variable } is a palindrome.\"\n else\n puts \"#{ variable } is not a palindrome.\"\n end\nend", "def is_palindrome(number)\n return false if number.class != Integer || number < 0\n\n # create a varibale to store the result number\n result = 0\n prev_result = 0\n copy_num = number\n\n while copy_num != 0\n current_digit = copy_num % 10\n result = result * 10 + current_digit\n\n # This is to handle overflow\n return false if ((result - current_digit) / 10) != prev_result\n\n prev_result = result\n copy_num = copy_num / 10\n end\n return result == number\nend", "def is_palindrome(number)\n return false if !number\n return false if number < 0\n return true if number < 10\n modulo = 10\n divide = 10\n digets = 2\n until number / divide < 10\n divide *= 10\n digets += 1\n end\n (digets / 2).times do\n return true if number == 0\n return false if number % modulo != number / divide\n first_num = number / divide\n number = (number % (first_num * divide)) / modulo\n divide /= 100\n end\n return true\nend", "def is_palindrome(number)\n if number == nil || number < 0\n return false\n elsif number == 0\n return true\n end\n\n # Count number of digits in number.\n digit_count = 0\n div_result = 0\n int = number\n until div_result == 0 && digit_count > 0\n digit_count += 1\n div_result = int / 10\n int /= 10\n end\n if digit_count == 1\n return true\n end\n\n # Math to check for palindrome.\n count = 1\n (digit_count / 2).times do\n if number % 10 != number / (10 ** (digit_count - count))\n return false\n else\n number = number / 10\n count += 1\n number = number % (10 ** (digit_count - count))\n count += 1\n end\n end\n return true\nend", "def q10_palindromic?(num)\n q9_palindrome?(num.to_s)\nend", "def is_palindrome?(num)\r\n\tnum = num.to_s\r\n\t# Go down array, checking each number against its relevant counterpart down the line\r\n\tnum.length.times do |x|\r\n\t\treturn false unless num[x] == num[num.length-1-x]\r\n\tend\r\n\ttrue\r\nend", "def palindrome?(input)\n input == input.reverse\nend", "def palindrome?(input)\n input == input.reverse\nend", "def palindrome?(input)\n input == input.reverse\nend", "def palindrome?(input)\n input == input.reverse\nend", "def valid_palindrome(str)\n l_ndx = 0\n r_ndx = str.size - 1\n while l_ndx < r_ndx\n unless str[l_ndx] == str[r_ndx]\n return palindromic?(str, l_ndx, r_ndx - 1) || palindromic?(str, l_ndx + 1, r_ndx)\n end\n\n l_ndx += 1\n r_ndx -= 1\n end\n\n true\nend", "def is_palindrome?(num)\n num_string = num.to_s\n num_string == num_string.reverse\nend", "def palindromic_number?(num)\n # my_list = num.digits\n # array_palindrome?(my_list)\n my_list = num.to_s\n palindrome?(my_list)\nend", "def palindrome?(werd)\n werd == werd.reverse\nend", "def palindrome?(sequence)\n sequence == sequence.reverse\nend", "def Palindrome? (number)\r\n nstr = number.to_s()\r\n nstr == nstr.reverse\r\n end", "def hack?(n)\n binary_n = n.to_s(2).to_i\n palindrome? binary_n and sum_digits(binary_n).odd?\nend", "def Palindrome? (number)\r\n nstr = number.to_s()\r\n nstr == nstr.reverse\r\nend", "def is_palindrome?(x)\n x.to_s == x.to_s.reverse ? true : false\nend", "def palindrome?(param)\n param == param.reverse\nend", "def palindrome?(arg)\n arg == arg.reverse\nend", "def palindrome?(arg)\n arg == arg.reverse\nend", "def palindrome?(number)\n number_array = number.abs.to_s.split(\"\")\n index = number_array.size-1\n (0..number_array.size/2).each do |index|\n if number_array.at(index) != number_array.at(number_array.size-(index+1))\n return false\n end\n end\n return true\nend", "def is_palindrome(number)\n # Special cases.\n if number.nil? or number < 0\n return false\n end\n if number == 0\n return true\n end\n # Get number of digits in number.\n num_digits = Math.log10(number).to_i + 1\n if num_digits == 1\n return true\n end\n # Reverse the last half of the number's digits.\n last_half = 0\n (num_digits / 2).to_i.downto(1) do |digit_index|\n digit = number % 10\n last_half += digit * 10**(digit_index - 1)\n number = (number / 10).to_i\n end\n # Ignore middle digit in number with odd num digits.\n if num_digits % 2 == 1\n number = (number / 10).to_i\n end\n return last_half == number\nend", "def palindrome?(argument)\n argumen.reverse == argument\nend", "def is_palindrome(s)\n\tl = 0\n\tr = s.length - 1\n\treturn pal_helper(s, l, r)\nend", "def check_palindrome(num)\n\tstring = num.to_s\n\tlength = string.length\n\tlast = length-1\n\tfirst = 0\n\tbegin\n\t\tis_palindrome = (string[first].to_i == string[last].to_i)\n\t\tbreak if !is_palindrome\n\t\tfirst += 1\n\t\tlast -=1\n\tend while first <= last\n\treturn is_palindrome\nend", "def palindrome(st1)\n if st1.reverse == st1\n return true\n else\n return false\n end\nend", "def is_palindrome(number)\n if number == nil || number < 0\n return false\n end\n\n converted_string_number = number.to_s\n\n i = 0\n j = converted_string_number.length - 1\n\n while i < j\n last_character = converted_string_number[i]\n converted_string_number[i] = converted_string_number[j]\n converted_string_number[j] = last_character\n i += 1\n j -= 1\n end\n\n converted_string_number = converted_string_number.to_i\n\n return number == converted_string_number\nend", "def palindrome?(chars)\n if chars.is_a? Integer\n chars == reverse(chars)\n else\n len = chars.length\n\n ((len / 2) + 1).times do |i|\n return false unless chars[i] == chars[len - i - 1]\n end\n\n true\n end\n end", "def is_palindrome(s)\n return true if s.length <= 1\n return pal(s, 0, (s.length - 1))\nend" ]
[ "0.8810984", "0.87939155", "0.8771195", "0.87482905", "0.87386256", "0.87324905", "0.8675722", "0.86734205", "0.86734205", "0.8651917", "0.86509025", "0.8641991", "0.86208445", "0.8605032", "0.8589484", "0.8588952", "0.8585475", "0.85803384", "0.8563643", "0.8548378", "0.85414326", "0.8522147", "0.8521546", "0.8509284", "0.84732527", "0.8377574", "0.8362229", "0.833308", "0.82965344", "0.829392", "0.82815295", "0.8238903", "0.8220039", "0.82113504", "0.8055059", "0.7938764", "0.78951", "0.7883119", "0.7860449", "0.78539145", "0.7850583", "0.78254414", "0.7825048", "0.78168535", "0.7765296", "0.7760095", "0.77455753", "0.77454454", "0.7738763", "0.7723889", "0.7714923", "0.7711525", "0.77062494", "0.77057993", "0.7695946", "0.7651295", "0.7650081", "0.7631905", "0.762963", "0.7628546", "0.76242816", "0.76192415", "0.7617976", "0.76172143", "0.76057076", "0.7604513", "0.76018655", "0.76010096", "0.7596809", "0.75925726", "0.7591192", "0.75653106", "0.7563745", "0.7559966", "0.7559307", "0.7559307", "0.7559307", "0.7559307", "0.75538224", "0.7549988", "0.7543826", "0.7527314", "0.75271577", "0.7515943", "0.750105", "0.74876636", "0.7457887", "0.7448303", "0.74467516", "0.74467516", "0.7444024", "0.7439256", "0.74307764", "0.7399409", "0.73943746", "0.73891944", "0.73856413", "0.73748165", "0.7367712" ]
0.8605417
14
Used to log the activity of the scraper methods.
def scraper_logger @@scraper_logger ||= Logger.new("#{Rails.root}/log/scraper.log") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log\n end", "def logs\n end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def logs\n\n end", "def logme\n\t\tlogger.debug \"============Main ApplicationController get calls at #{Time.now}\"\n\tend", "def log_history\n logger.info('[]' + request.method + \"\\t\" + request.fullpath + \"\\t\" + request.remote_ip + \"\\t\" + Time.now.strftime('%Y-%m-%d %H:%M:%S'))\n end", "def logs\n @runner.log\n end", "def log_startup\n log_environment\n log_dispatcher\n log_app_name\n end", "def log()\n @log\n end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def log mess\n SiteHtml::TestSuite::log mess\nend", "def autoflush_log; end", "def autoflush_log; end", "def request_log(request); end", "def activity_logging\n %w(write delete).each do |event|\n observer = @ts.notify(event, [:name, nil, DRbObject, nil])\n activity_output(observer)\n end\n end", "def log_dispatch(method, args=[])\n\t\t\tmeth_str = self.class.to_s + \"#\" + method.to_s\n\t\t\tmeth_str += \" #{args.inspect}\" unless args.empty?\n\t\t\tlog \"Dispatching to: #{meth_str}\"\n\t\tend", "def log_funnel_page_visit\n log_funnel_event(:view_page)\n end", "def tracing()\n #This is a stub, used for indexing\n end", "def log_stuff\r\n log.info(\"TestLogger is here to log stuff.\")\r\n log.warn(\"TestLogger is finishged logging. Be careful.\")\r\n end", "def __log(method, path, params, body, url, response, json, took, duration)\n logger.info \"#{method.to_s.upcase} #{url} \" +\n \"[status:#{response.status}, request:#{sprintf('%.3fs', duration)}, query:#{took}]\"\n logger.debug \"> #{__convert_to_json(body)}\" if body\n logger.debug \"< #{response.body}\"\n end", "def access_logger\n Rails.application.config.another_logger.info(\"#{request.method} '#{request.path}' #{request.version} from: #{request.remote_ip}\")\n end", "def log\n @log\n end", "def log\n self.class.log\n end", "def record!\n if OhMyLog::Log.configuration.print_log\n p \"REQUEST\"\n p @request.to_s\n p \"RESPONSE\" unless @effects.empty?\n @effects.each {|effect| p effect.to_s}\n end\n\n print_into_log\n\n #we can record everything that happend (OPTIONALL)\n if OhMyLog::Log.configuration.record_history\n OhMyLog::Log.history << self\n end\n #We always save the last operation recorded\n OhMyLog::Log.last_recorded = self\n #save this string on file or upload it somewhere\n end", "def log \n\t\t\tArrow::Logger[ self.class ]\n\t\tend", "def result_log\n end", "def result_log\n end", "def result_log\n end", "def logger ; @log end", "def logger_output; end", "def log\n return if @logger.nil?\n\n @logger.debug(\"Counter\") { \"attempt #{self}\" }\n end", "def log_request\n logger.info \"HTTP request received => #{request.fullpath} , params => #{params} \"\n end", "def perform(user_agent, remote_ip, user_id, timestamp, record_class, record_id)\n logForemVisit(user_agent, remote_ip, user_id, timestamp, record_class, record_id)\n end", "def logVisit record=nil, rateable=false\n return if !valid_browser?(request.user_agent) or valid_robot?(request.user_agent)\n\n user_id = user_signed_in? ? current_user.id : nil\n record_class = record_id = nil\n record_class = record.class.to_s unless record.nil?\n record_id = record.id unless record.nil?\n LogVisitWorker.perform_async(request.user_agent, request.remote_ip, user_id, Time.now, record_class, record_id, rateable)\n \n# Thread.new do\n# #Wait 10 seconds to allow the request to be returned before starting. This saves the request some time.\n# #On development using Webrick, if we wait too long and another thread gets created this one gets killed.\n# #Should be good on production.\n# sleep 10\n\n# ip_address = logIpAddress #First log IpAddress\n \n# record.register_visit_by(ip_address)\n\n# return unless rateable\n# #If the user is not the author then record statistics about how much they viewed the record\n# if user_signed_in? && record.user != current_user\n#\trecord.register_view_by(current_user)\n# end\n# end\n end", "def record_hit(klass, data)\n system(\"echo '#{data}' >> #{get_log_file_name(klass)}\")\n end", "def welcome\n __log_activity\n __debug_route\n end", "def log\n advanced[:log]\n end", "def advanced\n __log_activity(anonymous: true)\n __debug_route\n end", "def start_logger\n VWO::Logger.class_eval do\n # Override this method to handle logs in a #{ab_test_campaign_goal} manner\n def log(level, message)\n # Modify message for #{ab_test_campaign_goal} logging\n message = \"#{ab_test_campaign_goal} message #{message}\"\n VWO::Logger.class_variable_get('@@logger_instance').log(level, message)\n end\n end\nend", "def log_writer; end", "def update_activity_logs\n request_number = request.number\n req_link = \"<a href = 'requests/#{request_number}'>#{request_number}</a>\"\n app = request.app_name.size > 1 ? \"Applications\" : \"Application\"\n # Log activity is not supported in Rails3\n #User.current_user.log_activity(:context => \"#{req_link} has been #{request.aasm_state} for #{app} #{request.app_name.to_sentence}\") do\n #end\n end", "def activity_log_create\n write_activity_log(:create)\n end", "def logging_prefs; end", "def verbose_logging; end", "def log_with_benchmark(request, action)\n msg = [ ]\n msg << \"#{request.env['REQUEST_METHOD']} #{request.env['PATH_INFO']}\"\n msg << \"Params: #{request.params.inspect}\"\n msg << \"Action: #{action.to_s.upcase}\"\n \n logger.info \"[sinatras-hat] \" + msg.join(' | ')\n \n result = nil\n \n t = Benchmark.realtime { result = yield }\n \n logger.info \" Request finished in #{t} sec.\"\n \n result\n end", "def log\n Lita.logger\n end", "def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend", "def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend", "def run\n print_debug 'In #run'\n audit self.class.payloads, self.class.options\n end", "def log\n Engines.log\n end", "def with_logging(method_name = nil)\n method_name ||= caller[0][/`([^']*)'/, 1]\n result = yield\n self.log method_name, result\n result\n end", "def log_state\n super\n end", "def rss_log\n self\n end", "def rss_log\n self\n end", "def on_request(env)\n env['sinatra.commonlogger'] = true\n super\n end", "def log\n @list\n end", "def activity_logger_end\n # Don't care about logging activity if the user is not registered\n# return if !session[:user]\n\n puts \"In: Logger End\"\n\n # In case the request is of type '2' = AJAX (dynamic), store 'session' information for content storage between\n # AJAX pages but don't record a database activity (making the transition faster)\n if Activity::activities[params[:action]] && Activity::activities[params[:action]][3] == 2\n \n # Store the AJAX data in the 'session' object under the general key ':params' with the 'page' being the 2nd 'key'\n# session[:params][params[:action]] = params\n end\n \n # If the current action & controller match the previous activity (i.e. the user has refreshed and clicked on a link\n # that takes them to the same page, the previous Activity will be updated with the 'updated_at' field ONLY\n if (session[:last_activity_o]) && \n (session[:last_activity_o].action == params[:action] && session[:last_activity_o].controller == params[:controller])\n session[:last_activity_o].touch\n return\n end\n \n # If current activity is of type 'secondary'\n \n # 1. Maintain 5 last links in the session object\n session[:last_5_urls] = Array.new(5) if !session[:last_5_urls]\n session[:last_5_urls].unshift(request.env[\"REQUEST_URI\"])\n session[:last_5_urls].pop if session[:last_5_urls].length > 5\n \n @activity = Activity::create_o(params, @friendly_names_h, session[:user])\n \n begin\n \n# @activity.save(false)\n \n # If current activity is of type 'primary', store it as primary\n # This will be used as a 'return_to' link when exiting a 'secondary' view\n if Activity::activities[params[:action]] && Activity::activities[params[:action]][3] == 1\n session[:last_primary_activity_o] = @activity\n \n # 2. In case current page is secondary (e.g Feedback, Contact Us etc) and there is no 'last_primary_activity' object in memory\n # E.g. user bookmarked the 'Provide Feedback' page and 2nd time opening the browser, using cookie login, they access this page directly\n elsif !session[:last_primary_activity_o] &&\n (Activity::activities[params[:action]] && Activity::activities[params[:action]][3] == 0)\n \n # 3. If the current action is not defined regardless if it's a primary or secondary (as we can't tell at this stage)\n # Set the 'last_primary_activity' to 'home'\n elsif !Activity::activities[params[:action]] \n session[:last_primary_activity_o] = Activity::create_o(\n {:action => \"home\", :controller => \"application\"}, nil, session[:user])\n \n # Let the admin know an action was used that doesn't have\n raise 'ERROR #2' if !send_message(nil, {:missing_action => params[:action]}, false, 3, 4) \n end \n \n # Set the current activity to be the last in the session\n session[:last_activity_o] = @activity\n \n rescue Exception => exc\n \n flash[:error] = 'Activity could not be saved due to a validation error = ' + exc.clean_backtrace.join( \"\\n\" )\n \n end # rescue\n \n end", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log_action msg\n\t\t\t\tputs '=> ' + msg\n\t\t\tend", "def log_http_call(payload); end", "def log_http_call(payload); end", "def log_files(method, *args)\n # When running remotely on an LSF client, the LSF manager will capture STDOUT (i.e. the console log output)\n # and save it to a log file.\n # Don't write to the last log file in that case because we would have multiple processes all vying to\n # write to it at the same time.\n last_file.send(method, *args) unless Origen.running_remotely?\n @job_file.send(method, *args) if @job_file\n end", "def report\n @logger\n end", "def method_missing(method, *args, &block)\n tokens = method.to_s.split('_')\n result = tokens.pop\n action = tokens.join('_')\n if args.first.is_a? Hash\n message = Log.data(args.first)\n else\n message = args.join(' ')\n end\n Log.log self.level, \"action=#{action} status=#{result} #{message}\"\n end", "def _log(text)\n\t\topen($location+\"/logs/class.log\", 'a') { |f| f.puts(\"[\"+DateTime.now.strftime('%Y-%m-%d %H:%M:%S')+\"] \"+text+\"\\n\") } if (text.is_a?(String) && !text.empty?)\n\tend", "def trace\n set_trace_func proc { |event, _file, _line, id, binding, classname|\n if event == watched && id != :log && classes.include?(classname.to_s)\n vars = variables(binding)\n\n if vars.empty?\n log_this(sprintf(\"%s %-25s #%-20s\",\n class_count, classname, id))\n\n else\n log_this(sprintf(\"%s %-25s #%-20s\\n%s\\n\",\n class_count, classname, id, vars))\n\n end\n end\n } if trace?\n end", "def log\n @log || Mechanize.log\n end", "def log()\n return @log unless @log.nil?\n @flow.log()\n end", "def tapp\n Babushka::LogHelpers.deprecated! '2017-09-01'\n tap { STDOUT.puts \"#{File.basename caller[2]}: #{self.inspect}\" }\n end", "def _roda_after_90__common_logger(result)\n super if result && _common_log_request?(result)\n end", "def reopen_logs; end" ]
[ "0.66825444", "0.66351515", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65490013", "0.64487576", "0.6360396", "0.6342089", "0.61816376", "0.611208", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.60609543", "0.6056672", "0.60471916", "0.60471916", "0.6040977", "0.6031779", "0.6010433", "0.59918493", "0.59520274", "0.5937668", "0.5933913", "0.591847", "0.59140474", "0.5899595", "0.58957326", "0.58927953", "0.58875376", "0.58875376", "0.58875376", "0.5883552", "0.57910764", "0.57885015", "0.5784032", "0.5774507", "0.5767402", "0.5764851", "0.5764412", "0.57231057", "0.57230026", "0.5706965", "0.569816", "0.5679475", "0.56641513", "0.56632155", "0.563029", "0.5628643", "0.5622402", "0.5601198", "0.5601198", "0.5601007", "0.55939186", "0.55803406", "0.5574165", "0.5565466", "0.5565466", "0.55627835", "0.5550019", "0.55429894", "0.5539392", "0.5539392", "0.5539392", "0.5539392", "0.5539392", "0.55393326", "0.55274653", "0.55274653", "0.5518684", "0.54942167", "0.54913247", "0.5489432", "0.54805315", "0.5475729", "0.5474289", "0.54731625", "0.54691446", "0.54664785" ]
0.64462554
12
Updates all stations from BOM website.
def update_stations State.all.each do |s| fetch_stations(s) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateStation()\n uri=URI.parse(ViaggiatrenoURLs.STATION_INFO)\n response = Net::HTTP.post_form(uri,{\"stazione\" => @stationFrom, \"lang\" => \"IT\"})\n doc = Nokogiri::HTML(response.body)\n\n doc.xpath(XPathMatchInfo.XPATH_STATION).each do |x|\n \n StringUtils.remove_newlines_tabs_and_spaces(x)\n\n train_number_complete = x.xpath(XPathMatchInfo.XPATH_TRAIN_NUMBER()).to_s\n train_destination = x.xpath(XPathMatchInfo.XPATH_TRAIN_DESTINATION()).to_s\n train_schedule =x.xpath(XPathMatchInfo.XPATH_TRAIN_SCHEDULED()).to_s\n train_description = \"#{train_number_complete} #{train_destination} #{train_schedule}\"\n \n train_number=train_number_complete.match(\"[0-9]+\")[0]\n \n @trains[train_number]=train_description\n @destinations.push(train_destination)\n ### TODO #### #@trains[train_number][description]=train_description\n end\n end", "def update_station_list\n log('This script overwrites your local copy of config/stations.yml with the latest data from nationalrail.co.uk and '\\\n 'railwaycodes.org.uk')\n log('Press [ENTER] to continue or [Ctrl+c] to quit')\n gets\n # Fetch data from the web\n stations = fetch_stations\n locations = fetch_locations\n # Add location data to the current active station list\n stations.each { |crs, data| data.merge!(locations[crs]) if locations[crs] }\n write_yaml(stations)\n log('Your station list has been updated')\nend", "def update_from_darksky(historical_dates=[Date.today-1], forecast=true)\n darksky_secret = ApiKey.where(:service => 'Darksky').first.key\n hydra = Typhoeus::Hydra.new\n requests = Hash.new\n forecast_request = nil\n\n logger.debug(\"Updating Station #{name} for dates: #{historical_dates}\")\n \n # Construct the HTTP requests to Darksky: one for each of the past days we care about, and one for today to get the forecast\n historical_dates.each do |d|\n endpoint = \"https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude},#{d.to_time.to_i}\"\n request = Typhoeus::Request.new(endpoint) \n hydra.queue(request)\n requests[d] = request\n end\n forecast_request = Typhoeus::Request.new(\"https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude}\")\n hydra.queue(forecast_request) if forecast\n\n # Run the whole lot of them!\n hydra.run\n\n # Parse out the observed precipitation from the historical queries\n reports = []\n requests.each_pair do |d, request|\n if request.response.timed_out?\n logger.error \"Request to Darksky timed out: #{request}\"\n next\n end\n if request.response.nil?\n logger.error \"No response from Darksky for request #{request}\"\n next\n end\n if request.response.code != 200\n logger.error \"Unable to fetch weather data from #{request.base_url}: #{request.response.code} #{request.response.status_message}\"\n next\n end\n\n # With error trapping done, let's parse the body and update the db with the report data.\n data = JSON.load(request.response.body)\n data['daily']['data'].each do |report|\n logger.debug(report)\n d = Time.at(report['time']).to_date\n datestamp = \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"\n logger.debug(\"Using timestamp #{datestamp}\")\n # We want to update an existing row in place if we've previously computed one\n r = weather_reports.find_or_create_by(\n :latitude => self.latitude,\n :longitude => self.longitude,\n :date => datestamp,\n )\n \n \n # TODO: multiply by the actual number of hours in the time period.\n precip = report['precipIntensity'] # This is in inches per hour\n logger.debug(\"Extracted precipitation report: #{precip} from report #{report}\")\n r.precip = precip * 24.0\n logger.debug(\"Constructed WeatherReport: #{r}\")\n logger.debug(\"Coordinates: #{r.latitude},#{r.longitude}\")\n logger.debug(\"Datestamp: #{r.date}\")\n logger.debug(\"Recorded Precip: #{r.precip}\")\n \n r.save\n reports.push(r)\n end\n end\n\n # Add the forecast data as well\n forecasts = []\n if forecast\n logger.info(\"Parsing forecasts for station #{self}\")\n logger.debug(\"Got response: #{forecast_request.response}\")\n if forecast_request.response.timed_out?\n logger.error \"Request to Darksky timed out: #{forecast_request}\"\n return\n end\n if forecast_request.response.nil?\n logger.error \"No response from Darksky for request #{forecast_request}\"\n return\n end\n if forecast_request.response.code != 200\n logger.error \"Unable to fetch weather data from #{forecast_request.base_url}: #{forecast_request.response.code} #{forecast_request.response.message}\"\n return\n end\n\n logger.debug(\"Successful response from Darksky\")\n data = JSON.load(forecast_request.response.body)\n data['daily']['data'].each do |report|\n logger.debug(report)\n d = Time.at(report['time']).to_date\n datestamp = \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"\n r = weather_reports.find_or_create_by(\n :latitude => self.latitude,\n :longitude => self.longitude,\n :date => datestamp,\n )\n r.precip = report['precipIntensity'] * 24.0 # The Darksky report gives us inches per hour\n\n logger.debug(\"Created forecast object: #{r}\")\n r.save\n forecasts.push(r)\n end\n end\n\n # TODO: add a column that we can record when this update was last run, for display on the webpage.\n {:reports => reports, :forecasts => forecasts}\n end", "def extract_station(url, state)\n\n id, json_url = nil\n\n doc = Nokogiri::HTML(open(\"#{Global::BOM_BASE_URL}#{url}\"))\n doc.css('a').each do |l|\n\n if l.attr('href').include?('json')\n json_url = l.attr('href')\n id = l.attr('href').split('.')\n id = id[1]\n end\n\n end\n\n begin\n station = Station.find(id)\n scraper_logger.info(\"Updating existing station #{id}\")\n\n rescue\n station = Station.new\n station.id = id\n scraper_logger.info(\"Creating new station #{id}\")\n\n end\n\n begin\n station.state = state\n\n name = doc.css('h1').first\n station.name = name.text.gsub('Latest Weather Observations for ','')\n\n station.station_url = \"#{Global::BOM_BASE_URL}#{url}\"\n station.json_url = \"#{Global::BOM_BASE_URL}#{json_url}\"\n\n json = extract_observations(station.json_url)\n station.latitude = json['observations']['data'].first['lat']\n station.longitude = json['observations']['data'].first['lon']\n\n tz = Timezone.where(abbreviation: json['observations']['header'].first['time_zone'])\n if tz.size > 0\n station.timezone = tz.first\n station.save\n\n scraper_logger.info(\"#{station.id} - #{station.name} has been saved\")\n\n else\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due to unknown TZ (#{json['observations']['header'].first['time_zone']})\")\n\n end\n\n rescue\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due missing data in JSON file)\")\n\n end\n \n end", "def update_observations\n\n State.all.each do |s|\n fork do\n Station.where(state_id: s.id).each do |s|\n fetch_observations(s)\n end\n end\n end\n\n end", "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def refresh_way\n @osm.way.each_key do |way|\n @log.info('refreshing ' + way)\n response = query_server('/way/' + way)\n if !response.nil?\n xml = StringIO.new(response)\n importer = Xml_import_osm.new(@new_osm)\n listner = Listener.new(importer)\n REXML::Document.parse_stream(response, listner)\n if compare_way(@osm.way[way], @new_osm.way[way]) == false\n #remove way\n @log.debug(way + ' differs from live version')\n @osm.way.delete(way)\n end\n else\n #remove way\n @log.debug(way + ' differs from live version')\n @osm.way.delete(way)\n end\n end\n end", "def index\n @stations = Station.all\n\n #response = HTTParty.get('http://0.0.0.0:3000/convertcsv.json')\n # r = HTTParty.get('http://0.0.0.0:3000/convertcsv.json')\n # r = HTTParty.get('http://rubygems.org/api/v1/versions/httparty.json')\n # r = HTTParty.get('http://0.0.0.0:3000/convertcsv.json') \n\n linestation_list = JSON.parse(File.read('app/assets/javascripts/convertcsv.json'))\n # puts \"first record\"\n # puts linestation_list[0][\"From Station\"]\n $i = 0\n $stops = 5\n \n origin_stations = [\"East Ham\"]\n\n\n final_to_station_array =[]\n processed_stations = []\n\n\n while $i < $stops do\n puts(\"*******Stations from East Ham with the following stops (1+) #$i **********\" )\n to_station = \"\"\n\n final_to_station_array = []\n statition_detail = {}\n\n\n\n # origin_stations.each do | origin_station |\n # origin_station = origin_stations[0]\n\n\n linestation_list.each do | ls |\n\n\n # puts ls[\"To Station\"] == old_origin_station\n # if final_to_station_array.include?(ls[\"From Station\"])\n # puts \"include the From Station in the final\"\n # end\n from_tube_lines = []\n \n\n if origin_stations.include?(ls[\"From Station\"]) || origin_stations.include?(ls[\"To Station\"])\n \n from_tube_lines.push(ls[\"Tube Line\"])\n\n\n origin_tube_line = \"District\"\n updated_tube_lines =\"\"\n\n origin_stations.each do | origin_station |\n\n # updated_tube_lines = updated_tube_lines.present?? updated_tube_lines : origin_tube_line\n puts \"initialiezed updated_tube_lines\"\n puts updated_tube_lines\n\n unless processed_stations.include?(origin_station) \n puts \"*****adding to the processed_station now\"\n processed_stations.push(origin_station)\n puts \"origin_station\"\n puts origin_station\n puts \"*****processed_stations\"\n puts processed_stations\n end \n\n unless processed_stations.include?(ls[\"To Station\"]) \n unless final_to_station_array.include?(ls[\"To Station\"])\n puts \"***adding to the final stations now\"\n puts ls[\"To Station\"]\n final_to_station_array.push(ls[\"To Station\"])\n statition_detail[ls[\"To Station\"]] = \"#{ls['To Station']} (lines = #{ls['Tube Line']})\"\n end\n end\n\n unless processed_stations.include?(ls[\"From Station\"])\n unless final_to_station_array.include?(ls[\"From Station\"])\n puts \"***adding to the final stations now\"\n puts ls[\"From Station\"]\n final_to_station_array.push(ls[\"From Station\"])\n statition_detail[ls[\"From Station\"]] = \"#{ls['From Station']} (lines = #{ls['Tube Line']})\"\n end\n end\n\n puts \" old updated_tube_lines ???\"\n puts updated_tube_lines\n\n puts \" old origin_tube_line ???\"\n puts origin_tube_line \n\n if origin_tube_line == ls[\"Tube Line\"]\n updated_tube_lines = origin_tube_line \n puts \"original is the same as the current, assign to the updated one\"\n else\n\n puts \"----- the updated_tube_lines\"\n puts updated_tube_lines \n updated_tube_lines = origin_tube_line + \", \" + ls[\"Tube Line\"]\n puts \" **** new updated_tube_line\"\n puts updated_tube_lines\n\n end\n\n \n \n end \n\n origin_tube_line = updated_tube_lines\n puts \" **** new updated_tube_line\"\n puts updated_tube_lines\n puts \"-----from_tube_lines----\"\n puts from_tube_lines\n\n\n end\n end\n\n\n # end\n \n\n origin_stations = []\n origin_stations = final_to_station_array\n $i +=1\n\n puts \"&&&&&&& the needed information &&&&&&\" \n puts \"*******final_to_station_array\"\n puts final_to_station_array\n puts final_to_station_array.size\n puts \"** station detail\"\n puts statition_detail\n puts \"-----\"\n end\n\n\n # origin_station = \"East Ham\"\n # to_station = \"\"\n # linestation_list.each do | ls |\n # while $i < $stops do\n # puts(\"Inside the loop i = #$i\" )\n # puts ls[\"From Station\"]\n # if ls[\"From Station\"] == origin_station\n # # to_station = ls[\"To Station\"]\n # puts ls\n # end\n # # origin_station = to_station\n # # puts \"new origin_station\"\n # # puts origin_station\n # puts \"-----\"\n # $i +=1\n # end\n\n # end\n\n\n\n\n end", "def fetch_bart_stations\n bart_url = 'http://bart.gov/dev/eta/bart_eta.xml'\n\n xml_data = Net::HTTP.get_response(URI.parse(bart_url)).body\n xml_doc = REXML::Document.new(xml_data)\n\n stations = xml_doc.records('station')\n stations.each_with_index do |station, index|\n etas = xml_doc.records(\"//station[#{index}]/eta\")\n stations[index].merge!({ \"eta\" => etas })\n end\n \n return stations\nend", "def update\n respond_to do |format|\n if @set_station.update(set_station_params)\n format.html { redirect_to set_stations_path, notice: 'Set station was successfully updated.' }\n format.json { render :index, status: :ok, location: @set_stations }\n else\n format.html { render :edit }\n format.json { render json: @set_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def fetch_bart_stations\n bart_url = 'http://bart.gov/dev/eta/bart_eta.xml'\n\n xml_data = Net::HTTP.get_response(URI.parse(bart_url)).body\n xml_doc = REXML::Document.new(xml_data)\n\n stations = xml_doc.records('station')\n stations.each_with_index do |station, index|\n etas = xml_doc.records(\"//station[#{index + 1}]/eta\")\n stations[index].merge!({ \"eta\" => etas })\n end\n \n return stations\nend", "def fetch_stations(state)\n\n scraper_logger.info(\"Fetching stations for #{state.name}\")\n\n doc = Nokogiri::HTML(open(state.url))\n doc.css('a').each do |s|\n\n Global::OBSERVATION_PRODUCT_CODE.each do |c|\n if s.attr('href').include?(c) and s.attr('href').include?(state.product_group)\n extract_station(s.attr('href'), state)\n end\n end\n\n end\n\n scraper_logger.info(\"Completed fetching stations for #{state.name}\")\n\n end", "def update\n @station = Station.find(params[:id])\n\n if @station.update(station_params)\n head :no_content\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def updateTrainDetails()\n doc = Nokogiri::HTML(open(@site_info_details))\n doc.xpath(XPathMatchInfo.XPATH_DETAILS_GENERIC).each do |x|\n x.xpath(XPathMatchInfo.XPATH_DETAILS_STATION_NAME).each do |stationName|\n @stationName = stationName.to_s\n end\n x.xpath(XPathMatchInfo.XPATH_DETAILS_SCHEDULED_STOP_TIME).each do \\\n |scheduledArrivalTime|\n @scheduledArrivalTime = StringUtils.remove_newlines_tabs_and_spaces(\n scheduledArrivalTime).to_s\n end\n x.xpath(XPathMatchInfo.XPATH_DETAILS_ACTUAL_STOP_TIME).each do \\\n |actualArrivalTime|\n @actualArrivalTime = StringUtils.remove_newlines_tabs_and_spaces(\n actualArrivalTime).to_s\n end\n rail = StringUtils.remove_newlines_tabs_and_spaces(x).match(RegExpMatchInfo.REGEXP_RAIL).to_a\n if x.attributes()['class'].to_s =~ RegExpMatchInfo.REGEXP_STOP_ALREADY_DONE\n t = TrainStop.new(@stationName, @scheduledArrivalTime, \n @actualArrivalTime, StopState.DONE,rail)\n else\n t = TrainStop.new(@stationName, @scheduledArrivalTime, \n @actualArrivalTime, StopState.TODO,rail)\n end\n @train.addStop(t)\n end\n end", "def update_services\n Service.update_all('operator_aptour_id = operator_id')\n end", "def index\n @stations = Station.all\n end", "def update\n respond_to do |format|\n if @station.update(station_params)\n format.html { redirect_to @station, notice: 'Станция обновлена.' }\n format.json { render :show, status: :ok, location: @station }\n else\n format.html { render :edit }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!\n self.list = fetch(V4_URL) + fetch(V6_URL)\n end", "def update_list\n current_path = '/api/v1/update'\n @conn.get(current_path)\n end", "def update\n @stationeryrequest = Stationeryrequest.find(params[:id])\n #\n @stationeryrequest.hotelsuppliesrequests.each do |hotelsuppliesrequests|\n \n end\n\n respond_to do |format|\n if @stationeryrequest.update_attributes(params[:stationeryrequest])\n format.html { redirect_to @stationeryrequest, notice: 'Stationeryrequest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stationeryrequest.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @stations = Station.all\n end", "def perform\n UpdateDb.new.update_stations\n UpdateDb.new.delete_old_stations\n end", "def update_service_registers\n ServiceRegister.update_all('operator_aptour_id = id_ope')\n end", "def updateTrain()\n doc = Nokogiri::HTML(open(@site_info_main))\n doc.xpath(XPathMatchInfo.XPATH_STATUS).each do |x|\n @status = StringUtils.remove_newlines_tabs_and_spaces(x)\n end\n doc.xpath(XPathMatchInfo.XPATH_TRAIN_NAME).each do |x|\n @trainName = x.content\n end\n if @status =~ RegExpMatchInfo.REGEXP_STATE_NOT_STARTED\n @train.state = TrainState.NOT_STARTED\n elsif @status =~ RegExpMatchInfo.REGEXP_STATE_RUNNING or \\\n RegExpMatchInfo.REGEXP_STATE_FINISHED\n if @status =~ RegExpMatchInfo.REGEXP_NODELAY_STR\n @train.delay = 0\n else \n @train.delay = @status.match(RegExpMatchInfo.REGEXP_DELAY_STR)[1].to_i\n if @status.match(RegExpMatchInfo.REGEXP_DELAY_STR)[2] \\\n != RegExpMatchInfo.STR_DELAY_STR\n # train is ahead of time, delay is negative\n @train.delay *= -1\n end\n end\n if @status =~ RegExpMatchInfo.REGEXP_STATE_RUNNING\n @train.state = TrainState.RUNNING\n @train.lastUpdate = @status.match(\n RegExpMatchInfo.REGEXP_STATE_RUNNING)[3].strip\n @status = @status.match(RegExpMatchInfo.REGEXP_STATE_RUNNING)[1].rstrip\n else\n @train.state = TrainState.FINISHED\n end\n end\n\n @train.status = @status\n @train.trainName = @trainName\n end", "def update_all\n delete if blacklight_items.count > 0\n self.exports.collect { |pid| add_to_solr(pid) }\n commit\n end", "def data_add_stations\n @routes[0].stations.insert(-2, @stations[1])\n @routes[0].stations.insert(-2, @stations[2])\n @routes[2].stations.insert(-2, @stations[1])\n end", "def index\n @set_stations = SetStation.all\n end", "def refresh_bikes\n bike_ids = params[\"bike_ids\"].split(',')\n user_id = params[\"user_id\"]\n\n bike_ids.each {|bike_id|\n strava_bike = get_bike(bike_id, user_id)\n bike = Bike.find_by(strava_gear_id: bike_id)\n bike.update(distance_done: strava_bike[\"distance\"])\n }\n end", "def update\n @bom.update(bom_params)\n end", "def update_all\n data_in_batches do |batch|\n Bookings::Data::SchoolUpdater.new(batch).update\n end\n end", "def index\n @asos_stations = AsosStation.all\n end", "def stations_list\n @route.get_stations_list\n end", "def index\n @main_stations = MainStation.all\n end", "def fetch_observations(station)\n\n scraper_logger.info(\"Fetching latest weather observations for #{station.id} - #{station.name}\")\n\n new = 0\n\n json = extract_observations(station.json_url)\n json['observations']['data'].each do |o|\n\n Time.zone = 'UTC'\n recording_time = Time.zone.parse(\"#{o['aifstime_utc']}Z\")\n\n unless Observation.already_exists?(station, recording_time)\n observation = Observation.new\n observation.station = station\n observation.recording_time = recording_time\n observation.save\n\n parse_readings(o, observation)\n\n new += 1\n\n end\n\n end\n\n scraper_logger.info(\"Added #{new} new observations\")\n\n end", "def refresh\n @all = IlsService.new.get_location_list\n end", "def update\n @station = Station.find(params[:id])\n\n respond_to do |format|\n if @station.update_attributes(params[:station])\n format.html { redirect_to(@station, :notice => 'Station was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @station.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@components.each do |comp|\n\t\t\tcomp.update\n\t\tend\n\tend", "def index\n @station_infos = StationInfo.all\n end", "def stations\n doc = request(@user, \"stations\")\n stations = []\n doc.xpath('//rss/channel/item').each do |node|\n stations << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :artwork => node.xpath('pandora:stationAlbumArtImageUrl').text.strip,\n :songSeed_song => node.xpath('pandora:seeds/pandora:songSeed/pandora:song').text.strip,\n :songSeed_artist => node.xpath('pandora:seeds/pandora:songSeed/pandora:artist').text.strip,\n :composerSeed => node.xpath('pandora:seeds/pandora:composerSeed/pandora:composer').text.strip,\n :artistSeed => node.xpath('pandora:seeds/pandora:artistSeed/pandora:artist').text.strip}\n end\n stations\n end", "def load_station_data\n data = Net::HTTP.get(URI.parse(stations_url))\n JSON.parse(data)[\"result\"]\n end", "def update\n @space_station = SpaceStation.find(params[:id])\n\n if @space_station.update(space_station_params)\n head :no_content\n else\n render json: @space_station.errors, status: :unprocessable_entity\n end\n end", "def update_all_prices\n csv_contents = CSV.parse(open(DAILY_PRICE_URL).read)\n csv_contents.shift\n csv_contents.each do |row|\n date = Date.parse(row[0]).to_s\n symbol = row[1]\n openprice = row[3]\n closeprice = row[4]\n price_path = PRICE_DIR.join(\"#{symbol.downcase}.csv\")\n \n update(price_path, symbol, date, closeprice, openprice)\n end\nend", "def index\n @station = Station.find(params[:station_id])\n\t\t@acs = @station.acs\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @acs }\n end\n end", "def update(prices)\n data = prices.map do |station|\n {\n series: 'diesel',\n values: { value: cents_10x(station) },\n tags: {\n station: station.id,\n # TODO: Fetch station details that are not part of the price response\n # brand: station[:brand],\n # street: station[:street],\n # place: station[:place]\n }\n }\n end\n\n @influxdb_client.write_points(data)\n end", "def update\n components = params[:components]\n str = ''\n i = 0\n components.try(:each) do |c|\n str = if i == 0\n c.to_s\n else\n str.to_s + ',' + c.to_s\n end\n i += 1\n end\n @c_off_cash_master.base_component = str\n @c_off_cash_master.update(c_off_cash_master_params)\n @c_off_cash_masters = COffCashMaster.all\n @c_off_cash_master = COffCashMaster.new\n end", "def save_reading()\n\tStation.all.each do |x|\n\t\tstation_id = x.station_id\n\t\tlat = x.lat\n\t\tlong = x.long\n\t\tlat_long = \"#{lat},#{long}\"\n\t\tforecast = JSON.parse(open(\"#{BASE_URL}/#{API_KEY}/#{lat_long}\").read)\n\t\tr = WeatherReading.new\n\t\tr.build_reading(station_id,lat,long,current_date(forecast),current_time(forecast),current_temperature(forecast),current_dew_point(forecast),\n\t\t\tcurrent_wind_direction(forecast),current_wind_speed(forecast),current_rainfall(forecast),\"forecast.io\")\n\t\tr.save\n\tend\n\nend", "def stations_list\n @route.stations_list\n end", "def update\n @station = Station.find(params[:id])\n\n respond_to do |format|\n if @station.update_attributes(params[:station])\n format.html { redirect_to @station, notice: 'Station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @station = Station.find(params[:id])\n\n respond_to do |format|\n if @station.update_attributes(params[:station])\n format.html { redirect_to @station, notice: 'Station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if Venue.find_by(name: params[:venue]) == nil\n @venue = Venue.create(name: params[:venue])\n else\n @venue = Venue.find_by(name: params[:venue])\n end\n \n @bands = []\n \n respond_to do |format|\n if @event.update(event_params)\n event_date_time = event_params[:start] + ' CST'\n @event.update(start: DateTime.strptime(event_date_time, '%m/%d/%Y %l:%M %p %Z'))\n \n if @venue.id != @event.venue.id\n @event.update(venue_id: @venue.id)\n end\n \n if params[\"removed_supporting-acts\"] != nil\n removed_supporting_acts = params[\"removed_supporting-acts\"]\n \n removed_supporting_acts.each do |index, name|\n name = name.strip\n unless name == \"\"\n if Band.find_by(name: name) != nil\n @band = Band.find_by(name: name)\n @event.bands.delete(@band)\n @event.supporting_acts.delete(@band.id)\n end\n end\n end\n end\n \n if params[\"removed_headliners\"] != nil\n removed_headliners = params[\"removed_headliners\"]\n \n removed_headliners.each do |index, name|\n name = name.strip\n unless name == \"\"\n if Band.find_by(name: name) != nil\n @band = Band.find_by(name: name)\n @event.bands.delete(@band)\n @event.headliners.delete(@band.id)\n end\n end\n end\n end\n \n if params[\"supporting_acts\"] != nil\n supporting_acts = params[\"supporting_acts\"]\n \n supporting_acts.each do |index, name|\n name = name.strip\n unless name == \"\"\n if Band.find_by(name: name) == nil\n @band = Band.create(name: name)\n @event.bands << @band\n else\n @band = Band.find_by(name: name)\n band_in_lineup = false\n @event.bands.each do |band|\n if band.id == @band.id\n band_in_lineup = true\n break\n end\n end\n if band_in_lineup == false\n @event.bands << @band\n end\n end\n end\n end\n \n @event.update(supporting_acts: [])\n supporting_acts.each do |supporting_act|\n supporting_acts = @event.supporting_acts.push(Band.find_by(name: supporting_act).id)\n @event.update(supporting_acts: supporting_acts)\n end\n end\n \n if params[\"headliners\"] != nil\n headliners = params[\"headliners\"]\n \n headliners.each do |index, name|\n name = name.strip\n unless name == \"\"\n if Band.find_by(name: name) == nil\n @band = Band.create(name: name)\n @event.bands << @band\n else\n @band = Band.find_by(name: name)\n band_in_lineup = false\n @event.bands.each do |band|\n if band.id == @band.id\n band_in_lineup = true\n break\n end\n end\n if band_in_lineup == false\n @event.bands << @band\n end\n end\n end\n end\n \n @event.update(headliners: [])\n headliners.each do |headliner|\n headliners = @event.headliners.push(Band.find_by(name: headliner).id)\n @event.update(headliners: headliners)\n end\n end\n \n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def forecast(loc)\n\n url = \"#{@base_url}/#{FORECAST_QUERY}/q/#{loc[0]},#{loc[1]}.json\" \n\n result = JSON.parse(open(url).read)\n\n return nil if result['response']['error'] \n return nil unless result['current_observation']\n\n obs = result['current_observation']\n loc = result['current_observation']['observation_location']\n fc = result['forecast']['simpleforecast']\n\n # puts 'Fetching for ' + obs['station_id']\n \n weather = WeatherStation.find_or_create_by_station_id(obs['station_id'])\n\n location = ObservationLocation.new\n\n location.full = loc['full']\n location.city = loc['city']\n location.state = loc['state']\n location.country = loc['country']\n location.country_iso3166 = loc['country_iso3166']\n location.loc = [loc['latitude'].to_f,loc['longitude'].to_f]\n location.elevation = loc['elevation']\n \n weather.observation_location = location\n\n weather.forecasts.clear\n\n fc['forecastday'].each do |f|\n\n forecast = Forecast.new\n\n date = DateTime.strptime(f['date']['epoch'].to_s,'%s')\n\n forecast.date = date\n forecast.conditions = f['conditions']\n forecast.pop = f['pop']\n forecast.high_c = f['high']['celsius']\n forecast.high_f = f['high']['fahrenheit']\n forecast.low_c = f['low']['celsius']\n forecast.low_f = f['low']['fahrenheit']\n\n forecast.qpf_day_mm = f['qpf_day']['mm']\n forecast.qpf_day_in = f['qpf_day']['in']\n forecast.qpf_allday_mm = f['qpf_allday']['mm']\n forecast.qpf_allday_in = f['qpf_allday']['in']\n forecast.qpf_night_mm = f['qpf_night']['mm']\n forecast.qpf_night_in = f['qpf_night']['in']\n\n forecast.snow_day_mm = f['snow_day']['mm']\n forecast.snow_day_in = f['snow_day']['in']\n forecast.snow_allday_mm = f['snow_allday']['mm']\n forecast.snow_allday_in = f['snow_allday']['in']\n forecast.snow_night_mm = f['snow_night']['mm']\n forecast.snow_night_in = f['snow_night']['in']\n\n forecast.wind_max_kph = f['maxwind']['kph'] \n forecast.wind_max_mph = f['maxwind']['mph'] \n forecast.wind_max_dir = f['maxwind']['dir'] \n forecast.wind_max_degrees = f['maxwind']['degrees'] \n\n forecast.wind_ave_kph = f['avewind']['kph'] \n forecast.wind_ave_mph = f['avewind']['mph'] \n forecast.wind_ave_dir = f['avewind']['dir'] \n forecast.wind_ave_degrees = f['avewind']['degrees'] \n\n forecast.humidity_ave = f['avehumidity']\n forecast.humidity_min = f['minhumidity']\n forecast.humidity_max = f['maxhumidity']\n\n weather.forecasts << forecast\n\n end\n\n weather.observation_time_rfc822 = obs['observation_time_rfc822']\n weather.local_time_rfc822 = obs['local_time_rfc822']\n weather.weather = obs['weather']\n weather.temp_f = obs['temp_f']\n weather.temp_c = obs['temp_c']\n weather.relative_humidity = obs['relative_humidity']\n weather.precip_today_metric = obs['precip_today_metric']\n\n return weather\n\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def update_location\n # Get all empty records\n to_update = Restaurant.where(longitude: [false, nil, 1.0])\n # Update each\n to_update.each do |restaurant|\n restaurant.address\n long_lat = Location.long_lat(restaurant.address)\n Restaurant.where({id: restaurant.id}).update_all({longitude: long_lat[:longitude], latitude: long_lat[:latitude]})\n end\n end", "def update_in_saas\n\n return success unless @is_sync_in_saas_needed\n\n SaasApi::OnBoarding::EditBt.new.perform(\n name: @client_token[:name],\n symbol: @client_token[:symbol],\n conversion_factor: @conversion_factor,\n client_id: @client_token[:client_id]\n )\n\n end", "def update\n respond_to do |format|\n if @main_station.update(main_station_params)\n format.html { redirect_to @main_station, notice: 'Main station was successfully updated.' }\n format.json { render :show, status: :ok, location: @main_station }\n else\n format.html { render :edit }\n format.json { render json: @main_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n set_stations_initial_scope!\n\n sort_stations_by_given_distance!\n sort_stations_by_given_criteria!\n\n # Pagination:\n paginate_stations!\n\n # Associations 'current_forecasts' and 'last_measurement' are always eager\n # loaded... however, full data will only be included if using the 'include'\n # parameter:\n eager_load_associations!\n\n respond_to do |format|\n format.json { render json: @stations, fields: json_api_params[:fields], include: params[:include] }\n format.jsonapi { render json: @stations, fields: json_api_params[:fields], include: params[:include], key_transform: :dash }\n end\n end", "def refresh()\n @knights = Knight.all\n @events = Event.all\n @kingdoms = Kingdom.all\n run_results()\n end", "def update\n respond_to do |format|\n if @asos_station.update(asos_station_params)\n format.html { redirect_to @asos_station, notice: 'Asos station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asos_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def list_stations\n if @stations.empty?\n stations_void\n else\n stations_list\n end\n end", "def stations\n ActiveModel::ArraySerializer.new(object.station, each_serializer: Api::V1::StationSerializer)\n end", "def update\n @gas_station = GasStation.find(params[:id])\n\n respond_to do |format|\n if @gas_station.update_attributes(params[:gas_station])\n format.html { redirect_to @gas_station, notice: 'Gas station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gas_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def stations\n @stations ||= (exact_match? ? parse_station : parse_stations)\n end", "def get_all_stations\n url = 'radio/station'\n options = {query: {'alt': 'json', 'tier': 'aa', 'hl': 'en_US'}}\n\n make_post_request(url, options)\n end", "def update\n @odate = session[:working_date]\n @aorder = Aorder.find(params[:id])\n @aorder.ttmid=session[:user].id\n\n @onlineautos=Onlineauto.find_all_by_odate_id_puls_empty(@odate.id)\n\n respond_to do |format|\n if @aorder.update_attributes(params[:aorder])\n format.html { redirect_to(aorders_path, :notice => 'Заказ изменен.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @aorder.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_station_info\n @station_info = StationInfo.find(params[:id])\n end", "def daily_forecast(location)\n id = location_id[location.downcase.to_sym]\n puts id\n# Maybe call it weather_update to call at 00:01 every day, needs to iterate over each location\n url = \"http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/#{id}?res=3hourly&key=0da4e1ea-8681-47bc-a5f9-5ab535ff75f2\"\n resp = Net::HTTP.get_response(URI.parse(url))\n data = resp.body\n result = JSON.parse(data)\n tomorrow = result[\"SiteRep\"][\"DV\"][\"Location\"][\"Period\"][1][\"Rep\"]\n\n @temp_tomorrow=[]\n tomorrow.each do |f|\n @temp_tomorrow << f[\"F\"].to_i\n end\n @cloud_tomorrow=[]\n tomorrow.each do |f|\n @cloud_tomorrow << f[\"V\"].to_i\n end\n @rain_tomorrow=[]\n tomorrow.each do |f|\n @rain_tomorrow << f[\"Pp\"].to_i\n end\n @wind_tomorrow=[]\n tomorrow.each do |f|\n @wind_tomorrow << f[\"S\"].to_i\n end\n\n tomorrow = WeatherData.new \n tomorrow.date = [Date.today.next_day.year, Date.today.next_day.month, Date.today.next_day.day]\n tomorrow.location = location\n tomorrow.temperature = @temp_tomorrow\n tomorrow.rainfall = @rain_tomorrow\n tomorrow.wind = @wind_tomorrow\n tomorrow.cloud = @cloud_tomorrow\n tomorrow.save\nend", "def update\n @zonas = Zona.all\n @zona.update_attributes(zona_params)\n end", "def update\n respond_to do |format|\n if @station_info.update(station_info_params)\n format.html { redirect_to @station_info, notice: 'Station info was successfully updated.' }\n format.json { render :show, status: :ok, location: @station_info }\n else\n format.html { render :edit }\n format.json { render json: @station_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def merge_into(another_station)\n self.lifts.each do |lift|\n lift.station = another_station\n lift.save!\n end\n\n self.lines_stations.each do |line_station|\n line_station.station_id = another_station.id\n line_station.save!\n end\n\n another_station.location = self.location if self.location\n self.delete\n end", "def update\n @station = Station.find(params[:id])\n flash[:notice] = 'Station was successfully updated.' if @station.update_attributes(params[:station])\n respond_with(@station)\n end", "def index\n @fire_stations = FireStation.all\n end", "def set_station_daily\n @station_daily = StationDaily.find(params[:id])\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def weather_stations(options = {})\n if options.delete(:reload) { false } || @weather_stations.nil?\n @weather_stations = Services::WeatherStations.new(options).fetch\n end\n @weather_stations\n end", "def update\n update_all\n end", "def download_local\n nsd_cccc = Metar::Station.download_stations\n File.open(Metar::Station.local_nsd_path, 'w') do |fil|\n fil.write nsd_cccc\n end\n end", "def process\n Trade::Shipment.where(taxon_concept_id: @old_taxon_relationship.taxon_concept_id,\n reported_taxon_concept_id: @taxon_relationship.other_taxon_concept_id)\n .update_all(taxon_concept_id: @taxon_relationship.taxon_concept_id)\n end", "def update\n @service_station = ServiceStation.find(params[:id])\n\n respond_to do |format|\n if @service_station.update_attributes(params[:service_station])\n format.html { redirect_to @service_station, notice: 'Service station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @service_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def process\n Trade::Shipment.update_all(\n { taxon_concept_id: @taxon_relationship.taxon_concept_id },\n {\n taxon_concept_id: @old_taxon_relationship.taxon_concept_id,\n reported_taxon_concept_id: @taxon_relationship.other_taxon_concept_id\n }\n )\n end", "def update\n respond_to do |format|\n if @station.update(station_params)\n format.html { redirect_to @station, notice: 'Station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n connection.put(element_path, to_xml)\n end", "def update\n @polling_station = PollingStation.find(params[:id])\n\n respond_to do |format|\n if @polling_station.update_attributes(params[:polling_station])\n flash[:notice] = 'PollingStation was successfully updated.'\n format.html { redirect_to(@polling_station) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @polling_station.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @tollstations = Tollstation.all\n end", "def update\n @place = Place.find(params[:id])\n\n respond_to do |format|\n\t if !params[:working_days_names].nil?\n\t\tparams[:place][:working_days] = Array.new\n\t\tparams[:working_days_names].each do |wdn|\n\t\t\tparams[:place][:working_days] << WorkingDay.find_by_name(wdn)\n\t\tend\n\t end\n if @place.update_attributes(params[:place])\n format.html { redirect_to(@place, :notice => 'El local fue editado correctamente!') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @place.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_db (date, input, serps, url_array)\n #cycle through the serps NodeList to extract all the listings\n (0..serps.length-1).each do |i|\n #the columns in the database are date, search_term, rank, listing and url. All variables except rank are passed to\n #the update_db method which in turn calls the insert_records method with the correct data\n insert_records(date, input, (i+1).to_s, strip(serps[i].text), url_array[i].to_s)\n end\nend", "def active_flights\n flights = self.flights.active.in_order_of_creation\n flights.collect do |flight_obj|\n flight_obj.update_status_and_location\n end\n end", "def update_soaplab_server(url)\n soaplab = SoaplabServer.find_by_location(url)\n data = soaplab.services_factory().values.flatten\n wsdls_from_server = data.collect{ |item| item[\"location\"]}\n registered_soaps = SoapService.find_all_by_wsdl_location(wsdls_from_server).compact\n registered_wsdls = registered_soaps.collect{|s| s.wsdl_location}\n wsdls_from_relationships = soaplab.services.collect{|service| service.latest_version.service_versionified.wsdl_location}\n wsdls_to_add = registered_wsdls - wsdls_from_relationships \n submitter = nil\n unless soaplab.services.empty?\n submitter = User.find(soaplab.services.first.submitter_id)\n end\n \n \n soaps_to_add = SoapService.find_all_by_wsdl_location(wsdls_from_server).compact\n services_to_add = soaps_to_add.collect{|s| s.service}\n puts \"server : #{url}\"\n puts \"No of relationships to add #{wsdls_to_add.length}\"\n puts wsdls_to_add\n unless wsdls_to_add.empty?\n if submitter.nil?\n submitter = User.find(SoapService.find_by_wsdl_location(wsdls_to_add.first).service.submitter_id)\n end\n soaplab.create_relationships(wsdls_to_add)\n create_tags_if_not_exist(services_to_add, submitter)\n end\n if soaplab.endpoint.nil?\n proxy_info = get_endpoint_and_name(url)\n unless proxy_info.empty?\n soaplab.endpoint = proxy_info[0] \n soaplab.name = proxy_info[1]\n soaplab.save\n end\n end\n end", "def update\n respond_to do |format|\n if @courier_station.update(courier_station_params)\n format.html { redirect_to @courier_station, notice: 'Courier station was successfully updated.' }\n format.json { render :show, status: :ok, location: @courier_station }\n else\n format.html { render :edit }\n format.json { render json: @courier_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n super if defined? super\n @systems.each_value do |system|\n system.update\n end\n end", "def index\n @line_station_2s = LineStation2.all\n end", "def index\n @satellites = Satellite.all\n @sat_json = Satellite.includes(:barrels).map { |sat| sat.as_json.merge({barrels: sat.barrels.as_json}) }\n end", "def update!(**args)\n @agency = args[:agency] if args.key?(:agency)\n @station_code = args[:station_code] if args.key?(:station_code)\n end", "def scrape_fio_data\n\t# Get all the weather stations\n\tweather_stations = WeatherStation.all\n\t# For each of these weather stations get the forecast\n\tfor weather_station in weather_stations\n\t\tlat_lon = \"#{weather_station.lat},#{weather_station.lon}\"\n\t\tforecast = JSON.parse(open(\"#{BASE_URL}/#{API_KEY}/#{lat_lon}#{UNITS}\").read)\n\t\t# Parse the data which is required\n\t\ttemperature = forecast['currently']['temperature']\n\t\tdew_point = forecast['currently']['dewPoint']\n\t\twind_spd = forecast['currently']['windSpeed']\n\t\twind_dir = forecast['currently']['windBearing']\n\t\train = forecast['currently']['precipIntensity']\n\t\tpersist_data weather_station.name, SOURCEFIO, temperature, dew_point, wind_spd, wind_dir, rain\n\tend\nend", "def stations_status\n Citibikenyc.stations_status\n end", "def all_planes\n self.planes.collect do |plane_obj|\n plane_obj.update_status_and_location\n end\n end", "def index\n @station_dailies = StationDaily.all\n end", "def updateVehicleTableWhole()\n @newVehicleList.clear() ;\n @finishedVehicleList.clear() ;\n\n # get vehicle id list\n idList = fetchVehicleIdList() ;\n\n idTable = {} ;\n idList.each{|vId|\n idTable[vId] = vId ;\n if(@vehicleTable[vId].nil?) then\n #length\n newVehicle = newVehicle(vId, {}) ;\n @newVehicleList.push(newVehicle) ;\n\n newVehicle.submitAll() ;\n end\n }\n @vehicleList.each{|vehicle|\n if(vehicle.isOnRoad?() && idTable[vehicle.id].nil?) then\n @finishedVehicleList.push(vehicle) ;\n vehicle.letFinished() ;\n end\n }\n\n return @newVehicleList ;\n end" ]
[ "0.698828", "0.6278264", "0.5869688", "0.58676517", "0.5729337", "0.56947315", "0.5577968", "0.5575948", "0.55673766", "0.55408454", "0.55315363", "0.55167544", "0.54987544", "0.54011744", "0.5377886", "0.5368271", "0.53562886", "0.53431135", "0.5324092", "0.5319878", "0.5318463", "0.52785677", "0.5256175", "0.5249929", "0.52439046", "0.5218747", "0.5186257", "0.51775014", "0.5172632", "0.5165505", "0.5164029", "0.51569074", "0.51173615", "0.5114521", "0.5112656", "0.5085093", "0.5079364", "0.5077471", "0.5065794", "0.506304", "0.50357234", "0.50342554", "0.5032632", "0.5029426", "0.50131464", "0.5005903", "0.49962488", "0.4982245", "0.4982245", "0.49605706", "0.49602395", "0.49591035", "0.49591035", "0.49591035", "0.49482355", "0.4945671", "0.49396268", "0.4939488", "0.49358943", "0.49325937", "0.49273378", "0.4921397", "0.4912179", "0.49098897", "0.49098304", "0.490807", "0.49070382", "0.49029297", "0.4900996", "0.4900455", "0.49000448", "0.4893597", "0.48935044", "0.4884116", "0.488116", "0.48792556", "0.48774254", "0.48645166", "0.4857395", "0.48507306", "0.4836617", "0.48340002", "0.48332298", "0.48327926", "0.48317826", "0.48290753", "0.48288295", "0.4827067", "0.4826221", "0.4824888", "0.48114234", "0.48093495", "0.48072606", "0.48000574", "0.47931796", "0.4787139", "0.47766542", "0.47614276", "0.47538042", "0.47511208" ]
0.72969127
0
Updates all weather observations from BOM data feeds.
def update_observations State.all.each do |s| fork do Station.where(state_id: s.id).each do |s| fetch_observations(s) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_from_darksky(historical_dates=[Date.today-1], forecast=true)\n darksky_secret = ApiKey.where(:service => 'Darksky').first.key\n hydra = Typhoeus::Hydra.new\n requests = Hash.new\n forecast_request = nil\n\n logger.debug(\"Updating Station #{name} for dates: #{historical_dates}\")\n \n # Construct the HTTP requests to Darksky: one for each of the past days we care about, and one for today to get the forecast\n historical_dates.each do |d|\n endpoint = \"https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude},#{d.to_time.to_i}\"\n request = Typhoeus::Request.new(endpoint) \n hydra.queue(request)\n requests[d] = request\n end\n forecast_request = Typhoeus::Request.new(\"https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude}\")\n hydra.queue(forecast_request) if forecast\n\n # Run the whole lot of them!\n hydra.run\n\n # Parse out the observed precipitation from the historical queries\n reports = []\n requests.each_pair do |d, request|\n if request.response.timed_out?\n logger.error \"Request to Darksky timed out: #{request}\"\n next\n end\n if request.response.nil?\n logger.error \"No response from Darksky for request #{request}\"\n next\n end\n if request.response.code != 200\n logger.error \"Unable to fetch weather data from #{request.base_url}: #{request.response.code} #{request.response.status_message}\"\n next\n end\n\n # With error trapping done, let's parse the body and update the db with the report data.\n data = JSON.load(request.response.body)\n data['daily']['data'].each do |report|\n logger.debug(report)\n d = Time.at(report['time']).to_date\n datestamp = \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"\n logger.debug(\"Using timestamp #{datestamp}\")\n # We want to update an existing row in place if we've previously computed one\n r = weather_reports.find_or_create_by(\n :latitude => self.latitude,\n :longitude => self.longitude,\n :date => datestamp,\n )\n \n \n # TODO: multiply by the actual number of hours in the time period.\n precip = report['precipIntensity'] # This is in inches per hour\n logger.debug(\"Extracted precipitation report: #{precip} from report #{report}\")\n r.precip = precip * 24.0\n logger.debug(\"Constructed WeatherReport: #{r}\")\n logger.debug(\"Coordinates: #{r.latitude},#{r.longitude}\")\n logger.debug(\"Datestamp: #{r.date}\")\n logger.debug(\"Recorded Precip: #{r.precip}\")\n \n r.save\n reports.push(r)\n end\n end\n\n # Add the forecast data as well\n forecasts = []\n if forecast\n logger.info(\"Parsing forecasts for station #{self}\")\n logger.debug(\"Got response: #{forecast_request.response}\")\n if forecast_request.response.timed_out?\n logger.error \"Request to Darksky timed out: #{forecast_request}\"\n return\n end\n if forecast_request.response.nil?\n logger.error \"No response from Darksky for request #{forecast_request}\"\n return\n end\n if forecast_request.response.code != 200\n logger.error \"Unable to fetch weather data from #{forecast_request.base_url}: #{forecast_request.response.code} #{forecast_request.response.message}\"\n return\n end\n\n logger.debug(\"Successful response from Darksky\")\n data = JSON.load(forecast_request.response.body)\n data['daily']['data'].each do |report|\n logger.debug(report)\n d = Time.at(report['time']).to_date\n datestamp = \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"\n r = weather_reports.find_or_create_by(\n :latitude => self.latitude,\n :longitude => self.longitude,\n :date => datestamp,\n )\n r.precip = report['precipIntensity'] * 24.0 # The Darksky report gives us inches per hour\n\n logger.debug(\"Created forecast object: #{r}\")\n r.save\n forecasts.push(r)\n end\n end\n\n # TODO: add a column that we can record when this update was last run, for display on the webpage.\n {:reports => reports, :forecasts => forecasts}\n end", "def daily_forecast(location)\n id = location_id[location.downcase.to_sym]\n puts id\n# Maybe call it weather_update to call at 00:01 every day, needs to iterate over each location\n url = \"http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/#{id}?res=3hourly&key=0da4e1ea-8681-47bc-a5f9-5ab535ff75f2\"\n resp = Net::HTTP.get_response(URI.parse(url))\n data = resp.body\n result = JSON.parse(data)\n tomorrow = result[\"SiteRep\"][\"DV\"][\"Location\"][\"Period\"][1][\"Rep\"]\n\n @temp_tomorrow=[]\n tomorrow.each do |f|\n @temp_tomorrow << f[\"F\"].to_i\n end\n @cloud_tomorrow=[]\n tomorrow.each do |f|\n @cloud_tomorrow << f[\"V\"].to_i\n end\n @rain_tomorrow=[]\n tomorrow.each do |f|\n @rain_tomorrow << f[\"Pp\"].to_i\n end\n @wind_tomorrow=[]\n tomorrow.each do |f|\n @wind_tomorrow << f[\"S\"].to_i\n end\n\n tomorrow = WeatherData.new \n tomorrow.date = [Date.today.next_day.year, Date.today.next_day.month, Date.today.next_day.day]\n tomorrow.location = location\n tomorrow.temperature = @temp_tomorrow\n tomorrow.rainfall = @rain_tomorrow\n tomorrow.wind = @wind_tomorrow\n tomorrow.cloud = @cloud_tomorrow\n tomorrow.save\nend", "def forecast(loc)\n\n url = \"#{@base_url}/#{FORECAST_QUERY}/q/#{loc[0]},#{loc[1]}.json\" \n\n result = JSON.parse(open(url).read)\n\n return nil if result['response']['error'] \n return nil unless result['current_observation']\n\n obs = result['current_observation']\n loc = result['current_observation']['observation_location']\n fc = result['forecast']['simpleforecast']\n\n # puts 'Fetching for ' + obs['station_id']\n \n weather = WeatherStation.find_or_create_by_station_id(obs['station_id'])\n\n location = ObservationLocation.new\n\n location.full = loc['full']\n location.city = loc['city']\n location.state = loc['state']\n location.country = loc['country']\n location.country_iso3166 = loc['country_iso3166']\n location.loc = [loc['latitude'].to_f,loc['longitude'].to_f]\n location.elevation = loc['elevation']\n \n weather.observation_location = location\n\n weather.forecasts.clear\n\n fc['forecastday'].each do |f|\n\n forecast = Forecast.new\n\n date = DateTime.strptime(f['date']['epoch'].to_s,'%s')\n\n forecast.date = date\n forecast.conditions = f['conditions']\n forecast.pop = f['pop']\n forecast.high_c = f['high']['celsius']\n forecast.high_f = f['high']['fahrenheit']\n forecast.low_c = f['low']['celsius']\n forecast.low_f = f['low']['fahrenheit']\n\n forecast.qpf_day_mm = f['qpf_day']['mm']\n forecast.qpf_day_in = f['qpf_day']['in']\n forecast.qpf_allday_mm = f['qpf_allday']['mm']\n forecast.qpf_allday_in = f['qpf_allday']['in']\n forecast.qpf_night_mm = f['qpf_night']['mm']\n forecast.qpf_night_in = f['qpf_night']['in']\n\n forecast.snow_day_mm = f['snow_day']['mm']\n forecast.snow_day_in = f['snow_day']['in']\n forecast.snow_allday_mm = f['snow_allday']['mm']\n forecast.snow_allday_in = f['snow_allday']['in']\n forecast.snow_night_mm = f['snow_night']['mm']\n forecast.snow_night_in = f['snow_night']['in']\n\n forecast.wind_max_kph = f['maxwind']['kph'] \n forecast.wind_max_mph = f['maxwind']['mph'] \n forecast.wind_max_dir = f['maxwind']['dir'] \n forecast.wind_max_degrees = f['maxwind']['degrees'] \n\n forecast.wind_ave_kph = f['avewind']['kph'] \n forecast.wind_ave_mph = f['avewind']['mph'] \n forecast.wind_ave_dir = f['avewind']['dir'] \n forecast.wind_ave_degrees = f['avewind']['degrees'] \n\n forecast.humidity_ave = f['avehumidity']\n forecast.humidity_min = f['minhumidity']\n forecast.humidity_max = f['maxhumidity']\n\n weather.forecasts << forecast\n\n end\n\n weather.observation_time_rfc822 = obs['observation_time_rfc822']\n weather.local_time_rfc822 = obs['local_time_rfc822']\n weather.weather = obs['weather']\n weather.temp_f = obs['temp_f']\n weather.temp_c = obs['temp_c']\n weather.relative_humidity = obs['relative_humidity']\n weather.precip_today_metric = obs['precip_today_metric']\n\n return weather\n\n end", "def scrape_fio_data\n\t# Get all the weather stations\n\tweather_stations = WeatherStation.all\n\t# For each of these weather stations get the forecast\n\tfor weather_station in weather_stations\n\t\tlat_lon = \"#{weather_station.lat},#{weather_station.lon}\"\n\t\tforecast = JSON.parse(open(\"#{BASE_URL}/#{API_KEY}/#{lat_lon}#{UNITS}\").read)\n\t\t# Parse the data which is required\n\t\ttemperature = forecast['currently']['temperature']\n\t\tdew_point = forecast['currently']['dewPoint']\n\t\twind_spd = forecast['currently']['windSpeed']\n\t\twind_dir = forecast['currently']['windBearing']\n\t\train = forecast['currently']['precipIntensity']\n\t\tpersist_data weather_station.name, SOURCEFIO, temperature, dew_point, wind_spd, wind_dir, rain\n\tend\nend", "def update_weather\r\n # Update weather graphic\r\n @weather.type = $game_screen.weather_type\r\n @weather.max = $game_screen.weather_max\r\n @weather.update\r\n end", "def fetch_six_day_forecast_at lat, lon\n app_id = Rails.application.credentials.open_weather_key\n todays_weather_response = Faraday.get(\"http://api.openweathermap.org/data/2.5/weather?units=imperial&lat=#{lat}&lon=#{lon}&appid=#{app_id}\")\n five_day_forecast_response = Faraday.get(\"http://api.openweathermap.org/data/2.5/forecast?units=imperial&lat=#{lat}&lon=#{lon}&appid=#{app_id}\")\n todays_weather = JSON.parse(todays_weather_response.body)\n five_day_forecast = JSON.parse(five_day_forecast_response.body)\n\n # This is the serialized version being sent to the client. It only contains relevant information. Just the location followed by the six-day forecast\n six_day_forecast_serialized = {\n :location => \"#{todays_weather[\"name\"]}, #{todays_weather[\"sys\"][\"country\"]}\",\n :forecast => [\n todays_weather[\"main\"][\"temp\"]\n ]\n }\n\n # Used to shift all frame of time to correct offset. Could not find any built-in methods to set a fixed offset.\n utc_offset = five_day_forecast[\"city\"][\"timezone\"]\n\n # Find the current day (tomorrow) and the day after relative to the client\n current_day = (Time.zone.now + utc_offset).beginning_of_day.tomorrow\n next_day = current_day.tomorrow\n\n # Set the loop up with the first measurement\n highest_high = nil\n\n # Create index for moving days\n day_index = 1\n\n five_day_forecast[\"list\"].each do |forecast|\n # Find current time by UTC and then offset with given offset to make sure the day ranges are correct to capture the correct high's regardless of timezone\n current_time = Time.zone.at(forecast[\"dt\"]+utc_offset)\n temp = forecast[\"main\"][\"temp\"]\n\n if (current_time >= current_day) and (current_time < next_day)\n if (!highest_high) or (temp > highest_high)\n six_day_forecast_serialized[:forecast][day_index] = temp \n highest_high = temp\n end\n elsif current_time >= next_day\n highest_high = temp\n day_index += 1\n six_day_forecast_serialized[:forecast][day_index] = temp \n current_day = current_day.tomorrow\n next_day = current_day.tomorrow\n end\n\n end\n\n six_day_forecast_serialized\n end", "def fetch_weather\n\t response = HTTParty.get(\"http://api.wunderground.com/api/cdb75d07a23ad227/#{date}/q/#{location}/#{cityfixed}.xml\")\n\t parse_response(response)\n\tend", "def weatherData \n\n icons = {\n \"clear-day\" => \"pe-7w-sun\",\n \"clear-night\" => \"pe-7w-moon\",\n \"rain\" => \"pe-7w-rain-alt\",\n \"snow\" => \"pe-7w-snow-alt\",\n \"sleet\" => \"pe-7w-snow\",\n \"wind\" => \"pe-7w-wind\",\n \"fog\" => \"pe-7w-fog\",\n \"cloudy\" => \"pe-7w-cloud\",\n \"partly-cloudy-day\" => \"pe-7w-cloud-sun\",\n \"partly-cloudy-night\" => \"pe-7w-cloud-moon\", \n \"default\" => \"pe-7w-thermometer-full\",\n }\n \n @weather_data = HTTParty.get('https://api.darksky.net/forecast/f3d5dcb788b60bc988305e4ba4bf0fe9/51.208168,-1.516628?exclude=hourly,minutely,flags&units=auto')\n\n # Current Weather\n @current_time = Time.at(@weather_data ['currently']['time'].to_i)\n @timezone = @weather_data ['timezone']\n @current_summary = @weather_data ['currently']['summary']\n \n @current_icon = icons.fetch(@weather_data ['currently']['icon'],\"pe-7w-thermometer-full\")\n @current_temp = @weather_data ['currently']['temperature'].to_i\n @current_temp_feels = @weather_data ['currently']['apparentTemperature'].to_i\n @current_humidity = (@weather_data ['currently']['humidity'] * 100).to_i\n @current_windspeed = @weather_data ['currently']['windSpeed'].to_i\n @current_windgust = @weather_data ['currently']['windGust'].to_i\n @current_windbearing = @weather_data ['currently']['windBearing']\n @current_cloudcover = (@weather_data ['currently']['cloudCover'] * 100).to_i\n @current_uvindex = @weather_data ['currently']['uvIndex']\n if @current_uvindex <= 2\n @uvindex = 'bg-succes'\n elsif @current_uvindex <= 5\n @uvindex = 'bg-yellow'\n elsif @current_uvindex <= 7\n @uvindex = 'bg-warning'\n elsif @current_uvindex <= 10\n @uvindex = 'bg-danger'\n elsif @current_uvindex < 10\n @uvindex = 'bg-violet'\n else \n @uvindex = 'bg-transparent'\n end\n @current_percp = (@weather_data ['currently']['precipProbability'] * 100).to_i\n @current_high = @weather_data ['daily']['data'][0]['temperatureHigh']\n @current_low = @weather_data ['daily']['data'][0]['temperatureLow']\n \n #weather forcast\n @weekly_summary = @weather_data ['daily']['summary']\n # Next 6 days\n @day_one_time = Time.at( @weather_data ['daily']['data'][1]['time'].to_i)\n @day_one_icon = icons [@weather_data ['daily']['data'][1]['icon']]\n @day_one_hi = @weather_data ['daily']['data'][1]['temperatureHigh'].to_i\n @day_one_low = @weather_data ['daily']['data'][1]['temperatureLow'].to_i\n\n @day_two_time = Time.at( @weather_data ['daily']['data'][2]['time'].to_i)\n @day_two_icon = icons [@weather_data ['daily']['data'][2]['icon']]\n @day_two_hi = @weather_data ['daily']['data'][2]['temperatureHigh'].to_i\n @day_two_low = @weather_data ['daily']['data'][2]['temperatureLow'].to_i\n\n @day_three_time = Time.at( @weather_data ['daily']['data'][3]['time'].to_i)\n @day_three_icon = icons [@weather_data ['daily']['data'][3]['icon']]\n @day_three_hi = @weather_data ['daily']['data'][3]['temperatureHigh'].to_i\n @day_three_low = @weather_data ['daily']['data'][3]['temperatureLow'].to_i\n\n @day_four_time = Time.at( @weather_data ['daily']['data'][4]['time'].to_i)\n @day_four_icon = icons [@weather_data ['daily']['data'][4]['icon']]\n @day_four_hi = @weather_data ['daily']['data'][4]['temperatureHigh'].to_i\n @day_four_low = @weather_data ['daily']['data'][4]['temperatureLow'].to_i\n\n @day_five_time = Time.at( @weather_data ['daily']['data'][5]['time'].to_i)\n @day_five_icon = icons [@weather_data ['daily']['data'][5]['icon']]\n @day_five_hi = @weather_data ['daily']['data'][5]['temperatureHigh'].to_i\n @day_five_low = @weather_data ['daily']['data'][5]['temperatureLow'].to_i\n\n @day_six_time = Time.at( @weather_data ['daily']['data'][6]['time'].to_i)\n @day_six_icon = icons [@weather_data ['daily']['data'][6]['icon']]\n @day_six_hi = @weather_data ['daily']['data'][6]['temperatureHigh'].to_i\n @day_six_low = @weather_data ['daily']['data'][6]['temperatureLow'].to_i\n\n end", "def save_reading()\n\tStation.all.each do |x|\n\t\tstation_id = x.station_id\n\t\tlat = x.lat\n\t\tlong = x.long\n\t\tlat_long = \"#{lat},#{long}\"\n\t\tforecast = JSON.parse(open(\"#{BASE_URL}/#{API_KEY}/#{lat_long}\").read)\n\t\tr = WeatherReading.new\n\t\tr.build_reading(station_id,lat,long,current_date(forecast),current_time(forecast),current_temperature(forecast),current_dew_point(forecast),\n\t\t\tcurrent_wind_direction(forecast),current_wind_speed(forecast),current_rainfall(forecast),\"forecast.io\")\n\t\tr.save\n\tend\n\nend", "def set_current_weather(locations)\n lower_bound = Time.zone.now - 30.minutes\n loc_ids = []; distances = []\n locations.each do |loc, i|\n if !loc[:loc].last_update.nil? and loc[:loc].last_update > lower_bound\n loc_ids << loc[:id]\n distances << loc[:distance]\n end\n end\n loc_ids = loc_ids[0..1]; distances = distances[0..1]\n return if !loc_ids.compact.any?\n MEASUREMENTS.each do |m|\n values = []\n loc_ids.each do |lid|\n obs = Observation.where(location_id: lid).last\n return if obs.nil?\n values << obs.rainfall.intensity if (m == \"rain\")\n values << obs.temperature.temp if (m == \"temp\")\n values << obs.wind.speed if (m == \"wind_speed\")\n values << obs.wind.bearing if (m == \"wind_direction\")\n end\n agg = Observation.aggregate(values, distances).round(2)\n agg = agg.abs.to_s + \"mm/h\" if(m == \"rain\")\n agg = agg.abs.to_s + \"km/h\" if(m == \"wind_speed\")\n agg = Wind.bearing_to_cardinal(agg).to_s if (m == \"wind_direction\")\n agg = agg.to_s if (m == \"temp\")\n @data[\"0\"][m][\"value\"] = agg\n @data[\"0\"][m][\"probability\"] = \"1\"\n\n end\n end", "def weather(location)\n \n #instantiate client object\n client = Weatherman::Client.new(unit: 'f')\n \n temp = client.lookup_by_location(location).condition['temp']\n condition = client.lookup_by_location(location).condition['text']\n\n puts \"The weather right now is #{condition} with a temperature of #{temp} \\xC2\\xB0F.\"\n \n \n #instantiate forecasts\n weather = client.lookup_by_location(location)\n forecasts = weather.forecasts \n \n ##################################\n #loop through forecast hashes to print out forecast values\n ##################################\n \n puts \"Here's your 5-day forecast:\"\n \n #Get today's day of the week as a number\n current_day = Time.now.strftime('%w').to_i\n \n forecasts.each do |forecast|\n \n #Get forecast's day of the week as a number\n forecast_day = forecast['date'].strftime('%w').to_i\n\n #compare current day with each forecast day to determine if forecast is today, tomorrow, or another day\n if current_day == forecast_day\n weekday = 'Today'\n elsif current_day + 1 == forecast_day\n weekday = 'Tomorrow'\n elsif current_day == 6 && forecast_day == 0\n weekday = 'Tomorrow'\n else\n weekday = forecast['day']\n end\n\n #print out forecast in terminal\n puts weekday + \"\\'s forecast is \" + forecast.fetch('text') + \" with a low of \" + forecast.fetch('low').to_s + \"\\xC2\\xB0F and a high of \" + forecast.fetch('high').to_s + \"\\xC2\\xB0F.\"\n\n\n end\n ##################################\n #end loop\n ##################################\n \nend", "def weather_forecast\n city = self.city\n state = self.state\n ForecastFacade.forecast(city, state)\n end", "def current_weather_data\r\n response = self.get_data\r\n\r\n # next steps: error handling in case the call breaks outright and returns nothing / no error code / a socketerror\r\n return unless response.response.code == \"200\"\r\n\r\n data_points = JSON.parse(response.body)[\"list\"]\r\n weather_hash = {}\r\n\r\n # loop through the data points and then add to a list of points for each individual day\r\n data_points.map { |data_point|\r\n forecast_time = DateTime.strptime(data_point[\"dt\"].to_s,'%s').in_time_zone(\"Central Time (US & Canada)\")\r\n forecast_date = forecast_time.strftime(\"%B %-e\")\r\n weather_hash[forecast_date] = [] if weather_hash[forecast_date].blank?\r\n\r\n temperature = data_point[\"main\"][\"temp\"]\r\n weather_text = data_point[\"weather\"].first[\"description\"]\r\n icon = data_point[\"weather\"].first[\"icon\"]\r\n\r\n weather_hash[forecast_date] << {temperature: temperature, weather: weather_text, icon: icon}\r\n }\r\n\r\n weather_hash.keys.each do |key|\r\n weather_hash[key] = daily_weather(weather_hash[key])\r\n end\r\n\r\n # sometimes the way that the forecast looks out, we end up with extra days' worth of content\r\n # I'd check with the PO to see if we only want to consider full days of weather data\r\n # but for now I'm going to focus on the first five soonest days we have data for, and ignore the bits of day 6 that might creep into the feed\r\n return engagement_data(weather_hash).first(5)\r\n end", "def update_all_prices\n csv_contents = CSV.parse(open(DAILY_PRICE_URL).read)\n csv_contents.shift\n csv_contents.each do |row|\n date = Date.parse(row[0]).to_s\n symbol = row[1]\n openprice = row[3]\n closeprice = row[4]\n price_path = PRICE_DIR.join(\"#{symbol.downcase}.csv\")\n \n update(price_path, symbol, date, closeprice, openprice)\n end\nend", "def fetch_observations(station)\n\n scraper_logger.info(\"Fetching latest weather observations for #{station.id} - #{station.name}\")\n\n new = 0\n\n json = extract_observations(station.json_url)\n json['observations']['data'].each do |o|\n\n Time.zone = 'UTC'\n recording_time = Time.zone.parse(\"#{o['aifstime_utc']}Z\")\n\n unless Observation.already_exists?(station, recording_time)\n observation = Observation.new\n observation.station = station\n observation.recording_time = recording_time\n observation.save\n\n parse_readings(o, observation)\n\n new += 1\n\n end\n\n end\n\n scraper_logger.info(\"Added #{new} new observations\")\n\n end", "def update_all\n data_in_batches do |batch|\n Bookings::Data::SchoolUpdater.new(batch).update\n end\n end", "def city_weather\n self.class.get(\"/data/2.5/forecast\", @options)\n end", "def forecast_array\n @forecast ||= HTTParty.get(\"http://api.openweathermap.org/data/2.5/forecast/daily?q=Seattle&cnt=3&units=imperial&mode=json\").parsed_response[\"list\"]\n end", "def update\n @bom.update(bom_params)\n end", "def getForecast(location, today)\n forecasts = location.forecasts\n\n # for each forecast, set the weekday, predicted high temp and predicted low temp\n forecasts.each do |forecast|\n weekday = forecast['date']\n day = weekday.strftime('%A')\n weather = forecast['text'].downcase\n predHigh = forecast['high'].to_i\n predLow = forecast['low'].to_i\n\n dayNum = weekday.strftime('%w')\n\n # set the correct day of the week in the forecast using a conditional statement\n if dayNum == today\n weekday = \"Today\"\n elsif dayNum == today + 1 || dayNum == today -6\n weekday \"Tomorrow\"\n else\n weekday = day\n end\n\n puts \"#{weekday}'s forecast is #{weather} with a high of #{predHigh} ˚C and a low of #{predLow} ˚C.\"\n end\nend", "def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end", "def weather_api\n url = URI('https://api.weatherbit.io/v2.0/forecast/daily?city=Santiago&key=a01895cdf39141f9a8a77e66aafbcca2')\n https = Net::HTTP.new(url.host, url.port)\n https.use_ssl = true\n request = Net::HTTP::Get.new(url)\n https.use_ssl = true\n https.verify_mode = OpenSSL::SSL::VERIFY_PEER\n request['cache-control'] = 'no-cache'\n request['Postman-Token'] = 'e29ce4a5-022b-47aa-b42a-bb571635fc04'\n response = https.request(request)\n response = JSON.parse response.read_body\n temp = []\n response['data'].each_with_index do |r, index|\n temp.push(r['high_temp'])\n break if index > 6\n end\n Weather.create(hot_weather: temp.any? { |t| t > 24 })\n end", "def forecasts\n convertions = [[:date, :to_date], [:low, :to_i], [:high, :to_i], [:code, :to_i], :day, :text]\n item_attribute('yweather:forecast').collect do |forecast|\n translate! do_convertions(forecast, *convertions)\n end\n end", "def hourly_forecasts(data)\n @hourly_forecasts = data[:hourly][:data].map do |hourly_forecast|\n #remove to separate method\n forecast = {\n id: hourly_forecast[:time],\n date: Time.at(hourly_forecast[:time]).to_date,\n time: Time.at(hourly_forecast[:time]).to_s.split(\"T\").last.split(\".\").first,\n icon: hourly_forecast[:icon],\n temp: hourly_forecast[:temperature]\n }\n HourlyForecast.new(forecast)\n end\n end", "def get_forecast!( params_hash={} )\n \n # Use last known search if no params given.\n params_hash[:location] ||= current_location\n params_hash[:days] ||= current_days\n \n # If it's a new forecast\n if params_hash[:location] != prev_location || params_hash[:days] != prev_days \n \n # Log the changes\n update_attributes( prev_location: current_location, prev_days: current_days, current_location: params_hash[:location], current_days: params_hash[:days] )\n \n end\n \n # Return forecast data\n self.class.get_forecast( params_hash )\n \n end", "def set_weather_file(model, runner = nil)\n BTAP::runner_register(\"Info\", \"BTAP::Environment::WeatherFile::set_weather\",runner)\n OpenStudio::Model::WeatherFile::setWeatherFile(model, @epw_file)\n BTAP::runner_register(\"Info\", \"Set model \\\"#{model.building.get.name}\\\" to weather file #{model.weatherFile.get.path.get}.\\n\",runner)\n\n # Add or update site data\n site = model.getSite\n site.setName(\"#{@epw_file.city}_#{@epw_file.stateProvinceRegion}_#{@epw_file.country}\")\n site.setLatitude(@epw_file.latitude)\n site.setLongitude(@epw_file.longitude)\n site.setTimeZone(@epw_file.timeZone)\n site.setElevation(@epw_file.elevation)\n\n BTAP::runner_register(\"Info\",\"Setting water main temperatures via parsing of STAT file.\", runner ) \n water_temp = model.getSiteWaterMainsTemperature\n water_temp.setAnnualAverageOutdoorAirTemperature(@stat_file.mean_dry_bulb)\n water_temp.setMaximumDifferenceInMonthlyAverageOutdoorAirTemperatures(@stat_file.delta_dry_bulb)\n BTAP::runner_register(\"Info\",\"SiteWaterMainsTemperature.AnnualAverageOutdoorAirTemperature = #{@stat_file.mean_dry_bulb}.\", runner ) \n BTAP::runner_register(\"Info\",\"SiteWaterMainsTemperature.MaximumDifferenceInMonthlyAverageOutdoorAirTemperatures = #{@stat_file.delta_dry_bulb}.\", runner ) \n\n # Remove all the Design Day objects that are in the file\n model.getObjectsByType(\"OS:SizingPeriod:DesignDay\".to_IddObjectType).each { |d| d.remove }\n\n # Load in the ddy file based on convention that it is in the same directory and has the same basename as the weather\n @ddy_file.getObjectsByType(\"OS:SizingPeriod:DesignDay\".to_IddObjectType).each do |d|\n # grab only the ones that matter\n ddy_list = /(Htg 99.6. Condns DB)|(Clg .4. Condns WB=>MDB)|(Clg .4% Condns DB=>MWB)/\n if d.name.get =~ ddy_list\n BTAP::runner_register(\"Info\",\"Adding design day '#{d.name}'.\",runner)\n # add the object to the existing model\n model.addObject(d.clone)\n end\n end\n return true\n end", "def update\n @objects.map(&:update);\n end", "def feats_update\n if Config.exists?\n API.upload_feats\n end\n end", "def historical(loc, range)\n\n months = [] \n\n url = \"#{@base_url}/planner_01010131/q/#{loc}.json\"\n\n result = JSON.parse(open(url).read)\n\n return nil if result['response']['error'] \n return nil unless result['trip']\n \n icao = result['trip']['airport_code']\n\n if icao.nil? || icao.empty?\n # puts 'Empty airport code, trying next.'.color(:red)\n return nil \n end\n\n airport = Airport.find_by_gps_code(icao)\n\n if airport.nil?\n puts \"Error: Airport #{icao} not found in db, trying next.\".color(:red)\n return nil \n end\n\n if airport.historical_weather_months.size == 12\n puts \"Airport #{airport.gps_code} already populated with data, trying next.\".color(:cyan)\n return nil\n end\n\n puts \"<< Found #{airport.gps_code}.\".color(:cyan)\n\n # Loop through each month\n range.each do |month| \n \n sleep @delay\n\n case month\n when 2\n days = 28\n when 1, 3, 5, 7, 8, 10, 12\n days = 31\n else\n days = 30\n end\n\n range = \"%02d%02d%02d%02d\" % [month, 1, month, days]\n\n url = \"#{API_URL}/planner_#{range}/q/#{icao}.json\"\n\n # print \" Fetching data for #{month_names[month-1]}... \"\n\n result = JSON.parse(open(url).read)\n\n return nil if result['response']['error'] \n return nil unless result['trip']\n\n if result['trip']['airport_code'].empty?\n # puts\n # puts 'Airport code not found, breaking.'.color(:red)\n break\n end\n \n trip = result['trip']\n\n hist = HistoricalWeather.new\n\n hist.month = month\n\n hist.high_min_c = trip['temp_high']['min']['C'].to_i\n hist.high_avg_c = trip['temp_high']['avg']['C'].to_i\n hist.high_max_c = trip['temp_high']['max']['C'].to_i\n hist.high_min_f = trip['temp_high']['min']['F'].to_i\n hist.high_avg_f = trip['temp_high']['avg']['F'].to_i\n hist.high_max_f = trip['temp_high']['max']['F'].to_i\n\n hist.low_min_c = trip['temp_low']['min']['C'].to_i\n hist.low_avg_c = trip['temp_low']['avg']['C'].to_i\n hist.low_max_c = trip['temp_low']['max']['C'].to_i\n hist.low_min_f = trip['temp_low']['min']['F'].to_i\n hist.low_avg_f = trip['temp_low']['avg']['F'].to_i\n hist.low_max_f = trip['temp_low']['max']['F'].to_i\n \n hist.dewpoint_high_min_c = trip['dewpoint_high']['min']['C'].to_i\n hist.dewpoint_high_avg_c = trip['dewpoint_high']['avg']['C'].to_i\n hist.dewpoint_high_max_c = trip['dewpoint_high']['max']['C'].to_i\n hist.dewpoint_high_min_f = trip['dewpoint_high']['min']['F'].to_i\n hist.dewpoint_high_avg_f = trip['dewpoint_high']['avg']['F'].to_i\n hist.dewpoint_high_max_f = trip['dewpoint_high']['max']['F'].to_i\n \n hist.dewpoint_low_min_c = trip['dewpoint_low']['min']['C'].to_i\n hist.dewpoint_low_avg_c = trip['dewpoint_low']['avg']['C'].to_i\n hist.dewpoint_low_max_c = trip['dewpoint_low']['max']['C'].to_i\n hist.dewpoint_low_min_f = trip['dewpoint_low']['min']['F'].to_i\n hist.dewpoint_low_avg_f = trip['dewpoint_low']['avg']['F'].to_i\n hist.dewpoint_low_max_f = trip['dewpoint_low']['max']['F'].to_i\n\n hist.precip_min_cm = trip['precip']['min']['cm'].to_f\n hist.precip_avg_cm = trip['precip']['avg']['cm'].to_f\n hist.precip_max_cm = trip['precip']['max']['cm'].to_f\n hist.precip_min_in = trip['precip']['min']['in'].to_f\n hist.precip_avg_in = trip['precip']['avg']['in'].to_f\n hist.precip_max_in = trip['precip']['max']['in'].to_f\n\n chance = trip['chance_of']\n\n hist.chance_temp_below_0 = chance['tempbelowfreezing']['percentage'].to_i\n hist.chance_temp_0_16 = chance['tempoverfreezing']['percentage'].to_i\n hist.chance_temp_16_32 = chance['tempoversixty']['percentage'].to_i\n hist.chance_temp_over_32 = chance['tempoverninety']['percentage'].to_i\n hist.chance_dewpoint_over_16 = chance['chanceofhumidday']['percentage'].to_i\n hist.chance_dewpoint_over_21 = chance['chanceofsultryday']['percentage'].to_i\n hist.chance_precip = chance['chanceofprecip']['percentage'].to_i\n hist.chance_snow_ground = chance['chanceofsnowonground']['percentage'].to_i\n hist.chance_rain_day = chance['chanceofrainday']['percentage'].to_i\n hist.chance_snow_day = chance['chanceofsnowday']['percentage'].to_i\n hist.chance_hail_day = chance['chanceofhailday']['percentage'].to_i\n hist.chance_partly_cloudy_day = chance['chanceofpartlycloudyday']['percentage'].to_i\n hist.chance_cloudy_day = chance['chanceofcloudyday']['percentage'].to_i\n hist.chance_foggy_day = chance['chanceofhailday']['percentage'].to_i\n hist.chance_thunder_day = chance['chanceofthunderday']['percentage'].to_i\n hist.chance_tornado_day = chance['chanceoftornadoday']['percentage'].to_i\n hist.chance_windy_day = chance['chanceofwindyday']['percentage'].to_i\n hist.chance_sunny_cloudy_day = chance['chanceofsunnycloudyday']['percentage'].to_i\n\n months << hist\n\n# puts \"done\".color(:green)\n\n end\n\n airport.historical_weather_months = months\n \n return airport\n# airport.save!\n\n# puts \"Saved historical data for #{airport.gps_code}\".color(:cyan)\n# puts \n\n end", "def fill_repository(data, duration, offset, start_date)\n data.each { |line|\n forecast_hours = line[1].to_f\n next if (forecast_hours < offset)\n entry = create_wrf_entry(line, start_date)\n if (forecast_hours - offset <= duration)\n @data_repository.add_data_entry(entry)\n else\n break\n end\n }\n @duration = @data_repository.repository.last.forecast_time\n nil\n end", "def update_all_feeds\n Feed.all.each do |feed_entry|\n begin\n feed = Feedzirra::Feed.fetch_and_parse(feed_entry.feed_url)\n rescue Exception => e\n Rails.logger.error \"Feedzirra threw an error on feed_entry #{feed_entry.id}: #{e.inspect}\"\n end\n if !feed.blank? && !feed.is_a?(Fixnum) && !feed.entries.blank?\n feed.entries.each do |entry|\n begin\n entry.summary = @html_sanitizer.sanitize(entry.summary) unless entry.summary.blank?\n next if entry.title.blank? || entry.summary.blank? || entry.url.blank? || entry.id.blank? || entry.published.blank?\n guid = Base64.urlsafe_encode64(OpenSSL::Digest::MD5.digest(entry.id))\n unless FeedEntry.exists?(guid: guid)\n FeedEntry.create(title: clean_string(entry.title), summary: clean_string(entry.summary), url: clean_string(entry.url), published_at: entry.published, guid: guid, fetched: false)\n end\n rescue Exception => e\n Rails.logger.error \"Caught an error on inserting feed_entry #{entry.id}: #{e.inspect}\"\n end\n end\n end\n end\n end", "def update_orbit(available_orbits, orbit_meta, current_weather)\n orbit_name = orbit_meta.first\n orbit_traffic_speed = orbit_meta[-2].to_i\n\n orbit = available_orbits.find{|orbit| orbit.name == orbit_name }\n\n orbit.update_traffic_speed (orbit_traffic_speed)\n orbit.weathering (current_weather)\n end", "def set_weather\n @weather = Weather.find(params[:id])\n end", "def set_weather\n @weather = Weather.find(params[:id])\n end", "def set_weather\n @weather = Weather.find(params[:id])\n end", "def set_weather\n @weather = Weather.find(params[:id])\n end", "def weather\n # empty array dates is still fine, not a reason for 400 (happens for venues without courts)\n render json: {} and return if params.dig(:dates).blank?\n\n forecast = WeatherForecaster.call(venue, [*params.require(:dates)])\n json = forecast.transform_values do |value|\n value ? value.slice(*%w(icon temperature)) : nil\n end\n render json: json\n end", "def index\n @forecast_72s = Forecast72.all\n end", "def update_info_bars\n @info_bars.each_value do |info_bars|\n info_bars.each(&:update)\n end\n end", "def update\n update_save(@sensor_datum, sensor_datum_params, \"Sensor datum\")\n end", "def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end", "def update_all(logger=Logger.new)\n all_coins = get_latest_coins_ticker\n\n # Check if the data is up-to-date\n effective_date = Time.at(all_coins['time_stamp']).utc.to_datetime\n if !latest_effective_date.nil? and latest_effective_date >= effective_date\n logger.info \"Skipping update: latest_effective_date is #{latest_effective_date} but BraveNewCoin time_stamp is #{effective_date}\"\n return\n end\n\n logger.info \"Found #{all_coins['ticker'].size} coins to update\"\n all_coins['ticker'].each do |coin_data|\n # We store raw data as Strings for now as the API isn't fully documented yet\n ticker = new(coin_data)\n # Make sure to store UTC only\n ticker.effective_date = effective_date\n logger.warn \"Unable to store data for #{coin_data}\" unless ticker.save\n end\n end", "def update\n @creatures.each { |c| c.update(@map) }\n end", "def create\n# @weather = Weather.new(weather_params)\n\n\t# Montyレポートの取得\n @parse_weather_data = WeathersHelper::ParseWheatherData.new(\"public/weather_data/daily\")\n @weather_data = @parse_weather_data.main\n\n @weather_data.each do |w|\n w.data.each do |line|\n @weather = Weather.new(\n :area => w.area,\n :date => line[0],\n :ave_temperature => line[1],\n :max_temperature => line[4],\n :min_temperature => line[7],\n :rainfall => line[10],\n :max_rainfall => line[14],\n :day_length => line[18],\n :insolation => line[22],\n :max_snow => line[25],\n :total_snow => line[29],\n :ave_wind_speed => line[33],\n :max_wind_speed => line[36],\n :max_wind_direction => line[38],\n :momentary_wind_speed => line[41],\n :momentary_wind_direction => line[43],\n :most_direction => line[46],\n :ave_stream_pressure => line[49],\n :ave_humidity => line[52],\n :min_himidity => line[55],\n :ave_pressure => line[58],\n :ave_sea_pressure => line[61],\n :min_sea_pressure => line[64],\n :ave_cloud_amount => line[68],\n :outline06_18 => line[71],\n :outline18_06 => line[74]\n )\n @weather.save\n end\n end unless @weather_data.nil?\n\n # Dailyレポートの取得\n @parse_weather_data = WeathersHelper::ParseWheatherData.new(\"public/weather_data/hourly\")\n @weather_data = @parse_weather_data.main\n\n @weather_data.each do |w|\n w.data.each do |line|\n @weather_hours = WeatherHour.new(\n :area => w.area,\n :date => line[0].split[0],\n :t_time => line[0].split[1],\n :date_time => line[0],\n :temperature => line[1],\n :wind_speed => line[4],\n :wind_direction => line[6],\n :railfall => line[9],\n :snow => line[13],\n :day_length => line[21],\n :insolation => line[25],\n :pressure => line[28],\n :sea_pressure => line[31],\n :humidity => line[34],\n :stream_pressure => line[37],\n )\n @weather_hours.save\n end\n end unless @weather_data.nil?\n\n respond_to do |format|\n format.html { redirect_to @weather, notice: 'Weather was successfully created.' }\n format.json { render :show, status: :created, location: @weather }\n=begin\n if @weather.save\n format.html { redirect_to @weather, notice: 'Weather was successfully created.' }\n format.json { render :show, status: :created, location: @weather }\n else\n format.html { render :new, notice: 'Found Same Data' }\n format.json { render json: @weather.errors, status: :unprocessable_entity }\n end\n=end\n end\n end", "def get_weather\n location_id = params[:location_id].to_i\n date = Date.parse(params[:date])\n location = Location.find(location_id)\n current_time = Time.now\n weather_obs_list = Observation.where(location_id: location_id)\n latest_weather = weather_obs_list.last\n\n if (latest_weather.updated_at - current_time).to_i.abs > 30*60\n current_temp = \"Null\"\n else\n current_temp = latest_weather.temperature\n end\n\n current_cond = \"sunny\"\n if latest_weather.rainfall == 0\n current_cond = \"sunny\"\n else\n current_cond = \"raining\"\n end\n\n @hash = {}\n @hash[\"date\"] = date\n @hash[\"current_temp\"] = current_temp\n @hash[\"current_cond\"] = current_cond\n\n measurements = Array.new\n weather_obs_list.each do |weather|\n if weather.timestamp.to_date == date\n measurement_hash = Hash.new\n measurement_hash[\"time\"] = weather.updated_at\n measurement_hash[\"temp\"] = weather.temperature\n measurement_hash[\"precip\"] = weather.rainfall\n measurement_hash[\"wind_direction\"] = weather.wind_dir\n measurement_hash[\"wind_speed\"] = weather.wind_speed\n measurements << measurement_hash\n end\n end\n @hash[\"measurements\"] = measurements\n end", "def update\n respond_to do |format|\n if @weather.update(weather_params)\n format.html { redirect_to @weather, notice: 'Weather was successfully updated.' }\n format.json { render :show, status: :ok, location: @weather }\n else\n format.html { render :edit }\n format.json { render json: @weather.errors, status: :unprocessable_entity }\n end\n end\n end", "def feed\n @energy += REGULAR_ENERGY\n @fed = true\n end", "def get_forecast\n @forecast = ForecastIO.forecast( lat, lng )\n end", "def set_forecast_72\n @forecast_72 = Forecast72.find(params[:id])\n end", "def yahoo_weather_query(loc_ids, units)\n weather = []\n loc_ids.each do |l|\n h = {}\n open(\"http://xml.weather.yahoo.com/forecastrss?p=#{l}&u=#{units}\") do |http|\n response = http.read\n doc = REXML::Document.new(response)\n channel = doc.root.elements['channel']\n title = channel.elements['title'].text\n if title !~ /Error/ then\n location = channel.elements['yweather:location']\n h[:city] = location.attributes[\"city\"]\n h[:region] = location.attributes[\"region\"]\n h[:country] = location.attributes[\"country\"]\n h[:temp] = channel.elements[\"item\"].elements[\"yweather:condition\"].attributes[\"temp\"]\n weather << h\n end\n end\n end\n weather\nend", "def update_batch batch\n batch.file_name = @zip_file_name\n batch.arrival_time = Time.now\n batch.facility_id = facility.id\n batch.client_id = facility.client_id\n batch.contracted_time = (Time.now + facility.tat.to_i.hours)\n batch.target_time = (Time.now + facility.tat.to_i.hours)\n batch.date = Date.today if batch.date.blank?\n batch.bank_deposit_date = Date.today if batch.bank_deposit_date.blank?\n batch.correspondence = true if type == 'CORRESP'\n return batch\n end", "def update_batch batch\n batch.file_name = @zip_file_name\n batch.arrival_time = Time.now\n batch.facility_id = facility.id\n batch.client_id = facility.client_id\n batch.contracted_time = (Time.now + facility.tat.to_i.hours)\n batch.target_time = (Time.now + facility.tat.to_i.hours)\n batch.date = Date.today if batch.date.blank?\n batch.bank_deposit_date = Date.today if batch.bank_deposit_date.blank?\n batch.correspondence = true if type == 'CORRESP'\n return batch\n end", "def update_batch batch\n batch.file_name = @zip_file_name\n batch.arrival_time = Time.now\n batch.facility_id = facility.id\n batch.client_id = facility.client_id\n batch.contracted_time = (Time.now + facility.tat.to_i.hours)\n batch.target_time = (Time.now + facility.tat.to_i.hours)\n batch.date = Date.today if batch.date.blank?\n batch.bank_deposit_date = Date.today if batch.bank_deposit_date.blank?\n batch.correspondence = true if type == 'CORRESP'\n return batch\n end", "def update_symbol_data days=365, to_date=Date.today\n @symbols.each_key do |s|\n DataSource.update @symbols[s], days, to_date\n end\n end", "def populateDatabase\n self.getWeatherData()\n @temps = []\n # Super hacky and kind of a bad practice but its the best I could come up with for the time being\n temps_from_db = Temp.last(1152)\n temps_from_db.each do |record|\n if record.id % 47 == 0\n @temps << record\n end\n end\n render json: @temps\n end", "def save_city_weather(api_weather_data, city)\n city_weather_params = {\n :city_id => city.id,\n :temperature => api_weather_data['main']['temp'],\n :temperature_minimum => api_weather_data['main']['temp_min'],\n :temperature_maximum => api_weather_data['main']['temp_max'],\n :pressure_sea_level_default => api_weather_data['main']['pressure'],\n :pressure_seal_level => api_weather_data['main']['sea_level'],\n :pressure_ground_level => api_weather_data['main']['grnd_level'],\n :humidity => api_weather_data['main']['humidity'],\n :cloudiness_percentage => api_weather_data['clouds']['all'],\n :wind_speed => api_weather_data['wind']['speed'],\n :wind_degree => api_weather_data['wind']['deg'],\n :time_of_data_forecasted => api_weather_data['dt_txt'],\n }\n\n if !api_weather_data['snow'].nil? and api_weather_data['snow']['3h'].nil?\n city_weather_params[:snow_volume] = api_weather_data['snow']['3h'];\n end\n\n if !api_weather_data['rain'].nil? and !api_weather_data['rain']['3h']\n city_weather_params[:rain_volume] = api_weather_data['rain']['3h'];\n end\n\n city_weather = CityWeather.new(city_weather_params)\n\n unless city_weather.save\n #proabably duplicate entry\n else\n @saved_weather_rows += 1\n api_weather_data['weather'].each do |weather_condition_data|\n save_city_weather_conditions(weather_condition_data, city_weather)\n end\n\n end\n end", "def set_temperature\n if current_user.present?\n geocode = current_user.geocode\n if geocode.present?\n lat = geocode.first\n long = geocode.last\n else\n lat = DEFAULT_LAT\n long = DEFAULT_LONG\n end\n\n\n\n url = \"https://api.forecast.io/forecast/#{FORECAST_KEY}/#{long},#{lat}\"\n results = JSON.parse(open(url).read)\n @temperature = results['currently']['temperature']\n @summary = results['currently']['summary']\n end\nend", "def update_location\n # Get all empty records\n to_update = Restaurant.where(longitude: [false, nil, 1.0])\n # Update each\n to_update.each do |restaurant|\n restaurant.address\n long_lat = Location.long_lat(restaurant.address)\n Restaurant.where({id: restaurant.id}).update_all({longitude: long_lat[:longitude], latitude: long_lat[:latitude]})\n end\n end", "def refresh()\n @knights = Knight.all\n @events = Event.all\n @kingdoms = Kingdom.all\n run_results()\n end", "def weather_hourly(city, state)\n request = \"http://api.wunderground.com/api/747e267558954ba9/hourly/q/#{state}/#{city}.json\"\n hourly = HTTParty.get(request)\n hourly[\"hourly_forecast\"].each do |hour| \n puts \"#{hour[\"FCTTIME\"][\"civil\"]}: #{hour[\"temp\"][\"english\"]}F\"\n end\nend", "def update\n weather_validator = WeatherValidator.init_with(params)\n return render_400(weather_validator) if weather_validator.invalid?\n return render_400(weather_validator) unless (@weather = weather_validator.update)\n\n render_200(@weather)\n end", "def getWeatherData\n @tempModel = Temp\n current_date = Date.today.strftime \"%Y-%m-%d\"\n \n response = RestClient.get(\"http://api.worldweatheronline.com/premium/v1/past-weather.ashx?key=#{ENV['WEATHER_API_KEY']}&q=30.404251,-97.849442&date=2020-06-05&enddate=#{current_date}&format=json\n \", headers={})\n jsonified_response = JSON.parse(response)\n \n # API response is parsed and inserted into DB by the model method postWeatherData\n @tempModel.postWeatherData(jsonified_response);\n puts current_date\n end", "def batch_update_next_airdate!\n Show.active?.where('next_airdate < ? OR next_airdate IS NULL', DateTime.now).each{ |show| show.update_inactive_data!}\n end", "def set_dji_forecast\n @dji_forecast = DjiForecast.find(params[:id])\n end", "def update_world\n update_fish\n update_eggs\n update_food\n update_bubbles\n end", "def refresh\n Feed.update_all\n # @feeds = Feed.all\n # feed_array = []\n # @feeds.each do |f|\n # EntryFeed.create_from_feed(f)\n # end\n\n redirect_to blogs_path\n flash[:notice] = \"Blogs successfully updated\"\n end", "def request_weather\n unless @theButton\n add_the_button\n end\n # Use our Geocoder to get lat lon\n get_location_info(@input_field.text)\n\n # Our request url, you are going to need a forcase IO api key,\n url_string = \"https://api.forecast.io/forecast/#{ENV['FORCAST_IO_TOKEN']}/#{@lat},#{@lon}\"\n\n # Send the request and encode it for us `app/lib/url_request.rb`\n url_response = UrlRequest.send_request(url_string)\n\n # Decode the request and parse it as JSON `app/lib/json_parser.rb`\n json_data = JsonParser.decode(url_response)\n\n # Now you can use the JSON!\n load_weather(json_data)\n end", "def set_forecast\n @forecast = Forecast.find(params[:id])\n end", "def set_forecast\n @forecast = Forecast.find(params[:id])\n end", "def update\n respond_to do |format|\n if @forecast.update(forecast_params)\n format.html { redirect_to @forecast, notice: 'Forecast was successfully updated.' }\n format.json { render :show, status: :ok, location: @forecast }\n else\n format.html { render :edit }\n format.json { render json: @forecast.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(prices)\n data = prices.map do |station|\n {\n series: 'diesel',\n values: { value: cents_10x(station) },\n tags: {\n station: station.id,\n # TODO: Fetch station details that are not part of the price response\n # brand: station[:brand],\n # street: station[:street],\n # place: station[:place]\n }\n }\n end\n\n @influxdb_client.write_points(data)\n end", "def update\n update_flow\n update_sprites\n update_weather\n update_timer\n update_viewports\n @brightness -= 15 if @brightness > 0\n end", "def update_metric_values!\n puts \"Updating metric values...\"\n update_daily_happiness_distributions!\n update_weekly_happiness_distributions!\n update_monthly_happiness_distributions!\n update_annual_happiness_distributions!\n update_average_happiness_distributions!\n update_averages_for_metrics!\n puts \"Done updating metric values.\"\n end", "def index\n @weather_station = WeatherStation.find(params[:weather_station_id])\n @meteo_data = []\n @meteo_data = @weather_station.meteo_datums.order('created_at desc').limit(100) unless @weather_station.blank?\n\n render 'api/v1/meteo_data/index', params: [@weather_station, @meteo_data]\n end", "def update_batch bat\r\n bat.file_name = @zip_file_name\r\n bat.arrival_time = Time.now\r\n bat.facility_id = facility.id\r\n bat.client_id = facility.client_id\r\n bat.contracted_time = (Time.now + facility.tat.to_i.hours)\r\n bat.target_time = (Time.now + facility.tat.to_i.hours)\r\n bat.date = Date.today if bat.date.blank?\r\n bat.bank_deposit_date = Date.today if bat.bank_deposit_date.blank?\r\n bat.correspondence = true if type == 'CORRESP'\r\n return bat\r\n end", "def update_daily_happiness_distributions! \n HappinessEntry.dates.each do |date|\n uid = uid_for_day(date)\n entries_for_date = HappinessEntry.on_date(date)\n update_happiness_distribution! uid, :day, entries_for_date \n end\n end", "def update\n respond_to do |format|\n if @forecast_72.update(forecast_72_params)\n format.html { redirect_to @forecast_72, notice: 'Forecast 72 was successfully updated.' }\n format.json { render :show, status: :ok, location: @forecast_72 }\n else\n format.html { render :edit }\n format.json { render json: @forecast_72.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(env=:all)\n []\n end", "def set_weather_datum\n render json: WeatherDatum.find(params[:id])\n end", "def update_podcast_feeds()\n @ole.UpdatePodcastFeeds()\n end", "def updateStats\n \n totalDays = 0\n\n @week.days.each do |day|\n if day.wr\n totalDays += 1\n updateTempValues(day.oTotal, day.dTotal)\n end\n end\n\n assignStats(totalDays)\n\n end", "def update_station_list\n log('This script overwrites your local copy of config/stations.yml with the latest data from nationalrail.co.uk and '\\\n 'railwaycodes.org.uk')\n log('Press [ENTER] to continue or [Ctrl+c] to quit')\n gets\n # Fetch data from the web\n stations = fetch_stations\n locations = fetch_locations\n # Add location data to the current active station list\n stations.each { |crs, data| data.merge!(locations[crs]) if locations[crs] }\n write_yaml(stations)\n log('Your station list has been updated')\nend", "def update_all!(&block)\n self.local_entities_list.each do |entity|\n yield(:update_start, entity) if (block_given?)\n entity.update!(&block)\n yield(:update_finish, entity) if (block_given?)\n end\n end", "def update_weather(weather)\n weather_map = {\n 0 => \"Void\",\n 1 => \"Sun 2\",\n 2 => \"Overcast\",\n 3 => \"Rainy\",\n 4 => \"Sandstorm\",\n 5 => \"Snowy\",\n 6 => \"Acidic\",\n 7 => \"Solar Eclipse\",\n 8 => \"Glitter\",\n 9 => \"Blooddrain\",\n 10 => \"Peanuts\",\n 11 => \"Lots of Birds\",\n 12 => \"Feedback\",\n 13 => \"Reverb\",\n 14 => \"Black Hole\",\n 17 => \"Coffee 3s\",\n 18 => \"Flooding\",\n }\n weather_s = weather_map[weather] || \"(weather)\"\n @weather_indicator.text = \"(#{weather}) #{weather_s}\"\n end", "def update_list\n current_path = '/api/v1/update'\n @conn.get(current_path)\n end", "def add_24hour_weather_from_moji_by_rest(auth,weatherfilepath)\n jsl=get_24h_moji_json_list(weatherfilepath)\n\tcity={\"province\"=>\"北京\",\"city\"=>\"北京市\",\"district\"=>\"东城区\"}\n jsl.each do |j|\n diqu=JSON.parse(j)\n diqu.each do |k,v|\n if k == \"data\" \n v.each do |dk,dv|\n\t\t if dk == \"city\"\n dv.each do |dkk,dkv|\n if dkk == \"pname\"\n city[\"city\"] = dkv\n\t\t\t\tend #if dkk == \"pname\"\n if dkk == \"name\"\n case dkv\n when \"北京市朝阳区\"\n city[\"district\"] = \"朝阳区\"\n when \"北京市通州区\"\n city[\"district\"] = \"通州区\"\n when \"密云区\"\n city[\"district\"] = \"密云县\"\n when \"延庆区\"\n city[\"district\"] = \"延庆县\"\n else\n city[\"district\"] = dkv\n end #case dkv\n puts city[\"district\"]\n end #if dkk == \"name\"\n\t\t\t end #dv.each do |dkk,dkv|\n end #if dk == \"city\"\n if dk == \"hourly\"\n dv.each do |hourk|\n puts hourk[\"date\"]+\": \"+hourk[\"hour\"]\n tianqi=get_hotcloud_info_from_moji_rest(hourk,city)\n wjson=JSON.generate(tianqi)\n add_weather_by_rest(auth,wjson)\n end #dv.each do |hourk|\n end #if dk == \"hourly\"\n end #v.each do |dk,dv|\n end #if k == \"data\" \n end #diqu.each do |k,v|\n\tend #jsl.each do |j|\n end", "def update\n @weather = Weather.find(params[:id])\n\n respond_to do |format|\n if @weather.update_attributes(params[:weather])\n format.html { redirect_to @weather, notice: 'Weather was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weather.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @weather = Weather.find(params[:id])\n\n respond_to do |format|\n if @weather.update_attributes(params[:weather])\n format.html { redirect_to @weather, notice: 'Weather was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weather.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_monthly_happiness_distributions! \n HappinessEntry.beginning_of_month_days.each do |beginning_of_month_day|\n uid = uid_for_month(beginning_of_month_day)\n end_of_month_day = beginning_of_month_day.end_of_month\n entries_for_month = HappinessEntry.in_month(beginning_of_month_day, end_of_month_day)\n update_happiness_distribution! uid, :month, entries_for_month \n end\n end", "def update\n update_all\n end", "def index\n @day_forecasts = DayForecast.where(\"forecast_datetime >= ?\", Time.current.beginning_of_day)\n @half_forecasts = HalfForecast.where(point_date: Config.last.half_forecast_point_date)\n end", "def update!(**args)\n @time_series_data = args[:time_series_data] if args.key?(:time_series_data)\n end", "def update!(**args)\n @time_series_data = args[:time_series_data] if args.key?(:time_series_data)\n end", "def fetch_history(days)\n raw = YahooFinance::get_historical_quotes_days(self.stock_id, days)\n raw.each do |r|\n rd = Rawdatum.find_or_create_by_stock_map_id_and_record_date(self.id, r[0])\n rd.open_price = r[1]\n rd.high_price = r[2]\n rd.low_price = r[3]\n rd.close_price = r[4]\n rd.volume = r[5]\n rd.adjusted_close_price = r[6]\n rd.save\n end\n end", "def get_forecast\n if(!@zipcode)\n @zipcode = \"Oakland, CA\";\n end\n options = { units: \"imperial\", APPID: ENV[\"open_weather_id\"] }\n forecast = OpenWeather::Current.city(@zipcode, options)\n latitude = forecast[\"coord\"][\"lat\"]\n longitude = forecast[\"coord\"][\"lon\"]\n # timezone = Timezone::Zone.new(latlon: [latitude, longitude])\n p latitude\n self.conditions = forecast[\"weather\"].first[\"main\"]\n self.conditions_desc = forecast[\"weather\"].first[\"description\"]\n # object lookup for cond with underscores\n self.sunset = DateTime.strptime(forecast[\"sys\"][\"sunset\"].to_s,'%s')\n self.sunrise = DateTime.strptime(forecast[\"sys\"][\"sunrise\"].to_s,'%s')\n self.date = Date.today\n self.location = forecast[\"name\"]\n self.current_temp = forecast[\"main\"][\"temp\"]\n self.low_temp = forecast[\"main\"][\"temp_max\"]\n self.high_temp = forecast[\"main\"][\"temp_min\"]\n self.humidity = forecast[\"main\"][\"humidity\"]\n end", "def update\n @forecast = Forecast.find(params[:id])\n\n respond_to do |format|\n if @forecast.update_attributes(params[:forecast])\n format.html { redirect_to @forecast, notice: 'Forecast was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @forecast.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @weather = ForecastIO.forecast(@location.latitude, @location.longitude)\n @current_weather = @weather['currently']\n @forecast = @weather['daily']['data']\n end", "def index\n @weather_records = WeatherRecord.all\n end", "def update_fluorescent_data (info, op_list)\n op_list.each do |op|\n plate = op.input(\"Plate\").item\n if info[\"n#{plate.id}\".to_sym] == 0\n plate.mark_as_deleted\n plate.save\n op.temporary[:delete] = true\n op.error :no_colonies, \"There are no fluorescent colonies for plate #{plate.id}\"\n else\n plate.associate :num_fluorescent_colonies, info[\"n#{plate.id}\".to_sym]\n end\n end\n end", "def update\n @city = City.find(params[:id])\n @city.update_attributes(params[:city])\n get_data\n end" ]
[ "0.65698314", "0.64219064", "0.61091524", "0.5979429", "0.5871049", "0.5771896", "0.5708098", "0.570155", "0.5655932", "0.5645692", "0.5630039", "0.5600645", "0.55835366", "0.5520503", "0.5468013", "0.5421823", "0.54199296", "0.5389205", "0.536105", "0.5356867", "0.53242546", "0.52966565", "0.5224281", "0.5205794", "0.51871634", "0.5162941", "0.5142798", "0.51393723", "0.5127253", "0.5119797", "0.5105342", "0.50970364", "0.50920004", "0.50920004", "0.50920004", "0.50920004", "0.50904155", "0.5084358", "0.5078297", "0.5061472", "0.5056305", "0.5052841", "0.50502056", "0.5042273", "0.5030673", "0.50202805", "0.50195944", "0.50171226", "0.50160176", "0.50118876", "0.50079703", "0.50079703", "0.50079703", "0.5001816", "0.4998766", "0.4998236", "0.49885356", "0.49877772", "0.49857575", "0.49840733", "0.4983078", "0.49770978", "0.49697644", "0.49678785", "0.49658424", "0.496124", "0.49492663", "0.49410406", "0.49410406", "0.49375185", "0.49331045", "0.49209538", "0.49152818", "0.49098268", "0.49030972", "0.4902413", "0.48868218", "0.48785195", "0.4873018", "0.4871428", "0.48567098", "0.48558918", "0.4854579", "0.4849508", "0.4840891", "0.48331589", "0.4829871", "0.4829871", "0.48212025", "0.48191273", "0.48112676", "0.48077443", "0.48077443", "0.48050848", "0.4804687", "0.4803081", "0.4800893", "0.47959387", "0.47891426", "0.4785559" ]
0.5537161
13
Retrieves a list of the URLS for each weather station given a State. Each url is then passed to the extract_station method.
def fetch_stations(state) scraper_logger.info("Fetching stations for #{state.name}") doc = Nokogiri::HTML(open(state.url)) doc.css('a').each do |s| Global::OBSERVATION_PRODUCT_CODE.each do |c| if s.attr('href').include?(c) and s.attr('href').include?(state.product_group) extract_station(s.attr('href'), state) end end end scraper_logger.info("Completed fetching stations for #{state.name}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_station(url, state)\n\n id, json_url = nil\n\n doc = Nokogiri::HTML(open(\"#{Global::BOM_BASE_URL}#{url}\"))\n doc.css('a').each do |l|\n\n if l.attr('href').include?('json')\n json_url = l.attr('href')\n id = l.attr('href').split('.')\n id = id[1]\n end\n\n end\n\n begin\n station = Station.find(id)\n scraper_logger.info(\"Updating existing station #{id}\")\n\n rescue\n station = Station.new\n station.id = id\n scraper_logger.info(\"Creating new station #{id}\")\n\n end\n\n begin\n station.state = state\n\n name = doc.css('h1').first\n station.name = name.text.gsub('Latest Weather Observations for ','')\n\n station.station_url = \"#{Global::BOM_BASE_URL}#{url}\"\n station.json_url = \"#{Global::BOM_BASE_URL}#{json_url}\"\n\n json = extract_observations(station.json_url)\n station.latitude = json['observations']['data'].first['lat']\n station.longitude = json['observations']['data'].first['lon']\n\n tz = Timezone.where(abbreviation: json['observations']['header'].first['time_zone'])\n if tz.size > 0\n station.timezone = tz.first\n station.save\n\n scraper_logger.info(\"#{station.id} - #{station.name} has been saved\")\n\n else\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due to unknown TZ (#{json['observations']['header'].first['time_zone']})\")\n\n end\n\n rescue\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due missing data in JSON file)\")\n\n end\n \n end", "def stations\n doc = request(@user, \"stations\")\n stations = []\n doc.xpath('//rss/channel/item').each do |node|\n stations << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :artwork => node.xpath('pandora:stationAlbumArtImageUrl').text.strip,\n :songSeed_song => node.xpath('pandora:seeds/pandora:songSeed/pandora:song').text.strip,\n :songSeed_artist => node.xpath('pandora:seeds/pandora:songSeed/pandora:artist').text.strip,\n :composerSeed => node.xpath('pandora:seeds/pandora:composerSeed/pandora:composer').text.strip,\n :artistSeed => node.xpath('pandora:seeds/pandora:artistSeed/pandora:artist').text.strip}\n end\n stations\n end", "def urls\n @urls ||= extract_urls('url')\n end", "def functional_urls(states)\n states.map { |state| urlify(state) }\nend", "def get_townhall_urls(url)\n page = Nokogiri::HTML(open(url))\n cities_url = page.xpath('//a[@class=\"lientxt\"]').to_a\n links = (cities_url.map {|url| url[\"href\"][1..-1]}).to_a\n #puts links\n return links\nend", "def urls\n each_url.to_set\n end", "def list_stations\n if @stations.empty?\n stations_void\n else\n stations_list\n end\n end", "def city_list(url)\n\troot = Nokogiri::HTML(open(url))\n list = root.css(\"a\").map do |link|\n\n\t\t# This makes sure that we only store actual links, then stores the text & link for each valid link in an array.\n\n if link[:href] =~ /http/ \n [link.text, link[:href]] \n end \n end\n\n\t# This cleans up the array and gets rid of nil elements\n\n\tlist = list.reject {|x| x.nil?} \n\t\t\n\t## Here we have various sections of CL that we can search in for various gigs. \n\t## If you wanted to see more software development stuff, you may search in /sof and /eng\n\t\n\t\t\n\t# list.map! {|f,l| [f, l + \"/cpg/\"]}\n\t# list.map! {|f,l| [f, l + \"/web/\"]}\n\tlist.map! {|f,l| [f, l + \"/web/\", l + \"/cpg/\"]}\t\n\t# list.map! {|f,l| [f, l + \"/web/\", l + \"/cpg/\", l + \"/eng/\", l + \"/sof/\", l + \"/sad/\"]}\n\t\nend", "def sitemap_urls\n each_sitemap_url.to_a\n end", "def get_townhall_urls\n\t\tpage = Nokogiri::HTML(open(@url_dept))\n\t\t\n\t\turls = page.xpath('//*[@class=\"lientxt\"]/@href') #/ toutes les URLs appartiennent à la classe lientxt\n\n\t\turls.each do |url| #/ pour chaque URLs récupérées, il faut leur indiquer l'url parent \"http://annuaire-des-mairies.com\"\n\t\t\turl = \"http://annuaire-des-mairies.com\" + url.text[1..-1] #/ A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\n\t\t\t@urls_town << url\t\t\n\t\tend\n\t\treturn @urls_town\n\tend", "def get_movelist_urls_sf(search_url)\n results = Nokogiri::HTML(open(MOVELIST_SEARCH_URL_SF))\n result_links = results.css('li.result > article > h1 > a')\n movelist_urls = result_links.select{ |el|\n el.text.downcase.include? \"list of moves\"\n }.map{ |el|\n el.attribute('href').value\n }\nend", "def urls\n @urls ||= all_urls(sitemap)\n end", "def get_townhall_urls(html)\n url = []\n get_townhall_city(html).each do |x|\n url << \"http://annuaire-des-mairies.com/95/#{x}.html\"\n end \n return url\n end", "def stations\r\n return @stations\r\n end", "def stations_list\n @route.get_stations_list\n end", "def get_all_stations\n url = 'radio/station'\n options = {query: {'alt': 'json', 'tier': 'aa', 'hl': 'en_US'}}\n\n make_post_request(url, options)\n end", "def get_stations(array)\n origin = array[0].scan(/\\b[a-z][\\w\\s\\/]+/i)[0].split.map(&:capitalize)*' '\n destination = array[1].scan(/\\b[a-z][\\w\\s\\/]+/i)[0].split.map(&:capitalize)*' '\n origin.sub!(/[\\/]+[A-Za-z]+/){ $&.upcase }\n destination.sub!(/([\\/])\\w+/){ $&.upcase }\n origin.sub!(/(?: *town)/i, \"town\")\n destination.sub!(/(?: *town)/i, \"town\")\n\n # TODO: search our @@routes hash for the origin and destination, kick out if either invalid\n set_routes(origin, destination)\n end", "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end", "def get_urls( search_url )\n urls = []\n result_json = parse_json( search_url )\n result_json['items'].each do |item|\n urls << item['url']\n end\n\n return urls\nend", "def url_list\n url_list = []\n tile_generator = TileGenerator.new\n tile_size_with_gutter = @tile_size + (2 * @gutter_size)\n tile_generator.generate_tiles(@zoom_level, @bbox, @tile_size, @gutter_size, @version).each do |tile_bbox|\n url = @url_format % {\n :layer_name => @layer.gsub(\":\", \"%3A\"),\n :version => @version,\n :bbox => tile_bbox.join(\",\"),\n :width => tile_size_with_gutter,\n :height => tile_size_with_gutter\n }\n url_list << url\n end\n return url_list\n end", "def basic_setup\n [\"FL\",\"IL\",\"NY\"].each do |state|\n ClosestWeightliftingGem::Scraper.scrape_state_page(state)\n end\nend", "def sitemap_index_urls\n each_sitemap_index_url.to_a\n end", "def get_stationList(uPos)\n stationList = []\n for n in @@networks\n resp = Net::HTTP.get_response(URI.parse(n)).body\n result = JSON.parse(resp)['network']['stations']\n (stationList << result).flatten!\n end\n stationList.sort! {|s1, s2| dist_user(s1, uPos) <=> dist_user(s2, uPos)}\n end", "def paths_from_urls\n urls = []\n parsed_urls.each do |url|\n path = URI(url).path.sub(/^(http(s)?(:)?(\\/)+?(:)?)?((\\/)?www.)?gov.uk/, \"\")\n urls << (path.start_with?(\"/\") ? path : \"/#{path}\")\n end\n urls.uniq\n end", "def get_townhall_urls(url)\n urls_department = []\n \n doc = Nokogiri::HTML(open(url))\n \n # Extraire le texte et mettre ça dans un hash \n \n doc.xpath(\"//a[@class=\\\"lientxt\\\"]\").each do |node|\n urls_department << { name: node.text, url: \"http://annuaire-des-mairies.com\" + node[:href][1, node[:href].size - 1]}\n end\n urls_department\n end", "def stations\n @stations ||= (exact_match? ? parse_station : parse_stations)\n end", "def urls\n info.map(&:value).select { |u| u.match %r{\\Ahttps?://} }\n end", "def stations_list\n @route.stations_list\n end", "def getRoutesFrom(station)\n routeList = @fromNodeMap[station]\n \n return routeList == nil ? [] : routeList\n end", "def stations\n [\n master_station,\n SLCStationReport.new(@fields[5..9], false),\n SLCStationReport.new(@fields[10..14], false),\n SLCStationReport.new(@fields[15..19], false),\n SLCStationReport.new(@fields[20..24], false),\n SLCStationReport.new(@fields[25..29], false)\n ]\n end", "def paths\n\t\tresponse = self.server.run_with_json_template( :paths )\n\t\treturn response.each_with_object({}) do |entry, hash|\n\t\t\thash[ entry[:name].to_sym ] = URI( entry[:url] )\n\t\tend\n\tend", "def get_station_names\n\n\t\t# Typhoeus is used to submit http requests\n\n\t\t response = Typhoeus.get(\"http://api.bart.gov/api/stn.aspx?cmd=stns&key=ZZLI-UU93-IMPQ-DT35\")\n\n\t\t # Extract the station names and short names\n\n\t\t response_XML = Nokogiri.XML(response.body)\n\n\t\t @station_names = {}\n\n\t\t # Create a hash list of the station names and abbreviations\n\t\t # node provides the full name of the station and next node is \n\t\t # the abbreviation\n\n\t\t response_XML.xpath(\"//stations/station/name\").each do |node|\n\t\t \t\t@station_names[node.text] = node.next.text\n\t\t end\n\n\t\t return @station_names\n\n\tend", "def urls_of_val_doise_townhalls\n\turl_parent = \"http://annuaire-des-mairies.com/\" # The parent page url which list the town hall pages url\n\tpage = Nokogiri::HTML(open(url_parent+\"/val-d-oise.html\")) # url from the page and the specific town link\n\turls_array = page.xpath('//a[@class = \"lientxt\"]').map { |node| url_parent + node.attributes[\"href\"].value[1..-1] }\n\treturn urls_array # urls sheet\nend", "def get_urls()\n generate_thread(@@source_url)\n end", "def get_townhall_urls\n city = []\n town.xpath('//p/a').each do |node|\n city << node.text.downcase #l'array city, est l'ensemble des villes du 95\n end\n array_url = city\n final = []\n array_url.each do |town|\n return array_url2 = Nokogiri::HTML(URI.open(\"http://annuaire-des-mairies.com/95/#{town.gsub(\" \", \"-\" )}.html\"))\n end\nend", "def list_stations\n @stations.each_with_index { |station, i| puts \"#{i + 1} #{station.name}\" }\n end", "def resort_scraper\nstates = [\"CO\", \"CA\", \"WY\", \"ID\", \"MT\", \"NY\", \"UT\", \"VT\", \"WA\"]\n states.map do |state|\n url = \"https://opensnow.com/state/#{state}#forecasts\"\n unparsed_page = HTTParty.get(url)\n parsed_page = Nokogiri::HTML(unparsed_page)\n resorts_array = Array.new\n all_resorts = parsed_page.css('div.compare-item')\n all_resorts.each do |resort|\n resort = {\n state_id: states.index(state) + 1, \n name: resort.css('div.title-location').text\n }\n resorts_array << resort\n end \n resorts_array.each do |resort|\n Resort.create(resort)\n puts \"creating #{resort[:name]}\" \n end \n end\nend", "def get_urls(search_results)\n # A Google search_result looks like:\n # <a href=\"/url?q=https://www.scienceexchange.com/\">Science Exchange<b>...</b></a>\n # To get the actual page URL, use the 'href' and get the query param 'q' term.\n urls = []\n search_results.each do |result|\n url = result['href']\n query = URI.parse(url).query\n result_url = CGI.parse(query)['q'].first\n result_url = url if result_url.nil?\n urls << result_url\n end\n return urls\n end", "def get_urls(page)\n doc = Nokogiri::XML(open_url(page))\n urls = []\n\n doc.search('nodes > node').each do |node|\n url = nil\n node.search('URL').each do |t|\n url = t.inner_text\n end\n if url\n urls << url\n end\n end\n\n urls\n end", "def get_townhall_urls\n page = Nokogiri::HTML(open(\"https://www.annuaire-des-mairies.com/val-d-oise.html\"))\n town_url_list = []\n url_root = \"https://annuaire-des-mairies.com\"\n page.xpath('//*[@class=\"lientxt\"]/@href').each do |node|\n townhall_url = url_root + node.value.to_s.delete_prefix(\".\")\n town_url_list << townhall_url\n end \n town_url_list\nend", "def getRoutesTo(station)\n routeList = @toNodeMap[station]\n \n return routeList == nil ? [] : routeList\n end", "def weather_stations(options = {})\n if options.delete(:reload) { false } || @weather_stations.nil?\n @weather_stations = Services::WeatherStations.new(options).fetch\n end\n @weather_stations\n end", "def get_townhall_urls\n\tpage = la_page\n\turls = page.xpath('//*[@class=\"lientxt\"]/@href') #/ toutes les URLs appartiennent à la classe lientxt\n\turl_array = []\n\turls.each do |url| #/ pour chaque URLs récupérées, il faut leur indiquer l'url parent \"http://annuaire-des-mairies.com\"\n\t\turl = \"http://annuaire-des-mairies.com\" + url.text[1..-1] #/ A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\n\t\turl_array << url\n\tend\n puts url_array\n\n\treturn url_array\nend", "def perform\n get_all_the_urls_of_val_doise_townhalls\n end", "def sitelinks(params)\n response = YandexDirect::V5::Request.new(self, @token, 'sitelinks', 'get', params).perform\n @available_units = response[:available_units]\n response[:result]\n end", "def city_scraper\n #Id,Id2,Geography,Target Geo Id,Target Geo Id2,Geographical Area,Geographical Area,,,Total area,Water area,Land area,Population,Housing units\n #0400000US01,01,Alabama,1600000US0107000,0107000,\"Alabama - PLACE - Birmingham city, Alabama\",\"Birmingham city, Alabama\",242820,111927,151.95,2.04,149.92,1619.7,746.6\n # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 \n @states = Array.new\n @cities = Array.new\n \n count = 0\n state_name = \"\"\n CSV.foreach(\"data/DEC_10_SF1_GCTPH1.ST13.csv\") do |row|\n count = count + 1\n city_name = \"\"\n population = 0\n elevation = 0\n lat_dir = \"\"\n lat_deg = 0\n lat_min = 0\n lat_sec = 0\n lon_dir = \"\"\n lon_deg = 0\n lon_min = 0\n lon_sec = 0\n if(row[2] == row[5])\n #its a state\n puts \"State: #{row[2]}\"\n state_name = row[2]\n state = State.new(:name => row[2])\n if(@states.length == 51)\n break\n end\n @states << state\n next\n end\n \n geographical_area = CSV.parse(row[6])\n city_name = geographical_area[0][0]\n if(city_name.match(/(part)/))\n #puts \"skipping #{city_name}\"\n next\n end\n \n city_name = city_name.downcase.gsub(/ city/,'').gsub(/ town/,'').gsub(/ village/,'').gsub(/ cdp/,'').gsub(/ borough/,'').gsub(/ municipality/,'').gsub(/ and/,'')\n city_name.strip.capitalize!\n city_name = city_name.capitalize\n #puts \"#{city_name} #{count}\"\n \n city_name_uri = URI.escape(city_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n state_name_uri = URI.escape(state_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n city_html = Net::HTTP.get(URI.parse(\"http://www.geonames.org/search.html?q=#{city_name_uri}%2C+#{state_name_uri}&country=US\"))\n #puts \"http://www.geonames.org/search.html?q=#{city_name}%2C+#{state_name}&country=US\"\n @city_doc = Hpricot(city_html)\n \n @city_doc.search(\"//table[@class='restable']\") do |table|\n tr_count = 0\n table.search(\"//tr\") do |tr|\n #puts \"in tr search\"\n tr_count = tr_count + 1\n if(tr_count < 3)\n next\n end\n #puts \"in tr search 2\"\n td_count = 0\n tr.search(\"//td\") do |td|\n #puts \"in td search\"\n td_count = td_count + 1\n if(td_count < 4)\n next\n end\n if(td_count == 4)\n td.search(\"//small\") do |small|\n #population = \"#{small.match(/\\\\d+/)[1]}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n #puts td_count\n #puts \"#{small.inner_html}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n pop_elev = small.inner_html\n #population = \"#{pop_elev.match(/\\d+,\\d*/)}\".gsub(/,/,'')\n elevation = \"#{pop_elev.match(/\\d+m/)}\".gsub(/m/,'')\n #puts population\n #puts elevation\n end\n end\n if(td_count == 5)\n lat_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lat_deg = matches[0][0]\n lat_min = matches[1][0]\n lat_sec = matches[2][0]\n end\n if(td_count == 6)\n lon_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lon_deg = matches[0][0]\n lon_min = matches[1][0]\n lon_sec = matches[2][0]\n end\n end\n break\n \n end \n end\n city = City.new(\n :name => city_name,\n :states_id => @states.length,\n :total_area => row[9],\n :water_area => row[10],\n :land_area => row[11],\n :population => row[7],\n :population_density => row[12],\n :lat_deg => lat_deg,\n :lat_min => lat_min,\n :lat_sec => lat_sec,\n :lat_dir => lat_dir,\n :lon_deg => lon_deg, \n :lon_min => lon_min,\n :lon_sec => lon_sec,\n :lon_dir => lon_dir,\n :elevation => elevation)\n \n @cities << city\n if(count % 10 == 0)\n puts count\n end\n end\n \n @states.each do |state|\n state.save\n end\n \n @cities.each do |state|\n state.save\n end\n \n end", "def get_townhall_urls(url)\n\n page = Nokogiri::HTML(URI.open(url)) \n #townhall_url = page.xpath(\"//a/@href\").map {|x| x.value}\n townhall_urls_array_incomplete = page.css('a[href].lientxt').map {|x| x[\"href\"]}\n #remove the dot at the beginning of the url\n townhall_urls_array_incomplete = townhall_urls_array_incomplete.map {|x| x[2..]}\n townhall_urls_array = townhall_urls_array_incomplete.map {|x| \"http://annuaire-des-mairies.com/\" + x}\n return townhall_urls_array\n\nend", "def download_sites_urls(response)\n return [] if !response.is_a?(Hash) ||\n (sites_urls = response.dig('receipt', 'sites_urls')).nil?\n sites_urls.map do |url|\n Infosimples::Data::HTTP.request(url: url, http_timeout: 30)\n end\n end", "def load_station_data\n data = Net::HTTP.get(URI.parse(stations_url))\n JSON.parse(data)[\"result\"]\n end", "def urls(crawled: nil, limit: 0, skip: 0)\n query = crawled.nil? ? {} : { crawled: crawled }\n sort = { date_added: 1 }\n\n results = retrieve(URLS_COLLECTION, query,\n sort: sort, limit: limit, skip: skip)\n return [] if results.count < 1 # results#empty? doesn't exist.\n\n # results.respond_to? :map! is false so we use map and overwrite the var.\n results = results.map { |url_doc| Wgit::Url.new(url_doc) }\n results.each { |url| yield(url) } if block_given?\n\n results\n end", "def get_townhall_urls(townhall_list)\n page = Nokogiri::HTML(URI.open(townhall_list))\n annuaire = []\n page.xpath('//a[@class=\"lientxt\"]/@href').each do |link|\n annuaire << link.text\n end\n annuaire.map!{ |x| [\"https://www.annuaire-des-mairies.com\", x.reverse.chop.reverse].join}\n return annuaire\nend", "def get_all_the_urls_of_val_doise_townhalls()\n urls_town = []\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n doc.css('a.lientxt').each do |x|\n lien_page_mairie = x['href']\n lien_page_mairie.slice!(0)\n lien_page_mairie = \"http://annuaire-des-mairies.com\" + lien_page_mairie\n urls_town.push(lien_page_mairie)\n end\n return urls_town\nend", "def fetch_observations(station)\n\n scraper_logger.info(\"Fetching latest weather observations for #{station.id} - #{station.name}\")\n\n new = 0\n\n json = extract_observations(station.json_url)\n json['observations']['data'].each do |o|\n\n Time.zone = 'UTC'\n recording_time = Time.zone.parse(\"#{o['aifstime_utc']}Z\")\n\n unless Observation.already_exists?(station, recording_time)\n observation = Observation.new\n observation.station = station\n observation.recording_time = recording_time\n observation.save\n\n parse_readings(o, observation)\n\n new += 1\n\n end\n\n end\n\n scraper_logger.info(\"Added #{new} new observations\")\n\n end", "def urls\n @sets.collect(&:keys).flatten\n end", "def regional_sitelist\n query('txt/wxfcs/regionalforecast/json/sitelist')\n end", "def urls\n @@urls\n end", "def weather_hourly(city, state)\n request = \"http://api.wunderground.com/api/747e267558954ba9/hourly/q/#{state}/#{city}.json\"\n hourly = HTTParty.get(request)\n hourly[\"hourly_forecast\"].each do |hour| \n puts \"#{hour[\"FCTTIME\"][\"civil\"]}: #{hour[\"temp\"][\"english\"]}F\"\n end\nend", "def get_all_the_urls_of_val_doise_townhalls(url)\n page = Nokogiri::HTML(open(url))\n urls = []\n source = \"http://annuaire-des-mairies.com/\"\n news_links = page.css(\"a\").select{|link| link['class'] == \"lientxt\"}\n news_links.each do |link|\n lien = link['href']\n nv_link = lien.byteslice(2,lien.length)\n nv_link = source + nv_link\n urls << nv_link\n end\n return urls\nend", "def get_townhall_urls\r\n\r\n # Scrapping de toutes les URLs\r\n page = Nokogiri::HTML(URI.open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\r\n\turls = page.xpath('//*[@class=\"lientxt\"]/@href') # toutes les URLs appartiennent à la classe lientxt\r\n\r\n #stockage des URLs scrappées dans une array\r\n\turl_array = []\r\n urls.each do |url| # pour chaque URLs récupérées, il faut leur indiquer l'url parent \"http://annuaire-des-mairies.com\"\r\n\t\turl = \"http://annuaire-des-mairies.com\" + url.text[1..-1] # A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\r\n\t\turl_array << url\r\n end\r\n\r\n puts \" ⏳ URLs scrapping in process...3️, 2️, 1️\" \r\n sleep 3\r\n puts \"⭐⭐⭐ BINGOOOOOO ⭐⭐⭐\" #https://emojipedia.org/\r\n sleep 1\r\n return url_array \r\nend", "def to_urls!\n map! { |element| process_url_element(element) }\n end", "def all_urls\n urls = NG_URL.all.collect {|n| n.url}\n urls.sort!\n end", "def all_URLs(group)\n urls = Hash.new()\n each_normal_group_record(group) do |item|\n if item.URL == '' then next end # Only interested in items that has an URL\n key = item.URL.to_s # To avoid using NSStrings (not that it really matters)\n @unify_url_log.debug \"<#{key}> url of '#{item.name}' \"\n if urls.has_key?(key) then\n urls[key] << item.get\n else\n urls[key] = [item.get]\n end\n end\n return urls # hash with URL - number of this URL\n end", "def urls(crawled: nil, limit: 0, skip: 0)\n query = crawled.nil? ? {} : { crawled: crawled }\n sort = { date_added: 1 }\n\n results = retrieve(:urls, query,\n sort: sort, projection: {},\n limit: limit, skip: skip)\n return [] if results.count < 1 # results#empty? doesn't exist.\n\n # results.respond_to? :map! is false so we use map and overwrite the var.\n results = results.map { |url_doc| Wgit::Url.new(url_doc) }\n results.each { |url| yield(url) } if block_given?\n\n results\n end", "def get_townhall_urls\n\tpage = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n\turl_array = []\n\n\turls = page.xpath('//*[@class=\"lientxt\"]/@href') \n\n urls.each do |url| \n# ->Pour chaque URL récupérée : indiquer l'url parent \"http://annuaire-des-mairies.com\"\n url = \"http://annuaire-des-mairies.com\" + url.text[1..-1] \n#->A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\n\t\turl_array << url\t\t\n\tend\n\treturn url_array \nend", "def getLocations\n # create locations table\n locations = Array.new\n \n # turn page into Nokogiri object\n parsed_page = Nokogiri::HTML(@page)\n\n # get table of drop info from page\n locations = parsed_page.css(\"#mw-content-text\").css(\"ul\").css(\"li\").css(\"a\").children.map { |r| r.text }\n\n # prints table for debugging\n# puts(\"table = #{locations}\")\n\n # save locations globally\n @locations = locations\n end", "def list\n extract_names_and_urls = lambda do |doc|\n [extact_url(@url, document), extract_titles(document)]\n end\n \n html.css('a').map(&extract_names_and_urls)\n end", "def get_all_the_urls_of_val_doise_townhalls(page_url)\n doc = Nokogiri::HTML(open(page_url))\n urls = []\n#on recupere le css a[class=lientxt]\n get_urls = doc.css(\"a[class=lientxt]\")\n get_urls.each{|link| urls.push(\"http://annuaire-des-mairies.com\"+link['href'][1...link['href'].length])}\n urls\nend", "def get_folders\n doc = Nokogiri::HTML(open(url))\n doc.xpath(\"//@href\").map do |url|\n url.value\n end\n end", "def sites_of_a_type(type, url, site_list)\n get_geo_info(url)['results'].map do |site|\n site_info = {}\n site_info['location'] = site['geometry']['location']\n site_info['types'] = type\n site_info['name'] = site['name']\n site_info['address'] = site['vicinity']\n site_list << site_info\n end\n site_list\n end", "def sitemaps\n @sitemaps ||= extract_urls('sitemap')\n end", "def observations(stations, lang = 'is', time = '1h', anytime = '0')\n Apis.client.get(\"/weather/forecasts/#{lang}\" \\\n \"/?stations=#{stations.join(',')}&time=#{time}&anytime=#{anytime}\")\n end", "def sitelinks(params, additional_headers = {})\n perform_request(self, @token, 'sitelinks', 'get', params, additional_headers)\n end", "def get_townhall_urls(url)\n urls_department = []\n\n doc = Nokogiri::HTML(open(url))\n\n# Extraire le texte et mettre ça dans un hash \n\n doc.xpath(\"//a[@class=\\\"lientxt\\\"]\").each do |node|\n urls_department << { name: node.text, url: \"http://annuaire-des-mairies.com\" + node[:href][1, node[:href].size - 1]}\n end\n\n urls_department\nend", "def urls\n keys\n end", "def all_site_details\r\n @nsc.sites\r\n end", "def list_stations\n Station.all.collect{|obj| obj.name}.sort\n end", "def index\n @station_infos = StationInfo.all\n end", "def get_all_new_urls(results)\n all_urls = results.map { |result| result.absolute_linked_resources }.flatten\n all_urls.uniq!\n #TODO: handle any other url parsing error\n all_urls.delete_if { |url| !a_domain_we_care_about?(url)}\n all_urls.delete_if { |url| i_have_seen_this_url_before?(url)}\n end", "def all\n @all ||= raw.map { |link| URL.absolutify(link, base_url) }.compact.uniq\n end", "def get_city_list\r\n url = \r\n page = Nokogiri::HTML(URI.open('http://annuaire-des-mairies.com/val-d-oise.html'))\r\n citys = page.css('a.lientxt[href]').each {|city| @citys_list << city.text.downcase.gsub(' ', '-')}\r\nend", "def stream_urls\n @stream_urls ||= begin\n return {} unless presenter.solr_document['derivatives_metadata_ssi'].present?\n files_metadata = JSON.parse(presenter.solr_document['derivatives_metadata_ssi'])\n file_locations = files_metadata.select { |f| f['file_location_uri'].present? }\n return {} unless file_locations.present?\n streams = {}\n file_locations.each do |f|\n streams[f['label']] = Hyrax::IiifAv.config.iiif_av_url_builder.call(\n f['file_location_uri'],\n request.base_url\n )\n end\n streams\n end\n end", "def get_hrefs\n # this will grab all the html from the url that\n # the user created the scraper with\n url_to_scrape = HTTParty.get(self.url)\n # nokogiri turns everything from HTTParty into nodes.\n nodes = Nokogiri::HTML(url_to_scrape)\n nodes.css('a').each do |a|\n self.hrefs << a['href']\n end\n self.hrefs\n end", "def scrape_page_for_zip_hrefs(url)\n doc = Nokogiri::HTML(open(url))\n array_of_href = []\n doc.css('td a').each do |link|\n array_of_href << url+link['href'] if link['href'].include? \"zip\"\n end\n array_of_href\nend", "def contract_urls\n Scrapers::ContractUrlExtractor.new(report.url).urls\n end", "def get_upstream_stations(origin_station)\n\t\t\n\t\tstarting_station = Bartstation.where(\"short_name = '#{origin_station}'\").pluck(\"id\")[0]\n\t\t\n\t\t# Find all the instances of the starting station\n\t\t# The station may appear on multiple routes\n\t\t\n\t\tstation_routes = {}\n\t\t\n\t\tBartroutestation.where(\"bartstation_id = #{starting_station}\").each do |routestation|\n\t\t\t\tstation_routes[routestation.bartroute_id] = routestation.route_station_sequence\n\t\tend\n\n\t\t# For each route that has the starting station:\n\t\t# Find the starting station \n\t\t# Find the next 5 stations in the reverse direction\n\t\t# (The stations are sequenced in the database to increment from the east \n\t\t# bay direction)\n\n\t\tupstream_stations = {}\n\t\tstation_routes.each do |station_route,station_sequence|\n\t\t\tbartroute_id = station_route\n\t\t\tbartstation_sequence = station_sequence\t\t\t\n\t\t\tupstream_stations[bartroute_id] = \n\t\t\t\tBartroutestation.where(\"bartroute_id = #{bartroute_id} AND \n\t\t\t\t\troute_station_sequence >= #{bartstation_sequence}\").order('route_station_sequence').take(6)\n\t\tend\n\n\t\t# Return the list of upstream stations for each route from the origin station\n\n\t\treturn upstream_stations\n\n\tend", "def yahoo_weather_query(loc_ids, units)\n weather = []\n loc_ids.each do |l|\n h = {}\n open(\"http://xml.weather.yahoo.com/forecastrss?p=#{l}&u=#{units}\") do |http|\n response = http.read\n doc = REXML::Document.new(response)\n channel = doc.root.elements['channel']\n title = channel.elements['title'].text\n if title !~ /Error/ then\n location = channel.elements['yweather:location']\n h[:city] = location.attributes[\"city\"]\n h[:region] = location.attributes[\"region\"]\n h[:country] = location.attributes[\"country\"]\n h[:temp] = channel.elements[\"item\"].elements[\"yweather:condition\"].attributes[\"temp\"]\n weather << h\n end\n end\n end\n weather\nend", "def fetch\n @routes = []\n source_extractors.keys.each do |source|\n extract_routes(source, data_for_source(source))\n end\n end", "def index\n @stations = Station.all\n end", "def get_cities\n cities = {}\n doc = nil\n retry_if_exception do\n doc = Nokogiri::HTML( easy_curl(@host_url) )\n end\n return [] if not doc\n a_cities = doc.css(\"ul[class='s-dropdown afh-dd-city'] li a\")\n a_cities.each do |city|\n city_name = city.text\n city_code = city['href'].scan(/\\w+(?=\\/changecity)/).pop\n next if not city_code\n cities[city_code] = city_name\n end\n cities\nend", "def get_urls\n\n url_array = []\n top_five = 0\n\n while top_five < 5\n url_array << @news_instance[\"response\"][\"docs\"][top_five][\"web_url\"]\n top_five += 1\n end\n\n # returns the array\n return url_array\n\n end", "def image_url_list\n list = []\n images.each do |image|\n list << image.url \n end\n list\n end", "def get_redirection_urls\n\t\tputs \"getter to retrieve all the redirection URLs from the site store.\" if @verbose\n\t\turls=Array.new\n\t\t@known_sites.keys.map do |key|\n\t\t\tunless @known_sites[key]['redirection'].nil?\n\t\t\t\turls.push(@known_sites[key]['redirection'])\n\t\t\tend\n\t\tend\n\t\turls.sort!\n\t\treturn urls\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\treturn nil\n\tend", "def get_listing_URLs_from_search_html(search_html)\r\n raise NotImplementedError\r\n end", "def list_sites\n r = execute(make_xml('SiteListingRequest'))\n arr = []\n if r.success\n r.res.elements.each('SiteListingResponse/SiteSummary') do |site|\n arr << SiteSummary.new(site.attributes['id'].to_i,\n site.attributes['name'],\n site.attributes['description'],\n site.attributes['riskfactor'].to_f,\n site.attributes['riskscore'].to_f)\n end\n end\n arr\n end", "def get_all_the_urls_townhalls\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/bouches-du-rhone.html\"))\n urlend = []\n tabname = []\n doc.css('.lientxt').each do |i| tabname << i.content end\n doc.css('a.lientxt @href').each do |i| urlend << i.content end\n i = 0\n while i < urlend.size\n urlend[i][0] = ''\n urlend[i] = get_the_email_of_a_townhal_from_its_webpage(\"http://annuaire-des-mairies.com#{urlend[i]}\")\n i += 1\n end\n return myhash = Hash[tabname.zip(urlend)]\n end", "def list_cities\n list_galleries.map do |gallery|\n gallery.city\n end\n end", "def iterate_through_json(state) #should be called: make all breweries in a state\n (1..number_of_json_pages(state)).collect do |number|\n load_db_json(\"locations?region=#{state}&key=#{@key}&p=#{number}\")[\"data\"].collect do |hash|\n hash[\"id\"] # eventually Brewery.build(:name => hash[\"brewery\"][\"name\"], :state_id => :state_id)\n end\n end.flatten\n end", "def cities\n galleries.map {|g| g.city}\n end", "def visited_spots_urls(user_id=self.username)\n connection.get(\"/users/#{user_id}/visited_spots_urls\").body.urls\n end" ]
[ "0.6223554", "0.5820403", "0.57375234", "0.56964236", "0.56822276", "0.56321967", "0.5613308", "0.5611582", "0.56078744", "0.5523439", "0.5521253", "0.55070436", "0.5458414", "0.5438868", "0.5430657", "0.53995764", "0.5375218", "0.5367982", "0.5304522", "0.5283608", "0.5260278", "0.5240604", "0.5238195", "0.5235799", "0.5217479", "0.52147514", "0.5190267", "0.5183219", "0.51805514", "0.51738864", "0.516301", "0.5146412", "0.51395947", "0.5134804", "0.51321685", "0.5128414", "0.51249146", "0.5121378", "0.51068664", "0.51047796", "0.50935996", "0.50858814", "0.5085535", "0.5074524", "0.5046366", "0.5045254", "0.502916", "0.50240886", "0.5006645", "0.5004311", "0.4980577", "0.49790445", "0.49748394", "0.49596342", "0.49547687", "0.49497223", "0.49437493", "0.49199754", "0.4910002", "0.49009085", "0.489533", "0.48883158", "0.4883237", "0.4881545", "0.48708963", "0.48443848", "0.48433882", "0.4832392", "0.48272225", "0.48268318", "0.4811906", "0.47987035", "0.47965124", "0.47755978", "0.47662553", "0.47464478", "0.47458673", "0.4740153", "0.47347298", "0.47346333", "0.4725821", "0.47220382", "0.47076076", "0.47072124", "0.47061294", "0.47046578", "0.4694593", "0.46904063", "0.46880716", "0.46854147", "0.46843785", "0.4676342", "0.46745333", "0.46581763", "0.4648341", "0.4641485", "0.46412584", "0.46371505", "0.4630833", "0.4626182" ]
0.73837906
0
Creates a new, or updates an existing, Station given it's URL and the State to which it belongs.
def extract_station(url, state) id, json_url = nil doc = Nokogiri::HTML(open("#{Global::BOM_BASE_URL}#{url}")) doc.css('a').each do |l| if l.attr('href').include?('json') json_url = l.attr('href') id = l.attr('href').split('.') id = id[1] end end begin station = Station.find(id) scraper_logger.info("Updating existing station #{id}") rescue station = Station.new station.id = id scraper_logger.info("Creating new station #{id}") end begin station.state = state name = doc.css('h1').first station.name = name.text.gsub('Latest Weather Observations for ','') station.station_url = "#{Global::BOM_BASE_URL}#{url}" station.json_url = "#{Global::BOM_BASE_URL}#{json_url}" json = extract_observations(station.json_url) station.latitude = json['observations']['data'].first['lat'] station.longitude = json['observations']['data'].first['lon'] tz = Timezone.where(abbreviation: json['observations']['header'].first['time_zone']) if tz.size > 0 station.timezone = tz.first station.save scraper_logger.info("#{station.id} - #{station.name} has been saved") else scraper_logger.warn("#{station.id} - #{station.name} could not be saved due to unknown TZ (#{json['observations']['header'].first['time_zone']})") end rescue scraper_logger.warn("#{station.id} - #{station.name} could not be saved due missing data in JSON file)") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @station = Station.new(station_params)\n\n if @station.save\n render json: @station, status: :created, location: @station\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def create_station!(name)\n station = Station.new(name)\n @stations[name.to_sym] = station\n station_created(station.name)\n end", "def create\n @station = Station.new(params[:station])\n\n respond_to do |format|\n if @station.save\n format.html { redirect_to @station, notice: 'Station was successfully created.' }\n format.json { render json: @station, status: :created, location: @station }\n else\n format.html { render action: \"new\" }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @station = Station.new(params[:station])\n\n respond_to do |format|\n if @station.save\n format.html { redirect_to @station, notice: 'Station was successfully created.' }\n format.json { render json: @station, status: :created, location: @station }\n else\n format.html { render action: \"new\" }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @station = Station.new(params[:station])\n\n respond_to do |format|\n if @station.save\n format.html { redirect_to(@station, :notice => 'Station was successfully created.') }\n format.xml { render :xml => @station, :status => :created, :location => @station }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @station.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.create_update_with(url_params)\n @short_url = \"#{request.host_with_port}/#{@url.short_url}\"\n redirect_to root_path(short_url: @short_url)\n end", "def create\n @station = Station.new(station_params)\n\n respond_to do |format|\n if @station.save\n format.html { redirect_to @station, notice: 'Station was successfully created.' }\n format.json { render action: 'show', status: :created, location: @station }\n else\n format.html { render action: 'new' }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_station\n request = ['Enter station name: ']\n getting(request, :approve_station, :create_station!)\n end", "def update\n @station = Station.find(params[:id])\n\n if @station.update(station_params)\n head :no_content\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def create\n @station = Station.new(station_params)\n\n respond_to do |format|\n if @station.save\n format.html { redirect_to @station, notice: 'Станция создана.' }\n format.json { render :show, status: :created, location: @station }\n else\n format.html { render :new }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def make_location(params)\n new_location = Location.create(name: params[:name], address: params[:address], city: params[:city])\n self.update(location_id: new_location.id)\n end", "def save_url\n raise MotionModelResource::URLNotDefinedError.new \"URL is not defined for #{self.class.name}!\" unless self.class.respond_to?(:url)\n\n case save_action\n when :create then self.try(:url) || self.class.url\n when :update then self.try(:url) || \"#{self.class.url}/#{id}\"\n end\n end", "def updateStation()\n uri=URI.parse(ViaggiatrenoURLs.STATION_INFO)\n response = Net::HTTP.post_form(uri,{\"stazione\" => @stationFrom, \"lang\" => \"IT\"})\n doc = Nokogiri::HTML(response.body)\n\n doc.xpath(XPathMatchInfo.XPATH_STATION).each do |x|\n \n StringUtils.remove_newlines_tabs_and_spaces(x)\n\n train_number_complete = x.xpath(XPathMatchInfo.XPATH_TRAIN_NUMBER()).to_s\n train_destination = x.xpath(XPathMatchInfo.XPATH_TRAIN_DESTINATION()).to_s\n train_schedule =x.xpath(XPathMatchInfo.XPATH_TRAIN_SCHEDULED()).to_s\n train_description = \"#{train_number_complete} #{train_destination} #{train_schedule}\"\n \n train_number=train_number_complete.match(\"[0-9]+\")[0]\n \n @trains[train_number]=train_description\n @destinations.push(train_destination)\n ### TODO #### #@trains[train_number][description]=train_description\n end\n end", "def add_station_to_route(route)\n available_stations = Station.all.reject { |item| route.stations.include?(item) }\n\n return add_station_to_route_core(available_stations, route) unless available_stations.empty?\n\n show_info_for_action('adding Station to Route')\n show_info_you_need_at_least('1 Station not assigned to Route', 0)\n\n create_station_advanced\n\n add_station_to_route(route)\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def update\n @poopstation = Poopstation.find(params[:id])\n\n respond_to do |format|\n if @poopstation.locations.create(:name => params[:location], :city => params[:city], :state => params[:state])\n format.html { redirect_to @poopstation, notice: 'Spanks!' }\n format.json { head :no_content }\n format.mobile { redirect_to @poopstation, notice: 'Spanks!' }\n else\n format.html { render action: \"edit\" }\n format.mobile { render action: \"edit\" }\n format.json { render json: @poopstation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @set_station = SetStation.new(set_station_params)\n\n respond_to do |format|\n if @set_station.save\n format.html { redirect_to set_stations_path, notice: 'Set station was successfully created.' }\n format.json { render :index, status: :created, location: @set_stations }\n else\n format.html { render :new }\n format.json { render json: @set_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @station_info = StationInfo.new(station_info_params)\n\n respond_to do |format|\n if @station_info.save\n format.html { redirect_to @station_info, notice: 'Station info was successfully created.' }\n format.json { render :show, status: :created, location: @station_info }\n else\n format.html { render :new }\n format.json { render json: @station_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def addUrl(url)\n @persist.updateDefect(@story, url)\n end", "def create\n submitted_url = url_params[:original_url]\n\n @url = Url.where(original_url: [submitted_url, \"http://#{submitted_url}\",\"http://www.#{submitted_url}\"]).first_or_initialize\n @url.assign_attributes(url_params)\n\n respond_to do |format|\n if @url.persisted?\n format.html {redirect_to @url, notice: \"We've already redirected this url. Check out the shortened url below.\"}\n format.json { render action: 'show', status: 200, location: @url }\n elsif @url.save\n format.html { redirect_to @url, notice: 'Url was successfully created.' }\n format.json { render action: 'show', status: :created, location: @url }\n else\n format.html { render action: 'new' }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def create\n @main_station = MainStation.new(main_station_params)\n\n respond_to do |format|\n if @main_station.save\n format.html { redirect_to @main_station, notice: 'Main station was successfully created.' }\n format.json { render :show, status: :created, location: @main_station }\n else\n format.html { render :new }\n format.json { render json: @main_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_network_station\n @network_station = NetworkStation.find( params[ :id ])\n end", "def add_station(station)\n @stations.insert(-2, station)\n end", "def add_station(station)\n @stations.insert(-2, station)\n end", "def create\n @station = Station.new(params[:station])\n flash[:notice] = 'Station was successfully created.' if @station.save\n respond_with(@station)\n end", "def create url\n function = ''\n \n post_data = {}\n post_data[:url] = url\n\n request(@resource, function, nil, 'post', post_data)\n end", "def create\n @service_station = ServiceStation.new(params[:service_station])\n\n respond_to do |format|\n if @service_station.save\n format.html { redirect_to @service_station, notice: 'Service station was successfully created.' }\n format.json { render json: @service_station, status: :created, location: @service_station }\n else\n format.html { render action: \"new\" }\n format.json { render json: @service_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asos_station = AsosStation.new(asos_station_params)\n\n respond_to do |format|\n if @asos_station.save\n format.html { redirect_to @asos_station, notice: 'Asos station was successfully created.' }\n format.json { render action: 'show', status: :created, location: @asos_station }\n else\n format.html { render action: 'new' }\n format.json { render json: @asos_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @state = State.new(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render json: @state, status: :created, location: @state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @state = State.new(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render json: @state, status: :created, location: @state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def link_to_station\n if @trains.empty? || @stations.empty?\n staions_or_trains_void\n else\n request = [\"Enter train number [#{@trains.keys.join(', ')}]: \"]\n train = getting(request, :approve_train_selection, :select_train)\n request = request_station\n station = getting(request, :approve_station_selection, :select_station)\n train_placed if station.arrive(train)\n end\n end", "def insert(short, url)\n raise NotImplementedError\n end", "def create\n \turl = Url.create(params[:url])\n \t\n \tredirect_to urls_path\n end", "def create\n @space_station = SpaceStation.new(space_station_params)\n\n if @space_station.save\n render json: @space_station, status: :created, location: @space_station\n else\n render json: @space_station.errors, status: :unprocessable_entity\n end\n end", "def create\n # decode url to remove duplicacy in case of same url encoded and decoded\n url = URI.decode(params[:url])\n # check if url already exists in db\n mini_url = MiniUrlHelper.check_existing_url(url, current_user)\n unless mini_url\n mini_url = MiniUrl.new\n mini_url.url = url\n # a check to handle invalid expiry time\n begin\n mini_url.expiry = DateTime.parse(params[:expiry])\n rescue ArgumentError => e\n logger.error \"Invalid expiry time.\"\n end\n mini_url.user = current_user if current_user\n # call method to generate unique code and save into db\n # raise exception in case of some error\n unless mini_url.generate_unique_code\n raise Exceptions::SavingError.new(mini_url.errors)\n end\n end\n short_url = \"#{BASE_URL}/#{mini_url.url_code}\"\n render json: {short_url: short_url}, status: 201\n rescue Exceptions::SavingError => e\n render json: {error: e}, status: 400\n end", "def create\n @railway_station = RailwayStation.new(railway_station_params)\n\n respond_to do |format|\n if @railway_station.save\n format.html { redirect_to [:admin, @railway_station], notice: I18n.t('notices.railway_station_created') }\n format.json { render :show, status: :created, location: @railway_station }\n else\n format.html { render :new }\n format.json { render json: @railway_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_state = Api::State.new(api_state_params)\n\n if @api_state.save\n render json: @api_state, status: :created, location: @api_state\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end", "def initialize( url )\n @url, @name = url, url.match( /[^\\/]*$/ ).to_s\n begin\n http_action :put, nil, :doc => ''\n create_shared_design\n rescue\n end\n end", "def create\n @gas_station = GasStation.new(params[:gas_station])\n\n respond_to do |format|\n if @gas_station.save\n format.html { redirect_to @gas_station, notice: 'Gas station was successfully created.' }\n format.json { render json: @gas_station, status: :created, location: @gas_station }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gas_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @state = State.new(state_params)\n\n if @state.save\n render json: @state, status: :created, location: @state\n # 'state was successfully created.'\n else\n render json: @state.errors, status: :unprocessable_entity\n end\n end", "def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end", "def create\n @url = Url.new(url_params)\n\n if @url.save\n redirect_to @url\n else\n render 'new'\n end\n end", "def set_station_info\n @station_info = StationInfo.find(params[:id])\n end", "def add_station_in_to_route\n if @routes.empty?\n routes_void\n else\n request = [\"Enter route name [#{@routes.keys.join(', ')}]: \"]\n route = getting(request, :approve_route_selection, :select_route)\n request = request_station\n station = getting(request, :approve_station_for_route, :select_station)\n station_added if route.add_station(station)\n end\n end", "def create\n @state = State.new(state_params)\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render action: 'show', status: :created, location: @state }\n else\n format.html { render action: 'new' }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.new(url_params)\n @url.sanitize\n @url.current_ip = request.remote_ip\n if @url.new_url?\n respond_to do |format|\n if @url.save\n format.html { redirect_to shortened_path(@url.short_url), notice: 'Url was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:notice] = \"A short link for this URL is already in our database\"\n redirect_to shortened_path(@url.find_duplicate.short_url)\n end\n \n end", "def create\n @state = State.new(state_params)\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: @state }\n else\n format.html { render :new }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.find_or_initialize_by(url_params)\n if @url.save\n redirect_to urls_path, notice: \"Url shortner is successfully created\"\n else\n render :new\n end\n end", "def add_location(city, state)\n\n location = Location.find_by(city: city, state: state)\n\n unless location\n location = Location.create!(city: city, state: state)\n end\n\n location.id\n\nend", "def create\n @state = State.new(state_params)\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: @state }\n else\n format.html { render :new }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_location(location_hash={})\n l = Location.new(location_hash)\n l.save\n end", "def create\n @polling_station = PollingStation.new(params[:polling_station])\n\n respond_to do |format|\n if @polling_station.save\n flash[:notice] = 'PollingStation was successfully created.'\n format.html { redirect_to(@polling_station) }\n format.xml { render :xml => @polling_station, :status => :created, :location => @polling_station }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @polling_station.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @police_station = PoliceStation.new(police_station_params)\n\n respond_to do |format|\n if @police_station.save\n format.html { redirect_to @police_station, notice: 'Police station was successfully created.' }\n format.json { render :show, status: :created, location: @police_station }\n else\n format.html { render :new }\n format.json { render json: @police_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(station, previous_station = route[0])\n previous_station != @stations.last ? @stations.insert(@stations.index(previous_station) + 1, station) : @stations.insert(-1, station)\n end", "def site_exists?\n if Site.exists?(url: url)\n update_attribute(:site_id,\n Site.find_by(url: url).id)\n else\n new_site = Site.create(url: url,\n feed_url: parse_feed_url)\n FetchSiteInformationJob.perform_now(new_site.id)\n FetchNewArticlesJob.perform_later(new_site.id)\n update_attribute(:site_id, new_site.id)\n end\n end", "def create\n @tollstation = Tollstation.new(tollstation_params)\n\n respond_to do |format|\n if @tollstation.save\n format.html { redirect_to @tollstation, notice: 'Tollstation was successfully created.' }\n format.json { render :show, status: :created, location: @tollstation }\n else\n format.html { render :new }\n format.json { render json: @tollstation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.new(url_params)\n\n Url.transaction do\n @url.save\n #write base 62 method\n @url.short_url = generate_base62_short_url(@url.id)\n if @url.save\n render json: @url, status: :created, root: :url\n else\n render json: @url.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n @station = Station.find(params[:id])\n\n respond_to do |format|\n if @station.update_attributes(params[:station])\n format.html { redirect_to @station, notice: 'Station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @station = Station.find(params[:id])\n\n respond_to do |format|\n if @station.update_attributes(params[:station])\n format.html { redirect_to @station, notice: 'Station was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @station.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@state = State.create(states_params)\n\t\tif @state.save\n\t\t\tflash[:success] = \"Record updated successfully\"\n\t\t\tredirect_to states_path\n\t\t else\n\t\t \tflash[:error] = \"Record not updated\"\n\t\t redirect_to states_path\n\t\tend\n\tend", "def save\n update\n rescue Net::HTTPClientException => e\n # If that fails, go ahead and try and update it\n if e.response.code == \"404\"\n create\n else\n raise e\n end\n end", "def add_url(url, shortcode)\n @db.execute \"INSERT INTO pairings VALUES('#{url}', '#{shortcode}')\"\n return true\n rescue SQLite3::Exception => e\n puts 'Unable to add url:'\n puts e\n return false\n end", "def create_finalurl\n\t\tStore.all.each do |store_obj|\n\t\t\tif url.include?(store_obj.tracker_urlidentifier)\n\t\t\t\tself.store = store_obj\n\t\t \t\tself.finalurl = store.get_redirect_url(url, id)\n\t\t \t\tself.save!\n\t\t\tend\n\t\tend\n\tend", "def create\n url = params[:short_url][:url]\n\n # regex to validate url\n is_url = url.match(/^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$/ix).present?\n \n if is_url == true\n surl = Digest::MD5.hexdigest(url+\"in salt we trust\").slice(0..6) \n short_url = \"http://\" + surl\n\n @short_url = ShortUrl.create(title: params[:short_url][:title], url: params[:short_url][:url] , short_url: short_url, jmp_url: \"\", clicks: 0)\n redirect_to @short_url, notice: 'Short url was successfully created.'\n else \n redirect_to short_urls_path, notice: 'Invalid Url.'\n end \n\n \n end", "def create_station\n station_name = get_station_name\n @stations << Station.new(station_name) unless station_name.empty?\n puts \"Создана станция '#{station_name}'.\"\n separator\n end", "def create\n @workstation = Workstation.new(params[:workstation])\n\n respond_to do |format|\n if @workstation.save\n format.html { redirect_to @workstation, notice: 'Workstation was successfully created.' }\n format.json { render json: @workstation, status: :created, location: @workstation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workstation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @state = State.new(state_params)\n\n end", "def create\n @washing_station = WashingStation.new(params[:washing_station])\n\n respond_to do |format|\n if @washing_station.save\n format.html { redirect_to(@washing_station, :notice => 'WashingStation was successfully created.') }\n format.xml { render :xml => @washing_station, :status => :created, :location => @washing_station }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @washing_station.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\t url = params.require(:site)[:url]\n\t site = Site.create(url: url)\n\t LinksWorker.perform_async(site.id)\n\t redirect_to site_path(site)\n\tend", "def update\n @station = Station.find(params[:id])\n\n respond_to do |format|\n if @station.update_attributes(params[:station])\n format.html { redirect_to(@station, :notice => 'Station was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @station.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_state\n State.create(state:'TX')\n end", "def create\n @united_state = UnitedState.new(united_state_params)\n\n respond_to do |format|\n if @united_state.save\n format.html { redirect_to @united_state, notice: 'United state was successfully created.' }\n format.json { render :show, status: :created, location: @united_state }\n else\n format.html { render :new }\n format.json { render json: @united_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = Url.new(url_params)\n respond_to do |format|\n if @url.save\n #format.html { redirect_to @url, notice: 'Url was successfully created.' }\n FetchUrlWorker.perform_async(@url.id)\n format.json { render json: {\n short_url: \"#{request.protocol}#{request.host_with_port}/#{@url.short_url}\",\n status: :created,\n location: @url }\n }\n else\n # format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_api\n\n @url = Url.new(:url => params[:url])\n\n if @url.save\n url_hash = Hash.new\n\n url_hash[:short_url] = root_url.to_s() + \"urls_api/\" + (@url.id).to_s(36)\n url_hash[:url] = @url.url\n\n render :json => url_hash.to_json\n end\n\n end", "def create\n @duty_station = DutyStation.new(params[:duty_station])\n\n respond_to do |format|\n if @duty_station.save\n format.html { redirect_to military_discounts_path, notice: 'Duty station was successfully created.' }\n format.json { render json: @duty_station, status: :created, location: @duty_station }\n else\n format.html { render action: \"new\" }\n format.json { render json: @duty_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def station\n @station ||= Station.get(station_codes.first)\n end", "def create\n normalized_url = Link.normalize_url(params[:url])\n if normalized_url.nil?\n flash[:error] = \"Invalid URL\"\n redirect_to root_path\n else\n begin\n link = Link.find_or_create(normalized_url, params[:type])\n redirect_to root_path(code: link.code)\n rescue => error\n flash[:error] = ERROR_DB_CONNECTION\n redirect_to root_path\n end\n end\n end", "def create\n city = params['city'].downcase\n state = params['state'].upcase\n @result = process_location(city, state)\n\n if @result[:type] == \"error\"\n flash[:error] = @result[:value]\n redirect_to '/artists'\n else\n redirect_to \"/artists?select_location=#{@result[:value].id}\"\n end\n end", "def save_state(state)\n states.add(state)\n end", "def create\n @state = State.new(state_params)\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render json:{message:'State was successfully created.'}, status: :created, location: @state }\n else\n format.html { render action: 'new' }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(url, code = nil)\n url = ensure_url(url)\n\n if resp = check_host(url)\n return resp\n end\n \n begin\n if code = @db.add(url.to_s, code)\n [201, {\"Location\" => code}]\n else\n [422, {}, \"Unable to shorten #{url}\"]\n end\n rescue DuplicateCodeError => err\n [422, {}, err.to_s]\n end\n end", "def create\n @url = Url.new(url_params)\n\n\n respond_to do |format|\n if @url.save\n format.html { redirect_to @url, notice: 'Url was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def save\n requires :display_text, :name, :network_offering_id, :zone_id\n\n options = {\n 'displaytext' => display_text,\n 'name' => name,\n 'zoneid' => zone_id,\n 'networkofferingid' => network_offering_id\n }\n\n response = service.create_network(options)\n merge_attributes(response['createnetworkresponse']['network'])\n end", "def create\n @url = Url.new(url_params)\n \n set_url_host_model\n \n respond_to do |format|\n if @url.save\n format.html { redirect_to @url, notice: 'Url was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n end", "def station(code)\n Station.get(code)\n end", "def create\n original_url = params[:short_url][:url]\n sanity_url = get_sanity_url(original_url)[0]\n @short_url = ShortUrl.find_by(sanity_url: sanity_url)\n if !@short_url.present?\n short_url = create_short_url\n while ShortUrl.find_by(short: short_url).present?\n short_url = create_short_url\n end\n @short_url = ShortUrl.new(original: original_url, short: short_url, sanity_url: sanity_url)\n @short_url.save\n end\n redirect_to @short_url, notice: 'Short url was successfully created.'\n end", "def create\n if @site = Setting.current_site(current_user)\n @storeloc = Storeloc.new(storeloc_params)\n @storeloc.site = @site\n else\n flash[:error] = 'No Site Selected. Please Select a Site prior to proceeding.'\n redirect_to(setting_url, :action=>'edit')\n end\n\n if @storeloc.save\n flash[:notice] = 'Storage Location was successfully created.'\n redirect_to storelocs_path\n else\n render :action => \"new\"\n end\n end", "def perform(place)\n client = Foursquare2::Client.new(\n oauth_token: place.user.oauth_token,\n api_version: Places::Application::FOURSQUARE_API_VERSION\n )\n\n place.foursquare_venue_url =\n client.venue(place.foursquare_venue_id)['shortUrl']\n place.save\n end", "def create\n @line_station = LineStation.new(params[:line_station])\n\n respond_to do |format|\n if @line_station.save\n format.html { redirect_to @line_station, notice: 'Line station was successfully created.' }\n format.json { render json: @line_station, status: :created, location: @line_station }\n else\n format.html { render action: \"new\" }\n format.json { render json: @line_station.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n puts \"Adding the following URL to the index: #{url}\".green\n update_attributes!(:title => title,\n :keywords => keywords,\n :created_at => Time.now,\n :updated_at => Time.now)\n end", "def create\n @kanban_state = KanbanState.new(kanban_state_params)\n\n authorize @kanban_state\n\n respond_to do |format|\n if @kanban_state.save\n url = params[:url] || edit_admin_project_path(@kanban_state.project_id, anchor: \"kanban_states\")\n\n format.html { redirect_to url, notice: t('actions.created_with_success') }\n format.json { render :edit, status: :created, location: @kanban_state }\n else\n format.html { render :new }\n format.json { render json: @kanban_state.errors, status: :unprocessable_entity }\n end\n end\n end", "def []=(url, value)\n case\n when store.respond_to?(:[]=)\n store[key_for(url)] = value\n when store.respond_to?(:set)\n store.set key_for(url), value\n when store.respond_to?(:write)\n store.write key_for(url), value\n end\n end", "def create\n @map_state = MapState.new(params[:map_state])\n\n respond_to do |format|\n if @map_state.save\n format.html { redirect_to @map_state, :notice => 'Map state was successfully created.' }\n format.json { render :json => @map_state, :status => :created, :location => @map_state }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @map_state.errors, :status => :unprocessable_entity }\n end\n end\n end", "def url= new_url\n new_url = self.class.standardized_url new_url\n return if new_url == url\n super new_url # Heading for trouble if url wasn't unique\n @indexing_url = nil # Clear the memoized indexing_url\n self.http_status = nil # Reset the http_status\n # We do NOT build the associated site here, because we may be BUILDING the page_ref for a site, in\n # which case that site will assign itself to us. Instead, the site attribute is memoized, and if it\n # hasn't been built by the time that it is accessed, THEN we find or build an appropriate site\n self.site = SiteServices.find_or_build_for self\n self.kind = :site if site&.page_ref == self # Site may have failed to build\n # We trigger the site-adoption process if the existing site doesn't serve the new url\n # self.site = nil if site&.persisted? && (SiteServices.find_for(url) != site) # Gonna have to find another site\n request_attributes :url # Trigger gleaning and mercury_result to validate/modify url\n attrib_ready! :url # Has been requested but is currently ready\n end", "def create\n raise ArgumentError, \"Site already exists in Piwik, call 'update' instead\" unless new?\n raise ArgumentError, \"Name can not be blank\" if name.blank?\n raise ArgumentError, \"Main URL can not be blank\" if main_url.blank?\n xml = call('SitesManager.addSite', :siteName => name, :urls => main_url)\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n @id = result.to_i\n @created_at = Time.current\n id && id > 0 ? true : false\n end", "def passive_state_change!(state_details)\n api.state_change.create!(state_details)\n end" ]
[ "0.6124878", "0.5908352", "0.5855723", "0.5855723", "0.5790763", "0.5772726", "0.5731229", "0.5681185", "0.5606074", "0.5506624", "0.54587865", "0.5431429", "0.5410876", "0.53667563", "0.5360192", "0.5360192", "0.5360192", "0.5357474", "0.5355892", "0.5342366", "0.5306843", "0.52933764", "0.52454245", "0.5238423", "0.5231816", "0.52141666", "0.5212324", "0.5212324", "0.5201602", "0.5195442", "0.5174471", "0.5165158", "0.51631755", "0.51631755", "0.5155387", "0.5130652", "0.51305276", "0.5095966", "0.50943875", "0.50923395", "0.5090431", "0.50650394", "0.5056", "0.50382847", "0.5032808", "0.50327057", "0.503197", "0.5027732", "0.5012712", "0.5012512", "0.50100094", "0.5009456", "0.50060475", "0.49969018", "0.4995365", "0.49943143", "0.499353", "0.49865648", "0.497763", "0.49665773", "0.49653605", "0.49645263", "0.49645263", "0.49642113", "0.49600768", "0.4956306", "0.49539468", "0.49363714", "0.49305356", "0.4920113", "0.490583", "0.490341", "0.49004543", "0.4898375", "0.4894", "0.48911932", "0.48905003", "0.48625046", "0.4860925", "0.4854528", "0.4853708", "0.4851886", "0.4843414", "0.48373368", "0.48307025", "0.48281744", "0.48266146", "0.48190182", "0.48078358", "0.4807271", "0.4807052", "0.48041987", "0.48027584", "0.47978154", "0.47921792", "0.47885108", "0.47883093", "0.47858018", "0.47761887", "0.47761303" ]
0.6925179
0
Will retrieve all new observations given a Station.
def fetch_observations(station) scraper_logger.info("Fetching latest weather observations for #{station.id} - #{station.name}") new = 0 json = extract_observations(station.json_url) json['observations']['data'].each do |o| Time.zone = 'UTC' recording_time = Time.zone.parse("#{o['aifstime_utc']}Z") unless Observation.already_exists?(station, recording_time) observation = Observation.new observation.station = station observation.recording_time = recording_time observation.save parse_readings(o, observation) new += 1 end end scraper_logger.info("Added #{new} new observations") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end", "def index\n @stations = Station.all\n end", "def index\n @stations = Station.all\n end", "def index\n @station_infos = StationInfo.all\n end", "def gather!\n @observations = get_datas!\n @last_observation_at = Observation.last(:select => :observed_at).try(:observed_at)\n collection = @last_observation_at.nil? ? @observations : only_the_ones_we_care_about\n collection.each do |observation|\n o = Observation.create observation\n Observation.logger.info \"created #{o.inspect}\"\n end\n end", "def import_observations(station, date)\n self.send(:initialize)\n api_data = self.get_api_data(station, date)\n\n # Check for minutely data\n self.collect_processed_minutely_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_MINUTE\n\n # Check for hourly data\n self.collect_processed_hourly_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_HOUR\n\n # Check for daily data\n self.collect_processed_daily_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_DAY\n\n Rails.logger.debug \"Processed #{self.results[:processed]} observations\"\n Rails.logger.debug \"Created #{self.results[:created]} observations\"\n Rails.logger.debug \"Updated #{self.results[:updated]} observations\"\n Rails.logger.debug \"Skipped #{self.results[:skipped]} observations\"\n Rails.logger.debug \"#{self.results[:failed]} observations failed saving\"\n return self.results\n end", "def update_observations\n\n State.all.each do |s|\n fork do\n Station.where(state_id: s.id).each do |s|\n fetch_observations(s)\n end\n end\n end\n\n end", "def gather!\n Observation.prune!\n\n @observations = get_datas!\n @last_observation_at = Observation.select(:observed_at).last.try(:observed_at)\n collection = @last_observation_at.nil? ? @observations : only_the_ones_we_care_about\n collection.each do |observation|\n o = Observation.create observation\n Observation.logger.info \"created #{o.inspect}\"\n end\n end", "def latest_observations\n path = 'stations/%s/observations/latest' % [@id]\n get(path)['properties']\n end", "def index\n @station_dailies = StationDaily.all\n end", "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def observations(stations, lang = 'is', time = '1h', anytime = '0')\n Apis.client.get(\"/weather/forecasts/#{lang}\" \\\n \"/?stations=#{stations.join(',')}&time=#{time}&anytime=#{anytime}\")\n end", "def stations\r\n return @stations\r\n end", "def current_observations(lat, lon, options = {})\n station = options.fetch(:station) { nearest_weather_station(lat, lon, options) }\n Services::CurrentObservations.new(options).fetch(station)\n end", "def index\n @set_stations = SetStation.all\n end", "def list_observations # :nologin:\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def index\n @main_stations = MainStation.all\n end", "def list_observations\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def get_all_stations\n url = 'radio/station'\n options = {query: {'alt': 'json', 'tier': 'aa', 'hl': 'en_US'}}\n\n make_post_request(url, options)\n end", "def stations_list\n @route.stations_list\n end", "def stations_list\n @route.get_stations_list\n end", "def index\n @recordingstations = Recordingstation.all\n end", "def index\n @station_hours = StationHour.all\n end", "def list_stations\n if @stations.empty?\n stations_void\n else\n stations_list\n end\n end", "def index\n @fire_stations = FireStation.all\n end", "def index\n @stations = Station.all\n\n render json: @stations\n end", "def index\n @police_stations = PoliceStation.all\n end", "def index\n @asos_stations = AsosStation.all\n end", "def stations\n doc = request(@user, \"stations\")\n stations = []\n doc.xpath('//rss/channel/item').each do |node|\n stations << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :artwork => node.xpath('pandora:stationAlbumArtImageUrl').text.strip,\n :songSeed_song => node.xpath('pandora:seeds/pandora:songSeed/pandora:song').text.strip,\n :songSeed_artist => node.xpath('pandora:seeds/pandora:songSeed/pandora:artist').text.strip,\n :composerSeed => node.xpath('pandora:seeds/pandora:composerSeed/pandora:composer').text.strip,\n :artistSeed => node.xpath('pandora:seeds/pandora:artistSeed/pandora:artist').text.strip}\n end\n stations\n end", "def get_api_data(station)\n yield\n end", "def index\n @observations = scope.all\n end", "def index\n @tollstations = Tollstation.all\n end", "def find_closest_stations\n\tuserLoc = [params[:lat], params[:lng]]\n\tbounds = Geokit::Bounds.from_point_and_radius(userLoc, 10) \n\t@stations = Station.in_bounds(bounds).all # get all stations within 10 miles\t\n\t@stations.each do |s| # calc distance\n\t\ts['distance'] = s.distance_from(userLoc, :units => :miles)\n\tend\n\t@stations.sort! { |a, b| a.distance <=> b.distance }\n\tputs \"num stations found: \" + @stations.size.to_s\n\trender :json => @stations.to_json\n\t#render :json => Station.find_all_by_stop_lat_and_stop_lng(params[:lat], params[:lng]).to_json #works\n\t#repond_with was not working, not sure why\n end", "def station\n\trespond_with(@station = Station.find_all_by_stop_id(params[:stop_id]))\n end", "def save_reading()\n\tStation.all.each do |x|\n\t\tstation_id = x.station_id\n\t\tlat = x.lat\n\t\tlong = x.long\n\t\tlat_long = \"#{lat},#{long}\"\n\t\tforecast = JSON.parse(open(\"#{BASE_URL}/#{API_KEY}/#{lat_long}\").read)\n\t\tr = WeatherReading.new\n\t\tr.build_reading(station_id,lat,long,current_date(forecast),current_time(forecast),current_temperature(forecast),current_dew_point(forecast),\n\t\t\tcurrent_wind_direction(forecast),current_wind_speed(forecast),current_rainfall(forecast),\"forecast.io\")\n\t\tr.save\n\tend\n\nend", "def index\n @line_station_2s = LineStation2.all\n end", "def index\n @observations = Observation.all()\n end", "def list_stations\n Station.all.collect{|obj| obj.name}.sort\n end", "def list_stations\n @stations.each_with_index { |station, i| puts \"#{i + 1} #{station.name}\" }\n end", "def stations\n ActiveModel::ArraySerializer.new(object.station, each_serializer: Api::V1::StationSerializer)\n end", "def refresh()\n @knights = Knight.all\n @events = Event.all\n @kingdoms = Kingdom.all\n run_results()\n end", "def get_all_new\n uri = [@@base_uri, 'all', 'getAllNew'].join('/')\n return get(uri)\n end", "def insert_into_weather_data(station)\n\n\tobservations_table = DB[:weather_data]\n\theroku_obs_table = DBHeroku[:weather_data]\n\n# remember that you still need to erase the heroku weather_data before you write to it.\n# use a sequel delete command first, then write to it\n\theroku_obs_table.insert(\n\tstation_id: station[:id],\n\ttime: station[:time],\n\ttemp: station[:temp], \n\tdewpoint: station[:dewpoint],\n\thumidity: station[:humidity],\n\tconditions: station[:conditions], \n\tweather_primary_coded: station[:weather_primary_coded],\n\tclouds_coded: station[:clouds_coded], \n\tis_day: station[:is_day],\n\twind_kph: station[:wind_kph],\n\twind_direction: station[:wind_direction]\n\t)\n\n\tobservations_table.insert(\n\t\tstation_id: station[:id],\n\t\ttime: station[:time],\n\t\ttemp: station[:temp], \n\t\tdewpoint: station[:dewpoint],\n\t\thumidity: station[:humidity],\n\t\tconditions: station[:conditions], \n\t\tweather_primary_coded: station[:weather_primary_coded],\n\t\tclouds_coded: station[:clouds_coded], \n\t\tis_day: station[:is_day],\n\t\twind_kph: station[:wind_kph],\n\t\twind_direction: station[:wind_direction]\n\t\t)\n\nend", "def index\n @raiway_stations = RaiwayStation.all\n end", "def index\n @railway_stations = RailwayStation.all\n end", "def extract_station(url, state)\n\n id, json_url = nil\n\n doc = Nokogiri::HTML(open(\"#{Global::BOM_BASE_URL}#{url}\"))\n doc.css('a').each do |l|\n\n if l.attr('href').include?('json')\n json_url = l.attr('href')\n id = l.attr('href').split('.')\n id = id[1]\n end\n\n end\n\n begin\n station = Station.find(id)\n scraper_logger.info(\"Updating existing station #{id}\")\n\n rescue\n station = Station.new\n station.id = id\n scraper_logger.info(\"Creating new station #{id}\")\n\n end\n\n begin\n station.state = state\n\n name = doc.css('h1').first\n station.name = name.text.gsub('Latest Weather Observations for ','')\n\n station.station_url = \"#{Global::BOM_BASE_URL}#{url}\"\n station.json_url = \"#{Global::BOM_BASE_URL}#{json_url}\"\n\n json = extract_observations(station.json_url)\n station.latitude = json['observations']['data'].first['lat']\n station.longitude = json['observations']['data'].first['lon']\n\n tz = Timezone.where(abbreviation: json['observations']['header'].first['time_zone'])\n if tz.size > 0\n station.timezone = tz.first\n station.save\n\n scraper_logger.info(\"#{station.id} - #{station.name} has been saved\")\n\n else\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due to unknown TZ (#{json['observations']['header'].first['time_zone']})\")\n\n end\n\n rescue\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due missing data in JSON file)\")\n\n end\n \n end", "def index\n @stations = Station.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stations }\n end\n end", "def set_station\n # @station = Station.find(params[:id])\n @station = Station.where(:exam_id=>params[:id])\n end", "def index\n @petrol_stations = PetrolStation.all\n end", "def find_station_lines(station) #calling the relationship between the station and the station line\n station.station_lines\n end", "def find_station(input) #grab their input to find their station\n Station.find_by(stations: input)\n end", "def updateStation()\n uri=URI.parse(ViaggiatrenoURLs.STATION_INFO)\n response = Net::HTTP.post_form(uri,{\"stazione\" => @stationFrom, \"lang\" => \"IT\"})\n doc = Nokogiri::HTML(response.body)\n\n doc.xpath(XPathMatchInfo.XPATH_STATION).each do |x|\n \n StringUtils.remove_newlines_tabs_and_spaces(x)\n\n train_number_complete = x.xpath(XPathMatchInfo.XPATH_TRAIN_NUMBER()).to_s\n train_destination = x.xpath(XPathMatchInfo.XPATH_TRAIN_DESTINATION()).to_s\n train_schedule =x.xpath(XPathMatchInfo.XPATH_TRAIN_SCHEDULED()).to_s\n train_description = \"#{train_number_complete} #{train_destination} #{train_schedule}\"\n \n train_number=train_number_complete.match(\"[0-9]+\")[0]\n \n @trains[train_number]=train_description\n @destinations.push(train_destination)\n ### TODO #### #@trains[train_number][description]=train_description\n end\n end", "def initialize_stations\r\n @stations = Array.new\r\n i = 0\r\n\r\n @lines.each {|line, stations|\r\n stations.each_with_index {|item, index|\r\n @stations.push(Station.new(item))\r\n if index == 0\r\n @stations.at(-1).set_train(@trains.at(i))\r\n i += 1\r\n end\r\n }\r\n }\r\n\r\n @stations = @stations.uniq { |s| s.station.to_s}\r\n end", "def all\n @stations = Station.all\n\n respond_to do |format|\n format.html\n format.xml { render xml: @stations }\n format.json { render json: @stations, callback: params['callback'] }\n end\n end", "def get_new_luns\n @lun_table.get_new_luns\n end", "def index\n @station = Station.find(params[:station_id])\n\t\t@acs = @station.acs\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @acs }\n end\n end", "def show\n pass_query_params\n @observation = find_or_goto_index(Observation, params[:id].to_s)\n return unless @observation\n\n @observations = [\n MinimalMapObservation.new(@observation.id,\n @observation.public_lat,\n @observation.public_long,\n @observation.location)\n ]\n end", "def index\n @courier_stations = CourierStation.find_by_sql [\"SELECT cs.id, cs.courier_id, cs.station_id, cs.status, cs.created_at, cs.updated_at, s.station_name, c.courier_name FROM courier_stations cs, couriers c, stations s WHERE cs.courier_id = c.id AND cs.station_id = s.id\"]\n end", "def index\n case params.require(:asos_station_id)\n when /^([\\d]+)$/\n asos_station_id = $1.to_i\n when /^([\\w]+)$/\n asos_station_id = AsosStation.find_by_stnid($1)[:id]\n end\n @asos_data = AsosDatum.where(asos_station_id: asos_station_id)\n end", "def stations\n @stations ||= (exact_match? ? parse_station : parse_stations)\n end", "def index\n set_stations_initial_scope!\n\n sort_stations_by_given_distance!\n sort_stations_by_given_criteria!\n\n # Pagination:\n paginate_stations!\n\n # Associations 'current_forecasts' and 'last_measurement' are always eager\n # loaded... however, full data will only be included if using the 'include'\n # parameter:\n eager_load_associations!\n\n respond_to do |format|\n format.json { render json: @stations, fields: json_api_params[:fields], include: params[:include] }\n format.jsonapi { render json: @stations, fields: json_api_params[:fields], include: params[:include], key_transform: :dash }\n end\n end", "def search_data\n merge = {\n station_name: weather_station.name,\n\n # http://apidock.com/rails/String/to_time\n reading_date: reading_date.to_time,\n }\n attributes.merge(merge)\n end", "def index\n @stalls = Stall.all\n end", "def index\n @stalls = Stall.all\n end", "def weather_stations(options = {})\n if options.delete(:reload) { false } || @weather_stations.nil?\n @weather_stations = Services::WeatherStations.new(options).fetch\n end\n @weather_stations\n end", "def index\n @sensor_data = SensorData.by_time\n end", "def data_add_stations\n @routes[0].stations.insert(-2, @stations[1])\n @routes[0].stations.insert(-2, @stations[2])\n @routes[2].stations.insert(-2, @stations[1])\n end", "def all\r\n copy_and_return(@records)\r\n end", "def set_obersvation\n @observations = Observation.find(params[:id])\n end", "def show_trains_by_station\n if @stations.empty?\n stations_void\n else\n request = [\"Enter station name: [#{@stations.keys.join(', ')}]: \"]\n getting(request, :approve_station_selection, :show_train)\n end\n end", "def for_station(station_key)\n # STATIONS[station_key] can return either an array of RO keys or a single RO key\n [STATIONS[station_key]]\n .flatten\n .map(&RegionalOffice.method(:find!))\n end", "def set_station_daily\n @station_daily = StationDaily.find(params[:id])\n end", "def find_all_at_ts(ts)\n repository.find_all_at_ts(ts_bucket(ts))\n end", "def index\n @converstation_requests = ConverstationRequest.all\n end", "def new\n @station = Station.new\n respond_with(@station)\n end", "def stations\n [\n master_station,\n SLCStationReport.new(@fields[5..9], false),\n SLCStationReport.new(@fields[10..14], false),\n SLCStationReport.new(@fields[15..19], false),\n SLCStationReport.new(@fields[20..24], false),\n SLCStationReport.new(@fields[25..29], false)\n ]\n end", "def station_times(name, mins)\n ier = IERailGet.new(\"getStationDataByNameXML_withNumMins?StationDesc=#{name}&NumMins=#{mins}\", \"arrayofobjstationdata\", \"objstationdata\")\n \n ier.response.map { |sd| StationData.new(sd) }\n end", "def index\n @stamps = Stamp.all\n end", "def load_station_data\n data = Net::HTTP.get(URI.parse(stations_url))\n JSON.parse(data)[\"result\"]\n end", "def observations_at_where\n where = params[:where].to_s\n params[:location] = where\n query = create_query(:Observation, :at_where,\n user_where: where,\n location: Location.user_name(@user, where))\n show_selected_observations(query, always_index: 1)\n end", "def index\n @driver_trip_seats = DriverTripSeat.all\n end", "def get_all\n @monkeys.dup\n end", "def observations_at_where # :nologin: :norobots:\n where = params[:where].to_s\n params[:location] = where\n query = create_query(:Observation, :at_where,\n user_where: where,\n location: Location.user_name(@user, where))\n show_selected_observations(query, always_index: 1)\n end", "def show\n @station = Station.where(number:@forecast.station_number).last\n end", "def songs \n Song.all.select{|song| add_song(song)}.to_a\n # binding.pry\n end", "def index\n show and return if params[:id].present?\n\n @query = find_or_create_query(:Observation)\n apply_content_filters(@query)\n @query = restrict_query_to_box(@query)\n\n find_locations_matching_observations\n end", "def all_resorts\n @resort_svc.Objects.order_by(\"NOMSTATION\")\n @resort_svc.execute\n end", "def fetch_stations(state)\n\n scraper_logger.info(\"Fetching stations for #{state.name}\")\n\n doc = Nokogiri::HTML(open(state.url))\n doc.css('a').each do |s|\n\n Global::OBSERVATION_PRODUCT_CODE.each do |c|\n if s.attr('href').include?(c) and s.attr('href').include?(state.product_group)\n extract_station(s.attr('href'), state)\n end\n end\n\n end\n\n scraper_logger.info(\"Completed fetching stations for #{state.name}\")\n\n end", "def lines_at_station(station)\r\n line_array = Array.new\r\n\r\n lines.each {|lines, stations|\r\n stations.each {|x| \r\n if x == station\r\n line_array.push(lines)\r\n end \r\n } \r\n }\r\n\r\n return line_array\r\n end", "def set_station\n @station = Station.find(params[:id])\n end", "def info\n puts \"All stations:\"\n @stations.each.with_index(1) do |station|\n puts \"#{station.name}: \"\n station.show_trains(\"Cargo\")\n station.show_trains(\"Passenger\")\n end\n\n puts \"All routes:\"\n show_routes\n puts \"All trains:\"\n show_trains\n puts \"All wagons:\"\n show_wagons\n end", "def observations_by_name # :nologin: :norobots:\n query = create_query(:Observation, :all, by: :name)\n show_selected_observations(query)\n end", "def fetch_stations\n log(' - Fetching station list...', false)\n results = {}\n response = get_response('https://www.nationalrail.co.uk/static/documents/content/station_codes.csv')\n CSV.new(response, headers: true).each do |row|\n results[row['CRS Code']] ||= {}\n results[row['CRS Code']][:name] = row['Station Name']\n end\n log('DONE')\n results\nend", "def add_station(station)\n @stations.insert(-2, station)\n end", "def add_station(station)\n @stations.insert(-2, station)\n end", "def index\n @sensor_data = SensorDatum.all\n end", "def show\n update_datetime_of_query\n @date_in_question = datetime_of_query.to_date\n\n beginning = datetime_of_query.beginning_of_day\n\n @station = Station.find(params[:id])\n @clockwise_travels = @station.departures.includes(:train).\n where(:depart_at => beginning...beginning+1).\n where('trains.clockwise' => true).order('depart_at')\n\n @counterclockwise_travels = @station.departures.includes(:train).\n where(:depart_at => beginning...beginning+1).\n where('trains.clockwise' => false).order('depart_at')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @station }\n end\n end", "def index\n @duty_stations = DutyStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @duty_stations }\n end\n end", "def index\n @stations = Station.all\n\n #response = HTTParty.get('http://0.0.0.0:3000/convertcsv.json')\n # r = HTTParty.get('http://0.0.0.0:3000/convertcsv.json')\n # r = HTTParty.get('http://rubygems.org/api/v1/versions/httparty.json')\n # r = HTTParty.get('http://0.0.0.0:3000/convertcsv.json') \n\n linestation_list = JSON.parse(File.read('app/assets/javascripts/convertcsv.json'))\n # puts \"first record\"\n # puts linestation_list[0][\"From Station\"]\n $i = 0\n $stops = 5\n \n origin_stations = [\"East Ham\"]\n\n\n final_to_station_array =[]\n processed_stations = []\n\n\n while $i < $stops do\n puts(\"*******Stations from East Ham with the following stops (1+) #$i **********\" )\n to_station = \"\"\n\n final_to_station_array = []\n statition_detail = {}\n\n\n\n # origin_stations.each do | origin_station |\n # origin_station = origin_stations[0]\n\n\n linestation_list.each do | ls |\n\n\n # puts ls[\"To Station\"] == old_origin_station\n # if final_to_station_array.include?(ls[\"From Station\"])\n # puts \"include the From Station in the final\"\n # end\n from_tube_lines = []\n \n\n if origin_stations.include?(ls[\"From Station\"]) || origin_stations.include?(ls[\"To Station\"])\n \n from_tube_lines.push(ls[\"Tube Line\"])\n\n\n origin_tube_line = \"District\"\n updated_tube_lines =\"\"\n\n origin_stations.each do | origin_station |\n\n # updated_tube_lines = updated_tube_lines.present?? updated_tube_lines : origin_tube_line\n puts \"initialiezed updated_tube_lines\"\n puts updated_tube_lines\n\n unless processed_stations.include?(origin_station) \n puts \"*****adding to the processed_station now\"\n processed_stations.push(origin_station)\n puts \"origin_station\"\n puts origin_station\n puts \"*****processed_stations\"\n puts processed_stations\n end \n\n unless processed_stations.include?(ls[\"To Station\"]) \n unless final_to_station_array.include?(ls[\"To Station\"])\n puts \"***adding to the final stations now\"\n puts ls[\"To Station\"]\n final_to_station_array.push(ls[\"To Station\"])\n statition_detail[ls[\"To Station\"]] = \"#{ls['To Station']} (lines = #{ls['Tube Line']})\"\n end\n end\n\n unless processed_stations.include?(ls[\"From Station\"])\n unless final_to_station_array.include?(ls[\"From Station\"])\n puts \"***adding to the final stations now\"\n puts ls[\"From Station\"]\n final_to_station_array.push(ls[\"From Station\"])\n statition_detail[ls[\"From Station\"]] = \"#{ls['From Station']} (lines = #{ls['Tube Line']})\"\n end\n end\n\n puts \" old updated_tube_lines ???\"\n puts updated_tube_lines\n\n puts \" old origin_tube_line ???\"\n puts origin_tube_line \n\n if origin_tube_line == ls[\"Tube Line\"]\n updated_tube_lines = origin_tube_line \n puts \"original is the same as the current, assign to the updated one\"\n else\n\n puts \"----- the updated_tube_lines\"\n puts updated_tube_lines \n updated_tube_lines = origin_tube_line + \", \" + ls[\"Tube Line\"]\n puts \" **** new updated_tube_line\"\n puts updated_tube_lines\n\n end\n\n \n \n end \n\n origin_tube_line = updated_tube_lines\n puts \" **** new updated_tube_line\"\n puts updated_tube_lines\n puts \"-----from_tube_lines----\"\n puts from_tube_lines\n\n\n end\n end\n\n\n # end\n \n\n origin_stations = []\n origin_stations = final_to_station_array\n $i +=1\n\n puts \"&&&&&&& the needed information &&&&&&\" \n puts \"*******final_to_station_array\"\n puts final_to_station_array\n puts final_to_station_array.size\n puts \"** station detail\"\n puts statition_detail\n puts \"-----\"\n end\n\n\n # origin_station = \"East Ham\"\n # to_station = \"\"\n # linestation_list.each do | ls |\n # while $i < $stops do\n # puts(\"Inside the loop i = #$i\" )\n # puts ls[\"From Station\"]\n # if ls[\"From Station\"] == origin_station\n # # to_station = ls[\"To Station\"]\n # puts ls\n # end\n # # origin_station = to_station\n # # puts \"new origin_station\"\n # # puts origin_station\n # puts \"-----\"\n # $i +=1\n # end\n\n # end\n\n\n\n\n end", "def get_station_tracks(station_id, number_of_tracks = 25, recently_played = [])\n url = 'radio/stationfeed'\n options = {\n query: {'alt': 'json', 'include-tracks': 'true', 'tier': 'aa', 'hl': 'en_US'},\n headers: {'Content-Type': 'application/json'},\n body: {'contentFilter': 1,\n 'stations': [\n {\n 'numEntries': number_of_tracks,\n 'recentlyPlayed': recently_played.map { |rec| add_track_type rec},\n 'seed': { \n \"#{get_typename_from_id(station_id)}\": station_id, \n 'kind': 'sj#radioSeed', \n 'seedType': get_seed_type_from_id(station_id)\n }\n }\n ]}.to_json\n }\n\n res = make_post_request(url, options)\n return res['data']['stations']\n end" ]
[ "0.60627115", "0.60454845", "0.60211325", "0.60140836", "0.60013545", "0.599155", "0.5933164", "0.58868164", "0.58325136", "0.57831836", "0.5751916", "0.57026345", "0.56444305", "0.55942184", "0.5555724", "0.55298007", "0.54736036", "0.54655385", "0.5448267", "0.5442694", "0.54182553", "0.53669274", "0.536079", "0.53537506", "0.5351893", "0.53470916", "0.5328814", "0.5323855", "0.53206414", "0.5316794", "0.5312281", "0.5303195", "0.5238647", "0.52317137", "0.5230925", "0.5229725", "0.52244705", "0.52151746", "0.51983476", "0.5162433", "0.5149351", "0.5144627", "0.5141996", "0.5129339", "0.51248616", "0.5093005", "0.5091911", "0.5080325", "0.5076163", "0.50672483", "0.504288", "0.5034972", "0.5033114", "0.50315136", "0.5028152", "0.5027068", "0.50137687", "0.49775845", "0.49594828", "0.49453112", "0.49437073", "0.49373525", "0.49341986", "0.49341986", "0.49033678", "0.4878663", "0.48669547", "0.4860585", "0.48501527", "0.4839473", "0.48373622", "0.48359853", "0.48347828", "0.4832241", "0.4831116", "0.4830355", "0.48168123", "0.48163947", "0.48052052", "0.48044357", "0.48025694", "0.4796079", "0.47733805", "0.47702944", "0.47655708", "0.47642505", "0.47575203", "0.47531772", "0.47503895", "0.47356674", "0.4734441", "0.47260842", "0.4723764", "0.47225296", "0.47225296", "0.47199315", "0.4716573", "0.47114724", "0.47001603", "0.4699958" ]
0.7462373
0
Returns the JSON object from a stations observation.
def extract_observations(url) JSON.load(open(url)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stations\n ActiveModel::ArraySerializer.new(object.station, each_serializer: Api::V1::StationSerializer)\n end", "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def load_station_data\n data = Net::HTTP.get(URI.parse(stations_url))\n JSON.parse(data)[\"result\"]\n end", "def index\n @stations = Station.all\n\n render json: @stations\n end", "def fetch_observations(station)\n\n scraper_logger.info(\"Fetching latest weather observations for #{station.id} - #{station.name}\")\n\n new = 0\n\n json = extract_observations(station.json_url)\n json['observations']['data'].each do |o|\n\n Time.zone = 'UTC'\n recording_time = Time.zone.parse(\"#{o['aifstime_utc']}Z\")\n\n unless Observation.already_exists?(station, recording_time)\n observation = Observation.new\n observation.station = station\n observation.recording_time = recording_time\n observation.save\n\n parse_readings(o, observation)\n\n new += 1\n\n end\n\n end\n\n scraper_logger.info(\"Added #{new} new observations\")\n\n end", "def show\n render json: @station\n end", "def generateJson(sortedStationArray)\n\t\tSQLite3::Database.open(@filePath + \"sql/#{sortedStationArray.name}/#{@element}.db\" ) do |db|\n\t\t\t jsonArray = Array.new()\n\t\t\t# iterate through every row from start date to end date\n\t\t\tbegin \n\t\t\t\t\t db.execute( \"SELECT stationID, WERT, einheit, datum FROM data where datum >= '#{@start_date}' and datum <= '#{@end_date}';\" ) do |row|\n\t\t\t\t\t\t# create array containing all requested data\n\t\t\t\t\t\tdata = {}\n\t\t\t\t\t\tdata[\"location\"] = row[0].to_s\n\t\t\t\t\t\tdata[\"wert\"] = row[1]\n\t\t\t\t\t\tdata[\"einheit\"] = row[2]\n\t\t\t\t\t\tdata[\"date\"] = row[3]\n\t\t\t\t\t\tdata[\"element\"] = @element\n\t\t\t\t\t\tjsonArray.push(data)\n\t\t\t\t\tend\n\t\t\t\treturn jsonArray\n\t\t\t\t\trescue (SQLite3::SQLException)\n\t\t\t\treturn []\n\t\t\tend\n\t\tend\n\tend", "def stations\r\n return @stations\r\n end", "def latest_observations\n path = 'stations/%s/observations/latest' % [@id]\n get(path)['properties']\n end", "def extract_station(url, state)\n\n id, json_url = nil\n\n doc = Nokogiri::HTML(open(\"#{Global::BOM_BASE_URL}#{url}\"))\n doc.css('a').each do |l|\n\n if l.attr('href').include?('json')\n json_url = l.attr('href')\n id = l.attr('href').split('.')\n id = id[1]\n end\n\n end\n\n begin\n station = Station.find(id)\n scraper_logger.info(\"Updating existing station #{id}\")\n\n rescue\n station = Station.new\n station.id = id\n scraper_logger.info(\"Creating new station #{id}\")\n\n end\n\n begin\n station.state = state\n\n name = doc.css('h1').first\n station.name = name.text.gsub('Latest Weather Observations for ','')\n\n station.station_url = \"#{Global::BOM_BASE_URL}#{url}\"\n station.json_url = \"#{Global::BOM_BASE_URL}#{json_url}\"\n\n json = extract_observations(station.json_url)\n station.latitude = json['observations']['data'].first['lat']\n station.longitude = json['observations']['data'].first['lon']\n\n tz = Timezone.where(abbreviation: json['observations']['header'].first['time_zone'])\n if tz.size > 0\n station.timezone = tz.first\n station.save\n\n scraper_logger.info(\"#{station.id} - #{station.name} has been saved\")\n\n else\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due to unknown TZ (#{json['observations']['header'].first['time_zone']})\")\n\n end\n\n rescue\n scraper_logger.warn(\"#{station.id} - #{station.name} could not be saved due missing data in JSON file)\")\n\n end\n \n end", "def stations\n doc = request(@user, \"stations\")\n stations = []\n doc.xpath('//rss/channel/item').each do |node|\n stations << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :artwork => node.xpath('pandora:stationAlbumArtImageUrl').text.strip,\n :songSeed_song => node.xpath('pandora:seeds/pandora:songSeed/pandora:song').text.strip,\n :songSeed_artist => node.xpath('pandora:seeds/pandora:songSeed/pandora:artist').text.strip,\n :composerSeed => node.xpath('pandora:seeds/pandora:composerSeed/pandora:composer').text.strip,\n :artistSeed => node.xpath('pandora:seeds/pandora:artistSeed/pandora:artist').text.strip}\n end\n stations\n end", "def station_schedule\n\t\tinfo_array = Station.find_all_by_stop_id(params[:stop_id])\n\t\t\tinfo1 = info_array[0] # for first station\n\t\t\tpkey_base = info1.platform_key.chop\n\t\t\tpkey_base = pkey_base[1,3] # middle chars of platform key (i.e. ignore North, South, Line Color ==> mostly b/c of stations on intersecting lines\n\t\tjson1 = getjson(info1.line, pkey_base, info1)\n\n\t\t# get more json if station is at LINE intersect\n\t\tinfo2 = intersect_station?(info_array) # returns db entry of second line if station is intersection\n\t\tif (!info2.blank?) \n\t\t\tputs \"2nd line: \"\n\t\t\tputs info2.line\n\t\t\tjson2 = getjson(info2.line, pkey_base, info2)\n\t\t\t@json = json1 + json2\n\t\telse\n\t\t\t@json = json1\n\t\tend\n\t\trespond_with(@json)\n end", "def stations_status\n Citibikenyc.stations_status\n end", "def observations(stations, lang = 'is', time = '1h', anytime = '0')\n Apis.client.get(\"/weather/forecasts/#{lang}\" \\\n \"/?stations=#{stations.join(',')}&time=#{time}&anytime=#{anytime}\")\n end", "def show\n render json: @space_station\n end", "def station(station_object) \n \"stns=#{station_object.id}\"\n end", "def index\n @space_stations = SpaceStation.all\n\n render json: @space_stations, include: :astronauts\n\n end", "def index\n @stations = Station.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stations }\n end\n end", "def station\n @station ||= Station.get(@attrs['StationCode'])\n end", "def station\n @station ||= Station.get(station_codes.first)\n end", "def station_info\n\t\tarray = JSON.parse(response.body)\n\t\tarray.each do |station_info| \n\t\t\tif station_info[\"borough\"] == \"Manhattan\"\n\t\t\t\tputs \"Facility Name:\"\n\t\t\t\tputs station_info[\"facilityname\"]\n\t\t\t\tputs \"Facility Address:\"\n\t\t\t\tputs station_info[\"facilityaddress\"]\n\t\t\t\tputs \"Borough:\"\n\t\t\t\tputs station_info[\"borough\"]\n\t\t\t\tputs \"-------------------\"\n\t\t\tend\n\t\tend\n\tend", "def fetch_gasstation_json\n begin\n url = \"https://ethgasstation.info/json/predictTable.json\"\n uri = URI.parse(url)\n\n Timeout.timeout(REQUEST_TIMEOUT) do\n response = Net::HTTP.get(uri)\n\n Oj.load(response)\n end\n rescue Timeout::Error => e\n send_email(e)\n {}\n\n rescue Exception => e\n send_email(e)\n {}\n end\n end", "def get_json\n response = conn.get(@current_location)\n parsed = JSON.parse(response.body, symbolize_names: true)\n\n end", "def as_json(cyclones)\n if self.has_attribute?(:width)\n # Laziness variables for fewer db calls and less typing later\n all_avg = AvgCycloneData.find_by(year: \"all\")\n year_avg = AvgCycloneData.find_by(year: self.cyclone_date.year.to_s)\n # Setting up empty variables for the historical weather\n hourly = []\n currently = nil\n # binding.pry\n # Set all of the historical data if it exists, otherwise return nil and an empty array\n if touchdown = self.historical_weather.find_by(hour: -9)\n currently = {\n pressure: touchdown.pressure,\n windSpeed: touchdown.wind_speed,\n windBearing: touchdown.wind_bearing.to_i,\n temperature: touchdown.temperature\n }\n self.historical_weather.where('hour != -9').each do |hour_weather|\n hourly[hour_weather.hour] = {}\n hourly[hour_weather.hour][\"windSpeed\"] = hour_weather.wind_speed\n hourly[hour_weather.hour][\"temperature\"] = hour_weather.temperature\n hourly[hour_weather.hour][\"pressure\"] = hour_weather.pressure\n hourly[hour_weather.hour][\"windBearing\"] = hour_weather.wind_bearing.to_i\n end\n end\n {\n id: self.id,\n date: {\n day: self.cyclone_date.day,\n month: self.cyclone_date.month,\n year: self.cyclone_date.year,\n hour: self.hour,\n minute: self.minute,\n timeZone: self.time_zone\n },\n cycloneStrength: {\n fScale: self.f_scale,\n width: self.width\n },\n loss: {\n injuries: self.injuries,\n fatalities: self.fatalities,\n propertyLoss: self.property_loss,\n cropLoss: self.crop_loss\n },\n location: {\n startLat: self.start_lat,\n startLong: self.start_long,\n stopLat: self.stop_lat,\n stopLong: self.stop_long,\n distance: self.distance,\n state: self.state,\n countyCodeOne: self.county_code_one,\n countyCodeTwo: self.county_code_two,\n countyCodeThree: self.county_code_three,\n countyCodeFour: self.county_code_four,\n statesCrossed: self.path.states_crossed\n },\n path: {\n completeTrack: self.path.complete_track,\n segmentNum: self.path.segment_num\n },\n average: {\n all: {\n fatalities: all_avg.fatalities,\n propertyLoss: all_avg.property_loss,\n cropLoss: all_avg.crop_loss,\n injuries: all_avg.injuries,\n fScale: all_avg.f_scale,\n distance: all_avg.distance\n },\n year: {\n fatalities: year_avg.fatalities,\n propertyLoss: year_avg.property_loss,\n cropLoss: year_avg.crop_loss,\n injuries: year_avg.injuries,\n fScale: year_avg.f_scale,\n distance: year_avg.distance\n }\n },\n touchdownWeather: currently,\n historicalWeather: hourly\n }\n else\n {\n location: {\n startLat: self.start_lat,\n startLong: self.start_long,\n stopLat: self.stop_lat,\n stopLong: self.stop_long\n },\n cycloneStrength: {\n fScale: self.f_scale\n },\n id: self.id,\n date: {\n day: self.cyclone_date.day,\n month: self.cyclone_date.month,\n year: self.cyclone_date.year\n },\n loss: {\n fatalities: self.fatalities,\n propertyLoss: self.property_loss,\n cropLoss: self.crop_loss\n }\n }\n end\n end", "def list_stations\n if @stations.empty?\n stations_void\n else\n stations_list\n end\n end", "def stations_list\n @route.stations_list\n end", "def stations\n respond_to do |format|\n format.html\n format.js\n end\n end", "def show\n respond_to do |format|\n format.html do\n station_id = current_station.id if current_station\n station_id ||= params[:station_id]\n\n if station_id\n station_tickets = @game.tickets.select {|t| t.station_id == station_id}\n station_mobile = station_tickets[0] && station_tickets[0].station ?\n station_tickets[0].station.mobile : nil\n @stations = station_mobile ? {station_mobile => station_tickets} : {}\n else\n @stations = {}\n @game.tickets.each do |ticket|\n @stations[ticket.station.mobile] = [] unless @stations[ticket.station.mobile]\n @stations[ticket.station.mobile] << ticket\n end\n end\n end\n\n format.json do\n render json: @game, status: 200\n end\n end\n end", "def find_closest_stations\n\tuserLoc = [params[:lat], params[:lng]]\n\tbounds = Geokit::Bounds.from_point_and_radius(userLoc, 10) \n\t@stations = Station.in_bounds(bounds).all # get all stations within 10 miles\t\n\t@stations.each do |s| # calc distance\n\t\ts['distance'] = s.distance_from(userLoc, :units => :miles)\n\tend\n\t@stations.sort! { |a, b| a.distance <=> b.distance }\n\tputs \"num stations found: \" + @stations.size.to_s\n\trender :json => @stations.to_json\n\t#render :json => Station.find_all_by_stop_lat_and_stop_lng(params[:lat], params[:lng]).to_json #works\n\t#repond_with was not working, not sure why\n end", "def stations_list\n @route.get_stations_list\n end", "def create\n @station = Station.new(station_params)\n\n if @station.save\n render json: @station, status: :created, location: @station\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def show\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end", "def index\n @line_stations = LineStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @line_stations }\n end\n end", "def as_json\n { street_address: @street_address,\n street_address2: @street_address2,\n city: @city,\n state: @state,\n zipcode: @zipcode,\n lat_lon: {\n lat: @lat,\n lon: @lon\n }\n }\n end", "def stations\n @stations ||= (exact_match? ? parse_station : parse_stations)\n end", "def get_station_names\n\n\t\t# Typhoeus is used to submit http requests\n\n\t\t response = Typhoeus.get(\"http://api.bart.gov/api/stn.aspx?cmd=stns&key=ZZLI-UU93-IMPQ-DT35\")\n\n\t\t # Extract the station names and short names\n\n\t\t response_XML = Nokogiri.XML(response.body)\n\n\t\t @station_names = {}\n\n\t\t # Create a hash list of the station names and abbreviations\n\t\t # node provides the full name of the station and next node is \n\t\t # the abbreviation\n\n\t\t response_XML.xpath(\"//stations/station/name\").each do |node|\n\t\t \t\t@station_names[node.text] = node.next.text\n\t\t end\n\n\t\t return @station_names\n\n\tend", "def show\n @station = Station.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @station }\n end\n end", "def as_json(*)\n {\n JSON.create_id => self.class.name,\n 'y' => year,\n 'm' => month,\n 'd' => day,\n 'H' => hour,\n 'M' => min,\n 'S' => sec,\n 'of' => offset.to_s,\n 'sg' => start,\n }\n end", "def get_data series_id\n\t\traw_output = @fred.series( 'observations', series_id: series_id.to_s)\n\n\t\traw_output.observations.observation\n\tend", "def index\n @duty_stations = DutyStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @duty_stations }\n end\n end", "def workspaces_json\n params.permit(:include_historical)\n params.permit(:time_now)\n include_historical = params.fetch(:include_historical, false)\n time_now = time_now_or_param(params[:time_now])\n query_options = include_historical ? {} : { created_after: SchoolYear.first_day_of_school_for_time(time_now) }\n workspaces = queries.all_authorized_workspaces(query_options)\n\n workspaces_json = workspaces.map do |workspace|\n {\n workspace_id: workspace.workspace_id,\n revisions_count: workspace.revisions_count,\n class_list: workspace.class_list.as_json({\n only: [\n :id,\n :workspace_id,\n :grade_level_next_year,\n :list_type_text,\n :created_at,\n :updated_at,\n :submitted\n ],\n include: {\n created_by_teacher_educator: {\n only: [:id, :email, :full_name]\n },\n revised_by_principal_educator: {\n only: [:id, :email, :full_name]\n },\n school: {\n only: [:id, :local_id, :name]\n }\n }\n })\n }\n end\n\n render json: {\n include_historical: include_historical,\n workspaces: workspaces_json\n }\n end", "def current_observations(lat, lon, options = {})\n station = options.fetch(:station) { nearest_weather_station(lat, lon, options) }\n Services::CurrentObservations.new(options).fetch(station)\n end", "def index\n set_stations_initial_scope!\n\n sort_stations_by_given_distance!\n sort_stations_by_given_criteria!\n\n # Pagination:\n paginate_stations!\n\n # Associations 'current_forecasts' and 'last_measurement' are always eager\n # loaded... however, full data will only be included if using the 'include'\n # parameter:\n eager_load_associations!\n\n respond_to do |format|\n format.json { render json: @stations, fields: json_api_params[:fields], include: params[:include] }\n format.jsonapi { render json: @stations, fields: json_api_params[:fields], include: params[:include], key_transform: :dash }\n end\n end", "def areas_json\n @json = {}\n @json[:id] = self.id\n @json[:country] = self.name\n @json[:country_lat] = self.lat\n @json[:country_lon] = self.lon\n\n @json[:iccas] = []\n self.sites.each do |site|\n site_details = {}\n site_details[:name] = site.name\n site_details[:url] = \"/sites/\" + site.id.to_s\n site_details[:lat] = site.lat\n site_details[:lng] = site.lon\n @json[:iccas] << site_details\n end\n return @json\n end", "def convert_to_JSON(city, response)\n output = JSON.parse(response)\n result = { :city => output['name'],\n :country => output['sys']['country'],\n :temp => output['main']['temp'],\n :format => (settings.is_metric ? \"Celsius\" : \"Farenheit\") }\n result.to_json\nend", "def to_s\n \"<Observation #{self.id}: #{to_plain_s}>\"\n end", "def index\n @estacionamientos = Estacionamiento.all\n\n @json = Estacionamiento.all.to_gmaps4rails\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @estacionamientos }\n end\n end", "def as_json(*)\n {\n FunJSON.create_id => self.class.name,\n 'y' => year,\n 'm' => month,\n 'd' => day,\n 'sg' => start,\n }\n end", "def as_json\n {\n current_player_number: current_player_number,\n squares: squares.as_json,\n hands: hands.map(&:as_json)\n }\n end", "def show\n respond_to do |format|\n format.json { render json: @station, fields: json_api_params[:fields], include: params[:include] }\n format.jsonapi { render json: @station, fields: json_api_params[:fields], include: params[:include], key_transform: :dash }\n end\n end", "def show\n @line_station = LineStation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_station }\n end\n end", "def getRecordJSON()\n return @sObjectRecords\nend", "def get_measurements\n render json: @data_source.measurements\n end", "def affected_station\n Station.get(@attrs['StationCode'])\n end", "def import_observations(station, date)\n self.send(:initialize)\n api_data = self.get_api_data(station, date)\n\n # Check for minutely data\n self.collect_processed_minutely_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_MINUTE\n\n # Check for hourly data\n self.collect_processed_hourly_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_HOUR\n\n # Check for daily data\n self.collect_processed_daily_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_DAY\n\n Rails.logger.debug \"Processed #{self.results[:processed]} observations\"\n Rails.logger.debug \"Created #{self.results[:created]} observations\"\n Rails.logger.debug \"Updated #{self.results[:updated]} observations\"\n Rails.logger.debug \"Skipped #{self.results[:skipped]} observations\"\n Rails.logger.debug \"#{self.results[:failed]} observations failed saving\"\n return self.results\n end", "def station_address\n self['stationAddress']\n end", "def index\n @estates = Estate.all\n @json = @estates.to_gmaps4rails\n respond_with(@estates)\n \n end", "def json_callback\n trending_data = []\n\n # sql join statement to get all trends/locations through the link table\n trend_info = TrendDatum.find_by_sql(\n [\n 'select locations.x as x, locations.y as y, trends.name as name from trend_data\n inner join locations on trend_data.location_id = locations.id\n inner join trends on trend_data.trend_id = trends.id'\n ]\n )\n\n # loop every trend/location and store it in an object in a list\n trend_info.each do |trend_data|\n trend_data_point = TrendingData.new(trend_data.x, trend_data.y, trend_data.name)\n unless trend_data_point.nil?\n trending_data.push trend_data_point\n end\n end\n\n # return list of objects as json\n trending_data.to_json\n end", "def stations\n [\n master_station,\n SLCStationReport.new(@fields[5..9], false),\n SLCStationReport.new(@fields[10..14], false),\n SLCStationReport.new(@fields[15..19], false),\n SLCStationReport.new(@fields[20..24], false),\n SLCStationReport.new(@fields[25..29], false)\n ]\n end", "def fetch_stations\n log(' - Fetching station list...', false)\n results = {}\n response = get_response('https://www.nationalrail.co.uk/static/documents/content/station_codes.csv')\n CSV.new(response, headers: true).each do |row|\n results[row['CRS Code']] ||= {}\n results[row['CRS Code']][:name] = row['Station Name']\n end\n log('DONE')\n results\nend", "def index\n @zones= Zone.all\n\n @polyjson = []\n schoolpoints = []\n @zones.each do |zone|\n CoordinateZone.where(:zone_id => zone.id).each do |point|\n schoolpoints << { :zone => point.zone_id, :lng => point.longitud, :lat => point.latitud}\n end\n end\n # puts \"********schoolpoints***********\"\n # puts schoolpoints.inspect\n\n @polyjson = schoolpoints\n @polyjson = @polyjson.to_json\n end", "def get_api_data(station)\n yield\n end", "def save_observation(observation)\n success = true\n args = {}\n if observation.new_record?\n args[:method] = \"post\"\n args[:action] = \"observation\"\n args[:date] = observation.when\n if observation.location_id\n args[:location] = observation.location\n else\n args[:location] = observation.where\n end\n args[:notes] = observation.notes.to_s\n args[:specimen] = observation.specimen ? true : false\n args[:thumbnail] = observation.thumb_image_id.to_i\n args[:is_collection_location] = observation.is_collection_location\n else\n args[:method] = \"put\"\n args[:action] = \"observation\"\n args[:set_date] = observation.when if observation.when_changed?\n if observation.where_changed? || observation.location_id_changed?\n if observation.location_id\n args[:set_location] = observation.location\n else\n args[:set_location] = observation.where\n end\n end\n args[:set_notes] = observation.notes if observation.notes_changed?\n if observation.specimen_changed?\n args[:set_specimen] = observation.specimen\n end\n if observation.thumb_image_id_changed?\n args[:set_thumbnail] = observation.thumb_image_id.to_i\n end\n args[:set_is_collection_location] = observation.is_collection_location\n end\n if observation.save\n args[:id] = observation\n Transaction.create(args)\n else\n flash_error(:runtime_no_save_observation.t)\n flash_object_errors(observation)\n success = false\n end\n success\n end", "def show\n @observation_details = ObservationDetail.where(observation:@observation)\n end", "def tiny_json\n @small_json ||= Oj.dump(self.ensmallen)\n end", "def json()\n tmp = @plan_ir.map {|plan| plan.json()}\n @tiles = @plan_ir.empty? ? {} : @plan_ir[0].tiles.merge(*@plan_ir[1..].map{|ir|ir.tiles})\n tmp\n end", "def to_serialized_json\n options = {\n include: {\n bird: {\n only: %i[name species]\n },\n location: {\n only: %i[latitude longitude]\n }\n },\n except: [:updated_at]\n }\n @sighting.to_json(options)\nend", "def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end", "def show\n render json: @ozones\n end", "def as_json(*)\n to_ims_tool_proxy\n end", "def show\n @service_station = ServiceStation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_station }\n end\n end", "def show\n @station = Station.find_by! uuid: params[:uuid]\n\n @og = {\n \"og:title\" => @location,\n \"og:type\" => \"train-track:station\",\n \"og:url\" => request.original_url,\n \"og:image\" => \"https://maps.google.com/maps?ll=#{@station.lat},#{@station.lng}&amp;z=15&amp;output=embed\",\n \"og:site_name\" => \"dyl.anjon.es\",\n \"fb:app_id\" => \"272514462916508\",\n \"train-track:crs\" => @station.crs\n }\n\n respond_to do |format|\n format.html\n format.xml { render xml: @station }\n format.json { render json: @station, callback: params['callback'] }\n end\n end", "def show\n pass_query_params\n @observation = find_or_goto_index(Observation, params[:id].to_s)\n return unless @observation\n\n @observations = [\n MinimalMapObservation.new(@observation.id,\n @observation.public_lat,\n @observation.public_long,\n @observation.location)\n ]\n end", "def show\n\n show_metro_stations = (param? params[:metro_stations])\n\n\n render json: @metro_line, \n\n show_metro_stations: show_metro_stations,\n \n include: :metro_stations\n end", "def as_json\n {\n tag_id: tag_id,\n temperature: temperature,\n x_acceleration: x_acceleration,\n y_acceleration: y_acceleration,\n z_acceleration: z_acceleration,\n rssi: rssi,\n timestamp: timestamp.to_i\n }\n end", "def to_json_sub\n to_json_struct.to_json\n end", "def index\n @stations = Station.all\n end", "def to_json\n keys = [\"tsn\", \"unit_name1\", \"parent_tsn\", \"kingdom_id\", \"complete_name\"]\n self.attributes.filter(*keys).to_json\n end", "def show\n @outdoor = Outdoor.find(params[:id])\n @json = Outdoor.find(params[:id]).to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @outdoor }\n end\n end", "def to_serialized_json\n # @sighting.to_json(:include => {\n # :bird => {:only => [:name, :species]},\n # :location => {:only => [:latitude, :longitude]}\n # }, :except => [:updated_at])\n\n# This is still super messy, we could choose to leave it at this point\n# and work with controller (OPTON GO TO CONTROLLER)\n# or we can continue and rework this code\n#To do that, we can create a hash called options\n#This hash will say:\n#\"Include the bird and location I am tied with, only list specific things about each of them\"\n#Also, for me, the sighting object, don't send over the updated_at\noptions = {\n include: {\n bird: {\n only: [:name, :species]\n },\n location: {\n only: [:latitude, :longitude]\n }\n },\n except: [:updated_at],\n }\n @sighting.to_json(options)\n #This looks way cleaner, and does exactly what it did before\n #GO BACK TO CONTROLLER\n\nend", "def index\n @stations = Station.all\n end", "def create\n @asos_datum = AsosDatum.new(asos_datum_params(asos_station))\n\n respond_to do |format|\n if @asos_datum.save\n format.html { redirect_to @asos_datum, notice: 'Asos datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @asos_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @asos_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @tsessionjson= Tsession.find_by_sql [\"SELECT S.subject_name,T.id,C.class_name,\n U.name 'trainer_name',R.room_name,T.start_time,T.end_time, \n T.status, C.start_date, C.end_date, B.building_name, B.description,\n Courses.course_name \n\n FROM (Tsessions as T\n INNER JOIN Subjects as S \n ON(T.subject_id=S.id)\n\n INNER JOIN Training_classes as C \n ON (T.training_class_id=C.id)\n\n INNER JOIN Courses\n ON (Courses.id=C.course_id)\n\n INNER JOIN Rooms as R \n ON(T.room_id=R.id)\n\n INNER JOIN Buildings as B\n ON (B.id=R.building_id)\n INNER JOIN Users as U \n ON (T.user_id=U.id))\n WHERE T.id=?\", \n @tsession.id]\n respond_to do |format|\n format.html # index.html.erb\n format.json {render :json=>{:sessions=>@tsessionjson.first}}\n end\n end", "def station(code)\n Station.get(code)\n end", "def show\n @duty_station = DutyStation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @duty_station }\n end\n end", "def list_observations\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def sightings\n evaluate! if @sightings.nil?\n\n return JSON.dump(@sightings)\n end", "def show\n @station = @property.stations\n end", "def index\n @station_infos = StationInfo.all\n end", "def as_json(*)\n super.slice('latitude', 'longitude',\n 'restore_at', 'address').tap do |hash|\n hash['restore_at'] =\n Time.zone.parse(hash['restore_at']).to_formatted_s(:short)\n end\n end", "def index\n @satellites = Satellite.all\n @sat_json = Satellite.includes(:barrels).map { |sat| sat.as_json.merge({barrels: sat.barrels.as_json}) }\n end", "def datapoint\n # DLM: should this come from the OSW? the osd id and checksum are specified there.\n osd_abs_path = File.join(osw_dir, 'datapoint.osd')\n result = nil\n if File.exist? osd_abs_path\n result = ::JSON.parse(File.read(osd_abs_path), symbolize_names: true)\n end\n return result\n end", "def index\n @workstations = Workstation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workstations }\n end\n end", "def datapoint\n # DLM: should this come from the OSW? the osd id and checksum are specified there.\n osd_abs_path = File.join(osw_dir, 'datapoint.osd')\n result = nil\n if File.exist? osd_abs_path\n result = ::JSON.parse(File.read(osd_abs_path), symbolize_names: true)\n end\n return result\n end", "def show\n @tripJson = []\n @trip.segments.order(:order).each do |segment|\n locations = []\n segment.locations.order(:order).each do |location|\n locations << {:id => location.id, :lat => location.latitude, :lng => location.longitude }\n end\n @tripJson << {:id => segment.id, :transportation => segment.transportation, :locations => locations}\n end\n end", "def data geog_code, geog, stat='.toTable()'\n @json_stats ||={}\n @json_stats[geog_code + geog] ||= OnsOpenApi::request(\"dataset/#{id}\",\n context: context_name,\n geog: geog,\n \"dm/#{geog}\" => geog_code,\n totals: 'false',\n jsontype: 'json-stat')\n\n raw_json_stat = @json_stats[geog_code + geog].gsub(\"\\n\", ' ').gsub(\"'\", \"\").squeeze(' ')\n\n if raw_json_stat.include?('ns1faultstring')\n raise \"ONS Exception: #{raw_json_stat.gsub(/(<.?ns1XMLFault>)|(<.?ns1faultstring>)/,'')}\"\n elsif raw_json_stat.include?('errorMessage')\n raise \"ONS Error: #{raw_json_stat}\"\n end\n\n begin\n table = js_context.eval( %Q| JSONstat( JSON.parse(' #{raw_json_stat} ') ).Dataset(0)#{stat} | )\n rescue Encoding::UndefinedConversionError => e\n if e.to_s[/ASCII-8BIT to UTF-8/]\n raw_json_stat = raw_json_stat.force_encoding('ASCII-8BIT').encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?')\n table = js_context.eval( %Q| JSONstat( JSON.parse(' #{raw_json_stat} ') ).Dataset(0)#{stat} | )\n else\n raise \"#{e.to_s}: #{raw_json_stat}\"\n end\n rescue ExecJS::RuntimeError, ExecJS::ProgramError => e\n raise \"#{e.to_s}: #{raw_json_stat}\"\n end\n\n if table.is_a?(Array) && (index = table[1].index('Segment_1'))\n table.each {|row| row.delete_at(index)}\n end\n table\n end", "def to_json\n @front_end.get_json_string\n end", "def to_json_raw_object()\n #This is a stub, used for indexing\n end", "def list_stations\n Station.all.collect{|obj| obj.name}.sort\n end", "def create\n @observation = Observation.find(params[:observation_id])\n @observer = Observer.new(params[:observer])\n @observer.observation = @observation;\n\n respond_to do |format|\n if @observer.save\n format.html { redirect_to observation_observers_path(@observation), notice: 'Hospitující byl přídán k hospitaci.' }\n format.json { render json: @observer, status: :created, location: @observer }\n else\n format.html { redirect_to new_observation_observer_path(@observation)}\n format.json { render json: @observer.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6266639", "0.59415406", "0.59089315", "0.5828578", "0.57521707", "0.5751328", "0.5745187", "0.57077765", "0.57033914", "0.5675881", "0.5658068", "0.5614545", "0.5517063", "0.54889625", "0.54767823", "0.54497343", "0.54438025", "0.5437412", "0.5387793", "0.53203434", "0.5312849", "0.52794147", "0.5211953", "0.52094483", "0.52052426", "0.520034", "0.51979977", "0.51630664", "0.51612747", "0.51473516", "0.5139461", "0.5135318", "0.5129184", "0.511749", "0.51137143", "0.51009464", "0.50892615", "0.5069648", "0.50659317", "0.5060407", "0.50195026", "0.5014141", "0.49985954", "0.49924955", "0.49846077", "0.49627945", "0.4955791", "0.4948754", "0.4930325", "0.4923297", "0.48960328", "0.48911443", "0.48897535", "0.48876652", "0.48864156", "0.48717543", "0.4866163", "0.48649707", "0.48480538", "0.48455247", "0.4834652", "0.4833627", "0.48325577", "0.48273265", "0.4825461", "0.48244333", "0.48193216", "0.48108736", "0.48106283", "0.47970125", "0.47960937", "0.47906664", "0.47873962", "0.4786432", "0.47825325", "0.47815096", "0.47810745", "0.47726768", "0.47695577", "0.47669956", "0.4763518", "0.47634253", "0.476204", "0.47482055", "0.47409117", "0.47277376", "0.47259173", "0.47247878", "0.47233406", "0.4716603", "0.47136316", "0.47097623", "0.4709692", "0.47074482", "0.47072592", "0.4707033", "0.4705182", "0.4698976", "0.4698478", "0.46950576" ]
0.5382424
19
Given a JSON feed containing a group of BOM observations, along with an Observation, this method will create all necessary Reading records based on ReadingType records.
def parse_readings(json, observation) ReadingType.all.each do |r| reading = Reading.new reading.observation = observation reading.reading_type = r unless json[r.bom_field_name].nil? if r.numeric reading.numeric_value = json[r.bom_field_name].to_d unless json[r.bom_field_name] == '-' else reading.string_value = json[r.bom_field_name] unless json[r.bom_field_name] == '-' end end reading.save end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @readings = []\n lines = Base64.decode64 params[:file].sub('data:text/csv;base64,','')\n solar_readings = lines.split(\"\\n\").reverse\n solar_readings.each do |reading|\n reading = reading.split(\";\")\n begin\n date = DateTime.strptime(reading[0], '%d/%m/%Y')\n @readings << SolarReading.where(date: date).first_or_create.update(kwh: reading[1])\n rescue ArgumentError => e\n logger.error(e.message)\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @readings, callback: params[:callback] }\n format.xml { render xml: @readings }\n end\n end", "def new_reading_new_incidences(pre_reading, reading)\n pre_reading.reading_incidence_types.each do |i|\n ReadingIncidence.create(reading_id: reading.id, reading_incidence_type_id: i.id, created_at: Time.now)\n end\n end", "def read(io)\n begin\n while object = Marshal.load(io)\n type, id, attrs = object\n feed type, id, attrs\n end\n rescue EOFError\n end\n end", "def create\n authorize Reading\n # TODO: REFACTOR: I think some of this can be moved to the model\n # Find all readings based on given params\n # Update all found readings in a transaction\n # Create new readings for all remaining params\n set_readings\n assing_reading_params\n create_objects_for_new_records\n reject_invalid\n select_valid\n\n respons(@rejected.empty?)\n end", "def visit_bp_readings_trail(readings, patient, bp_concepts)\n readings.each_with_object({}) do |reading, trail|\n date = reading.obs_datetime.to_date\n visit = trail[date] || { date: date, sbp: nil, dbp: nil,\n drugs: bp_drugs_received(patient, date),\n note: bp_note_received(patient, date) }\n\n reading_classification = classify_bp_reading(reading, bp_concepts)\n\n # We are only interested in the first reading on a particular day.\n next if visit[reading_classification]\n\n visit[reading_classification] = reading.value_numeric if reading.value_numeric\n\n trail[date] = visit\n end\n end", "def build_enphase_energy_lifetime_daily_readings(eel, body_json)\n values = []\n\n body_json[\"production\"].each_with_index do |stat, i|\n values << [ \n :enphase_user_id => @user_id, \n :system_id => body_json[\"system_id\"], \n :production_enwh => stat, \n :est_date => (Date.parse(body_json[\"start_date\"]) + (i+1)) \n ]\n end\n\n eel.enphase_energy_lifetime_daily_readings.create!(values)\n end", "def addReading(sensor_type = nil, value = nil, location = nil, timestamp = nil)\n\n if @readings == nil\n\n @readings = Array::new\n\n end\n\n if @is_connected\n reading = Reading::new\n\n #serialise object\n reading.client_id = @client_id\n reading.sensor_type = sensor_type\n reading.value = value\n reading.location = location\n reading.timestamp = timestamp\n\n if sensor_type == 1\n @temperature_counter = @temperature_counter + 1\n else\n @acoustic_counter = @acoustic_counter + 1\n end\n\n @readings.push(reading)\n\n end\n\n if ((@readings.count == 10 || !@is_connected) && @readings.count > 0)\n DataReading.insertReadings(@client_id, @readings)\n readings.clear\n end\n\n end", "def save_reading()\n\tStation.all.each do |x|\n\t\tstation_id = x.station_id\n\t\tlat = x.lat\n\t\tlong = x.long\n\t\tlat_long = \"#{lat},#{long}\"\n\t\tforecast = JSON.parse(open(\"#{BASE_URL}/#{API_KEY}/#{lat_long}\").read)\n\t\tr = WeatherReading.new\n\t\tr.build_reading(station_id,lat,long,current_date(forecast),current_time(forecast),current_temperature(forecast),current_dew_point(forecast),\n\t\t\tcurrent_wind_direction(forecast),current_wind_speed(forecast),current_rainfall(forecast),\"forecast.io\")\n\t\tr.save\n\tend\n\nend", "def read\n sensor = nil\n @data.each do |log_item|\n log_values = log_item.split\n if sensor_data?(log_values)\n sensor = create_sensor(log_values)\n else\n create_reading(log_values, sensor)\n end\n end\n end", "def parse_feed(options={})\n document = read_from_file(filename)\n document.extend Hashie::Extensions::DeepFetch\n recommendations = document.deep_fetch('ObjectList', 'Article') { nil }\n\n Array(recommendations).each do |item|\n doi = item['Doi']\n # sometimes doi metadata are missing\n break unless doi\n\n # turn classifications into array with lowercase letters\n classifications = item['Classifications'] ? item['Classifications'].downcase.split(\", \") : []\n\n year = Time.zone.now.year\n month = Time.zone.now.month\n\n recommendation = { 'year' => year,\n 'month' => month,\n 'doi' => doi,\n 'f1000_id' => item['Id'],\n 'url' => item['Url'],\n 'score' => item['TotalScore'].to_i,\n 'classifications' => classifications,\n 'updated_at' => Time.now.utc.iso8601 }\n\n # try to get the existing information about the given work\n data = get_result(db_url + CGI.escape(doi))\n\n if data['recommendations'].nil?\n data = { 'recommendations' => [recommendation] }\n else\n # update existing entry\n data['recommendations'].delete_if { |recommendation| recommendation['month'] == month && recommendation['year'] == year }\n data['recommendations'] << recommendation\n end\n\n # store updated information in CouchDB\n put_lagotto_data(db_url + CGI.escape(doi), data: data)\n end\n end", "def load(records)\n records.map do |h| \n r = WeatherObservation.first_or_create({:weather_station_id => h[:weather_station_id], :date => h[:date]}, h)\n if (r.id.nil?)\n $stderr.puts(\"failed to save #{r.inspect}, #{r.errors.full_messages}\")\n end\n end\n end", "def fetch_observations(station)\n\n scraper_logger.info(\"Fetching latest weather observations for #{station.id} - #{station.name}\")\n\n new = 0\n\n json = extract_observations(station.json_url)\n json['observations']['data'].each do |o|\n\n Time.zone = 'UTC'\n recording_time = Time.zone.parse(\"#{o['aifstime_utc']}Z\")\n\n unless Observation.already_exists?(station, recording_time)\n observation = Observation.new\n observation.station = station\n observation.recording_time = recording_time\n observation.save\n\n parse_readings(o, observation)\n\n new += 1\n\n end\n\n end\n\n scraper_logger.info(\"Added #{new} new observations\")\n\n end", "def batch_create\n uploaded_io = params[:coPilotFile].tempfile\n uploaded_io.set_encoding('iso-8859-1:utf-8')\n\n #Skip a line\n line = uploaded_io.gets\n #event_type = EventType.find(1)\n\n ActiveRecord::Base.transaction do\n while (line = uploaded_io.gets)\n fields = line.split(\"\\t\")\n timestamp = Time.at(convert_excel_timestamp(fields[0]))\n value = -1\n event_type = -1\n should_insert = true;\n comment = fields[36]\n\n if fields[2] == '1'\n #BG reading\n value = Float(fields[11])\n event_type = 1\n current_user.events.create(:eventtype_id => event_type, :value => value, :is_manual => false, :event_time => timestamp, :comment => comment)\n\n elsif fields[2] == '2' && (fields[10] == '0' || fields[10] == '1')\n if fields[26].index(\"Pod activated\") != nil\n #New Pod activated\n value = 0.0\n event_type = 5\n current_user.events.create(:eventtype_id => event_type, :value => value, :is_manual => false, :event_time => timestamp, :comment => \"New Pod Activated\")\n else\n #Basal Rate change\n value = Float(fields[20])\n event_type = 2\n current_user.events.create(:eventtype_id => event_type, :value => value, :is_manual => false, :event_time => timestamp, :comment => comment)\n end\n\n elsif fields[2] == '3' && (fields[10] == '0' || fields[10] == '1')\n #Bolus Intake\n value = Float(fields[20])\n event_type = 3\n comment = (fields[27] + \"<br/>\" + fields[36])\n current_user.events.create(:eventtype_id => event_type, :value => value, :is_manual => false, :event_time => timestamp, :comment => comment)\n\n elsif fields[2] == '5'\n #food intake\n value = Float(fields[21])\n event_type = 4\n current_user.events.create(:eventtype_id => event_type, :value => value, :is_manual => false, :event_time => timestamp, :comment => comment)\n end\n end\n end\n\n redirect_to :controller => 'pages', :action => 'home' and return\n end", "def reading_exists_new_incidences(pre_reading, reading_exists)\n pre_reading.reading_incidence_types.each do |i|\n if !reading_exists.first.reading_incidences.map(&:reading_incidence_type_id).include? i.id\n ReadingIncidence.create(reading_id: reading_exists.first.id, reading_incidence_type_id: i.id, created_at: Time.now)\n end\n end\n end", "def process_and_import(data_file)\n items = JSON.load(File.open(data_file))[\"result\"]\n\n items.each do |item|\n date = item[\"/film/film/initial_release_date\"]\n\n next unless date\n\n case date.length\n when 4\n date = date + \"-01-01\"\n when 7\n date = date + \"-01\"\n end\n\n date = Date.parse(date)\n\n # Query current database so that we backfill/update information if the\n # film already exists\n film = Film.where(\n freebase_id: item[\"/type/object/mid\"]\n ).first\n film = Film.where(\n title: item[\"/type/object/name\"],\n year: date.year\n ).first unless film\n\n film = Film.new unless film\n film.title = valid_item?(item[\"/type/object/name\"]) unless film.title\n film.release_date = valid_item?(date) unless film.release_date\n film.year = date.year unless film.year\n film.freebase_id = item[\"/type/object/mid\"] unless film.freebase_id\n film.freebase_guid = item[\"/type/object/guid\"] unless film.freebase_guid\n film.save\n end\n end", "def read_atom_feed\n last_read = AtomFeedRead.order(\"avalon_last_updated DESC\").first\n page = 1\n timestamp_reached = false\n more_pages = true\n AtomFeedRead.transaction do\n while more_pages && !timestamp_reached\n uri = gen_atom_feed_uri('desc', ITEMS_PER_PAGE, page)\n response = read_uri(uri)\n xml = parse_xml(response)\n total_records = xml.xpath('//totalResults').first.content.to_f # convert to a float so ceiling will work in division\n start_index = xml.xpath('//startIndex').first.content.to_i\n @@logger.info \"\\n\\n\\nProcessing page #{page} of #{(total_records / ITEMS_PER_PAGE).ceil}\\n\\n\\n\"\n if start_index < total_records\n xml.xpath('//entry').each do |e|\n title = e.xpath('title').first.content\n avalon_last_updated = DateTime.parse e.xpath('updated').first.content\n json_url = e.xpath('link/@href').first.value\n avalon_item_url = e.xpath('id').first.content\n avalon_id = avalon_item_url.chars[avalon_item_url.rindex('/') + 1..avalon_item_url.length].join(\"\")\n # the very first read of the atom feed, last_read will be nil so read all pages\n if !last_read.nil? && avalon_last_updated <= last_read.avalon_last_updated\n timestamp_reached = true\n break\n else\n # check if this is an existing record that has been altered in MCO since the last read\n if AtomFeedRead.where(avalon_id: avalon_id).exists?\n AvalonItem.where(avalon_id: avalon_id).update_all(modified_in_mco: true)\n else\n AtomFeedRead.new(\n title: title, avalon_last_updated: avalon_last_updated, json_url: json_url,\n avalon_item_url: avalon_item_url, avalon_id: avalon_id, entry_xml: e.to_s\n ).save!\n end\n end\n end\n more_pages = (start_index + ITEMS_PER_PAGE) < total_records\n page += 1\n end\n end\n end\n end", "def parse_entry(io)\n # Read INSDC or RefSeq entry\n Bio::FlatFile.auto(io).each do |entry|\n @entry = entry\n @features = entry.features\n @source = @features.shift\n parse_sequence\n parse_source\n #parse_genes\n parse_features\n end\n end", "def sc_recorders(file_base, interval, limit)\n recs = []\n\n # Real power loss recorders\n loss_types = {\n 'overhead_line' => 'OHL',\n 'underground_line' => 'UGL',\n 'triplex_line' => 'TPL',\n 'transformer' => 'TFR'\n }\n loss_types.each do |ltype, abbrev|\n # Only set up recorders for classes that actually exist in the feeder\n # (Specifically, R3_1247_2 doesn't have any triplex_lines,\n # and trying to record on class=triplex_line crashes GridLAB-D)\n if @lines.detect {|line| line.is_a?(GLMObject) && line[:class] == ltype}\n recs << new_obj({\n class: 'collector',\n group: \"\\\"class=#{ltype}\\\"\",\n property: 'sum(power_losses.real),sum(power_losses.imag)',\n interval: interval,\n limit: limit,\n file: file_base + abbrev + '_losses.csv'\n })\n end\n end\n\n # Aging_Transformer loss of life and replacements\n # All we really care about is these values at the end of the run,\n # so we'll only collect them once a day to save space\n xfmr_props = {\n 'percent_loss_of_life' => 'pct_lol',\n 'transformer_replacement_count' => 'replacements'\n }\n xfmr_props.each do |prop, abbrev|\n recs << new_obj({\n class: 'group_recorder',\n group: \"\\\"groupid=#{AGING_GROUPID}\\\"\",\n property: prop,\n interval: DAY_INTERVAL,\n limit: limit,\n file: file_base + 'xfmr_' + abbrev + '.csv'\n })\n end\n\n # Also collect power profiles for Aging_Transformers so we\n # can have some sense of why we're seeing what we're seeing\n recs << new_obj({\n class: 'group_recorder',\n group: \"\\\"groupid=#{AGING_GROUPID}\\\"\",\n property: 'power_in',\n complex_part: 'MAG',\n interval: interval,\n limit: limit,\n file: file_base + 'xfmr_va.csv'\n })\n\n # Tap-change recorders\n find_by_class('regulator').each do |reg|\n recs << new_obj({\n class: 'recorder',\n parent: reg[:name],\n property: 'tap_A_change_count,tap_B_change_count,tap_C_change_count,tap_A,tap_B,tap_C,power_in_A.real,power_in_A.imag,power_in_B.real,power_in_B.imag,power_in_C.real,power_in_C.imag,power_out_A.real,power_out_A.imag,power_out_B.real,power_out_B.imag,power_out_C.real,power_out_C.imag,current_in_A.real,current_in_A.imag,current_in_B.real,current_in_B.imag,current_in_C.real,current_in_C.imag,current_out_A.real,current_out_A.imag,current_out_B.real,current_out_B.imag,current_out_C.real,current_out_C.imag',\n interval: interval,\n limit: limit,\n file: file_base + reg[:name][-5..-1] + '.csv'\n })\n end\n\n # Record voltage at the point of use, which conveniently is always\n # a triplex_meter\n recs << new_obj({\n class: 'group_recorder',\n group: 'class=triplex_meter',\n property: \"voltage_12\",\n complex_part: 'MAG',\n interval: interval,\n limit: limit,\n file: file_base + 'v_profile_12.csv'\n })\n\n # Record total PV output, if there is any SC solar to record\n if find_by_class('house').any? {|h| h.nested.any? {|n| n[:groupid] == SC_GROUPID }}\n recs << new_obj({\n class: 'collector',\n group: \"\\\"class=ZIPload AND groupid=#{SC_GROUPID}\\\"\",\n property: 'sum(actual_power.real)',\n interval: MINUTE_INTERVAL,\n limit: limit,\n file: file_base + 'sc_gen.csv'\n })\n end\n\n # Record aggregate SC storage stats, if there's any storage\n unless find_by_four_quadrant_control_mode(SC_CONTROL_MODE).empty?\n recs << new_obj({\n class: 'collector',\n group: \"\\\"class=inverter\\\"\",\n property: 'sum(sc_dispatch_power),avg(battery_soc),std(battery_soc),min(battery_soc),max(battery_soc)',\n interval: MINUTE_INTERVAL,\n limit: limit,\n file: file_base + 'sc_storage.csv'\n })\n end\n\n # Record capacitor switch states, if any\n caps = find_by_class('capacitor')\n unless caps.empty?\n\n prop = caps.map do |cap|\n PHASES.map do |ph|\n \"#{cap[:name]}:switch#{ph}\"\n end\n end.flatten.join ','\n\n recs << new_obj({\n class: 'multi_recorder',\n property: prop,\n interval: interval,\n limit: limit,\n file: file_base + 'cap_switch.csv'\n })\n end\n\n recs\n end", "def parse_feed(options={})\n document = read_from_file(filename)\n document.extend Hashie::Extensions::DeepFetch\n recommendations = document.deep_fetch('ObjectList', 'Article') { nil }\n\n Array(recommendations).each do |item|\n doi = item['Doi']\n # sometimes doi metadata are missing\n break unless doi\n\n # turn classifications into array with lowercase letters\n classifications = item['Classifications'] ? item['Classifications'].downcase.split(\", \") : []\n\n year = Time.zone.now.year\n month = Time.zone.now.month\n\n recommendation = { 'year' => year,\n 'month' => month,\n 'doi' => doi,\n 'f1000_id' => item['Id'],\n 'url' => item['Url'],\n 'score' => item['TotalScore'].to_i,\n 'classifications' => classifications,\n 'updated_at' => Time.now.utc.iso8601 }\n\n # try to get the existing information about the given article\n data = get_result(db_url + CGI.escape(doi))\n\n if data['recommendations'].nil?\n data = { 'recommendations' => [recommendation] }\n else\n # update existing entry\n data['recommendations'].delete_if { |recommendation| recommendation['month'] == month && recommendation['year'] == year }\n data['recommendations'] << recommendation\n end\n\n # store updated information in CouchDB\n put_alm_data(db_url + CGI.escape(doi), data: data)\n end\n end", "def create\n @breadcrumb = 'create'\n @reading_type = ReadingType.new(params[:reading_type])\n @reading_type.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @reading_type.save\n format.html { redirect_to @reading_type, notice: t('activerecord.attributes.reading_type.create') }\n format.json { render json: @reading_type, status: :created, location: @reading_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reading_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def load_objects\n objects = []\n [@opts[:organization_data], @opts[:ticket_data], @opts[:user_data]]\n .zip(['organization', 'ticket', 'user'])\n .map do |file_paths, object_type|\n file_paths.each do |file_path|\n read_objects = JSON.parse File.read(file_path)\n read_objects.each { |o| o['_type'] = object_type }\n objects.concat read_objects\n end\n end\n return objects\n end", "def import_data\n @formatted_data = []\n @customers.shift\n @customers.each do |customer|\n customer_data = {\n name: \"#{customer[0]} #{customer[1]}\",\n emails: [\n {\n type: \"\",\n email: customer[2]\n }\n ],\n phones: [\n {\n type: @home_phone_type,\n phone: customer[4]\n },\n {\n type: @work_phone_type,\n phone: customer[5]\n }\n ],\n type: customer[6],\n birthdayAt: customer[3]\n # socials: [\n # {\n # type: \"\",\n # userid: \"\",\n # username: \"\",\n # url: \"\"\n # }\n # ],\n # urls: [\n # {\n # url: \"\"\n # }\n # ],\n # locations: [\n # {\n # type: \"\",\n # address: \"\"\n # }\n # ],\n # locale: \"\",\n # gender: \"\",\n # tags: [\n # ]\n }\n # p @formatted_data << JSON.pretty_generate(customer_data)\n\n @formatted_data << customer_data\n end\n File.open(\"data.json\",\"w\") do |f|\n f.write(@formatted_data.to_json)\n end\n File.open(\"nojsondata.json\",\"w\") do |f|\n f.write(@formatted_data)\n end\n end", "def create_receipts\n @lines.each_with_index do |line, i|\n # Create new Rceipt\n if line.include?('. « P A R A G O N F I S K A L N Y « ')\n begins_at_line = i - header_length\n @receipt = SaleReceipt.new(sale_id: self.id, begins_at_line: begins_at_line)\n next\n end\n \n # If there are 2 empty lines tell receipt to read itself \n # and search for another receipt\n if @receipt && line.strip.empty? && @lines[i+1].strip.empty?\n @receipt.ends_at_line = i-1\n @receipt.save\n @receipt = nil\n next\n end\n end\n end", "def read()\n #reader = CSV::Reader.create(File.open(\"ctep_agent_list.txt\"))\n reader = CSV::Reader.create(File.open(\"ctep_agent_list_dec_09.txt\"))\n # skip first two rows\n reader.shift\n reader.shift\n \n #id = 1\n id=1306\n count = 1\n catIndex =1;\n catName = 'all0'\n $agents[catName] ||= [ ]\n $cat_order << catName\n reader.each do |row|\n # puts id\n # cat, term, ctep_term, ctep_code = row\n nsc, name = row\n \t\n $agents[catName] << {\n :nsc => nsc.to_i,\n :name => name,\n #:other_required => (agent_name =~ /-Other/ ? '1' : nil), \n :id => id\n }\n \n \tif ( count.modulo(25) == 0 )\n \t\tcatName = 'all' << catIndex.to_s\n \t\tcatIndex +=1\n \t\t$agents[catName] ||= [ ]\n \t\t$cat_order << catName\n \t\t#puts catName\n \tend\n \n id += 1\n count +=1\n end\nend", "def csv\n require 'csv'\n\n unless params[:uploaded_csv].blank?\n csv_path = params[:uploaded_csv].path\n\n # Wipe database on csv load, will need to be modified when event RSS feeds are fixed\n data_validated = false\n begin\n CSV.foreach(csv_path, :headers => true) do |row|\n csv_building = row[1]\n csv_room_number = row[3]\n csv_room_name = row[4]\n csv_department = row[7]\n csv_person_name = row[9] #can be general purpose name like 'general graduate student'\n csv_last_name, csv_first_name = csv_person_name.split(',').map(&:strip)\n\n csv_person_department = row[11] # appears to be less relevant to our needs\n csv_organization = row[12]\n csv_org_code, csv_person_organization = csv_organization.split(' ', 2) # Use this for department\n csv_phone = row[13]\n csv_email = row[14]\n\n # Destroy data only if the first row was parsed successfully\n unless data_validated\n Rails.logger.debug \"[[[[[[ Data validated, wiping db!!! ]]]]]]\"\n Person.destroy_all\n Department.destroy_all\n DirectoryObject.where(type: \"Room\").delete_all\n data_validated = true\n end\n\n # Don't bother with this row if a room number doesn't exist\n if csv_room_number != \"\"\n # Parse Rooms\n results = Room.where(room_number: csv_room_number)\n # Found new room?\n if results.empty?\n room = Room.new\n room.room_number = csv_room_number\n room.save\n else\n room = results.first\n end\n\n # Ensure custom data has not already been set\n # if room.name.blank?\n # room.name = csv_room_name\n # room.save\n # end\n # Parse Department\n # Don't bother with department/person parsing, something is wrong with this row\n unless csv_organization.include?(\"Identity Purged\")\n department = nil\n results = Department.where(title: csv_person_organization.downcase).first\n if results.blank?\n department = Department.new\n if csv_person_organization.present?\n department.title = (csv_person_organization).downcase\n department.save\n else\n logger.info \"entry was missing an organization\"\n end\n else\n department = results\n end\n\n # Parsing Person\n results = Person.where(email: csv_email)\n\n # Found new person?\n if results.empty?\n person = Person.new\n\n # Found existing person?\n else\n person = results.first\n end\n # Ensure room is associated\n if room.present?\n if not person.rooms.include?(room)\n person.rooms << room\n end\n end\n # Ensure department is associated\n # Currently assumes each person has one department, seems to be the case from the data\n if person.department.blank?\n if department.present?\n person.department = department\n end\n end\n person.email = csv_email\n person.phone = csv_phone\n person.first = csv_first_name\n person.last = csv_last_name\n person.save\n end\n end\n end\n\n notice = \"CSV was successfully parsed\"\n rescue\n error = \"CSV file contains invalid data\"\n end\n else\n error = \"Error uploading file\"\n end # unless csv_path.blank?\n\n respond_to do |format|\n format.html {\n redirect_to action: \"index\",\n error: error,\n notice: notice\n }\n end\n end", "def csv\n require 'csv'\n\n unless params[:uploaded_csv].blank?\n csv_path = params[:uploaded_csv].path\n\n # Wipe database on csv load, will need to be modified when event RSS feeds are fixed\n data_validated = false\n begin\n CSV.foreach(csv_path, :headers => true) do |row|\n csv_building = row[1]\n csv_room_number = row[3]\n csv_room_name = row[4]\n csv_department = row[7]\n csv_person_name = row[9] #can be general purpose name like 'general graduate student'\n csv_last_name, csv_first_name = csv_person_name.split(',').map(&:strip)\n\n csv_person_department = row[11] # appears to be less relevant to our needs\n csv_organization = row[12]\n csv_org_code, csv_person_organization = csv_organization.split(' ', 2) # Use this for department\n csv_phone = row[13]\n csv_email = row[14]\n\n # Destroy data only if the first row was parsed successfully\n unless data_validated\n Rails.logger.debug \"[[[[[[ Data validated, wiping db!!! ]]]]]]\"\n Person.destroy_all\n Department.destroy_all\n DirectoryObject.where(type: \"Room\").delete_all\n data_validated = true\n end\n\n # Don't bother with this row if a room number doesn't exist\n if csv_room_number != \"\"\n # Parse Rooms\n results = Room.where(room_number: csv_room_number)\n # Found new room?\n if results.empty?\n room = Room.new\n room.room_number = csv_room_number\n room.save\n else\n room = results.first\n end\n\n # Ensure custom data has not already been set\n # if room.name.blank?\n # room.name = csv_room_name\n # room.save\n # end\n # Parse Department\n # Don't bother with department/person parsing, something is wrong with this row\n unless csv_organization.include?(\"Identity Purged\")\n department = nil\n results = Department.where(title: csv_person_organization.downcase).first\n if results.blank?\n department = Department.new\n if csv_person_organization.present?\n department.title = (csv_person_organization).downcase\n department.save\n else\n logger.info \"entry was missing an organization\"\n end\n else\n department = results\n end\n\n # Parsing Person\n results = Person.where(email: csv_email)\n\n # Found new person?\n if results.empty?\n person = Person.new\n\n # Found existing person?\n else\n person = results.first\n end\n # Ensure room is associated\n if room.present?\n if not person.rooms.include?(room)\n person.rooms << room\n end\n end\n # Ensure department is associated\n # Currently assumes each person has one department, seems to be the case from the data\n if person.department.blank?\n if department.present?\n person.department = department\n end\n end\n person.email = csv_email\n person.phone = csv_phone\n person.first = csv_first_name\n person.last = csv_last_name\n person.save\n end\n end\n end\n\n notice = \"CSV was successfully parsed\"\n rescue\n error = \"CSV file contains invalid data\"\n end\n else\n error = \"Error uploading file\"\n end # unless csv_path.blank?\n\n respond_to do |format|\n format.html {\n redirect_to action: \"index\",\n error: error,\n notice: notice\n }\n end\n end", "def populate\n storage = MultiJson.decode(collection.find_one['boom']) || []\n \n storage['lists'].each do |lists|\n lists.each do |list_name, items|\n @lists << list = List.new(list_name)\n\n items.each do |item|\n item.each do |name,value|\n list.add_item(Item.new(name,value))\n end\n end\n end\n end \n end", "def gather!\n @observations = get_datas!\n @last_observation_at = Observation.last(:select => :observed_at).try(:observed_at)\n collection = @last_observation_at.nil? ? @observations : only_the_ones_we_care_about\n collection.each do |observation|\n o = Observation.create observation\n Observation.logger.info \"created #{o.inspect}\"\n end\n end", "def initialize(uri, factory, parent = nil, json: nil, ld: nil)\n\n # Set properties from the Reading Lists API\n # - this must be called before the superclass constructor so that item details are available\n json = self.set_data(uri, factory, json)\n\n super(uri, factory, parent, json: json, ld: ld)\n\n # Set properties from the Linked Data API data\n set_linked_data(uri, factory, ld)\n\n end", "def insertReadings(client_id, readings)\n\n DataReading.insertReadings(client_id, readings)\n\n end", "def baseline_recorders(file_base, interval, limit)\n recs = []\n\n recs << new_obj({\n class: 'group_recorder',\n file: file_base + 'xfmr_kva.csv',\n group: '\"class=transformer\"',\n property: 'power_in',\n complex_part: 'MAG',\n interval: interval,\n limit: limit\n })\n\n # Climate verification recorder\n recs << new_obj({\n class: 'recorder',\n file: file_base + 'climate.csv',\n parent: find_by_class('climate').first[:name],\n property: 'solar_flux,temperature,humidity,wind_speed',\n interval: interval,\n limit: limit\n })\n end", "def scrape_data_and_create_records link\n\n # Scrapes bracket/game data as JSON \n bracket_json = scrape_bracket link\n games_json = get_games_json bracket_json\n\n create_regions bracket_json\n create_teams games_json\n create_games games_json\n\n end", "def ingestAudioRecording(audiofilename, dateformat) #dateformat should be optional\n # For ingesting the \"Raw\" audio file. Can be cut in to segments later or separately, then imported and connected to the recording node\n \n # Check if a JSON already exists. If so, use it\n # if not, get the metadata, generate the JSON, and use it\n # IF dateformat nil, set it to \"%Y%m%d_%H%M%S%z\" (Double-check this)\n # Mark the STRFTIME format so that the time can be re-parsed from the filename programically\n # Parse JSON metadata\n # Map the JSON to the properties we care about\n # Set name\n # Set date\n # Set location, if it exists\n # Set ingest date to now\n # set ingestedFile to the file\n # set ingestedMetadataFile to the JSON file\n\nend", "def set_up_new_records\n @author_attrs = {x: 1, y: 2}\n @author = TestWriter.new(@author_attrs)\n @post_attrs = {x: 1, y: 2}\n @post1 = TestBlogPost.new(@post_attrs)\n @post2 = TestBlogPost.new(@post_attrs.dup)\n end", "def getReadings(sensor_type)\n\n @readings = Array.new\n\n @readings = DataReading.selectAllClientReadings(@client_id, sensor_type)\n\n\n\n end", "def create\n @breadcrumb = 'create'\n billing_period = BillingPeriod.find @period\n if billing_period #and @pre_readings.where(reading_type_id: 1).empty?\n if @routes.blank?\n meters = Meter.readable_by_center(@centers).includes(:service_points, :subscribers)\n else\n meters = Meter.readable_by_route(@routes).includes(:service_points, :subscribers)\n end\n meters.each do |m|\n reading1 = set_reading_1_to_reading(!m.subscribers.actives.blank? ? m.subscribers.actives.first : nil,m,billing_period)\n\n reading2 = set_reading_2_to_reading(!m.subscribers.actives.blank? ? m.subscribers.actives.first : nil,m,billing_period)\n\n reading_billing_period = m.readings.where(billing_period_id: billing_period.id, reading_type_id: ReadingType::NORMAL)\n prereading_billing_period = m.pre_readings.where(billing_period_id: billing_period.id)\n\n if prereading_billing_period.blank? and reading_billing_period.blank? and !reading1.nil?\n pre_reading = PreReading.new(\n project_id: billing_period.project_id,\n billing_period_id: billing_period.id,\n billing_frequency_id: billing_period.billing_frequency_id,\n reading_type_id: ReadingType::NORMAL,\n meter_id: m.id,\n subscriber_id: m.subscribers.actives.size > 1 || m.subscribers.actives.empty? ? nil : m.subscribers.actives.first.id,\n service_point_id: m.service_points.size > 1 || m.service_points.empty? ? nil : m.service_points.first.id,\n reading_route_id: !m.subscribers.actives.blank? ? m.subscribers.actives.first.reading_route_id : m.service_points.first.reading_route_id,\n reading_sequence: !m.subscribers.actives.blank? ? m.subscribers.actives.first.reading_sequence : m.service_points.first.reading_sequence,\n reading_variant: !m.subscribers.actives.blank? ? m.subscribers.actives.first.reading_variant : m.service_points.first.reading_variant,\n reading_1: reading1,\n reading_2: reading2,\n reading_index_1: reading1.try(:reading_index),\n reading_index_2: reading2.try(:reading_index),\n created_by: (current_user.id if !current_user.nil?)\n )\n pre_reading.save(:validate => false)\n end\n end\n\n # subscribers = Subscriber.where(reading_route_id: @routes).availables.where(\"meter_id IS NOT NULL\").order(&:reading_sequence).group_by(&:reading_route_id)\n # subscribers.each do |subs|\n # subs[1].each do |s|\n\n # # pervious_period_id = BillingPeriod.find_by_period_and_billing_frequency_id(billing_period.previous_period,billing_period.billing_frequency_id).try(:id)\n # reading1 = set_reading_1_to_reading(s,s.meter,billing_period) #Reading.where(subscriber_id: s.id, reading_type_id: ReadingType::NORMAL, billing_period_id: pervious_period_id).first || s.readings.where(reading_type_id: 4).last #s.readings.find_by_reading_type_id(4)\n\n # # pervious_year_id = BillingPeriod.find_by_period_and_billing_frequency_id(billing_period.year_period,billing_period.billing_frequency_id).try(:id)\n # reading2 = set_reading_2_to_reading(s,s.meter,billing_period) #Reading.where(subscriber_id: s.id, reading_type_id: ReadingType::NORMAL, billing_period_id: pervious_year_id).first\n\n # reading_billing_period = s.readings.where(billing_period_id: billing_period.id, reading_type_id: ReadingType::NORMAL)\n # prereading_billing_period = s.pre_readings.where(billing_period_id: billing_period.id)\n\n # if prereading_billing_period.blank? and reading_billing_period.blank? and !reading1.nil?\n # pre_reading = PreReading.new(\n # project_id: billing_period.project_id,\n # billing_period_id: billing_period.id,\n # billing_frequency_id: billing_period.billing_frequency_id,\n # reading_type_id: ReadingType::NORMAL,\n # meter_id: s.meter_id,\n # subscriber_id: s.id,\n # reading_route_id: s.reading_route_id,\n # reading_sequence: s.reading_sequence,\n # reading_variant: s.reading_variant,\n # reading_1: reading1,\n # reading_2: reading2,\n # reading_index_1: reading1.try(:reading_index),\n # reading_index_2: reading2.try(:reading_index),\n # created_by: (current_user.id if !current_user.nil?)\n # )\n # pre_reading.save(:validate => false)\n # end\n # end\n # end\n redirect_to list_pre_readings_path(prereading: { centers: @centers, reading_routes: @routes, period: billing_period.id})\n # redirect_to list_pre_readings_path(billing_period.id, @routes)\n # redirect_to impute_readings_pre_readings_path(prereading: { reading_routes: @routes, period: billing_period.id, project: [billing_period.project_id]})\n else\n redirect_to new_pre_reading_path, alert: t('activerecord.attributes.pre_reading.not_found')\n end\n end", "def generateObjectFromOrder_RYAN(pdfName)\n o={}\n o[:communityType] = 'RyanHomes'\n o[:fileName] = pdfName\n o[:changeOrders] = []\n currentChangeOrderDate = nil\n currentChangeOrderNumber = nil\n tmpChangeOrderObj = nil \n\n reader = PDF::Reader.new(pdfName)\n\n reader.pages.each{|x| #Iterate over each of the pages in the reader\n x.text.split(/\\n/).each{|y| #iterate over each line in the page\n\n if y[\"CHANGE ORDER\"] && y[\"Date:\"] #Does \"CHANGE ORDER\" occur in the string y\n if tmpChangeOrderObj.nil? == false && tmpChangeOrderObj.keys.count > 2\n o[:changeOrders] << tmpChangeOrderObj\n end\n\n currentChangeOrderDate = y.split(\"|\")[1] #we'll change this later for dates\n begin\n currentChangeOrderDate = Date.strptime(currentChangeOrderDate[currentChangeOrderDate.index(\"Date:\")+5...-1].strip,'%m/%d/%Y')\n rescue\n currentChangeOrderDate = \"FAILED TO PARSE DATE\"\n end\n\n currentChangeOrderNumber = y.split(\"|\")[0]\n tmpChangeOrderObj = {} \n tmpChangeOrderObj[:ChangeOrderNumber] = currentChangeOrderNumber\n tmpChangeOrderObj[:ChangeOrderDate] = currentChangeOrderDate\n end\n\n if currentChangeOrderDate.nil? then\n if y[\"KFK\"] #If the current line contains \"KFK\"\n o[:KitchenSink] = \"11444\"\n end\n\n if y[\"KFL\"] #If the current line contains \"KFL\"\n o[:KitchenSink] = \"11600\"\n end\n if y[\"999QK00\"]\n #We’re definately in a color line\n o[:ColorCode] = y.split[8..-1]*\" \"\n end\n\n if y[\"APPLIANCE PKG FREESTANDING\"] #If the current line contains \"freestanding\"\n o[:CooktopCode] = \"freestanding\"\n end\n if y[\"4CB\"] #If the current line contains \"4CB\"\n o[:CooktopCode] = \"jgp329setss\"\n end\n if (y[\"4CC\"]|| y[\"4CF\"]) #If the current line contains \"4CC,4CF\"\n o[:CooktopCode] = \"jgp940sekss\"\n end\n if y[\"4CT\"] #If the current line contains \"4CT\"\n o[:CooktopCode] = \"pgp953setss\"\n end\n\n\n if y[\"FAUCET FIXTURES KITCHEN\"]\n if y[\"UPGRADE\"]\n #Faucet Fixtures Kitchen AND Upgrade\n o[:FaucetSpread] = 'faucet centered, handle 4\" to R, soap 4\" to R of handle' #faucet upgrade\n else\n #Faucet Fixtures Kitchen AND NOT Upgrade\n o[:FaucetSpread] = 'centered' #faucet standard\n end\n end\n else\n #we're in change orders\n if y[\"999QK00\"] \n tmpChangeOrderObj[:ColorCode] = y.split[5...-2]*\" \"\n end\n\n if y[\"APPLIANCE PKG FREESTANDING\"] \n tmpChangeOrderObj[:CooktopCode] = \"freestanding\"\n end\n if (y[\"4CC\"]|| y[\"4CF\"])\n tmpChangeOrderObj[:CooktopCode] = \"jgp940sekss\"\n end\n if y[\"4CB\"]\n tmpChangeOrderObj[:CooktopCode] = \"jgp329setss\"\n end\n if y[\"4CT\"]\n tmpChangeOrderObj[:CooktopCode] = \"pgp953setss\"\n end\n if y[\"KFK\"]\n tmpChangeOrderObj[:KitchenSink] = \"11444\"\n end\n if y[\"KFL\"]\n tmpChangeOrderObj[:KitchenSink] = \"11600\"\n end\n if y[\"9FD\"]\n tmpChangeOrderObj[:FaucetSpread] = \"standard\"\n end\n if y[\"9FE\"]\n tmpChangeOrderObj[:FaucetSpread] = \"upgrade\"\n end\n end\n \n\n }#x.text.split.each\n }#reader.pages.each\n return o\nend", "def gather!\n Observation.prune!\n\n @observations = get_datas!\n @last_observation_at = Observation.select(:observed_at).last.try(:observed_at)\n collection = @last_observation_at.nil? ? @observations : only_the_ones_we_care_about\n collection.each do |observation|\n o = Observation.create observation\n Observation.logger.info \"created #{o.inspect}\"\n end\n end", "def entries\n if @entries.nil?\n raw_entries = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.root_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\",\n \"story\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"story\"\n ])\n ])\n\n # create the individual feed items\n @entries = []\n unless raw_entries.blank?\n for entry_node in raw_entries.reverse\n new_entry = FeedItem.new\n new_entry.feed_data = entry_node.to_s\n new_entry.feed_data_type = self.feed_data_type\n new_entry.root_node = entry_node\n if new_entry.root_node.namespace.blank?\n new_entry.root_node.add_namespace(self.root_node.namespace)\n end\n @entries << new_entry\n end\n end\n end\n \n # Sort the items\n if self.configurations[:entry_sorting_property] == \"time\"\n @entries = @entries.sort do |a, b|\n (b.time or Time.utc(1970)) <=> (a.time or Time.utc(1970))\n end\n elsif self.configurations[:entry_sorting_property] != nil\n sorting_property = self.configurations[:entry_sorting_property]\n @entries = @entries.sort do |a, b|\n eval(\"a.#{sorting_property}\") <=> eval(\"b.#{sorting_property}\")\n end\n else\n return @entries.reverse\n end\n return @entries\n end", "def setup_derived_entry_elements(id_generator)\n @hqmf_id = attr_val('./*/cda:id/@root') || attr_val('./*/cda:typeId/@extension')\n @title = attr_val('./*/cda:code/cda:displayName/@value').try(:titleize)\n @type = attr_val('./*/cda:code/@code')\n @comments = @entry.xpath('./*/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()', HQMF2::Document::NAMESPACES)\n .map(&:content)\n handle_preconditions(id_generator)\n obs_test = attr_val('./cda:measureObservationDefinition/@classCode')\n # If there are no measure observations, or there is a title, then there are no aggregations to extract\n return unless !@title && obs_test.to_s == 'OBS'\n @title = attr_val('../cda:code/cda:displayName/@value')\n @aggregator = attr_val('./cda:measureObservationDefinition/cda:methodCode/cda:item/@code')\n end", "def add_records(records)\n records.each do |r|\n condensed_record = condense_record(r)\n load_atoms(condensed_record)\n add_occurences(condensed_record,r.id)\n @records_size += 1\n end\n end", "def populate\n file = File.new(json_file, 'r')\n storage = Yajl::Parser.parse(file)\n\n storage['lists'].each do |lists|\n lists.each do |list_name, items|\n @lists << list = List.new(list_name)\n\n items.each do |item|\n item.each do |name,value|\n list.add_item(Item.new(name,value))\n end\n end\n end\n end\n end", "def read_objects(file, objects)\n objects.each do |data_type|\n num = DataNumber.new.read(file).data\n\n # use i to indentify the type of object.\n num.times do ||\n _obj = data_type.new.read(file)\n end\n end\n end", "def seed_refund_types\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/refund_types.json'))\n\tdata.each do |d|\n\t\tRefundType.create!(d)\n\tend\nend", "def _do_read(io)\n instantiate_all\n @field_objs.each { |f| f.do_read(io) }\n end", "def insert_line (json, gd_id)\n json.default = [];\n\n # Get the oclc value, look up a str_id for it and write to oclc load file together with the gd_id and marc_field.\n json['oclc'].each do |oclc|\n marc_field = oclc.keys.first;\n val = oclc[marc_field].to_s;\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['oclc'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n # Get the sudoc value, look up a str_id for it and write to sudoc load file together with the gd_id and marc_field.\n json['sudoc'].each do |sudoc|\n marc_field = sudoc.keys.first;\n val = HTPH::Hathinormalize.sudoc(sudoc[marc_field].to_s);\n next if val.nil?;\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['sudoc'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n # ... and so on for isbn, issn, lccn, title, enumc, pubdate and publisher.\n json['isbn'].each do |isbn|\n marc_field = isbn.keys.first;\n val = isbn[marc_field].to_s;\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['isbn'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n json['issn'].each do |issn|\n marc_field = issn.keys.first;\n val = issn[marc_field].to_s;\n next if val.empty?;\n next if val == '1'; # Common crud. Perhaps no longer.\n\n str_id = get_str_id(val);\n @loadfiles['issn'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n json['lccn'].each do |lccn|\n marc_field = lccn.keys.first;\n val = lccn[marc_field].to_s;\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['lccn'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n json['title'].each do |title|\n marc_field = title.keys.first;\n val = HTPH::Hathinormalize.title(title[marc_field]);\n next if val.nil?;\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['title'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n json['enumc'].each do |enumc|\n marc_field = enumc.keys.first;\n val = HTPH::Hathinormalize.enumc(enumc[marc_field]);\n next if val.nil?;\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['enumc'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n json['pubdate'].each do |pubdate|\n marc_field = pubdate.keys.first;\n val = pubdate[marc_field].to_s;\n # Date normalization?\n next if val.nil?\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['pubdate'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\n json['publisher'].each do |publisher|\n marc_field = publisher.keys.first;\n val = HTPH::Hathinormalize.agency(publisher[marc_field]);\n next if val.nil?;\n next if val.empty?;\n str_id = get_str_id(val);\n @loadfiles['publisher'].file.puts(\"#{gd_id}\\t#{str_id}\\t#{marc_field}\");\n end\n\nend", "def parse\n # TODO: Try to convert lsynth parts, maybe flag parts that are troublesome for manual editing,\n # look up to see if I've stored a conversion from ldraw ID to Bricklink ID,\n # convert Ldraw color IDs to BL color IDs, etc.\n parts = {}\n temp_parts = []\n\n @lines.each_with_index do |line, i|\n # This will stop getting parts for the base model once a submodel is reached\n break if line.match(/0 FILE/) && i > 15\n\n @submodels << line.match(/\\w+\\.ldr/).to_s.downcase if line.match(/^1/) && line.match(/\\.ldr$/)\n @lsynthed_parts << line.gsub('0 SYNTH BEGIN', '').split if line =~ /^0 SYNTH BEGIN/\n next unless line.match(/^1/) && line.match(/.dat$/)\n\n part = line.match(/\\w+\\.dat/).to_s.gsub!('.dat', '')\n next if lsynth_part?(part)\n\n color = line.match(/^1\\s\\d+/).to_s.gsub!('1 ', '')\n bl_part = get_bl_part_number(part)\n temp_parts << [bl_part, color, part]\n end\n\n # Now go through all submodels to determine the parts belonging to the submodels\n temp_parts = handle_submodels(temp_parts)\n\n # Not yet functional\n # handle_lsynthed_parts(temp_parts)\n\n temp_parts.each do |info|\n if parts.key?(\"#{info[0]}_#{info[1]}\")\n parts[\"#{info[0]}_#{info[1]}\"]['quantity'] += 1\n else\n parts[\"#{info[0]}_#{info[1]}\"] = {}\n parts[\"#{info[0]}_#{info[1]}\"]['quantity'] = 1\n parts[\"#{info[0]}_#{info[1]}\"]['ldraw_part_num'] = info[2]\n end\n end\n\n parts\n end", "def convert_files\n\n AppLogger.log.info(\"Starting JSON to CSV conversion.\")\n start_time = Time.now\n\n #Load keys from the Tweet Template.\n activity_template_file = @config.tweet_template\n contents = File.read(activity_template_file)\n activity_template = JSON.parse(contents)\n keys_template = Array.new\n keys_template = get_keys(activity_template)\n #Initialize @keys\n @keys = Array.new\n\n #Build header based on these keys.\n header = build_header(keys_template)\n\n #TODO - if we are handling compressed files, unzip, convert, then rezip?\n\n #tour output folder with current UUID and convert files\n\n Dir.glob(\"#{@config.inbox}/*.json\") do |file|\n\n AppLogger.log.debug(\"DEBUG, convert_files: Converting #{File.basename(file)} file...\")\n\n\n csv_filename = \"#{@config.outbox}/#{File.basename(file, \".*\")}.csv\"\n csv_file = File.open(csv_filename, \"w\")\n csv_file.puts header\n\n #This file has one or more activities in it, with a \"info\" footer.\n contents = File.read(file)\n\n activities = []\n\n #Inspect contents and determine the source of the data... Search API, HPT?\n #Markers:\n # Search API: file starts with '{\"results\":[' or '{\"next\":['.\n # HPT: last line is a \"info\" footer.\n # Realtime: contents start with '{\"id\":'. ##Not handling this yet....\n\n if (contents.start_with?('{\"results\":[') or contents.start_with?('{\"next\":'))\n\n json_contents = JSON.parse(contents)\n\n json_contents[\"results\"].each do |activity|\n activities << activity.to_json\n end\n\n elsif contents.include?('\"info\":{\"message\":\"Replay Request Completed\"')\n\n contents.split(\"\\r\")[0..-2].each { |line| #drop last \"info\" member.\n #Dev TODO: just added the \"id\": match, untested\n if line.include?('created_at') or line.include?('postedTime')\n activities << line\n end\n }\n\t\t \n\t else\n\n\t\t contents.split(\"\\n\").each { |line| #drop last \"info\" member.\n\t\t\t#Dev TODO: just added the \"id\": match, untested\n\t\t\tif line.include?('retweetCount') or line.include?('retweet_count')\n\t\t\t activities << line\n\t\t\tend\n\t\t }\n\n end\n\n activities.each { |activity|\n\n begin\n activity_hash = JSON.parse(activity)\n rescue Exception => e\n AppLogger.log.error(\"ERROR in convert_files: could not parse activity's JSON: #{e.message}\")\n end\n\n keys_activity = Array.new\n keys_activity = get_keys(activity_hash)\n\n #Initialize @keys\n @keys = Array.new\n\n #OK, time to compare this activity's payload with the template and grab only the matching keys.\n csv_array = []\n\n keys_template.each { |key_template|\n\n if keys_activity.include?(key_template)\n\n #p \"matched on #{key_template}\"\n\n if @config.arrays_to_collapse.split(',').any? { |item| key_template.include?(item) }\n #p \"NEED TO HANDLE SPECIAL CASE: #{key_template}\"\n data = get_collapsed_array_data(activity_hash, key_template)\n else\n #Go get this data and add it to csv_array\n data = get_data(activity_hash, key_template)\n end\n\n csv_array << data\n else\n csv_array << nil\n end\n }\n\n #Write csv array to CSV.\n csv_activity = CSV.generate do |csv|\n csv << csv_array\n end\n\n csv_file.puts csv_activity.to_s\n }\n\n csv_file.close #Close new CSV file.\n\n\n if (!@config.save_json)\n File.delete(file) #Delete json version.\n else #Move it to 'processed' folder.\n FileUtils.mv(file, \"#{@config.processed_box}/#{file.split('/')[-1]}\")\n end\n end\n\n AppLogger.log.info(\"Finished JSON to CSV conversion. Conversion required #{Time.now - start_time} seconds.\")\n\n end", "def process_events(patient_record, entries)\n patient_record['measures'] = {}\n @measure_importers.each_pair do |measure_id, importer|\n patient_record['measures'][measure_id] = importer.parse(entries)\n end\n\n entries.each_pair do |key, value|\n patient_record[key] = value.map do |e|\n if e.usable?\n e.to_hash\n else\n nil\n end\n end.compact\n end\n\n patient_record\n end", "def process_weekend_activities\n i=0\n while i < 10\n item = {name: weekend_activities[i][:title], value: i+1.to_i} \n \n @processed_weekend << item\n \n i += 1 \n end \n \n end", "def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end", "def initialize(input_file)\n\t\tsuper(input_file)\n\n\t\t@agent_uris = []\n\n\t\t@batch.record_filter = ->(record) {\n\t\t if record['jsonmodel_type'] == 'resource'\n\t\t\trecord['linked_agents'].reject! {|la| !@agent_uris.include?(la[:ref])}\n\t\t else\n\t\t record['names'][0]['source'] = 'import' #add source\n\t\t\t\n\t\t\t#Add the LOC link to the authority_id \n\t\t\trecord['names'][0]['authority_id'] = 'http://id.loc.gov/authorities/names/' + record['names'][0]['authority_id'].gsub(/\\s+/, \"\")\n\t\t\t\n\t\t\t#Remove redundant punctuation ArchivesSpace adds after import\n\t\t record['names'].each do |name|\n\t\t\t\tname.to_hash(:raw).each do |k, v|\n\t\t\t\t\tcase k\n\t\t\t\t\t when 'primary_name'\n\t\t\t\t\t\t name[k] = v.chomp(\",\")\n\t\t\t\t\t\t if record['jsonmodel_type'] == 'agent_corporate_entity'\t\n\t\t\t\t\t\t\tname[k] = v.chomp(\".\")\n\t\t\t\t\t\t end\n\t\t\t\t\t when 'rest_of_name', 'title', 'suffix'\n\t\t\t\t\t\t name[k] = v.chomp(\",\")\n\t\t\t\t\t when 'fuller_form'\n\t\t\t\t\t\t name[k] = v.chomp(\",\").delete('()') \n\t\t\t\t\t when 'dates', 'subordinate_name_1', 'subordinate_name_2', 'qualifier'\n\t\t\t\t\t\t name[k] = v.chomp('.') \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t end\n\t\t \n\t\t return false unless AgentManager.known_agent_type?(record.class.record_type)\n\t\t \n\t\t if (record['jsonmodel_type'] != 'agent_person' && record['jsonmodel_type'] != 'agent_software' && record['jsonmodel_type'] != 'agent_corporate_entity' && record['jsonmodel_type'] != 'agent_family')\n\t\t\treturn true \n\t\t end\n\t\t \n\t\t other = @batch.working_area.find {|rec| (rec['jsonmodel_type'] == 'agent_person' && rec['jsonmodel_type'] == 'agent_software' && rec['jsonmodel_type'] == 'agent_corporate_entity' && rec['jsonmodel_type'] == 'agent_family') }\n\t\t \n\t\t if other then \n\t\t\tfalse\n\t\t else\n\t\t\t@agent_uris << record['uri']\n\t\t\ttrue\n\t\t end\n\t\t}\n\t end", "def get_input_mashable(stories)\n response = JSON.parse(RestClient.get 'http://mashable.com/stories.json')\n response['new'].each do |story|\n story[:title] = story['title']\n story[:category] = story['channel']\n stories << {s_title: story[:title], s_story: story[:category]} \n end \n stories\nend", "def create_avalon_item(json_read_metadata)\n\n end", "def seed_with_rest_client\n api = API.new\n raw_event_data = api.get_flatiron_events\n event_data = api.parse_event_information(raw_event_data)\n event_data.each do |event|\n Event.create(event)\n end\nend", "def _process(tab_id, feed, how_many)\n show_this_many_summaries = how_many # show a summary for every article\n\n processed_feed = []\n if feed.nil?\n return processed_feed \n end\n how_many = how_many - 1\n feed.entries[0 .. how_many ].each {|e|\n\n e_sum = e.summary\n es_len = 0\n unless e_sum.nil?\n es_len = e.summary.length\n end\n\n e_con = e.content\n ec_len = 0\n unless e_con.nil?\n ec_len = e.content.length\n end\n\n if (ec_len == 0) and (es_len == 0)\n e_summary = ''\n else\n if ec_len >= es_len\n e_summary = e_con\n else\n e_summary = e_sum\n end\n end\n\n summary = processed_feed.count < show_this_many_summaries ? (e_summary.nil? ? \"\" : e_summary) : \"\"\n summary = Sanitize.clean(summary, { :attributes => { 'a' => ['href'] }}).strip\n\n if e.title.empty?\n e.title = \"untitled\"\n end\n\n f = { \n 'id' => Digest::MD5.hexdigest(e.url),\n 'feed_title' => feed.title.strip,\n 'title' => Sanitize.clean(e.title).strip,\n 'url' => e.url,\n 'pubdate' => e.published,\n 'summary' => summary\n }\n\n processed_feed << f \n\n # Kick off additional processing with mysql\n _process_mysql(f)\n }\n\n processed_feed\n end", "def process(document, reader)\n input_lines = reader.readlines.to_enum\n Asciidoctor::Reader.new(processed_lines(document, input_lines))\n end", "def add_records(records)\n atoms = {}\n\n records.each do |record|\n next unless @if_proc.call(record)\n\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record, record.id, atoms)\n end\n\n @storage.add(atoms)\n end", "def create\n\n\t\t\t\t\t# attributes\n\t\t\t\t\tbegin\n\t\t\t\t\t\tattrs = jsonapi_received_attributes\n\t\t\t\t\t\tif attrs\n\t\t\t\t\t\t\tif @jsonapi_record\n\t\t\t\t\t\t\t\t# update\n\t\t\t\t\t\t\t\t@jsonapi_record.update! attrs\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t# create\n\t\t\t\t\t\t\t\t@jsonapi_record = jsonapi_model_class.new attrs\n\t\t\t\t\t\t\t\t@jsonapi_record.save!\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\trescue NameError => e\n\t\t\t\t\t\tjsonapi_render_errors 500, \"Model class not found.\"\n\t\t\t\t\t\treturn\n\t\t\t\t\trescue \n\t\t\t\t\t\tjsonapi_render_errors 500, @jsonapi_record.to_jsonapi_errors_hash\n\t\t\t\t\t\treturn\n\t\t\t\t\tend\n\n\t\t\t\t\t# relationships\n\t\t\t\t\tjsonapi_received_relationships.each do |relationship|\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\t# to-one\n\t\t\t\t\t\t\t\tif relationship[:definition][:type] == :to_one\n\t\t\t\t\t\t\t\t\t@jsonapi_record.send :\"#{relationship[:definition][:name]}=\", relationship[:params][:data]\n\t\t\t\t\t\t\t\t\tnext\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t# to-many\n\t\t\t\t\t\t\t\t@jsonapi_record.send(relationship[:definition][:name]).send :clear # initialize the relation\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\trelationship[:params][:data].each do |item|\n\t\t\t\t\t\t\t\t\tobject = relationship[:receiver][:class].find_by_id item[:id]\n\t\t\t\t\t\t\t\t\t@jsonapi_record.send(relationship[:definition][:name]).send :<<, object\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\trescue \n\t\t\t\t\t\t\t# Should not happen\n\t\t\t\t\t\t\tjsonapi_render_errors 500, \"Relationship could not be created.\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tshow\n\t\t\t\tend", "def create\n Reading.create! reading_params\n head :created\n rescue ActiveRecord::RecordInvalid\n head :bad_request\n end", "def create\n @reading_record = ReadingRecord.new(reading_record_params)\n\n respond_to do |format|\n if @reading_record.save\n format.html { redirect_to @reading_record, notice: 'Reading record was successfully created.' }\n format.json { render :show, status: :created, location: @reading_record }\n else\n format.html { render :new }\n format.json { render json: @reading_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_scenario2\n data = [[File.dirname(__FILE__)+'/data/tiny_mushrooms.csv', [\"Edible\"], {'p_value'=> 5.26971e-31, 'confidence'=> 1, 'rhs_cover'=> [0.488, 122], 'leverage'=> 0.24986, 'rhs'=> [19], 'rule_id'=> '000002', 'lift' => 2.04918, 'lhs'=> [0, 21, 16, 7], 'lhs_cover'=> [0.488, 122], 'support' => [0.488, 122]}]]\n\n puts\n puts \"Scenario: Successfully creating local association object:\" \n\n data.each do |filename, item_list, json_rule|\n puts\n puts \"Given I create a data source uploading a \" + filename+ \" file\"\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"And I create an association from a dataset\"\n association = @api.create_association(dataset, {'name'=> 'new association'})\n puts \"And I wait until the association is ready\"\n assert_equal(BigML::HTTP_CREATED, association[\"code\"])\n assert_equal(1, association[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(association), true)\n\n puts \"And I create a local association\"\n local_association = BigML::Association.new(association)\n \n puts \"When I get the rules for %s\" % JSON.generate(item_list)\n\n association_rules = local_association.get_rules(nil, nil, nil, nil, item_list)\n\n puts \"Then the first rule is <%s>\" % json_rule\n assert_equal(association_rules[0].to_json(), json_rule)\n \n end\n\n end", "def recover_data\n subjects = []\n dt = nil\n begin\n File.open('data', 'r') do |file|\n file.each_line do |line|\n next if line.nil?\n if /^[0-9]+\\.[0-9]+/.match(line)\n code, name = line.strip.split('|')\n subj = Subject.new(code, name)\n subjects << subj\n dt = DataExtractor.new(subj)\n elsif /^[A-Z]+$/.match(line)\n dt.handle_event(:comision, line.strip)\n elsif /(Lunes|Martes|Miércoles|Jueves|Viernes|Sábado|Domingo)/.match(line)\n dt.handle_event(:dia, line.strip)\n elsif /^[0-9]+:[0-9]+$/.match(line)\n dt.handle_event(:hora, line.strip)\n end\n end\n end\n File.open('data.json', 'w') do |file|\n file.write(create_subjects_json(subjects))\n end\n rescue StandardError\n puts 'Archivo corrupto.'\n end\n subjects\nend", "def importFromFile(type, json_hash)\n idx = 0\n len = json_hash.length\n json_hash.each do |arr|\n # this is for jason, remove for prod\n if idx > 500\n break\n end\n begin\n type.create(arr)\n idx += 1\n puts \"Added #{idx}/#{len}\"\n rescue => exception\n puts \"Error #{exception}\"\n end\n end\nend", "def newsfeed_summary\n items = []\n extras = []\n booking_lines.each do |booking_item|\n items << {item_id: booking_item.item_id,\n item_unit_cost: booking_item.item_unit_cost,\n item_cost: booking_item.item_cost,\n quantity: booking_item.quantity,\n product_deposit_unit_cost: booking_item.product_deposit_unit_cost,\n product_deposit_cost: booking_item.product_deposit_cost}\n end\n booking_extras.each do |booking_extra|\n extras << {extra_id: booking_extra.extra_id,\n extra_unit_cost: booking_extra.extra_unit_cost,\n extra_cost: booking_extra.extra_cost,\n quantity: booking_extra.quantity}\n end\n {date_from: date_from,\n time_from: time_from,\n date_to: date_to,\n time_to: time_to,\n days: days,\n date_to_price_calculation: date_to_price_calculation,\n items: items,\n extras: extras,\n status: status,\n item_cost: item_cost,\n extras_cost: extras_cost,\n time_from_cost: time_from_cost,\n time_to_cost: time_to_cost,\n pickup_place_cost: pickup_place_cost,\n return_place_cost: return_place_cost,\n driver_age_cost: driver_age_cost,\n total_cost: total_cost,\n total_paid: total_paid,\n total_pending: total_pending,\n booking_amount: booking_amount,\n product_deposit_cost: product_deposit_cost,\n driver_age_deposit: driver_age_deposit,\n total_deposit: total_deposit}\n end", "def generateObjectFromOrder_NV(pdfName)\n o={}\n o[:communityType] = 'NVHomes'\n o[:fileName] = pdfName\n o[:FaucetSpread] = 'faucet centered, soap 8\" to R' #Default faucet spread\n o[:changeOrders] = []\n currentChangeOrderDate = nil\n currentChangeOrderNumber = nil\n tmpChangeOrderObj = nil \n\n reader = PDF::Reader.new(pdfName)\n\n reader.pages.each{|x| #Iterate over each of the pages in the reader\n x.text.split(/\\n/).each{|y| #iterate over each line in the page\n\n if y[\"CHANGE ORDER\"] && y[\"Date:\"] #Does \"CHANGE ORDER\" occur in the string y\n if tmpChangeOrderObj.nil? == false && tmpChangeOrderObj.keys.count > 2\n o[:changeOrders] << tmpChangeOrderObj\n end\n\n currentChangeOrderDate = y.split(\"|\")[1] #we'll change this later for dates\n begin\n currentChangeOrderDate = Date.strptime(currentChangeOrderDate[currentChangeOrderDate.index(\"Date:\")+5...-1].strip,'%m/%d/%Y')\n rescue\n currentChangeOrderDate = \"FAILED TO PARSE DATE\"\n end\n\n currentChangeOrderNumber = y.split(\"|\")[0]\n tmpChangeOrderObj = {} \n tmpChangeOrderObj[:ChangeOrderNumber] = currentChangeOrderNumber\n tmpChangeOrderObj[:ChangeOrderDate] = currentChangeOrderDate\n end\n if currentChangeOrderDate.nil? then\n #if currentChangeOrderDate.nil? then\n #Parse the start date to determine sink\n\n begin\n \ty[\"Contract Date\"] \n o[:contractDate] = Date.strptime(y[y.index(\"Contract Date\")+13..-1].split*\"\", '%m/%d/%Y')\n rescue\n \tcontractDate = \"FAILED TO PARSE DATE\"\n end\n\n if y[\"Set/\"] && o[:houseTypeCode].nil?\n o[:houseTypeCode] = y[y.rindex(\"(\")+1..y.rindex(\"-\")-1]\n end\n if y[\"999QK00\"]\n #We’re definately in a color line\n o[:\"ColorCode\"] = y.split[8..-1]*\" \"\n if y[\"UPDATE\"]\n o[:\"UpdatedColor\"] = y.split[8..-1]*\" \"\n #We’re on a color line *AND* it’s an update\n else\n #We’re on a color line *AND* it’s *NOT* an update\n o[:\"ColorCode\"] = y.split[8..-1]*\" \"\n end\n end\n\n if y[\"APPLIANCE PKG FREESTANDING\"] #If the current line contains \"freestanding\"\n o[:CooktopCode] = \"freestanding\"\n end\n if y[\"4CB\"] #If the current line contains \"4CB\"\n o[:CooktopCode] = \"jgp323setss\"\n end\n if (y[\"4CF\"]||y[\"4CH\"]||y[\"4CQ\"]) #If the current line contains \"4CF,4CH,4CQ\"\n o[:CooktopCode] = \"pgp976setss\"\n end\n if y[\"4CD\"] #If the current line contains \"4CD\"\n o[:CooktopCode] = \"pgp943setss\"\n end\n if y[\"4CP\"] #If the current line contains \"4CP\"\n o[:CooktopCode] = \"zgu385nsmss\"\n end\n if y[\"4CG\"] #If the current line contains \"4CG\"\n o[:CooktopCode] = \"jgp633setss\"\n end\n\n #Parse the Faucet and Sink fixtures from the doc\n if y[\"KFK\"] then \n faucetAndSink = determineFaucetSpreadAndKitchenSink_NV(o[:contractDate], \"KFK\", o[:houseTypeCode])\n o[:FaucetSpread] = faucetAndSink[:FaucetSpread]\n o[:KitchenSink] = faucetAndSink[:KitchenSink]\n end\n if (y[\"KFL\"]|| y[\"KFM\"]) then\n faucetAndSink = determineFaucetSpreadAndKitchenSink_NV(o[:contractDate], \"KFL\", o[:houseTypeCode])\n o[:FaucetSpread] = faucetAndSink[:FaucetSpread]\n o[:KitchenSink] = faucetAndSink[:KitchenSink] \n end\n else\n #we're in change orders\n if y[\"999QK00\"] \n tmpChangeOrderObj[:ColorCode] = y.split[5..-3]*\" \"\n end\n\n if y[\"APPLIANCE PKG FREESTANDING\"] \n tmpChangeOrderObj[:CooktopCode] = \"freestanding\"\n end\n if (y[\"4CF\"]||y[\"4CH\"]||y[\"4CQ\"])\n tmpChangeOrderObj[:CooktopCode] = \"pgp976setss\"\n end\n if y[\"4CB\"]\n tmpChangeOrderObj[:CooktopCode] = \"jgp333setss\"\n end\n if y[\"4CD\"] #If the current line contains \"4CD\"\n tmpChangeOrderObj[:CooktopCode] = \"pgp943setss\"\n end\n if y[\"4CP\"] #If the current line contains \"4CP\"\n tmpChangeOrderObj[:CooktopCode] = \"zgu385nsmss\"\n end\n if y[\"4CG\"] #If the current line contains \"4CG\"\n tmpChangeOrderObj[:CooktopCode] = \"jgp633setss\"\n end\n if y[\"KFK\"]\n tmpChangeOrderObj[:KitchenSink] = \"11409\"\n end\n if (y[\"KFL\"]|| y[\"KFM\"])\n tmpChangeOrderObj[:KitchenSink] = \"k3821-4\"\n end\n \n if y[\"KFK\"] then \n faucetAndSink = determineFaucetSpreadAndKitchenSink_NV(o[:contractDate], \"KFK\", o[:houseTypeCode])\n tmpChangeOrderObj[:KitchenSink] = faucetAndSink[:KitchenSink]\n end\n if (y[\"KFL\"]|| y[\"KFM\"]) then\n faucetAndSink = determineFaucetSpreadAndKitchenSink_NV(o[:contractDate], \"KFL\", o[:houseTypeCode])\n tmpChangeOrderObj[:KitchenSink] = faucetAndSink[:KitchenSink] \n end\n end \n \n }\n }\n return o\nend", "def create_rows\n # Once rows are created from the json_date they cannot be recreated to avoid possible duplication.\n return false if import_rows.size > 0\n rows = JSON.parse(json_data)\n logger.info \"Import File: creating #{rows.count} import rows.\"\n # account for title row\n row_count = 2\n import_errors = []\n added_rows = []\n rows.each do |row|\n # new_row = ImportRow.new(import_file_id: import_file_id, title: row[\"title\"], json_data: row.to_json)\n new_row = ImportRow.new(import_file: self, title: row[\"title\"], json_data: row.to_json)\n logger.info \"Create Rows: creating row #{row_count} with title #{new_row.title}.\"\n if new_row.valid?\n added_rows << new_row\n else\n logger.error \"Create Rows: error on row #{row_count}: #{new_row.errors.full_messages}.\"\n import_errors << { \"Row #{row_count}\": new_row.errors.full_messages.join(\",\") }\n end\n row_count += 1\n end\n import_errors = validate_rows(import_errors,added_rows)\n logger.error \"Create Rows: row creation aborted. #{import_errors.count} validation errors.\"\n if import_errors.empty?\n save_rows(added_rows)\n else\n import_errors << { \"Rows #{row_count-1}\": \"Import rows not created. #{import_errors.count} validation errors.\" }\n end\n #reload\n import_errors\n end", "def processedJsonListener\n allEvents = params[:event]\n eventCounter = 0\n saveCounter = 0\n Event.delete_all\n Address.delete_all\n EventDateTime.delete_all\n\n for event in allEvents\n begin\n newevent = Event.new\n newevent.name = nil_or_string(event[:name])\n newevent.description = nil_or_string(event[:description])\n newevent.imagepath = nil_or_string(event[:imagePath])\n newevent.source = nil_or_string(event[:source])\n newevent.location = nil_or_string(event[:location])\n newevent.datetime = nil_or_string(event[:datetime])\n\n #newevent.dump = nil_or_string(event[:dump])\n\n newevent.price = flatten(event[:pPrice])\n newevent.ptime = flatten(event[:time])\n newevent.pdate = flatten(event[:date])\n\n if newevent.save\n saveCounter+=1\n if event[:addresses][:addresses] != nil and event[:addresses][:addresses].count > 0\n for address in event[:addresses][:addresses]\n newaddy = Address.new\n newaddy.event_id = newevent.id\n newaddy.full_address = nil_or_string(address[:full_address])\n newaddy.city = nil_or_string(address[:city])\n newaddy.region = nil_or_string(address[:region1])\n\n newaddy.save\n end\n end\n if event[:datetime_structs] != nil and event[:datetime_structs].count > 0\n for datetime in event[:datetime_structs]\n eventDate = EventDateTime.new\n eventDate.event_id = newevent.id\n eventDate = setDateTime(eventDate, datetime[:date][:start_date][:full_date], datetime[:time][:start_time], nil_or_string(datetime[:time][:end_time]))\n eventDate.save\n\n\n if datetime[:date][:end_date] != nil and nil_or_string(datetime[:date][:end_date][:full_date]) != nil\n startDate = DateTime.parse(datetime[:date][:start_date][:full_date])\n endDate = DateTime.parse(datetime[:date][:end_date][:full_date])\n endInt = endDate.to_time.to_i\n currDate = startDate+1\n currDateInt = currDate.to_time.to_i\n while currDateInt <= endInt do\n eventDate = EventDateTime.new\n eventDate.event_id = newevent.id\n eventDate = setDateTime(eventDate, currDate, datetime[:time][:start_time], nil_or_string(datetime[:time][:end_time]))\n eventDate.save\n currDate = currDate + 1\n currDateInt = currDate.to_time.to_i\n end\n end\n end\n end\n end\n\n rescue\n #do nothing\n ensure\n eventCounter+=1\n end\n end\n\n statistic = Statistic.new\n statistic.num_sent = eventCounter\n statistic.total_events = saveCounter\n statistic.num_addresses = (Address.count(:all, :group => :event_id)).count()\n \n statsAllEvents = Event.all\n \n statistic.num_pdate = clean_and_count(statsAllEvents.pluck(:pdate))\n statistic.num_ptime = clean_and_count(statsAllEvents.pluck(:ptime))\n statistic.num_price = clean_and_count(statsAllEvents.pluck(:price))\n statistic.save()\n\n responseString = '{\"total\": \"'+eventCounter.to_s+'\", \"saved\":\"'+saveCounter.to_s+'\"}'\n respond_to do |format|\n format.html { render :html => responseString }\n format.json { render :json => responseString }\n \n end\n end", "def retrieve_data\n # Define the url\n url = 'http://www.abc.net.au/radionational/feed/3771046/rss.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Get the author\n regex_author = /<dc:creator>(.*)<\\/dc:creator>/\n regex_author.match(item.to_s)\n author = Regexp.last_match(1)\n\n author = nil if author.eql? ''\n\n # Get categories values\n regex_category = /<category>(.*)<\\/category>/\n\n categories = []\n item.categories.each do |category|\n regex_category.match(category.to_s)\n categories.push(Regexp.last_match(1))\n end\n\n # Make a template dictionary to put @articles\n temp = {\n author: author,\n title: item.title,\n summary: item.description.to_s,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: categories.join(',')\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end", "def create_from_json(json)\n if(json[\"type\"] == \"subject\")\n subject = Subject.new(name: json[\"name\"])\n subject.save\n elsif(json[\"type\"] == \"blog\")\n subject = Subject.find_by(name: json[\"subject\"])\n \n # TODO: Is there a more elegant way of doing this without explicitly\n # assigning everything?\n blog = subject.blogs.new(name: json[\"name\"],\n date_created: json[\"date_created\"],\n content: json[\"content\"],\n tags: json[\"tags\"]\n )\n blog.save\n end\n end", "def test_scenario3\n data = [[File.dirname(__FILE__)+'/data/tiny_mushrooms.csv', [\"Edible\"], {'p_value' => 2.08358e-17, 'confidence'=> 0.79279, 'rhs_cover'=> [0.704, 176], 'leverage' => 0.07885, 'rhs' => [11], 'rule_id' => '000007', 'lift' => 1.12613, 'lhs' => [0], 'lhs_cover' =>[0.888, 222], 'support' => [0.704, 176]}, 'lhs_cover']]\n\n puts \n puts \"Scenario: Successfully creating local association object:\"\n\n data.each do |filename, item_list, json_rule, seach_strategy|\n puts \n puts\n puts \"Given I create a data source uploading a \" + filename+ \" file\"\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"And I create an association from a dataset with search strategy %s\" % seach_strategy\n association = @api.create_association(dataset, {'name'=> 'new association', \n 'search_strategy' => seach_strategy})\n puts \"And I wait until the association is ready\"\n assert_equal(BigML::HTTP_CREATED, association[\"code\"])\n assert_equal(1, association[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(association), true)\n \n puts \"And I create a local association\"\n local_association = BigML::Association.new(association)\n \n puts \"When I get the rules for %s\" % JSON.generate(item_list)\n association_rules = local_association.get_rules(nil, nil, nil, nil, item_list)\n\n puts \"Then the first rule is <%s>\" % json_rule\n assert_equal(association_rules[0].to_json(), json_rule)\n\n end\n end", "def create_import_file_lines(array_of_po_hash)\n fields = [\n 'Sender',\n 'Receiver',\n 'PO Number',\n 'PO Date',\n 'Ship-To Location',\n 'Line Nbr',\n 'Quantity',\n 'Unit Price',\n 'UOM Basis of UOM',\n 'Buyer Item Nbr',\n 'dtl_user_defined_field3',\n 'Delivery Date Requested',\n 'Last Delivery Date Requested'\n ]\n lines = []\n lines << fields\n\n array_of_po_hash.each do |po_hash|\n sender = po_hash[:sender] || Faker::Number.number(12)\n receiver = po_hash[:receiver] || Faker::Number.number(12)\n po_number = po_hash[:number] || Faker::Number.number(10)\n po_date = po_hash[:date] || Time.now.to_date\n ship_to_location =\n po_hash[:ship_to_location] || Faker::Number.number(11)\n\n (1..po_hash[:lines].length).each do |i|\n po_line = po_hash[:lines][i - 1]\n quantity = po_line[:quantity] || 10\n unit_price = po_line[:unit_price] || 100\n item_number = po_line[:buyer_item_number] || Faker::Number.number(9)\n uom = po_line[:uom_basis_of_uom] || 'EA'\n dtl_user_defined_field3 = 1\n\n lines << [\n sender,\n receiver,\n po_number,\n po_date,\n ship_to_location,\n i,\n quantity,\n unit_price,\n uom,\n item_number,\n dtl_user_defined_field3,\n Time.now.to_date,\n Time.now.to_date + 1.day\n ]\n end\n end\n lines\n end", "def scrape_fio_data\n\t# Get all the weather stations\n\tweather_stations = WeatherStation.all\n\t# For each of these weather stations get the forecast\n\tfor weather_station in weather_stations\n\t\tlat_lon = \"#{weather_station.lat},#{weather_station.lon}\"\n\t\tforecast = JSON.parse(open(\"#{BASE_URL}/#{API_KEY}/#{lat_lon}#{UNITS}\").read)\n\t\t# Parse the data which is required\n\t\ttemperature = forecast['currently']['temperature']\n\t\tdew_point = forecast['currently']['dewPoint']\n\t\twind_spd = forecast['currently']['windSpeed']\n\t\twind_dir = forecast['currently']['windBearing']\n\t\train = forecast['currently']['precipIntensity']\n\t\tpersist_data weather_station.name, SOURCEFIO, temperature, dew_point, wind_spd, wind_dir, rain\n\tend\nend", "def demo1\n @feed_entries = []\n \n (4..7).each do |channelnum|\n json_str = Net::HTTP.get(URI.parse(\"http://\" + THINGSPEAK_SERVER + \"/channels/#{channelnum}/feed.json?results=5\"))\n parsed_hash = ActiveSupport::JSON.decode(json_str)\n parsed_hash[\"feeds\"].each do |e|\n entry = {}\n t = Time.strptime(e[\"created_at\"], \"%FT%T%z\")\n entry[\"time\"] = t\n entry[\"created_at\"] = t.strftime(\"%H:%M\")\n entry[\"field1\"] = e[\"field1\"].to_i\n entry[\"field2\"] = e[\"field2\"]\n @feed_entries.push(entry)\n end\n end\n @feed_entries.sort! { |a,b| b[\"time\"] <=> a[\"time\"] }\n end", "def process_file(filename)\n structure = nil\n begin\n structure = JSON.parse( IO.read(filename, encoding:'utf-8') )\n rescue\n print \"Error loading/parsing File: #{$!}\"\n return nil\n end\n begin\n if( structure[\"restaurants\"].count > 0 )\n structure[\"restaurants\"].each do |r_data|\n if( r_data[\"name\"] && r_data[\"rating\"] && r_data[\"meals_qty\"] )\n restaurant = Restaurant.new(r_data[\"name\"],r_data[\"rating\"],r_data[\"meals_qty\"])\n if( r_data[\"specials\"] )\n specials = r_data[\"specials\"]\n specials.each do |special|\n special.keys.each do |key|\n restaurant.addMeal(Meal.new( key, special[key] ))\n end\n end\n end\n addRestaurant(restaurant)\n else\n print \"Restaurant #{r_data} doesn't have minimum data\"\n return\n end\n end\n if( structure[\"order\"] )\n if( structure[\"order\"][\"quantity\"] )\n order_meal = OrderMeal.new(structure[\"order\"][\"quantity\"])\n specials = structure[\"order\"][\"specials\"]\n if( specials )\n specials.each do |special|\n special.keys.each do |key|\n order_meal.addMeal(Meal.new( key, special[key]))\n end\n end\n end\n return finder(order_meal)\n else\n print \"No quantity defined for order.\"\n end\n end\n else\n print \"No restaurantsi defined\";\n return\n end\n rescue\n print \"Error trying to load structure on #{$!}\"\n end\n return\n end", "def create_sample_database\n sample_database = [\n [1, \"Order\", 1484730554, \"{\\\"customer_name\\\":\\\"Jack\\\",\\\"customer_address\\\":\\\"Trade St.\\\",\\\"status\\\":\\\"unpaid\\\"}\"],\n [2, \"Order\", 1484730623, \"{\\\"customer_name\\\":\\\"Sam\\\",\\\"customer_address\\\":\\\"Gecko St.\\\",\\\"status\\\":\\\"unpaid\\\"}\"],\n [1, \"Product\", 1484731172, \"{\\\"name\\\":\\\"Laptop\\\",\\\"price\\\":2100,\\\"stock_levels\\\":29}\"],\n [1, \"Order\", 1484731481, \"{\\\"status\\\":\\\"paid\\\",\\\"ship_date\\\":\\\"2017-01-18\\\",\\\"shipping_provider\\\":\\\"DHL\\\"}\"],\n [2, \"Product\", 1484731671, \"{\\\"name\\\":\\\"Microphones\\\",\\\"price\\\":160,\\\"stock_levels\\\":1500}\"],\n [1, \"Invoice\", 1484731920, \"{\\\"order_id\\\":7,\\\"product_ids\\\":[1,5,3],\\\"status\\\":\\\"unpaid\\\",\\\"total\\\":2500}\"],\n [1, \"Invoice\", 1484732821, \"{\\\"status\\\":\\\"paid\\\"}\"]\n ]\n\n sample_database.each do |(object_id, object_type, timestamp, payload)|\n Event.create(object_id: object_id, object_type: object_type, timestamp: Time.at(timestamp.to_i), payload: JSON.parse(payload))\n end\nend", "def read_feeds(fname, locale, offset)\r\n File.foreach(fname) {|line| xml_feed_entries(line, locale, offset)}\r\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 create\n @reading = Reading.new(params[:reading])\n\n respond_to do |format|\n if @reading.save\n format.html { redirect_to @reading, notice: 'Reading was successfully created.' }\n format.json { render json: @reading, status: :created, location: @reading }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reading.errors, status: :unprocessable_entity }\n end\n end\n end", "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 create_format_types\n formats.each { |type, state| BookFormatType.create name: type, physical: state } \n create_message BookFormatType\nend", "def parse_article_from_file article_file_name\n article_values = {}\n article_values[:content] = ''\n article_values[:introduction] = ''\n article_values[:tags] = []\n article_values[:authors] = []\n article_values[:title] = ''\n article_values[:date] = nil\n article_values[:updated_at] = nil\n next_is = ''\n\n puts \"Parsing: #{article_file_name}\"\n File.open(File.join(ARTICLE_PATH, article_file_name), 'r') do |article_file|\n article_file.each_line do |line|\n next if line.blank?\n ##### Checking what next line will be\n # Detect date\n if line.include?(DATE_DELIMITER)\n next_is = 'date'\n # Detect updated_at date\n elsif line.include?(UPDATED_AT_DELIMITER)\n next_is = 'updated_at'\n # Detect introduction\n elsif line.include?(INTRODUCTION_DELIMITER)\n next_is = 'introduction'\n # Detect content\n elsif line.include?(CONTENT_DELIMITER)\n next_is = 'content'\n elsif line.include?(TAGS_DELIMITER)\n next_is = 'tags'\n elsif line.include?(TITLE_DELIMITER)\n next_is = 'title'\n elsif line.include?(AUTHORS_DELIMITER)\n next_is = 'authors'\n else\n case(next_is)\n when 'date' then article_values[:date] = Time.zone.parse(line.strip)\n when 'updated_at' then article_values[:updated_at] = Time.zone.parse(line.strip)\n when 'introduction' then article_values[:introduction] << line.strip\n when 'content' then article_values[:content] << line\n when 'title' then article_values[:title] << line.strip\n when 'authors' then\n line.strip.split(',').each do |author|\n author.strip! # Removing eventual spaces at the begining or at the end\n article_values[:authors] << Author.where(:name => author).first unless Author.where(:name => author).empty?\n end\n when 'tags' then\n line.strip.split(',').each do |tag_name|\n tag_name.strip! # Removing eventual spaces at the begining or at the end\n # If the tag exists, add it to the list of tags\n if Tag.where(:name => tag_name).empty?\n article_values[:tags] << Tag.create(:name => tag_name)\n else\n article_values[:tags] << Tag.where(:name => tag_name).first\n end\n end\n end\n end\n end\n end\n return article_values\nend", "def batch_retrieve_orders(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/orders/batch-retrieve',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def import_observations(station, date)\n self.send(:initialize)\n api_data = self.get_api_data(station, date)\n\n # Check for minutely data\n self.collect_processed_minutely_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_MINUTE\n\n # Check for hourly data\n self.collect_processed_hourly_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_HOUR\n\n # Check for daily data\n self.collect_processed_daily_data(station, api_data).each do |d|\n self.save(d)\n end if self.supported_periods.include? PERIOD_DAY\n\n Rails.logger.debug \"Processed #{self.results[:processed]} observations\"\n Rails.logger.debug \"Created #{self.results[:created]} observations\"\n Rails.logger.debug \"Updated #{self.results[:updated]} observations\"\n Rails.logger.debug \"Skipped #{self.results[:skipped]} observations\"\n Rails.logger.debug \"#{self.results[:failed]} observations failed saving\"\n return self.results\n end", "def new\n @breadcrumb = 'create'\n @reading = Reading.new\n @projects = projects_dropdown\n @projects_ids = projects_dropdown_ids\n @billing_periods = BillingPeriod.order(\"period DESC\").includes(:billing_frequency).find_all_by_project_id(@projects_ids)\n @subscribers = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reading }\n end\n end", "def feed\n expocodes = params[:expocodes].split(',')\n expocodes = [expocodes] unless expocodes.kind_of?(Array)\n\n @header = []\n @updates = []\n for expocode in expocodes\n @updates += Document.get_feed_documents_for(expocode)\n @updates += Event.get_feed_events_for(expocode)\n @header << \"(#{@updates.last.cruise.Line}) #{expocode}\"\n end\n\n @header = @header.join(',')\n\n @updates.sort do |a, b|\n a.feed_datetime() <=> b.feed_datetime()\n end\n\n respond_to do |format|\n format.atom\n end\n end", "def build_collection_objects_ori\n ce_a1 = ''\n ce_m1 = ''\n ce1 = CollectingEvent.find(1)\n # here we store the attributes of stuff we want to find later\n build_objects = {}\n i = 1 # accounting for headers\n # identifier namespace\n # header0 = csv.headers[0] # should be 'collection_object_identifier_namespace_short_name'\n # header1 = csv.headers[1] # should be 'collection_object_identifier_identifier'\n header5 = csv.headers[5] # should be 'collecting_event_identifier_namespace_short_name'\n header6 = csv.headers[6] # should be 'collecting_event_identifier_identifier'\n header7 = csv.headers[7] # should be 'collecting_event_identifier_type'\n csv.each do |row|\n parse_result = BatchLoad::RowParse.new\n # creation of the possible-objects list\n parse_result.objects[:otu] = []\n parse_result.objects[:co] = []\n parse_result.objects[:td] = []\n parse_result.objects[:ce] = []\n parse_result.objects[:gr] = []\n parse_result.objects[:ce_id] = []\n # attach the results to the row\n @processed_rows.merge!(i => parse_result)\n\n # hot-wire the project into the row\n row['project_id'] = @project_id.to_s if row['project_id'].blank?\n\n co_list = BatchLoad::ColumnResolver.collection_object_by_identifier(row)\n otu_list = BatchLoad::ColumnResolver.otu(row)\n if co_list.no_matches? # no namespace to search!\n parse_result.parse_errors.push('No CollectionObject found with the specified identifier.')\n next\n end\n co = co_list.item # there can be only one\n unless co.collecting_event.nil? # if it exists\n parse_result.parse_errors.push('The specified CollectionObject already has a CollectingEvent.')\n next\n end\n parse_result.objects[:co].push(co)\n otu = otu_list.item if otu_list.resolvable?\n otu = Otu.new(name: row['otu_name']) if otu.blank?\n parse_result.objects[:otu].push(otu)\n long = row['longitude'] # longitude\n lat = row['latitude'] # latitude\n method = row['method']\n error = (row['error'].to_s + ' ' + row['georeference_error_units'].to_s).strip\n ce_namespace = row[header5]\n ns_ce = Namespace.where(short_name: ce_namespace).first\n parse_result.parse_errors.push[\"No available namespace '#{ce_namespace}'.\"] if ns_ce.nil?\n\n begin # processing the TaxonDetermination\n td_attributes = {otu: otu,\n biological_collection_object: co}\n td_match = Digest::SHA256.digest(td_attributes.to_s)\n td = build_objects[td_match]\n td = TaxonDetermination.find_by(td_attributes) if td.nil?\n td = TaxonDetermination.new(td_attributes) if td.nil?\n parse_result.objects[:td].push(td)\n build_objects.merge!(td_match => td)\n end\n\n begin # processing Identifier\n ce_id_attributes = {namespace: ns_ce,\n identifier_object_type: 'CollectingEvent',\n project_id: @project_id,\n type: 'Identifier::' + row[header7],\n identifier: row[header6]}\n ce_id_match = Digest::SHA256.digest(ce_id_attributes.to_s)\n ce_id = build_objects[ce_id_match]\n ce_id = Identifier.find_by(ce_id_attributes) if ce_id.nil?\n ce_id = Identifier.new(ce_id_attributes) if ce_id.nil?\n parse_result.objects[:ce_id].push(ce_id)\n build_objects.merge!(ce_id_match => ce_id) # whichever way we came by it, save the item in our stash\n end\n\n co.collecting_event = ce\n i += 1\n end\n @total_lines = i - 1\n end", "def index\n @reading_records = ReadingRecord.all\n end", "def seatgeek_import(overwrite = false)\n response = seatgeek_schedule\n records = []\n response['events'].each do |event|\n venue = event['venue']\n records << Event.import(\n {\n import_key: \"https://api.seatgeek.com/2/events?id=#{event['id']}\",\n event_name: event['title'],\n description: \"#{venue['name']} (#{venue['display_location']})\",\n entity_id: id,\n start_time: \"#{event['datetime_utc']}+00:00\",\n date_tba: event['date_tbd'],\n time_tba: event['time_tbd']\n }, overwrite\n )\n end\n records\n rescue StandardError => e\n logger.info e.message\n return e.message\n end", "def create_for(record:)\n Rails.logger.info \"[zizia] event: record_import_started, batch_id: #{batch_id}, collection_id: #{collection_id}, record_title: #{record.respond_to?(:title) ? record.title : record}\"\n\n created = import_type.new\n attrs = process_attrs(record: record)\n actor_env = Hyrax::Actors::Environment.new(created,\n ::Ability.new(depositor),\n attrs)\n\n if Hyrax::CurationConcern.actor.create(actor_env)\n Rails.logger.info \"[zizia] event: record_created, batch_id: #{batch_id}, record_id: #{created.id}, collection_id: #{collection_id}, record_title: #{attrs[:title]&.first}\"\n csv_import_detail.success_count += 1\n # CU Boulder export of new generated URL and use Replaces to generate a map from Bepress to Samvera redirects\n new_url = work_url(created.id,attrs[:admin_set_id])\n open(Rails.root.join('tmp',\"load_batch#{batch_id}_processed.out\"), 'a') do |f|\n f << \"#{batch_id} , #{created.id} , #{new_url} , #{attrs[:replaces]} , #{attrs[:title]&.first} \\n\"\n end\n replace= \"#{attrs[:replaces]}\"\n if Rails.env.production?\n save_cybercom(replace.split('|')[0],replace.split('|')[1],new_url)\n end\n else\n # Log Errors for batch import\n open(Rails.root.join('tmp',\"load_batch#{batch_id}_errors.out\"), 'a') do |f|\n f << \"=========================================\\n\"\n created.errors.each do |attr, msg|\n Rails.logger.error \"[zizia] event: validation_failed, batch_id: #{batch_id}, collection_id: #{collection_id}, attribute: #{attr.capitalize}, message: #{msg}, record_title: record_title: #{attrs[:title] ? attrs[:title] : attrs}\"\n f << \"ValidationError: batch_id: #{batch_id}, collection_id: #{collection_id}, attribute: #{attr.capitalize}, message: #{msg}, record_title: record_title: #{attrs[:title] ? attrs[:title] : attrs}\\n\"\n end\n f << \"=========================================\\n\"\n end\n csv_import_detail.failure_count += 1\n end\n csv_import_detail.save\n end", "def import_resources\n # for each resource type, look for a file of measurement data\n Report.plugin_matrix.each do |resource_name, measurements|\n model = Object.const_get((resource_name + 'Resource').camelcase(:upper))\n model.unrestrict_primary_key\n iterate_lines(@directory + resource_name + '.json') do |idx, line|\n print \"\\rImporting #{resource_name}: #{idx}...\"\n\n resource = JSON.parse(line)\n resource.each do |key, value|\n value = update_date(value, @date_offset)\n resource[key] = value unless value.nil?\n end\n model.create(resource)\n end\n model.restrict_primary_key\n print \"Done\\n\"\n import_measurements(measurements)\n end\n end", "def new\n @breadcrumb = 'create'\n @reading_type = ReadingType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reading_type }\n end\n end", "def parse\n\n puts \"==> invoked: #parse\"\n\n {\n # raw_feed: @feed_hash,\n information: @information,\n amenities: @amenities,\n floorplan: @floorplan,\n file: @file,\n }\n end", "def create\n id = nil\n params.each_key{|key| key.to_s.match(\"read_edition_[0-9]*\").nil? ? nil : id = key.to_s.split(\"_\").last}\n unless id.nil?\n parameters = params[:reading][id][:end_read].nil? ? params[:reading][id].merge({:end_read => Time.now}) :\n params[:reading][id]\n\n else\n parameters = params[:reading][:end_read].nil? ? params[:reading].merge({:end_read => Time.now}) :\n params[:reading]\n end\n @reading = Reading.new(parameters)\n @user = User.find(parameters[:reader_id])\n @edition = Edition.find(parameters[:read_edition_id])\n\n unless @user.nil? || @edition.nil?\n\n respond_to do |format|\n if @reading.save\n format.html { redirect_to(@user, :flash => { :success => \"Le livre #{@edition.book.title} a été marqué comme lu\"}) }\n format.xml { head :ok }\n else\n format.html { redirect_to(@user, :flash => { :error => \"Problème avec l'action, veuillez réésayer plus tard\"}) }\n format.xml { render :xml => @reading.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to(root_url, :flash => { :error => \"L'utilisateur ou le livre est invalide\" }) \n end\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', '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 parse # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n xml = @datastream\n feed_records = xml.xpath('/ACLSExport/acls')\n feed_records.each do |fr|\n subscriber = Individual.new(fr.xpath('email').text)\n subscriber.lastname = fr.xpath('lastname').text\n subscriber.firstname = fr.xpath('firstname').text\n subscriber.phone = fr.xpath('phone').text\n\n lease = Lease.new(@product, subscriber)\n fr.xpath('expirationdate').text\n exp = fr.xpath('expirationdate').text.split('-')\n next unless Date.valid_date?(exp[0].to_i, exp[1].to_i, exp[2].to_i)\n\n expiration_date = Date.parse(fr.xpath('expirationdate').text)\n lease.authorize if Date.today < expiration_date\n lease.expire(expiration_date)\n end\n end", "def create_items_for(restaurant)\n puts \"================================== Creating Items, Categories, and ItemCategories for #{restaurant.name}\"\n filename = restaurant.slug.gsub(/-\\d+/, '')\n contents = CSV.open \"./db/seed/items/#{filename}-items.csv\", headers: true, header_converters: :symbol\n\n contents.each do |row|\n print \".\"\n title = row[:title]\n description = row[:description]\n category = row[:category]\n price = row[:price]\n image_file_name = row[:image_file_name]\n\n # create category\n category_object = Category.find_or_create_by(title: category, type_of: 'main_menu')\n\n # create item\n item = Item.create!(\n title: title,\n description: description,\n price: price,\n image_file_name: image_file_name,\n restaurant_id: restaurant.id\n )\n \n ItemCategory.create!(category_id: category_object.id, item_id: item.id)\n end\nend", "def from_org_io(io, **types)\n table_re = /\\A\\s*\\|/\n hrule_re = /\\A\\s*\\|[-+]+/\n rows = []\n table_found = false\n header_found = false\n io.each do |line|\n unless table_found\n # Skip through the file until a table is found\n next unless line.match?(table_re)\n\n unless line.match?(hrule_re)\n line = line.sub(/\\A\\s*\\|/, '').sub(/\\|\\s*\\z/, '')\n rows << line.split('|').map(&:clean)\n end\n table_found = true\n next\n end\n break unless line.match?(table_re)\n\n if !header_found && line =~ hrule_re\n rows << nil\n header_found = true\n next\n elsif header_found && line =~ hrule_re\n # Mark the boundary with a nil\n rows << nil\n elsif !line.match?(table_re)\n # Stop reading at the second hline\n break\n else\n line = line.sub(/\\A\\s*\\|/, '').sub(/\\|\\s*\\z/, '')\n rows << line.split('|').map(&:clean)\n end\n end\n from_array_of_arrays(rows, hlines: true, **types)\n end", "def each\n return if empty?\n\n @record_index = -1\n with_record_stream do |stream|\n mapper = org.codehaus.jackson.map.ObjectMapper.new\n parser = mapper.getJsonFactory.createJsonParser(stream)\n\n while parser.nextToken\n @record_index += 1\n\n if @deleted_entries.get(@record_index)\n # Skip this entry\n parser.skipChildren\n else\n result = parser.readValueAs(java.util.Map.java_class)\n yield result\n end\n\n skip_comma(parser)\n end\n\n unless @count\n @count = @record_index + 1\n end\n end\n end", "def import_from_default_json!\n Dir[EXPORT_DIR + \"*.json\"].each do |filename|\n json = JSON.parse(File.read(filename))\n voice_assistant = find_or_create_voice_assistant_from(json)\n\n # import entity types into the voice assistant\n json['entity_types'].select{|et| et['analyzer_id'].blank? }.each do |et|\n entity_type = voice_assistant.entity_types.find{|et2| et2.name == et['name'] } #inception hell - sorry\n unless entity_type\n entity_type = Epiphany::EntityType.create(name: et['name'], voice_assistant_id: voice_assistant.id)\n end\n\n #refreshes entity items\n entity_type.entity_items.destroy_all\n et['entity_items'].each do |ei|\n next if Epiphany::EntityItem.exists?(name: ei['name'], entity_type_id: entity_type.id,\n variations: ei['variations'], metadata: ei['metadata'])\n\n Epiphany::EntityItem.create(name: ei['name'], entity_type_id: entity_type.id,\n variations: ei['variations'], metadata: ei['metadata'])\n end\n end\n\n # import analyzers\n json['analyzers'].each do |a|\n et = a.dig('entity_type')\n entity_type = voice_assistant.entity_types.find{|et2| et2.name == et['name'] }\n unless entity_type\n entity_type = Epiphany::EntityType.create(name: et['name'], voice_assistant_id: voice_assistant.id)\n end\n\n analyzer = voice_assistant.analyzers.find{|an| an.name == a['name'] }\n unless analyzer\n analyzer = Epiphany::Analyzer.create(name: a['name'], voice_assistant_id: voice_assistant.id,\n entity_type_id: entity_type.id, rules: a['rules'])\n end\n\n entity_type.update(analyzer_id: analyzer.id)\n end\n\n #import intents\n json['intents'].each do |intent|\n next if intent['name'].blank?\n\n _intent = voice_assistant.intents.find{|__intent| __intent.name == intent['name'] }\n unless _intent\n _intent = Epiphany::Intent.create(name: intent['name'], voice_assistant_id: voice_assistant.id,\n rules: intent['rules'])\n else\n _intent.update(rules: intent['rules'])\n end\n end\n\n #import training phrases\n json['training_phrases'].each do |phrase|\n next if phrase['phrase'].blank?\n\n _phrase = voice_assistant.training_phrases.find{|__phrase| __phrase.phrase == phrase['phrase'] }\n unless _phrase\n _phrase = Epiphany::TrainingPhrase.create(phrase: phrase['phrase'], voice_assistant_id: voice_assistant.id,\n metadata: phrase['metadata'])\n else\n _phrase.update(metadata: phrase['metadata'])\n end\n end\n end\n puts 'import complete'\n end" ]
[ "0.5236031", "0.50617695", "0.50402725", "0.4994088", "0.48664123", "0.48345155", "0.47930834", "0.47810516", "0.47340125", "0.47205272", "0.46971118", "0.46683747", "0.4653783", "0.4649695", "0.46401024", "0.4635319", "0.4583495", "0.4558224", "0.45501173", "0.45426437", "0.4536411", "0.45039135", "0.44836444", "0.4472921", "0.44588754", "0.44588754", "0.44526288", "0.44494003", "0.44138202", "0.44049826", "0.43995416", "0.43947318", "0.43840986", "0.43796355", "0.43677965", "0.43478996", "0.43425587", "0.43392485", "0.43313754", "0.43288296", "0.4328225", "0.4299663", "0.4297104", "0.4295894", "0.4294647", "0.42876744", "0.42859113", "0.4279208", "0.42786068", "0.42780367", "0.42745784", "0.42724785", "0.42688087", "0.42683303", "0.42654654", "0.4264245", "0.4260348", "0.42579547", "0.424812", "0.4243408", "0.42408276", "0.42361912", "0.4233278", "0.4232966", "0.423212", "0.42282307", "0.4224606", "0.42233902", "0.42211646", "0.42186245", "0.42170832", "0.42114124", "0.4204398", "0.42036775", "0.41947708", "0.41932932", "0.41698977", "0.4169763", "0.41663817", "0.41638678", "0.41538304", "0.41479945", "0.41459277", "0.41405517", "0.413845", "0.4134823", "0.41289985", "0.41286263", "0.41134205", "0.41120023", "0.4111638", "0.4111467", "0.41114593", "0.41113862", "0.41039577", "0.40996596", "0.409745", "0.40957144", "0.40939543", "0.40922046" ]
0.73365414
0
Welcome_email is a eMail sent to the Channel Admin, after setting up the channel and contains the Sec_Hash
def welcome_email(channel) @channel = channel @url = 'http://example.com/login' mail(to: @channel.email, subject: 'Welcome to your Constructeev Channel') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def welcome_email\n # User welcome email sent.\n end", "def welcome_email(user, currenthost)\n\t @user = user\n\t @currenthost = currenthost\n\n\t mail(to: @user.email, subject: 'Welcome to Changefindr').deliver()\n\tend", "def welcome_email\n UserMailer.welcome_email\n end", "def welcome_email\n UserMailer.welcome_email\n end", "def welcome_email\n NotifierMailer.welcome_email User.take\n end", "def send_welcome_email(user)\n mail to: user.email, subject: \"Sign Up Confirmation - Welcome to NetworkMill\"\n Email.create(:user_id => user.id, :sent_to => user.email, :title => \"welcome_email\")\n end", "def welcome_email\n # NewsletterMailer.welcome_email.deliver\n mail(:to => \"rajakuraemas@gmail.com\", :subject => \"Welcome to My Awesome Site\")\n end", "def send_welcome\n UserMailer.welcome_email(self).deliver!\n end", "def send_welcome_email\n UserMailer.welcome(self).deliver_now\n end", "def send_welcome\n UserMailer.welcome_email(self).deliver\n end", "def welcome_email\n \t@user = params[:user]\n \t@url = 'https://recipeapp-mysticflower.herokuapp.com'\n \tmail(to: @user.email, subject: 'Welcome to My Awesome Site')\n \tend", "def welcome_email(email, trial_duration)\n\n @trial_duration = trial_duration\n @email = email\n\n mail :to => email, :subject => \"Welcome to Urbanzeak!\", from: \"Urbanzeak <notifications@urbanzeak.com>\"\n\n headers['X-MC-Track'] = \"opens\"\n headers['X-MC-Tags'] = \"Welcome Email\"\n end", "def send_welcome_email\n UserMailer.welcome_message(self).deliver_later\n end", "def send_welcome_mail\n UserMailer.welcome(self).deliver_now\n end", "def welcome_email(user,password,option = nil)\n @user = user\n @password = password\n @option = option\n @url = 'http://example.com/login'\n mail(to: @user.email, subject: 'Welcome to My Awesome Site')\n end", "def welcome_mail(user)\n mail to: user.email,\n subject: \"Welcome to Startglory\"\n\n end", "def welcome_email(user)\n @user = user\n @url = 'http://example.com/login' #\n mail(to: @user.email, subject: 'Welcome to My Awesome Site') #gets user email address and supplies a generic subject line\n end", "def send_welcome(user)\n @user = user\n mail(:to => user.email, :subject => \"Welcome to My Awesome Site\", :content_type => 'text/html', :template_name => 'send_welcome.html')\n end", "def welcome_email(user)\n @user = user\n @signin_url = \"http://www.lacquerloveandlend.com/auth/facebook\"\n \n mail(to: @user.email, subject: 'Welcome to Lacquer Love&Lend!', bcc: \"lacquerloveandlend@gmail.com\")\n\n headers['X-MC-Track'] = \"opens, clicks_all\"\n end", "def send_welcome_email\n CandidateMailer.welcome_candidate(self).deliver_now\n end", "def welcome(user)\n @user = user\n\n mail(to: user.email,\n cc: \"goodo73@gmail.com\", \n subject: \"[AFL Finals Sharemarket] Welcome to the AFL Finals Sharemarket website\")\n end", "def welcome_email\n UserMailer.with(user: @user).welcome_email.deliver_later\n end", "def welcome_email(user)\n\t\t# We get the user\n\t\t@user = user\n\t\t# Wedefine the website url\n\t\t@url = 'http://share-square.herokuapp.com/users/sign_in' \n\t\t#We send a welcome email every time a user signs up\n\t\tmail(to: @user.email, subject: \"Bienvenue sur Share Square\")\n\tend", "def send_email\n UserMailer.with(:password => self.manual_password, :user_email => self.email).welcome_email.deliver_now\n end", "def welcome_send\n UserMailer.welcome_email(self).deliver_now\n end", "def welcome_email(user)\n @user = user\n @url = 'http://buydeis.herokuapp.com/login'\n mail(to: @user.email, subject: 'Welcome to buydeis')\n end", "def welcome\n # only admin can send emails like these\n if !@current_user.is_admin?\n respond_with_403 and return\n end\n \n \n if @user.is_active == 0\n flash[:error] = \"Please Activate this Agent before sending welcome email.\"\n else\n UserNotifier::deliver_user_created(@user, @user.save_new_password)\n flash[:notice] = 'Welcome email has been sent.'\n end\n \n \n redirect_to user_path\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 welcome_email(user)\n @user = user\n @url = 'http://example.com/login'\n mail(to: @user.email, subject: 'Welcome to my Pair BNB! ')\n end", "def welcome_email email_address\n @greeting = \"Hi\"\n @user_name = UserInfo.last.user\n\n mail to: email_address\n end", "def welcome_email(user)\n @user = user\n @subject = \"Welcome to Rays Cruiser, home of customized cruisers\"\n result = mail(:to => @user.email, :subject => @subject)\n # puts \"+++++++ Notification Email status: -> \" + result.to_s\n end", "def welcome_user_email(user)\n @user = user\n @url = login_url\n mail(\n :subject => \"Welcome to StudyHall\",\n :from => \"noreply@studyhall.com\",\n :to => @user.email\n )\n end", "def send_activation_notification\n deliver_activation_email(:activation, :subject => (MaSA[:welcome_subject] || \"Welcome\" ))\n end", "def welcome_email(user)\n\t\t@user = user\n\t\t@url = 'http://example.com/login'\n\t\tmail(to: @user.email, subject: 'Welcome to My Awesome Site')\n\n\t\t# from = Email.new(email: 'test@example.com')\n\t\t# subject = 'Hello World from the SendGrid Ruby Library!'\n\t\t# to = Email.new(email: 'test@example.com')\n\t\t# content = Content.new(type: 'text/plain', value: 'Hello, Email!')\n\t\t# mail = Mail.new(from, subject, to, content)\n\n\t\t# sg = SendGrid::API.new(api_key: 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)\n\t\t# response = sg.client.mail._('send').post(request_body: mail.to_json)\n\t\t# puts response.status_code\n\t\t# puts response.body\n\t\t# puts response.headers\n\tend", "def instauser_welcome_email(user_id)\n @user = Instauser.find_by(id: user_id)\n @url = 'http://example.com/login'\n mail(to: @user.email, subject: 'Welcome to Capish!')\n end", "def welcome_email(user)\n\t\t@user = user\n\t\tmail(to: user.email.to_s, subject: \"Welcome to Interest Points\")\t\n\tend", "def group_welcome_email\n NotifierMailer.group_welcome_email Group.take\n end", "def welcome\n UserMailer.welcome\n end", "def welcome\n @user = params[:user]\n @token = @user.send(:set_reset_password_token)\n mail(to: @user.email, subject: 'Welcome to Swiss Hockey Tool')\n end", "def welcome_email(student)\n @student = student\n @url = 'http://clarionLibrary.com/login'\n mail(to: @student.email, subject: 'Welcome In Clarion library')\n end", "def welcome_email(user)\n \t@user = user\n\n \tmail :to\t\t=> user.email,\n \t\t :subject\t=> \"Welcome to Project Help!\"\n end", "def welcome_email(user)\n @user = user\n\n mail to: user.email, subject: 'Welcome to Alumni Connection!', from: 'WebMaster@AlumniConnection.com'\n end", "def activation_welcome\n PharmacistMailer.activation_welcome\n end", "def confirmation_email(user)\n # email header info MUST be added here\n @recipients = user.email\n @from = \"#{Site.current.email}\"\n @subject = \"SIR Information:: Welcome to SIR\"\n\n # email body substitutions go here\n @body[\"name\"] = user.login\n @body[\"hash\"] = user.activation_code\n end", "def welcome(user)\n\n mail to: user.email, subject: \"Welcome to Teamhuddle\"\n end", "def send_mail\n User.send_welcome_email(self.id)\n end", "def welcome_email(user)\n @greeting = \"Hi\"\n\n mail to: user.email\n end", "def welcome_email(user)\n @user = user\n mail(to: @user.email, subject: t(\"users.email.welcome.subject\"))\n end", "def send_welcome_newsletter\n WelcomeNewsletterJob.set(wait: 10.seconds).perform_later(@newsletter_user, @newsletter_setting)\n end", "def welcome_email(user)\n @user = user\n @url = \"http://vex.herokuapp.com/users/sign_in\"\n mail(to: user.email, subject: \"Welcome to the new way to experience Vex\")\n end", "def welcome_email(user)\n @user = user\n mail( to: user.email,\n subject: 'Thanks for signing up for Shiftable!',\n sent_on: Time.now )\n end", "def welcome_email(params)\n @user = params\n mail(to: @user.email,subject:\"Bienvenido a Mone Apps\")\n end", "def welcome_email(user)\n @user = user\n mail to: @user.email, subject: 'Welcome to Our Jungle Store'\n end", "def welcome(user, password)\n @greeting = \"Hi\"\n @email = user.email\n @password = password\n\n mail to: user.email\n end", "def welcome_email\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def send_welcome_email\n return if Rails.env.test?\n\n user = self\n Resque.enqueue(WelcomeEmailJob, user)\n # UserMailer.welcome_email(self).deliver\n end", "def welcome_information(user)\n @account = user\n mail(:to => named_email(user), :subject => \"Liveplus - Welcome\")\n end", "def send_welcome_email\n UserMailer.delay.welcome_email(self)\n end", "def welcome_email(user,password)\n \t@user = user[\"name\"]\n \t@email = user[:email]\n \t@password=password\n \t@url = \"http://localhost:3000/users/sign_in\"\n \tmail(to: @email, subject:\"Login your account\")\n end", "def welcome_email(user)\n @user=user\n @url = \"http://strong-flower-5407.heroku.com/\"\n mail(:to => user.person.email, :subject => \"Welcome to my Scripting Application\")\n end", "def user_welcome_reminder(user,subject,message)\n @from = \"REIMatcher <no-reply@reimatcher.com>\"\n @recipients = user.email\n @subject = \"#{subject}\"\n @sent_on = Time.now\n user_activation_link = \"#{REIMATCHER_URL}user_activate/#{user.activation_code}\"\n unless message.blank?\n @body = message.to_s.gsub(\"[User Email]\",user.email.to_s).gsub(\"[User First Name]\",user.first_name.to_s).gsub(\"[User Last Name]\",user.last_name.to_s).gsub(\"[User Login]\",\"<a href='#{user.login.to_s}'>#{user.login.to_s}</a>\").gsub(\"[User Full Name]\",user.first_name.to_s + \" \" + user.last_name.to_s).gsub(\"[User Activation Link]\",\"<a href='#{user_activation_link}'>#{user_activation_link}</a>\")\n else\n @body = \"\"\n end\n @content_type = \"text/html\"\n reminder_welcome_email_header = {:category => EMAIL_CATEGORIES[:ar]}\n @headers[\"X-SMTPAPI\"] = reminder_welcome_email_header.to_json unless reminder_welcome_email_header.blank?\n# @headers[\"X-SMTPAPI\"] = header\n end", "def welcome(email)\n @greeting = \"Hi\"\n\n mail to: email, subject: \"Email template\"\n end", "def welcome_email(user,random_password)\n @user = user\n @random_password = random_password\n \n mail(:to => user.email, :subject => \"Registration email\")\n end", "def welcome(user)\n #def welcome(email)\n @appname = \"Birdy's golf store\"\n mail( :to => user.email,\n #mail( :to => email,\n :subject => \"Welcome to #{@appname}!\")\n end", "def new_user_welcome(user_id)\n @user = User.find(user_id)\n\n mail :to => recipient(@user.email), :subject => \"Welcome to 25c!\"\n end", "def welcome_email(user)\n @user = user\n email_with_name = \"#{@user.name} <#{@user.email}>\"\n @url = \"http://mejoramigo.herokuapp.com/login\"\n mail(:to => user.email, :subject => \"Bienvenido a MejorAmigo\")\n end", "def branduser_welcome_email(user_id)\n @user = Branduser.find_by(id: user_id)\n @url = authenticate_brandusers_url(token: @user.auth_token)\n mail(to: @user.email, subject: 'Welcome to Capish!')\n end", "def welcome\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def welcome_email(user_info)\n @email = user_info[:mail]\n @name = user_info[:name]\n mail(:to => @email, :subject => \"تم تأكيد تسجيلك في !\")\n end", "def welcome(user)\n @user = user\n @greeting = \"Hi\"\n mail(to:\"nithyarajar@gmail.com\", sub:\"Welcome to Devfolio\")\n end", "def welcome_email(user)\n\n @user = user\n Rails.logger.info 'hello'\n emails = ['leolopelofranco@gmail.com', 'leo@palmsolutions.co']\n\n mail(to: user[\"to\"], subject: user[\"subject\"])\n\n end", "def user_welcome_notice(user)\n @user = user\n mail(:to => @user.email, :subject => \"Welcome to SocialStreet\") unless @user.email.blank?\n end", "def welcome_signup_email(signup)\n @signup = signup\n mail(\n :subject => \"We will be coming to your school soon!\",\n :from => \"noreply@studyhall.com\",\n :to => @signup.email\n )\n end", "def new_home\n @greeting = \"Email Sent!!!\"\n\n mail to: \"lilyw.416@gmail.com\"\n end", "def welcome(cust)\n @customer = cust\n @name = cust.email.split('@').first\n # @password = params[:customer][:password]\n @token = Rails.application.message_verifier('customer').generate(cust.id)\n\n # mail to: user.email\n # mail to: \"checking@gmail.com\"\n mail(to: @customer.email, subject: 'Welcome to new BetaStore Site')\n\n\n\n\n\n # @greeting = \"Hi\"\n\n # mail to: \"to@example.org\"\n end", "def activation_needed_email(user)\n @user = user\n @url = \"http://lvh.me:3000/users/#{user.activation_token}/activate\"\n mail(:to => user.email,\n :subject => \"Welcome to StackClown\")\n end", "def welcome(user)\n @user = user\n @greeting = \"Hi\"\n\n mail to: \"thomasjyang@gmail.com\", :subject => \"Awesome subject for welcome\"\n end", "def welcome(user)\n @the_new_user_who_signed_up = user\n\n mail to: user.email, from: \"jeff@startergrill.com\"\n end", "def welcome(customer)\n \n mail(:to => customer.email, \n \n :subject => \"welcome mate!\"\n )\n \n end", "def send_password\n UserMailer.welcome(self).deliver\n end", "def after_confirmation # Send welcome mail after user is successfully registered\n send_user_mail\n end", "def resend_welcome\n return forbidden unless current_account.admin?\n\n account = current_organization.accounts.find(params[:id])\n LifecycleMailer.login_instructions(account, current_organization, current_account).deliver_now\n json nil\n end", "def welcome(user)\n @appname = \"Oasis Books\"\n mail( :to => user.email,\n :subject => \"Welcome to #{@appname}!\")\n end", "def welcome\n InformationMailer.welcome\n end", "def greeting\n @greeting = \"Hi\"\n\n mail to: \"dmanishchenko@gmail.com\", subject: 'Invitation to Allianz Community'\n end", "def welcome(user)\n @user = user\n mail to: @user.email, from: \"welcome@theshoplift.com\"\n end", "def welcome(user)\n @user = user\n \n mail to: @user.email, subject: \"[Post] Welcome! Thanks for signing up.\"\n end", "def signup_email\n @greeting = \"Hi\"\n\n mail to: @user.email, subject: \"Welcome to CheeseBae! Please confim your email!\"\n end", "def welcome(user)\n @user = user\n mail(to: @user.email, subject: \"Welcome to DevPoint Labs!\")\n end", "def welcome(user)\n @user = user\n \n mail(:to => user.email, :subject => \"Registered\")\n end", "def weekly_email\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def send_password(clear_password) \n self.password = Digest::SHA1.hexdigest(self.password_salt.to_s + clear_password)\n self.save\n \n Mailer.deliver_message(\n {:recipients => self.email,\n :subject => \"Your Expertiza password has been reset\",\n :body => {\n :user => self,\n :password => clear_password,\n :first_name => ApplicationHelper::get_user_first_name(self),\n :partial_name => \"send_password\" \n }\n }\n )\n \n end", "def welcome_email(resource)\n \n @resource = resource\n\n mail :to => @resource.email, :from => \"email@domain.com\", :subject => \"Subject line\"\n \n end", "def welcome(user)\n @user = user\n mail to: @user.email\n end", "def activation_success_email(user)\n @user = user\n @url = \"http://lvh.me:3000/login\"\n mail(:to => user.email,\n :subject => \"Your account at Stackclown is now activated\")\n end", "def send_welcome_mail(user_id)\n @user = User.find(user_id)\n mail(:to => \"<#{@user.email}>\", :subject => \"Welcome to HACKMAI, #{@user.username}!\")\n end", "def welcome(user)\n @greeting = \"Hi #{user.fullname}\"\n\n mail to: \"#{user.email}\"\n end", "def welcome(url,shopname,email,password)\n\t@url = url\n\t@shopname = shopname\n\t@email = email\n\t@password= password\n mail(:to =>@email, :subject => \"Some one wnat to contact us \")\n# mail to: \"sharmavikrant14@gmail.com\"\n end", "def welcome_provider(user)\n\t\t@user = user\n\t\t@profile = user.profile\n\t\tsendgrid_category :stripe_connect_welcome_provider\n\t\t@show_logo = true\n\t\tsubject = \"You're all set to accept online payments on Kinstantly\"\n\t\tmail to: user.email, subject: subject\n\tend", "def welcome_email(user_id, token)\n @token = token\n @user = User.find(user_id)\n @account = @user.account\n mail to: @user.email, subject: \"Bienvenido a la cuenta Folio de #{@account.name}\"\n end" ]
[ "0.7122097", "0.7005587", "0.69214004", "0.69214004", "0.68974185", "0.6884443", "0.68843615", "0.68599933", "0.6839519", "0.6827258", "0.6815871", "0.68025696", "0.6710657", "0.66929525", "0.66835964", "0.6652146", "0.66480637", "0.66356033", "0.66262025", "0.6588923", "0.6581635", "0.6574595", "0.6568338", "0.6562971", "0.6562236", "0.6546256", "0.6531633", "0.6524846", "0.65016943", "0.649376", "0.6493052", "0.6462001", "0.64599884", "0.6453343", "0.6448911", "0.6448653", "0.64468586", "0.642357", "0.6418483", "0.64084214", "0.6407524", "0.640035", "0.6399314", "0.6397019", "0.6389912", "0.63782465", "0.6372959", "0.6372596", "0.63718075", "0.63693744", "0.6368469", "0.6358159", "0.6351057", "0.6334295", "0.63284564", "0.6325368", "0.63170874", "0.63000774", "0.6283775", "0.62624043", "0.62616", "0.62528455", "0.6244791", "0.6243411", "0.6235489", "0.62296104", "0.622446", "0.6210356", "0.6209418", "0.61753404", "0.61720514", "0.61708105", "0.6155856", "0.6131521", "0.61302644", "0.6129843", "0.6129229", "0.61266834", "0.61193925", "0.6104773", "0.6101588", "0.609769", "0.6094922", "0.609091", "0.60848266", "0.60844696", "0.6082285", "0.6081234", "0.606191", "0.6060055", "0.60564977", "0.60559714", "0.6053059", "0.60211307", "0.60157996", "0.5995231", "0.5982363", "0.59704936", "0.595626", "0.5949145" ]
0.78109956
0
receive post and email that feedback
def send_feedback @message = params[:message] @subject = params[:subject] if Staff.feedback_email(current_user, @subject, @message).deliver redirect_to root_path, notice: t("flash.feedback_sent") else render action: "feedback", alert: t("flash.feedback_failed") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_post_notification(post)\n @post = post\n @post = post\n @poster = post.poster\n if @post.post_needs.size == 0\n @post_needs = []\n else\n @post_needs = @post.post_needs.alphabetical\n end\n recipients = @post.notify_emails\n\n if recipients != \"\"\n mail(:to => recipients, :subject => 'New Request at ' + post.street_1)\n end\n end", "def new_post(post)\n @greeting = \"Hello! There has been a new post to your discussion on \" + post.discussion.topic + \" at rubydark.herokuapp.com. Please sign in to view the post.\"\n\n mail to: post.discussion.user.email\n end", "def feedback\n NotebookMailer.feedback\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 feedback\n NewsletterMailer.feedback\n end", "def work(raw_post)\n email_params = JSON.parse(raw_post).with_indifferent_access\n send_simple_message(params)\n ack! # we need to let queue know that message was received\n end", "def new_post(post)\n @user = post.wall_user\n @post = post\n\n mail to: @user.email, subject: \"Someone just posted on your wall.\", reply_to: post.poster.email\n end", "def new_post_notification(post)\n #author\n reciever = User.find_by_id post.user_id\n setup_email(reciever)\n @subject +=\"Новый пост в вашем сообществе\"\n body[:url] = RAILS_URL + \"posts/show/#{post.id}\"\n body[:post] = post\n end", "def received_feedback(feedback)\n @feedback = feedback\n\n mail :to => \"yahivin@gmail.com\", :reply_to => feedback.email_address || (feedback.user ? feedback.user.email : nil)\n end", "def feedback\n SystemMailer.user_feedback(current_user, params[:type], params[:message]).deliver!\n return_message(200, :ok)\n end", "def notice_post\n @greeting = \"Hi\"\n\n mail to: \"dan5.ya+bukt@gmail.com\"\n end", "def commented(post)\n @post = post\n @greeting = \"Hi\"\n\n mail to: 'barvis.fuchschittehr@gmail.com'\n nd\n\n # Subject can be set in your I18n file at config/locales/en.yml\n # with the following lookup:\n #\n # en.post_mailer.deleted.subject\n #\n def deleted\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end\n\n # Subject can be set in your I18n file at config/locales/en.yml\n # with the following lookup:\n #\n # en.post_mailer.updated.subject\n #\n def updated\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end\nend", "def postmark\n @program_acceptance = ProgramAcceptance.where(message_id: params[:MessageID]).first\n if @program_acceptance\n note = case params[:RecordType]\n when \"Delivery\" then \"Acceptance email delivered to #{params[:Recipient]}.\"\n when \"Bounce\" then \"Acceptance email not delivered to #{params[:Recipient]}.\\n\\n> #{params[:Description]}\"\n when \"SpamComplaint\" then \"Acceptance email to #{params[:Recipient]} flagged as spam.\"\n when \"Open\" then \"Acceptance email opened.\"\n when \"Click\" then \"Link clicked in acceptance email.\"\n end\n @program_acceptance.person.notes.create note_type: \"email-event\", message: note, data: request.request_parameters\n end\n head :ok\n end", "def notify(recipient, users_posts)\n \n\n @recipient = recipient\n @posts = users_posts\n # @post = post\n # @creator = creator\n # @group = group\n # @post_name = post.title\n # @post_desc = post.description\n #attachments[\"\"]\n mail(:to => recipient.email, :subject => \"New Stuff Today\")\n end", "def user_send_feedback\n\t\t# send feed back to the admin\n\t\tif UserMailer.feedback(current_user,params[:feedback_text]).deliver_now\n\t\t# response to the JSON\n \t render json: { success: true, message: \"Feedback has sent successfully\" },:status=> 200\n\t else\n\t render :json=> { success: false, message: \"problem with sending feedback\" },:status=> 203\n\t end\t\n\tend", "def receive(email)\n post = Post.new\n\n # Will fail if no matches. Rely on validation\n list_post_header = email.header_string(\"List-Post\")\n matches = list_post_header.match(/<mailto:(\\S+)@/) if list_post_header\n if matches\n mailing_list_name = matches[1]\n else\n mailing_list_name = email.to.first.to_s\n end\n post.mailing_list = MailingList.find_by_name(mailing_list_name)\n\n post.subject = email.subject\n \n if email.multipart?\n plain_text_part = nil\n\n # Outlook\n related_part = email.parts.find { |part| \n part.content_type == \"multipart/related\"\n }\n if related_part\n alt_part = related_part.parts.find { |part| \n part.content_type == \"multipart/alternative\"\n }\n else\n alt_part = email.parts.find { |part| \n part.content_type == \"multipart/alternative\"\n }\n end\n \n # OS X rich text email\n if alt_part \n plain_text_part = alt_part.parts.find { |part| \n part.content_type == \"text/plain\"\n }\n end\n\n plain_text_part = email.parts.find { |part| \n part.content_type == \"text/plain\"\n } unless plain_text_part\n \n plain_text_part = email.parts.find { |part| \n part.content_type == \"text/html\"\n } unless plain_text_part\n \n post.body = plain_text_part.body\n end\n \n if post.body.blank?\n post.body = email.body\n end\n \n post.from_name = email.friendly_from\n post.from_email_address = email.from\n post.date = email.date\n begin\n post.save!\n rescue => save_error\n RACING_ON_RAILS_DEFAULT_LOGGER.error(\"Could not save post: #{save_error}\")\n if post and !post.errors.empty?\n RACING_ON_RAILS_DEFAULT_LOGGER.error(post.errors.full_messages)\n end\n raise\n end\n end", "def record_submit(content)\n @greeting = content\n\n mail to: \"superacidjax@me.com\", :subject => 'New Submit Arrived'\n end", "def post_announcement\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/announcements/#{@announcement.id}\")\n mail to: @user.email, subject: \"[bootcamp] #{@announcement.user.login_name}さんからお知らせです。\"\n end", "def new_feedback(name, email, hear, can_publish, held, message)\n\t\t@name = name\n\t\t@email = email\n\t\t@message = message\n\t\t@hear = hear\n\t\t@can_publish = can_publish\n\t\t@held = held\n\t\t# Mail it to/from/subject\n\t\tmail(to: 'info@tailordevents.com', from: @email, subject: 'Message from ' + @name)\n\tend", "def send_feedback(email,name,text)\n @email = email\n @name = name\n @text = text\n mail to: \"grandison@mail.ru\", :subject => \"Feedback from email: #{email}, name: #{name}\"\n end", "def new_feedback\n UserMailer.new_feedback\n end", "def new_post_mail\n UserNotifierMailer.new_post_mail\n end", "def send_admin_review_email\n Mailer.admin_review_email(user, content, business, rating).deliver\n end", "def send_feedback_to_slack\n send_request_to_slack(make_positive_response)\n end", "def feedback\n end", "def new_post_mail(user, post)\n @user = user\n @post = post\n mail(to: @user.email, subject: 'Un nuevo post ha sido creado ')\n end", "def submitted(talk)\n @talk = talk\n @greeting = \"your talk has been subitted\"\n\n mail to: \"tnordloh@gmail.com\", subject: @greeting\n end", "def micropost_notification(poster, follower, micropost)\n @greeting = \"Hi\"\n @follower = follower\n @micropost = micropost\n @poster = poster\n\n mail to: follower.email, subject: \"New Tweet!\"\n \n end", "def post(message)\n puts message\n end", "def submitted\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/products/#{@product.id}\")\n mail to: @user.email, subject: \"[bootcamp] #{@message}\"\n end", "def sub_post\n page(NavTabBarPage).select_storytab(\"Reply\")\n page(SubmissionPage).create_post(\"reply post\")\n page(NavTabBarPage).flag_handler(\"Cancel\")\n page(SubmissionPage).touch_discard\n end", "def item_feedback\n to = params[:patron_email] + ', ' + params[:staff_email]\n from = \"Item Feedback <#{params[:staff_email]}>\"\n title = params[:bib_record].title\n subject = \"Item Feedback [#{title}]\"\n mail(to: to, from: from, subject: subject)\n end", "def create\n # store that comment for later mailer delivery and channel broadcasting\n comment = @post.comments.create! comments_params\n\n # mailer deliver later\n CommentsMailer.submitted(comment).deliver_later\n\n # render to page in real time using websocket channels\n CommentsChannel.broadcast(comment)\n\n redirect_to @post\n end", "def comment_received(comment)\n# @greeting = \"Hi\"\n @comment = comment\n\n mail :to => \"sandorafoods@gmail.com\"\n end", "def feedback\n\t\t@submission = Submission.find(params[:submissionFeedback][:id])\n\t\t@assessment = Assessment.find(@submission.assessment_id)\n\t\t# if the assessment exists\n\t\tif @assessment\n\t\t\tuser = User.find(@assessment.user_id)\n\t\t\t@creator = user.Fname + \" \" + user.Lname\n\t\tend\n\t\t@submission.send_feedback(params[:submissionFeedback][:Feedback], @creator, @assessment)\n\t\tredirect_to '/submissions/'+params[:submissionFeedback][:id]\n\t\tflash[:info] = 'Feedback was successfully sent.'\n\tend", "def ask_post\n page(MorePage).select_more_actions(\"Ask HN\")\n page(MorePage).page_handler(\"Ask HN\")\n page(FeedDetailsPage).touch_row\n page(NavTabBarPage).select_storytab(\"Reply\")\n page(SubmissionPage).create_post(\"reply post\")\n page(NavTabBarPage).flag_handler(\"Cancel\")\n page(SubmissionPage).touch_discard\n page(SubmissionPage).await\n page(MorePage).backpage\n page(MorePage).page_handler(\"Ask HN\")\n page(MorePage).backpage\n end", "def email(defn, participant, assignment)\n defn[:body][:type] = \"Teammate Review\"\n participant = AssignmentParticipant.find(reviewee_id)\n topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id)\n defn[:body][:obj_name] = assignment.name\n user = User.find(participant.user_id)\n defn[:body][:first_name] = user.fullname\n defn[:to] = user.email\n Mailer.sync_message(defn).deliver\n end", "def post_state_change_confermation(post)\n @greeting = \"Hi\"\n @post = post\n mail to: post.email, subject: \"Post's state changed!\"\n end", "def admin_review_email(user, content, business, rating)\n @user = user\n @content = content\n @business = business\n @rating = rating\n mail(:to => \"consigndotnyc@gmail.com\", :subject => \"New Review on CONSIGN.NYC\")\n end", "def mail; 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 do_new_post_feed\n if not verify_recaptcha\n flash[:notice] = \"Cannot Post. <br/>The words do not match the ones in the recaptcha image!\"\n redirect_to :back\n return\n end\n\n feed_text = params['feed_text']\n challenge_id = params['challenge_id']\n #try to post a feed_text\n status = ChallengeFeeds.post_feed(dbdc_client, challenge_id, feed_text)\n redirect_to :back \n end", "def post_message(form)\n begin\n config.sleep_before_post\n form.submit\n rescue StandardError => err\n raise Impostor::PostError.new(err)\n end\n end", "def recieved\n LeadMailer.recieved\n end", "def create\n \n\n #validate idea\n @idea = Idea.new(params[:idea])\n if @idea.valid? && verify_recaptcha(:model => @idea, :message => \"Please try the reCAPTCHA again\")\n #store description in temp database\n @temp_description = TempDescription.new(:description=>@idea.description)\n @temp_description.save\n #logger.debug(\"temp description object: #{@temp_description}\")\n real_description = params[:idea][:description]\n params[:idea][:description] = @temp_description.id\n idea_params = params.to_query\n\n create_idea_string = \"#{request.host}/approved_create?#{idea_params}\"\n\n #send approval email with correct params\n body_string = \"<p>Name: #{@idea.name}</p><p>Description: #{real_description}</p><p>Submitter: #{@idea.submitter_email}</p><p><a href=\\\"#{create_idea_string}\\\">approve</a></p>\"\n Pony.mail({\n :to => 'tmshu1@gmail.com',\n :via => :smtp,\n :body => body_string,\n :subject=> 'Idea Vending Machine: approval required',\n :headers => { 'Content-Type' => 'text/html' },\n :via_options => {\n :address => 'smtp.gmail.com',\n :port => '587',\n :enable_starttls_auto => true,\n :user_name => 'ideavendingmachine',\n :password => ENV['PASSWORD'],\n :authentication => :plain, # :plain, :login, :cram_md5, no auth by default\n :domain => \"localhost.localdomain\" # the HELO domain provided by the client to the server\n }\n })\n\n #redirect to home, with a flash of success. NEED to do this, so user can't refresh page and spam email me\n flash[:success] = \"Idea submitted for approval. If approved, you will receive an email with #{NUM_IDEAS} ideas\"\n redirect_to root_path\n else\n render action: \"new\"\n end\n \n end", "def do_new_reply\n @feeditem_id = params['feeditem_id']\n @challenge_id = params['challenge_id']\n @reply_text = params['reply_text']\n ChallengeFeeds.post_comment(dbdc_client, @feeditem_id, @reply_text)\n redirect_to :id => @challenge_id, :action => 'show'\n end", "def send_message_to_support\n MessageMailer.message_submitted(self).deliver_now\n end", "def notify(user, answer)\n @user = user\n @answer =answer\n mail(to: user.email, subject: 'You has new answers') \n end", "def create\n @feedback_reply = FeedbackReply.new(feedback_reply_params)\n if signed_in?\n @feedback_reply.user_id = current_user.id\n end\n if @feedback_reply.save\n \n # when admin reply\n if @feedback_reply.user.plan == 'admin'\n @feedback_reply.feedback.update(status: \"answered\")\n \n if(UserMailer.feedback_multiresponse(@feedback_reply).deliver)\n # flash[:success] = \"Your Request is send for Quote.\"\n else\n flash[:error] = \"Error sending email.\"\n end \n \n \n end\n \n # when user reply\n if @feedback_reply.user_id == @feedback_reply.feedback.user_id\n @feedback_reply.feedback.update(status: \"unanswered\")\n if(UserMailer.feedback_response(@feedback_reply).deliver)\n # flash[:success] = \"Your Request is send for Quote.\"\n else\n flash[:error] = \"Error sending email.\"\n end \n \n end \n end\n# respond_to do |format|\n# if @feedback_reply.save\n# format.html { redirect_to @feedback_reply, notice: 'Feedback reply was successfully created.' }\n# format.json { render action: 'show', status: :created, location: @feedback_reply }\n# else\n# format.html { render action: 'new' }\n# format.json { render json: @feedback_reply.errors, status: :unprocessable_entity }\n# end\n# end\n end", "def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <alexyang.personal@gmail.com>\",\n from: \"BaseRails <notifications@baserails.com>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end", "def review_request(user)\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def weekly_update(post)\n @post = post\n email1 = 'svavhal15@gmail.com'\n email2 = @post.email\n email3 = 'svavhal15@gmail.com'\n recipients = email1, email2, email3\n mail(to: recipients.join(','), subject: 'Weekly email from latest blog posts')\n end", "def send_new_post_to(role)\n ResponseMailer.deliver_new_post(self, role)\n end", "def new_feedback(user)\n @user = user\n mail to: user.email, subject: \"New Feedback is added\"\n end", "def post(title, target, message, color)\n a_message_note = {\n 'color' => color,\n 'fields' => [\n {\n 'title' => 'Message',\n 'value' => message,\n 'short' => false\n },\n {\n 'title' => 'Archive Name',\n 'value' => target,\n 'short' => true\n },\n {\n 'title' => 'Status',\n 'value' => color,\n 'short' => false\n }\n ]\n }\n\n notify_user = ENV['SLACK_USER'] || 'notifier'\n notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK'], :username => notify_user\n notifier.ping title, 'icon_emoji' => ENV['SLACK_ICON_EMOJI'], 'attachments' => [a_message_note]\nend", "def feedback(feedback, url)\n @notebook = feedback.notebook\n @url = url.chomp('/')\n @submitter = feedback.user\n @feedback = feedback\n @email_needs_to_be_simplified = need_to_simplify_email?(@notebook, @feedback)\n mail(\n bcc: @notebook.owner_email + [@submitter.email],\n subject: \"You have feedback on a Jupyter notebook\"\n )\n end", "def feedback_email (user_email, feedback_text, subject)\n\t\t@feedback_data = {:mailbody => feedback_text, :sender_email => user_email}\n\n\t\tmail(:to => 'gcomesana@cnio.es', :reply_to => user_email, :subject => subject) # returned value\n\tend", "def non_subscriber_post(email)\n end", "def create\n @feedback = Feedback.new(params[:feedback])\n if @feedback.save\n flash[:success] = \"Feedback was successfully submitted. Thank you. :)\"\n AppMailer.feedback(@feedback).deliver\n redirect_to \"/\"\n else\n flash[:error] = \"Please try again.\"\n redirect_to \"/feedback\"\n end\n end", "def post(message)\n puts message\n end", "def feedback(bike)\n @bike = bike\n\n mail to: \"antoine.escarrat@gmail.com\", subject: \"trouducul\"\n end", "def send_feedback\n feedback = FeedbackItem.new(:user_id=>current_user.id, :url=>params[:url], :page=>params[\"feedback-form-select\"], :description=>params[:description])\n if @saved = feedback.save\n flash[:success_message] = \"Thank you for your feedback. We will inform you when this issue has been resolved.\"\n else\n flash[:error_message] = \"We're sorry, but we could not complete this request. Please send an email to cparkin@tuftsmedicalcenter.org with a description of the problem.\"\n end\n render 'feedback_items/feedback_submit.js.erb'\n end", "def sendReview\r\n email=params[:email]\r\n emails=email.split(\",\")\r\n description=params[:description]\r\n page_id = params[:page_id]\r\n emails.each do |one|\r\n ReviewerInviter.task_invitation(one, description, \"http://localhost:3000/pages/reviewer?id=\"+page_id).deliver()\r\n end\r\n respond_to do |format|\r\n format.html { redirect_to(:back) } #, flash[:success] = \"holder updated\") \r\n end\r\n end", "def comment_recieved(comment)\n @comment = comment\n\n mail :to => comment.email_address, :subject => \"KM CMS comment confirmation\"\n end", "def create\n @feedback = Feedback.new(feedback_params)\n @feedback.course = Course.current\n if @feedback.save\n send_email(@feedback)\n redirect_to :root, notice: 'Feedback was successfully created.'\n else\n render action: 'new'\n end\n end", "def new_idea(idea)\n begin\n m = Mandrill::API.new\n template = m.templates.render 'GetViable New Idea Added', [{:name => \"first_name\", :content => idea.user.name}, {:name => \"idea_name\", :content => idea.title}]\n mail_job = mail(:to => idea.user.email, :subject => \"Getting started with #{idea.title}\") do |format|\n format.html { template['html'] }\n #format.text { render \"test\" }\n end\n mail_job.deliver\n rescue Exception => e\n\n end\n end", "def post\n config = create_or_find_config\n \n if ARGV.size == 0\n puts %(\\n You didn't enter a message to post.\\n\\n Usage: twitter post \"You're fabulous message\"\\n)\n exit(0)\n end\n \n post = ARGV.shift\n print \"\\nSending twitter update\"\n finished = false\n status = nil\n progress_thread = Thread.new { until finished; print \".\"; $stdout.flush; sleep 0.5; end; }\n post_thread = Thread.new(binding()) { |b|\n status = Twitter::Base.new(config['email'], config['password']).post(post)\n finished = true\n }\n post_thread.join\n progress_thread.join\n puts \" OK!\"\n puts \"Got it! New twitter created at: #{status.created_at}\\n\"\n end", "def automatic_results_published_post(contestproblem)\n contest = contestproblem.contest\n sub = contest.subject\n mes = Message.create(:subject => sub, :user_id => 0, :content => helpers.get_new_correction_forum_message(contest, contestproblem))\n sub.last_comment_time = mes.created_at\n sub.last_comment_user_id = 0 # Automatic message\n sub.save\n \n sub.following_users.each do |u|\n UserMailer.new_followed_message(u.id, sub.id, -1).deliver\n end\n end", "def emailOnFeedback(revieweeId)\r\n participant = Participant.find_by_id(revieweeId).user_id\r\n user=User.find_by_id(participant)\r\n asstId = Participant.find_by_id(revieweeId).parent_id\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_feedback\"\r\n if(user.email_on_feedback)\r\n email(user.email,\"feedback\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end", "def create\n @advicepost = Advicepost.new(params[:advicepost])\n #set advisor id attribute\n @advicepost.advisor_id = current_advisor.id\n #save categoryname in the advicepost listing\n @advicepost.categoryname = @advicepost.category.categoryname\n @rating = Rating.new(params[:rating])\n \n #Send email to advisee they have sent a new message to advisor\n UserMailer.delay(queue: \"email_new_advicepost\").new_advicepost_advisor(current_advisor)\n\n \n respond_to do |format|\n if @advicepost.save\n #After save send email to pa admin to notify them new advicepost has been created to review\n UserMailer.delay(queue: \"email_new_advicepost\").new_advicepost_admin(@advicepost,current_advisor)\n \n format.html { redirect_to apnew_path(@advicepost), notice: 'Your Advice Listing has been submitted! You should hear back soon after we review your listing.' }\n format.json { render json: @advicepost, status: :created, location: @advicepost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @advicepost.errors, status: :unprocessable_entity }\n end\n end\n end", "def succesfull_submission(offer)\n @greeting = \"Χαίρετε\"\n @user = User.find(offer.user_id)\n @offer = offer\n @procurement = Procurement.find(offer.procurement_id)\n\n mail to: @user.email, subject: '[E-Proc] Tender Submitted Succesfully'\n end", "def send_update_email(user,article)\n @user = user\n @article = article # controller getting fat with instance variables\n\t mail( :to => user.email, :subject => 'A new post has been added to EBWiki' )\n end", "def tradeya_postponed(n)\n @tradeya = n.trade.item\n @offer = n.trade.offer\n headers['X-SMTPAPI'] = '{\"category\": \"TradeYa postponed offerer copy\"}'\n mail(:to => @offer.user.email, :subject => 'TradeYa has been Postponed', :from => 'TradeYa <jared@tradeya.com>', :content_type => \"text/html\")\n end", "def mailer; end", "def receipt\n mail(\n to: \"smnrwebster5@gmail.com\",\n subject: \"New for review for your commute\"\n )\n end", "def post_news(subject, body)\n page = \"/news/submit.php\"\n\n subject % [unixname, version]\n\n form = {\n \"group_id\" => group_id,\n \"post_changes\" => \"y\",\n \"summary\" => subject,\n \"details\" => body,\n \"submit\" => \"Submit\"\n }\n\n login do\n http_post(page, form)\n end\n end", "def new_message_sent_advisee(user)\n @user = user\n mail to: @user.email, subject: \"New message sent to Advisor\"\n end", "def message_posted(user, message)\n redmine_headers 'Project' => message.project.identifier,\n 'Topic-Id' => (message.parent_id || message.id)\n @author = message.author\n message_id message\n references message.root\n @message = message\n @user = user\n @message_url = url_for(message.event_url)\n mail :to => user,\n :subject => \"[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}\"\n end", "def send_test\n email = Email.find(params[:id])\n @templet = email\n \n if request.post?\n begin\n recip = Recipient.new\n recip.email = params[:recipient][:email]\n \n Notifier::deliver_status_notify(:project => @project, :recipient => recip, :email => email)\n \n flash[:notice] = \"Test e-mail sent successfully!\"\n redirect_to :action => 'index'\n rescue\n flash.now[:error] = \"Unable to send the test email! \" + $!\n end\n end\n end", "def new_review_email(user, business)\n @user = user\n @business = business\n mail(:to => @user.email, :subject => \"Your review has been posted on CONSIGN.NYC\")\n end", "def fingering_submitted_email(fingering, admin)\n @fingering = fingering\n mail(:to => admin.email, :subject => \"Fingering Submitted for Approval\", :from => 'bassoonfingeringfinder@gmail.com') \n end", "def post( text )\n message = {\n 'time' => Time.now.strftime('%Y%m%d%H%M%S'),\n 'text' => text\n }\n\n data['plans'][me]['messages'] << message\n end", "def new_comment(commenter_name, body, url)\n @commenter_name = commenter_name\n @body = body\n @url = url\n\n mail to: \"Alex Yang <alexyang.personal@gmail.com>\",\n from: \"BaseRails <notifications@baserails.com>\",\n subject: \"#{commenter_name} posted a new comment on BaseRails\"\n end", "def raf_submitted(study_subject)\n#\t\t@greeting = \"Hi\"\n\t\t@study_subject = study_subject\n\n\t\tmail to: \"magee@berkeley.edu\"\n\t\tmail cc: [\"jakewendt@berkeley.edu\", \"notifyccls@berkeley.edu\"]\n\t\tmail subject: \"TEST [CCLS Patient Notification Received] Identifier: #{@study_subject.icf_master_id_to_s}\"\n\tend", "def new_submission(submission)\n @submission = submission\n @title = submission.title\n @submission_body = submission.body # using @body causes problems\n @author = submission.author_name\n @url = submission_url(submission)\n\n mail(\n :to => ENV['EDITOR_EMAIL'] || Person.editor.email,\n :from => \"#{submission.author_name} <#{ENV['ADMIN_EMAIL'] || \"admin@problemchildmag.com\"}>\",\n :reply_to => submission.email,\n :subject => \"Submission: \\\"#{strip_tags(@title)}\\\" by #{@author}\"\n ) do |format|\n format.text\n format.html\n end\n end", "def sendQuestionnaire\n email=params[:email]\n emails=email.split(\",\")\n description=params[:description]\n questionnaire_id = params[:questionnaire_id]\n emails.each do |one|\n ReviewerInviter.task_invitation(one, description, \"http://localhost:3000/questionnaires/answer_show?id=\"+questionnaire_id).deliver()\n end\n respond_to do |format|\n format.html { redirect_to(:back) } #, flash[:success] = \"holder updated\") \n end\n end", "def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end", "def test02_open_reject_post\n\t\t@msg = \"Note for rejection #{random}\"\n\t\tlogin $user_3_email, $master_password\n\t\t$browser.goto($patch_blogs_pre_open)\n\t\twait_for_ajax\n\t\tsleep 2\n\t\t#create post for approval\n\t\tpostApproveNoteSetup(@msg)\n\t\t\n\t\t#log out\n\t\tlogout_common\n\t\t\n\t\t#login in as admin (moderator of blog)\n\t\tlogin $admin_1_email, $master_password\n\t\t\n\t\t#reject post\n\t\t$browser.goto($patch_blogs_pre_open)\n\t\twait_for_ajax\n\t\tsleep 3\n\t\t$post_for_approval_icon.click #go to preview \n\t\tsleep 4\n\t\tassert $browser.text.include? \"#{@msg}\" #verify on correct page\n\t\tsleep 4\n\t\t$post_reject_icon.when_present.click\n\t\tsleep 2\n\t\t$post_reject_reason.when_present.set \"I don't link this post\"\n\t\t$post_reject_button.click\n\t\tassert !($browser.text.include? \"#{@msg}\")\n\tend", "def process_explanation_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.process_explanation_mail(Petition.live.first)\n end", "def new_advicepost_advisor(advisor)\n @advisor = advisor\n mail to: @advisor.email, subject: \"New advice listing submitted\"\n end", "def notice(review)\n @review = review\n @user = \"#{review.movie.user.first_name}, \"\n @greeting = \"Your movie has been reviewed.\"\n\n mail(\n to: review.movie.user.email,\n subject: \"New review posted for #{review.movie.title}\"\n )\n end", "def new_feedback(feedback, community)\n subject = t(\"feedback.feedback_subject\", service_name: community.name(I18n.locale))\n\n premailer_mail(\n :to => mail_feedback_to(community, APP_CONFIG.feedback_mailer_recipients),\n :from => community_specific_sender(community),\n :subject => subject,\n :reply_to => feedback.email) do |format|\n format.html {\n render locals: {\n author_name_and_email: feedback_author_name_and_email(feedback.author, feedback.email, community),\n community_name: community.name(I18n.locale),\n content: feedback.content\n }\n }\n end\n end", "def new_advicepost_admin(advicepost,advisor)\n @advicepost = advicepost\n @advisor = advisor\n @admin_email = \"gabe@pathadvisor.com\"\n mail to: @admin_email, subject: \"Check new advice listing submitted\"\n end", "def notify_post\n raise \"not yet implemented\"\n end", "def new_idea(user, topic, idea)\n @user = user\n @topic = topic\n @idea = idea\n mail to: user, subject: \"InventNet - New idea posted in '#{topic.title}'\"\n end", "def test_email\n @brother.post_notification(\n \"Email testing. \",\n \"This email serves solely to ascertain that ADP Dashboard emails can reach your email address. \",\n root_url\n )\n\n redirect_to root_url, flash: { notice: \"Test email sent to #{@brother.email}. \" }\n end", "def test02_closed_reject_post\n\t\t@msg = \"Note for rejection #{random}\"\n \tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_pre_closed)\n\t\twait_for_ajax\n\t\tsleep 2\n\t\t#create post for approval\n\t\tpostApproveNoteSetup(@msg)\n\t\t\n\t\t#log out\n\t\tlogout_common\n\t\tsleep 10 #let content populate\n\t\t#login in as admin (moderator of blog)\n\t\tlogin $admin_1_email, $master_password\n\t\t\n\t\t#reject post\n\t\t$browser.goto($patch_blogs_pre_closed)\n\t\twait_for_ajax\n\t\tsleep 3\n\t\t$post_for_approval_icon.when_present.click #go to preview \n\t\tsleep 4\n\t\tassert $browser.text.include? \"#{@msg}\" #verify on correct page\n\t\tsleep 4\n\t\t$post_reject_icon.when_present.click\n\t\tsleep 2\n\t\t$post_reject_reason.when_present.set \"I don't link this post\"\n\t\t$post_reject_button.click\n\t\tassert !($browser.text.include? \"#{@msg}\")\n\tend", "def email\n # If there is no url passed in, this will fail, so just redirect to the homepage\n redirect_to \"/\" and return if params[:u].blank?\n if request.post?\n @message = Message.new(params[:message])\n @message.subject = \"#{@message.from} has sent you a page from the NORC Blueprint Website\"\n if @message.save\n SiteMailer.deliver_page(@message, \"http://#{request.host_with_port}#{params[:u]}\")\n flash[:notice] = \"Your message was sent successfully\"\n redirect_to params[:u]\n end\n end\n end", "def review_decision\n\t\tproject = @task.project\n\t\t@data[:decision_owner] = @task.assigned_to.try(:full_name)\n\t\t@data[:decision_title] = @task.title\n\t\t@data[:project_name] = project.title\n @data[:recipient_names] = recipient_names\n\t\t@data[:decision_link] = \"#{ENV['DOMAIN']}/#/app/projects/#{project.id}/tasks\"\n\t\t@template_slug = APOSTLE_MAIL_TEMPLATE_SLUG[:review_decision]\n\t\ttrigger_mail\t\t\n\tend", "def new_feedback\n\n end" ]
[ "0.73912334", "0.71305496", "0.706481", "0.69875", "0.691727", "0.68479", "0.6812092", "0.6791208", "0.6728435", "0.67026794", "0.666112", "0.66548264", "0.6641871", "0.66367143", "0.6604505", "0.65924966", "0.65881306", "0.65679574", "0.6559134", "0.654583", "0.65415394", "0.6537702", "0.6496308", "0.6453717", "0.6410265", "0.63961864", "0.63831466", "0.6381146", "0.63717717", "0.63695854", "0.6363145", "0.63507473", "0.63419336", "0.6331072", "0.6317804", "0.631425", "0.6313858", "0.6302311", "0.63016653", "0.62725616", "0.62672746", "0.62655896", "0.62629205", "0.6239541", "0.6236269", "0.6216314", "0.6209268", "0.6203911", "0.6191704", "0.61865747", "0.6184578", "0.6182378", "0.61777115", "0.6176027", "0.61724097", "0.6169251", "0.61550343", "0.615115", "0.6151134", "0.6149818", "0.61427265", "0.6142626", "0.61385214", "0.6135868", "0.6131355", "0.61293197", "0.61262256", "0.611752", "0.61122376", "0.61043984", "0.6103968", "0.6095185", "0.60937667", "0.6088794", "0.6086718", "0.60796326", "0.60764444", "0.6072219", "0.6071959", "0.6052255", "0.6048024", "0.603425", "0.6029183", "0.6029008", "0.6026019", "0.6025446", "0.6022562", "0.60157627", "0.6013383", "0.60063565", "0.60038227", "0.60037225", "0.6000822", "0.59996396", "0.59945476", "0.5992685", "0.5990203", "0.5990192", "0.5989482", "0.59888816" ]
0.6082675
75
page to allow user changing password
def change_password @user = current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_password\r\n \r\n end", "def edit_password; end", "def change_password\n return if generate_filled_in\n if do_change_password_for(@user)\n # since sometimes we're changing the password from within another action/template...\n #redirect_to :action => params[:back_to] if params[:back_to]\n redirect_back_or_default :action => 'change_password'\n end\n end", "def change_password(old_password, new_password)\n old_password_tb.type_text(old_password)\n new_password_tb.type_text(new_password)\n password_confirm_tb.type_text(new_password)\n change_pw_btn.click\n end", "def change_password\n set_breadcrumbs(\"change_password\") \n if request.post? || request.patch? \n admin = Admin.find(current_admin.id)\n @check = params[:admin][:password] == params[:admin][:password_confirmation] && params[:admin][:password].present? && params[:admin][:password_confirmation].present?\n if admin.present? && admin.valid_password?(params[:admin][:old_password])\n if @check \n if admin.update_attribute(:password, params[:admin][:password])\n sign_in admin, :bypass => true\n flash[:notice] = I18n.t('change_password.update.success')\n redirect_to admin_root_path\n else\n flash[:error] = I18n.t('common.error') \n end\n else\n flash[:error] = I18n.t('change_password.failure.password_is_not_match')\n end\n else\n flash[:error] = I18n.t('change_password.failure.invalid_old_password')\n end\n end\n end", "def password_change_new\n\n end", "def change_password(new_password)\n update_password(new_password)\n @password = new_password\n puts 'Success! Your password has been changed.'.colorize(:light_green)\n @prompt.keypress('Press any key to continue..')\n menu = Menu.new(self)\n menu.account_details\n end", "def set_change_password(user)\n user.update_column(:must_change_passwd, true)\n session[:pwd] = 1\n end", "def set_password\n @user = User.find(session[:user_id])\n if @user.password == params[:old_password]\n if @user.update_attributes(params[:user])\n redirect_to user_new_path\n else\n flash[:notice] = \"Please enter correct passwords\"\n render user_change_password_path\n end\n else\n flash[:notice] = \"Please enter your correct passwords\"\n redirect_to user_change_password_path\n end\n end", "def password\n if !logged_in?\n flash[:error] = \"Must log in to change password\"\n redirect_to(:action => :login)\n else\n @user = User.find(current_user_id)\n end\n end", "def password=(new_password); end", "def change_password\n if request.post?\n @account = getAccount()\n pass = true\n err = \"\"\n old = params[:password][:old]\n new1 = params[:password][:new1]\n new2 = params[:password][:new2]\n if new1.length < 6 or new1.length > 18\n pass = false\n err = \"Length of password should be between 6 and 18.\"\n end\n \n if new1 != new2\n pass = false\n err = \"The retyped password doesn't match the new password.\"\n end\n \n if old != @account.password\n pass = false\n err = \"The password you entered doesn't match the password in our system.\"\n end\n \n if pass\n @account.update_attribute(\"password\", new1)\n flash[:notice] = \"Password updated.\"\n redirect_to :action=>'account', :controller=>'go'\n else\n flash[:notice] = err\n redirect_to :action=>'account', :controller=>'go'\n end \n \n else\n flash[:notice] = \"Please login.\"\n redirect_to :action=>'login', :controller=>'go'\n end\n \n if request.get?\n redirect_to(:action => \"index\", :controller =>\"go\")\n end \n end", "def change_password!(password)\n json = JSON.generate(:changePassword => { :adminPass => password })\n @compute.connection.req('POST', \"/servers/#{@id}/action\", :data => json)\n @adminPass = password\n end", "def change_temp_password\n\tend", "def change_password\n if current_user.update_with_password(password_params)\n #\n # Sign in the user bypassing validation in case\n # their password changed.\n #\n sign_in current_user, bypass: true\n\n redirect_to current_user, notice: 'Password successfully changed.'\n else\n render 'edit'\n end\n end", "def password \n if params[:reset]\n results = CsApi::Account.reset_password(current_user.username)\n if results['success'].eql?('true')\n redirect_to password_reset_url, :notice => results[\"message\"]\n else \n flash.now[:notice] = results[\"message\"]\n end\n get_account\n end\n @page_title = \"Change Your Password\"\n if !@account[\"login_managed_by\"].eql?('CloudSpokes')\n flash.now[:warning] = \"You are logging into CloudSpokes with your #{@account[\"login_managed_by\"]} account. You will need to change your password at #{@account[\"login_managed_by\"]}\"\n end\n end", "def change_password\n #check if user is new or being updated\n if self.encrypted_password.present?\n #verifies password\n if self.password_check\n self.encrypt_password\n else\n raise \"error\"\n end\n else\n raise \"error\"\n end\n end", "def change_password_for_user\n if (@user = find_user(params[:id]))\n do_change_password_for(@user)\n flash[:notice] = \"Password for user '#{@user.login}' has been updated.\"\n end\n redirect_back_or_default :action => 'list'\n end", "def update\n @user.password = params[:password]\n @user.password_confirmation = params[:password_confirmation]\n return unless @user\n if @user.save\n flash[:notice] = t 'password_resets.updated'\n redirect_to @user\n else\n render :action => :edit\n end\n end", "def change_password\n @user = current_user\n @user.update_password(params)\n\n if @user.errors.empty?\n redirect_to profile_path, :notice => I18n.t('profile.password_changed')\n else\n flash.now[:alert] = I18n.t(\"errors.passwords.problem\")\n render 'show', :status => :forbidden\n end\n end", "def password_changed_confirm\n pw_change_confirm.click\n end", "def update_password\n\t\t@admin = current_admin\n\t\tif(@admin.update_attributes(params[:admin]))\n\t\t\tredirect_to root_path\n\t\telse\n\t\t\trender :action => \"reset\"\n\t\tend\n\tend", "def update_password\n @user = User.shod(params[:id])\n if @user.update(user_params)\n flash[:notice] = t('pass_change')\n redirect_to user_path(@user)\n else\n render 'change_password'\n end\n end", "def update_password\n # check current password is valid\n if params[:account].present? and !@account.valid_password?(params[:account][:current_password])\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"Current password incorrectly.\" }\n return\n end\n\n if params[:account].present?\n params[:account].delete(:password) if params[:account][:password].blank?\n params[:account].delete(:password_confirmation) if params[:account][:password].blank? and params[:account][:password_confirmation].blank?\n\n if @account.update_with_password(account_params)\n bypass_sign_in(@account)\n redirect_to gns_core.my_account_backend_accounts_path, flash: { success: \"The new password has been successfully changed.\" }\n else\n if params[:account][:password].nil? or params[:account][:password].length < 6\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"New password must contain at least 6 characters.\" }\n else\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"Repeat password does not match.\" }\n end\n end\n end\n end", "def update_password\n\t\t# if admin, allow editing user's password\n if current_user.is_admin?\n @user = User.find(params[:id])\n else\n\t\t\t# else just use current user\n @user = current_user\n end\n\n\t\t# update user password with regards to the parameters\n if @user.update_attributes(params[:user])\n gflash :success => \"Password Successfully Updated\"\n redirect_to :action => 'edit', :id => @user.id\n else\n render :action => 'change_password', :id => params[:id]\n end\n end", "def password\n if @user.update_with_password(password_params)\n render_update_success @user\n else\n render_failure @user\n end\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def change_password\n\t\tauthor = current_author\n\t\tif author.valid_password?(author_password_params[:current_password])\n\t\t\tif author.change_password(author_password_params)\n\t\t\tsign_in(author, bypass: true)\n\t\t\tflash[:success] = 'Has been udates...'\n\t\t\telse\n\t\t\t\tflash[:danger] = author.display_error_message\n\t\t\tend\n\t\telse\n\t\t\tflash[:danger] = 'current password incorect!!'\n\tend\n \t \tredirect_to authors_account_path\nend", "def change_password\n\t\t# if admin, allow editing user's password\n if current_user.is_admin?\n @user = User.find(params[:id])\n else\n @user = current_user\n end\n end", "def newPassword(newPass)\n\t\tDATABASE.edit(\"users\", \"password\", newPass, \"username\", @username)\n\tend", "def set_password_field(password)\n end", "def password_update\n redirect_to lato_core.root_path unless core_getRecoveryPasswordPermission\n user = LatoCore::Superuser.find(params[:id])\n if !user || user.session_code != params[:token]\n flash[:warning] = CORE_LANG['recover_password']['recover_error']\n redirect_to lato_core.login_path and return false\n end\n user.update(password: params[:password], password_confirmation: params[:password])\n if !user.save\n flash[:warning] = CORE_LANG['recover_password']['recover_error']\n redirect_to lato_core.login_path and return false\n end\n\n flash[:success] = CORE_LANG['recover_password']['recover_success']\n redirect_to lato_core.login_path\n end", "def change_password\n # https://github.com/site5/lumberg\n server = Lumberg::Whm::Server.new(host: HOST_NAME, hash: `cat #{HASH_FILE_PATH}`)\n cp_email = Lumberg::Cpanel::Email.new(server: server, api_username: @username)\n @password = SecureRandom.urlsafe_base64(12)\n process_options = { domain: @domain, email: @email, password: @password }\n passwd_result = cp_email.change_password(process_options)\n if passwd_result[:params][:data][0][:reason] == ''\n puts \"Successfully changed password of #{@email}\"\n time = Time.new\n logtime = time.strftime('%Y-%m-%d %H:%M')\n File.open(\"#{LOG_FILE_PATH}\", 'a') { |logfile| logfile.puts \"#{logtime}: #{@email}\" }\n else\n # Print c-panel error message if failed to change the password\n puts \"#{passwd_result[:params][:data][0][:reason]}\"\n end\n end", "def change_password(username, password)\n perform_request({:action => \"client-updatepassword\", :username => username, :password => password})\n statusmsg.match /success/i\n end", "def change_password\r\n\r\n allowed = @current_user && (@current_user.is_admin? || @current_user.id.to_s == params[:id])\r\n if !allowed\r\n flash[:warning] = _(\"Not authorized!\")\r\n redirect_to(:action => :list) and return\r\n end\r\n params[:user] ||= {}\r\n params[:user][params[:id]] ||= {}\r\n conf = params[:user][params[:id]].delete(:password_confirmation)\r\n pass = params[:user][params[:id]][:password]\r\n @user_attributes = params[:user] ? params[:user][params[:id]].clone : {}\r\n @user_attributes.merge!(:id => params[:id]) if @user_attributes\r\n\r\n @user = User.load_from_params(@user_attributes)\r\n if @user.nil?\r\n flash[:warning] ||= []\r\n flash[:warning] << _(\"Warning: %{obj} with ID %{id} does not exist!\") % {:obj => 'user', :id => params[:id]}\r\n redirect_to(:action => :index)\r\n return\r\n end\r\n\r\n if request.post? && !pass.blank?\r\n if conf.blank? || pass.blank? || conf != pass\r\n @user.errors.add(:password, _(\"Password confirmation mismatch!\"))\r\n flash[:warning] ||= _(\"Password confirmation mismatch!\")\r\n @user.password = :random\r\n else\r\n flash[:notice] = _(\"Password changed\")\r\n @user.password = pass if @user.valid?\r\n end\r\n if @user.valid? && @user.password && @user.save\r\n flash[:notice] ||= _(\"Password not changed!\")\r\n redirect_to(:action => :show, :id => @user.id)\r\n else\r\n render(:action => :edit, :id => @user.id, :layout => !request.xhr?)\r\n end\r\n else\r\n render :layout => !request.xhr?\r\n end\r\n end", "def recruiter_password_change(current_password,new_password)\n current_password_field.set current_password\n\t new_password_field.set new_password\n confirm_password_field.set new_password\n\t change_button.click\n\t \n end", "def change_password\n @user = User.find(session[:user_id])\n if params[:user]\n @user.password = params[:user][:password]\n @user.password_confirmation = params[:user][:password_confirmation]\n if @user.save\n flash[:notice] = \"Password change successful\"\n end\n end\n end", "def enter_password\n end", "def update_password\n @employee = current_employee\n if @employee.update_with_password(params_employee)\n redirect_to root_path\n else\n render :action => \"edit_password\"\n end\n end", "def edit_password(user, new_password)\n if @config.restrictions[:password_count_restriction]\n unless new_password >= @config.restrictions[:password_count_restriction].to_i\n return false\n end\n end\n user.password = user.hash_plaintext(new_password)\n user.save_data\n end", "def change_password\n #if not logged in, display error message\n if !logged_in?\n flash[:error] = \"Must log in to change password\"\n redirect_to(:action => :login)\n else\n current_user = User.find(current_user_id)\n if current_user.update(user_params(params[:user])) then\n reset_session\n flash[:success] = \"Password successfully updated\"\n redirect_to(:action => :login)\n else\n current_user.errors.full_messages.each do |mess|\n flash[:error] = mess\n end\n redirect_to(:action => :password)\n end\n end\n end", "def change_password!(opts = {})\n password!(opts.merge(:verb => :put))\n end", "def password\n\n end", "def password_change\n respond_to do |format|\n if @user.update_with_password(password_change_params)\n bypass_sign_in(@user)\n format.html { redirect_to request.referer || root_url, notice: 'User password has been successfully updated.' }\n else\n format.html { render 'password_change_new' }\n end\n end\n end", "def change_password\n\t\t \tif params[:current_password]==current_user.password\n\t\t\t\tif params[:new_password]==params[:conform_password]\n\t\t\t\t\t current_user.password=params[:new_password]\n\t\t\t\t\t\tif current_user.save\t\n\t\t\t \t\t redirect_to take_password_path,:notice=>show_flash_message('Your Password is Successfully Changed.')\n\t\t\t \t\telse\n\t\t\t\t\t\t\tshow_flash_message('Your Password is not Changed.')\n\t\t\t \t\t \tredirect_to take_password_path\n\t \t\t\t\t\tend\n\t \t \telse\n\t\t\t\t \t\tredirect_to take_password_path,:notice=>show_flash_message('New Password and Conform password not matched.')\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t \t\tredirect_to take_password_path ,:notice=>show_flash_message('Old Password is not correct.')\n\t\t\tend\n\t\tend", "def update\n if @user.update_attributes(user_params)\n log_in @user\n flash[:success] = \"La tua password è stata aggiornata! Cerca di non dimenticarla stavolta!\"\n redirect_to groups_path\n else\n render file: \"app/views/new_password\"\n end\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end", "def set_Password(value)\n set_input(\"Password\", value)\n end" ]
[ "0.84290123", "0.8193663", "0.79619133", "0.78120226", "0.7776304", "0.7762628", "0.77188057", "0.7714539", "0.7679163", "0.7676821", "0.76365185", "0.7623872", "0.7599448", "0.7590641", "0.7584725", "0.7584069", "0.7581752", "0.75761884", "0.755969", "0.7553241", "0.75531113", "0.75352234", "0.74910265", "0.74789965", "0.74784064", "0.74706966", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74674296", "0.74665856", "0.74665856", "0.746425", "0.74436146", "0.7442299", "0.7426385", "0.7425665", "0.7392253", "0.7386757", "0.73786354", "0.7376876", "0.73729527", "0.73721594", "0.73690623", "0.7365674", "0.7365175", "0.73608845", "0.73592705", "0.72985256", "0.72976935", "0.7276818", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318", "0.7276318" ]
0.0
-1
Execute some code Execute some code condition = true another_condition = false if !condition && !another_condition puts 'This evaluated to true' else puts 'This evaluated to false' end puts 'La la la' name = 'Fikar' if name == 'Fikar' puts 'Welcome to the program, Fikar' elsif name == 'Jack' puts 'Welcome to the world, Jack' elsif name == 'Evgeny' puts 'Welcome to the world, Evgeny' else puts 'Welcome to the program, User' end List of Methods
def add(first_num, second_num) first_num.to_f + second_num.to_f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main\n\n #\n # In Ruby, everything is an expression, even the control structures.\n #\n\n #\n # if, else, elsif\n #\n # The value that results from evaluating an if expression is the\n # value of the last expression in the code that was executed, or\n # nil if no block of code is executed.\n #\n \n x = 3\n\n if x == 1\n name = \"one\"\n elsif x == 2\n name = \"two\"\n elsif x == 3\n name = \"three\"\n elsif x == 4\n name = \"four\"\n else\n name = \"many\"\n end\n\n puts name\n\n # here is another way to write the above if expression\n\n if x == 1\n name = \"one\"\n elsif x == 2\n name = \"two\"\n elsif x == 3 then name = \"three\"\n elsif x == 4 ; name = \"four\"\n else\n name = \"many\"\n end\n\n puts name\n\n # here is another way to write the above if expression\n\n name = if x == 1 then \"one\"\n elsif x == 2 then \"two\"\n elsif x == 3 then \"three\"\n elsif x == 4 then \"four\"\n else \"many\"\n end\n\n puts name\n\n # for single-line conditionals: use \"if\" as a modifier\n y = x.odd? if x.respond_to?(:odd?)\n puts y\n \n #\n # unless is the opposite of if. unless executes code only if associated\n # expression evaluates to false or nil. elsif clauses are not allowed.\n #\n x = 10\n unless x == 0\n puts \"x is not 0\"\n else\n puts \"x is 0\"\n end\n \n # for single-line conditionals: use \"unless\" as a modifier\n s = x.to_s unless x.nil?\n puts s\n \n #\n # case statement is a multiway conditional. Like if, case returns a value\n #\n x = 5\n case x\n when 1\n name = \"one\"\n when 2\n name = \"two\"\n when 3\n name = \"three\"\n when 4\n name = \"four\"\n else # optional\n name = \"many\"\n end\n puts name\n \n # since case returns a value, here is another way to write the above case\n name = case x\n when 1\n \"one\"\n when 2\n \"two\"\n when 3\n \"three\"\n when 4\n \"four\"\n else \"many\"\n end\n puts name\n \n #\n # Ruby has three looping statements: while, until, and for/in.\n #\n x = 10\n while x >= 0 do\n puts x\n x -= 1\n end\n puts\n \n # above code using until\n x = 10\n until x < 0 do\n puts x\n x -= 1\n end\n puts\n \n # while as a modifier\n x = 0\n puts x = x + 1 while x < 10\n puts\n \n # until as a modifier\n x = 0\n puts x = x + 1 until x == 10\n puts\n \n #\n # for/in loop is used to iterate through the elements of an enumerable object\n #\n for i in 1..10 do\n print i, \" \"\n end\n print \"\\n\\n\"\n \n # print elements in an array\n a = [5, 10, 15, 20, 25]\n for e in a do\n print e, \" \"\n end\n print \"\\n\\n\"\n \n # print keys and values in a hash\n h = {:a => 1, :b => 2, :c => 3}\n for key,value in h\n puts \"#{key} => #{value}\"\n end\n puts\n \nend", "def greet(name)\n puts \"hi #{name}!\"\n if name == \"nico\" || name == \"nicolas\"\n puts \"that's a great name \\n\"\n end\nend", "def test(name, last_name, age)\n if (name == \"Anndony\" && last_name == \"Quemag\") || age == \"23\" #This condition can generate confusion, so it is more advisable to use quotation marks so that ruby understands well what condition we want to put\n puts \"Yes, the information is correct\"\n else\n puts \"No! The information is false\"\n end\nend", "def fizzbuzz(num_1, num_2, range)\n #defines new method fizzbuzz with 3 parameters\n (1..range).each do |i|\n #establishes range and loop. |i| iterates through the range.\n if i % num_1 === 0 && i % num_2 === 0\n #starts conditional with mathematical function\n puts 'fizzbuzz'\n #prints out fizzbuzz if the \"if\" conditions are met.\n\n elsif i % num_1 === 0\n #establishes another condition if above condition parameters not met.\n puts 'fizz'\n #prints out fizz if the preceding \"elsif\" condition is met.\n elsif i % num_2 === 0\n #establishes another condition if above condition parameters not met.\n puts 'buzz'\n #prints out buzz if the preceding \"elsif\" condition is met.\n else\n #establishes condition for any other situation that does not fulfill preceding conditional staements.\n puts i\n # prints out value of if the preceding condition is met.\n\n end\n #ends conditional\n end\nend", "def condition(x)\r\n if x\r\n puts \"condition executed\"\r\n end\r\nend", "def if_condition; end", "def conditionally(*) end", "def conditionally(*) end", "def weatherman (condition, temperature)\n if condition == \"rainy\" && temperature == \"cold\"\n puts \"Better stay inside!\"\n elsif condition == \"rainy\" && temperature == \"hot\"\n puts \"Sounds like a gross combination.\"\n elsif condition == \"sunny\" && temperature == \"hot\"\n puts \"Maybe best to go swimming.\"\n elsif condition == \"windy\" && temperature == \"cold\"\n puts \"Bundle up!\"\n elsif condition == \"windy\" && temperature == \"hot\"\n puts \"Tornado warning!\"\n end\nend", "def body_function \n puts \"Please leave a desposit...\"\n body_function = gets.chomp #local variable\n if ['wee', 'pee', 'piss', 'slash', 'tinkle', 'piddle', 'urinate', 'wee-wee', 'pee-pee', '1'].any? { |word| body_function.downcase.include?(word) } # => true\n puts \"You pee into the bowl\"\n elsif ['poo', 'poop', 'crap', 'defecation', 'excretion', 'dung', 'discharge', 'shit', 'turd', 'bog', '2'].any? { |word| body_function.downcase.include?(word) } # => true\n puts \"You poo into the bowl\" \n elsif ['fart', 'fluff', 'puff', 'let rip'].any? { |word| body_function.downcase.include?(word) } # => true\n puts 'You fart into the toilet bowl'\n end\nend", "def fizzbuzz(num_1, num_2, range)\n# Defines a method that will test pass each of a range of integers to the if-statement.\n (1..range).each do |i|\n # Sets the condition to act on an integer if the it's multiple of num_1 and num_2.\n if i % num_1 === 0 && i % num_2 === 0\n # Prints string if the conditions are met.\n puts 'fizzbuzz'\n # Sets the condition to act on integer if it's a multiple of num_1\n elsif i % num_1 === 0\n # Prints string if the condition is met.\n puts 'fizz'\n # Sets the condition to act on integer if it's a multiple of num_2\n elsif i % num_2 === 0\n # Prints string if the condition is met.\n puts 'buzz'\n # Sets the condition if none of the previous conditions are met.\n else\n # Prints the integer from the range\n puts i\n # Closes if-statment\n end\n # Closes each method\n end\n# Closes method\nend", "def fizzbuzz(num_1, num_2, range)\n # creates an action that will be carried out when the method is called\n (1..range).each do |i|\n # creates the first conditional to the action above\n if i % num_1 === 0 && i % num_2 === 0\n # notes the action to carry out if the above is true\n puts 'fizzbuzz'\n # creates an alternate conditional route for the action above\n elsif i % num_1 === 0\n # notes the action to carry out if the above conditional is true\n puts 'fizz'\n # creates yet another conidtional route - if both of the above are false - this will be evaluated.\n elsif i % num_2 === 0\n # notes the action to carry out if the above conditional is true\n puts 'buzz'\n # creates the final condition - encompasses all other options if the all 3 of the above are false\n else\n # notes the action to carry out if we've moved to the 'else' realm with the first 3 conditions\n puts i\n # ends the function within the method\n end\n #ends the method within a method of .each\n end\n# ends the method\nend", "def my_if(condition, then_clause, else_clause)\n if condition\n then_clause.call\n else\n else_clause.call\n end\nend", "def gen\n res = ''\n res += ln('if (' + @condition.gen() + ') {') if @withinIf\n shift(1) if @withinIf\n checkSum = @context.method.context.genMethCheckSum()\n if @context.method.type == 'void'\n res += ln(@context.method.resFieldName + ' += ' + checkSum + ';') +\n ln('return;')\n elsif @context.method.type == 'boolean'\n res += ln('return ((int)(' + checkSum + ')) % 2 > 0;')\n else\n res += ln('return (' + @context.method.type + ')(' + checkSum + ');') if !@context.method.type==''\n res += ln('return;') if @context.method.type==''\n end\n shift(-1) if @withinIf\n res += ln('}') if @withinIf\n return res\n end", "def method4(a)\n if a\n puts \"bam\"\n end\n unless(a)\n puts \"baz\"\n end\n end", "def hello(name)\n\tif name == \"John\"\n\t\t\"Hello #{name}!\"\n\telsif name == \"Kevin\"\n\t\t\"Hey there #{name}!\"\n\telse\n\t\t\"I don't know you!\"\n\tend\nend", "def method_that_calls_the_other_methods\n puts \"Do you Want to run the keyboard_line method(use y for yes or n for no)\"\n input = gets.chop\n if (input == 'y') \n keyboard_line\n else\n puts \"No method was ran\"\n end\n\n puts \"Do you Want to run the rest of the methods\"\n input = gets.chop\n if (input == 'y')\n is_it_a_big_number\n hello_there\n get_info_from_user\n\n else\n puts \"the other methods were not ran\"\n end\nend", "def greet1\n print 'Enter your name : '\n name = gets.to_s.chomp\n if name == 'Alice' || name == 'Bob'\n puts 'Hello #{name}'\n else\n puts 'Hello'\n end\nend", "def condition; end", "def essay_writer(title, topic, date, thesis_statement, pronoun)\r\n\tputs \"#{title}\"\r\n\tputs \"\"\r\n\tif \"#{pronoun}\" == \"male\"\r\n\t\tputs \"#{topic} was an important person in #{date}. He did a lot. #{thesis_statement}\"\r\n\telsif pronoun == \"female\"\r\n\t\tputs \"#{topic} was an important person in #{date}. She did a lot. #{thesis_statement}\"\r\n\telsif pronoun == \"thing\"\r\n\t\tputs\"#{topic} was an important object in #{date}. One of the most important discoveries to date. #{thesis_statement}\"\r\n\telse pronoun == \"place\"\r\n\t\tputs\"#{topic} was an important place in #{date}. An important place in our world of history. #{thesis_statement}\"\r\nend\r\n\r\nend", "def greeting_user(name)\n name.include?('!') ? puts(\"HELLO #{name.chop.upcase}. WHY ARE WE SCREAMING?\") : puts(\"Hello #{name.capitalize}\")\nend", "def can_i_access_your_profile(is_friend, my_city, their_city, their_school)\n if is_friend\n is_friend\n elsif my_city == their_city && their_school == \"MakerSquare\"\n puts \"Yes\"\n elsif my_city == their_city\n puts \"Mehh\"\n else\n puts \"Naw\"\n end\nend", "def say_hi\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"each\")\n # @names is a list of some kind, iterate!\n\n @names.each do |name|\n puts \"Hello #{name}!\"\n end\n end\n\n #say bye to everyone \n\n def say_bye \n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n #Join the list elements with commas \n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else \n puts \"Goodbye #{@names}. Come back soon!\"\n end \n end\nend", "def going_hiking(temp)\n\n# Create if statement that checks for whether\n# temperature is >= 50\n\n\tif temp >= 50\n\n# Output string that interpolates \"temp\"\n\n\t\tputs \"#{temp} is pretty good for hiking!\"\n\n# Create second if statement that checks for \n# whether temperature is < 50\n\n\telsif temp == 23\n\n\t\tputs \"The temperature is 23!\"\n\n\telsif temp < 50\n\n# Output string that interpolates \"temp\"\n\t\t\n\t\tputs \"#{temp} is too cold for hiking!\"\n\n\n\tend\n\n# Close method\n\nend", "def greet(name,owner)\n return \"Hello boss\" if name.eql? owner\n return \"Hello guest\" \nend", "def greeting_user\n print \"What is your name? \"\n name = gets.chomp\n puts name.include?('!') ? \"HELLO #{name.upcase}. WHY ARE WE SCREAMING?\" : \"Hello #{name.capitalize}\"\nend", "def fizzbuzz(num_1, num_2, range)\n # Execute the code for each element in the collection (in this case, a range of numbers)\n (1..range).each do |i|\n # if i mod num_1 is zero (i.e. there isn't a remainder when you divide i by num_1) AND i mod num_2 is zero, then execute the code\n if i % num_1 === 0 && i % num_2 === 0\n # outputs string\n puts 'fizzbuzz'\n # Else if i mod num_1 is zero, then execute the code\n elsif i % num_1 === 0\n # outputs a string\n puts 'fizz'\n # Else if i mod num_2 is zero, then execute the code\n elsif i % num_2 === 0\n # outputs a string\n puts 'buzz'\n # If none of the above are true, then execute the code\n else\n # outputs a variable\n puts i\n # end the conditional arguments\n end\n # end the iteration\n end\n# end the method definition\nend", "def can_i_access_your_profile(is_friend, my_city, their_city, their_school)\n if is_friend\n puts \"Yes\"\n elsif their_school == \"MakerSquare\"\n puts \"HELL YEAH!\"\n elsif my_city == their_city\n puts \"Maybe\"\n else\n puts \"No\"\n end\nend", "def welcome(last_name, is_woman, is_sir)\n if is_sir\n \"Hello Sir #{last_name}\"\n elsif is_woman\n \"Hello Ms. #{last_name}\"\n else\n \"Hello Mr. #{last_name}\"\n end\nend", "def quiz_instructions\n puts \"This is a quiz that you can take to test out your programming knowledge and earn valuable spa points, which can be used at the Coder Detox Spa.\\n\\n\".blue\n puts \"You will be presented with a statement on a number of programming concepts, in which you will have provide a response.\\n \n If you believe a statement is correct, please type in 'true'.\\n \n On the other hand, if you believe a statement to be incorrect, please type in 'false'.\\n\\n\".blue\nend", "def compliment_machine(name)\nputs \"Hey there, #{name}! Lookin' good today!\"\nputs \"Is that a new face? It looks nice!\"\nend", "def allcaps(string) # Defining our method with a name and parameter\n if string.length > 10 # 'if' condition\n puts string.upcase # If above is true then this gets executed\n else\n puts string # If above 'if' condition is false this gets executed\n end\nend", "def fizzbuzz(num_1, num_2, range)\n # for...in loop executes through the range with <1> beginning and the function argument <range> ending.\n (1..range).each do |i|\n # if local variable <i> modulo, fuction argument <num_1> === 0 and <i> modulo function argument <num_2> === 0, returns <true> the code beneath executes.\n if i % num_1 === 0 && i % num_2 === 0\n # prints the string 'fizzbuzz' to the terminal\n puts 'fizzbuzz'\n # if the if condition returned false, then the conditional statement: <i> modulo <num_1> === 0, is evaluated. If it returns <true> the code beneath executes.\n elsif i % num_1 === 0\n # prints the string 'fizz' to the terminal if the conditional statement above returns <true>.\n puts 'fizz'\n # if and eslif above return <false>: the conditional statement: <i> modulo <num_2> === 0, is evaluated. If <true> then the code beneath executes.\n elsif i % num_2 === 0\n # prints the string 'buzz' to the terminal if the conditional statement above returns <true>.\n puts 'buzz'\n # if none of the other conditional statements return <true> the code beneath <else> executes.\n else\n # prints the local variable <i> to the terminal.\n puts i\n # ends the if statement block\n end\n # ends the for...in loop\n end\n # ends the <fizzbuzz> function\nend", "def compile_to_ruby\n \"if \" + indent_c(@condition.compile_to_ruby) + \"\\n\" +\n indent_ruby(@then_part.compile_to_ruby) +\n \"\\nelse\\n\" +\n indent_c(@else_part.compile_to_ruby) +\n \"\\nend\"\n end", "def introduce_myself\n #method body\n puts \"'I am handsome'\"\n puts \"i am talented\"\n puts \"i am briliant\"\n puts \"i am amazing\"\n puts 'is talented'\n puts \"is charming\"\n\n #method body\n end", "def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n #groupere les differents noms list par des virgules\n puts \"good bye #{@names.join(\" , \")}. come back soon \"\n\n else puts \"GOODBYE #{@names}. come back SOON\"\n\n end\n\nend", "def say_hi\n # If @names is empty, it will print ...\n if @names.nil?\n puts \"...\"\n # If @names responds to each, which is only useable on a list such as an array, it will print Hello to each name in the list\n elsif @names.respond_to?(\"each\")\n # Performs an action for each element in @names, and use the word in between the vertical bars as the variable for the current iteration\n @names.each do |name|\n # Uses the hashtag and brackets to put a variable into a string\n puts \"Hello #{name}!\"\n end\n # Runs if there is a single element stored in @names\n else\n puts \"Hello #{@names}!\"\n end\n end", "def can_go_on_ride(age, height,boss_son)\n if age >= 18 && (height >= 120 || boss_son == true)\n return \"Enter the ride\"\n else\n return \"Sorry!\"\n end\nend", "def cobble\n puts \"Your shoe is as good as new!\"\n @condition = \"new\"\n end", "def fizzbuzz(num)\n#case is used to evaluate several logical statements instead of using if / else\n case\n#if the variable num is divisible by 15, output \"FizzBuzz\"\n when num % 15 == 0 then \"FizzBuzz\"\n#if the first condition did not apply, if the variable num is divisible by 3, output \"Fizz\"\n when num % 3 == 0 then \"Fizz\"\n#if the first two conditions did not apply, if the variable num is divisible by 5, output \"Buzz\"\n when num % 5 == 0 then \"Buzz\"\n#if the none of the above conditions apply, output the variable num\n else num\n end\nend", "def praise_person(name)\n puts \"#{name} is amazing\"\n puts \"#{name} is talented\"\nend", "def complex_condition?(condition); end", "def body_function \n puts \"Please leave a desposit...\"\n print \"> \"\n body_function = gets.chomp #local variable\n moves = 0\n\nif ['wee', 'pee', 'piss', 'slash', 'tinkle', 'piddle', 'urinate', 'wee-wee', 'pee-pee', '1'].any? { |word| body_function.downcase.include?(word) } # => true\n puts \"You unzip you pants and pee into the bowl. At first it seems awkward, but eventually you manage to do what you need to do\"\n moves = 3\n \nelsif ['poo', 'poop', 'crap', 'defecation', 'excretion', 'dung', 'discharge', 'shit', 'turd', 'bog', '2'].any? { |word| body_function.downcase.include?(word) } # => true\n puts \"Dropping your pants you place your bottom on the toilet seat. It's not long until you do what you needed to do\"\n moves = 5\n \nelsif ['fart', 'fluff', 'puff', 'let rip'].any? { |word| body_function.downcase.include?(word) } # => true\n puts 'You sit on the toilet seat and let it rip. A little puff of the arse trumpet is all you can give.'\n moves = 1\n \nelse\n puts \"You need to make a desposit. The Mirai_Toire_Go v2.5 needs lower body increment to function\"\n body_function\n end\nend", "def fizzbuzz(num_1, num_2, range)\n# Iterate through each number in a range from 1 to whatever number is input for\n# the 'range' argument, and do something for each number.\n (1..range).each do |i|\n# Use an if statement that executes code if the conditional is true. If i is\n# divisible by num_1 and num_2, then execute the code below. If not true, move\n# on to the elsif statement.\n if i % num_1 === 0 && i % num_2 === 0\n# Print 'fizzbuzz' if the conditional above is true.\n puts 'fizzbuzz'\n# Use an elsif statement that executes code if the conditional is true. If i is\n# divisible by num_1, then print 'fizz'. If not true, move on to next elsif statement.\n elsif i % num_1 === 0\n puts 'fizz'\n# Use an elsif statement that executes code if the conditional is true. If i is\n# divisible by num_2, then print 'buzz'. If not true, move on to else statement.\n elsif i % num_2 === 0\n puts 'buzz'\n# If none of the above conditional statements are true, print i.\n else\n puts i\n# End the if/elsif/else statement.\n end\n# End the for loop.\n end\n# End the fizzbuzz method definition.\nend", "def codename_method\ncode_names = []\n # set up a loop to ask agent for names continuously, until 'done'\noption = ''\nuntil option == \"quit\"\n # get user input and call methods to swap and scramble the name\n puts \"What is your real name, agent?\"\n agent_name = gets.chomp\n # call both methods to swap and scramble name -> string output, use split to convert\n #to an array for later iteration\n alias_name = code_letter(swap_split_name(agent_name)).split\n # use map method to get both words in the array and capitalize both, use bang op\n p alias_name\n alias_name.map do |x|\n x.capitalize!\n end\n alias_name = alias_name.join(' ')\n # Give agent a new name!\n puts \"Agent, your new identity is: #{alias_name}\"\n # add alias_name to array code_names\n code_names << [agent_name, alias_name]\n # ask user for more input if wanted, otherwise quit\n puts \"Would you like to enter another name? Press any key and enter.\n If Finished, type 'quit'.\"\n option = gets.chomp\n end\n\n\n # Finally, iterate through the array, and print all user input before program exits.\ncode_names.each do |real, spy|\n puts \"Agent's real name: #{real}.\"\n puts \"Agent's code name: #{spy}.\"\nend\nend", "def can_go_on_ride(age, height, boss_son)\n if age >= 18 && height >= 120 || boss_son == true\n return \"Enter the ride\"\n else\n return \"Sorry!\"\n end\n\n\n\nend", "def basic_methods \n\n\t#ask the user their name\n\tputs \"What is your name?\"\n\n\t#create a variable to get the name then use the chomp method to remove the enter \n \tname = gets.chomp\n\n \t#let the user know how nice their name is \n \tputs \"What a lovely name \" + name\n\n \t#ask the user how old they are \n\tputs \"How old are you?\"\n\n\t#create a variable to old the users age and use the gets method to get the string of data and convert it into a integer to be calculated like so\n\tage = gets.to_i\n\n\t#calculate how old the user will be in 10 years \n \tputs \"You are \" + age.to_s\n \tputs \"That\\'s a good age\"\n \tputs \"Do you realize that in ten years you will be \" \n \ttenyears = age + 10 \n \ttenyears.to_i\n \tputs \"#{tenyears}\"\n\n \t#ask the user some more questions about themselves\n \tputs \"#{name} what do you do for a living?\"\n \tliving = gets.chomp\n\n \tputs \"What made you decide to #{living}\"\n\n \tdecide = gets.chomp\n \tputs \"That\\'s interesting!\"\n \tputs \"Good luck on all your endevours!\"\n \tputs \"GOD BLESS YOU #{name}\"\n\t\n\t#you have to let Ruby know to end the method before you can call the method. \n\tend", "def greet(personname)\n if personname != \"\"\n puts \"Hello, #{personname}!\"\n else\n puts \"Hello, World!\"\n end\nend", "def result(score) # created method named \"result\" that takes one\n # one arguement named score\n\n if score == 10 # compares score using \"==\" to value 10 and if\n # it's true it will excute until it hits an \"end\", \"else\" or \"elsif\".\n # Pro-tip: \"==\" is used for comparison and \"=\" is used for assignment.\n\n\n puts \"You won! Woo Hoo!\" # if true print \"You won! Woo Hoo!\"\n\n else # what to do if the the condtional is not true\n # other condtionals:\"elsif\" is short for else if\n\n puts \"Try Again!\" # else print \"Try Again!\"\n\n end # end of condtional\n\nend", "def fizzbuzz (i)\n if i % 3 == 0 && i % 5 == 0\n return \"FizzBuzz\"\nend\n if i % 3 == 0 \n return \"Fizz\"\nend\n if i % 5 == 0 \n return \"Buzz\"\nend \nend", "def captain_obvious(name, what_you_love)\n\tputs(\"My name is #{name} and I love #{what_you_love}!\")\nend", "def to_code(extra=nil)\n \"if #{line_up_cond} \\n #{line_up_result(extra)} \\n end\"\n end", "def follow_criterias?(methods)\n all_pass = true\n if (not methods.is_a? Array) or methods.size < 0\n return false \n else\n for m in methods\n if self.class.method_defined? m\n # evaluate \n all_pass &&= self.send(m) \n return all_pass if not all_pass #break if one not pass\n else\n puts \"[Error] #{m} method is not defined!\"\n return false # fail criteria not defined\n end\n end\n return all_pass\n end\n end", "def greet(name,owner)\n name == owner ? 'Hello boss' : 'Hello guest'\nend", "def greet(name,owner)\n name == owner ? 'Hello boss' : 'Hello guest'\nend", "def fizzbuzz(number)\n #binding.pry\n if (number % 3 == 0 && number % 5 == 0)\n then \"FizzBuzz\"\n elsif number % 3 == 0\n then \"Fizz\"\n elsif number % 5 == 0\n then \"Buzz\"\n else\n nil\n end\nend", "def introduce_myself\n puts \"My name is Anndony Quemag\"\n puts \"My age is 23\"\n puts \"Im work at kommit\"\nend", "def result_declare (name, result)\n say \"Great, #{name}! You win this game!\" if result == \"win\"\n say \"Oops, sorry, #{name}. You lose this game.\" if result == \"lose\"\n say \"#{name}, we draw. :)\" if result == \"draw\"\nend", "def printUsersChoiceOnScreen()\n $strAnswer = ($arrCorrectAnswers[$intQuestionOnScreen - 1].strip)\n if $strAnswer.length == 1\n case $arrUserAnswers[$intQuestionOnScreen - 1]\n when \"A\"\n $radioA.invoke()\n when \"B\"\n $radioB.invoke()\n when \"C\"\n $radioC.invoke()\n when \"D\"\n $radioD.invoke()\n end\n else\n case $arrUserAnswers[$intQuestionOnScreen - 1]\n when \"A\"\n checkInvoke(true, false, false, false)\n when \"B\"\n checkInvoke(false, true, false, false)\n when \"C\"\n checkInvoke(false, false, true, false)\n when \"D\"\n checkInvoke(false, false, false, true)\n when \"AB\"\n checkInvoke(true, true, false, false)\n when \"AC\"\n checkInvoke(true, false, true, false)\n when \"AD\"\n checkInvoke(true, false, false, true)\n when \"BC\"\n checkInvoke(false, true, true, false)\n when \"BD\"\n checkInvoke(false, true, false, true)\n when \"CD\"\n checkInvoke(false, false, true, true)\n when \"ABC\"\n checkInvoke(true, true, true, false)\n when \"ABD\"\n checkInvoke(true, true, false, true)\n when \"ACD\"\n checkInvoke(true, false, true, true)\n when \"BCD\"\n checkInvoke(false, true, true, true)\n when \"ABCD\"\n checkInvoke(true, true, true, true)\n end\n end\nend", "def main\n $own_process = check_user\n case $own_process\n when \"admin\"\n puts \"----------------------------------\"\n puts \"Lua chon chuc nang\"\n puts \"[1].Tim kiem sach\"\n puts \"[2].Them mot sach moi\"\n puts \"[3].Xoa sach trong thu vien\"\n puts \"[4].Sua thong tin sach\"\n puts \"[5].Them nguoi dung\"\n puts \"[6].Quay lai man hinh dang nhap\"\n puts \"[7].Thoat\"\n\n case gets.chomp.to_i\n when 1\n book_seaching\n when 2\n book_adding\n when 3\n book_deleting\n when 4\n book_editing\n when 5\n user_adding\n when 6\n login\n when 7\n exit\n end\n when \"user\"\n puts \"----------------------------------\"\n puts \"Lua chon chuc nang\"\n puts \"[1].Tim kiem sach\"\n puts \"[2].Quay lai man hinh dang nhap\"\n puts \"[3].Thoat\"\n case gets.chomp.to_i\n when 1\n book_seaching\n when 2\n login\n when 3\n exit\n end\n end\nend", "def if(condition, true_value, false_value)\n {\"Fn::If\" => [condition, true_value, false_value]}\n end", "def say_hello(anything)\n # write code\n puts anything\n puts \"Hello World!\"\nend", "def can_i_access_your_profile(is_friend, my_city, their_city)\n if is_friend\n puts \"Yes\"\n elsif my_city == their_city\n puts \"Maybe\"\n else\n puts \"No\"\n end\nend", "def firstMethod()\n p \"hey this is first method ok\"\n p \"here i show how can create method in ruby\"\n p \" know time end \"\nend", "def saludar(name=nil)\n print 'Hola'\n print \" #{name}\" if name\n print \"\\n\"\nend", "def test_code2(flight_planner_instance)\n puts flight_planner_instance.can_i_fly?(\"MIA\", \"LAX\") == false\n puts flight_planner_instance.can_i_fly?(\"PHX\", \"LAX\") == true\nend", "def oh_crap_i_forgot(title, person, location, date, thesis, major_accomplishment, pronoun)\n pronoun = 'male' ? p_use = 'he' : p_use = 'she'\n date < 1000 ? e_or_l = 'early era' : e_or_l = 'late era'\n\n puts \"#{title} : The Story of #{person}\"\n puts \" \"\n puts \"In #{e_or_l} #{location}, #{person} was a pretty big deal. #{thesis}. #{pronoun.capitalize} changed the very fabric of #{location} when #{pronoun} #{major_accomplishment}.\"\n puts \" \"\n puts \"All in all, #{e_or_l} #{location} would not have been so successful without #{person}, nor would #{location} be the way it is today without those contributions.\"\n puts \"By Mikee.\"\nend", "def my_method\n puts \"ayyy\"\n puts \"joe\"\nend", "def player_name\n puts \"What is your name?\"\n name = gets\n name_chomped = name.chomp.capitalize\n puts \"Hi #{name_chomped}! How are you doing today?\"\n response = gets.capitalize\n if response.include? \"not\"\n \tputs \"I am sorry, there's nothing I can do. Let's get on with the game.\"\n elsif response.include? \"Good\" or response.include? \"Great\" \n \tputs \"I am sure you are! But you won't be if you lose!\"\n else\n \tputs \"Okay! Good Luck with the game!\"\n end\n name_chomped\nend", "def fizzbuzz(num_1, num_2, range)\n# Do i for all the numbers in a range from 1 to the value that will be assigned to the variable \"range\".\n (1..range).each do |i|\n# If i divided by the value assigned to num_1 is equal to 0 and i divided by the value assigned to num_2 is equal to zero then print \"fizzbuzz\".\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n# If i divided by the value assigned to num_1 is equal to zero print \"fizz\".\n elsif i % num_1 === 0\n puts 'fizz'\n# If i divided by the value assigned to num_2 is equal to zero print \"buzz\".\n elsif i % num_2 === 0\n puts 'buzz'\n# If none of the previous conditions are true print i.\n else\n puts i\n# Ends the if/else statement.\n end\n# Ends the argument.\n end\n# Ends the method.\nend", "def sleigh(name, password)\n return true if name == \"Santa Claus\" && password == \"Ho Ho Ho!\"\n return false\nend", "def age_num_conditional(age, sum, name, fav1, fav2, fav3) \r\n if age > sum\r\n \t\t\"Your age of #{age} is greater than #{sum}, Which is the sum of your favorite numbers.\"\r\n \telse \r\n \t\t\"Your age of #{age} is less than #{sum}, Which is the sum of your favorite numbers.\"\r\n\tend \r\nend", "def say_bye\r\n if @names.nil?\r\n puts \"...\"\r\n elsif @names.respond_to?(\"join\")\r\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\r\n else\r\n puts \"Goodbye #{@names}. Come back soon!\"\r\n end\r\n end", "def fizzbuzz(num_1, num_2, range)\n #starts an iteraterion over the integers 1-value of range, defined as i\n (1..range).each do |i|\n # 41&42, if the remainder of i devided by parameter num_1 is equavalent to zero, AND the remainder of i divided by num_2 is zero, print 'fizzbuzz'\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n # if the remainder of i divided by num_1 is equavalent to zero, print string \"fizz\"\n elsif i % num_1 === 0\n puts 'fizz'\n # if the remainder of i divided by num_2 is zero, print string \"buzz\"\n elsif i % num_2 === 0\n puts 'buzz'\n #if no other conditional has been satisfied, print i\n else\n puts i\n #closes the conditional.\n end\n #closes the iteraterion\n end\n#closes the method\nend", "def mechanic\n if @functional\n \t@functional = false\n else\n \t@functional = true\n end\n\n if @functional\n puts \"The bike is working again!\"\n else\n puts \"The bike is in the shop! :(\"\n end\n end", "def check_answer_input(range) #this method both prints and checks the answer\r\n\r\n\tequation = new_equation(range)\r\n\tanswer = false\r\n\r\n\twhile answer == false\r\n\t\tputs equation\r\n\t\tresult = eval equation\r\n\t\tputs \"{answer: #{result}}\"\r\n\t\tanswer_user = gets.chomp\r\n\r\n\t\tif answer_user.downcase == \"q\" #make a new method for if ??? - yes, I would make a new method\r\n\t\t\texit\r\n\t\telsif answer_user.to_i == result\r\n\t\t\tputs \"Correct!\"\r\n\t\t\tcheck_answer_input(range)\r\n\t\telse\r\n\t\t\tputs \"Try again\"\r\n\t\tend\r\n\tend\r\nend", "def statement; end", "def run_cond; end", "def fizzbuzz(num_1, num_2, range)\n #Take all integers between 1 and the range arguments and does and using\n #if/elsif/else statements makes a function\n (1..range).each do |i|\n #Takes the integers from line 48 and divides them by the num_1 argument,\n #then takes the remainder, and sees if they equal 0, does this with num_2\n #argument as well, and if both are true runs the next line\n if i % num_1 === 0 && i % num_2 === 0\n #If the above is true, prints to terminal string 'fizzbuzz'\n puts 'fizzbuzz'\n #If the above code was not true and did not run, takes the integers from\n #line 48 and once again sees if the remainder of the argument num_1 ONLY\n #is equal to 0, if true, runs the next line\n elsif i % num_1 === 0\n #If the above is true, prints to terminal string 'fizz'\n puts 'fizz'\n #If both of the above code was not true and did not run, takes the integers\n #from line 48 and once again sees if the remainder of the argument num_2\n #ONLY is equal to 0, if true, runs the next line\n elsif i % num_2 === 0\n #If the above is true, prints to terminal string 'buzz'\n puts 'buzz'\n #If none of the above code was true for any argument, runs the code below\n else\n #If the above is true, prints the integer to terminal\n puts i\n #Ends the if/elsif/else function\n end\n #Ends the function that gave all integers between 1 and argument 'range' and\n #applied them to the if/elsif/else function\n end\n#Ends the function that defined what fizzbuzz did\nend", "def say_hello_4 name1, name2\n if name1.empty? or name2.empty?\n return \"Who are you?!\"\n end\n # Doesn't reach the last line because we used return\n \"hello, #{name1} and #{name2}\"\nend", "def fizzbuzz(num_1, num_2, range)\n #calls alll numbers in range to each do variable |i|\n (1..range).each do |i|\n # begins if else statement if i can be divided by num_1 and if i divided by num_2\n if i % num_1 === 0 && i % num_2 === 0\n # 'fizzbuzz' is printed to terminal\n puts 'fizzbuzz'\n #if the above is not true i will be checked if divisble by num_1\n elsif i % num_1 === 0\n # if true 'fizz' will be printed to the terminal\n puts 'fizz'\n # checks if i can be divided by num_2\n elsif i % num_2 === 0\n # if true 'buzz' is printed to the terminal\n puts 'buzz'\n #if none of the above is true\n else\n # the variable i is printed to the terminal\n puts i\n #ends if else statement\n end\n #ends range.each do\n end\n #ends method\nend", "def introduce_myself\n puts \"I am handsome\"\n puts \"I am talented\"\n puts \"I am brilliant\"\nend", "def greet(name)\n\nif name == \"\"\n p nil\nelsif name == nil\n p nil\nelse\n \"hello #{name}!\"\nend\n\nend", "def names(arg1, arg2)\n puts \"man: #{arg1}, woman: #{arg2}\"\n puts \"when #{arg1} met #{arg2}\"\n puts \"#{arg1} is much funnier than #{arg2}\"\nend", "def say_hi\n if @names.nil?\n puts \"...\"\n # If the @names object responds to each, it is something that you can iterate over, so iterate over it and greet each person in turn.\n #Finally, if @names is anything else, just let it get turned into a string automatically and do the default greeting.\n elsif @names.respond_to?(\"each\")\n #each is a method that accepts a block of code then runs that block of code for every element in a list, and the bit between do and end is just such a block.\n #A block is like ananonymous function or lambda. The variable between pipe characters is the parameter for this block.\n @names.each do |name|\n puts \"Hi #{name}\"\n end\n else\n puts \" Hi #{@names}\"\n end\n end", "def if_elsif_else\nif x == true\n puts x\nend\n\nif x\n puts x\nend\n\nif x\n puts \"It's true\"\nelse\n puts \"It's false\"\nend\n\nif num <= 0\n puts \"The number is too low\"\nelsif num > 3 && num < 7\n puts \"The number is just right\"\nelse\n puts \"The number is too high\"\nend\n\nif num % 2 == 0\n if num < 10\n puts \"even less than 10\"\n else\n puts \"even greater than 10\"\n end\nelse\n puts \"The number is odd\"\nend\nend", "def fizzbuzz(num_1, num_2, range)\n# looping through the code block using iteration.\n (1..range).each do |i|\n# If left hand operand i devided by right hand operand num_1 is equal to 0 and left hand operand i devided by right hand operand num_2 is equal to 0 then print fizzbuzz\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n# If not the first if check left hand operand i devided by right hand operand num_1 is equal to 0 if so print fizz.\n elsif i % num_1 === 0\n puts 'fizz'\n# If not the first if or first elsif check left hand operand i devided by right hand operand num_2 is equal to 0 if so print buzz. \n elsif i % num_2 === 0\n puts 'buzz'\n# If non of the above print i\n else\n puts i\n# End block of code\n end\n end\nend", "def ask_first_name\n puts \"\\n\" + \"====\" + \"\\n\" + \"ASK FIRST NAME\" + \"\\n\" + \"====\"\n puts \"Quel est ton nom?\" \nend", "def greeting\n # call defined determine_current_hour method from inside this greeting method\n # save resulting value to current_hour variable\n # this runs the determine_current_hour method and passes data back to greeting method\n # Ruby automatically returns the last value in its method (current_hour)\n current_hour = determine_current_hour\n name = determine_username\n if(current_hour > 3 && current_hour < 12)\n time = \"morning\"\n elsif(current_hour > 12 && current_hour < 18)\n time = \"afternoon\"\n elsif(current_hour > 18 || current_hour < 2)\n time = \"evening\"\n end\n\n puts \"Good #{time}, #{name.capitalize}!\"\nend", "def input_logic(value_from_user_input_method)\n\tcase value_from_user_input_method\n\t\twhen 1\n\t\t\tcommand_line_menu\n\t\twhen 2\n\t\t\tsearch\n\t\twhen 3\n\t\t\tputs \"GOODBYE\"\n\t\t\texit(0)\n\t\telse\n\t\t\tputs \"Please make a selection between 1-3. Typing anything else will only show you this message again.\"\n\t\t\tmenu\n\tend\nend", "def build_if_tree(application_name, method_names)\n user_input = get_user_input\n\n #title page------\n title\n #end title page----\n\n #look through each option and compare to input, if it has an associated method, run it. If no matches, prompt to enter a valid option and start again.\n method_names.each_with_index do |method_name, index|\n if user_input.to_i == index + 1\n #had return send(method_name)\n send(method_name)\n end\n end\n #returns error message if not a valid option\n if !user_input.to_i.between?(1, method_names.length)\n puts \"\\n****Error: Please enter a valid number****\"\n puts \"\\n\"\n application_builder(application_name, method_names)\n end\n end", "def get_name \n\tputs \"What is your surname?:\"\n\tname = gets.chomp \n\tprint_thanks \n\tif check_name_ok?(name)\n\t\tthen print_new_name(name) end\nend", "def introduceMyself\n puts \"I am handsome\"\n puts \"I am talented\"\n puts \"I am brilliant\"\nend", "def puts_if_condition(condition)\r\n re = /(.*)\\s?\\[(.*)\\]\\s*\\Z/\r\n cond = CGI.escapeHTML(condition)\r\n match1 = cond.match re\r\n if match1\r\n condText = match1[1].strip\r\n condCode = match1[2].strip\r\n else\r\n condText = cond.strip\r\n condCode = \"\"\r\n end \r\n puts \" <d:IfCondition>\"\r\n puts \" <r:Description>\"\r\n puts \" <r:Content xml:lang=\\\"en-GB\\\">#{condCode}</r:Content>\"\r\n puts \" </r:Description>\"\r\n puts \" <r:Command>\"\r\n puts \" <r:ProgramLanguage>pseudo-code</r:ProgramLanguage>\"\r\n puts \" <r:CommandContent>#{condText}</r:CommandContent>\"\r\n puts \" </r:Command>\"\r\n puts \" </d:IfCondition>\"\r\n end", "def main\n if 0\n p 0\n end\n\n if \"\" then\n p 1\n end\n\n if false\n p 2\n end\n\n if nil\n p 3\n end\n\n scope\nend", "def process_employees (amount)\n\tuntil amount == 0\n\t\tputs \"Employee #{amount}, processing now.\"\n\n\t\tputs \"What is your name?\"\n\t\tname = gets.chomp\n\n\t\tputs \"How old are you? (int)\"\n\t\tage = (gets.chomp).to_i\n\n\t\tputs \"What year were you born? (int)\"\n\t\tbirth_year = (gets.chomp).to_i\n\n\t\tputs \"Our company cafeteria serves garlic bread. Should we order some for you? (y/n)\"\n\t\tgarlic_bread = gets.chomp\n\n\t\tputs \"Would you like to enroll in the company's health insurance? (y/n)\"\n\t\tinsurance = gets.chomp\n\n\t\t#convert values of garlic_bread and insurance into booleans\n\t\tgarlic_bread = convert_to_boolean(garlic_bread)\n\t\tinsurance = convert_to_boolean(insurance)\n\n\t\t# check the age and assign to variable for the following logic checks, for simplicity.\n\t\tverified_age = check_age_accuracy(age, birth_year)\n\n\t\t#Checking for any vampireness before we even get into the rest of the questions.\n\t\tif vampire_initial_check(name) == false\n # if the name is fine, we will proceed with the rest of the process.\n\t\t\t# If the employee got their age right, and is willing to eat garlic bread or sign up for insurance, the result is “Probably not a vampire.”\n\t\t\tif (verified_age && (garlic_bread || insurance))\n\t\t\t\tputs \"Probably not a vampire.\"\n\t\t\t# If the employee got their age wrong, and hates garlic bread or waives insurance, the result is “Probably a vampire.”\n \t\telsif (!verified_age && !(garlic_bread || insurance))\n\t\t\t\tputs \"Probably a vampire.\"\n\t\t\t# If the employee got their age wrong, hates garlic bread, and doesn’t want insurance, the result is “Almost certainly a vampire.”\n\t\t\telsif (!verified_age && !garlic_bread && !insurance)\n\t\t\t\tputs \"Almost certainly a vampire.\"\n\t\t\telse\n\t\t\t\t\"results inconclusive.\"\n\t\t\tend\n # if the name is not fine, we will declare them a vampire and move on.\n\t\telse\n\t\t\tputs \"Definetly a vampire.\"\n\t end\n\n #Display employee number and reduce amount by 1 to continue or stop loop.\n\t\tputs \"Employee #{amount} processed.\"\n\t\tamount = amount - 1\n\tend\n\tputs \"All employees have been processed. Thank you for using the WIB 2.0. Good day.\"\n\tputs \"...Actually, never mind! What do these questions have to do with anything? Let's all be friends.\"\nend", "def fizzbuzz(fiz_3)\n if fiz_3 % 3 == 0 && fiz_3 % 5 == 0 \n return \"FizzBuzz\"\n end \n \n if fiz_3 % 3 == 0 \n return \"Fizz\"\n end\n \n if fiz_3 % 5 == 0 \n return \"Buzz\"\n end\nend", "def fizzbuzz(num_1, num_2, range)\n # this line defines a for-loop that runs from 1 to the range parameter passed in\n # this will iterate on each number from 1 to the range parameter inclusive\n (1..range).each do |i|\n # this line defines an if statement with 3 conditional statements\n # 1) the remainder of the iterator number (i) / num_1 parameter is 0 (meaning even division)\n # 2) the remainder of the iterator number (i) / num_2 parameter is 0 (meaning even division)\n # 3) that both of the above conditionals are true, meaning i is evenly divided by both nums\n if i % num_1 === 0 && i % num_2 === 0\n # if the above conditionals are true this prints a string\n puts 'fizzbuzz'\n # this line will run if the previous if returns false. this defines a second\n # conditional that returns true if the remainder of i / num_1 parameter\n # is 0 (meaning even division)\n elsif i % num_1 === 0\n # if the above conditional is true this line prints a string\n puts 'fizz'\n # this line will run if the previous elsif returns false. this defines a third\n # conditional that returns true if the remainder of i / num_2 parameter\n # is 0 (meaning even division)\n elsif i % num_2 === 0\n # if the above conditional is true this line prints a string\n puts 'buzz'\n # if none of the above the above conditionals return true run line below\n else\n # this line prints the iterator number i\n puts i\n # this line ends the if-elsif-else block\n end\n # this line ends the for-loop\n end\n# this line ends the fizzbuzz method\nend", "def q_insurance(name,wager)\n loop do\n status_bar\n if name = \"You\"\n puts \"Do you want insurance? Put down #{'%.2f' % (@wager/2)} to buy insurance.\\n\"\n else\n puts \"Does #{name} want insurance? Put down #{'%.2f' % (@wager/2)} to buy insurance.\\n\"\n end\n puts \"Get #{@wager} back if dealer reveals a blackjack. [y/n]\"\n answer = gets.chomp.downcase\n\n if answer[0] == \"y\" || answer == \"\"\n return true\n elsif answer[0] == \"n\"\n return false\n end\n clean\n puts \"That is not a valid answer!\"\n gets\n end\nend", "def fizzbuzz(num)\n # Example comment line\n\n#sets up case which is similiar to if statements. \n case\n #when number is multiple of 15, return \"FizzBuzz\", do no further cases and end\n when num % 15 == 0 then \"FizzBuzz\"\n #when number is multiple of 3, return \"Fizz\", do no further cases and end\n when num % 3 == 0 then \"Fizz\"\n #when number is multiple of 5, return \"Buzz\", do no further cases and end\n when num % 5 == 0 then \"Buzz\"\n #if all cases do no match, return the number \n else num\n #ends the case statement \n end\n#end the function definition\nend", "def say_hello4(name1, name2)\n if name1.empty? or name2.empty?\n return \"Who are you?!\"\n end\n # Doesn't reach the last line because we used return\n \"hello, #{name1} and #{name2}\"\nend" ]
[ "0.65457773", "0.63962626", "0.61645144", "0.6052445", "0.59823644", "0.59612036", "0.5883614", "0.5883614", "0.57998335", "0.5707243", "0.56869644", "0.56635284", "0.5638576", "0.5607927", "0.55924493", "0.55822223", "0.55742896", "0.55622834", "0.55575985", "0.55393755", "0.55286974", "0.5528307", "0.5519006", "0.5516946", "0.54875183", "0.5460588", "0.5456616", "0.5433681", "0.5420685", "0.540443", "0.54004794", "0.5394786", "0.5384847", "0.5381628", "0.53755736", "0.53732294", "0.53725785", "0.5363209", "0.53609645", "0.53606945", "0.5360659", "0.53588855", "0.53574854", "0.5357082", "0.535293", "0.5350184", "0.53489816", "0.53486395", "0.5342542", "0.5337154", "0.532837", "0.5326736", "0.53240705", "0.5319435", "0.5319435", "0.5317649", "0.53150123", "0.5294621", "0.5289637", "0.528132", "0.52731144", "0.52663803", "0.5258246", "0.5257945", "0.5257086", "0.5248829", "0.52487123", "0.5246039", "0.52458405", "0.52441657", "0.5238033", "0.5233692", "0.5227003", "0.5220864", "0.52172995", "0.52127117", "0.5208364", "0.52073264", "0.5202337", "0.51966375", "0.5194838", "0.5192927", "0.5186682", "0.51854485", "0.5183071", "0.5182955", "0.51805323", "0.5180378", "0.5179492", "0.5177562", "0.5177541", "0.51736706", "0.5172527", "0.5171519", "0.5168593", "0.5164803", "0.5164659", "0.5161223", "0.51565117", "0.5155305", "0.5155129" ]
0.0
-1
an empty array accessible to all methods
def save_students file = File.open("students.csv","w") @students.each do |student| student_data = [student[:name], student[:cohort]] csv_line = student_data.join(",") file.puts csv_line end file.close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array\n raise \"Not implemented\"\n end", "def another; return []; end", "def all\n []\n end", "def __array__; self; end", "def to_ary\n\t []\n\tend", "def variables\n EMPTY_ARRAY\n end", "def array\n @@array\n end", "def initialize; @ary = []; end", "def to_a; []; end", "def required_data() [] end", "def to_ary; []; end", "def initialize\n @array = []\n end", "def all\n @@all ||= Array.new\n end", "def to_ary\n nil\n end", "def to_ary\n nil\n end", "def to_ary\n nil\n end", "def to_ary\n nil\n end", "def to_ary\n nil\n end", "def array_start\n []\n end", "def to_ary; nil; end", "def values\n []\n end", "def to_ary\n nil\n end", "def to_ary\n nil\n end", "def to_ary\n nil\n end", "def to_ary\n nil\n end", "def airports_normal\n return Array.new\n end", "def array()\n\t\t@array\n\tend", "def ignorable_objects\n\t\t[]\n\tend", "def empty()\n \n end", "def get_data\n @data = []\n end", "def Array(p0) end", "def void_array(*args)\n return nil.to_a\n end", "def discardable\n []\n end", "def defaults\n []\n end", "def invokables\n []\n end", "def get_items\n\t\t@arr\n\tend", "def array\n\t\t#create an array of\n\t\tarray = [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\tend", "def array\n @array\n end", "def airports_out_of_region\n return Array.new\n end", "def exposed_methods\n []\n end", "def exposed_methods\n []\n end", "def variables_instance\n warn 'i dont like this!'\n []\n end", "def initialize arr = []\n super arr\n end", "def []=(*) end", "def in_memory\n []\n end", "def initialize\n @data = []\n end", "def initialize\n @more_array = Array.new\n end", "def to_ary()\n return nil;\n end", "def all\n @list || []\n end", "def empty!\r\n\t\t@items = []\r\n\tend", "def empty!; end", "def items\n\t\t\t\tnil\n\t\t\tend", "def array\n self.allObjects\n end", "def initialize()\n\t@list_arr\t= []\nend", "def missing_data\n only_missing.to_a\n end", "def get_array\n\t\tsynchronize do\n\t\t\t@condition.wait_until{@array.size > 0}\n\t\t\ta = @array\n\t\t\t@array = []\n\t\t\treturn a\n\t\tend\n\tend", "def in_memory\n []\n end", "def in_memory\n []\n end", "def initial_state\n []\n end", "def existing\n []\n end", "def list\n {}\nend", "def zero()\n\treturn([0,0,0,0,0,0,0,0,0])\nend", "def initialize\n\t\t@e = []\n\tend", "def get_all()\n raise \"Must be overridden\"\n end", "def all\n\t\t@data_base.keys.dup || []\n\tend", "def make_array\n [@name, @author, @deviation_url, @views, @favs, @comments]\n end", "def values\n @values ||= []\n end", "def initialize\n @Users = Array.new \n end", "def keys\n return [], []\n end", "def initialize\n empty!\n end", "def initialize\n empty!\n end", "def keys\n return []\n end", "def initialize_issues_array\n find_all_issues\n end", "def to_a; Array(force) end", "def to_ary\n [ self ]\n end", "def get_items\r\n @arr.to_a\r\n end", "def to_a; [self] end", "def to_a; [self] end", "def values\n @values ||= []\n end", "def clear\n with(keys: EMPTY_ARRAY)\n end", "def initialize\n @listOfItem = Array.new\n end", "def __elements\n @__elements ||= {}\n end", "def initialize arr = [], deferred = [], missing = []\n super arr\n @deferred = deferred\n @missing = missing\n end", "def clear_data \n @data = []\n end", "def list\n @list ||= []\n end", "def build_array\n arr = []\n yield(arr)\n arr \n end", "def methods=(_arg0); end", "def clear\n @known = []\n end", "def data\n {}\n end", "def attributes; @attributes ||= []; end", "def initialize\n @_calls = []\n end", "def to_a; [self]; end", "def items\n @items ||= []\n end", "def empty_curve\n Array.new(FRAMES, 0.0)\n end", "def points\n []\n end", "def elements; end", "def elements; end", "def elements; end", "def instantiate_new_array\n<<<<<<< HEAD\n Array.new\nend", "def users\n []\n end", "def all\n @rarray\n end" ]
[ "0.73341405", "0.7154377", "0.70395124", "0.6939797", "0.68577194", "0.6831367", "0.67742383", "0.67736715", "0.6770608", "0.675761", "0.6746169", "0.67191696", "0.6681353", "0.661779", "0.661779", "0.661779", "0.661779", "0.6611431", "0.65442127", "0.6529813", "0.652277", "0.6505915", "0.6505915", "0.6505915", "0.6505915", "0.6502524", "0.64952826", "0.645656", "0.6393116", "0.63789195", "0.63611114", "0.6334588", "0.6327558", "0.63256234", "0.63189673", "0.63172346", "0.6296135", "0.6292642", "0.6292023", "0.62846667", "0.62846667", "0.6251168", "0.6241256", "0.6222292", "0.62099326", "0.6208323", "0.6190815", "0.61832386", "0.618115", "0.61775017", "0.6176499", "0.6162423", "0.6152129", "0.6145069", "0.61387867", "0.613435", "0.6128402", "0.6128402", "0.6122757", "0.6091468", "0.6087842", "0.60775876", "0.6071743", "0.60342175", "0.60334545", "0.603068", "0.602223", "0.60171086", "0.59929466", "0.59864724", "0.59864724", "0.5981396", "0.59717256", "0.5959422", "0.59421134", "0.593213", "0.5928745", "0.5928745", "0.59279776", "0.5917732", "0.59148663", "0.59141994", "0.5905558", "0.5897715", "0.58936566", "0.58773965", "0.5873992", "0.58636725", "0.5857826", "0.584588", "0.584565", "0.58355963", "0.58351606", "0.5830997", "0.58196956", "0.58165", "0.58165", "0.58165", "0.58129096", "0.5810123", "0.5806773" ]
0.0
-1
Creates the window contents
def create_contents @shell.layout = GridLayout.new(6, true) Label.new(@shell, SWT::NONE).text = "Your name:" @name_box = Text.new(@shell, SWT::BORDER) layout_data = GridData.new(GridData::FILL_HORIZONTAL) layout_data.horizontalSpan = 4 @name_box.layout_data = layout_data @status_label = Label.new(@shell, SWT::BORDER) layout_data = GridData.new(GridData::FILL_HORIZONTAL) layout_data.horizontalSpan = 3 @status_label.layout_data = layout_data @button = Button.new(@shell, SWT::PUSH) @button.text = "Click me!" layout_data = GridData.new(GridData::END, GridData::CENTER, false, false) layout_data.horizontalSpan = 6 @button.layout_data = layout_data @button.addSelectionListener do handle_click end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createWindow\r\n \r\n end", "def create\r\n super # Create the windows\r\n show(PLACEMENT_SCREEN) # Make the main window appear\r\n end", "def remake_window\n self.width = window_width\n self.height = window_height\n create_contents\n end", "def main_window\r\n super\r\n # Make main command window\r\n main_command_window\r\n # Make play time window\r\n @playtime_window = Window_PlayTime.new\r\n @playtime_window.x = 0\r\n @playtime_window.y = 224\r\n # Make steps window\r\n @steps_window = Window_Steps.new\r\n @steps_window.x = 0\r\n @steps_window.y = 320\r\n # Make gold window\r\n @gold_window = Window_Gold.new\r\n @gold_window.x = 0\r\n @gold_window.y = 416\r\n # Make status window\r\n @status_window = Window_MenuStatus.new\r\n @status_window.x = 160\r\n @status_window.y = 0\r\n end", "def createWindow\n windowMask = NSTitledWindowMask |\n NSClosableWindowMask |\n NSMiniaturizableWindowMask |\n NSResizableWindowMask\n self.window = NSWindow.alloc\n .initWithContentRect( WINDOW_RECT,\n styleMask: windowMask,\n backing: NSBackingStoreBuffered,\n defer: true)\n self.window.contentMinSize = WINDOW_MIN_SIZE\n self.window.preventsApplicationTerminationWhenModal = false\n self.window.allowsConcurrentViewDrawing = true\n self.window.hasShadow = true\n end", "def create_description_windows\n width = Graphics.width / 2\n @left_window = Window_PartyTitle.new(0, 0, width)\n @right_window = Window_PartyTitle.new(width, 0, width)\n @left_window.set_text(Vocab.active_members)\n @right_window.set_text(Vocab.standby_members)\n end", "def create_command_window\n end", "def create_details_window\n x = @items_window.right_corner\n y = @items_window.y\n width = Graphics.width / 2\n height = Graphics.height - y\n @details_window = Window_ItemInfo.new(x, y, width, height)\n @items_window.info_window = @details_window\n end", "def createTestWindow(x, y, w, h)\n mdichild = FXMDIChild.new(@mdiclient, \"Child\", @mdiicon, @mdimenu,\n 0, x, y, w, h)\n scrollwindow = FXScrollWindow.new(mdichild, 0)\n scrollwindow.verticalScrollBar.setLine(@font.fontHeight)\n btn = FXButton.new(scrollwindow, TYGER, nil, nil, 0,\n LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 600, 1000)\n btn.font = @font\n btn.backColor = FXColor::White\n mdichild\n end", "def create_all_windows\n en_tm_sb_caw\n create_target_window\n end", "def create_all_shared_acts_win\n h,w = Graphics.height, Graphics.width\n @all_shared_acts_win = Window_BasicTextTB.new(0,0,200,55)\n @all_shared_acts_win.viewport = @viewport\n \n @all_shared_acts_win.text = actions_left_txt_era\n @all_shared_acts_win.no_skin\n @all_shared_acts_win.font_size = 14\n @all_shared_acts_win.hide\n end", "def create_info_window\n y = @enemy_list_window.y\n x = @enemy_list_window.width\n @info_window = Window_EnemyInfo.new(x, y, Graphics.width - x, Graphics.height - y)\n @enemy_list_window.set_info_window(@info_window)\n @category_window.z = 9999\n @info_window.viewport = @viewport\n end", "def main_window\r\n super\r\n # Make help window\r\n @help_window = Window_Help.new\r\n @help_window.set_text(@help_text)\r\n # Make save file window\r\n @savefile_windows = []\r\n for i in 0..3\r\n @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))\r\n end\r\n @savefile_windows[@file_index].selected = true\r\n end", "def document_window(name)\n Window.new {\n title \"Document: \" + name\n\t\t\n text = TextArea.new {\n ...\n }\n }\nend", "def set_windows\n set_title \"R-Bloggyn::#{@usuario.alias}\" #nombre de la ventana\n set_default_size 640, 480 #tamaño de la ventana\n set_skip_taskbar_hint true\n set_window_position Gtk::Window::POS_CENTER #posicion de la ventana\n self.set_attributes\n add @hbox\n show_all #muestra todo\n end", "def create_name_window\n @name_window = Window_StorageName.new\n @name_window.viewport = @viewport\n @name_window.x = @command_window.width\n @name_window.y = @help_window.height\n if @storage_name_window == true\n @name_window.show\n end\n end", "def create_window\n set_buffer_modified() # required still ??\n # first create the main top window with the tab buttons on it.\n $log.debug \" TPane create_buff Top #{@row}, Left #{@col} H #{@height} W #{@width} \"\n #$log.debug \" parentwin #{@parentwin.left} #{@parentwin.top} \"\n\n r = @row\n c = @col\n @form = ScrollForm.new(@parentwin)\n @form.set_layout(1, @width, @row+1, @col+1)\n @form.display_h = 1\n @form.display_w = @width-3\n @buttonpad = @form.create_pad\n\n\n ## We will use the parent window, and not a pad. We will write absolute coordinates.\n @window = @parentwin\n color = $datacolor\n # border around button bar. should this not be in scrollform as a border ? XXX\n @window.print_border @row, @col, 2, @width, color #, Ncurses::A_REVERSE\n @buttonpad.name = \"Window::TPTOPPAD\" # 2010-02-02 20:01 \n @form.name = \"Form::TPTOPFORM\"\n $log.debug(\"TP WINDOW TOP ? PAD MAIN FORM W:#{@window.name}, F:#{@form.name} \")\n @form.parent_form = @parent ## 2010-01-21 15:55 TRYING OUT BUFFERED\n @form.navigation_policy = :NON_CYCLICAL\n #xx @current_form = @form\n #xx color = $datacolor\n #xx @window.print_border @row, @col, @height-1, @width, color #, Ncurses::A_REVERSE\n \n Ncurses::Panel.update_panels\n _recreate_buttons\n \n button_form_repaint true\n @window.wrefresh ## ADDED 2009-11-02 23:29 \n @old_tab = @tabs.first\n @buttons.first().fire unless @buttons.empty? # make the first form active to start with.\n end", "def create_title_window\n @title_window = Window_TitleList.new(TITLE_WINDOW_X, TITLE_WINDOW_Y)\n @title_window.actor = @actor\n @title_window.set_handler(:ok, method(:on_title_ok))\n @title_window.set_handler(:cancel, method(:on_title_cancel))\n @title_window.set_handler(:start, method(:toggle_help))\n @title_window.help_window = @help_window\n @title_window.hide\n end", "def main_window\r\n super\r\n # Make help window\r\n @help_window = Window_Help.new\r\n # Make command window\r\n @command_window = Window_ShopCommand.new\r\n # Make gold window\r\n @gold_window = Window_Gold.new\r\n @gold_window.x = 480\r\n @gold_window.y = 64\r\n # Make dummy window\r\n @dummy_window = Window_Base.new(0, 128, 640, 352)\r\n # Make buy window\r\n @buy_window = Window_ShopBuy.new($game_temp.shop_goods)\r\n @buy_window.active = false\r\n @buy_window.visible = false\r\n @buy_window.help_window = @help_window\r\n # Make sell window\r\n @sell_window = Window_ShopSell.new\r\n @sell_window.active = false\r\n @sell_window.visible = false\r\n @sell_window.help_window = @help_window\r\n # Make quantity input window\r\n @number_window = Window_ShopNumber.new\r\n @number_window.active = false\r\n @number_window.visible = false\r\n # Make status window\r\n @status_window = Window_ShopStatus.new\r\n @status_window.visible = false\r\n end", "def create_item_window\n y = @help_window.bottom_corner\n width = Graphics.width / 2\n height = @materials_window.y - y\n @items_window = Window_ForgeList.new(0, y, width, height)\n @items_window.set_handler(:ok, method(:command_select))\n @items_window.set_handler(:cancel, method(:return_scene))\n @items_window.help_window = @help_window\n @items_window.mat_window = @materials_window\n #@items_window.gold_window = @gold_window\n end", "def main_window\r\n super\r\n # Make actor command window\r\n s1 = $data_system.words.attack\r\n s2 = $data_system.words.skill\r\n s3 = $data_system.words.guard\r\n s4 = $data_system.words.item\r\n @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])\r\n @actor_command_window.y = 160\r\n @actor_command_window.back_opacity = 160\r\n @actor_command_window.active = false\r\n @actor_command_window.visible = false\r\n # Make other windows\r\n @party_command_window = Window_PartyCommand.new\r\n @help_window = Window_Help.new\r\n @help_window.back_opacity = 160\r\n @help_window.visible = false\r\n @status_window = Window_BattleStatus.new\r\n @message_window = Window_Message.new\r\n end", "def createMessageWindow\n return true if @done # already created\n raise unless createWindow\n self.window.delegate = NSApp.delegate # windowWillClose, etc\n self.window.windowController = self\n self.window.addTitlebarAccessoryViewController(createTitlebar)\n [createImageView, createLabel, createTextView].each do |view|\n self.window.contentView.addSubview(view) if view\n end\n setWrapMode(@wrapping)\n self.window.makeFirstResponder(@spinner) # get focus off the imageView\n @done = true\n rescue StandardError => error\n @done = false\n errorString = \"Error in MessageWindow's createMessageWindow method: \"\n if error.class == NSException\n errorString += error.reason\n else\n errorString += error.message\n end\n NSLog(errorString) # Terminal and Console\n end", "def window\n @window || create_window\n end", "def new_window(type); end", "def main_window\r\n super\r\n # Make windows\r\n @left_window = Window_DebugLeft.new\r\n @right_window = Window_DebugRight.new\r\n @help_window = Window_Base.new(192, 352, 448, 128)\r\n @help_window.contents = Bitmap.new(406, 96)\r\n # Restore previously selected item\r\n @left_window.top_row = $game_temp.debug_top_row\r\n @left_window.index = $game_temp.debug_index\r\n @right_window.mode = @left_window.mode\r\n @right_window.top_id = @left_window.top_id\r\n end", "def create_places_window\n y = @legend_window.y + @legend_window.height\n height = Graphics.height - @mission_window.height - @legend_window.height\n @places_window = Window_PlaceList.new(y, height)\n @places_window.set_handler(:ok, method(:place_selection))\n @places_window.set_handler(:cancel, method(:return_scene))\n @places_window.activate\n end", "def create_bs_window\n @blacksmith_window = Window_ForgeBlacksmith.new(0, 0, Graphics.width - 160)\n end", "def create_header_window\n @header_window = Window_MenuHeader.new(Vocab::LOAD)\n end", "def main_window\r\n super\r\n # Make command window\r\n s1 = \"To Title\"\r\n s2 = \"Shutdown\"\r\n s3 = \"Cancel\"\r\n @command_window = Window_Command.new(192, [s1, s2, s3])\r\n @command_window.x = 320 - @command_window.width / 2\r\n @command_window.y = 240 - @command_window.height / 2\r\n end", "def main_window\r\n super\r\n # Make windows\r\n @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)\r\n @input_window = Window_NameInput.new\r\n end", "def create_info_window\n x = @command_window.right_corner\n y = @help_window.bottom_corner\n width = Graphics.width - x\n @info_window = Window_RegistrationInfo.new(x, y, width)\n @info_window.openness = 0 if $game_temp.registration_step == 0\n end", "def initialize(rows, cols, row, col, title_prefix)\n @win = Window.new(rows, cols, row, col)\n @title_prefix = title_prefix\n @max_contents_len = @win.maxx - 3 # 2 for borders\n end", "def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @title_window = Window_Outline_Title.new(0, 0, 640, 56)\n @content_window = Window_Outline.new(0, 56, 640, 424)\n \n # Create Window \n @list_window = Window_Outline_List.new(0, 0, 400, 400, Vocab::tutorials_strings)\n width_remain = (640 - @list_window.width)/2\n @list_window.x = width_remain.floor\n height_remain = (480 - @list_window.height)/2\n @list_window.y = height_remain.floor\n end", "def create_workspace_and_options_tabs()\n new_notebook = Wx::Notebook.new(self)\n\n @ws_tab = Wx::Panel.new(new_notebook) # Add workspace tab\n @ws_mvsizer = Wx::BoxSizer.new(Wx::VERTICAL)\n @ws_tab.set_sizer(@ws_mvsizer)\n\n @options_tab = Wx::Panel.new(new_notebook) # Add options tab\n @options_mvsizer = Wx::BoxSizer.new(Wx::VERTICAL)\n @options_tab.set_sizer(@options_mvsizer)\n\n\n new_notebook.add_page(@ws_tab , \"Workspace\")\n new_notebook.add_page(@options_tab , \"Options\")\n evt_notebook_page_changing(new_notebook.get_id()) {|event| on_changing_page(event) }\n end", "def create_unit_data_window\n @unit_data_win = Window_TBUnitData.new(0,0,160,195)\n @unit_data_win.hide\n end", "def create_dummy_window\n wy = @command_window.y + @command_window.height\n wh = Graphics.height - wy\n @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)\n @dummy_window.viewport = @viewport\n @dummy_window.hide\n end", "def create_help_window\n @help_window = Window_Help.new(1)\n @help_window.viewport = @viewport\n end", "def main_window\r\n super\r\n # Make actor command window\r\n s1 = SDK::Scene_Commands::Scene_Battle::Attack\r\n s2 = SDK::Scene_Commands::Scene_Battle::Skill\r\n s3 = SDK::Scene_Commands::Scene_Battle::Guard\r\n s4 = SDK::Scene_Commands::Scene_Battle::Item\r\n @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])\r\n @actor_command_window.y = 160\r\n @actor_command_window.back_opacity = 160\r\n @actor_command_window.active = false\r\n @actor_command_window.visible = false\r\n # Make other windows\r\n @party_command_window = Window_PartyCommand.new\r\n @help_window = Window_Help.new\r\n @help_window.back_opacity = 160\r\n @help_window.visible = false\r\n @status_window = Window_BattleStatus.new\r\n @message_window = Window_Message.new\r\n end", "def create_enemy_list_window\n y = 0 #@category_window.height + @category_window.y\n h = Graphics.height - y - 80\n @enemy_list_window = Window_EnemyList.new(0, y, 180, h)\n @category_window.set_list(@enemy_list_window)\n @enemy_list_window.set_category_window(@category_window)\n @enemy_list_window.viewport = @viewport\n end", "def main_window\r\n super\r\n # Make help window, item window\r\n @help_window = Window_Help.new\r\n @item_window = Window_Item.new\r\n # Associate help window\r\n @item_window.help_window = @help_window\r\n # Make target window (set to invisible / inactive)\r\n @target_window = Window_Target.new\r\n @target_window.visible = false\r\n @target_window.active = false\r\n end", "def main_window\r\n super\r\n # Make windows\r\n @help_window = Window_Help.new\r\n @left_window = Window_EquipLeft.new(@actor)\r\n @right_window = Window_EquipRight.new(@actor)\r\n @item_window1 = Window_EquipItem.new(@actor, 0)\r\n @item_window2 = Window_EquipItem.new(@actor, 1)\r\n @item_window3 = Window_EquipItem.new(@actor, 2)\r\n @item_window4 = Window_EquipItem.new(@actor, 3)\r\n @item_window5 = Window_EquipItem.new(@actor, 4)\r\n # Associate help window\r\n @right_window.help_window = @help_window\r\n @item_window1.help_window = @help_window\r\n @item_window2.help_window = @help_window\r\n @item_window3.help_window = @help_window\r\n @item_window4.help_window = @help_window\r\n @item_window5.help_window = @help_window\r\n # Set cursor position\r\n @right_window.index = @equip_index\r\n refresh\r\n end", "def initialize(rows, cols, row, col, title_prefix)\n @win = Window.new(rows, cols, row, col)\n super(@win)\n @title_prefix = title_prefix\n set_max_contents_len(cols)\n end", "def create_help_window\n @help_window = Window_Help.new\n end", "def create_help_window\n @help_window = Window_Help.new\n end", "def setupMainPanel\n createStatusBarItem\n createWebView\n createButton\n\n # Setup window and add subviews\n @window = PopupPanel.alloc.initPopup(POPUP_WIDTH + 2, POPUP_HEIGHT + 2)\n @window.contentView.addSubview(@web_view)\n @window.contentView.addSubview(@button);\n end", "def create_mission_window\n @mission_window = Window_Mission.new(0, 0)\n @mission_window.y = Graphics.height - @mission_window.height\n end", "def main_window\r\n super\r\n # Make help window, status window, and skill window\r\n @help_window = Window_Help.new\r\n @status_window = Window_SkillStatus.new(@actor)\r\n @skill_window = Window_Skill.new(@actor)\r\n # Associate help window\r\n @skill_window.help_window = @help_window\r\n # Make target window (set to invisible / inactive)\r\n @target_window = Window_Target.new\r\n @target_window.visible = false\r\n @target_window.active = false\r\n end", "def create_location_window\n x = @status_window.x\n width = @status_window.width\n @location_window = Window_Location.new(x, 0, width)\n @location_window.y = Graphics.height - @location_window.height\n @status_window.height = Graphics.height - @location_window.height\n @status_window.refresh\n end", "def main_window\r\n super\r\n # Make command window\r\n s1 = \"New Game\"\r\n s2 = \"Continue\"\r\n s3 = \"Shutdown\"\r\n @command_window = Window_Command.new(192, [s1, s2, s3])\r\n @command_window.back_opacity = 160\r\n @command_window.x = 320 - @command_window.width / 2\r\n @command_window.y = 288\r\n # If continue is enabled, move cursor to \"Continue\"\r\n # If disabled, display \"Continue\" text in gray\r\n if @continue_enabled\r\n @command_window.index = 1\r\n else\r\n @command_window.disable_item(1)\r\n end\r\n end", "def create_avatar_window\n @avatar_window = Window_AvatarList.new(0, 0, Graphics.width)\n @avatar_window.y = Graphics.height - @avatar_window.height\n @avatar_window.visible = false\n @avatar_window.active = false\n @avatar_window.set_handler(:ok, method(:avatar_selected))\n @avatar_window.set_handler(:cancel, method(:close_avatar))\n end", "def create_mix_window\n @mix_window = Window_MixItem.new(@help_window, @info_viewport)\n @mix_window.set_handler(:ok, method(:on_mixitem_ok))\n @mix_window.set_handler(:confirm, method(:on_mixitem_confirm))\n @mix_window.set_handler(:cancel, method(:on_mixitem_cancel))\n resize_mix_window_yea_abe\n end", "def create_quest_data_window\n x = @quest_list_window.width\n y = (@quest_label_window && (@quest_category_window || \n @quest_category_label_window)) ? @quest_label_window.height : 0\n @quest_data_window = Window_QuestData.new(x, y, Graphics.width - x, \n Graphics.height - y)\n @quest_list_window.help_window = @quest_data_window\n @quest_data_window.quest = @quest_list_window.item\n @quest_data_window.set_handler(:ok, method(:on_data_ok))\n @quest_data_window.set_handler(:cancel, method(:on_data_cancel))\n end", "def main_window ; end", "def create_enemy_window() end", "def create_materials_window\n width = Graphics.width / 2\n @materials_window = Window_ForgeMaterials.new(0, 0, width)\n y = Graphics.height - @materials_window.height\n #y = @gold_window.y - @materials_window.height\n @materials_window.y = y\n end", "def main_window\r\n super\r\n # Make command window\r\n s1 = SDK::Scene_Commands::Scene_Title::New_Game\r\n s2 = SDK::Scene_Commands::Scene_Title::Continue\r\n s3 = SDK::Scene_Commands::Scene_Title::Shutdown\r\n @command_window = Window_Command.new(192, [s1, s2, s3])\r\n @command_window.back_opacity = 160\r\n @command_window.x = 320 - @command_window.width / 2\r\n @command_window.y = 288\r\n # If continue is enabled, move cursor to \"Continue\"\r\n # If disabled, display \"Continue\" text in gray\r\n if @continue_enabled\r\n @command_window.index = 1\r\n else\r\n @command_window.disable_item(1)\r\n end\r\n end", "def initialize\n @msg_win = MessageWindow.new\n @opts_win = OptionsWindow.new\n @board_win = BoardWindow.new\n end", "def main_window\r\n super\r\n # Make command window\r\n s1 = SDK::Scene_Commands::Scene_End::To_Title\r\n s2 = SDK::Scene_Commands::Scene_End::Shutdown\r\n s3 = SDK::Scene_Commands::Scene_End::Cancel\r\n @command_window = Window_Command.new(192, [s1, s2, s3])\r\n @command_window.x = 320 - @command_window.width / 2\r\n @command_window.y = 240 - @command_window.height / 2\r\n end", "def create_command_window\n c_list = []\n @cm_list = []\n CP::MENU_COMMANDS.COMMANDS.each_with_index do |comm, index|\n in_op = comm.size\n if in_op > 3\n in_op -= 1 if comm.include?(:no1)\n in_op -= 1 if comm.include?(:save)\n end\n next if in_op > 3\n c_list.push(comm[0])\n @cm_list.push(index)\n end\n @command_window = Window_Command.new(160, c_list)\n @command_window.index = @menu_index\n save_op = !$game_system.save_disabled\n char_op = $game_party.members.size != 0\n CP::MENU_COMMANDS.COMMANDS.each_with_index do |comm, index|\n i = @cm_list.index(index)\n next unless i\n if comm.include?(:save)\n @command_window.draw_item(i, save_op)\n end\n if comm.include?(:no1)\n @command_window.draw_item(i, char_op)\n end\n end\n end", "def create_help_window\n @help_window = Window_TitleHelp.new(HELP_WINDOW_X, HELP_WINDOW_Y)\n @help_window.hide\n end", "def create_stat_window\n @stat_window = Window_EquipStat.new(STAT_WINDOW_X, STAT_WINDOW_Y)\n @stat_window.actor = @actor\n @stat_window.hide\n end", "def create_number_window\n @number_window = Window_StorageNumber.new\n @number_window.viewport = @viewport\n @number_window.x = ((Graphics.width / 2) - (@number_window.width / 2)) \n @number_window.y = ((Graphics.height / 2) - (@number_window.height / 2)) \n @number_window.hide\n @number_window.set_handler(:ok, method(:on_number_ok))\n @number_window.set_handler(:cancel, method(:on_number_cancel))\n end", "def window\n Window_Base.new(0, 0, 0, 0)\n end", "def content_windows\n content = {\n score_window: Curses::Window.new(4, 14, 4, 3),\n lvl_window: Curses::Window.new(3, 5, 11, 3),\n lines_window: Curses::Window.new(3, 7, 11, 10),\n highscores_window: Curses::Window.new(24, 14, 17, 3),\n tetris_window: Curses::Window.new(40, 20, 4, 20),\n next_window: Curses::Window.new(10, 14, 4, 43)\n }\n\n content.each do |_name, window|\n window.noutrefresh\n end\n content\nend", "def create_help_window\n @help_window = Window_ItemHelp.new(HELP_WINDOW_X, HELP_WINDOW_Y)\n end", "def create_help_window\n @help_window = Window_ItemHelp.new(HELP_WINDOW_X, HELP_WINDOW_Y)\n end", "def create_bestiary_window\n y = @enemy_list_window.height\n w = @enemy_list_window.width\n @bestiary_window = Window_BestiaryInfo.new(0, y, w)\n @bestiary_window.viewport = @viewport\n end", "def pbListWindow(cmds,width=256)\n list = Window_CommandPokemon.newWithSize(cmds,0,0,width,Graphics.height)\n list.index = 0\n list.rowHeight = 24\n pbSetSmallFont(list.contents)\n list.refresh\n return list\nend", "def create_command_window\n @command_window = Window_RegistrationCommand.new(0, @help_window.bottom_corner)\n @command_window.help_window = @help_window\n @command_window.set_handler(:name, method(:set_name))\n @command_window.set_handler(:avatar, method(:set_avatar))\n @command_window.set_handler(:title, method(:select_title))\n @command_window.set_handler(:register, method(:register))\n @command_window.set_handler(:cancel, method(:back))\n @command_window.openness = 0\n @command_window.deactivate\n if $game_temp.registration_step == 1\n @command_window.open\n @command_window.activate\n end\n end", "def create_quest_list_window\n if @category_dummy_window\n y = @category_dummy_window.height\n else\n y = @quest_category_window ? @quest_category_window.height : 0\n y += @quest_category_label_window ? @quest_category_label_window.height : 0\n y = @quest_label_window.height if y == 0\n end\n @quest_list_window = Window_QuestList.new(0, y, QuestData::LIST_WINDOW_WIDTH, \n Graphics.height - y)\n @quest_list_window.set_handler(:ok, method(:on_list_ok))\n @quest_list_window.deactivate if !QuestData::CONCURRENT_ACTIVITY\n if !QuestData::CONCURRENT_ACTIVITY || !@quest_category_window\n @quest_list_window.set_handler(:cancel, method(:on_list_cancel))\n end\n if @quest_category_window\n @quest_category_window.add_observing_proc(:list) { |category| \n @quest_list_window.category = category }\n else\n @quest_list_window.category = $game_system.quest_categories[0]\n end\n @quest_list_window.index = @init_quest_index if @init_quest_index\n end", "def createWidgets\n @topTab = KDE::TabWidget.new\n\n @mainTabPageHSplitter = Qt::Splitter.new\n @topTab.addTab(@mainTabPageHSplitter, 'Channels')\n\n @mainTabPageHSplitter.addWidget(createChannelAreaWidget)\n\n # Main Tab page. programme table area\n @progTableFrame = Qt::Splitter.new(Qt::Vertical)\n @progTableFrame.addWidget(createProgrammeAreaWidget)\n @progTableFrame.addWidget(createProgrammeSummaryWidget)\n @mainTabPageHSplitter.addWidget(@progTableFrame)\n\n # parameter : Qt::Splitter.setStretchFactor( int index, int stretch )\n @mainTabPageHSplitter.setStretchFactor( 0, 0 )\n @mainTabPageHSplitter.setStretchFactor( 1, 1 )\n\n # dock\n createPlayerDock\n\n\n # Top Tab - Task Page\n @taskWin = TaskWindow.new\n @topTab.addTab(@taskWin, 'Task')\n\n # Top Tab - Schedule Page\n @scheduleWin = ScheduleWindow.new\n @topTab.addTab(@scheduleWin, 'Schedule')\n\n # Top Tab - Log Page\n @logWin = LogWindow.new\n @topTab.addTab(@logWin, 'Log')\n\n\n # set Top Widget & Layout\n setCentralWidget(@topTab)\n end", "def show_window\n end", "def create_totals_window\r\r\n @totals_window = CSCA_Window_AchievementTotals.new(0,@head_window.height+\r\r\n @achievement_window.height,Graphics.width,Graphics.height-@head_window.height-\r\r\n @achievement_window.height)\r\r\n @totals_window.viewport = @viewport\r\r\n end", "def new_window(name)\n execute_script(%(\n var w = Math.max(\n document.documentElement.clientWidth, window.innerWidth || 0\n );\n var h = Math.max(\n document.documentElement.clientHeight, window.innerHeight || 0\n );\n window.open(\"about:blank\", arguments[0], `width=${w},height=${h}`);\n ), name)\n end", "def main_window\r\n super\r\n # Make message window\r\n @message_window = Window_Message.new\r\n end", "def window name, cwd, cmd\n raise NotImplementedError.new(\n \"window should be implemented to open new window\")\n end", "def create_selection_window\r\r\n @command_window = CSCA_Window_AchievementSelect.new(0,@head_window.height,\r\r\n Graphics.width/2,Graphics.height-@head_window.height-48)\r\r\n @command_window.viewport = @viewport\r\r\n @command_window.help_window = @achievement_window\r\r\n @command_window.set_handler(:cancel, method(:return_scene))\r\r\n @command_window.activate\r\r\n end", "def create_skill_preview_wtb\n w,h,g = 155, 55, Graphics\n @skill_prev_win = Window_BasicTextTB.new(g.width-w, g.height-h, w,h)\n @skill_prev_win.viewport = @viewport\n @skill_prev_win.font_size = 20\n @skill_prev_win.hide\n end", "def create_all_windows\n create_quest_label_window unless $game_system.quest_scene_label.empty?\n create_quest_category_window if $game_system.quest_categories.size > 1\n create_quest_category_label_window if QuestData::SHOW_CATEGORY_LABEL\n create_dummy_category_window if QuestData::CATEGORY_LABEL_IN_SAME_WINDOW &&\n @quest_category_window && @quest_category_label_window\n create_quest_list_window\n create_quest_data_window\n end", "def createContent\n\t\tcontent = Gtk::Grid.new\n\n\t\tcontent.row_spacing = 5\n\t\tcontent.halign = Gtk::Align::CENTER\n\t\tcontent.valign = Gtk::Align::CENTER\n\t\n\t\tcontents = self.createContents\n\t\tcontents.each_index do |index|\n\t\t\tcontent.attach(contents[index], 0, index, 1, 1)\n\t\tend\n\t\t\n\t\treturn content # 42\n\tend", "def create_equip_list_window\n x = @enchant_list.width; y = @enchant_list.y\n w = Graphics.width - @enchant_list.width; h = @enchant_list.height\n @equip_window = Window_EquipEnchantList.new(x, y, w, h)\n @equip_window.help_window = @help_window\n @equip_window.active = true\n @enchant_list.equip_window = @equip_window\n @equip_window.set_item(@enchant_list.item)\n @equip_window.index = 0\n @equip_window.set_handler(:ok, method(:equip_selected))\n @equip_window.set_handler(:cancel, method(:equip_unselected))\n @equip_window.viewport = @viewport1\n end", "def create_text_input_window\n @text_input_window = Window_CommonTextInput.new(0, 0, 100, 100)\n @text_input_window.openness = 0\n end", "def make_dialog_and_display\n dialog = JDialog.new(nil, @title)\n dialog.setLayout(BorderLayout.new)\n\n @center_panel = Box.create_vertical_box\n dialog.add(@center_panel, BorderLayout::CENTER)\n\n add_ok_cancel(dialog)\n \n GadgetFactory.add_gadget_list(@center_panel, '', @gadgets, @data_get_hash, @data_put_hash)\n\n @mgr = DialogDefaultsManager.new(dialog, @name, @defaults, @data_get_hash, @data_put_hash)\n dialog.add(@mgr, BorderLayout::NORTH) if @name\n\n @mgr.initialize_dialog\n \n dialog.set_modality_type(Java::java.awt.Dialog::ModalityType::APPLICATION_MODAL)\n dialog.pack\n dialog.set_location_relative_to(@parent_win)\n dialog.visible = true\n end", "def start!\n @window = Window.new width, height, fullscreen?\n window.caption = name\n window.scene = Scenes.generate(first_scene)\n window.show\n end", "def create_window(w, h)\n GLFW.window_hint GLFW::RESIZABLE, GL2::GL_FALSE\n GLFW.window_hint GLFW::CONTEXT_VERSION_MAJOR, 3\n GLFW.window_hint GLFW::CONTEXT_VERSION_MINOR, 3\n GLFW.window_hint GLFW::OPENGL_FORWARD_COMPAT, GL2::GL_TRUE # for 3.0\n GLFW.window_hint GLFW::OPENGL_PROFILE, GLFW::OPENGL_CORE_PROFILE # for 3.0 and on\n Moon::Shader.is_legacy = false\n\n title = 'Moon Player'\n begin\n @window = GLFW::Window.new w, h, title\n rescue GLFWError\n GLFW.default_window_hints\n GLFW.window_hint GLFW::CONTEXT_VERSION_MAJOR, 2\n GLFW.window_hint GLFW::CONTEXT_VERSION_MINOR, 1\n Moon::Shader.is_legacy = true\n\n @window = GLFW::Window.new w, h, title\n end\n end", "def create(name, position=[0,0], active=true)\n return @windows[name.to_sym] if @windows[name.to_sym]\n window = GUI::Window.new(name)\n window.move(position[0],position[1])\n @windows[name.to_sym] = window\n end", "def create_playtime_window\n width = @command_window.width\n y = @location_window.y\n @playtime_window = Window_PlayTime.new(0, y, width)\n @gold_window.y = @playtime_window.y - @gold_window.height\n end", "def create_reserve_members_window\n x = Graphics.width/2\n y = @right_window.bottom_corner\n @reserve_members_window = Window_ReserveMembers.new(x, y)\n @reserve_members_window.set_handler(:left, method(:pass_on_left))\n @reserve_members_window.set_handler(:cancel, method(:on_cancel))\n @reserve_members_window.set_handler(:ok, method(:on_actor_selection))\n @reserve_members_window.y = Graphics.height - @reserve_members_window.height\n @reserve_members_window.deactivate\n end", "def create_item_window\n @index ||= 0\n wy = @help_window.y + @help_window.height\n wh = Graphics.height - wy\n @item_window = Window_BestiaryEnemyList.new(wy, wh)\n @item_window.viewport = @viewport\n @item_window.help_window = @help_window\n @item_window.set_handler(:ok, method(:on_item_ok))\n @item_window.set_handler(:cancel, method(:return_scene))\n @item_window.refresh\n @item_window.index = @index\n @item_window.activate\n end", "def create_command_window()\n s1 = Vocab::ShopBuy\n s2 = Vocab::ShopSell\n s3 = $data_system.terms.equip\n s4 = Vocab::ShopCancel\n @command_window = Window_Command.new(640, [s1, s2, s3, s4], 4)\n @command_window.index = @menu_index\n @command_window.y = 56\n if $game_temp.shop_purchase_only\n @command_window.draw_item(1, false)\n end\n end", "def create_number_window\n wy = @dummy_window.y\n wh = @dummy_window.height\n @number_window = Window_ShopNumber.new(0, wy, wh)\n @number_window.viewport = @viewport\n @number_window.hide\n @number_window.set_handler(:ok, method(:on_number_ok))\n @number_window.set_handler(:cancel, method(:on_number_cancel))\n end", "def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n @help_window = Window_Help.new\n @help_window.width = 640\n @saves_list = []\n (0..MAX_SAVE_SLOT-1).each do |i|\n @saves_list << SaveData.new(SLOT_NAME.clone.gsub!(/\\{ID\\}/i) { (i+1).to_s }, \n make_filename(i))\n end\n @window_slotdetail = Window_Slot_Details.new(160, 56, 480, 424, nil)\n @window_slotlist = Window_Slot_List.new(0, 56, 160, 424, @saves_list)\n if OPACITY_DEFAULT == false\n @help_window.opacity = NSS_WINDOW_OPACITY\n @window_slotlist.opacity = NSS_WINDOW_OPACITY\n @window_slotdetail.opacity = NSS_WINDOW_OPACITY\n end\n \n @confirm_window = Window_Confirmation.new(220, 212, SFC_Window_Width, \n Vocab::confirm_save_text,\n Vocab::confirm_yes_text,\n Vocab::confirm_no_text)\n @confirm_window.active = false\n @confirm_window.visible = false\n \n # Create Folder for Save file\n if SAVE_PATH != ''\n Dir.mkdir(SAVE_PATH) if !FileTest.directory?(SAVE_PATH)\n end\n if @saving\n @index = $game_temp.last_file_index\n @help_window.set_text(Vocab::SaveMessage)\n else\n @index = latest_file_index()\n @help_window.set_text(Vocab::LoadMessage)\n end\n @window_slotlist.index = @index\n # Draw Information\n @last_slot_index = @window_slotlist.index\n @window_slotdetail.window_update(@saves_list[@last_slot_index])\n end", "def create_status_window\n @status_window = Window_Status.new(STATUS_WINDOW_X, STATUS_WINDOW_Y, @actor)\n @status_window.set_handler(:name, method(:input_name))\n @status_window.set_handler(:title, method(:change_title))\n @status_window.set_handler(:cancel, method(:return_scene))\n @status_window.set_handler(:pagedown, method(:next_actor))\n @status_window.set_handler(:pageup, method(:prev_actor))\n end", "def test_detail_window\n detail_window = Window_ItemDetails.new(0,384,640,96,nil)\n detail_window.visible = false\n help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n w = Window_Selectable_Implemented.new(0,256,160,128,$data_items.compact)\n w.help_window = help_window\n w.detail_window = detail_window\n @windows.push(w)\n @windows.push(help_window)\n @windows.push(detail_window)\n end", "def create_playtime_window\r\n @playtime_window = Window_Playtime.new\r\n @playtime_window.x = 0\r\n @playtime_window.y = Graphics.height - @playtime_window.height - @gold_window.height\r\n end", "def pbListWindow(cmds, width = Graphics.width / 2)\r\n list = Window_CommandPokemon.newWithSize(cmds, 0, 0, width, Graphics.height)\r\n list.index = 0\r\n list.rowHeight = 24\r\n pbSetSmallFont(list.contents)\r\n list.refresh\r\n return list\r\nend", "def initialize\n super \"Simple calculator\"\n self.create_main_window\n end", "def create_active_members_window\n y = @left_window.bottom_corner\n @active_members_window = Window_ActiveMembers.new(0, y)\n @active_members_window.set_handler(:right, method(:pass_on_right))\n @active_members_window.set_handler(:cancel, method(:on_cancel))\n @active_members_window.set_handler(:ok, method(:on_actor_selection))\n @active_members_window.y = Graphics.height - @active_members_window.height\n @active_members_window.activate\n end", "def main_window\r\n super\r\n # Make status window\r\n @status_window = Window_Status.new(@actor)\r\n end", "def create_background\n @background = Window.new(@viewport, @x, @y, @width, @height, skin: @skin)\n end" ]
[ "0.8128017", "0.73508704", "0.7312985", "0.70642495", "0.70542985", "0.70298475", "0.698378", "0.69769484", "0.6923041", "0.6913859", "0.68736434", "0.6871386", "0.68163425", "0.6775724", "0.6772868", "0.67457336", "0.6744301", "0.6741835", "0.6728215", "0.67052084", "0.6684373", "0.6674015", "0.6635372", "0.6611855", "0.6560036", "0.65440416", "0.6523989", "0.6518383", "0.6512657", "0.65084946", "0.64895695", "0.6473465", "0.64670616", "0.6460108", "0.6454709", "0.644506", "0.64332646", "0.6424029", "0.6412156", "0.6395103", "0.6381619", "0.6378353", "0.6347476", "0.6347476", "0.63419634", "0.6329418", "0.631552", "0.630494", "0.6293471", "0.628861", "0.62721395", "0.62700945", "0.6259323", "0.6258009", "0.6257413", "0.6249866", "0.6238882", "0.6238109", "0.6233904", "0.6233063", "0.62243253", "0.6219539", "0.6203952", "0.61971974", "0.6190757", "0.6190757", "0.6188834", "0.61865634", "0.6184179", "0.61784226", "0.6174051", "0.61652285", "0.6159668", "0.6142549", "0.61349", "0.61206615", "0.61201227", "0.6116914", "0.60998124", "0.609312", "0.6091921", "0.6091148", "0.6086849", "0.60840267", "0.60825795", "0.6079523", "0.60698164", "0.60653377", "0.6060997", "0.6056651", "0.6052314", "0.60390294", "0.6037605", "0.60332364", "0.60318327", "0.6029213", "0.6028839", "0.6025685", "0.6023838", "0.60235786" ]
0.6732302
18
Return the current binding.
def get_binding binding end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_binding\n return binding()\n end", "def get_binding\n return binding()\n end", "def get_binding\n return binding\n end", "def get_binding\n return binding()\n end", "def get_binding\n binding()\n end", "def get_binding\n binding()\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n binding\n end", "def get_binding\n return binding()\n end", "def get_binding\n return binding()\n end", "def get_binding\n binding\n end", "def get_binding\r\n binding\r\n end", "def get_binding\n binding()\n end", "def get_binding\n binding()\n end", "def get_binding\n binding()\n end", "def current_binding\n binding_stack.last\n end", "def getbinding\n binding\n end", "def get_binding\r\n binding()\r\n end", "def get_binding\n @binding ||= binding\n end", "def binding\n Kernel.binding\n end", "def get_binding\n\t\t\tbinding\n\t\tend", "def get_binding\n @_bindings.last\n end", "def get_binding\n @_bindings.last\n end", "def get_binding # rubocop: disable AccessorMethodName\n binding\n end", "def binding\n @binding ||= {}\n end", "def get_bind\n @bind\n end", "def get_binding\n a = 123 # => 123\n binding # => #<Binding:0x007fd7c087add0>\nend", "def local_binding\n binding\n end", "def get_binding(param)\n binding\nend", "def binding\n @binding ||= env_brine_vars\n end", "def get_binding\n a = 123\n binding\nend", "def get_binding(str)\n binding\nend", "def binding\n return Binding.setup(\n Rubinius::VariableScope.of_sender,\n Rubinius::CompiledMethod.of_sender,\n Rubinius::StaticScope.of_sender)\n end", "def bind\n binding\n end", "def bind\n binding\n end", "def _binding() binding end", "def _binding() binding end", "def top_binding\n self.send(:binding)\nend", "def binding()\n return Binding.setup(\n VariableScope.of_sender,\n CompiledMethod.of_sender,\n StaticScope.of_sender)\n\n end", "def get_a_binding\n\tval = 123\n\tbinding\nend", "def command_binding\n if @command_binding != nil\n return @command_binding\n elsif block != nil\n return block.binding\n else\n return nil\n end\n end", "def public_binding\n binding\n end", "def get_a_binding\n val = 123\n binding\nend", "def __eval_binding\n RUBY_VERSION < \"1.9\" ? binding : ::Kernel.binding\n end", "def binding() end", "def binding() end", "def bindings\n @bindings\n end", "def binding\n Binding.new(_base, _target, _association)\n end", "def get_binding derby\n cabar = derby = derby\n binding\n end", "def bound_object\n return super if Rib::Anchor.disabled?\n return super if eval_binding.kind_of?(Binding)\n eval_binding\n end", "def bind; binding() end", "def project_context\n instance_eval('binding')\n end", "def binding!\n @binding = true\n end", "def get_binding(keyset)\n environment = $environment\n myPublicIp = $myPublicIp\n myRoot = $myRoot\n myAZ = $myAZ\n myRegion = $myRegion\n myAppName = $myAppName\n credentials = @default_credentials ? @default_credentials : \"default\"\n\n# return MU::Config.global_bindings[keyset] if MU::Config.global_bindings[keyset]\n MU::Config.global_bindings[keyset] = binding\n MU::Config.global_bindings[keyset]\n end", "def bindings\n @bindings ||= []\n end", "def frame_binding(frame_position=0)\n #This is a stub, used for indexing\n end", "def innermost_binding(name)\n name = to_name(name)\n @symbols.has_key?(name) ?\n self :\n Scope === @parent ?\n @parent.innermost_binding(name) :\n nil\n end", "def binding; super end", "def scope() binding end", "def current\n @env.first\n end", "def binding?\n !bind_stack.empty?\n end", "def bound_object\n @obj\n end", "def empty_binding # :nodoc:\n binding\n end", "def binding(*args, &block)\n method_missing(:binding, *args, &block)\n end", "def get_binding(variables)\n obj = Class.new {\n attr_accessor *variables.keys\n def get_binding(); binding end\n }.new\n variables.each { |name, value| obj.public_send(:\"#{name}=\", value) }\n obj.get_binding\n end", "def binding_n(n = 0)\n Debugger.current_context.frame_binding[n+1]\n end", "def binding?\n Thread.current[:\"[mongoid]:binding-mode\"] ||= false\n end", "def binding(new_target = nil)\n Bindings::Referenced::One.new(base, new_target || target, metadata)\n end", "def binding_n(n = 0)\n Debugger.current_context.frame_binding[n+1]\n end", "def f\n x = 3\n b = binding()\n b\nend", "def current_scope\n if ss = method.staticscope\n return ss.module\n else\n home.current_scope\n end\n end", "def current\n @db[:current]\n end", "def get_current_scope\n get_current_hub&.current_scope\n end", "def bind\n conf['api']['bind']\n end", "def cur_values\r\n @bindings[-1].values\r\n end", "def st_bind\n Bind.new(header.st_info >> 4)\n end", "def bind(&block)\n self\n end", "def eval_binding(args, current_cont)\n\t\t\tname, env = args[:name], args[:env]\n\t\t\tif env.include? name.val.to_sym\n\t\t\t\treturn current_cont.next_with(ast: env[name.val.to_sym])\n\t\t\telse\n\t\t\t\tif env.parent\n\t\t\t\t\t# TODO: check if copy_with is necessary\n\t\t\t\t\treturn current_cont.with name: name, env: env.parent\n\t\t\t\telse\n\t\t\t\t\treturn current_cont.heap[:error_handler].with message: \n\t\t\t\t\t\t\"Could not resolve symbol #{name.val.inspect}\",\n\t\t\t\t\t\tast: name, backtrace: caller(0)\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def empty_binding\n Object.new.instance_exec { binding }\n end", "def as_binding\n result = binding\n as_hash.merge(ENV).each_pair do |key, value|\n result.local_variable_set(key.downcase.to_sym, value)\n end\n result\n end", "def doSomething\r\n puts \"inside the method\"\r\n return binding\r\nend", "def generate_binding(a_binding=binding)\n a_binding.local_variables do |local_var|\n a_binding.local_variable_set local_var, nil\n end\n @bound_procs.each_with_index do |bound_proc, index|\n a_binding.local_variable_set \"proc_#{index}\", bound_proc\n end\n @bound_constants.each_with_index do |bound_const, index|\n a_binding.local_variable_set \"const_#{index}\", bound_const\n end\n a_binding\n end" ]
[ "0.88186055", "0.88186055", "0.8805381", "0.87528974", "0.86933494", "0.86933494", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.8626539", "0.8626539", "0.8626539", "0.8626539", "0.8601867", "0.8601867", "0.85767776", "0.8569945", "0.85596573", "0.85596573", "0.85596573", "0.85568976", "0.8509767", "0.8496074", "0.8248093", "0.8170826", "0.8104474", "0.80194044", "0.80194044", "0.78225434", "0.779526", "0.76961094", "0.7581492", "0.7571779", "0.7523184", "0.740464", "0.7336681", "0.7324377", "0.7315753", "0.7273484", "0.7216272", "0.7178772", "0.7178772", "0.7131751", "0.7113466", "0.7066016", "0.7063337", "0.70601135", "0.7052546", "0.68367815", "0.680894", "0.680894", "0.66331017", "0.6495341", "0.6468081", "0.64196473", "0.6380467", "0.6338158", "0.63247675", "0.6288638", "0.6278683", "0.6236988", "0.6191841", "0.6138719", "0.6137811", "0.612494", "0.6059325", "0.6051973", "0.6041868", "0.5998272", "0.5978039", "0.59349406", "0.5911782", "0.5881391", "0.5868302", "0.5851556", "0.58442485", "0.58426183", "0.58336556", "0.5825539", "0.58206505", "0.5805619", "0.57504237", "0.57268953", "0.5721622", "0.5678519", "0.5658158", "0.56425625" ]
0.8375841
36
GET /forum_cat_l1s/1 GET /forum_cat_l1s/1.xml
def show @forum_cat_l1 = ForumCatL1.find(params[:id]) @forum_cat_l2s = ForumCatL2.find(:all, :conditions => ["forum_cat_l1_id = ?", params[:id]]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @forum_cat_l1 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @forum_cat_l1 = ForumCatL1.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l1 }\n end\n end", "def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end", "def index\n respond_to do |format|\n format.html { redirect_to forum_path(params[:forum_id]) }\n format.xml do\n @topics = Topic.find_all_by_forum_id(params[:forum_id], :order => 'sticky desc, replied_at desc', :limit => 25)\n render :xml => @topics.to_xml\n end\n end\n end", "def index\n @forums = Forum.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @forums }\n end\n end", "def index\n @forums = Forum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @forums }\n end\n end", "def index\n @page = params[:page] || '1'\n @forums = TogForum::Forum.find(:all, :order => 'id ASC').paginate({:page => @page})\n respond_to do |format|\n format.html\n format.rss { render :rss => @forums } \n end\n end", "def create\n @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])\n\n respond_to do |format|\n if @forum_cat_l1.save\n flash[:notice] = t(:category1_created)\n format.html { redirect_to(@forum_cat_l1) }\n format.xml { render :xml => @forum_cat_l1, :status => :created, :location => @forum_cat_l1 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @forum_categories = ForumCategory.all\n end", "def show\n @forum = Forum.find(params[:id])\n\t\t@topics = Topic.find_all_by_forum_id(@forum.id)\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum }\n end\n end", "def show\n @forum_category = ForumCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forum_category }\n end\n end", "def index\n @topics = @category.topics.preload(:category)\n render 'api/v1/topics/index'\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum_topic }\n end\n end", "def index\n @forum_categories = ForumCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @forum_categories }\n end\n end", "def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end", "def destroy\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n @forum_cat_l1.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_cat_l1s_url) }\n format.xml { head :ok }\n end\n end", "def index\n @category = Category.find(params[:id])\n @topic = @category.topics.all\n end", "def list\n\t\t@ssccategories = Ssccategory.paginate :page => params[:page], :per_page => 10\t#Pagination for 10 Records\n \trespond_to do |format|\t\t\n \t\t format.html # list.html.erb\n \t\t\tformat.xml { render :xml => @ssccategories }\t#Render to XML File\n \tend\n\tend", "def fetchCats(dataDir, minConfidence)\n return NellELoad.allCategories(dataDir, minConfidence, NellE::STRICT_TRAINING_CAT_FILENAMES)\nend", "def list_customer_categories\n doc = Hpricot::XML(request.raw_post) \n doc = doc.to_s.gsub(\"&amp;\",\"&\") \n doc = Hpricot::XML(doc)\n @customer_categories = Customer::CustomerCrud.list_customer_categories(doc)\n render_view( @customer_categories,'customer_categories','L')\n end", "def index\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @categories }\n end\n end", "def index\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @categories }\n end\n end", "def show\n @title = t(\"h2.categories\")\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end", "def show\n @otml_category = OtrunkExample::OtmlCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @otml_category }\n end\n end", "def new\n @forum = TogForum::Forum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.rss { render :rss => @forum }\n end\n end", "def update\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n\n respond_to do |format|\n if @forum_cat_l1.update_attributes(params[:forum_cat_l1])\n flash[:notice] = t(:category_updated)\n format.html { redirect_to(@forum_cat_l1) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @list_cats = ListCat.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_cats }\n end\n end", "def show\n @list_cat = ListCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_cat }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @categories }\n end\n end", "def index\n @forums = AnAxe::Forum.an_axe_forums\n # @forums = Forum.find_ordered\n # reset the page of each forum we have visited when we go back to index\n session[:forum_page] = nil\n respond_to do |format|\n format.html\n format.xml { render :xml => @forums }\n end\n end", "def show\n\t\t@ssccategory = Ssccategory.find(params[:id])\n \trespond_to do |format|\n \t\t format.html # show.html.erb\n \t\t\tformat.xml { render :xml => @ssccategories }\n \tend\n\t\t\n\tend", "def category(id)\n response = establish_connection(\"categories/#{id}.xml\")\n parse_single_category_xml(response.at(:category))\n end", "def new\n @forum = Forum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum }\n end\n end", "def new\n @forum = Forum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum }\n end\n end", "def index\n @training_categories = @ministry.training_categories\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @training_categories }\n end\n end", "def new\n @forum_cat_l2 = ForumCatL2.find(params[:forum_cat_l2_id])\n @forum_post = @forum_cat_l2.forum_posts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_post }\n end\n end", "def index\n @roots = Category.roots\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @categories }\n end\n end", "def getCat \n\t\tputs ''\n\t\tputs 'Fetching categories . . '\n\t\t@page.css('ul.dropdown li a').each do |cat|\n\t\t\tarr=[]\n\t\t\tarr.push cat.text\n\t\t\tarr.push cat['href']\n\t\t\t@arr_cat.push arr\n\t\t\tprint '. '\n\t\tend\n\t\ti=0\n\t\t@arr_cat.each do |pair|\n\t\t\t@db.execute 'insert into category values (?, ? ,?)', i, pair[0], pair[1]\n \t\t\ti +=1\n \t\tend\n\tend", "def catses\n REXML::XPath.match(@xml, './app:categories', Names::XmlNamespaces)\n end", "def show\n\t\t@forum = Forum.find(params[:id])\n\t\t@topics = @forum.topics.order(\"created_at DESC\")\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @forum }\n\t\tend\n\tend", "def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @category }\n end\n end", "def index\n @forum_groups = ForumGroup.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @forum_groups.to_xml }\n end\n end", "def categories(options = {})\n fetch_categories.at('categories').children_of_type('category').inject([]){ |r, i| r << parse_single_category_xml(i) }\n\tend", "def show\n @news_category = NewsCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @news_category }\n end\n end", "def index\n@topic = Topic.find(params[:topic_id], :include => :forum)\n@posts = Post.find(:all, :conditions => ['topic_id = ?', @topic.id])\n@posts_pages = Post.find(:all, :conditions => ['topic_id = ?', @topic.id])\nrespond_to do |format|\nformat.html # index.rhtml\nformat.xml { render :xml => @posts.to_xml }\nend\nend", "def index\n @department_forums = current_user.department.forums.find(:all, :order => 'position desc')\n\t\t@forums = Forum.noninternal current_user.department.id\n\t\t@css_class = current_user.department.short.downcase\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @forums }\n end\n end", "def new\n @topic = Topic.new\n @super_categories = Topic.ordered_roots\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def fetch_all_categories\n everything = @@news_api.get_everything(\n language: 'en',\n sources:'techcrunch,talksport,the-next-web,\n national-geographic, al-jazeera-english,\n crypto-coins-news',\n page: 1\n )\n end", "def show\n @topiccluster = Topiccluster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @topiccluster }\n end\n end", "def GetForum id\n\n APICall(path: \"forums/#{id}.json\")\n\n end", "def show\n @menu =\"Blog\"\n @page_name =\"Blog categories\"\n @blog_category = BlogCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @blog_category }\n end\n end", "def show\n @forum = @group.forum\n if @forum\n @topics = @forum.topics.paginate :order => \"created_at DESC\", :page => params[:page]\n else\n @topics = [].paginate\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end", "def fetch_categories\r\n page = File.open(\"#{Rails.root}/public/Categories.html\") { |f| Nokogiri::HTML(f) }\r\n Category.save_fetched_categories_and_subcategories(page)\r\n end", "def fetch_more\n more_url = $yaml_obj[:next_url]\n #perror \"more url is #{more_url} \"\n fetch_data_from_net $subforum, more_url\nend", "def index\n @forum_forums = Forum::Forum.main_forums\n end", "def index\n @post_categories = PostCategory.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @post_categories }\n end\n end", "def index\r\n @categories = Category.find(:all)\r\n respond_to do |format|\r\n format.html\r\n format.atom\r\n end\r\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @menus }\n end\n end", "def show\n @categorymaster = Categorymaster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @categorymaster }\n end\n end", "def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end", "def visit_the_forum\n @forum = Forum.find_by_permalink 'a-forum-with-two-topics'\n \n get '/a-forum-with-two-topics'\n renders_template \"forum/show\"\n end", "def index\n @forum_threads = Forum::Thread.all\n end", "def discover_url\n \"http://discover.amee.com/categories#{path}\"\n end", "def index\n @forum_topics = Forum::Topic.all\n end", "def show\n @thread = ForumThread.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @thread }\n end\n end", "def create_avail_category\n file = ::File.new(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"r\")\n doc = REXML::Document.new file\n file.close\n cg_el = doc.elements[\"/catinfo/categorygroup[name[text()[contains(.,'#{new_resource.category_group}')]]]/categories\"]\n cat_el = cg_el.add_element 'category'\n label_el = cat_el.add_element 'label'\n label_el.add_text(REXML::CData.new(new_resource.label))\n comment_el = cat_el.add_element 'comment'\n comment_el.add_text new_resource.comment\n normal_el = cat_el.add_element 'normal'\n normal_el.add_text \"#{new_resource.normal}\" # really ruby? really?\n warning_el = cat_el.add_element 'warning'\n warning_el.add_text \"#{new_resource.warning}\"\n new_resource.services.each do |s|\n s_el = cat_el.add_element 'service'\n s_el.add_text s\n end\n rule_el = cat_el.add_element 'rule'\n rule_el.add_text(REXML::CData.new(new_resource.rule))\n out = \"\"\n formatter = REXML::Formatters::Pretty.new(2)\n formatter.compact = true\n formatter.write(doc, out)\n ::File.open(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"w\"){ |file| file.puts(out) }\nend", "def index \t\n @categories = Category.pages(params[:page], params[:q]) \t\r\n \r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @categories }\r\n end\r\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def index\n @topics = Topic.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def index\n @blog_categories = BlogCategory.all\n @blog_category = BlogCategory.new\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @blog_categories }\n end\n end", "def categories()\n @web.get('http://www.waymarking.com/cat/categorydirectory.aspx') do |page|\n ile = 0\n #puts page.parser.to_html.to_s\n cache = {}\n\n page.parser.css('div#content div.gutter a').each do |cat|\n href = cat.attr('href')\n m = Category::GUID_REGEXP.match href\n key = Waymarking::Utils.parameterize(cat.text)\n unless m.nil? then\n ile +=1\n raise DuplicatedCategory if cache.has_key? key\n\n cache[key] = m[1]\n #puts \"#{ile} #{key} #{cat.text} #{m[1]}\"\n else\n puts href\n end\n\n end\n\n cache2 = {}\n cache.keys.each do |key|\n @web.get(\"http://www.waymarking.com/cat/details.aspx?f=1&guid=#{cache[key]}&exp=True\") do |page2|\n begin\n cat = Waymarking::Category.from_html(page2)\n cache2[key] = cat\n rescue\n puts key\n end\n end\n end\n\n File.open('categories.yml', 'w') do |f|\n f.write YAML::dump(cache2)\n end\n end\n end", "def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end", "def show\n @category = Category.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @category }\n end\n end", "def latest_topics_rss\r\n @title = \"The Latest Discussions\"\r\n @topics = Topic.paginate_all(20, @cobrand)\r\n render :template => \"common/topics_rss\", :layout => false\r\n end", "def show\n @forum_subjects = @forum_category.forum_subjects.paginate(page: params[:page], per_page: PAGINATE_PAGES)\n end", "def show\n @article_category = ArticleCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @article_category }\n end\n end", "def index\n @forums = Forum.all\n end", "def index\n @forums = Forum.all\n end", "def index\n @forums = Forum.all\n end", "def index\n @forums = Forum.all\n end", "def show\n\n #fetch the forum thread based on the url\n @forum_thread = ForumThread.find(params[:id])\n\n #fetch an array of all the forum posts using the pagination plugin\n @forum_posts = @forum_thread.forum_posts.paginate :per_page => 10, :page => params[:page], :order => 'id'\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum_thread }\n end\n end", "def get_channnel_xml( url )\n path = url.sub(/http:\\/\\/gdata\\.youtube\\.com/,'')\n xml = \"\"\n\n Net::HTTP.version_1_2\n Net::HTTP.start(\"#{@url}\", \"#{@port}\") do |http|\n response = http.get(\"/#{path}\")\n xml = response.body\n end\n\n return xml\n end", "def new\n @topiccluster = Topiccluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topiccluster }\n end\n end", "def index\r\n @forums = Forum.all\r\n end", "def forum_get(args)\n JSON.parse(HelpSpot.api_request('forums.get', 'GET', :xForumId => args[:forum_id])) rescue []\n end", "def catalog_dcat()\n return uri(\"api/dcat.json\")\n end", "def index\n @clusters = Cluster.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clusters }\n end\n end", "def show\n @recipe_category = RecipeCategory.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @recipe_category }\n end\n end", "def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def index\n redirect_to category_child_url(@main_category,@category)\n #@descriptions = @category.descriptions\n #respond_to do |format|\n # format.xml\n #end\n end", "def index\n respond_to do |format|\n format.html do\n @recipe_categories = RecipeCategory.paginate(:page => params[:page], :order => 'name', :per_page => 5)\n end # index.html.haml\n format.xml do\n @recipe_categories = RecipeCategory.find(:all, :order => 'name')\n render :xml => @recipe_categories\n end\n end\n end", "def show\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cat }\n end\n end", "def index\n @categories = @categories.includes(:forums).ordered\n end", "def categories(sport_id)\n get(\"sports/en/sports/sr:sport:#{sport_id}/categories.xml\")\n end", "def index\n @forum_categories = @forum_categories.order('position ASC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @forum_categories }\n end\n end", "def index\n @categories = Categorie.find(:all, :conditions => {:parametres_cabinet_id => current_user.parametres_cabinet_id})\n\n respond_to do |format|\n format.html {render :layout => \"light\"} # index.html.erb\n format.xml { render :xml => @categories }\n format.json {render :json => {\"success\"=>true,\"data\"=>@categories}}\n \n end\n end", "def index\n @featured_categories = Category.find( :all, :conditions => { :is_featured => true } )\n @featured_categories.delete_if {|x| !x.allowed_to_read} #Hide Private Featured Categories\n\n @categories = Category.roots\n @categories.delete_if {|x| !x.allowed_to_read} #Hide Private Root Categories\n\n respond_to do |format|\n format.html # index.html.erb\n format.rss\n format.xml { render :xml => @categories }\n end\n end", "def index\n @tags = @category.tags.all\n\n respond_to do |format|\n format.html { redirect_to @category }\n format.xml { render :xml => @tags }\n end\n end", "def index\n @rcadmin_faq_categories = Rcadmin::FaqCategory.all\n end", "def show\r\n @category = Category.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @category }\r\n end\r\n end", "def show\n @page = params[:page] || '1'\n @asc = (params[:asc] and params[:asc] == \"desc\") ? \"asc\" : 'desc'\n\n @forum = TogForum::Forum.find(params[:id])\n @topics = TogForum::Topic.paginate :per_page => Tog::Config[\"plugins.tog_social.profile.list.page.size\"],\n :page => @page,\n :conditions => ['tog_forum_topics.forum_id = ?', @forum.id]\n \n respond_to do |format|\n format.js { render :partial => \"/forums/partials/topics_paginated\" }\n format.html\n format.rss { render :rss => @forum }\n end\n end" ]
[ "0.6666921", "0.657437", "0.6237197", "0.6066407", "0.6056434", "0.60168463", "0.5993059", "0.59686416", "0.5965243", "0.58546954", "0.5843813", "0.5819074", "0.58076763", "0.5786881", "0.57772726", "0.5771613", "0.57529575", "0.5740423", "0.57294387", "0.57013685", "0.57013685", "0.5693715", "0.5692518", "0.5689713", "0.56822485", "0.56745493", "0.56616086", "0.5650119", "0.5632092", "0.5621767", "0.5619498", "0.5612596", "0.5612596", "0.56125283", "0.56024945", "0.5575121", "0.5557224", "0.55568045", "0.55563384", "0.5554084", "0.5548757", "0.5540086", "0.5535022", "0.5533067", "0.55264235", "0.5520129", "0.5517246", "0.5502585", "0.548755", "0.5478735", "0.54759806", "0.54718906", "0.54601634", "0.5435917", "0.5434659", "0.5429172", "0.54242843", "0.54212195", "0.5411728", "0.5411723", "0.5409039", "0.5403739", "0.53970104", "0.5387131", "0.5385015", "0.53844154", "0.5380044", "0.53796667", "0.53794605", "0.5373888", "0.5370533", "0.5370533", "0.5368361", "0.53642076", "0.5361381", "0.5356367", "0.5356367", "0.5356367", "0.5356367", "0.53559923", "0.53518486", "0.5348798", "0.53423405", "0.53421503", "0.53391117", "0.5338103", "0.53378063", "0.53292185", "0.53272825", "0.53258526", "0.53203297", "0.53195393", "0.530832", "0.53052205", "0.53024614", "0.5300377", "0.52999425", "0.52973384", "0.5289266", "0.5287496" ]
0.67749006
0
GET /forum_cat_l1s/new GET /forum_cat_l1s/new.xml
def new @forum_cat_l1 = ForumCatL1.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @forum_cat_l1 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])\n\n respond_to do |format|\n if @forum_cat_l1.save\n flash[:notice] = t(:category1_created)\n format.html { redirect_to(@forum_cat_l1) }\n format.xml { render :xml => @forum_cat_l1, :status => :created, :location => @forum_cat_l1 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @title = t(\"h2.categories\")\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @forum = Forum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum }\n end\n end", "def new\n @forum = Forum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum }\n end\n end", "def new\n @forum_cat_l2 = ForumCatL2.find(params[:forum_cat_l2_id])\n @forum_post = @forum_cat_l2.forum_posts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_post }\n end\n end", "def new\n @news_category = NewsCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_category }\n end\n end", "def new\n @topic = Topic.new\n @super_categories = Topic.ordered_roots\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @activity = Activity.new\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activity }\n end\n end", "def new\n @forum_category = ForumCategory.new\n @position = next_position\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @forum_category }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cat }\n end\n end", "def new\n @collection = Collection.find(params[:collection_id])\n @category_collection = CategoryCollection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category_collection }\n end\n end", "def new\n @list_cat = ListCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_cat }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @faq_category }\n end\n end", "def new\n @tag = @category.tags.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tag }\n end\n end", "def new\n @topiccluster = Topiccluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topiccluster }\n end\n end", "def new\n @blog_category = BlogCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @blog_category }\n end\n end", "def new\n @otml_category = OtrunkExample::OtmlCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @otml_category }\n end\n end", "def new\n @article_category = ArticleCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @article_category }\n end\n end", "def new\n @pcategory = Pcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pcategory }\n end\n end", "def new\n @story = Story.new\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end", "def new\n @feature_category = FeatureCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feature_category }\n end\n end", "def new\n @admin_section = true\n @course_category = CourseCategory.new\n @page_title = \"New Course Category\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course_category }\n end\n end", "def new\n @forum = TogForum::Forum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.rss { render :rss => @forum }\n end\n end", "def new\n @categorymaster = Categorymaster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @categorymaster }\n end\n end", "def new\n# @category = Category.by_company(current_company.id).new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @activity = Activity.new\n @attcategories = Attcategory.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activity }\n end\n end", "def new\n puts @category.inspect\n @internal = @category.internals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internal }\n end\n end", "def new\n @post_category = PostCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post_category }\n end\n end", "def new\n @menu = Menu.new\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end", "def new\n @project_category = ProjectCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project_category }\n end\n end", "def new\n @category_page = CategoryPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category_page }\n end\n end", "def new\n @categorie = Categorie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @categorie }\n end\n end", "def new\n @categorization = Categorization.new\n @categories = category_list\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @categorization }\n end\n end", "def new\n @forum = TogForum::Forum.new\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @category = current_mall.categories.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @article = Article.new\n @categories = Category.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @article }\n end\n end", "def new\n @article = Article.new\n @categories = Category.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @article }\n end\n end", "def new\n curs\n @forumtheme = Forumtheme.new\n @forumtheme.forumroot_id = params[:root]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forumtheme }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @forum }\n end\n end", "def create\n @category_form_url = forum_categories_path\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @topic = Topic.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n \n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @contact_category = ContactCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contact_category }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\r\n @ccategory = Ccategory.new\r\n @titles = ptitles\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @ccategory }\r\n end\r\n end", "def new\n @catena = Catena.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catena }\n end\n end", "def new\n @post_category = PostCategory.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post_category }\n end\n end", "def new\n @category = Category.new\n @rollover = Rollover.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n\t @category = Category.new\n\n\t respond_to do |format|\n\t\tformat.html # new.html.erb\n\t end\n\tend", "def new\n @categoria = Categoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @categoria }\n end\n end", "def new\n @forum = Forum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @forum }\n end\n end", "def new\n @category2 = Category2.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category2 }\n end\n end", "def new\n\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\r\n\t\tif params[:create]\r\n\t\t\t@root_category = Category.find(:first, :conditions => 'parent_id IS NULL') || Category.create\r\n\t\t\tparams[:category][:parent_id] = @root_category.id unless !params[:category][:parent_id].empty?\r\n\t\t\t@category = Category.new(params[:category])\r\n\t\t\tif @category.save\r\n\t\t\t\texpire_fragment(:controller => :products, :action => :home, :part => 'category_menu')\r\n\r\n\t\t\t\t# Requested after a usability review so people can add the description and SEO options\r\n\t\t\t\t# without having to click through. If you disagree with this then swap for the\r\n\t\t\t\t# commented-out code below.\r\n\t\t\t\tredirect_to(:action => :edit, :id => @category.id) and return true\r\n#\t\t\t\tflash.now[:notice] = 'Category successfully created'\r\n\t\t\telse\r\n\t\t\t\tflash.now[:notice] = 'Error creating category'\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\tredirect_to(:action => :list)\r\n\tend", "def new\n @parent_id = params[:parent_id]\n @category = Category.new(:parent_id => @parent_id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @cluster = Cluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cluster }\n end\n end", "def new\n @recipe_category = RecipeCategory.new\n\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @recipe_category }\n end\n end", "def new\n @component_category = ComponentCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @component_category }\n end\n end", "def new\n @retailer_category = RetailerCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retailer_category }\n end\n end", "def new\n #1st you retrieve the forum_thread thanks to params[:forum_thread_id]\n forum_thread = ForumThread.find (params[:forum_thread_id])\n #2nd you build a new one\n @forum_post = forum_thread.forum_posts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_post }\n end\n end", "def new\n @recipe_category = RecipeCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recipe_category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu }\n end\n end", "def new\n @headline = t(:new_thread)\n @fred = Fred.new\n @parent = Category.find(params[:id])\n @fred.category = @parent\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fred }\n end\n end", "def new\n @kind=params[:k] || 'news'\n @locale=params[:locale] || 'zh_CN'\n @default_status='live'\n @language=Language.find_by_code(@locale)\n @article = Article.new({:language_id=>@language.id,:kind=>@kind,:status=>@default_status})\n @categories=@language.categories\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_article }\n end\n end", "def new\n @topic_attribute = TopicAttribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic_attribute }\n end\n end", "def new\n @nspirefile = Nspirefile.new\n @categories = get_categories\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nspirefile }\n end\n end", "def new\n @feed_category = FeedCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @feed_category }\n end\n end", "def new\n @forum = Forum.find(params[:forum_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @element = Element.new\n @root_category = Category.find(272)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @element }\n end\n end", "def new\n @classified_person_category = ClassifiedPersonCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @classified_person_category }\n end\n end", "def new\n\t\t@forum = Forum.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @forum }\n\t\tend\n\tend", "def new\n @company_forum = CompanyForum.find(params[:company_forum_id])\n @company_forum_topic = CompanyForumTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company_forum_topic }\n end\n end", "def new\n @creation = Creation.new\n @topics = Topic.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @creation }\n end\n end", "def new\n @post = Post.new\n @categoria = Categorium.find(:all, :order => 'nombre ASC').collect {|m| [m.nombre, m.id]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => [@post, @categoria] }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @category = @current_user.categories.new\n add_breadcrumb I18n.t('layout.categories.title'), categories_path\n add_breadcrumb I18n.t('layout.categories.new'), new_category_path\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @staffclassification = Staffclassification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @staffclassification }\n end\n end", "def new\n @clasificacion = Clasificacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @clasificacion }\n end\n end", "def new\n @documentocategoria = Documentocategoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentocategoria }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @blog_post = BlogPost.new\n @categories = BlogCategory.all\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @blog_post }\n end\n end", "def new\n respond_to do |format|\n @categories = Category.all\n @article = Article.new\n format.html { render layout: 'minimal' }\n format.json { render json: @article }\n end\n end", "def new\n @information_category = InformationCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @information_category }\n end\n end", "def new\n @topic_comment = TopicComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic_comment }\n end\n end", "def new\n @ccl = Ccl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ccl }\n end\n end", "def new\n @category = Category.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @categoria_comida = CategoriaComida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @categoria_comida }\n end\n end", "def create\n respond_to do |format|\n if @forum_category.save\n format.html { redirect_to forum_categories_path, notice: 'Forum category was successfully created.' }\n format.json { render json: @forum_category, status: :created, location: @forum_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @forum_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @post306 = Post306.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post306 }\n end\n end", "def new\n @flag_category = FlagCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @flag_category }\n end\n end" ]
[ "0.7542703", "0.7050673", "0.7031274", "0.7031274", "0.68963134", "0.6877075", "0.68483984", "0.6834801", "0.68277633", "0.68277633", "0.68277633", "0.68277633", "0.680393", "0.6793724", "0.6777852", "0.67618775", "0.67491084", "0.67463917", "0.6737806", "0.6737038", "0.67322236", "0.6674215", "0.6651412", "0.66441137", "0.6642776", "0.66313535", "0.6627291", "0.6612465", "0.66036123", "0.65952253", "0.65916824", "0.6590862", "0.6586757", "0.6560391", "0.65504336", "0.65439296", "0.65416247", "0.6528814", "0.65214264", "0.65206957", "0.65168804", "0.65168804", "0.65067804", "0.65044343", "0.65027654", "0.64980423", "0.64967763", "0.6493657", "0.648843", "0.648843", "0.648843", "0.648843", "0.648843", "0.6482377", "0.6480114", "0.64709485", "0.6468419", "0.6464312", "0.645414", "0.6445625", "0.6445432", "0.64394075", "0.6433931", "0.64318633", "0.6430162", "0.64148086", "0.6413657", "0.6407993", "0.6398779", "0.6390885", "0.6389319", "0.6387329", "0.63871074", "0.63812846", "0.6372029", "0.63716394", "0.63610995", "0.63558406", "0.63402843", "0.633605", "0.6322675", "0.6314046", "0.6302968", "0.62909967", "0.6283231", "0.62813646", "0.6279761", "0.62790656", "0.6271606", "0.62690604", "0.62687343", "0.62420356", "0.6240207", "0.62400055", "0.62345976", "0.6233184", "0.6230885", "0.622729", "0.622479", "0.62232524" ]
0.7759111
0
POST /forum_cat_l1s POST /forum_cat_l1s.xml
def create @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1]) respond_to do |format| if @forum_cat_l1.save flash[:notice] = t(:category1_created) format.html { redirect_to(@forum_cat_l1) } format.xml { render :xml => @forum_cat_l1, :status => :created, :location => @forum_cat_l1 } else format.html { render :action => "new" } format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @forum_cat_l1 = ForumCatL1.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l1 }\n end\n end", "def update\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n\n respond_to do |format|\n if @forum_cat_l1.update_attributes(params[:forum_cat_l1])\n flash[:notice] = t(:category_updated)\n format.html { redirect_to(@forum_cat_l1) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @category_form_url = forum_categories_path\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def variables_for_new\r\n @path = administration.article_cluster_categories_path\r\n @method = :post\r\n end", "def uhook_create_category\n category = ::Category.new(params[:category])\n category.locale = current_locale\n category\n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def destroy\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n @forum_cat_l1.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_cat_l1s_url) }\n format.xml { head :ok }\n end\n end", "def new\n @forum_cat_l2 = ForumCatL2.find(params[:forum_cat_l2_id])\n @forum_post = @forum_cat_l2.forum_posts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_post }\n end\n end", "def create\n @cat = Cat.new(params[:cat])\n\n respond_to do |format|\n if @cat.save\n _update_topics \n format.html { redirect_to action: \"new\", notice: 'Cat was successfully created.' }\n format.json { render json: @cat, status: :created, location: @cat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = '分类创建成功.'\n format.html { redirect_to(cpanel_categories_url) }\n format.xml { render :xml => @menu, :status => :created, :location => @menu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_avail_category\n file = ::File.new(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"r\")\n doc = REXML::Document.new file\n file.close\n cg_el = doc.elements[\"/catinfo/categorygroup[name[text()[contains(.,'#{new_resource.category_group}')]]]/categories\"]\n cat_el = cg_el.add_element 'category'\n label_el = cat_el.add_element 'label'\n label_el.add_text(REXML::CData.new(new_resource.label))\n comment_el = cat_el.add_element 'comment'\n comment_el.add_text new_resource.comment\n normal_el = cat_el.add_element 'normal'\n normal_el.add_text \"#{new_resource.normal}\" # really ruby? really?\n warning_el = cat_el.add_element 'warning'\n warning_el.add_text \"#{new_resource.warning}\"\n new_resource.services.each do |s|\n s_el = cat_el.add_element 'service'\n s_el.add_text s\n end\n rule_el = cat_el.add_element 'rule'\n rule_el.add_text(REXML::CData.new(new_resource.rule))\n out = \"\"\n formatter = REXML::Formatters::Pretty.new(2)\n formatter.compact = true\n formatter.write(doc, out)\n ::File.open(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"w\"){ |file| file.puts(out) }\nend", "def create\n respond_to do |format|\n if @forum_category.save\n format.html { redirect_to forum_categories_path, notice: 'Forum category was successfully created.' }\n format.json { render json: @forum_category, status: :created, location: @forum_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @forum_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @otml_category = OtrunkExample::OtmlCategory.new(params[:otml_category])\n\n respond_to do |format|\n if @otml_category.save\n flash[:notice] = 'OtrunkExample::OtmlCategory was successfully created.'\n format.html { redirect_to(@otml_category) }\n format.xml { render :xml => @otml_category, :status => :created, :location => @otml_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @otml_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n \n @article = Article.new(article_params)\n\n #获取文章所属类别\n myParams = {}\n myParams[:label] = params[:article][:content]\n categoryURI = 'http://74.71.193.8:8080/robin8/label.jsp'\n uri = URI.parse(categoryURI)\n res = Net::HTTP.post_form(uri,myParams)\n params[:article][:category] = res.body #ActiveSupport::JSON.decode(res.body)\n \n\n respond_to do |format|\n if @article.save\n #format.html { redirect_to :action=>'list',:title=>params['article']['title'] }\n #format.html { render :for_redirect }\n format.html { render :check_category }\n format.json { render :show, status: :created, location: @user }\n\n else\n format.html { redirect_to :action =>'find' }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_category(category_node)\n url = category_node.xpath(\"./a[1]/@href\").text\n name = url.sub(URL,'').delete('/')\n name_ru = category_node.xpath(\"./a[last()]\").text\n is_new = category_node.xpath(\"./a[2]/img[@class='img_new']\").any?\n Category.create(name: name, name_ru: name_ru, url: url, is_new: is_new)\n end", "def uhook_new_category\n ::Category.translate(params[:from], current_locale, :copy_all => true)\n end", "def create\r\n @bcat1 = Bcat1.new(params[:bcat1])\r\n @cat=Cat1.find :first , :conditions=>['k1c=? and vis=?',@bcat1.s1, 1]\r\n if @cat\r\n @bcat1.cat1_id=@cat.id\r\n else\r\n @cat2=Cat1.find :first , :conditions=>['k1c=? and vis=?',@bcat1.s1, 0]\r\n if @cat2\r\n @bcat1.cat1_id=@cat2.id\r\n end\r\n end\r\n respond_to do |format|\r\n if @bcat1.save\r\n flash[:notice] = 'Номенклатура сохранена.'\r\n format.html { redirect_to(:action=>'edit' , :id=>@bcat1.id, :btg1=>@bcat1.btg1_id) }\r\n format.xml { render :xml => @bcat1, :status => :created, :location => @bcat1 }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @bcat1.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @forum_cat_l2 = ForumCatL2.find(params[:forum_cat_l2_id])\n @forum_post = @forum_cat_l2.forum_posts.new(params[:forum_post])\n @forum_post.user_id = current_user.id \n current_user.number_of_posts += 1 \n current_user.save!\n \n respond_to do |format|\n if @forum_post.save\n flash[:notice] = t(:Forum_post_created)\n format.html { redirect_to(@forum_post) }\n format.xml { render :xml => @forum_post, :status => :created, :location => @forum_post }\n else\n format.html {\n render :action => \"new\"\n }\n format.xml { render :xml => @forum_post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @category = @collection.categories.new(category_params)\n\n if @category.save\n ActionCable.server.broadcast 'categories',\n title: @category.title,\n collection_id: @category.collection_id\n head :ok\n else\n\n end\n end", "def create\n @blog_category = BlogCategory.new(params[:blog_category])\n\n respond_to do |format|\n if @blog_category.save\n format.html { redirect_to(admin_blog_categories_path, :notice => 'Blog category was successfully created.') }\n format.xml { render :xml => @blog_categories, :status => :created, :location => @blog_category }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @blog_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def category1=(value)\n @category1 = value\n end", "def create\n @categories = Category.all\n\n @category = Category.create(category_params)\n flash[:notice]=\"Catégorie créer avec succès!!!\"\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Kategoria została stworzona poprawnie.'\n format.html { redirect_to([:admin, @category]) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n @article = Article.new(params[:article])\n @kind=params[:k] || 'news'\n respond_to do |format|\n if @article.save\n flash[:notice] = 'Article was successfully created.'\n format.html { redirect_to(admin_articles_url) }\n format.xml { render :xml => @article, :status => :created, :location => @article }\n else\n @locale=params[:locale] || 'zh_CN'\n \n @language=Language.find_by_code(@locale)\n \n @categories=@language.categories\n @kind=params[:k] || 'news'\n @locale=params[:locale] || 'zh_CN'\n @language=Language.find_by_code(@locale)\n @categories=@language.categories\n format.html { render :action => \"new\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @categorization = Categorization.new(params[:categorization])\n @categories = category_list\n respond_to do |format|\n if @categorization.save\n format.html { redirect_to(admin_categorization_path(@categorization), :notice => 'Categorization was successfully created.') }\n format.xml { render :xml => @categorization, :status => :created, :location => @categorization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @categorization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n \n category = params[:category]\n category_name = category['name']\n \n write_log(\"category.to_s: #{category.to_s}\",\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n \n cats = []\n if category_name != nil\n cats = category_name.split(\" \")\n end\n \n write_log(\"cats.size: #{cats.size}\",\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n if cats.size > 1\n \n flag = true\n counter = 0\n \n cats.each do |cat|\n # @category = Category.new(params[:category])\n # @category = Category.new(name=cat)\n @category = Category.new({\"name\"=> cat, \"genre_id\"=> category['genre_id']})\n \n if @category.save\n else\n counter += 1\n end\n end#cats.each do |cat|\n \n respond_to do |format|\n format.html { redirect_to @category, \n notice: \"New categories: Created => #{cats.size - counter}, Failed => #{counter}\" }\n format.json { render json: @category, status: :created, location: @category }\n end\n \n else#if cats.size > 1\n @category = Category.new(params[:category])\n \n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end#if cats.size > 1\n \n \n # @category = Category.new(params[:category])\n# \n # respond_to do |format|\n # if @category.save\n # format.html { redirect_to @category, notice: 'Category was successfully created.' }\n # format.json { render json: @category, status: :created, location: @category }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @category.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Category was successfully created.'\n format.html { redirect_to(admin_categories_path) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @forum_category = ForumCategory.new(params[:forum_category])\n\n respond_to do |format|\n if @forum_category.save\n if @forum_category.position.blank?\n @forum_category.position = next_position\n @forum_category.save\n end\n format.html { redirect_to forums_path, notice: 'Forum category was successfully created.' }\n format.json { render json: @forum_category, status: :created, location: @forum_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @forum_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to adminpanel_categories_path, notice: \"Категория #{@category.name} успешно создана\" }\n format.json { render :show, status: :created, location: adminpanel_categories_path }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @ccategory = Ccategory.new(params[:ccategory])\r\n @titles = ptitles\r\n\r\n respond_to do |format|\r\n if @ccategory.save\r\n format.html { redirect_to(@ccategory, :notice => 'Ccategory was successfully created.') }\r\n format.xml { render :xml => @ccategory, :status => :created, :location => @ccategory }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @ccategory.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n respond_to do |format|\n @faq_category.brand_id = website.brand_id\n if @faq_category.save\n format.html { redirect_to([:admin, @faq_category], notice: 'Category was successfully created.') }\n format.xml { render xml: @faq_category, status: :created, location: @faq_category }\n website.add_log(user: current_user, action: \"Created FAQ Category: #{@faq_category.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @faq_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def list_customer_categories\n doc = Hpricot::XML(request.raw_post) \n doc = doc.to_s.gsub(\"&amp;\",\"&\") \n doc = Hpricot::XML(doc)\n @customer_categories = Customer::CustomerCrud.list_customer_categories(doc)\n render_view( @customer_categories,'customer_categories','L')\n end", "def create\n @category = current_mall.categories.new(params[:category])\n\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:success] = 'Category was successfully created.'\n format.html { redirect_to(admin_categories_url) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n flash[:error] = 'Category could not be created. See errors below.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @master_category = Master::Category.new(master_category_params)\n\n respond_to do |format|\n if @master_category.save\n format.html { redirect_to @master_category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @master_category }\n else\n format.html { render :new }\n format.json { render json: @master_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categorymaster = Categorymaster.new(params[:categorymaster])\n\n respond_to do |format|\n if @categorymaster.save\n format.html { redirect_to(@categorymaster, :notice => 'Categorymaster was successfully created.') }\n format.xml { render :xml => @categorymaster, :status => :created, :location => @categorymaster }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @categorymaster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @news_category = NewsCategory.new(params[:news_category])\n\n respond_to do |format|\n if @news_category.save\n format.html { redirect_to(@news_category, :notice => 'News category was successfully created.') }\n format.xml { render :xml => @news_category, :status => :created, :location => @news_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic_form_url = forum_category_forum_topics_path(@category, @forum)\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.find_by(id: params[:category_id])\n @topic = @category.topics.new(topic_params)\n\n if @topic.save\n flash[:success] = \"temat został utworzony\"\n redirect_to category_topic_path(@category, @topic)\n else\n flash[:error] = \"coś poszło nie tak\"\n end\n end", "def postEntityMigrate_category( from, to, limit)\n params = Hash.new\n params['from'] = from\n params['to'] = to\n params['limit'] = limit\n return doCurl(\"post\",\"/entity/migrate_category\",params)\n end", "def create\n @cat = Cat.new(params[:cat])\n\n respond_to do |format|\n if @cat.save\n format.html { redirect_to(@cat, :notice => 'Cat was successfully created.') }\n format.xml { render :xml => @cat, :status => :created, :location => @cat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @list_cat = ListCat.new(params[:list_cat])\n\n respond_to do |format|\n if @list_cat.save\n flash[:notice] = 'ListCat was successfully created.'\n format.html { redirect_to(:controller => 'list_cats', :action => 'edit', :id => @list_cat.id) }\n format.xml { render :xml => @list_cat, :status => :created, :location => @list_cat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @list_cat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @mk_categoria = MkCategoria.new(mk_categoria_params)\n\n respond_to do |format|\n if @mk_categoria.save\n format.html { redirect_to @mk_categoria, notice: 'Mk categoria was successfully created.' }\n format.json { render :show, status: :created, location: @mk_categoria }\n else\n format.html { render :new }\n format.json { render json: @mk_categoria.errors, status: :unprocessable_entity }\n end\n end\n end", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to admin_categories_url, notice: 'Добавлена новая категоря.' }\n else\n format.html { render :new }\n end\n end\n end", "def new\n @topic = Topic.new\n @super_categories = Topic.ordered_roots\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def create\n @topiccluster = Topiccluster.new(params[:topiccluster])\n\n respond_to do |format|\n if @topiccluster.save\n format.html { redirect_to(@topiccluster, :notice => 'Topiccluster was successfully created.') }\n format.xml { render :xml => @topiccluster, :status => :created, :location => @topiccluster }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topiccluster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Категория добавлена.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sys_category = Sys::Category.new(sys_category_params)\n\n respond_to do |format|\n if @sys_category.save\n format.html { redirect_to @sys_category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sys_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @sys_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @articlecat = Articlecat.new(articlecat_params)\n\n respond_to do |format|\n if @articlecat.save\n format.html { redirect_to @articlecat, notice: 'Articlecat was successfully created.' }\n format.json { render :show, status: :created, location: @articlecat }\n else\n format.html { render :new }\n format.json { render json: @articlecat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category_collection = CategoryCollection.new(params[:category_collection])\n @collection = @category_collection.collection\n\n respond_to do |format|\n if @category_collection.save\n flash[:notice] = 'CategoryCollection was successfully created.'\n format.html { redirect_to(@collection) }\n format.xml { render :xml => @category_collection, :status => :created, :location => @category_collection }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category_collection.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to categories_path, notice: 'Категория была успешно создана'}\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_forum payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post FORUMS, payload )\n\t\t\t\tend", "def postCategoryMerge( from, to)\n params = Hash.new\n params['from'] = from\n params['to'] = to\n return doCurl(\"post\",\"/category/merge\",params)\n end", "def fetchCats(dataDir, minConfidence)\n return NellELoad.allCategories(dataDir, minConfidence, NellE::STRICT_TRAINING_CAT_FILENAMES)\nend", "def htmlcreate\n @category = Category.new(category_params)\n if @category.save\n flash[:success] = t('admin.categories.create.created')\n redirect_to admin_categories_path\n else\n render 'new'\n end\n end", "def create\n @category = Category.new(category_params)\n\n if @category.save\n redirect_to @category.topic, notice: 'Category was successfully created.'\n else\n render action: 'new'\n end\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @cat = Category.new(cat_params)\n if @cat.save\n flash[:success] = \"successfully created new category #{@cat.name}.\"\n redirect_to dashboard_path\n else\n flash[:error] = @cat.errors.messages\n render :new, status: :bad_request\n end\n return\n end", "def add_categories(collection)\n\tcategory = \"\"\n\tcollection[\"results\"][\"collection1\"].each do |article|\n\t\tif article[\"category\"] == \"\"\n article[\"category\"] = category\n else\n category = article[\"category\"]\n end\n\tend\nend", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n flash[:notice] = 'Category was successfully created.'\n format.html { redirect_to(@category) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tag = @category.tags.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to([@category,@tag], :notice => 'Tag was successfully created.') }\n format.xml { render :xml => @tag, :status => :created, :location => [@category,@tag] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @kind=params[:k] || 'news'\n @locale=params[:locale] || 'zh_CN'\n @default_status='live'\n @language=Language.find_by_code(@locale)\n @article = Article.new({:language_id=>@language.id,:kind=>@kind,:status=>@default_status})\n @categories=@language.categories\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_article }\n end\n end", "def postCategoryMappings( category_id, type, id, name)\n params = Hash.new\n params['category_id'] = category_id\n params['type'] = type\n params['id'] = id\n params['name'] = name\n return doCurl(\"post\",\"/category/mappings\",params)\n end", "def create_category(cat_name)\n category = Spree::Taxonomy.where(name: 'Categories').first\n category = Spree::Taxonomy.create(name: 'Categories') if category.nil?\n taxon = Spree::Taxon.find_by(name: cat_name, taxonomy_id: category.id)\n if taxon.present?\n spree_taxons.append(taxon)\n else\n taxon = Spree::Taxon.new(name: cat_name, taxonomy_id: category.id, parent_id: category.root.id)\n if taxon.save\n spree_taxons.append(taxon)\n else\n Rails.logger.info \"Error! #{taxon.errors.full_messages}\"\n end\n end\n end", "def create\n @question = Question.new(params[:question])\n @question_category= QuestionCategory.new\n\n respond_to do |format| \n if @question.save\n @question_category.question_id = @question.id\n format.html { render \"add_categories\"}\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @xcategory = Xcategory.new(xcategory_params)\n\n respond_to do |format|\n if @xcategory.save\n format.html { redirect_to @xcategory, notice: 'Xcategory was successfully created.' }\n format.json { render :show, status: :created, location: @xcategory }\n else\n format.html { render :new }\n format.json { render json: @xcategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article_category = ArticleCategory.new(params[:article_category])\n\n respond_to do |format|\n if @article_category.save\n flash[:notice] = 'ArticleCategory was successfully created.'\n format.html { redirect_to :controller => 'admin/article_categories' }\n format.xml { render :xml => @article_category, :status => :created, :location => @article_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @article_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post_category = PostCategory.new(params[:post_category])\n \n respond_to do |format|\n if @post_category.save\n format.html { redirect_to(@post_category, :notice => 'Category was successfully created.') }\n format.xml { render :xml => @post_category, :status => :created, :location => @post_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_cat(name_en, name_nl)\n c = Category.new(name_en: name_en, name_nl: name_nl)\n c.save!\nend", "def bootstrap\n create(:category_name => tl(:unassigned_category), \n :category_id => 1)\n end", "def new\n @categorization = Categorization.new\n @categories = category_list\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @categorization }\n end\n end", "def update_categories(cats=[])\n rescue_extra_data\n cats = cats.to_i\n old_categories = categories.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")\n delete_categories = old_categories - cats\n news_categories = cats - old_categories\n term_relationships.where(\"term_taxonomy_id in (?)\", delete_categories ).destroy_all if delete_categories.present?\n news_categories.each do |key|\n term_relationships.create(:term_taxonomy_id => key)\n end\n update_counters(\"categories\")\n end", "def create\n\n # params[:forum_post] && params[:forum_post][:parent_id] = params[:thread_id].to_i\n @forum_post = ForumPost.new(params[:forum_post])\n\n respond_to do |format|\n if @forum_post.save\n format.html { redirect_to(main_forum_path, :notice => 'Posted.') }\n format.xml { render :xml => @forum_post, :status => :created, :location => @forum_post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @forum_post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @forum_category = ForumCategory.new\n @position = next_position\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @forum_category }\n end\n end", "def create\n @feature_category = FeatureCategory.new(params[:feature_category])\n\n respond_to do |format|\n if @feature_category.save\n format.html { redirect_to(feature_categories_url, :notice => 'Feature category was successfully created.') }\n # format.html { redirect_to(@feature_category, :notice => 'Feature category was successfully created.') }\n format.xml { render :xml => @feature_category, :status => :created, :location => @feature_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feature_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @contact_category = ContactCategory.new(params[:contact_category])\n\n respond_to do |format|\n if @contact_category.save\n flash[:notice] = 'ContactCategory was successfully created.'\n format.html { redirect_to(@contact_category) }\n format.xml { render :xml => @contact_category, :status => :created, :location => @contact_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def fetch_categories\r\n page = File.open(\"#{Rails.root}/public/Categories.html\") { |f| Nokogiri::HTML(f) }\r\n Category.save_fetched_categories_and_subcategories(page)\r\n end", "def create\n #render :text => rcadmin_category_params.inspect and return false\n @rcadmin_category = current_admin.categories.build rcadmin_category_params\n\n respond_to do |format|\n if @rcadmin_category.save\n\tflash[:notice] = 'Category was successfully created.'\n format.html { redirect_to rcadmin_categories_url }\n format.json { render action: 'show', status: :created, location: @rcadmin_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @rcadmin_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_category_pages\n tags.keys.each do |tag|\n items << Nanoc3::Item.new(\n \"= render('category', :tag => '#{tag}')\",\n {\n :title => \"Category: #{tag}\",\n :changefreq => 'daily',\n :priority => 0.4\n },\n \"/categories/#{tag.downcase.parameterize}/\",\n :binary => false\n )\n end\nend", "def create\n category = Documents::Category.create(category_params)\n if category.save\n redirect_to categories_path\n else\n redirect_to categories_path, alert: I18n.t('admin.categories.validation_error')\n end\n end", "def create\n @post_category = PostCategory.new(params[:post_category])\n\n respond_to do |format|\n if @post_category.save\n flash[:notice] = 'PostCategory was successfully created.'\n format.html { redirect_to(@post_category) }\n format.xml { render :xml => @post_category, :status => :created, :location => @post_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @cms_blog_category = CMS::BlogCategory.new(cms_blog_category_params)\n\n respond_to do |format|\n if @cms_blog_category.save\n format.html { redirect_to cms_admin_blog_categories_url, notice: 'Blog category was successfully created.' }\n format.json { render :show, status: :created, location: @cms_blog_category }\n else\n format.html { render :new }\n format.json { render json: @cms_blog_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @forum = Forum.new(forum_params)\n @forum.user_id = current_user.id\n @forum.tags = if !params[:selected_tags].nil? then params[:selected_tags].join(\",\") end\n\n respond_to do |format|\n if @forum.save\n format.html { redirect_to @forum, notice: 'Forum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @forum }\n else\n format.html { render action: 'new' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article = Article.new(article_params)\n if params[:article][:draft] === \"false\"\n labels = params[:article].delete(:labels).to_s\n initialize_or_create_labels(labels)\n add_category(params[:article][:category])\n end\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to [:admin, @article], notice: 'Article was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def addLogsBatchXML(collection=\"lclsLogs\", dizList, bulk: false)\n uri = URI.parse(\"http://#{@host}:#{@port}/solr/#{collection}/update\") \n # uri = URI.parse(\"http://psmetric04:8983/solr/lclsLogs/update\") \n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/xml')\n req.body = formatLogBatchAsXML(dizList)\n # puts req.body \n # res = http.request(req, xml: formatLogBatchAsXML(dizList) )\n res = http.request(req)\n # puts \"response: #{res.body}\"\n return [dizList.length, req.body.size, res]\n end", "def new\n @title = t(\"h2.categories\")\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def create\n \n @categorias_tipo = CatTipo.new(params[:cat_tipo])\n\n\t\trespond_to do |format|\n\t\t\tif @categorias_tipo.save\n \t\t\tcategories = @categorias_tipo.update_attributes(:tipo_acc_ids =>params[:tipo_accs])\n\t\t\t\t@categorias_tipo.update_attributes(:estado_ids =>params[:estados])\n\t\t\t\t\n\t\t\t\n\n format.html { redirect_to cat_tipos_path, notice: 'OK' }\n format.json { render json: @categorias_tipo, status: :created, location: @categorias_tipo }\n\t\t\telse\n format.html { render action: \"new\" }\n format.json { render json: @categorias_tipo.errors, status: :unprocessable_entity }\n \tend\t\n\t\tend\n\tend", "def user_category\n # byebug\n @user = User.where(contact: params[:contact]).first\n params[:category_ids].each do |category|\n @user.user_categories.create!(category_id: category, user_id: @user.id)\n end\n render json: {status: \"SUCCESS\", message: \"user-data\", data: \"category saved\"}, status: :ok\n end", "def create\n @course_category = CourseCategory.new(params[:course_category])\n @admin_section = true\n @page_title = \"New Course Category\"\n \n respond_to do |format|\n if @course_category.save\n format.html { redirect_to(course_categories_url, :notice => 'Course category was successfully created.') }\n format.xml { render :xml => @course_category, :status => :created, :location => @course_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def categories()\n @web.get('http://www.waymarking.com/cat/categorydirectory.aspx') do |page|\n ile = 0\n #puts page.parser.to_html.to_s\n cache = {}\n\n page.parser.css('div#content div.gutter a').each do |cat|\n href = cat.attr('href')\n m = Category::GUID_REGEXP.match href\n key = Waymarking::Utils.parameterize(cat.text)\n unless m.nil? then\n ile +=1\n raise DuplicatedCategory if cache.has_key? key\n\n cache[key] = m[1]\n #puts \"#{ile} #{key} #{cat.text} #{m[1]}\"\n else\n puts href\n end\n\n end\n\n cache2 = {}\n cache.keys.each do |key|\n @web.get(\"http://www.waymarking.com/cat/details.aspx?f=1&guid=#{cache[key]}&exp=True\") do |page2|\n begin\n cat = Waymarking::Category.from_html(page2)\n cache2[key] = cat\n rescue\n puts key\n end\n end\n end\n\n File.open('categories.yml', 'w') do |f|\n f.write YAML::dump(cache2)\n end\n end\n end", "def create\n #...\n params[:cat].permit(...:tag_ids: []) #allow tag_ids and expect it to be an Array\n end", "def create\n @ledger_category = LedgerCategory.new(ledger_category_params)\n\n respond_to do |format|\n if @ledger_category.save\n format.html { redirect_to @ledger_category, notice: 'Ledger category was successfully created.' }\n format.json { render :show, status: :created, location: @ledger_category }\n else\n format.html { render :new }\n format.json { render json: @ledger_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n auction_category = Auction::Category.new(auction_category_params)\n\n begin\n if auction_category.save_category!(params[:auction_category][:attribute_ids])\n flash_msg('success', '添加分类成功!', 'index')\n end\n rescue Exception => e\n flash_render('danger', \"添加分类失败!#{error_msg(auction_category)}\", 'new')\n end\n end", "def create\n @cp_category = Category.new(cp_category_params)\n\n respond_to do |format|\n if @cp_category.save\n format.html { redirect_to @cp_category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @cp_category }\n else\n format.html { render :new }\n format.json { render json: @cp_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @rcadmin_faq_category = Rcadmin::FaqCategory.new(rcadmin_faq_category_params)\n\n respond_to do |format|\n if @rcadmin_faq_category.save\n\t\tflash[:notice] = 'Faq category was successfully created.'\n format.html { redirect_to rcadmin_faq_categories_url, notice: 'Faq category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @rcadmin_faq_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @rcadmin_faq_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @catena = Catena.new(params[:catena])\n\n respond_to do |format|\n if @catena.save\n format.html { redirect_to(catenas_path, :notice => 'Catena was successfully created.') }\n format.xml { render :xml => @catena, :status => :created, :location => @catena }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @catena.errors, :status => :unprocessable_entity }\n end\n end\n end", "def import_cat1_file(doc)\n patient, _warnings = QRDA::Cat1::PatientImporter.instance.parse_cat1(doc)\n Cypress::QrdaPostProcessor.replace_negated_codes(patient, @bundle)\n patient.update(_type: CQM::TestExecutionPatient, correlation_id: 'api_eval', bundleId: @bundle.id)\n patient.save!\n patient.id\n end" ]
[ "0.61182815", "0.5838544", "0.57440066", "0.56360775", "0.5618319", "0.561795", "0.55866885", "0.5584254", "0.5566893", "0.5534312", "0.55145437", "0.5512915", "0.54744476", "0.54412353", "0.5435567", "0.5377139", "0.537596", "0.53596586", "0.53553075", "0.53281456", "0.52806693", "0.52640396", "0.52573514", "0.5245706", "0.52378005", "0.522051", "0.52201873", "0.5204189", "0.5203025", "0.51830393", "0.51828605", "0.51667416", "0.51502603", "0.51483685", "0.51391613", "0.5131955", "0.5110742", "0.5106809", "0.51048183", "0.510445", "0.5104252", "0.5103461", "0.51025665", "0.5091385", "0.5084322", "0.5079362", "0.50540376", "0.5032023", "0.50310326", "0.50178057", "0.50149274", "0.5014886", "0.5013924", "0.5009938", "0.500962", "0.5006515", "0.5004558", "0.49956876", "0.4995555", "0.4995555", "0.49911526", "0.49897048", "0.49858057", "0.49810234", "0.49804443", "0.4975334", "0.49727434", "0.49710965", "0.49703506", "0.4969774", "0.49678418", "0.49661106", "0.4966005", "0.49640787", "0.49635917", "0.4961976", "0.49581826", "0.49577948", "0.4954791", "0.4954149", "0.49527994", "0.49461776", "0.49428385", "0.49397424", "0.49327084", "0.49321896", "0.49281758", "0.492724", "0.49206752", "0.4915382", "0.49076432", "0.49034", "0.4901759", "0.49014825", "0.48995188", "0.4893786", "0.48929277", "0.4891509", "0.48885158", "0.48851076" ]
0.72710294
0
PUT /forum_cat_l1s/1 PUT /forum_cat_l1s/1.xml
def update @forum_cat_l1 = ForumCatL1.find(params[:id]) respond_to do |format| if @forum_cat_l1.update_attributes(params[:forum_cat_l1]) flash[:notice] = t(:category_updated) format.html { redirect_to(@forum_cat_l1) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n if @cat.update_attributes(params[:cat])\n _update_topics \n format.html { redirect_to action: \"edit\", notice: 'Cat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])\n\n respond_to do |format|\n if @forum_cat_l1.save\n flash[:notice] = t(:category1_created)\n format.html { redirect_to(@forum_cat_l1) }\n format.xml { render :xml => @forum_cat_l1, :status => :created, :location => @forum_cat_l1 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum_category.update_attributes(params[:forum_category])\n format.html { redirect_to forum_categories_path, notice: 'Forum category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @forum_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateForum id,params = {}\n \n APICall(path: \"forums/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end", "def update\n @otml_category = OtrunkExample::OtmlCategory.find(params[:id])\n\n respond_to do |format|\n if @otml_category.update_attributes(params[:otml_category])\n flash[:notice] = 'OtrunkExample::OtmlCategory was successfully updated.'\n format.html { redirect_to(@otml_category) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @otml_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @faq_category.update(faq_category_params)\n format.html { redirect_to([:admin, @faq_category], notice: 'Category was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated FAQ Category: #{@faq_category.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @faq_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(forum_category_params)\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end", "def destroy\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n @forum_cat_l1.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_cat_l1s_url) }\n format.xml { head :ok }\n end\n end", "def update\n respond_to do |format|\n if @forum.update_attributes(params[:forum])\n flash[:notice] = 'The forum was successfully updated.'\n format.html { redirect_to(forum_url(@forum)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.rss { render :rss => @forum.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @topiccluster = Topiccluster.find(params[:id])\n\n respond_to do |format|\n if @topiccluster.update_attributes(params[:topiccluster])\n format.html { redirect_to(@topiccluster, :notice => 'Topiccluster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topiccluster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { render \"add_categories\"}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = '分类修改成功.'\n format.html { redirect_to(cpanel_categories_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @forum = Forum.find(params[:id])\n\n respond_to do |format|\n if @forum.update_attributes(params[:forum])\n format.html { redirect_to(@forum, :notice => 'Forum was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @forum.errors, :status => :unprocessable_entity }\n end\n end\n end", "def putCategory( category_id, language, name)\n params = Hash.new\n params['category_id'] = category_id\n params['language'] = language\n params['name'] = name\n return doCurl(\"put\",\"/category\",params)\n end", "def update\n @forum_category = ForumCategory.find(params[:id])\n\n respond_to do |format|\n if @forum_category.update_attributes(params[:forum_category])\n if @forum_category.position.blank?\n @forum_category.position = next_position\n @forum_category.save\n end\n format.html { redirect_to forums_path, notice: 'Forum category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @forum_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update_attributes(params[:forum])\n flash[:notice] = 'The forum was successfully updated.'\n format.html { redirect_to(admin_forum_url(@forum)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.rss { render :rss => @forum.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @headline = t(:update_category)\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: t(:updated_category_success) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_forum_category\n @forum_category = ForumCategory.find(params[:id])\n end", "def update\n @company_forum_topic = CompanyForumTopic.find(params[:id])\n\n respond_to do |format|\n if @company_forum_topic.update_attributes(company_forum_topic_params)\n format.html { redirect_to @company_forum_topic, notice: 'Company forum topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company_forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @faqcat.update(faqcat_params)\n format.html { redirect_to root_url, notice: 'Category updated successfully.' }\n #format.html { redirect_to @faqcat, notice: 'Category was successfully updated.' }\n #format.json { render :show, status: :ok, location: @faqcat }\n else\n format.html { redirect_to root_url, notice: 'Something went wrong.' }\n #format.html { render :edit }\n #format.json { render json: @faqcat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @category.name == \"ROOT\"\n if @category.update(category_params)\n render 'show', :status => 200, :layout => false, notice: 'Category was successfully created.'\n else\n render :json => {:message => \"Error in updating category\"}, notice: @category.errors, :layout => false, :status => 400\n end\n else\n render :json => {:message => \"Root can't be edited.\"}, :layout => false, :status => 400\n end\n end", "def update_factcat\n cat = Category.find(self.category_id)\n self.factcat_id = cat.get_factcat_from_category.id\n self.save!\n end", "def update\n @news_category = NewsCategory.find(params[:id])\n\n respond_to do |format|\n if @news_category.update_attributes(params[:news_category])\n format.html { redirect_to(@news_category, :notice => 'News category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end", "def update\n @faq_category = FaqCategory.find(params[:id])\n\n respond_to do |format|\n if @faq_category.update_attributes(params[:faq_category])\n format.html { redirect_to @faq_category, notice: 'Faq category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @faq_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n @category.format_name = params[:category][:name].gsub(/ /, \"_\").downcase\n \n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to admin_scenic_spots_url, notice: 'Article was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @bcat1 = Bcat1.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @bcat1.update_attributes(params[:bcat1])\r\n flash[:notice] = 'Bcat1 was successfully updated.'\r\n format.html { redirect_to(@bcat1) }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @bcat1.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def new\n @forum_cat_l1 = ForumCatL1.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l1 }\n end\n end", "def update\n if @category.update(params[:category])\n head :no_content\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @category.update_attributes(params[:category])\n if @category.cambio_algo\n format.html {redirect_to notify_changes_category_url}\n else\n format.html { redirect_to(@category, :notice => t('scaffold.notice.updated', :item=> Category.model_name.human)) }\n format.xml { head :ok }\n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Kategoria została zapisana poprawnie.'\n format.html { redirect_to([:admin, @category]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @category = current_mall.categories.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n json_update(category,category_params, Category)\n end", "def update\n respond_to do |format|\n if @rcadmin_faq_category.update(rcadmin_faq_category_params)\n\t\tflash[:notice] = 'Faq category was successfully updated.'\n format.html { redirect_to rcadmin_faq_categories_url, notice: 'Faq category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rcadmin_faq_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n category = Documents::Category.find(params[:id])\n category.update!(category_params)\n redirect_to categories_path\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: \"Forum was successfully updated.\" }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:success] = 'Category was successfully updated.'\n format.html { redirect_to(admin_categories_url) }\n format.xml { head :ok }\n else\n flash[:error] = 'Category could not be updated. Please see errors below.'\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n labels = params[:article].delete(:labels).to_s\n puts \"---------------------------\"\n\n if !params[:article][:draft] || params[:article][:draft] === \"false\"\n initialize_or_create_labels(labels)\n if !@article.draft\n minus_category(@article.category)\n end\n add_category(params[:article][:category])\n end\n\n respond_to do |format|\n if @article.update(article_params)\n format.html { redirect_to [:admin, @article], notice: 'Article was successfully updated.' }\n format.json { render :show, status: :ok, location: @article }\n else\n format.html { render :edit }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @blog_category = BlogCategory.find(params[:id])\n\n respond_to do |format|\n if @blog_category.update_attributes(params[:blog_category])\n format.html { redirect_to([:admin, @blog_category], :notice => 'Blog category was successfully updated.') }\n # format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n # format.xml { render :xml => @blog_category.errors, :status => :unprocessable_entity }\n format.json { respond_with_bip(@blog_category) }\n end\n end\n end", "def update\n @feed_category = FeedCategory.find(params[:id])\n\n respond_to do |format|\n if @feed_category.update_attributes(params[:feed_category])\n format.html { redirect_to @feed_category, :notice => 'Feed category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @feed_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to forums_path, notice: t('.success') }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n if @cat.update_attributes(params[:cat])\n format.html { redirect_to(@cat, :notice => 'Cat was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cat.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n @forum.tags = params[:selected_tags].join(\",\")\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @ccategory = Ccategory.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @ccategory.update_attributes(params[:ccategory])\r\n format.html { redirect_to(pcategories_path, :notice => 'Ccategory was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @ccategory.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @category.master_id == 1 && category_params[:master_id].to_i != 1\n format.html { render :edit, notice: '不能相互隶属,也不能把顶级分类降级~'}\n else\n if @category.update(category_params)\n format.html { redirect_to categories_path, notice: '分类修改成功,没事你就改着玩吧,哈~' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n @feature_category = FeatureCategory.find(params[:id])\n\n respond_to do |format|\n if @feature_category.update_attributes(params[:feature_category])\n format.html { redirect_to(feature_categories_url, :notice => 'Feature category was successfully updated.') }\n # format.html { redirect_to(@feature_category, :notice => 'Feature category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @feature_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n update! {admin_categories_path}\n end", "def update\r\n respond_to do |format|\r\n if @forum.update(forum_params)\r\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @forum }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @forum.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Category was successfully updated.'\n format.html { redirect_to(@category) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @consumer_category = ConsumerCategory.find(params[:id])\n\n respond_to do |format|\n if @consumer_category.update_attributes(params[:consumer_category])\n format.html { redirect_to @consumer_category, notice: 'Consumer category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @consumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to forum_topic_path(@forum,@topic), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Category was successfully updated.'\n format.html { redirect_to(admin_categories_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @category.update_attributes(params[:category])\n flash[:notice] = \"Категория успешно изменена\"\n else\n flash[:alert] = \"Ошибка изменения категории: #{@category.errors.full_messages}\"\n end\n respond_to do |format|\n format.html { redirect_to categories_path }\n end\n end", "def update_categories(cats=[])\n rescue_extra_data\n cats = cats.to_i\n old_categories = categories.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")\n delete_categories = old_categories - cats\n news_categories = cats - old_categories\n term_relationships.where(\"term_taxonomy_id in (?)\", delete_categories ).destroy_all if delete_categories.present?\n news_categories.each do |key|\n term_relationships.create(:term_taxonomy_id => key)\n end\n update_counters(\"categories\")\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Foro actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @microsite = Microsite.find(params[:id])\n @microsites = Microsite.where(\"id != ?\",@microsite.id)\n @categories = Category.all\n respond_to do |format|\n if @microsite.update_attributes(params[:microsite])\n format.html { redirect_to admins_microsite_path(@microsite, :notice => 'Microsite was successfully updated.') }\n format.xml { head :ok }\n else\n build_microsite(@microsite)\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @microsite.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n flash[:notice] = 'Cluster was successfully updated.'\n format.html { redirect_to(@cluster) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cluster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @foursquare_category = FoursquareCategory.find(params[:id])\n\n respond_to do |format|\n if @foursquare_category.update_attributes(params[:foursquare_category])\n format.html { redirect_to([:scaffold, @foursquare_category], :notice => 'Foursquare category was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @foursquare_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum_forum.update(forum_forum_params)\n format.html { redirect_to @forum_forum, notice: 'Forum was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum_forum }\n else\n format.html { render :edit }\n format.json { render json: @forum_forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: 'Категория изменена.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cat = Cat.new(params[:cat])\n\n respond_to do |format|\n if @cat.save\n _update_topics \n format.html { redirect_to action: \"new\", notice: 'Cat was successfully created.' }\n format.json { render json: @cat, status: :created, location: @cat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n if @topic.update_attributes(params[:topic])\n forum = Forum.find(@topic.forum_id);\n redirect_to forum\n else\n render action: \"edit\" \n end\n end", "def update\n @category = Category.find(params[:id])\n @category.update_attributes(params[:category])\n respond_with(@category, location: categories_url)\n end", "def update_category_attribute_definition(kapp_slug, name, body, headers=default_headers)\n @logger.info(\"Updating the \\\"#{name}\\\" Category attribute definition in the \\\"#{kapp_slug}\\\" kapp.\")\n put(\"#{@api_url}/kapps/#{kapp_slug}/categoryAttributeDefinitions/#{encode(name)}\",body, headers)\n end", "def update\n @categorymaster = Categorymaster.find(params[:id])\n\n respond_to do |format|\n if @categorymaster.update_attributes(params[:categorymaster])\n format.html { redirect_to(@categorymaster, :notice => 'Categorymaster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @categorymaster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_faqcat\n @faqcat = Faqcat.find(params[:id])\n end", "def update\n @documentocategoria = Documentocategoria.find(params[:id])\n\n respond_to do |format|\n if @documentocategoria.update_attributes(params[:documentocategoria])\n format.html { redirect_to(@documentocategoria, :notice => 'Documentocategoria was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @documentocategoria.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @articlecat.update(articlecat_params)\n format.html { redirect_to @articlecat, notice: 'Articlecat was successfully updated.' }\n format.json { render :show, status: :ok, location: @articlecat }\n else\n format.html { render :edit }\n format.json { render json: @articlecat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n @title = 'Kategorie ' + @category.title + ' bearbeiten'\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to categories_path, notice: 'Category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to adminpanel_categories_path, notice: \"Категория #{@category.name} успешно обновлена\" }\n format.json { render :show, status: :ok, location: adminpanel_categories_path }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category_collection = CategoryCollection.find(params[:id])\n @collection = @category_collection.collection\n\n respond_to do |format|\n if @category_collection.update_attributes(params[:category_collection])\n flash[:notice] = 'CategoryCollection was successfully updated.'\n format.html { redirect_to(@collection) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category_collection.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @forum = Forum.find(params[:forum_id])\n\n params[:user_id] = current_user.id\n params[:forum_id] = @forum.id\n params[:moderation] = true if current_user.role <= Role.get_id(:guest)\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to [@forum, @topic], notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @component_category = ComponentCategory.find(params[:id])\n\n respond_to do |format|\n if @component_category.update_attributes(params[:component_category])\n flash[:notice] = 'ComponentCategory was successfully updated.'\n format.html { redirect_to(component_categories_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @component_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n # render plain: params.inspect\n @question = Question.find(params[:id])\n respond_to do |format|\n if @question.update_attributes(category: params[:question][:category], text: params[:question][:text])\n format.html { redirect_to(@question, notice: 'Question was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: 'edit' }\n format.xml { render xml: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to forums_path, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@forum = Forum.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @forum.update_attributes(params[:forum])\n\t\t\t\tformat.html { redirect_to @forum, notice: 'Το forum άλλαξε με επιτυχία' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @forum.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def editCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.find(params[:id])\n status = c.update(name: params[:name])\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end", "def update\n @word_list = current_user.word_list\n\n #need to first remove categories from the word\n @word.categories.each do |category|\n @word.categories.delete category\n end\n\n #then push categories in from the category_params\n if params[\"category\"].include?(:category_ids)\n (params[\"category\"])[\"category_ids\"].each do |i|\n next if i.to_i == 0\n @word.categories << Category.find(i.to_i) unless @word.categories.include?(Category.find(i.to_i))\n end\n end\n\n if category_params.include?(:title) && ((params[\"category\"])[\"title\"]) != \"\"\n @word.categories << @word_list.categories.build(title: (params[\"category\"])[\"title\"])\n end\n\n respond_to do |format|\n if @word.update(word_params)\n format.html { redirect_to @word_list, notice: 'Word was successfully updated.' }\n #format.json { render :show, status: :ok, location: @word }\n else\n format.html { render :edit }\n #format.json { render json: @word.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mk_categoria.update(mk_categoria_params)\n format.html { redirect_to @mk_categoria, notice: 'Mk categoria was successfully updated.' }\n format.json { render :show, status: :ok, location: @mk_categoria }\n else\n format.html { render :edit }\n format.json { render json: @mk_categoria.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to api_v1_category_path(@category), notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @category.update(category_params)\n redirect_to @category.topic, notice: 'Category was successfully updated.'\n else\n render action: 'edit'\n end\n end", "def update\n respond_to do |format|\n if @sys_category.update(sys_category_params)\n format.html { redirect_to @sys_category, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sys_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category.update(category_params)\n end", "def update_category(favorite_token)\n case favorite_token\n when '0'\n category.update_attribute(:favorite, '0')\n when '1'\n unless category.notes.where(favorite: '0').any?\n category.update_attribute(:favorite, '1')\n end\n end\n category.update_nesting_categories(favorite_token)\n end", "def update\n @training_category = TrainingCategory.find(params[:id])\n\n respond_to do |format|\n if @training_category.update_attributes(params[:training_category])\n flash[:notice] = 'Training Category was successfully updated.'\n format.html { redirect_to(training_categories_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @training_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n updated_activity = params.require(:activity).permit(:title, :body,\n tags_attributes:\n [:category_id])\n activity = Activity.find(params[:id])\n # first, clear any of the current activity's categories, then save\n Tag.where(activity_id: activity.id).destroy_all\n activity.update_attributes(updated_activity)\n\n respond_to do |format|\n format.html { redirect_to activity }\n format.json { render json: @activity }\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to @category, notice: 'Категория была успешно изменена' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # update attribute\n if @category.update_attributes(category_params)\n # flash message\n flash.now[:success] = \"更新完了しました。\"\n # get category data\n all_categories\n else\n render 'edit'\n end\n end", "def update\n @category = Category.find(params[:id])\n\n if @category.update_attributes(params[:category])\n flash[:notice] = 'Sucesso - update'\n else\n flash[:notice] = 'Falha ao atualizar a categoria'\n end\n\n # respond_to do |format|\n # if @category.update_attributes(params[:category])\n # format.html { redirect_to categories_path}\n # format.json { head :no_content }\n # else\n # format.html { render action: \"edit\" }\n # format.json { render json: @category.errors, status: :unprocessable_entity }\n \n # end\n # end\n end", "def update\n\n #params.require(:article).permit(:title, :status)\n\n respond_to do |format|\n\n if @article.update(article_params)\n\n @article.save_categories\n\n format.html { redirect_to @article, notice: \"Article was successfully updated.\" }\n\n format.json { render :show, status: :ok, location: @article }\n\n else\n\n format.html { render :edit, status: :unprocessable_entity }\n\n format.json { render json: @article.errors, status: :unprocessable_entity }\n\n end\n\n end\n\n end" ]
[ "0.61464083", "0.61202496", "0.6073736", "0.6055222", "0.60029536", "0.5998899", "0.59769785", "0.5892616", "0.58444476", "0.58378303", "0.58305293", "0.5809139", "0.5806455", "0.5758757", "0.57459974", "0.57392335", "0.57291216", "0.571252", "0.5706334", "0.569899", "0.56981546", "0.5695571", "0.563461", "0.55788606", "0.5577512", "0.5576202", "0.55632603", "0.55626106", "0.5548078", "0.55462486", "0.5530835", "0.5517992", "0.5515073", "0.55115896", "0.55058336", "0.5498127", "0.54936814", "0.549287", "0.5492581", "0.54923546", "0.5491713", "0.54833955", "0.54756755", "0.54756755", "0.5462417", "0.5461967", "0.5458384", "0.5453655", "0.54504466", "0.54439443", "0.5429668", "0.5428986", "0.5421695", "0.54163516", "0.5411326", "0.5408821", "0.5402648", "0.53937954", "0.5392436", "0.5391605", "0.5391605", "0.53912663", "0.5389808", "0.5389024", "0.5386501", "0.5383454", "0.5375246", "0.5367673", "0.5367673", "0.5367673", "0.53675807", "0.5359379", "0.5357179", "0.5355998", "0.53525513", "0.5350718", "0.53476864", "0.5337391", "0.5331986", "0.5326843", "0.532645", "0.5326076", "0.5307633", "0.53075933", "0.53068244", "0.5302503", "0.53002304", "0.52970904", "0.5296865", "0.52957755", "0.5290575", "0.52879757", "0.5285719", "0.5285581", "0.5282769", "0.5281187", "0.52770525", "0.52761483", "0.5274332", "0.5272639" ]
0.7152804
0
DELETE /forum_cat_l1s/1 DELETE /forum_cat_l1s/1.xml
def destroy @forum_cat_l1 = ForumCatL1.find(params[:id]) @forum_cat_l1.destroy respond_to do |format| format.html { redirect_to(forum_cat_l1s_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @forum_post = ForumPost.find(params[:id])\n forum_cat_l2 = @forum_post.forum_cat_l2\n @forum_post.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_cat_l2_path(forum_cat_l2) }\n format.xml { head :ok }\n end\n end", "def delete_forum id\n\t\t\t\t\tFreshdesk::Api::Client.delete_status_wrapper do\n\t\t\t\t\t\t( @connection.delete FORUMS, id ).code\n\t\t\t\t\tend\n\t\t\t\tend", "def destroy\n @forum = Forum.find(params[:id])\n @forum.destroy\n\n respond_to do |format|\n format.html { redirect_to(forums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @forum_category.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_categories_path }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @cat1 = Cat1.find(params[:id])\r\n @cat1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(cat1s_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @forum_category = ForumCategory.find(params[:id])\n @forum_category.destroy\n\n respond_to do |format|\n format.html { redirect_to forums_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @faq_category.destroy\n respond_to do |format|\n format.html { redirect_to(admin_faqs_path, notice: \"The category was deleted.\") }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted FAQ Category: #{@faq_category.name}\")\n end", "def destroy\n @otml_category = OtrunkExample::OtmlCategory.find(params[:id])\n @otml_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(otrunk_example_otml_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @forum = TogForum::Forum.find(params[:id])\n\n if @forum.destroy\n flash[:notice] = \"The forum was successfully deleted.\"\n else\n flash[:error] = \"An error occurred: #{@forum.errors.full_messages}\"\n end\n \n respond_to do |format|\n format.html { redirect_to(forums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news_category = NewsCategory.find(params[:id])\n @news_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(cpanel_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @forum_group = ForumGroup.find(params[:id])\n @forum_group.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_groups_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n\t\t@forum = @topic.forum\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(@forum) }\n end\n end", "def destroy\n @topiccluster = Topiccluster.find(params[:id])\n @topiccluster.destroy\n\n respond_to do |format|\n format.html { redirect_to(topicclusters_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\n if @forum.destroy\n flash[:notice] = \"The forum was successfully deleted.\"\n else\n flash[:error] = \"An error occurred: #{@forum.errors.full_messages}\"\n end\n \n respond_to do |format|\n format.html { redirect_to(admin_forums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @ccategory = Ccategory.find(params[:id])\r\n @ccategory.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(ccategories_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def DeleteForum id\n \n APICall(path: \"forums/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @forum = Forum.find(params[:id])\n \n begin\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to(forums_url, :notice => \"Forum #{@forum.name} was successfully deleted.\") }\n format.xml { head :ok }\n end\n rescue ActiveRecord::DeleteRestrictionError\n respond_to do |format|\n format.html { redirect_to(forums_url, :flash => {:alert => \"Forum #{@forum.name} cann`t be deleted due to dependencies to APs.\"}) }\n format.xml { head :ok }\n end\n end\n end", "def destroy\n @categorymaster = Categorymaster.find(params[:id])\n @categorymaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(categorymasters_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @company_forum_topic = CompanyForumTopic.find(params[:id])\n @company_forum_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to company_forum_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: 'Foro eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_categories_path) }\n format.xml { head :ok }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n #1st you retrieve the forum_thread thanks to params[:forum_thread_id]\n forum_thread = ForumThread.find (params[:forum_thread_id])\n #2nd you retrieve the forum_post thanks to params[:id]\n @forum_post = forum_thread.forum_posts.find(params[:id])\n @forum_post.destroy\n\n respond_to do |format|\n #1st argument reference the path /forum_threads/:forum_thread_id/forum_posts/\n format.html { redirect_to(forum_thread_forum_posts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @forumm.destroy\n respond_to do |format|\n format.html { redirect_to forumms_url }\n format.json { head :no_content }\n end\n end", "def destroy_forum\n @lecture.forum.destroy if @lecture.forum?\n redirect_to edit_lecture_path(@lecture)\n end", "def destroy\n @topic = Topic.find(params[:id])\n forum = Forum.find(@topic.forum_id);\n @topic.destroy\n redirect_to forum \n end", "def destroy\n @topic = Topic.find(params[:id])\n forum = @topic.forum\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_url(forum) }\n format.json { head :no_content }\n end\n end", "def destroy\n params[:id].each{|id| \n article_category = ArticleCategory.find(id.to_i)\n article_category.destroy\n }\n\n respond_to do |format|\n format.html { redirect_to(article_categories_url) }\n format.xml { head :ok }\n end\n end", "def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end", "def destroy\n @category.destroy\n head :no_content\n end", "def destroy\n @feature_category = FeatureCategory.find(params[:id])\n @feature_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(feature_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n # Destruir moderaciones\n Moderator.all.each do |mod|\n mod.destroy if mod.forum_id == @forum.id\n end\n\n # Destruir subscripciones\n Subscription.all.each do |sub|\n sub.destroy if sub.forum_id == @forum.id\n end\n\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: 'Forum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum = Forum.find(params[:forum_id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_url(@forum) }\n format.json { head :no_content }\n end\n end", "def delete_category id\n\t\t\t\t\tFreshdesk::Api::Client.delete_status_wrapper do\n\t\t\t\t\t\t( @connection.delete CATEGORIES, id ).code\n\t\t\t\t\tend\n\t\t\t\tend", "def destroy\n @documentocategoria = Documentocategoria.find(params[:id])\n @documentocategoria.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentocategorias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rcadmin_faq_category.destroy\n respond_to do |format|\n\t\tflash[:notice] = 'Faq category was successfully deleted.'\n format.html { redirect_to rcadmin_faq_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cat = Cat.find(params[:id])\n @cat.destroy\n\n respond_to do |format|\n format.html { redirect_to(cats_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n@post = Post.find(params[:id])\n@post.destroy\nrespond_to do |format|\nformat.html { redirect_to posts_path(:forum_id => params[:forum_id],\n:topic_id => params[:topic_id]) }\nformat.xml { head :ok }\nend\nend", "def destroy\n @forum_topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @catena = Catena.find(params[:id])\n @catena.destroy\n\n respond_to do |format|\n format.html { redirect_to(catenas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @wforum = Wforum.find_by_permalink(params[:id])\n @wforum.destroy\n\n respond_to do |format|\n format.html { redirect_to wforums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = @topic.category\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to @category }\n format.json { head :no_content }\n end\n end", "def deleteEntityCategory( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/category\",params)\n end", "def destroy\n @contact_category = ContactCategory.find(params[:id])\n @contact_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(contact_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @clique = Clique.find(params[:id])\n @clique.destroy\n\n respond_to do |format|\n format.html { redirect_to(cliques_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n authorize! :destroy, ForumComentario\n @forum = @forum_comentario.forum_id\n @forum_comentario.destroy\n if @forum_comentario.destroy\n @forum_comentario = ForumComentario.where(forum_id: @forum)\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: 'Forum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url, notice: 'Вы удалили категорию и список услуг.' }\n end\n end", "def destroy\n @categories=Category.all\n @category.destroy\n flash[:notice]=\"Supprimé avec succès!!!\"\n \n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: \"Forum was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @categoria = Categoria.find(params[:id])\n @categoria.destroy\n\n respond_to do |format|\n format.html { redirect_to(categorias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @forum.destroy\r\n respond_to do |format|\r\n format.html { redirect_to forums_url, notice: 'Forum was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @forum_forum.destroy\n respond_to do |format|\n format.html { redirect_to forum_forums_url, notice: 'Forum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @post_category = PostCategory.find(params[:id])\n @post_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(post_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pcategory = Pcategory.find(params[:id])\n @pcategory.destroy\n\n respond_to do |format|\n format.html { redirect_to(pcategories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cms_blog_category.destroy\n respond_to do |format|\n format.html { redirect_to cms_admin_blog_categories_url, notice: 'Blog category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ccl = Ccl.find(params[:id])\n @ccl.destroy\n\n respond_to do |format|\n format.html { redirect_to(ccls_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to forum_categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n listentries = List.find(:all,:conditions => \"list_cat_id = #{params[:id]}\")\n for listentry in listentries \n listentry.destroy\n end\n @list_cat = ListCat.find(params[:id])\n @list_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to(:controller => 'lists') }\n format.xml { head :ok }\n end\n end", "def destroy\n @course_category = CourseCategory.find(params[:id])\n @course_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(course_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @categoria_comida = CategoriaComida.find(params[:id])\n @categoria_comida.destroy\n\n respond_to do |format|\n format.html { redirect_to(categoria_comidas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sotto_categoria = SottoCategoria.find(params[:id])\n @sotto_categoria.destroy\n\n respond_to do |format|\n format.html { redirect_to(sotto_categorie_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @blogger = Blogger.find(params[:id])\n @blogger.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_bloggers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category2 = Category2.find(params[:id])\n @category2.destroy\n\n respond_to do |format|\n format.html { redirect_to(category2s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category_collection = CategoryCollection.find(params[:id])\n @collection = @category_collection.collection\n @category_collection.destroy\n\n respond_to do |format|\n format.html { redirect_to(@collection) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cuitcheque = Cuitcheque.find(params[:id])\n @cuitcheque.destroy\n respond_to do |format|\n format.html { redirect_to(cuitcheques_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @categorization = Categorization.find(params[:id])\n @categorization.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_categorizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cluster = Cluster.find(params[:id])\n @cluster.destroy\n\n respond_to do |format|\n format.html { redirect_to(clusters_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @media_category_association = MediaCategoryAssociation.find(params[:id])\n root_id = @media_category_association.root_id\n @media_category_association.destroy\n respond_to do |format|\n format.html { redirect_to edit_medium_url(@medium, :anchor => \"topics-#{root_id}\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @subcategory = @category.subcategories.find(params[:id])\n @subcategory.destroy\n\n respond_to do |format|\n format.html { redirect_to(kadmin_category_subcategories_url(@category)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n begin\n @category.destroy\n rescue ActiveRecord::DeleteRestrictionError\n error = 'Эта категория не может быть удалена, пока с ней связан хоть один файл.'\n ensure\n respond_to do |format|\n format.html { redirect_to categories_url, notice: error }\n format.json { head :ok }\n end\n end\n end", "def destroy\n @post = @topic.posts.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_topic_url(@forum, @topic)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n flash[:success] = 'Category was deleted.'\n format.html { redirect_to(admin_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @feed_category = FeedCategory.find(params[:id])\n @feed_category.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @retailer_category = RetailerCategory.find(params[:id])\n @retailer_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(retailer_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category.delete\n end", "def destroy\n @content_category = ContentCategory.find(params[:id])\n @content_category.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_home_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_url(:id=>@forum) }\n format.mobile { redirect_to forum_url(:id=>@forum) }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @mk_categoria.destroy\n respond_to do |format|\n format.html { redirect_to mk_categories_url, notice: 'Mk categoria was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mush_crawler = MushCrawler.find(params[:id])\n @mush_crawler.destroy\n\n respond_to do |format|\n format.html { redirect_to(mush_crawlers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\t@post.destroy\n\t\tredirect_to category_posts_path(1) #posts forum index page cat 1\n\tend", "def destroy\n @clasificacion = Clasificacion.find(params[:id])\n @clasificacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(clasificaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_topics_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic_attribute = TopicAttribute.find(params[:id])\n \n @topic_attribute.opinions.each do |opinion|\n opinion.destroy\n end\n \n @topic_attribute.destroy\n\n respond_to do |format|\n format.html { \n redirect_to(root_path)\n #topic_attributes_url\n }\n format.xml { head :ok }\n end\n end" ]
[ "0.71156746", "0.67091733", "0.66993564", "0.665105", "0.66479176", "0.65998554", "0.65891576", "0.6509587", "0.6448298", "0.64113075", "0.640622", "0.6388922", "0.6378038", "0.63606995", "0.6355409", "0.63508177", "0.62868", "0.6277622", "0.6273756", "0.62716573", "0.62595385", "0.6259214", "0.6259214", "0.6259214", "0.6259214", "0.6259214", "0.6253903", "0.62488645", "0.6246661", "0.6235817", "0.6228256", "0.62257653", "0.62234414", "0.62177867", "0.62160236", "0.6202727", "0.619948", "0.61981595", "0.6191954", "0.6189809", "0.617642", "0.61652267", "0.6164948", "0.6162533", "0.6160827", "0.6158694", "0.61527324", "0.61383635", "0.61336607", "0.61215997", "0.6113879", "0.6113879", "0.6113879", "0.61057144", "0.60789543", "0.60751605", "0.60735774", "0.6064264", "0.6062382", "0.6059874", "0.6055119", "0.60544145", "0.60421467", "0.60399634", "0.6035045", "0.6028507", "0.60258657", "0.6021759", "0.60204864", "0.6013001", "0.600628", "0.6002889", "0.6001362", "0.59994024", "0.5991784", "0.59757555", "0.5973546", "0.59671146", "0.5966073", "0.59636825", "0.59628135", "0.59611505", "0.5958223", "0.595104", "0.5946295", "0.59436846", "0.59413946", "0.59386504", "0.59342486", "0.5931127", "0.5930957", "0.5928252", "0.5927298", "0.5927298", "0.59192324", "0.5917402", "0.5915943", "0.59155536", "0.5914921", "0.5913163" ]
0.77989984
0
Things to do: Clean up code Add error exceptions Make UI understandable Create sudoku generator Add more simple way to input nums to sudoku (let user write in each square, and tab through them with enter) Write code to solve harder sudokus!!! Functions:
def mainSheet # Add sudoku defaults after hashes to run them hashes puts sudokuGUI(0.3) terminal end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve!\n simple_sudoku_logic\n puts \"HERE'S YOUR BOARD, SOLVED. ?\"\n display_board\n end", "def solve!\n \t# keep looping if previous board doesn't match current board (new grids are being solved)\n\t \twhile true do\n\t\t \t@sudoku.each_with_index do |row, rowindex|\n\t\t \t\trow.each_with_index do |cell, cellindex|\n\t\t \t\t\t# duplicate sudoku board to solve grids and compare with previous board\n\t\t \t\t\t@sudokudup = @sudoku.dup\n\t\t \t\t\t# get the array of numbers from current column \n\t\t \t\t\tcol = @sudoku.transpose[cellindex]\n\t\t \t\t\t# find unsolved grids\n\t\t \t\t\tnext if cell != 0\n\t\t \t\t\t# form an array of possible solutions, starting with all numbers from 1 to 9\n\t\t \t\t\tsolutions=(1..9).to_a\n\t\t \t\t\t# loop through numbers from 1 to 9, delete the number from solutions if it appears in current row/column\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if row.include?(x)}\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if col.include?(x)}\n\n\t\t \t\t\t# get the numbers from current box(3x3 grid)\n\t\t \t\t\t# example (number in each grids represent column index):\n\t\t \t\t\t# | 0 1 2 | - 0 (row/array index)\n\t\t \t\t\t# | 0 1 2 | - 1\n\t\t \t\t\t# | 0 1 2 | - 2\n\t\t \t\t\t# ---------\n\t\t \t\t\t# box_x returns the array/row index of the top left number of current box (refer to sample board)\n\t\t \t\t\tbox_x = (rowindex./3)*3\n\t\t \t\t\tbox = []\n\t\t \t\t\t# loop through the 3 rows in the box\n\t\t \t\t\t3.times do\n\t\t \t\t\t\t# box_y returns the column index of the top left number of current box (refer to sample board)\n\t\t \t\t\t\tbox_y=(cellindex./3)*3\n\t\t \t\t\t\t# loop through the 3 columns for each rows\n\t\t \t\t\t\t3.times do\n\t\t \t\t\t\t\t# insert current number into the 'box' array\n\t\t \t\t\t\t\tbox << @sudoku[box_x][box_y]\n\t\t \t\t\t\t\t# get the next column index from the current row\n\t\t \t\t\t\t\tbox_y += 1\n\t\t \t\t\t\tend\n\t\t \t\t\t\t# get the next row/array index\n\t\t \t\t\t\tbox_x += 1\n\t\t \t\t\tend\n\t\t \t\t\t# delete number from solutions if it appears in current box\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if box.include?(x)}\n\t\t \t\t\t# if solutions contain only 1 number, the current grid will be replaced with the number\n\t\t \t\t\t@sudoku[rowindex][cellindex] = solutions[0] if solutions.length == 1\n\t\t \t\tend\n\t\t \tend\n\t\t \tif @sudoku == @sudokudup\n\t\t \t\tguess\n\t\t \t\treturn @sudoku.flatten.join\n\t\t \t\tbreak\n\t\t \tend\n\t\tend\n end", "def guess\n \t# loop 1\n\t while true do\n\t\t @sudoku.each_with_index do |row, rowindex|\n\t\t row.each_with_index do |cell, cellindex|\n\t\t \t# *******************************************************\n\t\t \t# this part same as solve! method\n\t\t col = @sudoku.transpose[cellindex]\n\t\t # return to previous loop (loop 2) if sudoku board is completely solved\n\t\t return if !@sudoku.flatten.include?(0)\n\t\t next if cell != 0\n\t\t solutions=(1..9).to_a\n\t\t 1.upto(9) {|x| solutions.delete(x) if row.include?(x)}\n\t\t 1.upto(9) {|x| solutions.delete(x) if col.include?(x)}\n\t\t box_x=(rowindex./3)*3\n\t\t box=[]\n\t\t 3.times do\n\t\t \tbox_y=(cellindex./3)*3\n\t\t \t3.times do\n\t\t \t\tbox << @sudoku[box_x][box_y]\n\t\t \t\tbox_y += 1\n\t\t \tend\n\t\t box_x += 1\n\t\t \tend\n\t\t \t\t1.upto(9) {|x| solutions.delete(x) if box.include?(x)}\n\t\t \t\t# *******************************************************\n\t\t \t\t# return to previous loop/previous unsolved grid(loop 2) if no solutions found for current grid\n\t\t \treturn if solutions == []\n\t\t \tsolutions_index = 0\n\t\t \t# loop through each number in solutions array (loop 2)\n\t\t \twhile true do\n\t\t \t\t# replace current grid with a number with in solutions\n\t\t\t @sudoku[rowindex][cellindex] = solutions[solutions_index]\n\t\t\t # call itself\n\t\t\t guess\n\t\t\t # code start from this line if no solution found from previous recursion (from return if solutions == [])\n\t\t\t # break the loop if sudoku board is completely solved\n\t\t\t break if !@sudoku.flatten.include?(0) \n\t\t\t # change index to the next number in solutions\n\t\t\t solutions_index += 1\n\t\t\t \tif rowindex == 0 && cellindex ==0 && solutions_index == solutions.length\n\t\t\t\t \t@sudoku[rowindex][cellindex] = 0\n\t\t\t\t \t# stop recursion and goes to next loop(loop 1) if no solutions found at all\n\t\t\t\t \tbreak\n\t\t\t \telsif solutions_index == solutions.length\n\t\t\t \t@sudoku[rowindex][cellindex] = 0\n\t\t\t \t# return to previous loop/previous unsolved grid(loop 2) if no solutions found for current grid\n\t\t\t \treturn\n\t\t\t \tend\n\t\t \tend\n\t \tend\n\t \tend\n \tend\n end", "def valid_sudoku(table)\n sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {},\n [1, 0] => {}, [1, 1] => {}, [1, 2] => {},\n [2, 0] => {}, [2, 1] => {}, [2, 2] => {}}\n\n sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {},\n 4 => {}, 5 => {}, 6 => {},\n 7 => {}, 8 => {}, 9 => {}}\n \n sudoku_col_hash = { 1 => {}, 2 => {}, 3 => {},\n 4 => {}, 5 => {}, 6 => {},\n 7 => {}, 8 => {}, 9 => {}}\n\n sudoku_diagonal_hash = {1 => {}, 9 => {}}\n\n table.each_with_index do |arr, i|\n arr.each_with_index do |ele, j|\n next if ele == \".\"\n # check and add diagonals\n if i == j \n return false if sudoku_diagonal_hash[1].include?(ele)\n sudoku_diagonal_hash[1][ele] = 1\n elsif i + j + 1 == 9 || i == 4 && j == 4\n return false if sudoku_diagonal_hash[9].include?(ele)\n sudoku_diagonal_hash[9][ele] = 1\n end\n\n # check these hashes for all elements\n return false if sudoku_row_hash[i + 1].include?(ele)\n return false if sudoku_col_hash[j + 1].include?(ele)\n return false if sudoku_box_hash[[i / 3, j / 3]].include?(ele)\n\n # can add if no return \n sudoku_row_hash[i + 1][ele] = 1\n sudoku_col_hash[j + 1][ele] = 1\n sudoku_box_hash[[i / 3, j / 3]][ele] = 1 # based off calculating indices of ecah sudoku box\n end\n end\n\n return true\nend", "def temp_test(sudoku_datas)\n sudoku_cells = prepare_sudoku_cells(sudoku_datas)\n # display_sudoku(sudoku_cells, \"Sudoku to solve\")\n # build the potential list of values for each cell\n build_potential_value_list(sudoku_cells)\n update_cells(sudoku_cells) # update the value of each cell\n counter = 0\n # continue to the try to solve\n # if the counter goes beyond a million\n # it's probably a bad sudoku\n \n display_sudoku(sudoku_cells, \"Test\")\n shed_potential_value_list(sudoku_cells)\n \n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n \nend", "def valid_sudoku(table)\n # edge cases\n return false if table.nil? || table.size != 9 || table[0].size != 9\n # 3 new storages will count number of occurances of each element for columns, rows and sub-boxes\n rows = Array.new(9)\n i = 0\n while i < rows.size\n rows[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n columns = Array.new(9)\n i = 0\n while i < columns.size\n columns[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n sub_boxes = Array.new(9)\n i = 0\n while i < sub_boxes.size\n sub_boxes[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n # loop through the input table to populate the above created storages with occurance numbers\n i = 0 # i is a row counter\n while i < table.size\n j = 0 # j is a column counter\n while j < table.size\n if table[i][j] != \".\"\n rows[i][table[i][j]] += 1\n columns[j][table[i][j]] += 1\n # find a number of a box/hash by calculating (i/3)*3 + (j/3)\n # e.g. for the element at indexes 1,2 the box will be: (1/3)*3 + (2/3) = 0, first box\n sub_boxes[(i/3)*3 + (j/3)][table[i][j]] += 1\n end\n j += 1\n end\n i += 1\n end\n # check if any of table elements occured more than 1 time within a row, a column or a sub-box\n rows.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n columns.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n sub_boxes.each_with_index do |hash, i|\n return false if hash.any? { |key, value| value > 1}\n end\n\n return true\nend", "def valid_sudoku(table)\n store = {\n rows: {},\n cols: {},\n square: {},\n }\n # First loop it represents the first row we are checking\n # Second loop it represents the column.\n\n (0...9).each do |i|\n (0...9).each do |j|\n box = table[i][j]\n if !store[:rows][i] && box != \".\"\n store[:rows][i] = []\n store[:rows][i].push(box)\n elsif box != \".\" && !store[:rows][i].include?(box)\n store[:rows][i].push(box)\n elsif store[:rows][i] && store[:rows][i].include?(box)\n return false\n end\n\n if !store[:cols][j] && box != \".\"\n store[:cols][j] = []\n store[:cols][j].push(box)\n elsif box != \".\" && !store[:cols][j].include?(box)\n store[:cols][j].push(box)\n elsif store[:cols][j] && store[:cols][j].include?(box)\n return false\n end\n\n # Converting to float and the ceil to round up always.\n squareRowId = ((i + 1).to_f / 3).ceil\n squareColId = ((j + 1).to_f / 3).ceil\n # The squeare id is gonna be like\n # 1-1 , 1-2, 1-3\n # 2-1 , 2-2, 2-3\n # 3-1 , 3-2, 3-3\n\n squareId = \"#{squareRowId}-#{squareColId}\"\n\n # Here insted of checking rows and colums I will be checking the numbers inside of this\n # Squeare ids.\n if !store[:square][squareId] && box != \".\"\n store[:square][squareId] = []\n store[:square][squareId].push(box)\n elsif box != \".\" && !store[:square][squareId].include?(box)\n store[:square][squareId].push(box)\n elsif store[:square][squareId] && store[:square][squareId].include?(box)\n return false\n end\n end\n end\n return true\nend", "def valid_sudoku(table)\n subgrids = {}\n\n # return false if any element is repeated in a row\n table.each do |row|\n row_count = {}\n row.each do |element|\n if row_count[element]\n return false unless element == \".\"\n else\n row_count[element] = 1\n end\n end\n end\n\n # return false if any element is repeated in a column\n columns = {\n 0 => {},\n 1 => {},\n 2 => {},\n 3 => {},\n 4 => {},\n 5 => {},\n 6 => {},\n 7 => {},\n 8 => {},\n }\n table.each do |row|\n row.each_with_index do |element, index|\n if columns[index][element]\n return false unless element == \".\"\n else\n columns[index][element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[0..2].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[3..5].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[6..8].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n return true\nend", "def valid_sudoku(table)\n \nend", "def solve_a_sudoku(sudoku_datas)\n sudoku_cells = prepare_sudoku_cells(sudoku_datas)\n # display_sudoku(sudoku_cells, \"Sudoku to solve\")\n # build the potential list of values for each cell\n build_potential_value_list(sudoku_cells)\n update_cells(sudoku_cells) # update the value of each cell\n counter = 0\n # continue to the try to solve\n # if the counter goes beyond a million\n # it's probably a bad sudoku\n until solved(sudoku_cells) || counter > 1000 #\n shed_potential_value_list(sudoku_cells)\n update_cells(sudoku_cells)\n # double_whammer(sudoku_cells)\n counter += 1\n end\n if (counter > 1000)\n return nil\n end\n sudoku_cells\nend", "def board\n\t \t# counter for the row and cell numbers\n\t cell_counter = 0\n\t row_counter = 0\n\t puts \"----------------------\"\n\t @sudoku.each do |row|\n\t # row_counter indicates the row number/array index of current loop \n\t row_counter += 1 \n\t row.each do |cell|\n\t \t# cell_counter indicates the cell number/index in current array\n\t cell_counter += 1\n\t # display underscore to indicate an unsolved grid\n\t cell = \"_\" if cell == 0\n\t # print the number if the number not 0\n\t print \"#{cell} \"\n\t # print '|' for every 3 numbers to display to 3x3 sub grid\n\t print \"|\" if cell_counter%3 == 0\n\t # start a new row for every 9 numbers\n\t puts \"\" if cell_counter%9 == 0\n\t end\n\t # display dotted lines for every 3 rows \n\t puts \"----------------------\" if row_counter%3 == 0\n\t end\n end", "def valid_sudoku(table)\n numbers = {}\n\n # iterate through each row and confirm valid\n row = 0\n while row < table.length\n table[row].each do |value|\n return false if !check_value(numbers, value)\n end\n\n numbers = {}\n row += 1\n end\n\n # iterate through each column and confirm valid\n numbers = {}\n col = 0\n while col < table[0].length\n (0..8).each do |x|\n value = table[x][col]\n\n return false if !check_value(numbers, value)\n end\n\n numbers = {}\n col += 1\n end\n\n # create list of each sub-box's upper left corner\n corners = []\n (0..2).each do |row|\n (0..2).each do |col|\n corners << [row * 3, col * 3]\n end\n end\n\n # iterate through the list of corners to see if each value is unique within the sub-box\n numbers = {}\n index = 0\n while index < corners.length\n (0..2).each do |x|\n (0..2).each do |y|\n x_point = corners[index][0] + x\n y_point = corners[index][1] + y\n value = table[x_point][y_point]\n\n return false if !check_value(numbers, value)\n end\n end\n\n numbers = {}\n index += 1\n end\n\n return true\nend", "def valid_sudoku(table)\n table.each do |row|\n row_map = {}\n row.each do |elem|\n if elem != '.'\n if row_map[elem] \n return false\n else\n row_map[elem] = 1\n end\n end\n end\n end\n \n i = 0\n 9.times do\n column_map = {}\n table.each do |row|\n col = row[i]\n if col != '.'\n if column_map[col] \n return false\n else\n column_map[col] = 1\n end\n end\n\n end\n k += 1\n end\n \n i = 0\n k = 0\n 9.times do\n box_map = {}\n while i < i + 3\n while k < k + 3\n \n end\n end \n end\n \n return true\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend", "def valid_sudoku(table)\n row_list = {}\n col_list = {}\n\n i = 0\n while i < table.length \n j = 0\n\n while j < table[i].length\n \n row_num = table[i][j]\n col_num = table[j][i]\n\n row_list = update_sub_grid(row_list, row_num)\n return false if !row_list\n\n col_list = update_sub_grid(col_list, col_num)\n return false if !col_list\n\n j += 1\n end\n\n\n row_list = {}\n col_list = {}\n \n i += 1\n end\n\n\n starting_points = [\n [0, 0],\n [0, 3],\n [0, 6],\n [3, 0],\n [3, 3],\n [3, 6],\n [6, 0],\n [6, 3],\n [6, 6]\n ]\n\n starting_points.each do |row_start, col_start|\n return false if !valid_sub_grid(table, row_start, col_start)\n end \n\n return true\nend", "def solve(board_string)\n sudoku_board = string_breaker(board_string)\n i = 0\n until solved?(sudoku_board) || i == 80\n sudoku_board.each_with_index do |row, row_idx|\n row.each_with_index do |square, col_idx|\n if row[col_idx].is_a?(Array)\n row[col_idx] = solve_suite(row, square, row_idx, col_idx, sudoku_board)\n row[col_idx] = row[col_idx][0].to_i if row[col_idx].length == 1\n end\n end\n end\n i += 1\n end\n sudoku_board\nend", "def solve!\n return false unless valid?\n return @board.join if solved?\n\n unsolved = @board.index(\"0\")\n\n (1..9).each do |possible|\n @board[unsolved] = possible\n solution = Sudoku.new(@board.join).solve!\n return solution if solution\n end\n\n false\n end", "def demoMethod\n\t\tif(@step == nil)\n\t\t\tstatutMethod(true)\n\n\t\t\t@step = 0\n\n\t\t\t@type = \"demoMethod\"\n\n\t\t\tSudokuAPI.API.saveSudoku(\"old\");\n\n\t\t\t#Assistant dit \"Voici une démonstration\"\n\t\t\tgridDemo = \"005000070400000400000000000000404000000000000000000000000000000000000000000000000\"\n\n\t\t\tSudokuAPI.API.setSudoku(Sudoku.create(gridDemo),Sudoku.create(gridDemo),Sudoku.create(gridDemo));\n\n\n\t\t\tSudokuAPI.API.sudokuEditable(true)\n\n\t\t\tSudokuAPI.API.assistantMessage=(\"Voici une démonstration de la méthode du candidat unique. \\n(Appuyez sur Suivant)\")\n\n\t\t\t#grisage des cases non importantes\n\t\t\t0.upto(8) do |x|\n\t\t\t\t1.upto(8) do |y|\n\t\t\t \t\t#SudokuAPI.API.setCazeInvisble(x,y)\n\t\t\t \t\tSudokuAPI.API.cazeAt(x,y).color=Colors::CL_NUMBER_LOCKED;\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t0.upto(8) do |x|\n\t\t\t\tSudokuAPI.API.setHintAt(x,0,true)\n\t\t\tend\n\n\t\t\t\t#Assistant dit on va s'occuper de cette ligne\n\t\t\t\tSudokuAPI.API.assistantMessage=(\"Nous allons effectuer la méthode sur cette ligne. \\n(Appuyez sur Suivant)\")\n\n\t\telsif(@step == 1)\n\t\t\t#Mise en valeur de la case\n\t\t\tSudokuAPI.API.cazeAt(4,0).color=Colors::CL_HIGHLIGHT_METHOD;\n\n\t\t\t#\"On peut remarquer que sur cette case machin truc\"\n\t\t\tSudokuAPI.API.assistantMessage=(\"On peut remarquer que 4 est candidat dans cette case et\\nqu'il n'est présent nul par ailleurs dans l'unité. \\n(Appuyez sur Suivant)\")\n\n\t\telsif(@step == 2)\n\t\t\t#affichage du chiffre\n\t\t\tSudokuAPI.API.cazeAt(4,0).value=(4)\n\t\t\tSudokuAPI.API.assistantMessage=(\"On en déduit donc que 4 est le chiffre présent dans cette case. \\n(Appuyez sur Suivant)\")\n\n\t\telsif(@step == 3)\n\t\t\t#Chargement de la grille précédente\n\t\t\tSudokuAPI.API.loadSudoku(\"old\");\n\t\t\tstatutMethod(false)\n\t\t\tSudokuAPI.API.assistantMessage=(\"Bonjour, je suis l'assistant, je suis là pour vous aider.\")\n\n\t\tend\n\n\t\t@step+=1\n\n\tend", "def solve_sudoku(board, empty_positions)\n i = 0\n\n while i < empty_positions.length\n rrow = empty_positions[i][0]\n ccolumn = empty_positions[i][1]\n number = board[rrow][ccolumn] + 1\n found = false\n\n while !found && number <= 9\n if check_value(board, rrow, ccolumn, number)\n found = true\n board[rrow][ccolumn] = number\n i += 1\n else\n number += 1\n end\n end\n\n if !found\n board[rrow][ccolumn] = 0\n i -= 1\n end\n end\n \n board\nend", "def solve(board_string)\n board_array = []\n separated_board_string = board_string.split('')\n board_array << (separated_board_string[0..8])\n board_array << (separated_board_string[9..17])\n board_array << (separated_board_string[18..26])\n board_array << (separated_board_string[27..35])\n board_array << (separated_board_string[36..44])\n board_array << (separated_board_string[45..53])\n board_array << (separated_board_string[54..62])\n board_array << (separated_board_string[63..71])\n board_array << (separated_board_string[72..80])\n board_array\n\n# temp_array = board_array.join\n# while board_array.include?(\"-\")\n 50.times { sudoku_solver(board_array) }\n # end\n board_array\nend", "def valid_sudoku(table)\n\n return true if in_row?(table) && in_column?(table) && in_box?(table)\n\n return false\n\nend", "def sudoku_valid? grid\n \n # grid has first index for row, 2nd index for column\n \n # Check every row\n grid.each do |row|\n seen = Set.new\n (0..9).each do |row_value|\n if !seen.add?(row_value)\n return false\n end\n end\n end\n \n # Check every column\n grid.each do |row|\n seen = Set.new\n row.each do |col_value|\n if !seen.add?(col_value)\n return false\n end\n end\n end\n \n # Check every 3x3\n [0,3,6].each do |offset|\n [0,3,6].each do |offset2|\n to_check = get3by3 grid, offset, offset2\n seen = Set.new\n to_check.each do |value|\n if !seen.add?(value)\n return false\n end\n end\n end\n end\n \n \n return true\nend", "def puzzle(sudoku)\n#this method is yours to implement\n#need to remove 2 numbers from grid\nsudoku =sudoku.dup\n# [10,20,30,40,23,45,56,76,34,56,77,21].each do |index| \n(1.upto(81).to_a.shuffle.slice(0,25)).each do |index|\n sudoku[index]=''\nend\n # random_values =Array.new(10.upto(37).to_a).shuffle\n\t# random.values.each {|index| sudoku[index] =''}\n\t# sudoku[9]=0\n\t# sudoku[5]=0\n\tsudoku\nend", "def sudoku(rows)\n # constrain the non-zero elements to keep their current values, and\n # constrain the zero elements (i.e. the blanks) to be between 1 and 9\n constrain_each_row(rows)\nend", "def sudoku_with_options(grid_lines, grid_columns, sudoku)\n sudoku_grids = sudoku_grids(grid_lines, grid_columns, sudoku)\n sudoku_flatten = sudoku.map { |element| element.flatten }\n sudoku_transpose_flatten = sudoku.transpose.map { |element| element.flatten }\n\n sudoku_with_options = []\n line_index = 0\n\n sudoku_with_options = sudoku.each_with_index do |line, line_index|\n cell_index = 0\n line.each_with_index do |cell, cell_index|\n sudoku_grids_index = (line_index / grid_lines) * grid_lines + (cell_index / grid_columns)\n unless cell.length == 1\n (1..grid_size(grid_lines, grid_columns)).to_a.each do |i|\n cell << i unless sudoku_flatten[line_index].include?(i) || sudoku_transpose_flatten[cell_index].include?(i) || sudoku_grids[sudoku_grids_index].include?(i)\n end\n end\n cell_index += 1\n end\n line_index += 1\n end\n return sudoku_with_options\nend", "def solve(row, col)\n\tif row == 9 then\n\t\treturn true\n\tend\n\t\n\tif col == 9 then\n\t\treturn solve(row +1, 0)\n\tend\n\t\n\tif @sudokuBoard[row][col] != 0 then\n\t\treturn solve(row, col +1)\n\tend\n\t\n\t1.upto(9) {\n\t|num|\n\t\n\tif check(row,col,num) then\n\t\t@sudokuBoard[row][col] = num\n\t\tif solve(row, col+1) then\n\t\t\treturn true\n\t\tend\n\tend\n\t}\n\t\n\t@sudokuBoard[row][col] = 0\n\treturn false\n\t\n\t\n\tend", "def is_valid_sudoku(board)\n transposed_board = board.transpose\n board.each_with_index do |row, r_index|\n row.each_with_index do |cell, c_index|\n # check row\n # check column\n if !check_row(row, cell, c_index) || !check_row(transposed_board[c_index], cell, r_index)\n p \"False at: #{cell}, #{r_index}, #{c_index}\"\n return false\n end\n end\n end\n return true\nend", "def puzzle(sudoku)\n\tfor i in (1..65)\n\t\tb = rand(81)\n\t\tsudoku[b] = 0\n\tend\n\tsudoku\nend", "def loadFromFile(fileName)\n inFile = File.new(fileName, \"r\")\n index = 0\n\n # Iterate over the lines from the file.\n inFile.each_line do |line|\n # line is a string containing one line from the file.\n\n ### The code to process the line goes here. ###\n\t\tvals = line.split\n\t\t# The collect block will iterate over each item in vals (strings)\n\t\t# and perform the function (convert to int) returning the set as a new array.\n\t\t@sudokuBoard[index] = vals.collect { |x| x.to_i }\n index = index + 1\n end\n\t\n\t\n\t# Returns whether a number can be placed in this column\n\t#\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the column, false otherwise\n\tdef checkCol(col, num)\n\t\t0.upto(BOARD_SIZE-1){\n\t\t|row| \n\t\tif num == @sudokuBoard[row][col] then\n\t\t\treturn false\n\t\tend\n\t\t}\n\t\treturn true\n\n\tend\n\t# Returns whether a number can be placed in this row\n\t#\n\t# @param row A number representing the board row\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the row, false otherwise\n\tdef checkRow(row, num)\n\t\tdisjointSet = @sudokuBoard[row] - [num]\n\t\tif disjointSet.length == 9 then\n\t\t\t# Safe to add sum to the row.\n\t\t\treturn true\n\t\telse\n\t\t\t# Unsafe to add sum to the row, since it already existed there.\n\t\t\treturn false\n\t\tend\n\t\t\n\tend\n\t\n\t# Returns whether a number can be placed in this subgrid\n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the subgrid, false otherwise\n\tdef checkSubgrid(row, col, num)\n\t\tx = (row / 3) * 3\n\t\ty = (col / 3) * 3\n\n\t\tbox = @sudokuBoard[x][y..(y+2)] + @sudokuBoard[x+1][y..(y+2)] + @sudokuBoard[x+2][y..(y+2)]\n\t\tdisjointSet = box - [num]\n\t\tif disjointSet.length == 9 then\n\t\t\t# Safe to add num to the row.\n\t\t\treturn true\n\t\telse\n\t\t\t# Unsafe to add num to the row, since it already existed there.\n\t\t\treturn false\n\t\tend\n\t\t\n\t\n\t\n\t\n\tend\n\t\n\t# Returns whether a number can be placed per sudoku rules\n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in this postion, false otherwise\n\tdef check(row, col, num)\n\t\treturn checkCol(col,num) && checkRow(row,num) && checkSubgrid(row,col,num)\n\t\n\tend\n\t\n\t# A recursive backtracking function to solve sudoku boards \n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @return Returns true if the board is solved, false otherwise\n\tdef solve(row, col)\n\tif row == 9 then\n\t\treturn true\n\tend\n\t\n\tif col == 9 then\n\t\treturn solve(row +1, 0)\n\tend\n\t\n\tif @sudokuBoard[row][col] != 0 then\n\t\treturn solve(row, col +1)\n\tend\n\t\n\t1.upto(9) {\n\t|num|\n\t\n\tif check(row,col,num) then\n\t\t@sudokuBoard[row][col] = num\n\t\tif solve(row, col+1) then\n\t\t\treturn true\n\t\tend\n\tend\n\t}\n\t\n\t@sudokuBoard[row][col] = 0\n\treturn false\n\t\n\t\n\tend\n\t\t\n\n inFile.close\nend", "def sudoku_clauses\n res = []\n\n #ensure each cell contains a digit\n (1..9).each do |i|\n (1..9).each do |j|\n #must contains at least one of 9 digits\n res << (1..9).map {|d| variable(i, j, d) }\n\n (1..9).each do |d|\n ((d+1)..9).each do |dp|\n #can not contain two digits at once\n res << [-variable(i, j, d), -variable(i, j, dp)]\n end\n end\n end\n end\n\n #ensure each rows and columns contain distinct values\n (1..9).each do |i|\n res += valid( (1..9).map{|j| [i, j]} )\n res += valid( (1..9).map{|j| [j, i]} )\n end\n\n #ensure 3x3 sub-grids regions have distinct values\n [1, 4, 7].each do |i|\n [1, 4, 7].each do |j|\n res += valid((0..8).map{|k| [i + k%3, j+k / 3]})\n end\n end\n\n res\n end", "def create_puzzle(params)\n difficulty = params[:difficulty] || \"medium\"\n case difficulty\n when \"medium\"\n blanks = rand(49..51)\n when \"hard\"\n blanks = rand(52..54)\n when \"veryhard\"\n blanks = rand(55..57)\n when \"easy\"\n blanks = rand(45..48)\n when \"veryeasy\"\n blanks = rand(40..44)\n end\n c = Sudoku.make(blanks)\n @puzzle = c[0]\n @solution = c[1]\n \n # Returns html using index.html.erb template\n # Bindings include @puzzle and @solution\n current_dir = File.dirname(__FILE__)\n text = File.read(File.join(current_dir, \"../erb/index.html.erb\"))\n return ERB.new(text).result(binding)\n\n end", "def check_sudoku(grid)\n return (check_rows(grid) and check_cols(grid) and check_squares(grid))\nend", "def validSolution(board)\n array_of_boxes = Array.new\n box = Array.new\n i = 0\n\n add_box_array = lambda do\n 3.times do\n 3.times do\n row = board[i]\n box.push(row[0]).push(row[1]).push(row[2])\n i += 1\n end\n\n array_of_boxes << box\n box = Array.new\n end\n end\n\n reset_and_rotate = lambda do\n i = 0\n board.each{ |row| row.rotate!(3) }\n end\n\n add_reset_rotate = lambda do\n add_box_array.call\n reset_and_rotate.call\n end\n\n 2.times {add_reset_rotate.call}\n add_box_array.call\n all_possible_arrays = (1..9).to_a.permutation.to_a\n\n # each row & each column is a unique permutation of base_array\n board.all?{ |row| all_possible_arrays.include?(row) } &&\n board.uniq.size == 9 &&\n board.transpose.all?{ |column| all_possible_arrays.include?(column) } &&\n board.transpose.uniq.size == 9 &&\n array_of_boxes.all? { |box| all_possible_arrays.include?(box) }\nend", "def sudoku_constraint(input)\n grid = grid_sub(input.split(''))\n grid = solve(grid)\nend", "def sudoku_constraint(input)\n grid = grid_sub(input.split(''))\n grid = solve(grid)\nend", "def step0(debug=false)\n\n # make sure we don't step beyond the solution\n return nil if done?\n\n t0 = Time.now\n @nb_iter += 1\n\n puts \"+++iteration #{@nb_iter}+++\" if debug\n puts \"nb problems = #{@pb_list.length}\" if debug\n\n best_pb = @pb_list.shift\n @rejected_grids.push(best_pb.grid)\n\n puts \"best problem:\" if debug\n puts best_pb.show_stats if debug\n\n if best_pb.min_depth == 1 then\n\n # we can create a problem with all the steps included at once\n new_steps = []\n best_pb.each_poss(1) do |poss|\n new_steps.push(Step.new(poss.row, poss.col, poss.first))\n end\n @nb_try += 1\n begin\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n rescue RuntimeError\n # the combination of depth=1 solution caused a conflict\n puts \"Impossible solution for best problem, discard it\" if debug\n @nb_discard += 1\n end\n else\n\n # we need to create a new problem for each possibility\n best_pb.each_poss(best_pb.min_depth) do |poss|\n poss.each do |v|\n @nb_try += 1\n new_steps = [Step.new(poss.row, poss.col, v)]\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n end\n end\n end\n\n # resort the list by max_poss / min_dof\n @pb_list.sort! do |x,y|\n res = x.max_poss <=> y.max_poss\n res = x.dof <=> y.dof if res == 0\n res\n end\n\n @duration += Time.now - t0\n\n #return the solution if we have one\n if @pb_list.empty? then\n return null\n else\n return @pb_list[0]\n end\n\n end", "def solve(puzzle, row, column = 0)\n return puzzle.flatten if column == 4\n return nil if permissible_values(puzzle, row, column).empty?\n p \"puzzle: #{puzzle}\"\n p \"row: #{row}\"\n p \"column: #{column}\"\n blank_puzzle.each { |i_in_row|\n i_in_row.each { |i_in_column|\n permissible_values(puzzle, i_in_row, i_in_column).map do |value|\n solve(update_puzzle(puzzle.dup, value, row, column), row, column + 1)\n end\n }\n }\nend", "def test_solve_sudoku\n assert_equal(false, @sudoku_1.sudoku_complete?(@sudoku_1))\n @sudoku_1.solve_sudoku(@sudoku_1)\n assert_equal(true, @sudoku_1.sudoku_complete?(@sudoku_1))\n end", "def validSolution(board)\n return false if board.flatten.size != 81\n return false if board.flatten.any? { |el| el.class != Fixnum }\n return false if board.size != 9\n board.each do |row|\n return false if row.any? { |el| el < 1 || el > 9 }\n return false if row.uniq.size != 9\n end\n (0..8).each do |col|\n this_col = []\n (0..8).each do |el|\n this_col << board[el][col]\n end\n return false if this_col.uniq.size != 9\n end\n [-1, 2, 5].each do |xoffset|\n [-1, 2, 5].each do |yoffset|\n this_square = []\n (1..3).each do |x|\n (1..3).each do |y|\n this_square << board[x + xoffset][y + yoffset]\n end\n end\n return false if this_square.uniq.size != 9\n end\n end\n true\nend", "def user_input(array, spaces, array2)\n loop do\n space = count_spaces(array, spaces)\n puts \"Enter the Element: \"\n element = gets.chomp.to_i\n puts \"Enter the Row: \"\n row = gets.chomp.to_i\n puts \"Enter the Column: \"\n column = gets.chomp.to_i\n check_user_input = validate_user_input(element, row, column)\n if check_user_input == 0\n puts \"Please Re-enter valid Number, Row, Column\"\n else\n flag_result = validate_number(array, element, row, column, spaces, array2)\n if flag_result == 0\n puts \"Number exists please Re-enter !!\"\n display(array)\n else\n display(array)\n end\n end\n puts \"Press Any Key to Continue: \"\n puts \"Press Q to Quit: \"\n quit = gets.chomp\n break if quit == \"Q\" || quit == \"q\"\n end\nend", "def double_whammer(sudoku_cells)\n\n # 1. obtain the lists of cells that still need a value\n # 2. for each cell in the list look for other cells\n # which are in the same row, column or subgrid\n # that has the same potential values\n # 3. if such cells are found, remove from other\n # cells all those values from them\n working_list = get_working_list(sudoku_cells)\n\n #Those that are of the same row/column/subgrid\n #check if any of them has the same potential values\n working_list.each do |cell_a|\n check_list = working_list.find_all do |cell_b| \n !cell_a.eql?(cell_b) && (cell_a.row == cell_b.row || cell_a.column == cell_b.column || cell_a.same_subgrid?(cell_b))\n end\n \n check_list.each do |cell|\n if cell_a.same_potential?(cell)\n #if the match is found on the same row\n if cell_a.row == cell.row\n sudoku_cells[cell_a.row].each do |x|\n if x.value.zero? && !x.eql?(cell_a) && !x.eql?(cell)\n cell_a.potential_value_stack.each {|v| x.potential_value_stack.delete(x)}\n end\n end\n elsif cell_a.column == cell.column\n i = 0\n until i >= sudoku_cells.size do\n cell_a.potential_value_stack.each do |v|\n if !sudoku_cells[i][cell_a.column].eql?(cell_a) && !sudoku_cells[i][cell_a.column].eql?(cell)\n sudoku_cells[i][cell_a.column].potential_value_stack.delete(v)\n end\n end\n i += 1\n end\n elsif cell_a.same_subgrid?(cell)\n cell_a.block_family.each do |indexes|\n if !sudoku_cells[indexes[0]][indexes[1]].eql?(cell_a) && !sudoku_cells[indexes[0][1]].eql?(cell)\n cell_a.potential_value_stack.each do |v|\n sudoku_cells[indexes[0]][indexes[1]].potential_value_stack.delete(v)\n end\n end\n end\n end\n end\n end\n end\n\n # working_list.each do |cell|\n # puts \"[#{cell.row}, #{cell.column}]\"\n # end\n # puts \"Working list: #{working_list.size}\"\n # binding.pry\nend", "def valid_sudoku(table)\n l = table.length\n # row, time l * l\n table.each do |row|\n return false if !sudoku_helper(row)\n end\n \n # column, time l * 2l\n l.times do |i|\n column = []\n l.times do |j|\n column << table[j][i]\n end\n return false if !sudoku_helper(column)\n end\n \n # area, time l * 2l\n x = Integer.sqrt(l)\n m = n = 0\n x.times do\n x.times do \n area = []\n x.times do |i|\n area += table[n + i][m...(m+x)]\n end\n return false if !sudoku_helper(area)\n m += x\n end\n n += x\n m = 0\n end\n return true\nend", "def validateBoard()\n #cycle through all lines in the file\n row = 0\n for row in 0..8\n # @gameboard index\n index = 0\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n while index<@DIMENSION\n if (1..9).member? @gameboard[row * @DIMENSION + index]\n if temp.include? @gameboard[row * @DIMENSION + index]\n return false\n else\n temp[i] = @gameboard[row * @DIMENSION + index]\n i += 1\n end\n end\n index += 1\n end\n end\n #cycle through all columns in the file\n column = 0\n for column in 0..8\n # @gameboard index\n index = 0\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n while index<@DIMENSION\n if (1..9).member? @gameboard[column + index * @DIMENSION]\n if temp.include? @gameboard[column+ index * @DIMENSION]\n return false\n else\n temp[i] = @gameboard[column+ index * @DIMENSION]\n i += 1\n end\n end\n index += 1\n end\n end\n #cycle through all @DEIMENSION squares in the file\n startIndex = 0\n rowBase = 0\n columnBase = 0\n for rowBase in 0..2\n startIndex = rowBase * 3 * @DIMENSION\n for columnBase in 0..2\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n #find the real index in @gameboard\n l = 0\n for l in 0..2\n m = 0\n for m in 0..2\n index = startIndex + m * @DIMENSION + l\n if (1..9).member? @gameboard[index]\n if temp.include? @gameboard[index]\n return false\n else\n temp[i] = @gameboard[index]\n i += 1\n end\n end\n end\n end\n startIndex += 3\n end\n end\n return true\nend", "def demoMethod\n\t\t@type = \"demoMethod\"\n\t\tif(@step==nil)\n\t\t\t@step = 0\n\t\t\tSudokuAPI.API.saveSudoku(\"old\");\n\t\t\tstatutMethod(true)\n\t\t\tgridDemo = \"375648129010925070200371000732089060000267000060034792020453917147896235953712648\"\n\t\t\tSudokuAPI.API.setSudoku(Sudoku.create(gridDemo),Sudoku.create(gridDemo),Sudoku.create(gridDemo));\n\t\t\tSudokuAPI.API.assistantMessage=(\"Bienvenue dans la démo (Appuyez sur Suivant)\");\n\t\telsif(@step==1)\n\t\t\tSudokuAPI.API.cazeAt(0,4).color=Colors::CL_NUMBER_LOCKED;\n\t\t\tSudokuAPI.API.cazeAt(2,4).color=Colors::CL_NUMBER_LOCKED;\n\t\t\tSudokuAPI.API.cazeAt(6,4).color=Colors::CL_HIGHLIGHT_METHOD;\n\t\t\tSudokuAPI.API.cazeAt(8,4).color=Colors::CL_HIGHLIGHT_METHOD;\n\t\t\tSudokuAPI.API.assistantMessage=(\"Les 2 candidats 4, alignés dans cette région (en rouge),\\n donnent la possibilité de supprimer les 4 dans les autres régions\\n de cette ligne (en gris)\");\n\t\telsif(@step==2)\n\t\t\tSudokuAPI.API.loadSudoku(\"old\");\n\t\t\tstatutMethod(false)\n\t\t\tSudokuAPI.API.assistantMessage=(\"Bonjour, je suis l'assistant, je suis là pour vous aider.\")\n\t\tend\n\t\t@step+=1\n\tend", "def validate(section)\n \n #Rows, Columns or Blocks\n #--------------------------------------------------\n section.each do |i|\n check = i.sort.join.squeeze(\"0\")\n if check.length > check.split(\"\").uniq.length\n\tputs \"***************************************************\"\n\tputs \"Failed Validation, Values did not meet sudoku rules\"\n\tputs \"***************************************************\"\n\treturn false\n end\n end \n \n #Return true if all validations passed\n #--------------------------------------------------\n return true\n end", "def sudoku_with_uniques(sudoku_with_options, grid_lines, grid_columns)\n (0..grid_size(grid_lines, grid_columns) - 1).to_a.each do |i|\n options = []\n sudoku_with_options[i].each { |array| options << array }\n options_hash = Hash.new(0)\n options.flatten.each { |j| options_hash[j] += 1 }\n uniques = []\n options_hash.each { |key, value| uniques << key if value == 1}\n uniques_hash = Hash.new\n uniques.each do |unique|\n sudoku_with_options[i].each_with_index do |array, index|\n uniques_hash[index] = unique if array.include?(unique)\n end\n end\n sudoku_with_uniques_i = []\n (0..grid_size(grid_lines, grid_columns) - 1).to_a.each do |j|\n uniques_hash[j].nil? ? sudoku_with_uniques_i << sudoku_with_options[i][j] : sudoku_with_uniques_i << [uniques_hash[j]]\n end\n sudoku_with_options[i] = sudoku_with_uniques_i\n end\n return sudoku_with_options\nend", "def solve\n\t\t\n\t\tcell_index = 0\n\t\t# move to the right position..\n\t\t# puts @unsolved.length.to_s + \" unknown cells!\"\n\n\t\twhile cell_index >= 0 && cell_index < @unsolved.length do\n\t\t\tcell = @unsolved[cell_index];\n\t\t\t\n\t\t\tpossible = cell.nextPossible()\t\n\n\t\t\tif possible > 9 || possible <= 0\n\t\t\t\tcell.set(0)\n\t\t\t\tcell_index -= 1\n\t\t\telse\n\t\t\t\tcell.set(possible)\n\t\t\t\tcell_index += 1\n\t\t\tend\t\t\t\t\t\t\t\n\t\tend\n\n\t\tif cell_index < 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend", "def solve\n fail 'invalid game given' unless @grid.valid?\n puts \"missing values #{@grid.missing}, filled #{@grid.filled}\"\n end", "def set_solution\n if @game_mode == 1\n @solution = @solution[0..3]\n else\n @solution = []\n puts \"Very Brave of you!\"\n puts \"Enter your combination. Don't worry the computer isn't looking.\"\n 4.times do |i|\n valid = false\n puts \"Enter position #{i + 1} \"\n position = gets.chomp.to_i\n until valid\n if @solution.include?(position)\n puts \"You already entered that number. Try again:\"\n position = gets.chomp.to_i\n elsif ((position > 6) || (position < 0))\n puts \"Enter a valid number:\"\n position = gets.chomp.to_i\n else\n @solution << position\n valid = true\n end\n end \n end\n \n end\n end", "def create_board\n\t@a1 = Cases.new(\"a1\", \" \") \n\t@a2 = Cases.new(\"a2\", \" \")\n\t@a3 = Cases.new(\"a3\", \" \")\n\t@b1 = Cases.new(\"b1\", \" \")\n\t@b2 = Cases.new(\"b2\", \" \")\n\t@b3 = Cases.new(\"b3\", \" \")\n\t@c1 = Cases.new(\"c1\", \" \")\n\t@c2 = Cases.new(\"c2\", \" \")\n\t@c3 = Cases.new(\"c3\", \" \")\n\n puts \" ________________________________________________________________________________________________________ \"\n puts \" | __ ___ __ ________ __ ________ ________ ___ ___ ________ | \"\n puts \" | l l l l l l l ______l l l l _____l l __ l l l l l l ______l | \"\n puts \" | l l l _ l l l l l__ l l l l l l l l l l l l l l__ | \"\n puts \" | l l_l l l l_l l l __l l l l l l l l l l l_l l_l l_l l l ___l | \"\n puts \" | l l l l l l_____ l l_____ l l_____ l l__l l l l l l l l l l_____ | \"\n puts \" | l___l l___l l________l l________l l________l l________l l__l l___l l__l l________l | \"\n puts \" |____________________________________________ TO ______________________________________________| \"\n puts \" | TIC TAC TOE | \"\n puts \" |_________________________________________________________________________________________________________| \"\n\n #On cree un Board et on definit ses 9 variables (voir Classe Board) comme etant la valeur de nos 9 cases, soit \" \"\n #on affiche un Board, qui sera vide\n #on cree un array avec toutes nos cases, qui sert a garder a jour les valeurs des cases au fur et a mesure de l'avancee du jeu\n\t@the_board = Board.new(@a1.position, @a2.position, @a3.position, @b1.position, @b2.position, @b3.position, @c1.position, @c2.position, @c3.position) \n\t@the_board.display \n\t@array = [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3] \n end", "def onSudokuMethod\n\t\t@type = \"onSudokuMethod\"\n\t\tif(@step==nil)\n\t\t\t@step = 0\n\t\t\tstatutMethod(true)\n\t\t\tSudokuAPI.API.assistantMessage=(\"Nous allons appliquer cette méthode sur la grille actuel \\n(cliquez sur suivant pour continuer)\");\n\t\telsif(@step==1)\n\t\t\t@compteur=0\n\t\t\t0.upto(8) do |region|\n\t\t\t\t1.upto(3) do |n|\n\t\t\t\t\ttraitementOnRow(region,1,n)\n\t\t\t\t\ttraitementOnRow(region,0,n)\n\t\t\t\tend\n\t\t\tend\n\t\t\tif(@cand!=nil)\n\t\t\t\tSudokuAPI.API.assistantMessage=(\"Le candidat \" + @cand.to_s + \" n'est présent que sur ces deux cases,\\n il est donc obligé de le placer ici.\");\n\t\t\telse\n\t\t\t\tSudokuAPI.API.assistantMessage=(\"Il n'est pas possible d'appliquer cette méthode sur la grille.\");\n\t\t\tend\n\t\telsif(@step==2)\n\t\t\tstatutMethod(false)\n\t\t\tSudokuAPI.API.resetColors()\n\t\t\tSudokuAPI.API.assistantMessage=(\"Bonjour, je suis l'assistant, je suis là pour vous aider.\")\n\t\tend\n\t\t@step+=1\n\tend", "def solve!\n\n until solved?\n\n\n @cell_array.each do |cell_object|\n cell_object.refresh_possible_values(@cell_array)\n if cell_object.value == 0 && cell_object.possible_values.length == 1\n cell_object.value = cell_object.possible_values[0]\n end\n end\n\n end\n\n board\n\n end", "def puzzle_game\n\t\t\tloop do\n\t\t\t\t#Set up deck and hand\n\t\t\t\tclear\n\t\t\t\tget_deck\n\t\t\t\tshuffle\n\t\t\t\tget_hand\n\n\t\t\t\t#Set up a single solution game\n\t\t\t\tsolution = find_set\n\t\t\t\tnext if (solution == [])\n\t\t\t\tsolution.each {|card_in_set| removed_card = @hand.delete(card_in_set); break if (find_set != []); @hand << removed_card}\n\t\t\t\tnext if @hand.length < 12\n\t\t\t\t@hand.shuffle!\n\n\t\t\t\t#Display message and ask user for input\n\t\t\t\tloop do\n\t\t\t\t\tshow_hand\n\t\t\t\t\tprint \"\\nEnter your set or type 'quit': \"\n\t\t\t\t\tcase user_input = gets.chomp.downcase.split(\",\")\n\t\t\t\t\twhen [\"quit\"]\n\t\t\t\t\t\tsystem('clear'); system('cls')\n\t\t\t\t\t\treturn\n\t\t\t\t\telse\n\t\t\t\t\t\tif good_set_syntax? user_input\n\t\t\t\t\t\t\t# safe to convert user input\n\t\t\t\t\t\t\tuser_input = user_input.map {|card| card.to_i}.sort\n\t\t\t\t\t\t\t# return user defined set in ascending card order\n\t\t\t\t\t\t\tif (user_input == solution.map {|card| @hand.find_index(card)}.sort)\n\t\t\t\t\t\t\t\tsystem('clear'); system('cls')\n\t\t\t\t\t\t\t\tshow_hand\n\t\t\t\t\t\t\t\tputs \"\\n#{user_input[0]},#{user_input[1]},#{user_input[2]}\\nGreat job! You found the only set.\\nHit enter to go back to main menu.\"\n\t\t\t\t\t\t\t\tgets\n\t\t\t\t\t\t\t\tsystem('clear'); system('cls')\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tsystem('clear'); system('cls')\n\t\t\t\t\t\t\tputs \"#{user_input[0]},#{user_input[1]},#{user_input[2]}\\nIncorrect set. There is only one soltuion. Try again.\",\"\"\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tsystem('clear'); system('cls')\n\t\t\t\t\t\t\tputs \"Invalid command or set syntax.\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tputs \"Error in execution.\"\n\t\t\t\tbreak\n\t\t\tend\n\t\tend", "def step(debug=false)\n\n # make sure we don't step beyond the solution\n return nil if done?\n\n t0 = Time.now\n @nb_iter += 1\n\n puts \"+++iteration #{@nb_iter}+++\" if debug\n puts \"nb problems = #{@pb_list.length}\" if debug\n\n best_pb = @pb_list.shift\n @rejected_grids.push(best_pb.grid)\n\n puts \"best problem:\" if debug\n puts best_pb.show_stats if debug\n\n if best_pb.min_depth == 1 then\n\n # we can create a problem with all the steps included at once\n new_steps = []\n best_pb.each_poss(1) do |poss|\n new_steps.push(Step.new(poss.row, poss.col, poss.first))\n end\n @nb_try += 1\n begin\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n rescue RuntimeError\n # the combination of depth=1 solution caused a conflict\n puts \"Impossible solution for best problem, discard it\" if debug\n @nb_discard += 1\n end\n else\n\n # we will just process the problem that reduce the most the possibilities\n # on its row, col and box\n poss_list = best_pb.sorted_poss { |x, y| x.min_poss <=> y.min_poss }\n poss = poss_list[0]\n poss.each do |v|\n @nb_try += 1\n new_steps = [Step.new(poss.row, poss.col, v)]\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n end\n end\n\n # resort the list by max_poss / min_dof\n @pb_list.sort! do |x,y|\n res = x.max_poss <=> y.max_poss\n res = x.dof <=> y.dof if res == 0\n res\n end\n\n @duration += Time.now - t0\n\n #return the solution if we have one\n if @pb_list.empty? then\n return nil\n else\n return @pb_list[0]\n end\n\n end", "def show\n \n $sudoku.grid.convert_to_grid(@solver.to_s)\n Timeout::timeout(5){$sudoku.solve_brute_force \n @solution = $sudoku.grid.to_s\n render 'show.html.erb'}\n rescue Timeout::Error\n @solution = 'Taking too much time' \n render 'show.html.erb' \n end", "def play\r\n\r\n # loop that runs until puzzle is solved\r\n b = Board.new\r\n\r\n b.populate_array(\"sudoku1.txt\")\r\n\r\n # inside loop:\r\n until b.solved?\r\n # clear screen\r\n system \"clear\"\r\n # ascii title splash\r\n b.splash \r\n # render board\r\n b.render\r\n # get position and value from the player, update position and value\r\n b.update_position\r\n end\r\n\r\n end", "def set_sudoku\n @sudoku = Sudoku.find(params[:id])\n end", "def sudoku2(grid)\n \n i = 0\n \n while i < grid.length\n hash = Hash.new(0)\n j = 0\n\n while j < grid[0].length\n hash[grid[i][j]] += 1\n return false if hash[grid[i][j]] > 1 && grid[i][j] != '.'\n j += 1\n end\n i += 1\n end\n\n i = 0\n\n while i < grid[0].length\n hash = Hash.new(0)\n j = 0\n\n while j < grid.length\n hash[grid[j][i]] += 1\n return false if hash[grid[j][i]] > 1 && grid[j][i] != '.'\n j += 1\n end\n i += 1\n end\n\n true && grid_builder(grid)\nend", "def validate\n\n entireSet = Set.new([1, 2, 3, 4, 5, 6, 7, 8, 9])\n\n @rows = []\n 9.times { @rows.push(entireSet.dup) }\n\n @cols = []\n 9.times { @cols.push(entireSet.dup) }\n\n @box = []\n 3.times do\n subrow = []\n 3.times { subrow.push(entireSet.dup) }\n @box.push(subrow)\n end\n\n (0..8).each do |i|\n (0..8).each do |j|\n v = @grid[i,j]\n if v > 0\n raise \"dup number in row #{i} : #{v}\" unless @rows[i].delete?(v)\n raise \"dup number in column #{j} : #{v}\" unless @cols[j].delete?(v)\n raise \"dup number in box #{i/3}-#{j/3} : #{v}\" unless @box[i/3][j/3].delete?(v)\n end\n end\n end\n\n @poss = []\n @poss_grid = []\n (0..8).each do |i|\n poss_row = []\n (0..8).each do |j|\n if @grid[i,j] == 0 then\n p = Poss.new(i, j, @rows[i], @cols[j], @box[i/3][j/3])\n @poss.push(p)\n poss_row.push(p.to_a)\n else\n poss_row.push([])\n end\n end\n @poss_grid.push(poss_row)\n end\n @poss.sort! { |x, y| x.length <=> y.length }\n\n end", "def help(game)\n\n game = game.game()\n\n #Algorithm for each columns\n (0...game.nCol).each do |i|\n\n cell = nil #reset\n nbTent = 0\n\n whiteZone = FindWhiteZone.find(game, 0, i)\n whiteZone.each do |zone| #Count the number of possible tent\n if (zone.size % 2 == 0)\n nbTent += (zone.size / 2)\n else\n nbTent += (zone.size / 2) + 1\n cell = zone.first #registered answer\n end\n end\n nbTent += Count.count(game, :tent, 0, i)\n\n if nbTent != game.colClues[i]\n break\n end\n\n if !(cell.nil?) #We find an answer\n return HelpAllPossibilitiesGiveItRow.new(cell, game.correction.cols[i], \"tent\")\n end\n\n end\n\n #Algorithm for each row\n (0...game.nRow).each do |i|\n\n cell = nil #reset\n nbTent = 0\n\n whiteZone = FindWhiteZone.find(game, 1, i)\n whiteZone.each do |zone| #Count the number of possible tents\n if (zone.size % 2 == 0)\n nbTent += (zone.size / 2)\n else\n nbTent += (zone.size / 2) + 1\n cell = zone.first #register answer\n end\n end\n nbTent += Count.count(game, :tent, 1, i)\n\n if nbTent == game.rowClues[i]\n\n if !(cell.nil?) #We find an answer\n return HelpAllPossibilitiesGiveItColumn.new(cell, game.correction.rows[i], \"tent\")\n end\n\n end\n end\n\n return HelpNotFound.new()\n\n end", "def solved?\n # Return whether the total passed in is equal to the total for a valid house.\n def is_valid_house_total?(total)\n return total == 45\n end\n\n # Return the total of adding up all the cells in this house.\n def house_total(house)\n return house.inject(0) {|sum, cell| sum + cell.to_i }\n end\n\n ## Check whether all the houses in the puzzle have valid totals.\n ##\n\n each_row do |row|\n return false unless is_valid_house_total?(house_total(row))\n end\n\n each_column do |column|\n return false unless is_valid_house_total?(house_total(column))\n end\n\n each_nonet do |nonet|\n return false unless is_valid_house_total?(house_total(nonet))\n end\n end", "def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend", "def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend", "def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend", "def move() \n if @used[0][1] == 0 \n @index_start1 = 0\n @index_start2 = 1\n boardSolver1st()\n elsif @used[0][2] == 0\n @index_start1 = 0\n @index_start2 = 2\n boardSolver1st()\n elsif @used[0][3] == 0\n @index_start1 = 0\n @index_start2 = 3\n boardSolver1st()\n elsif @used[0][4] == 0\n @index_start1 = 0\n @index_start2 = 4\n boardSolver1st()\n elsif @used[1][0] == 0\n @index_start1 = 1\n @index_start2 = 0\n boardSolver1st()\n elsif @used[1][1] == 0\n @index_start1 = 1\n @index_start2 = 1\n boardSolver1st()\n elsif @used[1][2] == 0\n @index_start1 = 1\n @index_start2 = 2\n boardSolver1st()\n elsif @used[1][3] == 0\n @index_start1 = 1\n @index_start2 = 3\n boardSolver1st()\n elsif @used[2][0] == 0\n @index_start1 = 2\n @index_start2 = 0\n boardSolver1st()\n elsif @used[2][1] == 0\n @index_start1 = 2\n @index_start2 = 1\n boardSolver1st()\n elsif @used[2][2] == 0\n @index_start1 = 2\n @index_start2 = 2\n boardSolver1st()\n elsif @used[2][3] == 0\n @index_start1 = 2\n @index_start2 = 3\n boardSolver1st()\n elsif @used[3][1] == 0\n @index_start1 = 3\n @index_start2 = 1\n boardSolver1st()\n elsif @used[3][2] == 0\n @index_start1 = 3\n @index_start2 = 2\n boardSolver1st()\n elsif @used[3][3] == 0\n @index_start1 = 3\n @index_start2 = 3\n boardSolver1st()\n else \n puts words()\n puts \"There are #{words().length} words! Play again\"\n end\n\nend", "def puzzle(sudoku)\n # this method is yours to implement\n puzzle_board = sudoku.dup\n (0..80).to_a.sample(rand(80)).each do |index|\n puzzle_board[index]= 0\n end\n return puzzle_board\n \nend", "def set_sudoku\n @sudoku = Sudoku.find(params[:id])\n end", "def handle_forks!\n fork_found = false\n @possibilities.each_with_index do |row, i|\n break if fork_found\n row.each_with_index do |cell, j|\n break if fork_found\n if @possibilities[i][j].length > 1\n fork_found = true\n solutions = @possibilities[i][j].map do |possibility|\n new_board = @board.map(&:clone)\n new_board[i][j] = possibility\n sudoku = Sudoku.new(new_board)\n sudoku.solve!\n @solutions += sudoku.solutions unless sudoku.status == :impossible\n end\n end\n end\n end\n end", "def solve(arr = @input_arr)\n number_array = NumberArray.new\n pos = number_array.first_free_position arr\n # sudoku is solved, there are no free spaces in output_arr\n return arr unless pos\n ('1'..'9').each do |num|\n arr[pos] = num\n next unless number_array.valid_sudoku? pos, arr\n temp_sol = solve arr.dup\n return temp_sol if temp_sol\n end\n false\n end", "def solution_checker(array)\n if array.length > 1\n # Create a board that can be manipulated without affecting the original board\n internal_board = []\n column_counter = 1\n row_counter = 1\n 4.times do\n 4.times do\n internal_board.push(Square.new([column_counter, row_counter]))\n column_counter = column_counter + 1\n end\n row_counter = row_counter + 1\n column_counter = 1\n end\n #Label squares on the board as occupied\n array.each do |piece|\n square = internal_board.find {|s| s.location == piece.location}\n square.occupied = true\n square.piece = piece\n end\n array.each_with_index do |piece, index|\n if array.include?(piece) && piece != array.last\n original_square = internal_board.find {|s| s.location == piece.location}\n blocker = piece.impediments?([(array[index + 1]).column, (array[index + 1]).row], internal_board)\n if blocker\n break\n elsif piece.move([(array[index + 1]).column, (array[index + 1]).row])\n captured_piece = array[index + 1]\n array.uniq!{|piece| piece.location}\n original_square.occupied = false\n original_square.piece = nil\n new_moves = array.permutation.to_a\n new_moves.each do |new_array|\n new_array.map {|a| a.dup}\n end\n new_moves.each do |new_array|\n solution_checker(array)\n end\n else\n break\n end\n else\n break\n end\n end\n end\nend", "def puzzle(sudoku,removed_cells=20)\n # this method is yours to implement\n random = (0..81).to_a.sample(removed_cells)\n @puzzled = []\n sudoku.each_with_index do |element,index|\n if random.include?(index) then @puzzled.push(0)\n else @puzzled.push(element) end\n end\n @puzzled\n # random.each { |index| sudoku[index] = 0 }\n # sudoku\nend", "def solve(board_string)\n # Get location of empty cell\n position = board_string.index(\"-\")\n return board_string if position == nil\n # Figure out which potential numbers can go into empty cell\n possible_numbers = checker(position, board_string)\n # For each potential number...\n possible_numbers.each do |number|\n # Fill in current cell with potential number\n board_string[position] = number.to_s\n # Call solve method on that modified board\n puts pretty_board(board_string)\n sleep(0.01)\n output = solve(board_string)\n # If board is solved, return solved board\n return output if solved?(output)\n end\n board_string[position] = \"-\"\n return board_string\nend", "def index\n @sudokus = Sudoku.all\n end", "def onSudokuMethod\n\t\traise \"Ceci est une methode abstraite. This is an abstact method.\";\n\tend", "def solution_board\n @maker_row = [\"?\", \"?\", \"?\", \"?\"]\n puts \" \"\n puts \"| \" + \"#{@maker_row[0..3].join(\" | \")}\" + \" | --> The hidden solution!\"\n puts \" \"\n end", "def guessing_method\n smallest_num_of_possibilities = 9\n\n loop_board do |cell|\n smallest_num_of_possibilities = cell.possibilities.length if cell.possibilities.length < smallest_num_of_possibilities && cell.content.is_a?(Array)\n end\n\n loop_board do |cell|\n if cell.possibilities.length == smallest_num_of_possibilities\n cell.possibilities.each do |guess_value|\n\n guessing_board_copy = Marshal.load(Marshal.dump(self))\n guessing_board_copy.full_board[cell.tri_square_index][cell.square_index][cell.tri_cell_index][cell.cell_index].content = guess_value\n guessing_board_copy.full_board[cell.tri_square_index][cell.square_index][cell.tri_cell_index][cell.cell_index].possibilities = []\n\n if guessing_board_copy.solve!\n self.full_board = guessing_board_copy.full_board\n return guessing_board_copy\n end\n end\n return false\n end\n end\n end", "def valid_sudoku(table)\n # seen_set = Set.new()\n # for i in \nend", "def get_puzzle_grid(level)\n\n #get a random grid\n page = Net::HTTP.get_response(\"show.websudoku.com\", \"?select&level=#{level}\")\n\n #find the puzzle number for reference\n page.body =~ /Puzzle (.*?) /\n puzzle_id = $1\n\n #the puzzle is in a giant table\n page.body =~ /<TABLE .*?>(.*)?<\\/TABLE>/\n table = $1\n\n # each cell has ID=cxy where x is column, y is row\n grid = []\n (0..8).each do |r|\n row = []\n (0..8).each do |c|\n table =~ /<TD CLASS=.. ID=c#{c}#{r}>(.*?)<\\/TD>/\n cell = $1\n cell =~ /READONLY VALUE=\"(\\d)\"/\n if cell\n row.push($1.to_i)\n else\n row.push(0)\n end\n end\n grid.push(row)\n end\n\n return grid\nend" ]
[ "0.765487", "0.7586966", "0.73946303", "0.7381409", "0.7256992", "0.71871614", "0.7110504", "0.7104196", "0.7091132", "0.7065601", "0.70635486", "0.7026126", "0.6937003", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.6864549", "0.6855605", "0.6794585", "0.6732119", "0.6673419", "0.6598203", "0.65856713", "0.6532293", "0.64645797", "0.64091116", "0.6370614", "0.63645035", "0.6349204", "0.6325375", "0.63072264", "0.63059", "0.6254303", "0.62446976", "0.6225294", "0.61975545", "0.61975545", "0.6197067", "0.61965865", "0.61871344", "0.6172191", "0.6171601", "0.6153121", "0.6132076", "0.6126151", "0.61253923", "0.61251426", "0.6084922", "0.60223764", "0.6020319", "0.60194457", "0.6004722", "0.59909207", "0.59895825", "0.5980914", "0.5974755", "0.59729815", "0.594525", "0.5936234", "0.5931221", "0.5923995", "0.58942485", "0.589421", "0.5892148", "0.5892148", "0.5892148", "0.58876485", "0.58638585", "0.58615166", "0.5855755", "0.5855713", "0.5851496", "0.58398694", "0.5837362", "0.5830921", "0.5827584", "0.58040833", "0.58037037", "0.57981026", "0.57893" ]
0.7352753
4
GET /portal/learners GET /portal/learners.xml
def index @portal_learners = Portal::Learner.search(params[:search], params[:page], nil) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @portal_learners } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @learners = Learner.all\n end", "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def index\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n # PUNDIT_REVIEW_SCOPE\n # PUNDIT_CHECK_SCOPE (did not find instance)\n # @learners = policy_scope(Portal::Learner)\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def new\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def set_learner\n @learner = Learner.find(params[:id])\n end", "def create\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def multiple_choice_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def external_report_learners_from_jwt\n authorize Portal::PermissionForm\n\n # Empty hashes and arrays are removed from param list now\n # see: https://github.com/rails/rails/issues/26569\n query = params[\"query\"] || {}\n page_size = params[\"page_size\"].to_i\n search_after = params[\"search_after\"] || nil\n endpoint_only = params[\"endpoint_only\"] || false\n\n if (page_size == nil || page_size < 1)\n return error \"param page_size must be a positive number\", 400\n elsif (page_size > 5000)\n return error \"param page_size may not be larger than 5000\", 400\n end\n\n query[:size_limit] = page_size\n\n learners = []\n # endpoint_only doesn't include all the learner data, just the remote endpoint.\n # should result in a faster response. Used for learner logs usually.\n if endpoint_only\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :endpoint_only,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map do |l|\n {\n learner_id: l.learner_id,\n run_remote_endpoint: l.remote_endpoint_url,\n runnable_url: l.runnable_url\n }\n end\n # Response should include learner metadata (names, schools, email ...)\n else\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :elasticsearch,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map {|l| self.class.detailed_learner_info l}\n end\n response = {\n json: {\n version: \"1\",\n learners: learners,\n lastHitSortValue: learner_selector.last_hit_sort_value\n }\n }\n render json: response.to_json\n end", "def create\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def open_response_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def show\n @learner = @activity.find_or_create_learner(current_user)\n respond_to do |format|\n# format.html { render :layout => 'layouts/show_activity' } # show.rhtml\n format.html # show.rhtml\n format.xml { render :xml => @activity.to_xml }\n end\n end", "def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n @portal_learner.periodic_bundle_logger = Dataservice::PeriodicBundleLogger.create!(:learner_id => @portal_learner.id) unless @portal_learner.periodic_bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render_learner_jnlp @portal_learner }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n bundle_get_url = dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle)\n if @portal_learner.student.user == current_visitor\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n if current_settings.use_periodic_bundle_uploading?\n bundle_get_url = dataservice_periodic_bundle_logger_url(@portal_learner.periodic_bundle_logger, :format => :bundle)\n bundle_post_url = nil\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => bundle_get_url,\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\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 potential_service_learners\n service_learning_courses.collect(&:enrollees)\n end", "def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @partners.to_xml }\n end\n end", "def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def show\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render :partial => 'shared/learn',\n :locals => { :runnable => @portal_learner.offering.runnable, :learner => @portal_learner } }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n if @portal_learner.student.user == current_user\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle),\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def destroy\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def show\n @researcher = Researcher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def update\n @portal_learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n if @portal_learner.update_attributes(params[:learner])\n flash[:notice] = 'Portal::Learner was successfully updated.'\n format.html { redirect_to(@portal_learner) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bundle_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def learn_url\n \"http://learn.uwaterloo.ca\"\n end", "def index\n @teachers = Teacher.search @year_selected, @degree_selected\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teachers }\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 @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 @wrestlers = Wrestler.all\n end", "def tournaments\n get('sports/en/tournaments.xml')\n end", "def index\n @leks = Lek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leks }\n end\n end", "def index\n @partners = Partner.all\n end", "def index\n @leaders = Leader.all\n @leadership_report = LeadershipReport.new\n @outreach_report = OutreachReport.new\n end", "def show\n @installation = Installation.find(params[:installation_id]) \n @offpost = Offpost.find(params[:id])\n @learn = @offpost.learns\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offpost }\n end\n end", "def download_people_data\n print \"Getting IDs of articles about people...\\n\"\n PeopleGetter.new([MEN_URL, WOMEN_URL]).result\n end", "def index\n @roles = @client.roles\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end", "def index\n @reviewers = Reviewer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reviewers }\n end\n end", "def show\n @portal_clazz = Portal::Clazz.find(params[:id], :include => [:teachers, { :offerings => [:learners, :open_responses, :multiple_choices] }])\n @portal_clazz.refresh_saveable_response_objects\n @teacher = @portal_clazz.parent\n @offerings = substitute_default_class_offerings(@portal_clazz.active_offerings)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @portal_clazz }\n end\n end", "def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def gererateLacpLearnedInfoView ( viewName )\r\n viewCaption = viewName\r\n protocol = 'LACP'\r\n drillDownType = 'Global Learned Info'\r\n root = @ixNet.getRoot()\r\n statistics = root + '/statistics'\r\n statsViewList = @ixNet.getList(statistics, 'view')\r\n\r\n # Add a StatsView\r\n view = @ixNet.add(statistics, 'view')\r\n @ixNet.setAttribute(view, '-caption', viewCaption)\r\n @ixNet.setAttribute(view, '-type', 'layer23NextGenProtocol')\r\n @ixNet.setAttribute(view, '-visible', 'true')\r\n @ixNet.commit()\r\n view = @ixNet.remapIds(view)[0]\r\n\r\n # Set Filters\r\n trackingFilter = @ixNet.add(view, 'advancedCVFilters')\r\n @ixNet.setAttribute(trackingFilter, '-protocol', protocol)\r\n @ixNet.commit()\r\n #ixNet getAttr $trackingFilter -availableGroupingOptions\r\n @ixNet.setAttribute(trackingFilter, '-grouping', drillDownType)\r\n @ixNet.commit()\r\n layer23NextGenProtocolFilter = view + '/' + 'layer23NextGenProtocolFilter'\r\n @ixNet.setAttribute(layer23NextGenProtocolFilter, '-advancedCVFilter', trackingFilter)\r\n @ixNet.commit()\r\n\r\n # Enable Stats Columns to be displayed\r\n statsList = @ixNet.getList(view, 'statistic')\r\n for stat in statsList\r\n @ixNet.setAttribute(stat, '-enabled', 'true')\r\n end\r\n @ixNet.commit()\r\n\r\n # Enable Statsview\r\n @ixNet.setAttribute(view, '-enabled', 'true')\r\n @ixNet.commit()\r\nend", "def index\n @enrollements = Enrollement.all\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 @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 @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 teachers\n if current_user.is_admin?\n @teachers= User.find(:all, :conditions => \"is_teacher = '1' and is_admin = '0'\")\n respond_to do |format|\n format.xml { render :xml => @teachers }\n end\n else\n respond_to do |format|\n format.xml { render :text => \"error\" }\n end\n end\n end", "def show\n @reviewer = Reviewer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @reviewer }\n end\n end", "def index\n @clients = Client.all\n @lawyers = Lawyer.all\n end", "def show\n @offlearn = Offlearn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offlearn }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end", "def setup_portal_student\n learner = nil\n if current_user\n portal_student = current_user.portal_student\n # create a learner for the user if one doesn't exist\n learner = @offering.find_or_create_learner(portal_student)\n end\n learner\n end", "def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n end\n \n respond_to do |format|\n format.json { render json: entities }\n end\n end", "def index\n @partners = Partner.order(id: :desc).page(params[:page]).per(25)\n end", "def index\n @learn_articles = LearnArticle.all\n end", "def index\n @question_learneds = QuestionLearned.all\n end", "def me\n users(request(\"users/authenticate.xml\", :auth => true))\n end", "def bundle_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def index\n @remission_guides = RemissionGuide.all\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def index\n @referrals = Referral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @referrals }\n end\n end", "def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend", "def index\n @referral_enrolments = ReferralEnrolment.all\n end", "def index\n @learning_resources = @language.learning_resources\n end", "def show\n @research = Research.find(params[:id])\n @page_title = \"Hello Congress research request: \" + @research.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def index\n @relatories = Relatory.all\n end", "def index\n @guides = Guide.all\n #@guide = Guide.find(params[:guide]) rescue nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @guides }\n end\n end", "def get_user_leads username, password, options = {}\n do_request 'get_user_leads', options.merge(username: username, password: password)\n end", "def index\n @researchers = Researcher.all\n end", "def show\n @lr40 = Lr40.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr40 }\n end\n end", "def index\n @story_tellers = StoryTeller.all\n end", "def new\n @wrestler = Wrestler.new\n @teams = Team.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def get_doctor\n puts \"Which Doctor would you like more information about?\"\n Scrape.scrape_doctor\n end", "def index\n @tutors = Tutor.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tutors }\n end\n end", "def index\n @subjects = @client.subjects\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subjects }\n end\n end", "def new\n @reviewer = Reviewer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reviewer }\n end\n end", "def show\n @wrestler = Wrestler.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def index\r\n @legers = Leger.all\r\n\r\n end", "def index\n @borrower_residences = BorrowerResidence.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @borrower_residences.to_xml }\n end\n end", "def index\n @teachers = Teacher.all\n end", "def index\n @teachers = Teacher.all\n end", "def index\n @teachers = Teacher.all\n end", "def index\n @teachers = Teacher.all\n end", "def index\n @teachers = Teacher.all\n end", "def show\n @teacher = Teacher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def show\n @teacher = Teacher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def show\n @teacher = Teacher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def show\n @announcer = Announcer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @announcer }\n end\n end", "def destroy\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def index\n @leaderships = Leadership.all\n end", "def index\n @realtors = Realtor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @realtors }\n end\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def show\n @offering = Portal::Offering.find(params[:id])\n authorize @offering\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offering }\n\n format.run_html {\n @learner = setup_portal_student\n render :show, :layout => \"layouts/run\"\n }\n\n format.run_resource_html {\n if learner = setup_portal_student\n learner.update_last_run\n cookies[:save_path] = @offering.runnable.save_path\n cookies[:learner_id] = learner.id\n cookies[:student_name] = \"#{current_visitor.first_name} #{current_visitor.last_name}\"\n cookies[:activity_name] = @offering.runnable.name\n cookies[:class_id] = learner.offering.clazz.id\n cookies[:student_id] = learner.student.id\n cookies[:runnable_id] = @offering.runnable.id\n else\n # session[:put_path] = nil\n end\n external_activity = @offering.runnable\n if external_activity.lara_activity_or_sequence?\n uri = URI.parse(external_activity.url)\n uri.query = {\n :externalId => learner.id,\n :returnUrl => learner.remote_endpoint_url,\n :logging => @offering.clazz.logging || @offering.runnable.logging,\n :domain => root_url,\n :domain_uid => current_visitor.id,\n :class_info_url => @offering.clazz.class_info_url(request.protocol, request.host_with_port),\n :context_id => @offering.clazz.class_hash,\n # platform_id and platform_user_id are similiar to domain and domain_uid.\n # However, LARA uses domain and domain_uid to authenticate the user,\n # while the platform params are moving towards LTI compatible launching\n # More specifically LARA removes domain and domain_uid from URL,\n # so it is harder to use the domain params to setup the run in LARA.\n :platform_id => APP_CONFIG[:site_url],\n :platform_user_id => current_visitor.id,\n :resource_link_id => @offering.id\n }.to_query\n redirect_to(uri.to_s)\n else\n redirect_to(@offering.runnable.url(learner, root_url))\n end\n }\n end\n end", "def show\n @adults_howyouknowu = AdultsHowyouknowu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @adults_howyouknowu }\n end\n end", "def show\n @laborer = Laborer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @laborer }\n end\n end", "def index\n @advances = user_capabilities(Advance).current_advances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advances }\n end\n end", "def allergies\n raise UserNotAuthenticated unless access_token\n\n get('records/allergies')\n end", "def external_report_query_jwt\n authorize Portal::PermissionForm\n\n response = {\n token: SignedJWT::create_portal_token(current_user, {}, 3600), # just sets uid\n json: {\n query: params,\n type: \"learners\",\n version: \"2\",\n user: {\n id: url_for(current_user),\n email: current_user.email\n },\n portal_url: root_url,\n learnersApiUrl: external_report_learners_from_jwt_api_v1_report_learners_es_url\n }\n }\n\n render json: response.to_json\n end", "def external_report_query\n authorize Portal::PermissionForm\n\n # Note that Report::Learner::Selector is a little helper that actually calls\n # API::V1::ReportLearnersEsController.query_es.\n learner_selector = Report::Learner::Selector.new(params, current_user, { learner_type: :elasticsearch })\n # In the future, we might want to extend this query format and add other filters, e.g. dates.\n response = {\n type: \"learners\",\n version: \"1.1\",\n learners: learner_selector.es_learners.map do |l|\n {\n run_remote_endpoint: l.remote_endpoint_url,\n class_id: l.class_id,\n runnable_url: l.runnable_url\n }\n end,\n user: {\n id: url_for(current_user),\n email: current_user.email\n }\n }\n # Note that we're not generating JWT. We're only signing generated query JSON, so the external report can verify\n # that it's coming from the Portal and it hasn't been modified on the way. The external report app needs to know\n # hmac_secret to verify query and signature.\n signature = OpenSSL::HMAC.hexdigest(\"SHA256\", SignedJWT.hmac_secret, response.to_json)\n render json: {\n json: response,\n signature: signature\n }.to_json\n end", "def index\n\t\trelators\n\tend", "def index\n @attorneys = Attorney.all\n end" ]
[ "0.6887659", "0.6740972", "0.6546517", "0.6353626", "0.6158483", "0.60948175", "0.5989694", "0.5976165", "0.5920067", "0.585862", "0.58358645", "0.58119965", "0.57782644", "0.5743717", "0.57227707", "0.57206905", "0.5714451", "0.5702505", "0.56483495", "0.56342185", "0.55877984", "0.55638885", "0.5549649", "0.5538341", "0.55069435", "0.5496222", "0.54941034", "0.54927075", "0.54613817", "0.54547185", "0.5449685", "0.5429858", "0.53984976", "0.5366054", "0.5364597", "0.53601485", "0.5349708", "0.53408027", "0.5338665", "0.5333782", "0.5330819", "0.5314002", "0.53130645", "0.5312327", "0.5312025", "0.5307812", "0.5301543", "0.52992916", "0.52992916", "0.5298746", "0.5296682", "0.52948153", "0.5281324", "0.5272965", "0.5265268", "0.5257769", "0.52510715", "0.52448785", "0.5238055", "0.5232968", "0.522574", "0.5224676", "0.52197516", "0.5218546", "0.5217116", "0.5215016", "0.5214792", "0.5211537", "0.52110964", "0.52099854", "0.5193889", "0.51827776", "0.51801527", "0.5172973", "0.5167003", "0.5162762", "0.51548856", "0.5125067", "0.511943", "0.511943", "0.511943", "0.511943", "0.511943", "0.5119214", "0.5119214", "0.5119214", "0.5105349", "0.51018363", "0.51014405", "0.5091022", "0.5089219", "0.508887", "0.5086604", "0.5082641", "0.50823456", "0.50731266", "0.5069205", "0.50645614", "0.50633734", "0.50592065" ]
0.703121
0
GET /portal/learners/1/open_response_report GET /portal/learners/1/open_response_report.xml
def open_response_report @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| format.html # report.html.haml end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def http_report(request, _response)\n path = request.path\n\n root_element_name = Box.new('')\n result = @server.xml.parse(request.body, request.url, root_element_name)\n root_element_name = root_element_name.value\n\n if @server.emit('report', [root_element_name, result, path])\n # If emit returned true, it means the report was not supported\n fail Exception::ReportNotSupported\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end", "def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end", "def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def multiple_choice_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end", "def download_report(name, request_time, format)\n response = @client.get('arborws/reports/configured',\n api_key: @api_key, name: name,\n request_time: request_time, format: format)\n\n response\n end", "def report\n offering_id = params[:id]\n activity_id = params[:activity_id] # Might be null\n offering = Portal::Offering.find(offering_id)\n authorize offering\n report = DefaultReportService::default_report_for_offering(offering)\n raise ActionController::RoutingError.new('Default Report Not Found') unless report\n next_url = report.url_for_offering(offering, current_visitor, request.protocol, request.host_with_port, { activity_id: activity_id })\n redirect_to next_url\n end", "def bundle_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def get_report(id_or_name, options={})\n request_params = options.inject({}) do |params, (key, val)|\n xero_key = key.to_s.camelize.gsub(/id/i, \"ID\").to_sym\n params[xero_key] = val\n params\n end\n response_xml = http_get(@client, \"#{@xero_url}/reports/#{id_or_name}\", request_params)\n parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/reports'})\n end", "def get(options = {})\n @response_xml = options[:cache_file] ? File.read(options[:cache_file]) : http_get(options)\n response = Response.parse(response_xml, options) do | inner_response, elements |\n parse_reports(inner_response, elements)\n end\n response.response_items.first # there is is only one\n end", "def show\n @comparative_report = ComparativeReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @comparative_report }\n end\n end", "def external_report_query\n authorize Portal::PermissionForm\n\n # Note that Report::Learner::Selector is a little helper that actually calls\n # API::V1::ReportLearnersEsController.query_es.\n learner_selector = Report::Learner::Selector.new(params, current_user, { learner_type: :elasticsearch })\n # In the future, we might want to extend this query format and add other filters, e.g. dates.\n response = {\n type: \"learners\",\n version: \"1.1\",\n learners: learner_selector.es_learners.map do |l|\n {\n run_remote_endpoint: l.remote_endpoint_url,\n class_id: l.class_id,\n runnable_url: l.runnable_url\n }\n end,\n user: {\n id: url_for(current_user),\n email: current_user.email\n }\n }\n # Note that we're not generating JWT. We're only signing generated query JSON, so the external report can verify\n # that it's coming from the Portal and it hasn't been modified on the way. The external report app needs to know\n # hmac_secret to verify query and signature.\n signature = OpenSSL::HMAC.hexdigest(\"SHA256\", SignedJWT.hmac_secret, response.to_json)\n render json: {\n json: response,\n signature: signature\n }.to_json\n end", "def connect(report_path = \"\")\n response = nil\n\n # Open a connection to the url\n URI.open(url(report_path)) do |f|\n # Query the status of the API Call\n status = f.status[0]\n\n # Only allow successful API Calls\n if status != \"200\"\n raise \"Bad Status: \" + status\n end\n\n # Read the document into the response\n response = f.read\n end\n\n # Parse the result with Nokogiri\n @document = Nokogiri::XML(response)\n\n # Remove namespaces before parsing\n @document.remove_namespaces!\n\n # Pull out the resumption token and the indicator for last page\n resumption_token = @document.xpath('//ResumptionToken').first.content rescue \"\"\n is_finished = @document.xpath('//IsFinished').first.content rescue \"\"\n\n # Return the token value and the finished flag\n {\n token: resumption_token,\n is_finished: is_finished\n }\n end", "def get_report_list\n res=api_call('GetReportList')[:data]\n end", "def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end", "def index\n if params[:external_otrunk_activity_id]\n @reports = ExternalOtrunkActivity.find(params[:external_otrunk_activity_id]).reports\n else\n @reports = Report.search(params[:search], params[:page], current_user)\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end", "def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def test_downloadXmlReport\n report_srv = @adwords.get_service(13, 'Report')\n\n # First we schedule a report\n job = AdWords::V13::ReportService::DefinedReportJob.new\n job.selectedReportType = 'Structure'\n job.aggregationTypes = 'Keyword'\n job.name = 'Report-%s' % DateTime.now.to_s\n job.selectedColumns = %w{Campaign AdGroup Keyword KeywordTypeDisplay}\n job.startDay = '2009-01-01'\n job.endDay = '2009-01-31'\n job_id = report_srv.scheduleReportJob(job).scheduleReportJobReturn\n\n # Now we use the downloadXmlReport method to download it\n report_data = report_srv.downloadXmlReport(job_id)\n\n # See if we got anything back\n assert((!report_data.nil? and !report_data.strip.empty?),\n 'Empty report returned; unable to verify correctness')\n\n # Check if we received valid XML as a reply\n doc = REXML::Document.new(report_data)\n\n # See if what we got back was XML, as we expected\n assert_not_nil(doc, 'Invalid XML returned; unable to verify correctness')\n end", "def url_report(resource) # resource: scan_id or url\n merged_options = options.merge!({ resource: resource })\n response = RestClient.post endpoint(\"/url/report\"), merged_options\n parse_response(response)\n end", "def show\n @report = Report.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def show\n @user_reports = UserReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_reports }\n end\n end", "def request_active_report\n begin\n #both of these return some info include the report request id..\n @active_report = @client.request_report(\"_GET_MERCHANT_LISTINGS_DATA_\").parse\n\n rescue Excon::Errors::ServiceUnavailable\n puts \"the active report had an issue\"\n sleep 2 and retry\n \n else\n puts \"The active report was requested fine\"\n end\n \n if @difference < 1800\n find_report_status_just_active\n end\n \n end", "def show\n @dailyreport = Dailyreport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dailyreport }\n end\n end", "def show\n @report = Report.find(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def index\n @help_offers = @job_request.help_offers\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @help_offers }\n end\n end", "def rights_overview\n\t\t@survey = Survey.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html \n\t\t\tformat.xml { render :xml => @survey }\n\t\tend\n\tend", "def show\n @report = Mg::Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def show\n @software_report = SoftwareReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @software_report }\n end\n end", "def new\n @dailyreport = Dailyreport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dailyreport }\n end\n end", "def show\n @lr70 = Lr70.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr70 }\n end\n end", "def new\n @comparative_report = ComparativeReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comparative_report }\n end\n end", "def disp_xml_rq\n body= File.open(\"public/OTA/OTA_HotelAvailRQ100.xml\").read\n render :xml => body\n end", "def url_report(url)\n URLReport.new(api_key: @api_key, resource: url).response\n end", "def report(id)\n get(\"reports/#{id}\")\n end", "def report(object)\n full_name = extract_full_name object\n post 'api/report', :id => full_name\n end", "def show\n @report_line = ReportLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_line }\n end\n end", "def new\n @report = Mg::Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end", "def new\n @user_report = UserReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_report }\n end\n end", "def fetch_report\n\t\t\t\tbegin\n\t\t\t\t\treport = fetch(\"#{Middlecoin::MIDDLECOIN_URL}/json\")\n\t\t\t\t\t@report = JSON.parse(report.body)[\"report\"]\n\t\t\t\trescue => e\n\t\t\t\t\traise Middlecoin::MiddlecoinAPIError, \"Unable to collect JSON report from middlecoin.com\"\n\t\t\t\tend\n\t\t\tend", "def new\n @software_report = SoftwareReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software_report }\n end\n end", "def new\n @report_line = ReportLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_line }\n end\n end", "def get_response_url\n\tdoc = Nokogiri::HTML(open(lease_break_url))\nend", "def show\n @tps_report = TpsReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tps_report }\n end\n end", "def show\n @offlearn = Offlearn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offlearn }\n end\n end", "def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end", "def new\n @report2 = Report2.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report2 }\n end\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def show\n @inpatientdailyreport = Inpatientdailyreport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @inpatientdailyreport }\n end\n end", "def new\n @inpatientdailyreport = Inpatientdailyreport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @inpatientdailyreport }\n end\n end", "def show\n @service_report = ServiceReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_report }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_type }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_type }\n end\n end", "def fetch_report_page \n @report_page = client.get(REPORT_URL)\n dump(client, @report_page)\n \n @ajax_id = get_ajax_id(@report_page)\n @report_page\n end", "def new\n \n #@neuotransmitter_report = NeuotransmitterReport.new\n # LDN_report = Nokogiri::XML(open(\"LDN_neurotransmitter_report\"))\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neuotransmitter_report }\n end\n end", "def xml_report\n @xml_report ||= parse\n end", "def new\n @tps_report = TpsReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tps_report }\n end\n end", "def new\n @user_reports = UserReport.new(params[:user_report])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_reports }\n end\n end", "def index\n @responses = @survey.responses.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @responses }\n end\n end", "def get_report(report_id, params = {})\n response = get(\"/\", {\"Action\" => \"GetReport\", \"ReportId\" => report_id})\n # TODO format response\n end", "def index\n @action_reports = ActionReport.all\n end", "def getSalesReport(year, month)\n #url = sprintf('https://market.android.com/publish/salesreport/download?report_date=%04d_%02d', year, month)\n url = sprintf('https://play.google.com/apps/publish/salesreport/download?report_date=%04d_%02d&report_type=payout_report&dev_acc=%s', year, month, @dev_acc)\n try_get(url)\n return @agent.page.body\n end", "def show\n respond_to do |format|\n response.headers['Content-Length'] = @pod_report.size.to_s\n format.xls { send_file(Rails.root.join(\"public/reports/#{@pod_report.filename}\"), filename: @pod_report.filename) }\n end\n end", "def getTokenReport( entity_id, portal_name, language, flatpack_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['portal_name'] = portal_name\n params['language'] = language\n params['flatpack_id'] = flatpack_id\n return doCurl(\"get\",\"/token/report\",params)\n end", "def make_request_get_response_trend_availible\n @path_trend_availible = '/1.1/trends/available.json'\n @address_trend_availible = URI(\"#{@baseurl}#{@path_trend_availible}\")\n # Set up HTTP. Need ssL to make the connection\n @request_trend_availible = Net::HTTP::Get.new @address_trend_availible.request_uri\n @http = Net::HTTP.new @address_trend_availible.host, @address_trend_availible.port\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n # Issue the request.\n @request_trend_availible.oauth! @http, @consumer_key_country, @access_token_country\n @http.start\n @response_trend_availible = @http.request @request_trend_availible\n @response_trend_availible\n end", "def offense_report(label = 'Attackers:')\n status_report(\n name: label,\n items: @attackers,\n item_text: lambda { |item| item.list_name num_id_cols: @attackers.size.to_s.size }\n )\nend", "def show\n @response = Response.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @response }\n end\n end", "def show\n @user_report = UserReport.find(params[:id])\n\n respond_to do |format|\n format.html # edit.html.erb\n format.xml { render :xml => @user_report }\n end\n end", "def perform_search(report_name, params = {})\n begin\n # additional report params \n params.merge!({\"rs:Command\" => \"Render\", \"rs:format\" => \"XML\"})\n \n LOG.info(\"[EdwAdapter] url: #{config[:url]}\")\n LOG.info(\"[EdwAdapter] report: #{report_name}, params: #{params.inspect}\")\n\n req = Net::HTTP::Get.new(config[:url] + \"/#{URI.encode(report_name)}\" + \"&\" + params.to_query, {'connection' => 'keep-alive'})\n req.ntlm_auth(config[:username], config[:password], true)\n \n #self.agent.set_debug_output $stderr\n xml_response = agent.request(req).body\n #LOG.debug(\"#{Time.now} [EdwAdapter] results: #{xml_response.inspect}\")\n\n ## TODO Handle errors better here - yoon\n ## Hush Warning: xmlns: URI ENOTIS_x0020_-_x0020_TEST is not absolute at :1.\n LibXML::XML::Error.set_handler do |error|\n puts error.to_s if [LibXML::XML::Error::ERROR, LibXML::XML::Error::FATAL].include? error.level\n end\n\n xml_doc = LibXML::XML::Document.string(xml_response)\n return self.class.format_search_results(xml_doc || \"\")\n rescue TimeoutError, StandardError => bang\n raise WebserviceError.new(bang.message)\n end\n end", "def fetch_report(report_code, date_par)\n def academic_year(date_par) # converts the month/year into the academic year\n if date_par.month >= 6\n date_par.year\n else\n date_par.year-1\n end\n end\n \n uri = URI.parse(\"http://www.amion.com/cgi-bin/ocs?Lo=#{@login}&Rpt=#{report_code}\" +\n \"&Month=#{date_par.month}&year=#{academic_year( date_par )}\")\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n @report_code = report_code\n @report_raw_csv = http.request(request).body\n end", "def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end", "def get_report(params = {})\n values = params.slice(:vendor_number, :report_type, :report_sub_type, :date_type, :date).values\n if params[:version]\n values << params[:version]\n end\n\n fetch(@config[:sales_path], (['Sales.getReport'] + [values.join(',')]).join(', '))\n end", "def index\n @patient_encounters = PatientEncounter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @patient_encounters }\n end\n end", "def index\n @received_issues = ReceivedIssue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @received_issues }\n end\n end", "def show\n @uncoiler_report = UncoilerReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @uncoiler_report }\n end\n end", "def new\n @uncoiler_report = UncoilerReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uncoiler_report }\n end\n end", "def index\n @long_term_goals = LongTermGoal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @long_term_goals }\n end\n end", "def new\n @lr70 = Lr70.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr70 }\n end\n end", "def index\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def new\n @quarterly_report = QuarterlyReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quarterly_report }\n end\n end", "def index\n @lookup_cohorts = LookupCohort.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_cohorts }\n end\n end", "def index\n @available_offs=current_employee.available_offs\n if @available_offs\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @available_offs } \n end\n else\n render :text => \"Error\"\n end\n end", "def index\n @individual_reports = @medical_record.individual_reports.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @individual_reports }\n end\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def resource_details\n @encounter = Encounter.find(params[:id])\n\t#render :layout => \"layouts/popup\"\n respond_to do |format|\n format.html # writeup.html.erb\n format.xml { render :xml => @encounter }\n end\n end", "def report\n\t\tend", "def index\n @leaders = Leader.all\n @leadership_report = LeadershipReport.new\n @outreach_report = OutreachReport.new\n end", "def index\n @referrals = Referral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @referrals }\n end\n end", "def show\n @quarterly_report = QuarterlyReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quarterly_report }\n end\n end", "def show\n if params[:format] == 'xml'\n send_file @test_plan.jmx.path, :type => 'application/xml', :disposition => 'attachment'\n end\n end", "def types\n @client.make_request :get, reports_path\n end", "def fetch_row\n @screen = session.active_screen\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def show\n @lookup_eligibilityoutcome = LookupEligibilityoutcome.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_eligibilityoutcome }\n end\n end", "def response_xml\r\n @sess.DoRequests(@request_set).ToXMLString\r\n end", "def show\n @management_info_system_report = ManagementInfoSystemReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @management_info_system_report }\n end\n end", "def show\n @report_group = Irm::ReportGroup.multilingual.status_meaning.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_group }\n end\n end", "def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def search_for_new_reports(until_date=Date.today)\n\n url = \"http://www.fixmystreet.com/open311/v2/requests.xml?jurisdiction_id=fiksgatami.no&agency_responsible=2434%7C2240&start_date=#{(until_date - 14).strftime('%Y-%m-%d')}&end_date=#{until_date.strftime('%Y-%m-%d')}\"\n\n doc = Nokogiri::XML HTTParty.get(url).response.body\n\n rows = []\n count = 0\n\n doc.search('request').each do |i|\n rows << i.children.inject({}){|hsh,el| hsh[el.name] = el.inner_text;hsh}\n end\n\n rows.each do |row|\n\n if row[\"agency_responsible\"].strip == \"Staffordshire County Council\"\n subdomain = \"www\"\n else\n subdomain = \"lichfielddc\"\n end\n\n details = {\n :uid => row[\"service_request_id\"],\n :url => \"http://#{subdomain}.fixmystreet.com/report/#{row['service_request_id']}\",\n :council => row[\"agency_responsible\"].strip,\n :description => row[\"description\"],\n :detail => row[\"detail\"],\n :sent => Date.parse(row[\"agency_sent_datetime\"]),\n :lat => row[\"lat\"],\n :lng => row[\"long\"],\n :requested => Date.parse(row[\"requested_datetime\"]),\n :service => row[\"service_name\"],\n :title => row[\"title\"],\n :status => row[\"status\"],\n :updated => Date.parse(row[\"updated_datetime\"])\n }\n\n ScraperWiki.save([:uid], details)\n\n end\n\nend" ]
[ "0.69289225", "0.6280504", "0.6258765", "0.6258765", "0.5913563", "0.58976084", "0.58624345", "0.58320194", "0.5812011", "0.5787797", "0.5779233", "0.5773819", "0.5771644", "0.5771005", "0.57687", "0.57683724", "0.57568294", "0.5755484", "0.57528955", "0.5735385", "0.56987286", "0.56950074", "0.5682224", "0.5679004", "0.5675271", "0.56564486", "0.5653084", "0.5652269", "0.5634633", "0.56300515", "0.5616702", "0.56138486", "0.5595089", "0.55880916", "0.55856824", "0.5569175", "0.5567875", "0.5567542", "0.5565312", "0.55645895", "0.55592257", "0.55567247", "0.55501276", "0.55435026", "0.5543314", "0.5537273", "0.55332786", "0.55303985", "0.5514893", "0.55132157", "0.55081934", "0.5505915", "0.5503979", "0.5499714", "0.5499714", "0.54931444", "0.5490756", "0.5482924", "0.5477758", "0.54762", "0.5444233", "0.5426648", "0.5420835", "0.5412955", "0.54046845", "0.54025716", "0.53952855", "0.5360911", "0.53592587", "0.53434014", "0.53377986", "0.5328568", "0.5320217", "0.5319734", "0.53189033", "0.53145564", "0.5313895", "0.53102267", "0.52909446", "0.52898574", "0.5289242", "0.5284451", "0.52838814", "0.5283613", "0.5280112", "0.5276951", "0.5275495", "0.5265618", "0.52641976", "0.5260903", "0.5255783", "0.52500194", "0.5249204", "0.52443624", "0.5243797", "0.52415764", "0.5241374", "0.5239855", "0.5231191", "0.5221628" ]
0.7529565
0
GET /portal/learners/1/multiple_choice_report GET /portal/learners/1/multiple_choice_report.xml
def multiple_choice_report @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| format.html # report.html.haml end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def open_response_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def bundle_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def index\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def external_report_learners_from_jwt\n authorize Portal::PermissionForm\n\n # Empty hashes and arrays are removed from param list now\n # see: https://github.com/rails/rails/issues/26569\n query = params[\"query\"] || {}\n page_size = params[\"page_size\"].to_i\n search_after = params[\"search_after\"] || nil\n endpoint_only = params[\"endpoint_only\"] || false\n\n if (page_size == nil || page_size < 1)\n return error \"param page_size must be a positive number\", 400\n elsif (page_size > 5000)\n return error \"param page_size may not be larger than 5000\", 400\n end\n\n query[:size_limit] = page_size\n\n learners = []\n # endpoint_only doesn't include all the learner data, just the remote endpoint.\n # should result in a faster response. Used for learner logs usually.\n if endpoint_only\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :endpoint_only,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map do |l|\n {\n learner_id: l.learner_id,\n run_remote_endpoint: l.remote_endpoint_url,\n runnable_url: l.runnable_url\n }\n end\n # Response should include learner metadata (names, schools, email ...)\n else\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :elasticsearch,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map {|l| self.class.detailed_learner_info l}\n end\n response = {\n json: {\n version: \"1\",\n learners: learners,\n lastHitSortValue: learner_selector.last_hit_sort_value\n }\n }\n render json: response.to_json\n end", "def external_report_query\n authorize Portal::PermissionForm\n\n # Note that Report::Learner::Selector is a little helper that actually calls\n # API::V1::ReportLearnersEsController.query_es.\n learner_selector = Report::Learner::Selector.new(params, current_user, { learner_type: :elasticsearch })\n # In the future, we might want to extend this query format and add other filters, e.g. dates.\n response = {\n type: \"learners\",\n version: \"1.1\",\n learners: learner_selector.es_learners.map do |l|\n {\n run_remote_endpoint: l.remote_endpoint_url,\n class_id: l.class_id,\n runnable_url: l.runnable_url\n }\n end,\n user: {\n id: url_for(current_user),\n email: current_user.email\n }\n }\n # Note that we're not generating JWT. We're only signing generated query JSON, so the external report can verify\n # that it's coming from the Portal and it hasn't been modified on the way. The external report app needs to know\n # hmac_secret to verify query and signature.\n signature = OpenSSL::HMAC.hexdigest(\"SHA256\", SignedJWT.hmac_secret, response.to_json)\n render json: {\n json: response,\n signature: signature\n }.to_json\n end", "def bundle_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end", "def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end", "def get_report_list\n res=api_call('GetReportList')[:data]\n end", "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def show\n @multiplechoice = Multiplechoice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @multiplechoice }\n end\n end", "def types\n @client.make_request :get, reports_path\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def new\n @multiplechoice = Multiplechoice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @multiplechoice }\n end\n end", "def index\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n # PUNDIT_REVIEW_SCOPE\n # PUNDIT_CHECK_SCOPE (did not find instance)\n # @learners = policy_scope(Portal::Learner)\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def report\n offering_id = params[:id]\n activity_id = params[:activity_id] # Might be null\n offering = Portal::Offering.find(offering_id)\n authorize offering\n report = DefaultReportService::default_report_for_offering(offering)\n raise ActionController::RoutingError.new('Default Report Not Found') unless report\n next_url = report.url_for_offering(offering, current_visitor, request.protocol, request.host_with_port, { activity_id: activity_id })\n redirect_to next_url\n end", "def new\n @comparative_report = ComparativeReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comparative_report }\n end\n end", "def index\n @group = Group.find(params[:group_id])\n @survey = @group.surveys.find(params[:survey_id])\n sheet_ids = @survey.sheet_ids\n @answer_sheets = AnswerSheet.find_all_by_sheet_id(sheet_ids,\n :order => 'date desc')\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answer_sheets }\n end\n end", "def index\n @responses = @survey.responses.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @responses }\n end\n end", "def index\n @learners = Learner.all\n end", "def index\n @question_reports = QuestionReport.all\n end", "def index\n @samples = Sample.approved_or_rejected.page(params[:page]).per(100)\n respond_to do |format|\n format.html\n format.csv do\n render_csv\n end\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end", "def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @partners.to_xml }\n end\n end", "def index\n @teachers = Teacher.search @year_selected, @degree_selected\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teachers }\n end\n end", "def reports\n collection(\"reports\")\n end", "def index\n @answers = Answer.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end", "def index\n @admin_answers = Admin::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @admin_answers }\n end\n end", "def index\n @answers = @question.answers.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end", "def index\n @checkstudies = Checkstudy.all\n\n respond_to do |format|\n format.html\n format.csv {render text: @checkstudies.to_csv}\n end\n end", "def index\n @multiples = @confirm.multiples.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @multiples }\n end\n end", "def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end", "def index\n @criterions = Criterion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @criterions }\n end\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def index\n @compares = @chapter.compares\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compares }\n end\n end", "def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end", "def index\n @leaders = Leader.all\n @leadership_report = LeadershipReport.new\n @outreach_report = OutreachReport.new\n end", "def new\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def reports\n backend.reports\n end", "def index\n @questionnaires = Questionnaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questionnaires }\n end\n end", "def show\n @report = Report.find(params[:id])\n correct_questions = Array.new\n question_labels = Array.new\n answers_picked = Array.new\n # get the correct questions into the array\n if(@report.participants.count == 0)\n correct_questions << -1\n else\n sorted = @report.poll.pollquestions.sort { |a, b| a.weight <=> b.weight }\n sorted.each do |q|\n correct_questions << AnsweredQuestion.num_correct(q.question, @report)\n question_labels << q.question.body\n end\n end\n @report.poll.pollquestions.sort { | a, b | a.weight <=> b.weight } .each do |q|\n q.question.answers.each do |a|\n answers_picked << a.picked(@report)\n end \n end\n data = [{ \n :p_count => @report.participants.count,\n :q_count => @report.poll.questions.count,\n :correct_questions => correct_questions,\n :q_labels => question_labels,\n :answers_picked => answers_picked\n }];\n respond_with data.to_json\n end", "def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end", "def index\n @long_term_goals = LongTermGoal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @long_term_goals }\n end\n end", "def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n @portal_learner.periodic_bundle_logger = Dataservice::PeriodicBundleLogger.create!(:learner_id => @portal_learner.id) unless @portal_learner.periodic_bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render_learner_jnlp @portal_learner }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n bundle_get_url = dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle)\n if @portal_learner.student.user == current_visitor\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n if current_settings.use_periodic_bundle_uploading?\n bundle_get_url = dataservice_periodic_bundle_logger_url(@portal_learner.periodic_bundle_logger, :format => :bundle)\n bundle_post_url = nil\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => bundle_get_url,\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def index\n @lookup_sets = LookupSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_sets }\n end\n end", "def all\n status_not_acceptable && return unless accept_header?\n\n patient = get_patient(params.permit(:id)[:id])\n\n status_forbidden && return if patient.nil?\n\n # Gather assessments and lab results\n assessments = patient.assessments || []\n laboratories = patient.laboratories || []\n all = [patient] + assessments.to_a + laboratories.to_a\n results = all.collect { |r| FHIR::Bundle::Entry.new(fullUrl: full_url_helper(r.as_fhir), resource: r.as_fhir) }\n\n # Construct bundle from monitoree and data\n bundle = FHIR::Bundle.new(\n id: SecureRandom.uuid,\n meta: FHIR::Meta.new(lastUpdated: DateTime.now.strftime('%FT%T%:z')),\n type: 'searchset',\n total: all.size,\n entry: results\n )\n\n status_ok(bundle) && return\n rescue StandardError\n render json: operation_outcome_fatal.to_json, status: :internal_server_error\n end", "def index\n @referrals = Referral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @referrals }\n end\n end", "def index\n @compliances = Compliance.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compliances }\n end\n end", "def index\n @test_subject_evaluations = @test_subject.test_subject_evaluations.find(:all, :order => 'evaluated_on DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @test_subject_evaluations }\n end\n end", "def index\n @analysis_responses = AnalysisResponse.all\n end", "def external_report_query_jwt\n authorize Portal::PermissionForm\n\n response = {\n token: SignedJWT::create_portal_token(current_user, {}, 3600), # just sets uid\n json: {\n query: params,\n type: \"learners\",\n version: \"2\",\n user: {\n id: url_for(current_user),\n email: current_user.email\n },\n portal_url: root_url,\n learnersApiUrl: external_report_learners_from_jwt_api_v1_report_learners_es_url\n }\n }\n\n render json: response.to_json\n end", "def index\n @reporte = Reporte.find(params[:reporte_id])\n @reporte_detalles = @reporte.reporte_detalles.all\n end", "def index\n @all_reports = AllReport.all\n\n @lead_positive = LeadReport.all \n @lead_negative = LeadReportNeg.all \n end", "def index\n @et_reports = EtReport.all\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end", "def index\n @compliances = Compliance.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compliances }\n end\n end", "def show\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render :partial => 'shared/learn',\n :locals => { :runnable => @portal_learner.offering.runnable, :learner => @portal_learner } }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n if @portal_learner.student.user == current_user\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle),\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def new\n @differentiator_answer = DifferentiatorAnswer.new\n @differentiator_questions = DifferentiatorQuestion.find :all\n @employers = Employer.find :all\n @users = User.find :all\n @job_postings = JobPosting.find :all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @differentiator_answer }\n end\n end", "def list\n @reports_fetch = Report.all\n @reports = []\n\n @reports_fetch.each do |report|\n @reports << report if current_user == report.submitter\n end\n\n render status: 200, json: @reports.as_json(methods: [:url_title_string, :report_time_ms], include: { report_status_type: {}, report_type: {}, specified_submit_to_role: {} })\n end", "def agreement_report\n\t\treport = ActiveReporting::Report.new( { :title => \"Review Stage Agreement\", :description => \"Comparison of document dispositions across reviewers\" } )\n\t\tfor sr in self.stage_reviewers do\n\t\t\treport.columns << ActiveReporting::Report::Column.new( :title => \"Reviewer #{sr.user.nickname}\", :formatter => Proc.new { |v| DocumentReview.action_verb(v) } )\n\t\tend\n\t\treport.columns << ActiveReporting::Report::Column.new( :title => \"Count\" )\n\t\tsql_select1 = self.stage_reviewers.collect{ |sr| \"dr#{sr.id}.disposition disposition#{sr.id}\" }.join(\", \")\n\t\tsql_join1 = self.stage_reviewers.collect{ |sr| \"LEFT JOIN stage_reviewers sr#{sr.id} ON sr#{sr.id}.review_stage_id = rs.id AND sr#{sr.id}.id = #{sr.id}\" }.join(\"\\n\")\n\t\tsql_join2 = self.stage_reviewers.collect{ |sr| \"LEFT JOIN document_reviews dr#{sr.id} ON dr#{sr.id}.stage_reviewer_id = sr#{sr.id}.id AND dr#{sr.id}.document_id = d.id\" }.join(\"\\n\")\n\t\tsql_where1 = self.stage_reviewers.collect{ |sr| \"dr#{sr.id}.id IS NOT NULL\" }.join(\" OR \")\n\t\tsql_group1 = self.stage_reviewers.collect{ |sr| \"dr#{sr.id}.disposition\" }.join(\", \")\n\t\t# SELECT dr101.disposition disp202, dr202.disposition disp202, count(d.id)\n\t\t# FROM review_stages rs, documents d\n\t\t# LEFT JOIN stage_reviewers sr101 ON sr101.review_stage_id = rs.id AND sr101.id = 101\n\t\t# LEFT JOIN stage_reviewers sr202 ON sr202.review_stage_id = rs.id AND sr202.id = 202\n\t\t# LEFT JOIN document_reviews dr101 ON dr101.stage_reviewer_id = sr101.id AND dr101.document_id = d.id\n\t\t# LEFT JOIN document_reviews dr202 ON dr202.stage_reviewer_id = sr202.id AND dr202.document_id = d.id\n\t\t# GROUP BY dr101.disposition, dr202.disposition\n\t\t# WHERE rs.id = #{self.id} AND (dr101.id NOT NULL OR dr202.id NOT NULL)\n\t\tsql = <<-EOT\n\t\t\tSELECT\n\t\t\t\t#{sql_select1},\n\t\t\t\tCOUNT(d.id) document_count\n\t\t\t\tFROM review_stages rs JOIN documents d\n\t\t\t\tLEFT JOIN document_sources ds ON d.document_source_id = ds.id\n\t\t\t\t#{sql_join1}\n\t\t\t\t#{sql_join2}\n\t\t\t\tWHERE rs.id = #{self.id} AND ds.project_id = rs.project_id AND (#{sql_where1})\n\t\t\t\tGROUP BY\n\t\t\t\t\t#{sql_group1}\n\t\t\t\t;\n\t\tEOT\n\t\trows = self.connection.select_rows( sql )\n\t\tfor row in self.connection.select_rows( sql )\n\t\t\tvalues = {}\n\t\t\treport.columns.each_index do |i|\n\t\t\t\tcol = report.columns[i]\n\t\t\t\tvalue = col.format(row[i])\n\t\t\t\tvalues[col] = value\n\t\t\tend\n\t\t\trow = ActiveReporting::Report::Row.new( values )\n\t\t\treport.rows << row\n\t\tend\n\t\treport\n\tend", "def view_indicators_and_resources\n\t\t@competency = Competency.find(params[:competency_id])\n\t\t@indicators = Indicator.by_level(params[:level]).by_competency(@competency.name)\n\t\t@resources = Resource.all\n\tend", "def index\n @report_templates = ReportTemplate.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @report_templates }\n end\n end", "def index\n @merchandise_option_sets = MerchandiseOptionSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @merchandise_option_sets }\n end\n end", "def index\n @report_mockups = @survey.list_report_mockups\n end", "def index\n if choice_hash = get_selected_status_staffer\n @clean_choice_hash = {}\n @view_mode = choice_hash[:view_mode]\n\n choice_hash.each do |key, value|\n @clean_choice_hash[key] = value if !value.nil? && value != \"\" && key != :view_mode\n end\n divided_hash = choice_hash_divider(@clean_choice_hash)\n @selected_data = Staffer.where(divided_hash[:only_attrs])\n @selected_data = applied_non_attrs(@selected_data, divided_hash[:non_attrs])\n else # choice_hash is nil\n @selected_data = Staffer.all\n end\n\n if url = params[:url]\n @selected_data = @selected_data.where(domain: url)\n end\n\n @staffer_count = Staffer.count\n @selected_staffer_count = @selected_data.count\n\n @selected_data = @selected_data.order(:acct_name, :lname, :fname, scrape_date: :desc)\n\n # CSV #\n respond_to do |format|\n format.html\n format.csv { render text: @selected_data.to_csv }\n end\n\n @staffers = @selected_data.filter(filtering_params(params)).paginate(:page => params[:page], :per_page => 50)\n\n batch_status\n end", "def all(params = {})\n unless params[:type]\n raise ArgumentError, \"Missing 'type' parameter in params\" # TODO: replace the error in the error-handling overhaul PR\n end\n\n type = params.delete(:type)\n url = \"reports/#{type}\"\n\n response = @client.make_request(:get, url, MODEL_CLASS, params)\n response.define_singleton_method(:type) { type }\n response\n end", "def index\n @evil_wizards = EvilWizard.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evil_wizards }\n end\n end", "def index\n @questionnaires = Questionnaire.all\n# @questionnaires = User.questionnaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questionnaires }\n end\n end", "def index\n @measures = current_user.account.measures.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @measures }\n end\n end", "def new\n @user_reports = UserReport.new(params[:user_report])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_reports }\n end\n end", "def new\n @report = Mg::Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end", "def index\n @survey_responses = SurveyResponse.all\n end", "def report_data\n options = process_params_options(params)\n if options.nil? || options[:view].nil?\n model_view = process_params_model_view(params, options)\n @edit = session[:edit]\n @view, settings = get_view(model_view, options, true)\n else\n @view = options[:view]\n settings = options[:pages]\n end\n settings = set_variables_report_data(settings, @view)\n\n if options && options[:named_scope] == \"in_my_region\" && options[:model] == \"Tenant\"\n @view.table = filter_parent_name_tenant(@view.table)\n end\n\n render :json => {\n :checkboxes_clicked => params.fetch_path(:additional_options, :checkboxes_clicked),\n :settings => settings,\n :data => view_to_hash(@view, true),\n :messages => @flash_array\n }\n end", "def index\n @action_reports = ActionReport.all\n end", "def get_report_list(params = {})\n response = get(\"/\", {\"Action\" => \"GetReportList\"}.merge(params))\n GetReportListResponse.format(response)\n end", "def rights_overview\n\t\t@survey = Survey.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html \n\t\t\tformat.xml { render :xml => @survey }\n\t\tend\n\tend", "def new\n @software_report = SoftwareReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software_report }\n end\n end", "def index\n @ee_reports = EeReport.all\n end", "def index\n @ee_reports = EeReport.all\n end", "def index\n @failure_reports = FailureReport.all\n end", "def report\n @employees=Employee.all\n @routing_sheets=RoutingSheet.find(:all, :conditions=> \"routing_sheet_state_id=1\") ## 1 = \"En Proceso\"\n $routing_sheets_details=Array.new\n respond_to do |format|\n format.html # report.html.erb\n format.json {render json: @routing_sheet }\n end\n end", "def index\n @possible_answers = PossibleAnswer.all\n end", "def index\n #ransack search\n @q = Absence.ransack(params[:q])\n #paginate\n @pagy, @absences = pagy(@q.result)\n #define for charkick\n @absence_type = [\n ['Full Pay', @absences.sum(:full_pay)],\n ['Half Pay', @absences.sum(:half_pay)]\n ]\n #attempt to upload/download cvs format - in development\n respond_to do |format|\n format.html\n format.csv { render text: @absences.to_csv }\n end\n\n end", "def solicitudes\n report = SolicitudesReport.new(:page_size => 'LEGAL',\n :page_layout => :landscape)\n report.reporttitle = 'REPORTES DE SOLICITUDES'\n report.items = Solicitud.find(:all, :conditions => [\"solicitudes.institucion_id = ? and solicitudes.anulada = ?\", current_usuario.institucion_id, false], :order => :numero)\n output = report.to_pdf\n\n file_name = \"solicitudes_\" + Time.now.to_i.to_s + \".pdf\"\n\n respond_to do |format|\n format.pdf do\n send_data output, :filename => file_name,\n :type => \"application/pdf\"\n end\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def new\n @report_question_answer = ReportQuestionAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report_question_answer }\n end\n end", "def show\n @results = @report.results\n end", "def show\n @results = @report.results\n end", "def index\n @borrower_residences = BorrowerResidence.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @borrower_residences.to_xml }\n end\n end", "def new\n \n #@neuotransmitter_report = NeuotransmitterReport.new\n # LDN_report = Nokogiri::XML(open(\"LDN_neurotransmitter_report\"))\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neuotransmitter_report }\n end\n end", "def new\n @lessonrecords = Lessonrecord.new\n @kojenadults = Kojenadult.all\n @adults_session_descriptions = AdultsSessionDescription.all\n @childs_session_descriptions = ChildsSessionDescription.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lessonrecords }\n end\n end", "def new\n @individual_report = @medical_record.individual_reports.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @individual_report }\n end\n end", "def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end", "def index\n @initial_surveys = InitialSurvey.all\n respond_to do |format|\n format.html { render :action => \"index\" }\n format.csv { send_data InitialSurvey.to_csv(@initial_surveys) }\n end\n end", "def new\n @survey_answer = SurveyAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @survey_answer }\n end\n end" ]
[ "0.73271894", "0.62780035", "0.62171257", "0.6011317", "0.5902038", "0.58832306", "0.5837398", "0.5745126", "0.56874603", "0.56874603", "0.56849986", "0.5626224", "0.55406445", "0.5522408", "0.55100685", "0.5503292", "0.5492647", "0.5462987", "0.5432649", "0.54154414", "0.54080564", "0.5403324", "0.5385961", "0.5375219", "0.5348506", "0.5339012", "0.53308165", "0.5310471", "0.52971923", "0.5293132", "0.5291718", "0.5284134", "0.52815855", "0.5278022", "0.5273976", "0.5272583", "0.5267619", "0.5262002", "0.52589905", "0.52539885", "0.5253331", "0.52530736", "0.5247938", "0.5245873", "0.52242875", "0.52182925", "0.5211573", "0.52099967", "0.5209417", "0.5207721", "0.52028114", "0.5186592", "0.51784545", "0.517323", "0.51707655", "0.5169463", "0.5163434", "0.51608694", "0.5143572", "0.5139128", "0.5138732", "0.5136813", "0.5136598", "0.5129307", "0.5104055", "0.5102062", "0.51012427", "0.5099064", "0.50969195", "0.5086601", "0.508018", "0.50676143", "0.5064014", "0.50587964", "0.5058564", "0.50577295", "0.50565743", "0.50555676", "0.50518405", "0.5050843", "0.5050773", "0.5044232", "0.5044232", "0.5042779", "0.5040478", "0.50341797", "0.5029632", "0.50263405", "0.5023385", "0.5023385", "0.5023245", "0.50190496", "0.50190496", "0.5018996", "0.5018592", "0.5017201", "0.5016756", "0.50159335", "0.5014508", "0.5013115" ]
0.80092335
0
GET /portal/learners/1/bundle_report GET /portal/learners/1/bundle_report.xml
def bundle_report @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| format.html # report.html.haml end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bundle_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def multiple_choice_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def open_response_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def show\n @bundle = Bundle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bundle }\n end\n end", "def index_loans_for_bundle\n @bundles = Bundle.find(params[:id])\n\n respond_to do |format|\n format.html { render 'loans/index'}\n format.xml { render :xml => @bundles }\n end\n end", "def index\n @bundle_sources = BundleSource.find(:all, :conditions => [\"user_id=#{@user.id}\"])\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bundle_sources }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bundle_source }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bundle_content }\n end\n end", "def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end", "def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end", "def report(id)\n get(\"reports/#{id}\")\n end", "def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n @portal_learner.periodic_bundle_logger = Dataservice::PeriodicBundleLogger.create!(:learner_id => @portal_learner.id) unless @portal_learner.periodic_bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render_learner_jnlp @portal_learner }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n bundle_get_url = dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle)\n if @portal_learner.student.user == current_visitor\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n if current_settings.use_periodic_bundle_uploading?\n bundle_get_url = dataservice_periodic_bundle_logger_url(@portal_learner.periodic_bundle_logger, :format => :bundle)\n bundle_post_url = nil\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => bundle_get_url,\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @periodic_bundle_logger\n @dataservice_bundle_logger = Dataservice::PeriodicBundleLogger.find(params[:id])\n eportfolio_bundle = @dataservice_bundle_logger.sail_bundle\n # FIXME How do we now associate launch process events since bundle_content != session?\n # For now, the in_progress_bundle is still being created, so just use that.\n if ipb = @dataservice_bundle_logger.learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:bundle_requested],\n :event_details => \"Learner session data loaded. Loading activity content...\",\n :bundle_content => ipb\n )\n end\n NoCache.add_headers(response.headers)\n respond_to do |format|\n # format.html # show.html.erb\n format.xml { render :xml => eportfolio_bundle }\n format.bundle {render :xml => eportfolio_bundle }\n end\n end", "def report_load\n self.report('load_report')\n end", "def new\n @bundle_source = BundleSource.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bundle_source }\n end\n end", "def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end", "def index\n @bundle_content_count = BundleContent.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bundle_content_count }\n end\n end", "def show\n @report = Mg::Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def reports\n backend.reports\n end", "def new\n @bundle = Bundle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bundle }\n end\n end", "def show\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render :partial => 'shared/learn',\n :locals => { :runnable => @portal_learner.offering.runnable, :learner => @portal_learner } }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n if @portal_learner.student.user == current_user\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle),\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end", "def get_report_list\n res=api_call('GetReportList')[:data]\n end", "def new\n @software_report = SoftwareReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software_report }\n end\n end", "def create_bundle\n @conclusion_draft_review.create_bundle_zip current_organization,\n params[:index_items]\n\n @report_path = @conclusion_draft_review.relative_bundle_zip_path\n\n respond_to do |format|\n format.html { redirect_to @report_path }\n format.js { render 'shared/pdf_report' }\n end\n end", "def show\n @software_report = SoftwareReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @software_report }\n end\n end", "def new\n @report = Mg::Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end", "def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def getSalesReport(year, month)\n #url = sprintf('https://market.android.com/publish/salesreport/download?report_date=%04d_%02d', year, month)\n url = sprintf('https://play.google.com/apps/publish/salesreport/download?report_date=%04d_%02d&report_type=payout_report&dev_acc=%s', year, month, @dev_acc)\n try_get(url)\n return @agent.page.body\n end", "def report\n offering_id = params[:id]\n activity_id = params[:activity_id] # Might be null\n offering = Portal::Offering.find(offering_id)\n authorize offering\n report = DefaultReportService::default_report_for_offering(offering)\n raise ActionController::RoutingError.new('Default Report Not Found') unless report\n next_url = report.url_for_offering(offering, current_visitor, request.protocol, request.host_with_port, { activity_id: activity_id })\n redirect_to next_url\n end", "def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n content_type: FrameworkHelper.content_type_for_report( format ),\n text: FrameworkHelper.framework { |f| f.report_as format, @scan.report.object }\n end", "def fetch_report\n\t\t\t\tbegin\n\t\t\t\t\treport = fetch(\"#{Middlecoin::MIDDLECOIN_URL}/json\")\n\t\t\t\t\t@report = JSON.parse(report.body)[\"report\"]\n\t\t\t\trescue => e\n\t\t\t\t\traise Middlecoin::MiddlecoinAPIError, \"Unable to collect JSON report from middlecoin.com\"\n\t\t\t\tend\n\t\t\tend", "def show\n @bundle = Bundle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bundle }\n end\n end", "def show\n @bundle = Bundle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bundle }\n end\n end", "def report(object)\n full_name = extract_full_name object\n post 'api/report', :id => full_name\n end", "def reports_path; end", "def reports_path; end", "def show\n @service_report = ServiceReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_report }\n end\n end", "def get_report(params = {})\n values = params.slice(:vendor_number, :report_type, :report_sub_type, :date_type, :date).values\n if params[:version]\n values << params[:version]\n end\n\n fetch(@config[:sales_path], (['Sales.getReport'] + [values.join(',')]).join(', '))\n end", "def show\n @report = Report.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def show\n @report = Report.find(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end", "def show\n @report_group = Irm::ReportGroup.multilingual.status_meaning.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_group }\n end\n end", "def report\n\t\tend", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end", "def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n text: FrameworkHelper.\n framework { |f| f.report_as format, @scan.report.object }\n end", "def new\n @bundle_content = BundleContent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bundle_content }\n end\n end", "def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @bucket_logger\n @dataservice_bucket_logger = Dataservice::BucketLogger.find(params[:id])\n bundle = @dataservice_bucket_logger.most_recent_content\n if @dataservice_bucket_logger.learner\n # FIXME How do we now associate launch process events since bucket_content != session?\n # For now, the in_progress_bundle is still being created, so just use that.\n if ipb = @dataservice_bucket_logger.learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:bundle_requested],\n :event_details => \"Learner session data loaded. Loading activity content...\",\n :bundle_content => ipb\n )\n end\n end\n respond_to do |format|\n # format.html # show.html.erb\n format.bundle {\n send_data(\n bundle,\n :type => 'application/octet-stream',\n :filename => \"data-#{@dataservice_bucket_logger.id}.dat\",\n :disposition => 'inline'\n )\n }\n end\n end", "def index\n @referrals = Referral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @referrals }\n end\n end", "def report\n \n end", "def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end", "def show\n @group_report = GroupReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group_report }\n end\n end", "def getTokenReport( entity_id, portal_name, language, flatpack_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['portal_name'] = portal_name\n params['language'] = language\n params['flatpack_id'] = flatpack_id\n return doCurl(\"get\",\"/token/report\",params)\n end", "def show\n authorize :report, :show?\n if params[:finalizar]\n @resquest_criminal.status = 2\n @resquest_criminal.save\n end\n respond_to do |format|\n format.html\n format.pdf {render template: 'reports/report_pdf', pdf: \"laudo-#{@report.id}-#{@report.updated_at}\"}\n end\n end", "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def index\n @bundlelinks = Bundlelink.my_bundles(current_user)\n end", "def new\n @group_report = GroupReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_report }\n end\n end", "def download_report(name, request_time, format)\n response = @client.get('arborws/reports/configured',\n api_key: @api_key, name: name,\n request_time: request_time, format: format)\n\n response\n end", "def reports\n collection(\"reports\")\n end", "def report\n @report_file || \"kacl_report.json\"\n end", "def show\n @user_reports = UserReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_reports }\n end\n end", "def show_bundle(id)\n BrickFTP::API::Bundle.find(id)\n end", "def show_bundle(id)\n BrickFTP::API::Bundle.find(id)\n end", "def show\n @comparative_report = ComparativeReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @comparative_report }\n end\n end", "def new\n @report2 = Report2.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report2 }\n end\n end", "def show\n @dailyreport_job = DailyreportJob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dailyreport_job }\n end\n end", "def new\n @dailyreport_job = DailyreportJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dailyreport_job }\n end\n end", "def index_bundle_selection\n @bundles = Bundle.order(:id).all\n\n respond_to do |format|\n format.html # index_bundle_selection.html.erb\n format.json { render json: @bundles }\n end\n end", "def index\n @chef_server_reports = ChefServerReport.all\n end", "def show\n if params[:format] == 'xml'\n send_file @test_plan.jmx.path, :type => 'application/xml', :disposition => 'attachment'\n end\n end", "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def file_report(resources)\n resources = format(resources)\n merged_options = options.merge({ resource: resources })\n response = RestClient.post endpoint(\"/file/report\"), merged_options\n parse_response(response)\n end", "def create\n @bundle = Bundle.new(params[:bundle])\n\n respond_to do |format|\n if @bundle.save\n flash[:notice] = 'Bundle was successfully created.'\n format.html { redirect_to(@bundle) }\n format.xml { render :xml => @bundle, :status => :created, :location => @bundle }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bundle.errors, :status => :unprocessable_entity }\n end\n end\n end", "def http_report(request, _response)\n path = request.path\n\n root_element_name = Box.new('')\n result = @server.xml.parse(request.body, request.url, root_element_name)\n root_element_name = root_element_name.value\n\n if @server.emit('report', [root_element_name, result, path])\n # If emit returned true, it means the report was not supported\n fail Exception::ReportNotSupported\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_type }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_type }\n end\n end", "def index\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def index\n @report_templates = ReportTemplate.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @report_templates }\n end\n end", "def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end", "def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def new\n @report_group = Irm::ReportGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_group }\n end\n end", "def index \n @agentes = Agente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @agentes }\n #format.pdf do\n # pdf = AgentesPdf.new(@agentes, view_context)\n # send_data pdf.render, filename: \"agentes.pdf\",\n # type: \"application/pdf\",\n # disposition: \"inline\"\n #end\n format.pdf {reporte_agentes(@agentes)}\n format.xls {send_data @agentes.to_xls, :filename => 'reporte.xls' }\n end\n end", "def index\n @support_bundles = SupportBundle.all\n end", "def index\n @bundle_totals = BundleTotal.all\n end", "def index\n\t @assets = @campaign.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def retrieve_bundle\n VCR.use_cassette('bundle_download') do\n bundle_resource = RestClient::Request.execute(method: :get,\n url: 'https://cypress.healthit.gov/measure_bundles/fixture-bundle-2020.zip',\n user: ENV.fetch('VSAC_USERNAME', nil),\n password: ENV.fetch('VSAC_PASSWORD', nil),\n raw_response: true,\n headers: { accept: :zip })\n\n return bundle_resource.file\n end\n end", "def new\n @user_report = UserReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_report }\n end\n end", "def new\n @user_reports = UserReport.new(params[:user_report])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_reports }\n end\n end", "def components\r\n params = {\r\n method: :get,\r\n url: '/report/components',\r\n params: {\r\n reportUUID: @uuid\r\n }\r\n }\r\n @session.request(params).perform!\r\n end", "def new\n @comparative_report = ComparativeReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comparative_report }\n end\n end", "def report_file\n File.join(@params[\"SS_output_dir\"], \"report_data.json\")\nend", "def get(asset_report_token)\n post_with_auth 'asset_report/get',\n AssetReportGetResponse,\n asset_report_token: asset_report_token\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @download_registrations }\n end\n end", "def student_report\n offering_id = params[:id]\n offering = Portal::Offering.find(offering_id)\n authorize offering\n student_id = current_visitor.portal_student.id\n report = DefaultReportService::default_report_for_offering(offering)\n raise ActionController::RoutingError.new('Default Report Not Found') unless report\n next_url = report.url_for_offering(offering, current_visitor, request.protocol, request.host_with_port, { student_id: student_id })\n redirect_to next_url\n end" ]
[ "0.67965174", "0.60938025", "0.60678214", "0.602353", "0.5999329", "0.59496105", "0.58446866", "0.5828353", "0.57782066", "0.57782066", "0.57239056", "0.5691119", "0.56887", "0.5677733", "0.56447494", "0.5640766", "0.5632636", "0.5608801", "0.55764884", "0.5571586", "0.55653024", "0.5563589", "0.5543729", "0.55374527", "0.5537142", "0.55302936", "0.55175805", "0.5515103", "0.5512971", "0.55112535", "0.5499734", "0.5498329", "0.5484693", "0.5479784", "0.54767394", "0.54767394", "0.54756504", "0.547556", "0.547556", "0.54721177", "0.54631096", "0.54568267", "0.5444558", "0.5441198", "0.54401356", "0.54280674", "0.5395865", "0.5389795", "0.5386948", "0.5383659", "0.5377246", "0.5375087", "0.5371527", "0.5369371", "0.5359636", "0.5353365", "0.5353365", "0.5353365", "0.5353365", "0.5353365", "0.5353086", "0.5346436", "0.5337916", "0.53361917", "0.53340423", "0.533297", "0.5330026", "0.53297544", "0.53207815", "0.53196913", "0.5318672", "0.53182316", "0.5303911", "0.5290001", "0.52886695", "0.5287162", "0.52858233", "0.52849954", "0.5283774", "0.527854", "0.527854", "0.52775234", "0.5277382", "0.52688277", "0.526075", "0.525392", "0.5250894", "0.5250796", "0.5249138", "0.52484083", "0.52463144", "0.5245137", "0.5242824", "0.5238752", "0.52373147", "0.5232458", "0.5230791", "0.52306455", "0.5227072", "0.5222916" ]
0.7743663
0
GET /portal/learners/1 GET /portal/learners/1.xml
def show @portal_learner = Portal::Learner.find(params[:id]) @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger respond_to do |format| format.html # show.html.erb format.jnlp { render :partial => 'shared/learn', :locals => { :runnable => @portal_learner.offering.runnable, :learner => @portal_learner } } format.config { # if this isn't the learner then it is launched read only properties = {} if @portal_learner.student.user == current_user if @portal_learner.bundle_logger.in_progress_bundle launch_event = Dataservice::LaunchProcessEvent.create( :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested], :event_details => "Activity configuration loaded. Loading prior learner session data...", :bundle_content => @portal_learner.bundle_logger.in_progress_bundle ) end bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle) else bundle_post_url = nil properties['otrunk.view.user_data_warning'] = 'true' end render :partial => 'shared/sail', :locals => { :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id), :session_id => (params[:session] || request.env["rack.session.options"][:id]), :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle), :bundle_url => dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle), :bundle_post_url => bundle_post_url, :properties => properties } } format.xml { render :xml => @portal_learner } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def index\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def index\n @learners = Learner.all\n end", "def new\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def index\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n # PUNDIT_REVIEW_SCOPE\n # PUNDIT_CHECK_SCOPE (did not find instance)\n # @learners = policy_scope(Portal::Learner)\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def create\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_learner\n @learner = Learner.find(params[:id])\n end", "def multiple_choice_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def open_response_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def show\n @learner = @activity.find_or_create_learner(current_user)\n respond_to do |format|\n# format.html { render :layout => 'layouts/show_activity' } # show.rhtml\n format.html # show.rhtml\n format.xml { render :xml => @activity.to_xml }\n end\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def create\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @researcher = Researcher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n @portal_learner.periodic_bundle_logger = Dataservice::PeriodicBundleLogger.create!(:learner_id => @portal_learner.id) unless @portal_learner.periodic_bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render_learner_jnlp @portal_learner }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n bundle_get_url = dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle)\n if @portal_learner.student.user == current_visitor\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n if current_settings.use_periodic_bundle_uploading?\n bundle_get_url = dataservice_periodic_bundle_logger_url(@portal_learner.periodic_bundle_logger, :format => :bundle)\n bundle_post_url = nil\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => bundle_get_url,\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def bundle_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def destroy\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def external_report_learners_from_jwt\n authorize Portal::PermissionForm\n\n # Empty hashes and arrays are removed from param list now\n # see: https://github.com/rails/rails/issues/26569\n query = params[\"query\"] || {}\n page_size = params[\"page_size\"].to_i\n search_after = params[\"search_after\"] || nil\n endpoint_only = params[\"endpoint_only\"] || false\n\n if (page_size == nil || page_size < 1)\n return error \"param page_size must be a positive number\", 400\n elsif (page_size > 5000)\n return error \"param page_size may not be larger than 5000\", 400\n end\n\n query[:size_limit] = page_size\n\n learners = []\n # endpoint_only doesn't include all the learner data, just the remote endpoint.\n # should result in a faster response. Used for learner logs usually.\n if endpoint_only\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :endpoint_only,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map do |l|\n {\n learner_id: l.learner_id,\n run_remote_endpoint: l.remote_endpoint_url,\n runnable_url: l.runnable_url\n }\n end\n # Response should include learner metadata (names, schools, email ...)\n else\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :elasticsearch,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map {|l| self.class.detailed_learner_info l}\n end\n response = {\n json: {\n version: \"1\",\n learners: learners,\n lastHitSortValue: learner_selector.last_hit_sort_value\n }\n }\n render json: response.to_json\n end", "def update\n @portal_learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n if @portal_learner.update_attributes(params[:learner])\n flash[:notice] = 'Portal::Learner was successfully updated.'\n format.html { redirect_to(@portal_learner) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\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 show\n @installation = Installation.find(params[:installation_id]) \n @offpost = Offpost.find(params[:id])\n @learn = @offpost.learns\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offpost }\n end\n end", "def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def show\n @offlearn = Offlearn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offlearn }\n end\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @partners.to_xml }\n end\n end", "def show\n @reviewer = Reviewer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @reviewer }\n end\n end", "def show\n @research = Research.find(params[:id])\n @page_title = \"Hello Congress research request: \" + @research.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend", "def index\n @leks = Lek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leks }\n end\n end", "def new\n @reviewer = Reviewer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reviewer }\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 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 show\n @wrestler = Wrestler.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def index\n @reviewers = Reviewer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reviewers }\n end\n end", "def show\n @lr40 = Lr40.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr40 }\n end\n end", "def new\n @offlearn = Offlearn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offlearn }\n end\n end", "def learn_url\n \"http://learn.uwaterloo.ca\"\n end", "def index\n @teachers = Teacher.search @year_selected, @degree_selected\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teachers }\n end\n end", "def show\n @portal_clazz = Portal::Clazz.find(params[:id], :include => [:teachers, { :offerings => [:learners, :open_responses, :multiple_choices] }])\n @portal_clazz.refresh_saveable_response_objects\n @teacher = @portal_clazz.parent\n @offerings = substitute_default_class_offerings(@portal_clazz.active_offerings)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @portal_clazz }\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 new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def download_people_data\n print \"Getting IDs of articles about people...\\n\"\n PeopleGetter.new([MEN_URL, WOMEN_URL]).result\n end", "def show\n @portal = Portal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @portal }\n end\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 @leaders = Leader.all\n @leadership_report = LeadershipReport.new\n @outreach_report = OutreachReport.new\n end", "def new\n @wrestler = Wrestler.new\n @teams = Team.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def show\n @lek = Lek.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def show\n @teacher = Teacher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def show\n @teacher = Teacher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def show\n @teacher = Teacher.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def index\n @guides = Guide.all\n #@guide = Guide.find(params[:guide]) rescue nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @guides }\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\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lesson }\n end\n end", "def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end", "def bundle_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def show\n @lr70 = Lr70.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr70 }\n end\n end", "def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def gererateLacpLearnedInfoView ( viewName )\r\n viewCaption = viewName\r\n protocol = 'LACP'\r\n drillDownType = 'Global Learned Info'\r\n root = @ixNet.getRoot()\r\n statistics = root + '/statistics'\r\n statsViewList = @ixNet.getList(statistics, 'view')\r\n\r\n # Add a StatsView\r\n view = @ixNet.add(statistics, 'view')\r\n @ixNet.setAttribute(view, '-caption', viewCaption)\r\n @ixNet.setAttribute(view, '-type', 'layer23NextGenProtocol')\r\n @ixNet.setAttribute(view, '-visible', 'true')\r\n @ixNet.commit()\r\n view = @ixNet.remapIds(view)[0]\r\n\r\n # Set Filters\r\n trackingFilter = @ixNet.add(view, 'advancedCVFilters')\r\n @ixNet.setAttribute(trackingFilter, '-protocol', protocol)\r\n @ixNet.commit()\r\n #ixNet getAttr $trackingFilter -availableGroupingOptions\r\n @ixNet.setAttribute(trackingFilter, '-grouping', drillDownType)\r\n @ixNet.commit()\r\n layer23NextGenProtocolFilter = view + '/' + 'layer23NextGenProtocolFilter'\r\n @ixNet.setAttribute(layer23NextGenProtocolFilter, '-advancedCVFilter', trackingFilter)\r\n @ixNet.commit()\r\n\r\n # Enable Stats Columns to be displayed\r\n statsList = @ixNet.getList(view, 'statistic')\r\n for stat in statsList\r\n @ixNet.setAttribute(stat, '-enabled', 'true')\r\n end\r\n @ixNet.commit()\r\n\r\n # Enable Statsview\r\n @ixNet.setAttribute(view, '-enabled', 'true')\r\n @ixNet.commit()\r\nend", "def show\n @rant = Rant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rant }\n end\n end", "def teachers\n if current_user.is_admin?\n @teachers= User.find(:all, :conditions => \"is_teacher = '1' and is_admin = '0'\")\n respond_to do |format|\n format.xml { render :xml => @teachers }\n end\n else\n respond_to do |format|\n format.xml { render :text => \"error\" }\n end\n end\n end", "def index\n @referrals = Referral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @referrals }\n end\n end", "def show\n @laborer = Laborer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @laborer }\n end\n end", "def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end", "def show\n @expertise = current_user.expertises.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expertise }\n end\n end", "def show\n @lr45 = Lr45.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr45 }\n end\n end", "def new\n @rant = Rant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rant }\n end\n end", "def index\n @wrestlers = Wrestler.all\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def show\n @listener = Listener.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @listener }\n end\n end", "def index\n @borrower_residences = BorrowerResidence.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @borrower_residences.to_xml }\n end\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def new\n @portal = Portal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal }\n end\n end", "def new\n @hr_attendence = Hr::Attendence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hr_attendence }\n end\n end", "def show\n @announcer = Announcer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @announcer }\n end\n end", "def index\n @subjects = @client.subjects\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subjects }\n end\n end", "def me\n users(request(\"users/authenticate.xml\", :auth => true))\n end", "def show\n @expert_personal = ExpertPersonal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expert_personal }\n end\n end", "def show\n @installation = Installation.find(params[:installation_id])\n @learn = Learn.find(params[:id])\n @comment = @learn.comments\n @user = @comment.users\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @learn }\n end\n end", "def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def show\n @lab = @course.labs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @lab }\n end\n end", "def show\n @kennel = Kennel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @kennel }\n end\n end", "def tournaments\n get('sports/en/tournaments.xml')\n end", "def new\n @lesson_plan = LessonPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lesson_plan }\n end\n end", "def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lesson }\n end\n end", "def show\n @adults_howyouknowu = AdultsHowyouknowu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @adults_howyouknowu }\n end\n end", "def new\n @expert_personal = ExpertPersonal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expert_personal }\n end\n end", "def index\n @tutors = Tutor.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tutors }\n end\n end", "def index\n @roles = @client.roles\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end", "def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def destroy\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def new\n @kennel = Kennel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kennel }\n end\n end", "def show\n #not using\n #@litter = Litter.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n # format.xml { render :xml => @litter }\n #end\n end", "def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lore }\n end\n end", "def new\n @adults_howyouknowu = AdultsHowyouknowu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adults_howyouknowu }\n end\n end", "def new\n @teacher = Teacher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def new\n @teacher = Teacher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teacher }\n end\n end" ]
[ "0.6907847", "0.6860391", "0.6570956", "0.63729715", "0.625766", "0.618486", "0.61430395", "0.6115878", "0.60385853", "0.59582907", "0.5929482", "0.5908546", "0.5834841", "0.58073485", "0.5769593", "0.5768594", "0.5747755", "0.57408077", "0.57163537", "0.5711283", "0.5695722", "0.56674665", "0.5631138", "0.5623849", "0.5602278", "0.5598937", "0.55576265", "0.5545208", "0.54811037", "0.5479393", "0.5466917", "0.5446173", "0.5421585", "0.54127276", "0.5411514", "0.5406943", "0.5400462", "0.53917557", "0.5389108", "0.5379972", "0.53770685", "0.5368902", "0.5368902", "0.53656036", "0.53503084", "0.5347543", "0.5345518", "0.534304", "0.5331002", "0.5324554", "0.5324554", "0.5324554", "0.5323467", "0.5315622", "0.52963996", "0.52950084", "0.52947724", "0.52941424", "0.52929", "0.52929", "0.5282239", "0.52792495", "0.5275643", "0.52752036", "0.52616596", "0.52528346", "0.52356684", "0.5234482", "0.52333057", "0.52321994", "0.5228703", "0.5226428", "0.5223398", "0.52221155", "0.5214005", "0.52114075", "0.52085215", "0.52072597", "0.52048874", "0.51860195", "0.5184825", "0.5183534", "0.5183534", "0.5181595", "0.5180581", "0.5178382", "0.5177889", "0.5174293", "0.5172207", "0.51711935", "0.5169938", "0.5169605", "0.51671326", "0.5164252", "0.5164166", "0.5158244", "0.515681", "0.5152941", "0.5152542", "0.5152542" ]
0.57050246
20
GET /portal/learners/new GET /portal/learners/new.xml
def new @portal_learner = Portal::Learner.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @portal_learner } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def create\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def new\n @portal = Portal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal }\n end\n end", "def new\n @offlearn = Offlearn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offlearn }\n end\n end", "def new\n @rant = Rant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rant }\n end\n end", "def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lesson }\n end\n end", "def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def new\n @lead = Lead.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lead }\n end\n end", "def new\n head :status => 405\n return\n \n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.xml { render :xml => @participant }\n end\n end", "def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end", "def new\n @rails_url = RailsUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rails_url }\n end\n end", "def new\n @kennel = Kennel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kennel }\n end\n end", "def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end", "def new\n @reviewer = Reviewer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reviewer }\n end\n end", "def new\n @lr40 = Lr40.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr40 }\n end\n end", "def new\n @partner_link = PartnerLink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partner_link }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\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 new\n @tutorials = Tutorials.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tutorials }\n end\n end", "def new\n @partner_person = PartnerPerson.new\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partner_person }\n end\n end", "def new\n @lr70 = Lr70.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr70 }\n end\n end", "def new\n @lesson_plan = LessonPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lesson_plan }\n end\n end", "def new\n @listener = Listener.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @listener }\n end\n end", "def new\n @announcer = Announcer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @announcer }\n end\n end", "def new\n @expert_personal = ExpertPersonal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expert_personal }\n end\n end", "def new\n @teacher = Teacher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def new\n @teacher = Teacher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def new\n @teacher = Teacher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teacher }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def new\n @person = Person.new\n @title = \"people\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @learn = Learn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @learn }\n end\n end", "def new\n @lr45 = Lr45.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr45 }\n end\n end", "def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lyric }\n end\n end", "def new\n @meant_it_rel = MeantItRel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @meant_it_rel }\n end\n end", "def new\n @crawler_article = CrawlerArticle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crawler_article }\n end\n end", "def new\n \n @personnel = Personnel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @personnel }\n end\n end", "def new\n @people = People.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @people }\n end\n end", "def new\n @adults_howyouknowu = AdultsHowyouknowu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adults_howyouknowu }\n end\n end", "def new\n @wrestler = Wrestler.new\n @teams = Team.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wrestler }\n end\n end", "def new\n @client_app = ClientApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @seed }\n end\n end", "def new\n @relatorios = Relatorio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatorios }\n end\n end", "def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hacker }\n end\n end", "def new\n submenu_item 'agents-new'\n @agent = Agent.new(:host_id => params[:host_id])\n dictionary\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @agent }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def new\n @learning_module = LearningModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @learning_module }\n end\n end", "def new\n @howto = Howto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @howto }\n end\n end", "def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @researcher }\n end\n end", "def new\n @technician = Technician.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @technician }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @vip_programmer_training }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def new\n @counterparty = Counterparty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @counterparty }\n end\n end", "def new\n @guide = Guide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @guide }\n end\n end", "def new\n @intelligence = Intelligence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @intelligence }\n end\n end", "def new\n @page_title = t('partners.new.title', :government_name => current_government.name)\n @partner = Partner.new\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @employeer = Employeer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @employeer }\n end\n end", "def new\n\t\t@clicker = Clicker.new\t\t\t\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @clicker }\n end\n end", "def new\n @recycling_site = RecyclingSite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recycling_site }\n end\n end", "def new\n @sitelink = Sitelink.new\n @sitelink.preferredpage = \"DEFAULT\"\n @preferredpages = Preferredpage.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sitelink }\n end\n end", "def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end", "def new\n @retain_node_selector = RetainNodeSelector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node_selector }\n end\n end", "def new\n @tutorial = Tutorial.new\n\t@title = \"New tutorial\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tutorial }\n end\n end", "def new\n @personal = Personal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @personal }\n end\n end", "def new\n @election = Election.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @election }\n end\n end", "def new\n @partyrole = Partyrole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partyrole }\n end\n end", "def new\n @selector_site = SelectorSite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @selector_site }\n end\n end", "def new\n @college = College.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @college }\n end\n end", "def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lease }\n end\n end", "def new\n @administrator = Administrator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrator }\n end\n end", "def new\n @administrator = Administrator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrator }\n end\n end", "def new\n @realtor = Realtor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @realtor }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end", "def new\n @lecture = Lecture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lecture }\n end\n end", "def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end", "def new\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @participant }\r\n end\r\n end", "def new\n @manual = Manual.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @manual }\n end\n end", "def new\n @attender = Attender.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attender }\n end\n end", "def new\n @lendable = Lendable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lendable }\n end\n end", "def new_rest\n @entry_answer = EntryAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_answer }\n end\n end", "def new\n @referral = Referral.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @referral }\n end\n end", "def new\n @referral = Referral.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @referral }\n end\n end", "def new\n @crew = Crew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crew }\n end\n end", "def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end", "def new\n @lr13 = Lr13.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr13 }\n end\n end" ]
[ "0.73440623", "0.7120477", "0.704073", "0.6972769", "0.6964356", "0.68110347", "0.67845285", "0.675575", "0.6717819", "0.66996443", "0.66921794", "0.6691826", "0.66797376", "0.6663254", "0.6658634", "0.66570395", "0.6641818", "0.6639715", "0.66185206", "0.6604964", "0.6600085", "0.6600085", "0.6586083", "0.65770864", "0.6565729", "0.65551764", "0.65535665", "0.65518403", "0.65342104", "0.65057856", "0.6503389", "0.6503389", "0.6503389", "0.65004194", "0.65004194", "0.65004194", "0.64982015", "0.6488872", "0.6485962", "0.64840955", "0.64762783", "0.64688224", "0.6468178", "0.6463663", "0.64508796", "0.6446979", "0.64449346", "0.6443662", "0.64366364", "0.6436247", "0.64357674", "0.64268696", "0.64194375", "0.6416629", "0.6412123", "0.6409092", "0.64078075", "0.6402449", "0.64014184", "0.6396988", "0.6390996", "0.6388322", "0.63836014", "0.6382169", "0.63772976", "0.63770336", "0.637285", "0.6372068", "0.6364508", "0.6362162", "0.6361014", "0.63582206", "0.6354269", "0.63446224", "0.63434446", "0.6342066", "0.6342066", "0.63357735", "0.63347197", "0.63347197", "0.63347197", "0.63347197", "0.63347197", "0.63347197", "0.63347197", "0.63347197", "0.63347197", "0.63347197", "0.63340175", "0.63320976", "0.6332029", "0.63315004", "0.63271326", "0.632656", "0.63255984", "0.63254523", "0.63254523", "0.6320223", "0.6314299", "0.63128144" ]
0.78264666
0
POST /portal/learners POST /portal/learners.xml
def create @portal_learner = Portal::Learner.new(params[:learner]) respond_to do |format| if @portal_learner.save flash[:notice] = 'Portal::Learner was successfully created.' format.html { redirect_to(@portal_learner) } format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner } else format.html { render :action => "new" } format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def new\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def set_learner\n @learner = Learner.find(params[:id])\n end", "def index\n @learners = Learner.all\n end", "def create\n relearnable = current_user.relearnables.new(relearnable_params)\n\n respond_to do |format|\n if relearnable.save\n format.html { redirect_to relearnable, notice: 'Relearnable was successfully created.' }\n format.json { render :show, status: :created, location: relearnable }\n else\n @relearnable = relearnable\n format.html { render :new }\n format.json { render json: relearnable.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @research = Research.new(params[:research])\n @research.legislator = current_legislator\n respond_to do |format|\n if @research.save\n flash[:notice] = 'Your research request has been submitted. Keep your eye on an email from White House 2 with updates on your request.'\n format.html { redirect_to(@research) }\n format.xml { render :xml => @research, :status => :created, :location => @research }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @research.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @portal_learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n if @portal_learner.update_attributes(params[:learner])\n flash[:notice] = 'Portal::Learner was successfully updated.'\n format.html { redirect_to(@portal_learner) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @learner = Learner.new(learner_params)\n\n respond_to do |format|\n if @learner.save\n format.html { head :created, content_type: \"text/html\" }\n format.json { head :created, location: @order }\n else\n format.html { head :bad_request, content_type: \"text/html\" }\n format.json { head :bad_request }\n end\n end\n end", "def create\n @question_learned = QuestionLearned.new(question_learned_params)\n\n respond_to do |format|\n if @question_learned.save\n format.html { redirect_to @question_learned, notice: 'Question learned was successfully created.' }\n format.json { render action: 'show', status: :created, location: @question_learned }\n else\n format.html { render action: 'new' }\n format.json { render json: @question_learned.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def index\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def create\n @researcher = Researcher.new(params[:researcher])\n\n respond_to do |format|\n if @researcher.save\n format.html { redirect_to(@researcher, :notice => 'Researcher was successfully created.') }\n format.xml { render :xml => @researcher, :status => :created, :location => @researcher }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @researcher.errors, :status => :unprocessable_entity }\n end\n end\n end", "def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def learner_params\n params.require(:learner).permit(:email, :first_name, :middle_name, :last_name, :phone_number, :company_name, :job_role, :certifications)\n end", "def create\n @offlearn = Offlearn.new(params[:offlearn])\n\n respond_to do |format|\n if @offlearn.save\n flash[:notice] = 'Offlearn was successfully created.'\n format.html { redirect_to(@offlearn) }\n format.xml { render :xml => @offlearn, :status => :created, :location => @offlearn }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @offlearn.errors, :status => :unprocessable_entity }\n end\n end\n end", "def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def multiple_choice_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\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 index\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n # PUNDIT_REVIEW_SCOPE\n # PUNDIT_CHECK_SCOPE (did not find instance)\n # @learners = policy_scope(Portal::Learner)\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portal_learners }\n end\n end", "def post\n frm.button(:name=>\"post\").click\n AssignmentsList.new(@browser)\n end", "def create\n @lek = Lek.new(params[:lek])\n\n respond_to do |format|\n if @lek.save\n format.html { redirect_to(@lek, :notice => 'Lek was successfully created.') }\n format.xml { render :xml => @lek, :status => :created, :location => @lek }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lek.errors, :status => :unprocessable_entity }\n end\n end\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 new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def create\n @rant = Rant.new(params[:rant])\n\n respond_to do |format|\n if @rant.save\n format.html { redirect_to(@rant, :notice => 'Rant was successfully created.') }\n format.xml { render :xml => @rant, :status => :created, :location => @rant }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def update\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n if @portal_learner.update_attributes(params[:learner])\n flash[:notice] = 'Portal::Learner was successfully updated.'\n format.html { redirect_to(@portal_learner) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n @portal_learner.periodic_bundle_logger = Dataservice::PeriodicBundleLogger.create!(:learner_id => @portal_learner.id) unless @portal_learner.periodic_bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render_learner_jnlp @portal_learner }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n bundle_get_url = dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle)\n if @portal_learner.student.user == current_visitor\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n if current_settings.use_periodic_bundle_uploading?\n bundle_get_url = dataservice_periodic_bundle_logger_url(@portal_learner.periodic_bundle_logger, :format => :bundle)\n bundle_post_url = nil\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => bundle_get_url,\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def create\n \"\"\"\n on save of researcher form, send the researcher's email \n and their current question number (0) to the researcher\n rankings controller\n \"\"\"\n @researcher = Researcher.new(researcher_params)\n\n respond_to do |format|\n\n if @researcher.save\n format.html { redirect_to controller: 'instruction', action: 'show', email: @researcher.email }\n\n format.json { render action: 'show', status: :created, location: @researcher }\n else\n format.html { render action: 'new' }\n format.json { render json: @researcher.errors, status: :unprocessable_entity }\n end\n end\n end", "def post\n frm.button(:value=>\"Post\").click\n AssignmentsList.new(@browser)\n end", "def create\n @practice = Practice.new(practice_params)\n if params[:recruiter_partner].present?\n @partner = Partner.find(params[:recruiter_partner])\n @practice.partners << @partner\n end\n\n @practice.site_id = @current_partner.site.id\n\n respond_to do |format|\n if @practice.save\n format.html { redirect_to partner_path(current_partner), 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 @learn_article = LearnArticle.new(learn_article_params)\n\n respond_to do |format|\n if @learn_article.save\n format.html { redirect_to @learn_article, notice: 'Learn article was successfully created.' }\n format.json { render :show, status: :created, location: @learn_article }\n else\n format.html { render :new }\n format.json { render json: @learn_article.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def create\n @partner_person = PartnerPerson.new(params[:partner_person])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.save\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully created.') }\n format.xml { render :xml => @partner_person, :status => :created, :location => @partner_person }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @teacher = Teacher.new(params[:teacher])\n\n respond_to do |format|\n if @teacher.save\n flash[:notice] = 'Teacher was successfully created.'\n format.html { redirect_to(teachers_path) }\n format.xml { render :xml => @teacher, :status => :created, :location => @teacher }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @teacher.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def create\n @researcher = Researcher.new(params[:researcher])\n\n respond_to do |format|\n if @researcher.save\n format.html { redirect_to @researcher, notice: 'Researcher was successfully created.' }\n format.json { render json: @researcher, status: :created, location: @researcher }\n else\n format.html { render action: \"new\" }\n format.json { render json: @researcher.errors, status: :unprocessable_entity }\n end\n end\n end", "def setup_portal_student\n learner = nil\n if current_user\n portal_student = current_user.portal_student\n # create a learner for the user if one doesn't exist\n learner = @offering.find_or_create_learner(portal_student)\n end\n learner\n end", "def create\n p'*'*800\n p params\n\n @trainer = Trainer.new(trainer_params)\n\n p @trainer\n\n if @trainer.save\n render json: @trainer, status: :created, location: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end", "def create!\n if @options[:id]\n @id = @options[:id]\n @model = TestChamber::Models::Partner.find(@id)\n else\n # The entire partners page has to render after a new partner is created\n # before we can proceed which takes a while.\n # Just submit the form with the rest client A dirty hack\n # but we create a lot of partners so it gets very slow.\n name = @company_name\n contact_name = 'John Smith'\n phone = '827-5309'\n\n\n if @use_ui\n visit \"#{TestChamber.target_url}/partners/new\"\n fill_in('partner[name]', :with => name)\n fill_in('partner[contact_name]', :with => contact_name)\n fill_in('partner[contact_phone]', :with => phone)\n select(\"United States\", :from => \"partner[country]\")\n\n Util.wait_for(5,1) { first('#partner_submit') }\n Util.trigger_click(first('#partner_submit')) do\n first('#partner_submit').nil?\n end\n else\n # yes, this is horrible, but it is VASTLY faster than using the browser to do this so when\n # we create lots of partners, like one before each test, we can use this.\n html = Nokogiri::HTML(authenticated_request(:get, \"dashboard/partners/new\", format: :html)[:body])\n\n begin\n authenticity_token = html.css(\"input[name=authenticity_token]\")[0][\"value\"]\n rescue\n # Sometimes the authenticity token doesn't exist; we need to catch that situation.\n # Usually due to a redirect to the login page because user auth is not working 100% of the time.\n # Raising makes this more visible.\n raise \"Didn't have the authenticity token. Html: #{html}\"\n end\n\n submit_form_with_rest(action: \"#{TestChamber.target_url}/dashboard/partners\",\n params: {'partner[name]' => name,\n 'partner[contact_name]' => contact_name,\n 'partner[contact_phone]' => phone,\n 'partner[country]' => \"US\",\n 'utf8' => \"✓\",\n 'authenticity_token' => authenticity_token,\n 'commit' => \"Create Partner\"\n },\n expected_redirect: \"#{TestChamber.target_url}/dashboard/partners\")\n end\n\n Util.wait_for(TestChamber.default_wait_for_timeout,\n TestChamber.default_wait_for_interval,\n {:partner_name => @company_name, :options => @options}) do\n @model = TestChamber::Models::Partner.where(:name => @company_name).order(:created_at => :desc).first\n end\n\n @id = @model.id\n TestChamber.created_partners << @id\n\n # Set reseller_id manually since no reliable way to set via UI.\n set_reseller\n\n configure_partner\n approve_partner\n # cache_object\n\n verify_partner\n end\n end", "def create\n @trainer = Trainer.new(params[:trainer])\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, :notice => 'Trainer was successfully created.' }\n format.json { render :json => @trainer, :status => :created, :location => @trainer }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trainer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def open_response_report\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def create\n @kennel = Kennel.new(params[:kennel])\n\n respond_to do |format|\n if @kennel.save\n flash[:notice] = 'Kennel was successfully created.'\n format.html { redirect_to(@kennel) }\n format.xml { render :xml => @kennel, :status => :created, :location => @kennel }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @kennel.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @leader = Leader.new(leader_params)\n\n respond_to do |format|\n if @leader.save\n format.html { redirect_to departments_url, notice: \"Leader was successfully created.\" }\n format.json { render :show, status: :created, location: @leader }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @leader.errors, status: :unprocessable_entity }\n end\n end\n end", "def attend\n user_id = current_user.id\n training_id = params[:id]\n TrainingRecord.create_new_record user_id, training_id\n redirect_to @training, notice: \"You have successfully registered for #{@training.title}\"\n end", "def create\n @reviewer = Reviewer.new(params[:reviewer])\n\n respond_to do |format|\n if @reviewer.save\n format.html { redirect_to(@reviewer, :notice => 'Reviewer was successfully created.') }\n format.xml { render :xml => @reviewer, :status => :created, :location => @reviewer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @reviewer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_assignment(name)\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/assignments\"\n puts \"@url is #{@url}\"\n\n @payload={'assignment': { \n 'name': name,\n 'points_possible': '0',\n 'grading_type': 'pass_fail',\n 'published': 'true',\n 'submission_types': [ \"none\" ]\n }\n }\n\n @postResponse = HTTParty.post(@url, :body => @payload.to_json, :headers => $header )\n puts(\" POST to create assignment has Response.code #{@postResponse.code} and postResponse is #{@postRepsone}\")\nend", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def new\n @teaching_route = TeachingRoute.new\n @names = Person.selectionList\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @teaching_route }\n end\n end", "def create\n @trainer = Trainer.new(params[:trainer])\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, notice: 'Trainer was successfully created.' }\n format.json { render json: @trainer, status: :created, location: @trainer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @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 @engineer = Engineer.new(engineer_params)\n r = Rentee.find(params[:rentee_id])\n @engineer.rentee = r\n if @engineer.save\n end\n\n respond_to do |format|\n if @engineer.save\n format.html { redirect_to [@engineer.rentee, @engineer], notice: 'Engineer was successfully created.' }\n format.json { render :show, status: :created, location: @engineer }\n else\n format.html { render :new }\n format.json { render json: @engineer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @partner_person = PartnerPerson.new\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partner_person }\n end\n end", "def create\n @trainer = Trainer.new(trainer_params)\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, notice: 'Trainer was successfully created.' }\n format.json { render :show, status: :created, location: @trainer }\n else\n format.html { render :new }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trainer = Trainer.new(trainer_params)\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, notice: 'Trainer was successfully created.' }\n format.json { render :show, status: :created, location: @trainer }\n else\n format.html { render :new }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @differentiator_answer = DifferentiatorAnswer.new(params[:differentiator_answer])\n @differentiator_questions = DifferentiatorQuestion.find :all\n @employers = Employer.find :all\n @users = User.find :all\n @job_postings = JobPosting.find :all\n respond_to do |format|\n if @differentiator_answer.save\n flash[:notice] = 'DifferentiatorAnswer was successfully created.'\n format.html { redirect_to(@differentiator_answer) }\n format.xml { render :xml => @differentiator_answer, :status => :created, :location => @differentiator_answer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @differentiator_answer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @learnwordlist = Learnwordlist.new(learnwordlist_params)\n\n respond_to do |format|\n if @learnwordlist.save\n format.html { redirect_to @learnwordlist, notice: 'Learnwordlist was successfully created.' }\n format.json { render :show, status: :created, location: @learnwordlist }\n else\n format.html { render :new }\n format.json { render json: @learnwordlist.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_create_lead\n client.expects(:request).with(:post, 'https://api.com/rest/sites/site-123/leads',\n '{\"email\":\"lead@gmail.com\"}', nil)\n\n client.create_lead(\"site-123\", {email: \"lead@gmail.com\"})\n end", "def create\n @paper = Paper.new(paper_params)\n\t respond_to do |format|\n if @paper.save\n filename = @paper.userdoc.path \n puts filename \n response = RestClient.post('http://maui-indexer.appspot.com/mauiapp',\n :document => File.new(filename,\"rb\"),\n :domain => \"keywords\")\n doc = Nokogiri::HTML(response)\n keywords = \"\"\n doc.css(\"#keywords a\").each do |k|\n keywords << k << ' '\n end\n puts keywords \n textfile = `pdftotext #{filename} -`\n ref =[]\n #textfile.reverse_each do|s|\n #if s.upcase == \"REFERENCES\\n\"\n #break\n #end\n #ref << s\n #end\n #ref.reverse_each do |s|\n # puts s\n #end\n url = \"http://wikipedia-miner.cms.waikato.ac.nz/services/wikify?source=\" + URI::encode(keywords.force_encoding('ASCII-8BIT')) + \"&minProbability=0.1\"\n doc = Nokogiri::XML(open(url))\n topics = []\n doc.css(\"detectedTopic\").each do |t|\n puts t\n topics << t[:title]<<t[:weight] \n end\n puts topics\n @paper.keywords = keywords\n @paper.topics = topics\n\nkeywords.gsub!(\" \",\"%20\")\nkeywords = keywords.chomp('+')\nurl = \"https://api.mendeley.com:443/search/catalog?query=\"+keywords+\"&view=all&limit=100\"\nhtml = open(url, \"Authorization\" => \"Bearer #{session[:mendeley_token]}\").read\ndocs = JSON.parse(html)\nsession = Neo4j::Session.open(:server_db, 'http://localhost:7474')\n\ndocs.each do |d|\n puts \"ID: \" + d[\"id\"]\n authors = [] \n begin\n d[\"authors\"].each do |a|\n authors << a[\"first_name\"] + \" \" + a[\"last_name\"]\n end\n rescue \n authors = []\n end\n docnode = Neo4j::Node.create({id: d[\"id\"], title: d[\"title\"], type: d[\"type\"], authors: authors, year: d[\"year\"], month: d[\"month\"], day: d[\"day\"], source: d[\"source\"], keywords: d[\"keywords\"], accessed: d[\"accessed\"], reader_count: d[\"reader_count\"], abstract: d[\"abstract\"]}, :PAPER)\n begin\n reader_count_by_academic_status = []\n d[\"reader_count_by_academic_status\"].each do |key, value|\n docnode[key.to_sym] = value\n reader_count_by_academic_status << key\n end\n docnode[:reader_count_by_academic_status] = reader_count_by_academic_status\n rescue\n #academic status details not found\n end\n\n begin \n reader_count_by_country =[]\n d[\"reader_count_by_country\"].each do |key, value|\n docnode[key.to_sym] = value\n reader_count_by_country << key\n end\n docnode[:reader_count_by_country] = reader_count_by_country\n rescue\n #country details not found \n end\n begin\n reader_count_by_subdiscipline = []\n d[\"reader_count_by_subdiscipline\"].each do |key,value|\n docnode[key.to_sym] = value.values.inject(:+)\n reader_count_by_subdiscipline << key\n end\n docnode[:reader_count_by_subdiscipline] = reader_count_by_subdiscipline\n rescue\n #subdiscipline details not found \n end\nend\n\n\n # puts `ruby ~/rails_project/maui_rest.rb \"#{@paper.userdoc.path}\"`\n @paper.save \n format.html { redirect_to @paper, notice: 'Paper was successfully created.' }\n format.json { render :show, status: :created, location: @paper }\n else\n format.html { render :new }\n format.json { render json: @paper.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @learner.update(learner_params)\n format.html { redirect_to @learner, notice: 'Learner was successfully updated.' }\n format.json { head :ok, location: @learner }\n else\n format.html { render :edit }\n format.json { render json: @learner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @evaluation = Evaluation.new(params[:evaluation])\r\n @answers = @evaluation.responses\r\n\r\n respond_to do |format|\r\n if @evaluation.save && @answers.each{|a| a.save }.all?\r\n format.html { redirect_to(@evaluation, :notice => 'Evaluation was successfully created.') }\r\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @installation = Installation.find(params[:installation_id])\n @learn = Learn.new(params[:learn])\n respond_to do |format|\n if @learn.save\n flash[:notice] = 'Learn was successfully created.'\n format.html { redirect_to :back}\n format.xml { render :xml => @learn, :status => :created, :location => @learn }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @learn.errors, :status => :unprocessable_entity }\n end\n end\n end", "def validator_captive_portal(args = {}) \n post(\"/profiles.json/captiveportal/\", args)\nend", "def create\n @expert_writer = ExpertWriter.new(expert_writer_params)\n\n respond_to do |format|\n if @expert_writer.save\n format.html { redirect_to @expert_writer, notice: 'Expert writer was successfully created.' }\n format.json { render :show, status: :created, location: @expert_writer }\n else\n format.html { render :new }\n format.json { render json: @expert_writer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end", "def show\n @portal_learner = Portal::Learner.find(params[:id])\n \n @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger\n @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger\n \n respond_to do |format|\n format.html # show.html.erb\n format.jnlp { render :partial => 'shared/learn',\n :locals => { :runnable => @portal_learner.offering.runnable, :learner => @portal_learner } }\n format.config { \n # if this isn't the learner then it is launched read only\n properties = {}\n if @portal_learner.student.user == current_user\n if @portal_learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested],\n :event_details => \"Activity configuration loaded. Loading prior learner session data...\",\n :bundle_content => @portal_learner.bundle_logger.in_progress_bundle\n )\n end\n bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle)\n else\n bundle_post_url = nil\n properties['otrunk.view.user_data_warning'] = 'true'\n end\n render :partial => 'shared/sail',\n :locals => { \n :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id),\n :session_id => (params[:session] || request.env[\"rack.session.options\"][:id]),\n :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle),\n :bundle_url => dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle),\n :bundle_post_url => bundle_post_url,\n :properties => properties\n }\n }\n format.xml { render :xml => @portal_learner }\n end\n end", "def new\n @kennel = Kennel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kennel }\n end\n end", "def create_rest\n @entry_answer = EntryAnswer.new(params[:entry_answer])\n\n respond_to do |format|\n if @entry_answer.save\n flash[:notice] = 'EntryAnswer was successfully created.'\n format.html { redirect_to(@entry_answer) }\n format.xml { render :xml => @entry_answer, :status => :created, :location => @entry_answer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_answer.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[: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 @offlearn = Offlearn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offlearn }\n end\n end", "def bundle_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.find(params[:id])\n \n respond_to do |format|\n format.html # report.html.haml\n end\n end", "def create\n @adults_howyouknowu = AdultsHowyouknowu.new(params[:adults_howyouknowu])\n\n respond_to do |format|\n if @adults_howyouknowu.save\n format.html { redirect_to(@adults_howyouknowu, :notice => 'Adults howyouknowu was successfully created.') }\n format.xml { render :xml => @adults_howyouknowu, :status => :created, :location => @adults_howyouknowu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adults_howyouknowu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\r\n @reviewId = params[:review_id]\r\n @review = Review.find(@reviewId)\r\n \r\n @reviewer = TeamMember.find_by_name('Eric Peterson')\r\n\r\n @reviewee_name = @review.TeamMember.name\r\n @reviewer_name = @reviewer.name\r\n\r\n @evaluation = Evaluation.new\r\n @evaluation.Review = @review\r\n @evaluation.TeamMember = @reviewer\r\n\r\n @questions = Question.all\r\n @answers = @questions.compact.map { |q|\r\n @r = Response.new\r\n @r.Evaluation = @evaluation\r\n @r.Question = q\r\n @r.Answer = Answer.new\r\n\r\n @r\r\n }\r\n\r\n @evaluation.answer_set = @answers\r\n \r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\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\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 create\n @leader = User.find(params[:user_id])\n @leader.user_followers.create(:follower_id => current_user.id)\n\n saved = @leader.save\n respond_to do |format|\n if saved\n flash[:notice] = 'You are now following '.concat(@leader.login)\n end\n format.html { redirect_to user_tweets_path(@leader) }\n if saved\n format.xml { render :xml => @leader, :status => :created, :location => @leaders }\n else\n format.xml { render :xml => @leader.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @story_teller = StoryTeller.new(story_teller_params)\n\n respond_to do |format|\n if @story_teller.save\n format.html { redirect_to @story_teller, notice: 'Story teller was successfully created.' }\n format.json { render :show, status: :created, location: @story_teller }\n else\n format.html { render :new }\n format.json { render json: @story_teller.errors, status: :unprocessable_entity }\n end\n end\n end", "def external_report_learners_from_jwt\n authorize Portal::PermissionForm\n\n # Empty hashes and arrays are removed from param list now\n # see: https://github.com/rails/rails/issues/26569\n query = params[\"query\"] || {}\n page_size = params[\"page_size\"].to_i\n search_after = params[\"search_after\"] || nil\n endpoint_only = params[\"endpoint_only\"] || false\n\n if (page_size == nil || page_size < 1)\n return error \"param page_size must be a positive number\", 400\n elsif (page_size > 5000)\n return error \"param page_size may not be larger than 5000\", 400\n end\n\n query[:size_limit] = page_size\n\n learners = []\n # endpoint_only doesn't include all the learner data, just the remote endpoint.\n # should result in a faster response. Used for learner logs usually.\n if endpoint_only\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :endpoint_only,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map do |l|\n {\n learner_id: l.learner_id,\n run_remote_endpoint: l.remote_endpoint_url,\n runnable_url: l.runnable_url\n }\n end\n # Response should include learner metadata (names, schools, email ...)\n else\n learner_selector = Report::Learner::Selector.new(query, current_user, {\n learner_type: :elasticsearch,\n search_after: search_after\n })\n learners = learner_selector.es_learners.map {|l| self.class.detailed_learner_info l}\n end\n response = {\n json: {\n version: \"1\",\n learners: learners,\n lastHitSortValue: learner_selector.last_hit_sort_value\n }\n }\n render json: response.to_json\n end", "def create\n @pt_trainer = Pt::Trainer.new(pt_trainer_params)\n\n respond_to do |format|\n if @pt_trainer.save\n format.html { redirect_to @pt_trainer, notice: 'Trainer was successfully created.' }\n format.json { render :show, status: :created, location: @pt_trainer }\n else\n format.html { render :new }\n format.json { render json: @pt_trainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def create\n @teacher = Teacher.new(params[:teacher])\n\n respond_to do |format|\n if @teacher.save\n format.html { redirect_to(@teacher, :notice => 'Profesor creado con éxito.') }\n format.xml { render :xml => @teacher, :status => :created, :location => @teacher }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @teacher.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_question_learned\n @question_learned = QuestionLearned.find(params[:id])\n end", "def create\n @trainer = Trainer.new(trainer_params)\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, notice: 'Trener został pomyslnie dodany' }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def create\n @listener = Listener.new(params[:listener])\n\n respond_to do |format|\n if @listener.save\n flash[:notice] = 'Listener was successfully created.'\n format.html { redirect_to(@listener) }\n format.xml { render :xml => @listener, :status => :created, :location => @listener }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @listener.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @expert = Expert.new(expert_params)\n\n respond_to do |format|\n if @expert.save\n format.html { redirect_to @expert, notice: 'Expert was successfully created.' }\n format.json { render :show, status: :created, location: @expert }\n else\n format.html { render :new }\n format.json { render json: @expert.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", "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 offers \n @host.offers.create(offer_params) if request.post?\n @offers = @host.offers\n end", "def create\n @expertise = Expertise.new(expertise_params)\n\n if @expertise.save\n render json: @expertise, status: :created, location: @expertise\n else\n render json: @expertise.errors, status: :unprocessable_entity\n end\n end", "def create\n @reagent_list = ReagentList.new(reagent_list_params)\n\n respond_to do |format|\n if @reagent_list.save\n if params[:program_id] != nil\n @analyte.reagent_list_id = @reagent_list.id\n @analyte.save\n format.html { redirect_to program_analyte_reagent_list_path(@program, @analyte, @reagent_list), notice: 'Reagent list was successfully created.' }\n format.json { render :show, status: :created, location: [@program, @analyte, @reagent_list] }\n else\n format.html { redirect_to reagent_list_path(@reagent_list), notice: 'Reagent list was successfully created.' }\n format.json { render :show, status: :created, location: @reagent_list }\n end\n else\n format.html { render :new }\n format.json { render json: @reagent_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_trainer\n\tend", "def new\n @trainer = Trainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trainer }\n end\n end", "def create\n @agent = Agent.new(agent_params)\n creat_agentlanguage(@agent)\n respond_to do |format|\n if @agent.save\n format.html { redirect_to @agent, notice: 'Agent was successfully created.' }\n format.json { render action: 'show', status: :created, location: @agent}\n else\n format.html { render action: 'new' }\n format.json { render json: @agent.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partner = Partner.new(params[:partner])\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'Partner was successfully created.' }\n format.json { render json: @partner, status: :created, location: @partner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @response = Response.find(params[:response_id])\n @request_selection = @response.create_request_selection(params[:request_selection])\n #@reward = @request_selection.create_reward(params[:reward])\n \n respond_to do |format|\n if @request_selection.save\n \n format.html { redirect_to _my_requests_path }\n format.json { render json: @request_selection, status: :created, location: @request_selection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @request_selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @rant = Rant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rant }\n end\n end", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @partners.to_xml }\n end\n end", "def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @researcher }\n end\n end", "def create\n return\n teacher = Teacher.find_by_name(params[:teacher])\n user = User.new(:username => params[:username])\n\n teacher.users << user\n \n user.record_exam(params)\n\n respond_to do |format|\n format.html { render :status => 200, :text => 'done' }\n end\n end" ]
[ "0.6938103", "0.6385076", "0.6179851", "0.59332085", "0.5912572", "0.59061766", "0.5651073", "0.56488985", "0.5646559", "0.55446005", "0.5529626", "0.5484558", "0.5480279", "0.5458917", "0.54394794", "0.5380092", "0.53788173", "0.5377595", "0.5368053", "0.5321442", "0.5303776", "0.52622724", "0.5248039", "0.5240232", "0.52312875", "0.52263767", "0.5224056", "0.5210289", "0.5199402", "0.5198988", "0.5190004", "0.51845795", "0.517943", "0.5170788", "0.5170041", "0.51581055", "0.5136238", "0.5133328", "0.51321906", "0.51319367", "0.5125157", "0.5112728", "0.5108705", "0.508341", "0.5083381", "0.50803375", "0.5077668", "0.5072639", "0.5072639", "0.5070316", "0.5048555", "0.50409496", "0.50378364", "0.5034673", "0.5034673", "0.502656", "0.49941766", "0.49932358", "0.49910036", "0.49876696", "0.49869642", "0.49820703", "0.49724862", "0.49694133", "0.49648803", "0.49522594", "0.4946911", "0.4944923", "0.4939334", "0.493899", "0.49319533", "0.4925421", "0.49236587", "0.49236137", "0.49141923", "0.49100646", "0.4909488", "0.49016458", "0.48964635", "0.4895009", "0.4880216", "0.48799786", "0.4878292", "0.48776904", "0.48775077", "0.48730686", "0.487115", "0.48706502", "0.486863", "0.48614264", "0.48597994", "0.4857539", "0.48546016", "0.48530957", "0.48530957", "0.48530486", "0.48507935", "0.48493195", "0.48488912", "0.48474923" ]
0.7061077
0
PUT /portal/learners/1 PUT /portal/learners/1.xml
def update @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| if @portal_learner.update_attributes(params[:learner]) flash[:notice] = 'Portal::Learner was successfully updated.' format.html { redirect_to(@portal_learner) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n if @portal_learner.update_attributes(params[:learner])\n flash[:notice] = 'Portal::Learner was successfully updated.'\n format.html { redirect_to(@portal_learner) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @learner.update(learner_params)\n format.html { redirect_to @learner, notice: 'Learner was successfully updated.' }\n format.json { head :ok, location: @learner }\n else\n format.html { render :edit }\n format.json { render json: @learner.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_learner\n @learner = Learner.find(params[:id])\n end", "def update\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n if @learn.update_attributes(params[:learn])\n flash[:notice] = 'Learn was successfully updated.'\n format.html { redirect_to(@learn) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @learn.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @offlearn = Offlearn.find(params[:id])\n\n respond_to do |format|\n if @offlearn.update_attributes(params[:offlearn])\n flash[:notice] = 'Offlearn was successfully updated.'\n format.html { redirect_to(@offlearn) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @offlearn.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 create\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def update\n @researcher = Researcher.find(params[:id])\n\n respond_to do |format|\n if @researcher.update_attributes(params[:researcher])\n format.html { redirect_to(researchers_url, :notice => 'Researcher was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @researcher.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @partner_person = PartnerPerson.find(params[:id])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.update_attributes(params[:partner_person])\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def create\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end", "def new\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def update\n @trainer = Trainer.find(params[:id])\n\n if @trainer.update(trainer_params)\n head :no_content\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @question_learned.update(question_learned_params)\n format.html { redirect_to @question_learned, notice: 'Question learned was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question_learned.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_learn_article\n @learn_article = LearnArticle.find(params[:id])\n end", "def update\n update_resource_response(@headline, headline_params)\n end", "def update\n respond_to do |format|\n if @learn_article.update(learn_article_params)\n format.html { redirect_to @learn_article, notice: 'Learn article was successfully updated.' }\n format.json { render :show, status: :ok, location: @learn_article }\n else\n format.html { render :edit }\n format.json { render json: @learn_article.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_api_definition_file\n if @research_tool.update(research_tool_params)\n redirect_to [:api_definition, :admin, @research_tool], notice: 'Research Tool was successfully updated.'\n else\n render :api_definition\n end\n end", "def update\n @researcher = Researcher.find(params[:id])\n\n respond_to do |format|\n if @researcher.update_attributes(params[:researcher])\n format.html { redirect_to @researcher, notice: 'Researcher was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @researcher.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateArticle id,params = {}\n \n APICall(path: \"help_center/articles/#{id}.json\",method: 'PUT',payload: params.to_json)\n \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 test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def update\n @rant = Rant.find(params[:id])\n\n respond_to do |format|\n if @rant.update_attributes(params[:rant])\n format.html { redirect_to(@rant, :notice => 'Rant was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @trainer = Trainer.find(params[:id])\n\n respond_to do |format|\n if @trainer.update_attributes(params[:trainer])\n format.html { redirect_to @trainer, :notice => 'Trainer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @trainer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end", "def update\n @trainer = Trainer.find(params[:id])\n\n respond_to do |format|\n if @trainer.update_attributes(params[:trainer])\n format.html { redirect_to @trainer, notice: 'Trainer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @official_tenure = OfficialTenure.find(params[:id])\n\n respond_to do |format|\n if @official_tenure.update_attributes(params[:official_tenure])\n format.html { redirect_to @official_tenure, notice: 'Official tenure was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @official_tenure.errors, status: :unprocessable_entity }\n end\n end\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_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @wrestler = Wrestler.find(params[:id])\n\n respond_to do |format|\n if @wrestler.update_attributes(params[:wrestler])\n format.html { redirect_to(@wrestler, :notice => 'Wrestler was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @wrestler.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n if @leader.update_attributes(params[:leader])\n format.html { redirect_to @leader, notice: 'Leader was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leader.errors, status: :unprocessable_entity }\n end\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 @relearnable.update(relearnable_params)\n format.html { redirect_to @relearnable, notice: 'Relearnable was successfully updated.' }\n format.json { render :show, status: :ok, location: @relearnable }\n else\n format.html { render :edit }\n format.json { render json: @relearnable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reviewer = Reviewer.find(params[:id])\n\n respond_to do |format|\n if @reviewer.update_attributes(params[:reviewer])\n format.html { redirect_to(@reviewer, :notice => 'Reviewer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @reviewer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollement.update(enrollement_params)\n format.html { redirect_to @enrollement, notice: \"Enrollement was successfully updated.\" }\n format.json { render :show, status: :ok, location: @enrollement }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @enrollement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lek = Lek.find(params[:id])\n\n respond_to do |format|\n if @lek.update_attributes(params[:lek])\n format.html { redirect_to(@lek, :notice => 'Lek was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lek.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params.permit!\n @employeer = Employeer.find(params[:id])\n\n respond_to do |format|\n if @employeer.update_attributes(params[:employeer])\n format.html { redirect_to(@employeer, :notice => 'Employeer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @employeer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update\n # this action is not provided for partyroles\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 @portal = Portal.find(params[:id])\n\n respond_to do |format|\n if @portal.update_attributes(params[:portal])\n flash[:notice] = 'Portal was successfully updated.'\n format.html { redirect_to(@portal) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @portal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agent = Agent.find(params[:id])\n\n respond_to do |format|\n if @agent.update_attributes(params[:agent])\n format.html { redirect_to(@agent, :notice => 'Agent was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @agent.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end", "def update\n @adults_howyouknowu = AdultsHowyouknowu.find(params[:id])\n\n respond_to do |format|\n if @adults_howyouknowu.update_attributes(params[:adults_howyouknowu])\n format.html { redirect_to(@adults_howyouknowu, :notice => 'Adults howyouknowu was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @adults_howyouknowu.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 @intelligence = Intelligence.find(params[:id])\n\n respond_to do |format|\n if @intelligence.update_attributes(params[:intelligence])\n flash[:notice] = 'Intelligence was successfully updated.'\n format.html { redirect_to(intelligences_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @intelligence.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n if @lore.update_attributes(params[:lore])\n format.html { redirect_to(@lore, :notice => 'Lore was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lore.errors, :status => :unprocessable_entity }\n end\n end\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def solveticket(assigneeid, ticketidxml)\n\n raise ArgumentError.new(\"no assignee is present\") if assigneeid.empty?\n raise ArgumentError.new(\"ticketid is present text provided\") if ticketidxml.empty?\n\n xml = createsolvedticketxml(assigneeid)\n\n begin\n resource = RestClient::Resource.new @hostname, @username, @password\n url = 'tickets/'+ ticketidxml\n httpresponse = resource[url].put xml.to_s, :content_type => 'application/xml', :accept => '*/*'\n processresponse(httpresponse) # call success handler\n rescue => e\n processerror(e) # call error handler\n end\n\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @knowledge_point = KnowledgePoint.find(params[:id])\n\n respond_to do |format|\n if @knowledge_point.update_attributes(params[:knowledge_point])\n format.html { redirect_to @knowledge_point, :notice => 'Knowledge point was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @knowledge_point.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_learner_info(learner_id, learner_info, opts = {})\n update_learner_info_with_http_info(learner_id, learner_info, opts)\n nil\n end", "def update\n @role = Role.find_by_name(params[:name])\n \n respond_to do |format|\n @role.authorities = Authority.find_by_name(params[:authority_names])\n format.html { redirect_to(my_gem_role_path(@role.name),\n :notice => 'Role was successfully updated.') }\n format.xml { head :ok }\n end\n end", "def update\n update_resource @ride, ride_params\n end", "def update\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n if @trial.update_attributes(params[:trial])\n flash[:notice] = 'Trial was successfully updated.'\n format.html { redirect_to(@trial) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n if @taker.update_attributes(params[:taker])\n format.html { redirect_to @taker, notice: 'Taker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taker.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @elector = Elector.find(params[:id])\n\n if @elector.update(elector_params)\n head :no_content\n else\n render json: @elector.errors, status: :unprocessable_entity\n end\n end", "def update\n @tool = Tool.find(params[:id])\n @user = current_user\n @tool.user_id = @user.id\n @user.tools << @tool\n\n respond_to do |format|\n if @tool.update_attributes(params[:tool])\n format.html { redirect_to @tool, notice: 'Tool was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end", "def update\n @agent = Agent.find(params[:id])\n params.delete :username\n params.delete :name\n params.delete :password\n\n respond_to do |format|\n if @agent.update_attributes(params[:agent])\n Rosteruser.update_all({:nick => @agent.name}, {:jid => \"#{@agent.username}@agent.monit.cn\"})\n flash[:notice] = \"#{@agent.name}更新成功\"\n format.html { redirect_to(@agent) }\n format.xml { head :ok }\n else\n dictionary\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @agent.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @kennel = Kennel.find(params[:id])\n\n respond_to do |format|\n if @kennel.update_attributes(params[:kennel])\n flash[:notice] = 'Kennel was successfully updated.'\n format.html { redirect_to(@kennel) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @kennel.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n resource_path = \"/projects/#{project_id}/people/#{id}\"\n Request.put(resource_path, self.to_xml('person'))\n end", "def update\n @leye = Leye.find(params[:id])\n\n respond_to do |format|\n if @leye.update_attributes(params[:leye])\n format.html { redirect_to @leye, notice: 'Leye was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leye.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @employee_remunerative_concept = @employee.employee_emunerative_concept.find(params[:id])\n\n respond_to do |format|\n if @employee_remunerative_concept.update_attributes(params[:employee_remunerative_concept])\n format.html { redirect_to([@employee,@employee_remunerative_concept], :notice => 'Employee remunerative concept was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @employee_remunerative_concept.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @learners = Learner.all\n end", "def update\n @agent = Agent.find(params[:id])\n @agent.save!\n respond_to do |format|\n if @agent.update_attributes(params[:agent])\n flash[:notice] = 'Agent was successfully updated.'\n format.html { redirect_to(@agent) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => agent.errors, :status => :unprocessable_entity }\n end\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def update\n @meant_it_rel = MeantItRel.find(params[:id])\n\n respond_to do |format|\n if @meant_it_rel.update_attributes(params[:meant_it_rel])\n format.html { redirect_to(@meant_it_rel, :notice => 'Meant it rel was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meant_it_rel.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @helocagree = Helocagree.find(params[:id])\n\n respond_to do |format|\n if @helocagree.update_attributes(params[:helocagree])\n flash[:notice] = 'Helocagree was successfully updated.'\n format.html { redirect_to(@helocagree) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @helocagree.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @kennel_litter = KennelLitter.find(params[:id])\n\n respond_to do |format|\n if @kennel_litter.update_attributes(params[:kennel_litter])\n format.html { redirect_to @kennel_litter, notice: 'Kennel litter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kennel_litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_question_learned\n @question_learned = QuestionLearned.find(params[:id])\n end", "def update_rest\n @answer_localized = AnswerLocalized.find(params[:id])\n\n respond_to do |format|\n if @answer_localized.update_attributes(params[:answer_localized])\n flash[:notice] = 'AnswerLocalized was successfully updated.'\n format.html { redirect_to(@answer_localized) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer_localized.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @research = Research.find(params[:id])\n\n respond_to do |format|\n if @research.update_attributes(params[:research])\n format.html { redirect_to @research, notice: 'Research was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @research.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_learnwordlist\n @learnwordlist = Learnwordlist.find(params[:id])\n end", "def update\n @bottle = Bottle.find(params[:id])\n\n respond_to do |format|\n if @bottle.update_attributes(params[:bottle])\n format.html { redirect_to(@bottle, :notice => 'Bottle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bottle.errors, :status => :unprocessable_entity }\n end\n end\n end", "def offer\n @offer = @host.offers.find(params[:id])\n @offer.update(offer_params) if request.put?\n redirect_to offers_host_path if request.put?\n end", "def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end", "def update\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n\n respond_to do |format|\n if @education.update_attributes(params[:education])\n format.html { redirect_to(@education, :notice => 'Education was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @guide = Guide.find(params[:id])\n\n respond_to do |format|\n if @guide.update_attributes(params[:guide])\n flash[:notice] = 'Guide was successfully updated.'\n format.html { redirect_to(@guide) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @guide.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n user = demo? ? demo_user : current_user\n @resume = user.resumes.find(params[:id])\n @resume.update_count += 1\n\n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n format.html { \n redirect_to(html_resume_path(@resume), :notice => 'updated') \n }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @manual = Manual.find(params[:id])\n\n respond_to do |format|\n if @manual.update_attributes(params[:manual])\n format.html { redirect_to(@manual, :notice => 'Manual was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @manual.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @technician = Technician.find(params[:id])\n\n respond_to do |format|\n if @technician.update_attributes(params[:technician])\n format.html { redirect_to(@technician, :notice => 'Technician was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @technician.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_leadership\n @leadership = Leadership.find(params[:id])\n end", "def update\n @role = @client.roles.find(params[:id])\n\n respond_to do |format|\n if @role.update_attributes(params[:role])\n flash[:notice] = 'Role was successfully updated.'\n format.html { redirect_to client_role_url(@client, @role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tool = Tool.find(params[:id])\n\n respond_to do |format|\n if @tool.update_attributes(params[:tool])\n format.html { redirect_to @tool, notice: 'Tool was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @teacher = Teacher.find(params[:id])\n\n respond_to do |format|\n if @teacher.update_attributes(params[:teacher])\n flash[:notice] = 'Teacher was successfully updated.'\n format.html { redirect_to(teachers_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @teacher.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @election = Election.find(params[:id])\n\n respond_to do |format|\n if @election.update_attributes(params[:election])\n flash[:notice] = 'Election was successfully updated.'\n format.html { redirect_to(@election) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @election.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @models = self.class.model_class.find(params[:id])\n\n respond_to do |format|\n if @models.update_attributes(params[:partners])\n flash[:notice] = 'Partners was successfully updated.'\n format.html { redirect_to(@models) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @models.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @story_teller.update(story_teller_params)\n format.html { redirect_to @story_teller, notice: 'Story teller was successfully updated.' }\n format.json { render :show, status: :ok, location: @story_teller }\n else\n format.html { render :edit }\n format.json { render json: @story_teller.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @knowledge = current_user.knowledges.find(params[:id])\n\n respond_to do |format|\n if @knowledge.update_attributes(params[:knowledge])\n format.html { redirect_to @knowledge, notice: 'Knowledge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @knowledge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @technique_type = TechniqueType.find(params[:id])\n\n respond_to do |format|\n if @technique_type.update_attributes(params[:technique_type])\n format.html { redirect_to(@technique_type, :notice => 'Technique type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @technique_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @refferalmaster = Refferalmaster.find(params[:id])\n\n respond_to do |format|\n if @refferalmaster.update_attributes(params[:refferalmaster])\n format.html { redirect_to(@refferalmaster, :notice => 'Refferalmaster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @refferalmaster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n expire_one(params[:id])\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to([:admin, @article], :notice => 'Article was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @person_verse = PersonVerse.find(params[:id])\n\n respond_to do |format|\n if @person_verse.update_attributes(params[:person_verse])\n flash[:notice] = 'PersonVerse was successfully updated.'\n format.html { redirect_to(@person_verse) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\", :layout => \"main\" }\n format.xml { render :xml => @person_verse.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.66387635", "0.63641405", "0.61911106", "0.6068104", "0.58350945", "0.5793474", "0.5713103", "0.56420976", "0.5604703", "0.5587539", "0.5583807", "0.55471885", "0.55346245", "0.5482316", "0.5470577", "0.5464942", "0.5450375", "0.5440535", "0.5422126", "0.53941256", "0.53704065", "0.535923", "0.5345016", "0.53449655", "0.5337575", "0.5324952", "0.5319918", "0.5312323", "0.5308189", "0.5306989", "0.5301366", "0.5295314", "0.5293279", "0.52691835", "0.52659667", "0.52630365", "0.52586126", "0.5242837", "0.5236023", "0.52268016", "0.52251786", "0.5218907", "0.5218874", "0.5217091", "0.5213384", "0.5203783", "0.52026904", "0.519377", "0.51913315", "0.51888174", "0.5188814", "0.5187071", "0.5186122", "0.5182375", "0.5182242", "0.5182242", "0.51720417", "0.5171741", "0.5162281", "0.515814", "0.5155885", "0.5154859", "0.5152235", "0.5146906", "0.51435506", "0.5138434", "0.5135455", "0.5119156", "0.51106054", "0.51105773", "0.51026297", "0.50981194", "0.5096962", "0.50925314", "0.50920546", "0.50893927", "0.5087458", "0.5081294", "0.50806993", "0.5076851", "0.50719917", "0.5071878", "0.507079", "0.5064451", "0.50610405", "0.50550705", "0.5051003", "0.5045563", "0.5045541", "0.5037511", "0.50308704", "0.5024016", "0.50179136", "0.5017821", "0.5012613", "0.50119966", "0.50112337", "0.50086576", "0.50014246", "0.49997398" ]
0.6968493
0
DELETE /portal/learners/1 DELETE /portal/learners/1.xml
def destroy @portal_learner = Portal::Learner.find(params[:id]) @portal_learner.destroy respond_to do |format| format.html { redirect_to(portal_learners_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\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.xml { head :ok }\n end\n end", "def destroy\n @offlearn = Offlearn.find(params[:id])\n @offlearn.destroy\n\n respond_to do |format|\n format.html { redirect_to(offlearns_url) }\n format.xml { head :ok }\n end\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\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 @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 netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n @lek = Lek.find(params[:id])\n @lek.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(leks_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @researcher = Researcher.find(params[:id])\n @researcher.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def destroy\n @expert_personal = ExpertPersonal.find(params[:id])\n @expert_personal.destroy\n\n respond_to do |format|\n format.html { redirect_to(expert_personals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @trial = Trial.find(params[:id])\n @trial.destroy\n\n respond_to do |format|\n format.html { redirect_to(trials_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @trial = Trial.find(params[:id])\n @trial.destroy\n\n respond_to do |format|\n format.html { redirect_to(trials_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lead = Lead.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to(leads_url) }\n format.xml { head :ok }\n end\n end", "def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend", "def destroy\n @hr_attendence = Hr::Attendence.find(params[:id])\n @hr_attendence.destroy\n\n respond_to do |format|\n format.html { redirect_to(hr_attendences_url) }\n format.xml { head :ok }\n end\n end", "def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end", "def destroy\n @refferalmaster = Refferalmaster.find(params[:id])\n @refferalmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(refferalmasters_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rant = Rant.find(params[:id])\n @rant.destroy\n\n respond_to do |format|\n format.html { redirect_to(rants_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expertise = current_user.expertises.find(params[:id])\n @expertise.destroy\n\n respond_to do |format|\n format.html { redirect_to(expertises_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expertise.destroy\n\n head :no_content\n end", "def destroy\n @exam_candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to(candidates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @advertise = Advertise.find(params[:id])\n @advertise.destroy\n\n respond_to do |format|\n format.html { redirect_to(advertises_url) }\n format.xml { head :ok }\n end\n end", "def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end", "def destroy\n @partner_person = PartnerPerson.find(params[:id])\n @partner_person.destroy\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n format.html { redirect_to(partner_people_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 @wrestler = Wrestler.find(params[:id])\n @wrestler.destroy\n\n respond_to do |format|\n format.html { redirect_to(wrestlers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @agent = Agent.find(params[:id])\n @agent.destroy\n \n respond_to do |format|\n format.html { redirect_to(agents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n @education.destory\n\n respond_to do |format|\n format.html { redirect_to(educations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @discovery = Discovery.find(params[:id])\n @discovery.destroy\n\n respond_to do |format|\n format.html { redirect_to(discoveries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reviewer = Reviewer.find(params[:id])\n @reviewer.destroy\n\n respond_to do |format|\n format.html { redirect_to(reviewers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @adults_howyouknowu = AdultsHowyouknowu.find(params[:id])\n @adults_howyouknowu.destroy\n\n respond_to do |format|\n format.html { redirect_to(adults_howyouknowus_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @correspondence = Correspondence.find(params[:id])\n @correspondence.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @retain_node_selector = RetainNodeSelector.find(params[:id])\n @retain_node_selector.destroy\n\n respond_to do |format|\n format.html { redirect_to(retain_node_selectors_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @agent = Agent.find(params[:id])\n flash[:success] = \"#{@agent.username}删除成功\"\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to(agents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @absence_request = AbsenceRequest.find(params[:id])\n @absence_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(absence_requests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\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.xml { head :ok }\n end\n end", "def destroy\n @relatorio = Relatorio.find(params[:id])\n @relatorio.destroy\n\n respond_to do |format|\n format.html { redirect_to(home_path) }\n format.xml { head :ok }\n end\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def destroy\n @attender = Attender.find(params[:id])\n @attender.destroy\n\n respond_to do |format|\n format.html { redirect_to(attenders_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @nepal.destroy\n\n head :no_content\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 @partner = Partner.find(params[:id])\n @partner.destroy\n\n respond_to do |format|\n format.html { redirect_to partners_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @relearnable.destroy\n respond_to do |format|\n format.html { redirect_to relearnables_url, notice: 'Relearnable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @partner_link = PartnerLink.find(params[:id])\n @partner_link.destroy\n\n respond_to do |format|\n format.html { redirect_to(partner_links_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rute = Rute.find(params[:id])\n @rute.destroy\n\n respond_to do |format|\n format.html { redirect_to(rutes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @manual = Manual.find(params[:id])\n @manual.destroy\n\n respond_to do |format|\n format.html { redirect_to(manuals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @teacher = Teacher.find(params[:id]) \n @teacher.destroy\n\n\n respond_to do |format|\n format.html { redirect_to(teachers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @meant_it_rel = MeantItRel.find(params[:id])\n @meant_it_rel.destroy\n\n respond_to do |format|\n format.html { redirect_to(meant_it_rels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @docent = Docent.find(params[:id])\n @docent.destroy\n\n respond_to do |format|\n format.html { redirect_to(docents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @crawler_article = CrawlerArticle.find(params[:id])\n @crawler_article.destroy\n\n respond_to do |format|\n format.html { redirect_to(crawler_articles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @agent = Agent.find(params[:id])\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to(agents_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @differentiator_answer = DifferentiatorAnswer.find(params[:id])\n @differentiator_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(differentiator_answers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @engagement_attendee.destroy\n head :no_content\n end", "def destroy\n @guide = Guide.find(params[:id])\n @guide.destroy\n\n respond_to do |format|\n format.html { redirect_to(guides_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recycling_site = RecyclingSite.find(params[:id])\n @recycling_site.destroy\n\n respond_to do |format|\n format.html { redirect_to(recycling_sites_url) }\n format.xml { head :ok }\n end\n end", "def test_set3_04c_delete_principal()\n user = \"test_user\"\n @test_acl.create_principal(user)\n id = @test_acl.create_ace(user, \"allow\", \"SELECT\", \"test\", \"/db/temporary/testsource\")\n \n @test_acl.delete_principal(user)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end", "def destroy\n return unless lesson_level1 #增加權限控管 \n @lessonrecords = Lessonrecord.find(params[:id])\n @kojenadults = Kojenadult.all\n @lessonrecords.destroy\n\n respond_to do |format|\n format.html { redirect_to(lessonrecords_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @bottle = Bottle.find(params[:id])\n @bottle.destroy\n\n respond_to do |format|\n format.html { redirect_to(bottles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @question_learned.destroy\n respond_to do |format|\n format.html { redirect_to question_question_learneds_path(@question) }\n format.json { head :no_content }\n end\n end", "def destroy\n @leilao = Leilao.find(params[:id])\n @leilao.destroy\n\n respond_to do |format|\n format.html { redirect_to(leilaos_url) }\n format.xml { head :ok }\n end\n end", "def delete_trust(xml) \n if current_user \n trust_root = xml.root.get_elements('TrustRoot').first.text \n unless trust_root.empty? \n @trust = current_user.trusts.find(:first, :conditions => ['trust_root = ?', trust_root]) \n if @trust \n @trust.destroy \n return render(:text => \"<Response>success</Response>\") \n end \n end \n end \n render :text => '<Response>trust root does not exist</Response>' \n end", "def destroy\n @portal = Portal.find(params[:id])\n @portal.destroy\n\n respond_to do |format|\n format.html { redirect_to(portals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attend = Attend.find(params[:id])\n @attend.destroy\n\n respond_to do |format|\n format.html { redirect_to(attends_url) }\n format.xml { head :ok }\n end\n end", "def delete!\n\t\t\tClient.delete @root\n\t\tend", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete(name)\n @ctx.delete(@path + name)\n end", "def destroy\n @wklysum = Wklysum.find(params[:id])\n @wklysum.destroy\n\n respond_to do |format|\n format.html { redirect_to(wklysums_url) }\n format.xml { head :ok }\n end\n end", "def destroy_rest\n @entry_answer = EntryAnswer.find(params[:id])\n @entry_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_answers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @article = Article.find_by_sysname(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(articles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lr45 = Lr45.find(params[:id])\n @lr45.destroy\n\n respond_to do |format|\n format.html { redirect_to(lr45s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n @expectation_stem.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectation_stems_url) }\n format.xml { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.xml { head :ok }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @lore = Lore.find(params[:id])\n @lore.destroy\n\n respond_to do |format|\n format.html { redirect_to(lores_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @intelligence = Intelligence.find(params[:id])\n @intelligence.destroy\n\n respond_to do |format|\n format.html { redirect_to(intelligences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lesson_plan = LessonPlan.find(params[:id])\n @lesson_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(lesson_plans_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ordendetalle = Ordendetalle.find(params[:id])\n @ordendetalle.destroy\n\n respond_to do |format|\n format.html { redirect_to(ordendetalles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to(emple_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @educator = Educator.find(params[:id])\n @educator.destroy\n\n respond_to do |format|\n format.html { redirect_to(educator_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @education = @resume.educations.find(params[:id])\n @education.destroy\n\n respond_to do |format|\n format.html { redirect_to(edit_resume_path(@resume)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lease = Lease.find(params[:id])\n @lease.destroy\n\n respond_to do |format|\n format.html { redirect_to(leases_url) }\n format.xml { head :ok }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @type_expertise = TypeExpertise.find(params[:id])\n @type_expertise.destroy\n\n\n respond_to do |format|\n format.html { redirect_to(type_expertises_url) }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>[]}}\n end\n end", "def destroy\n @student_correspondence = StudentCorrespondence.find(params[:id])\n @student_correspondence.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_correspondences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @additionalinfo = @resume.additionalinfo \n @additionalinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to(resumes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @xml_sample = XmlSample.find(params[:id])\n @xml_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to xml_samples_url }\n format.xml do\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n return render xml: xml\n end\n end\n end" ]
[ "0.70256513", "0.6791501", "0.65993", "0.65353346", "0.65283394", "0.64936334", "0.6363794", "0.6329985", "0.6323121", "0.62932867", "0.62773335", "0.6267726", "0.6203709", "0.61961305", "0.6189406", "0.61839694", "0.6148021", "0.6148021", "0.6147826", "0.61392593", "0.6137154", "0.6126033", "0.61234957", "0.61218077", "0.6116912", "0.6096166", "0.6076829", "0.6075412", "0.6073137", "0.6068982", "0.6064256", "0.60615116", "0.6060175", "0.6055585", "0.60512674", "0.6045399", "0.60444194", "0.6043539", "0.6042078", "0.60406494", "0.60361254", "0.60309225", "0.60258144", "0.6023381", "0.6018697", "0.6018444", "0.60087734", "0.60087734", "0.6004085", "0.6000085", "0.6000029", "0.59999406", "0.5998203", "0.59976745", "0.59941757", "0.5987922", "0.5987031", "0.5985068", "0.59786355", "0.5971395", "0.59676397", "0.59657264", "0.5956278", "0.5952019", "0.5951065", "0.5948783", "0.5946909", "0.59463555", "0.59449893", "0.5943769", "0.5943223", "0.5941154", "0.5934952", "0.59333336", "0.5931521", "0.59265506", "0.59229547", "0.5922663", "0.5921595", "0.59210306", "0.59210306", "0.5916616", "0.5915645", "0.59123623", "0.5910283", "0.59100175", "0.5908941", "0.59082526", "0.58977526", "0.58964574", "0.58939517", "0.58932567", "0.58923596", "0.5891087", "0.5889696", "0.5888368", "0.5885604", "0.5884711", "0.5884549", "0.58845204" ]
0.7416241
0
Refresh token and get a new one
def call api_key = ApiKey.find_by(access_token: @expired_token) if api_key.present? api_key.refresh api_key.save { token: api_key.access_token } else raise ExceptionService.new('Invalid Token.') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fresh_token\n refresh! if token_expired?\n access_token\n end", "def fresh_token\n refresh! if expired?\n access_token\n end", "def refresh_token\n return if token\n refresh_token!\n end", "def refresh_auth_token\n generate_token(:auth_token)\n save!\n end", "def refreshToken\n # is there a token? (and is it's timestamp not older than 24h?)\n if @token.nil? or @tokenTimeStamp < Time.now - 86400\n @token = getToken(@email,@password)\n @tokenTimeStamp = Time.now\n end\n end", "def refresh_token\n self.generate_token\n end", "def refresh_token\n @token = @authenticator.refresh_token\n end", "def update_token\n client.authorization.update_token!(oauth_data)\n if client.authorization.refresh_token && client.authorization.expired?\n client.authorization.fetch_access_token!\n end\n end", "def refresh!(params={})\n @token = token.refresh!(params)\n end", "def refresh_token!\n create_token = Kickit::API::CreateToken.new\n resp = create_token.execute(:username => username,\n :developerKey => Kickit::Config.developerKey)\n @token = resp\n end", "def renew\n req_body = { grant_type: 'refresh_token', refresh_token: @token.refresh_token }\n\n response = JSON.parse(request_token(req_body).body)\n\n @token.update!(response['access_token'], response['expires_in'], response['refresh_token'])\n\n save\n rescue StandardError => e\n puts \"Unable to refresh token\\n#{e.message}\"\n end", "def refresh\n begin\n oauth_attrs = source.create(params: refresh_token_params)\n oauth_attrs.each do |attr, value|\n send(\"#{attr}=\", value)\n end\n rescue My::Oauth::Unauthorized => e\n errors << 'Error refreshing token'\n end\n self\n end", "def refresh_token\n authorize current_user\n original = current_user.api_token\n current_user.generate_token!\n @success = current_user.api_token != original\n end", "def renew_token\n body_params = token_request_body\n body_params << [\"refresh_token\", current_user.refresh_token]\n body_params << [\"grant_type\", \"refresh_token\"]\n\n get_token(body_params)\n redirect_to sage_accounting_data_path\n end", "def refresh_single_use_oauth2_token!\n assign_single_use_oauth2_token\n save!\n end", "def refresh!(params = {})\n raise('A refresh_token is not available') unless refresh_token\n params[:grant_type] = 'refresh_token'\n params[:refresh_token] = refresh_token\n new_token = @client.get_token(params)\n new_token.options = options\n new_token.refresh_token = refresh_token unless new_token.refresh_token\n new_token\n end", "def token_refresh!\n self.access_token = access_token.refresh!\n end", "def refresh_token\n end", "def refresh_token\n get_comm_token if Time.now.to_i - @comm_token_ttl > TOKEN_TTL\n end", "def refresh_token\n get_comm_token if Time.now.to_i - @comm_token_ttl > TOKEN_TTL\n end", "def token\n refresh_token! if token_expired?\n super\n end", "def refreshToken(token)\n makeToken(:refresh_token, :refresh_token => token.refresh_token)\n end", "def refresh_token\n @auth.refresh_token\n end", "def refresh_oauth2_token!\n ensure_oauth2_token(true)\n save!\n end", "def get_new_token\n auth = 'Basic ' + Base64.strict_encode64( session[:client_id] + \":\" + session[:client_secret]).chomp\n \n rcResultJson = RestClient.post(\n session[:token_url],\n {\n grant_type: 'refresh_token', \n refresh_token: session[:refresh_token], \n },\n {\n :Authorization => auth\n }\n )\n rcResult = JSON.parse(rcResultJson)\n\n session[:patient_id] = rcResult[\"patient\"]\n session[:access_token] = rcResult[\"access_token\"]\n session[:refresh_token] = rcResult[\"refresh_token\"]\n session[:token_expiration] = (Time.now.to_i + rcResult[\"expires_in\"].to_i )\n rescue StandardError => exception\n # binding.pry \n err = \"Failed to refresh token: \" + exception.message\n redirect_to root_path, alert: err\n end", "def get_new_token\n binding.pry \n auth = 'Basic ' + Base64.strict_encode64( session[:client_id] +\":\"+session[:client_secret]).chomp\n \n rcResultJson = RestClient.post(\n session[:token_url],\n {\n grant_type: 'refresh_token', \n refresh_token: session[:refresh_token], \n },\n {\n :Authorization => auth\n }\n )\n rcResult = JSON.parse(rcResultJson)\n\n session[:patient_id] = rcResult[\"patient\"]\n session[:access_token] = rcResult[\"access_token\"]\n session[:refresh_token] = rcResult[\"refresh_token\"]\n session[:token_expiration] = Time.now.to_i + rcResult[\"expires_in\"].to_i \n rescue => exception\n binding.pry \n err = \"Failed to refresh token\"\n redirect_to root_path, flash: { error: err }\n end", "def refresh_access_token(refresh_token = @config.REFRESH_TOKEN)\r\n get_new_access_token(refresh_token)\r\n end", "def refresh_token()\n if @access_token_obj\n @access_token_obj.refresh_token\n else\n return nil\n end\n end", "def refresh!\n now = Time.now\n raise RefreshTokenExpired if refresh_token_expires_at&.<= now\n\n data = refresh_token_request!\n\n @access_token = data[\"access_token\"]\n @access_token_expires_at = (now + data[\"expires_in\"])\n\n on_refresh&.call(@access_token, @access_token_expires_at)\n end", "def refresh_access_token!\n self.save! if refresh_access_token\n end", "def refresh! options = {}\n fetch_access_token! options\n end", "def update_token\n params = {\n client_id: client_id,\n client_secret: client_secret,\n grant_type: 'refresh_token',\n refresh_token: refresh_token\n }\n request(:post, 'oauth2/token', params, true)\n end", "def refresh_token\n if remember_token?\n self.remember_token = self.class.make_token\n save(false)\n end\n end", "def refresh_access_token()\n\n\t\tif(Time.now - @start_time) >=3000\n\t\t\tputs \"Access Token Expired .......Creating a new one\"\n\t\t\t@access_token = @new_token.get_access_token\n\t\t\t@start_time = Time.now\n\t\tend\n\tend", "def refresh_token_if_needed\n token_timestamp = decoded_jwt['exp']\n current_timestamp = DateTime.now.to_i\n return unless token_timestamp - current_timestamp <= 0\n\n refresh_token\n end", "def refresh_token\n if remember_token?\n self.remember_token = self.class.make_token \n save(false) \n end\n end", "def refresh_token\n @agent.shutdown\n @agent = Mechanize.new\n\n get_token\n set_headers\n end", "def refresh_tokens\n @token = @token.refresh!\n tokens\n end", "def refresh_token(token = @token)\n raise \"invalid token\" unless token\n @access_token ||= OAuth2::AccessToken.new(@oauth_client, token, :refresh_token => @refresh_token, :expires_at => @token_expires_at)\n if @access_token.expired?\n @access_token.refresh!\n @access_token_refreshed = true\n end\n end", "def refresh(access_token)\n new_access_token = access_token.client.access_token!\n expires = Time.zone.at(decode_id_token(new_access_token.id_token).exp).to_datetime\n\n {\n access_token: new_access_token.access_token,\n expires_at: expires\n }\n rescue Rack::OAuth2::Client::Error\n # Refresh token was expired\n {}\n end", "def refresh_access_token\n new_token = FireCloudClient.generate_access_token(self.service_account_credentials)\n new_expiry = Time.zone.now + new_token['expires_in']\n self.access_token = new_token\n self.expires_at = new_expiry\n new_token\n end", "def refresh_token\n @connection.refresh_token\n end", "def refresh_access_token\n self.expires_at = Time.now + 3600 \n save\n end", "def refresh()\n uri = uri('auth-api/v2/authenticate/refresh', {}, {})\n RestClient.post(uri.to_s, MultiJson.dump({:refreshToken => @refresh}), {:content_type => :json, :accept => :json}) {|res, _, _|\n process_auth(process(res))\n return @token\n }\n end", "def refresh_tokens\n\t\tbegin\n\t\t\t\n\t\t\tresp = $c.initiate_auth({\n\t\t\t auth_flow: \"REFRESH_TOKEN\",\n\t\t\t auth_parameters: {\n\t\t\t \"REFRESH_TOKEN\" => self.refresh_token,\n\t\t\t \"SECRET_HASH\" => calculate_cognito_hmac\n\t\t\t },\n\t\t\t client_id: ENV[\"COGNITO_CLIENT_ID\"]\n\t\t\t})\n\t\t\t\n\t\t\tself.access_token = resp[:authentication_result][:access_token]\n\t\t\tself.refresh_token = resp[:authentication_result][:refresh_token]\n\t\t\tself.token_expires_at = Time.now + (resp[:authentication_result][:expires_in]).seconds\n\t\t\tself.save\n\t\t\t#session[:user] = self\n\t\trescue => e\n\t\t\te.to_s\n\t\tend\t\n\tend", "def refresh_token\n raise NotImplementedError\n end", "def refresh_token\n if remember_token?\n self.remember_token = self.class.create_token\n save(:validate => false)\n end\n end", "def refresh!\n response = request_token_from_google\n data = JSON.parse(response.body)\n if data[\"access_token\"].present?\n update_attributes(access_token: data['access_token'], expires_at: Time.now + (data['expires_in'].to_i).seconds)\n else\n puts data[\"error_description\"]\n end\n end", "def access_token\n refresh! if access_token_expires_at&.<= Time.now + 60 # time drift margin\n @access_token\n end", "def refresh_tokens\n response = get(path: 'tokens')[\"data\"]\n token_array = response || {}\n tokens = {}\n token_array.each do |t|\n tokens[t.keys.first] = t.values.first\n end\n @tokens = tokens\n return tokens\n end", "def regenerate_token\n self.auth_token = nil\n generate_token\n save!\n end", "def refresh_access_token!\n @access_token = access_token.refresh!\n end", "def refresh_token\n warden.authenticate!(scope: resource_name)\n # the route is already hooked up for session check and jwt dispatch\n render json: {}.merge(prepared_jwt_as_access_token)\n end", "def refresh_token\n @refresh_token ||= nil\n end", "def refresh_token\n if remember_token?\n self.remember_token = make_token \n save(:validate => false) \n end\n end", "def refresh_from_store\n ext_token = store.read\n raise \"Cannot refresh token : Unable to read store data\" if !ext_token&.is_a?(Hash) || ext_token.empty?\n client.update_token!(ext_token)\n end", "def refresh \n decoded_refresh_token = JWT.decode(params[:refreshToken], 's3cr3t', true, algorithm: 'HS256')\n # Check if token was decoded\n if decoded_refresh_token\n refresh_token_record = Blacklist.find_by(jwt: params[:refreshToken])\n if refresh_token_record && Time.now < refresh_token_record.expiration \n @user = User.find_by(id: decoded_refresh_token[0]['user_id'])\n if @user # user exists\n Blacklist.find_by(jwt: params[:refreshToken]).delete\n # update the device_key for the user\n new_access_token = create_access_token(@user.id)\n new_refresh_token = create_refresh_token(@user.id)\n render json: {status: \"Refreshed Tokens\", auth: {accessToken: new_access_token.jwt, accessTokenExpiration: new_access_token.expiration, refreshToken: new_refresh_token.jwt, refreshTokenExpiration: new_refresh_token.expiration }}\n else\n render json: {error: \"Invalid User\"}\n end\n else\n render json: {status: \"Token Expired\"}\n end \n else # token is null\n render json: {error: \"Invalid Token\"}\n end\n end", "def refresh_access_token!\n @access_token = access_token.refresh!\n self.class.default_params :access_token => @access_token.token\n @access_token\n end", "def fresh_hubstaff_access_token\n raise 'Organiaztion not connected to HB. Please edit hubstaff start auth code.' if hubstaff_token_will_end.blank?\n\n # still fresh\n return hubstaff_access_token if hubstaff_token_will_end - 2.hours > DateTime.now\n\n res = HubstaffClient.new.refresh_access_token_request hubstaff_refresh_token\n\n raise StandardError, res.parsed_response['error'] if res.code != 200\n\n self.hubstaff_access_token = res.parsed_response['access_token']\n self.hubstaff_refresh_token = res.parsed_response['refresh_token']\n self.hubstaff_token_get_at = DateTime.now\n self.hubstaff_token_will_end = DateTime.now + (res.parsed_response['expires_in'].to_i / 60.0 / 60.0).round.hours\n\n self.save\n\n hubstaff_access_token\n end", "def update_token\n\trequire 'date'\n\ttil = Time.at(settings.exp) - Time.now\n\tleft = (til/60).to_i\n\tp left\n\tif left < 5\n\t\tres = RestClient.post( \"https://auth.exacttargetapis.com/v1/requestToken\",\n\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t:clientId => settings.clientId,\n\t\t\t\t\t\t\t\t:clientSecret => settings.clientSecret,\n\t\t\t\t\t\t\t\t:refreshToken => settings.refreshToken,\n\t\t\t\t\t\t\t\t:accessType => \"offline\"\n\t\t\t\t\t\t\t })\n\t\t@res = JSON.parse(res)\n\t\tsettings.oauthToken = @res[\"accessToken\"]\n\t\tsettings.exp = Time.now + @res[\"expiresIn\"]\n\t\tsettings.refreshToken = @res[\"refreshToken\"]\n\tend\t\nend", "def refresh_tokens!\n update(Twitch.new_tokens!(refresh_token))\n rescue RestClient::Unauthorized, RestClient::BadRequest\n # If the refresh got 401 Unauthorized, we were probably de-authorized from using the user's Twitch account. If it\n # got 400 Bad Request, we probably have a nil refresh token, perhaps because the authorization was created before we\n # started saving refresh tokens to the database.\n #\n # Ideally we'd destroy the TwitchUser here, but that may leave the user with no way to sign in. Instead, force a\n # sign out so we can get some fresh tokens. Until that happens we technically have no way to verify this Twitch user\n # and this Splits.io user are the same person, only that they once were in the past.\n #\n # Once we have linkless accounts, change this to destroy the TwitchUser.\n user.sessions.destroy_all\n end", "def refresh_access_token\n\t\t\t\trequire \"open-uri\"\n\t\t\t\trequire \"net/http\"\n\t\t\t\trequire \"openssl\"\n\t\t\t\trequire \"base64\"\n\n\t\t\t\turi = URI.parse(\"#{self.add_on.jive_url}/oauth2/token\")\n\t\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\thttp.use_ssl = true\n\n\t\t\t\trequest = Net::HTTP::Post.new(uri.request_uri)\n\t\t\t\trequest.basic_auth self.add_on.client_id, self.add_on.client_secret\n\t\t\t\trequest.set_form_data({\n\t\t\t\t\t\"refresh_token\" => \"#{self.refresh_token}\",\n\t\t\t\t\t\"grant_type\" => \"refresh_token\",\n\t\t\t\t})\n\n\t\t\t\tresponse = http.request(request)\n\t\t\t\tjson_body = JSON.parse(response.body)\n\n\t\t\t\tif (response.code.to_i != 200)\n\t\t\t\t\traise RuntimeError, json_body[\"error\"].to_s.upcase\n\t\t\t\tend\n\n\t\t\t\tself.access_token = json_body[\"access_token\"]\n\t\t\t\tself.expires_in = json_body[\"expires_in\"]\n\t\t\t\tself.expires_at = json_body[\"expires_in\"].to_i.seconds.from_now\n\t\t\t\tself.save\n\t\t\tend", "def regenerate_auth_token\n new_token = oauth.exchange_access_token_info(authentication.auth_token)\n\n # Save the new token and its expiry over the old one\n authentication.update_attributes!(\n auth_token: new_token['access_token'],\n last_expires_at: authentication.expires_at,\n expires_at: Time.now + new_token['expires_in'].to_i,\n )\n\n authentication.auth_token\n end", "def refreshed!(body)\n @access_token = body[:access_token]\n @expires_at = Time.now + body[:expires_in]\n end", "def refresh_token\n debug { \"Performing token refresh\" }\n return false if token.nil?\n return false if token['refresh_token'].nil?\n uri = URI.parse(token_account['token_endpoint'])\n endpoint_data = { path: uri.path }\n endpoint_data[:host] = uri.host if uri.host\n endpoint_data[:port] = uri.port if uri.port\n\n debug { \"Token refresh endpoint: #{endpoint_data.inspect}\" }\n\n return false unless endpoint_data[:path]\n\n response = request(\n {\n http_method: token_account['token_method'].downcase.to_sym,\n body: refresh_request_params,\n headers: {\n CONTENT_TYPE => token_account['token_post_content_type']\n }.merge(\n token_account['code_requires_basic_auth'] ? basic_auth_header : {}\n ),\n expects: [200, 201, 400, 401, 403],\n auth: false\n }.merge(endpoint_data)\n )\n\n if response && response['access_token']\n debug { \"Got response to refresh request\" }\n token['access_token'] = response['access_token']\n token['refresh_token'] = response['refresh_token']\n token['expires_at'] = in_to_at(response['expires_in'])\n token.config.write if token.respond_to?(:config)\n true\n else\n debug { \"Got null or bad response to refresh request: #{last_response.inspect}\" }\n false\n end\n rescue => ex\n error { \"Access token refresh exception\" }\n error { ex }\n false\n end", "def regenerate_auth_token\n self.auth_token = nil\n generate_token\n save!\n end", "def regenerate_auth_token\n self.auth_token = nil\n generate_token\n save!\n end", "def refresh_token= new_refresh_token\n @refresh_token = new_refresh_token\n end", "def token\n refresh_token if needs_token_refresh?\n return @token\n end", "def regenerate_auth_token!\n generate_auth_token\n set_auth_token_expiry\n\n save\n end", "def refresh\n new_token = EsdlSuiteService.setup.refresh(to_access_token)\n return delete if new_token.empty?\n\n update(new_token)\n end", "def refresh_session\n self.with_lock(timeout: 60, retries: 120, retry_sleep: 0.5) do\n if self.token_expires_at <= 10.seconds.from_now\n begin\n session.refresh_tokens\n self.refresh_token = session.refresh_token\n self.access_token = session.access_token\n self.token_expires_at = session.expires_at\n self.save\n rescue ExactOnlineLib::Api::Sdk::AuthError\n @session = nil\n end\n else\n @session = nil\n end\n @client = nil\n end\n end", "def refresh\n token = authenticate.call\n file = Tempfile.new('conjur-access-token.')\n begin\n file.write JSON.pretty_generate(token)\n file.close\n FileUtils.mv file.path, filename\n Conjur.log << \"Refreshed Conjur auth token to #{filename.inspect}\\n\" if Conjur.log\n ensure\n file.unlink\n end\n rescue\n $stderr.puts $!\n end", "def refresh_access!\n response = auth_connection.post(\n \"/api/v1/access_token\",\n grant_type: \"refresh_token\",\n refresh_token: access.refresh_token\n )\n access.refreshed!(response.body)\n reset_connection!\n end", "def refresh_token\n QueryHelper::HeaderValidationChecker.new(request.headers, 'RefreshToken', 'Authorization').check_null_headers\n TokenHelper.check_blacklist(request.headers['RefreshToken'])\n # access token validation check\n payload = TokenHelper.jwt_decode(request.headers['Authorization'])\n unless payload && !payload['refresh']\n raise Exceptions::AuthenticationError.new(\"invalid access_token\")\n end\n # refresh_token validation and expiry check\n payload = TokenHelper.jwt_decode(request.headers['RefreshToken'])\n unless payload && payload['refresh'] && payload['expiry_time'] > Time.now\n raise Exceptions::AuthenticationError.new(\"invalid refresh_token\")\n end\n # user validation\n user = User.find(payload['user_id'])\n unless user\n Rails.logger.error \"no user found with the given user_id -- #{payload['user_id']}\"\n raise Exceptions::AuthenticationError.new(\"invalid token\")\n end\n res = user.generate_auth_token\n # Adding both the tokens to blacklist in redis, disabling its use again\n TokenHelper.add_blacklist(request.headers['Authorization'],\"access\")\n TokenHelper.add_blacklist(request.headers['RefreshToken'],\"refresh\")\n render json: res, status: 200, scope: nil\n rescue Exceptions::AuthenticationError, Exceptions::InvalidHeaderError, Exceptions::WrongHeaderError, JWT::DecodeError, JWT::VerificationError => e\n render json: {error: e}, status: 401, scope: nil\n end", "def refresh_token\n return nil unless (temp_refresh_token = read_attribute(:refresh_token))\n # logger.debug2 \"temp_refresh_token = #{temp_refresh_token}\"\n encrypt_remove_pre_and_postfix(temp_refresh_token, 'refresh_token', 45)\n end", "def refresh_token\n return nil unless (temp_refresh_token = read_attribute(:refresh_token))\n # logger.debug2 \"temp_refresh_token = #{temp_refresh_token}\"\n encrypt_remove_pre_and_postfix(temp_refresh_token, 'refresh_token', 45)\n end", "def refresh_token(code=nil)\n body = {}\n body[:code] = code unless code.nil?\n\n @client.client_credentials.get_token(\n headers: { 'Authorization' => 'Basic' })\n end", "def token\n return @access_token if @access_token && !needs_refresh?\n\n update_access_token\n @access_token\n end", "def refresh_token(pin, device_id)\n values = {\n pin: pin,\n device_id: device_id\n }\n @client.make_request :post,\n auth_path('token'),\n values\n end", "def with_fresh_token\n retried = false\n\n begin\n token = File.exist?(TOKEN_PATH) && File.read(TOKEN_PATH) || refresh_token()\n yield(token)\n rescue StaleTokenError\n raise if retried # Avoid endless loops.\n retried = true\n\n FileUtils.rm(TOKEN_PATH)\n retry\n end\nend", "def refresh_token?\n if (@token_timer + 6000) < Time.now\n self.get_token\n true\n else\n false\n end\n end", "def refresh(new_resource = resource)\n token_response = TokenRequest\n .new(authority, @client)\n .get_with_refresh_token(refresh_token, new_resource)\n if token_response.instance_of? SuccessResponse\n token_response.parse_id_token(id_token)\n end\n token_response\n end", "def get_token\n if @token && @valid_until && @valid_until > Time.now + 10\n @token\n else\n renew_token\n end\n end", "def get_NewRefreshToken()\n \t return @outputs[\"NewRefreshToken\"]\n \tend", "def get_NewRefreshToken()\n \t return @outputs[\"NewRefreshToken\"]\n \tend", "def refresh(response)\n @access_token = response[:access_token]\n @expires_at = Time.now + response[:expires_in]\n end", "def refresh_user_access_token(user_refresh_token)\r\n get_new_access_token(user_refresh_token)\r\n end", "def auth_token\n return regenerate_auth_token if expired?\n\n authentication.auth_token\n end", "def access_token\n # Synchronization is needed, otherwise race condition may ensue:\n # Let's assume token has expired, and two threads ask for a new token.\n # Both proceed to fetch the token from remote server, both return,\n # but the first token is no longer valid.\n MUTEX.synchronize do\n token = Nordea::Siirto.redis.get(KEY)\n return token if token\n\n Nordea::Siirto.log('Requesting new access token...')\n payload = response.body\n\n token = payload['access_token']\n expires_in = payload['expires_in'] - EXPIRATION_BUFFER\n Nordea::Siirto.redis.set(KEY, token)\n Nordea::Siirto.redis.expire(KEY, expires_in)\n\n token\n end\n end", "def refresh_session_token\n session_signature = Digest::MD5.hexdigest(@toodle_uid + Babar::Base.toodle_app_token) \n session_token_url = \"http://api.toodledo.com/2/account/token.php?\" + self.parse_params({:userid => @toodle_uid, :appid => Babar::Base.toodle_app_id , :sig => session_signature,})\n puts session_signature, session_token_url\n @session_token = JSON.parse(Typhoeus::Request.get(session_token_url).body)[\"token\"]\n @toodle_token_death = Time.now + Babar::Base.toodle_app_token_lifetime\n [@session_token, @toodle_token_death]\n end", "def refresh_token=(token)\n token_response.instance_variable_set(:@refresh_token, token)\n logger.verbose(\"Updated the refresh token for #{token_response}.\")\n end", "def refresh_access_token(access_token)\n begin\n client, auth = google_api_client_auth\n auth.refresh_token = access_token\n auth.refresh!\n auth.access_token\n rescue\n puts \"Failed to refresh Google OAuth access token\"\n nil\n end\n end", "def get_new_refresh_token\n\t\tclient = OAuth2::Client.new(\n\t\t\tCLIENT_ID, CLIENT_SECRET,\n\t\t\t:site => \"https://accounts.google.com\",\n\t\t\t:token_url => \"/o/oauth2/token\",\n\t\t\t:authorize_url => \"/o/oauth2/auth\")\n\n\t\tauth_url = client.auth_code.authorize_url(\n\t\t\t:redirect_uri => \"http://localhost\",\n\t\t\t:scope =>\n\t\t\t\"https://docs.google.com/feeds/ \" +\n\t\t\t\"https://docs.googleusercontent.com/ \" +\n\t\t\t\"https://spreadsheets.google.com/feeds/\")\n\n\t\tputs auth_url\n\n\t\tprint \"authorization code:\"\n\t\tauthorization_code = STDIN.gets.chomp\n\n\t\tcmd = \"curl -d client_id=#{CLIENT_ID} -d client_secret=#{CLIENT_SECRET} -d redirect_uri=http://localhost -d grant_type=authorization_code -d code=#{authorization_code} https://accounts.google.com/o/oauth2/token\"\n\t\tJSON.parse( `#{cmd}` )[\"refresh_token\"]\n\tend", "def refresh_access_token_by_refresh_token(refresh__token)\n if isNullOrWhiteSpace(refresh__token)\n raise LoginRadius::Error.new, getValidationMessage('refresh__token')\n end\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n query_parameters['refresh_Token'] = refresh__token\n\n resource_path = 'identity/v2/manage/account/access_token/refresh'\n get_request(resource_path, query_parameters, nil)\n end", "def latest_refresh_token\n credentials.refresh_token\n end", "def refresh_fitbit_token\n @fitbit_oauth_client.site = \"https://api.fitbit.com\" \n @fitbit_token = @fitbit_token.refresh!(:headers =>{'Authorization' => \"Basic #{@base64_id_secret}\",'Body' => \"client_id=#{@fitbit_oauth_client.id}\"})\n end", "def refresh(refresh_token:)\n body = {\n grant_type: \"refresh_token\",\n refresh_token: refresh_token\n }\n\n response = connection.post do |req|\n req.headers[\"Authorization\"] = \"Basic \" + Base64.strict_encode64(Keap::REST.client_id + \":\" + Keap::REST.client_secret)\n req.body = body\n end\n\n new(response.body)\n end", "def update_token!(object)\n self.refresh_token = object.refresh_token unless object.refresh_token.nil?\n self.access_token = object.access_token\n self.expires_at = object.expires_at\n end", "def fetch_or_refresh\n refresh_from_store\n fetch_and_write if client.expired?\n client.access_token\n end" ]
[ "0.8607038", "0.84962076", "0.8459562", "0.8394218", "0.8325173", "0.8255056", "0.8212024", "0.820078", "0.8198548", "0.8151004", "0.8076849", "0.80393016", "0.80309474", "0.8026996", "0.79955965", "0.7963001", "0.7918421", "0.7887903", "0.78613967", "0.78613967", "0.785747", "0.78416073", "0.7836336", "0.7823336", "0.7793185", "0.77826273", "0.7762052", "0.77596617", "0.7739519", "0.7706827", "0.7704852", "0.7703643", "0.7684406", "0.76794285", "0.767833", "0.7669261", "0.7667102", "0.7665136", "0.766088", "0.7655897", "0.7621336", "0.7620232", "0.7576621", "0.7556312", "0.753743", "0.7513688", "0.75103605", "0.7476462", "0.74664605", "0.7443469", "0.7412632", "0.74117696", "0.74021983", "0.7394519", "0.73869413", "0.7372515", "0.7338122", "0.73147583", "0.729548", "0.7291294", "0.7277872", "0.72765", "0.72744054", "0.7273052", "0.72525775", "0.7224498", "0.7224498", "0.7219221", "0.7209864", "0.71996427", "0.7172879", "0.7171927", "0.7161403", "0.7151889", "0.71341485", "0.7130088", "0.7130088", "0.7111579", "0.70597947", "0.705254", "0.7044295", "0.70389956", "0.7031381", "0.7006984", "0.7003385", "0.7003385", "0.7001401", "0.69940245", "0.6983154", "0.6981991", "0.6978632", "0.6977022", "0.69614786", "0.6957475", "0.69354016", "0.6920666", "0.691316", "0.68890905", "0.6854987", "0.6851666" ]
0.7183969
70
Adjusts the hash storage and redistributes the entries among the new bins. Any Iterator instance will be invalid after a call to redistribute. Does not recalculate the cached key_hash values. See +rehash+.
def redistribute(entries) capacity = @capacity # Rather than using __setup__, initialize the specific values we need to # change so we don't eg overwrite @state. if @size > @max_entries @capacity = capacity * 2 @max_entries = @max_entries * 2 @min_entries = @min_entries * 2 else @capacity = capacity / 2 @max_entries = @max_entries / 2 @min_entries = @min_entries / 2 end @entries = Entries.new @capacity @mask = @capacity - 1 i = -1 while (i += 1) < capacity if item = entries[i] next if item.deleted index = key_index item.key_hash index = (1 + index) % @capacity while @entries[index] @entries[index] = item end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redistribute(entries)\n capacity = @capacity\n\n # TODO: grow smaller too\n __setup__ @capacity * 2, @max_entries * 2, @size\n\n i = -1\n while (i += 1) < capacity\n next unless old = entries[i]\n while old\n old.next = nil if nxt = old.next\n\n index = key_index old.key_hash\n if entry = @entries[index]\n old.next = entry\n end\n @entries[index] = old\n\n old = nxt\n end\n end\n end", "def rehash\n buckets.compact.each do |key, value|\n insert(key, value)\n end\n end", "def rehash\n capacity = @capacity\n entries = @entries\n\n @entries = Entries.new @capacity\n\n i = -1\n while (i += 1) < capacity\n next unless old = entries[i]\n while old\n old.next = nil if nxt = old.next\n\n index = key_index(old.key_hash = old.key.hash)\n if entry = @entries[index]\n old.next = entry\n end\n @entries[index] = old\n\n old = nxt\n end\n end\n\n self\n end", "def resize_indexer\n HashItem.each do |item|\n new_index = index(item.key, @size)\n if(@items[new_index] == nil)\n @items[new_index] = item.value\n else\n resize \n end\n end\n end", "def rebuild\n raise \"Too many entries.\" if @rebuilds >= MAX_REBUILDS old = @table\n @slots = PRIMES[@rebuilds]\n self.size = 0\n fill_table @slots\n old.each do |e|\n upsert e.key, e.value if e\n end\n @rebuilds += 1\nend", "def resize\n temp_array = Array.new(@items)\n @items = Array.new(temp_array.length*2)\n\n # Iterates over every item in the original array, makes a new hash key, and puts it into new @items.\n for item in temp_array do\n if item != nil\n new_hash_key = self.index(item.key,self.size)\n @items[new_hash_key] = item\n end\n end\n end", "def resize\n old_items = @items\n @items = Array.new(@items.size*2)\n old_items.each do |i|\n if i != nil\n puts i\n @items[index(i.key,@items.length)] = HashItem.new(i.key, i.value)\n end\n end\n end", "def resize\n old_array = @items\n @items = Array.new(old_array.length * 2)\n old_array.each do |h_item|\n if h_item != nil\n @items[index(h_item.key, size)] = HashItem.new(h_item.key, h_item.value)\n end\n end\n end", "def refresh!\n @buckets = init_buckets\n @full_buckets = Hash.new\n end", "def rehash(oldhash, size)\n (oldhash + 1) % size\n end", "def __clone_buckets\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n v = self.__at(kofs + 1)\n if v._not_equal?(RemoteNil)\n k = self.__at(kofs)\n if k._not_equal?(RemoteNil)\n # a k,v pair\n elsif v._isFixnum\n # internal collision chain\n else\n # a collision bucket\n nbucket = v.clone\n nbucket.__parent=(self)\n self.__at_put(kofs + 1, nbucket )\n end\n end\n kofs += 2\n end\n end", "def resize\n old_array = @items\n @items = Array.new(old_array.length * 2)\n old_array.each do |ll|\n unless ll.nil?\n current = ll.head\n unless current.nil?\n index = self.index(current.key, @items.length)\n if @items[index].nil?\n @items[index] = LinkedList.new\n @items[index].add_to_tail(Node.new(current.key, current.value))\n if load_factor >= @max_load_factor\n self.resize\n end\n current = current.next\n else\n @items[index].add_to_tail(Node.new(current.key, current.value))\n if load_factor >= @max_load_factor\n self.resize\n end\n current = current.next\n end\n end\n end\n end\n end", "def check_rehash!\n return if @size.to_f/@cardinality < LOAD_FACTOR_THRESHOLD\n\n @cardinality *= 2\n old_arr = @arr.dup\n @arr = []\n old_arr.each do |r|\n next unless r\n\n self.add(r.number, r.name)\n el = r\n while (el = el.next_rec)\n self.add(el.number, el.name)\n end\n end\n end", "def maybe_rehash\n load_factor = (count / table.length.to_f)\n puts \"Thinking about rehashing. Load factor is #{load_factor}\"\n\n rehash if load_factor > MAX_LOAD_FACTOR\n end", "def rehash(growth_multiple = DEFAULT_GROWTH_MULTIPLE)\n puts \"Rehashing\"\n new_size = (table.length * growth_multiple).to_i\n @table = table.each_with_object(HashTable.new(new_size)) do |value, result|\n result.insert(value) unless value == TOMBSTONE_MARKER\n end.dump_table\n end", "def flush_buckets\n\n count = 0\n\n synchronize do\n\n @buckets.each do |k, v|\n v.flush\n count += 1\n end\n @buckets.clear\n end\n\n linfo { \"flush_buckets() flushed #{count} buckets\" } \\\n if count > 0\n end", "def insert_into_bucket(value, bucket)\n @table[bucket] = value\n @count += 1\n maybe_rehash\n end", "def []=(key, value)\n\n @buckets[index(key, size)].add_to_tail(Node.new(key, value))\n @num_items += 1\n\n resize if load_factor > @max_load_factor\n end", "def updated_redis(distribution)\n redis.pipelined do\n redis.zadd(distribution.name, distribution.bins.to_a.map(&:reverse))\n redis.set(hits_count_key, distribution.hits_count)\n redis.set(last_updated_at_key, Time.now.to_i)\n end\n end", "def modify_keys\n each_with_object self.class.new do |hash_pair, hsh|\n hsh[ yield( hash_pair ) ] = self[ hash_pair[0] ]\n end\n end", "def split_old_bin(table, new_table, i, node, node_hash, forwarder); end", "def original_scheduling_initial!(partitions)\n # Phase 1: Sort partitions by sites.size\n partitions.sort_by_sites!\n\n # Phase 2: Initial filling\n bin_assigner = 0\n full_bins = 0\n partitions.size.times do\n if @list[bin_assigner].total_sites + partitions.first.sites.size <= @sites_lower_bound\n @list[bin_assigner].add!([partitions.first])\n partitions.drop!(1)\n\n # Edge case handling for perfect fit\n if @list[bin_assigner].total_sites == @sites_lower_bound\n full_bins += 1\n @sites_lower_bound -= 1 if full_bins == @list.size - @sites_rounding_adjustment\n end\n\n else\n break\n end\n\n bin_assigner = (bin_assigner + 1) % @list.size\n end\n partitions\n end", "def update!(**args)\n @integer_buckets = args[:integer_buckets] if args.key?(:integer_buckets)\n end", "def populate_buckets\n bucket_offset = header.class.bytesize\n bucktes = []\n header.num_buckets.times do |i|\n bucket = HMapBucket.new_from_bin(swapped, @raw_data[bucket_offset, HMapBucket.bytesize])\n bucket_offset += HMapBucket.bytesize\n next if bucket.key == HEADER_CONST[:HMAP_EMPTY_BUCKT_KEY]\n\n bucktes[i] = { bucket => yield(bucket) }\n end\n bucktes\n end", "def adapted_scheduling_initial!(partitions)\n bin_index = 0\n full_bins = 0\n partitions.size.times do\n if @list[bin_index].size + partitions.first.size <= @operations_lower_bound\n @list[bin_index].add!([partitions.first])\n partitions.drop!(1)\n\n # Edge case handling for perfect fit\n if @list[bin_index].size == @operations_lower_bound\n full_bins += 1\n @operations_lower_bound -= 1 if full_bins == @list.size - @operations_rounding_adjustment\n end\n\n else\n break\n end\n\n bin_index = (bin_index + 1) % @list.size\n end\n @list = @list.sort\n\n partitions\n end", "def rehash() end", "def split\n results = @ordered.inject([]) { |memo,(identity,buckets)|\n newinst = self.class.new(:identity => identity)\n newinst.buckets = buckets.dup\n newinst.collate!\n memo << newinst\n memo\n }\n return results\n end", "def each\n copy = self_new { |a, b| compare(a, b) }\n @keys[1..size].each { |key| copy.insert key }\n\n yield copy.delete until copy.is_empty?\n end", "def increment_bucket(bucket)\n (bucket + 1) % table.length\n end", "def resize!\n @capacity *= 2\n new_store = StaticArray.new(@capacity)\n (0...@length).each do |idx|\n if idx < @start_idx\n new_store[idx] = @store[idx]\n else\n new_store[idx + @length] = @store[idx]\n end\n end\n @store = new_store\n @start_idx += @length\n end", "def update!(**args)\n @num_finite_buckets = args[:num_finite_buckets] if args.key?(:num_finite_buckets)\n @offset = args[:offset] if args.key?(:offset)\n @width = args[:width] if args.key?(:width)\n end", "def cut_fill!(remaining_partitions)\n # Fill each bin starting with the least filled\n self.each do |bin|\n break if remaining_partitions.empty? # End if all remaining partitions have been distributed already\n\n # Total number of operations that need to go into this bin\n total_operations_remaining = remaining_partitions.op_optimized_size\n total_free_space = self.total_free_space\n\n # How many operations need to go into the current bin\n operations_for_bin = [((@operations_lower_bound - bin.size).to_f / total_free_space * total_operations_remaining).ceil,\n @operations_lower_bound - bin.size].max\n\n # Fill sites that add up to \"operations_for_bin\" taken from \"remaining_partitions\" into the bin.\n # The rest stays in \"remaining_partitions\".\n dropped_partitions = remaining_partitions.drop_operations!(operations_for_bin)\n bin.add!(dropped_partitions)\n end\n end", "def upscale\n old_val_arr = @val_arr.compact\n old_key_arr = @key_arr.compact\n initialize(old_key_arr.zip(old_val_arr), @size + 32)\n end", "def resize\n doubled = Array.new(size*2)\n @items.each do |item|\n if item\n doubled[index(item.key, doubled.length)] = item\n #puts \"item: #{item.key} \\n#{doubled}\"\n end\n end\n @items = doubled\n end", "def update!(**args)\n @buckets = args[:buckets] if args.key?(:buckets)\n @overflow_bucket = args[:overflow_bucket] if args.key?(:overflow_bucket)\n @underflow_bucket = args[:underflow_bucket] if args.key?(:underflow_bucket)\n end", "def resize!\n self.capacity *=2 \n new_store = StaticArray.new(capacity)\n self.length.times { |i| new_store[i] = self[i] } \n self.store = new_store\n end", "def merge! hist\n self.frequency.reserve(hist.size) # avoid repeated reallocation if growing\n for i in 0...hist.size\n freq = hist.frequency[i] # avoid calling swig for zero frequencies\n self.accumulate(i, freq) if freq > 0\n end\n self\n end", "def _rebuild\n replacement = ActiveSupport::OrderedHash.new\n self.keys.sort.each do |key|\n replacement[key] = self[key]\n end\n\n self.replace(replacement)\n end", "def put(key, value)\n remove(key) unless get(key) == -1\n @count += 1\n resize! if @count == @size\n bucket = @map[key.hash % @size]\n bucket << [key, value]\n end", "def resize!\n dcap = @capacity * 2\n dstore = StaticArray.new(dcap)\n\n for i in 0...@length\n dstore[i] = self[i]\n end\n\n self.capacity = dcap\n self.store = dstore\n end", "def resize!\n new_capacity = capacity * 2\n # make new StaticArray with capacity that's double the length of the original store\n new_store = StaticArray.new(new_capacity)\n # iterate and copy over all the elements to the new store \n length.times{ |i| new_store[i] = self[i]}\n # set self.capacity to new capacity\n # set selt.store to new store \n self.store = new_store\n self.capacity = new_capacity\n end", "def prepare_buckets\n @buckets = {}\n @words.each do |word|\n next if word.size > 80\n @buckets[word.size] ||= []\n @buckets[word.size] << word\n end\n end", "def reset\n if @hash.respond_to?(:rehash)\n @hash.rehash # This should perform frozenness check.\n else\n raise FrozenError, \"can't modify frozen #{self.class.name}\" if frozen?\n end\n self\n end", "def increase_size\n hash_size *= 2\n end", "def rehash\n @rules.rehash\n @elements = nil\n end", "def distribute_jobs distrib, jobs\n\n # we can stop, we have reached the maximum number of press\n if distrib.size == @number_of_presses\n\n # copy the remaining jobs in last press and empty jobs array\n while !jobs.empty?\n distrib.last << jobs.pop\n end\n\n # we don't have any solution yet, copy this one\n if FairDistribution.is_distribution_empty?(@distribution)\n @distribution = distrib\n # let's check if this distribution is better than our previous\n # best and make it the new solution if it is\n elsif FairDistribution.time_required(distrib) <= @time_required &&\n FairDistribution.standard_deviation(distrib) < FairDistribution.standard_deviation(@distribution)\n @distribution = distrib\n @time_required = FairDistribution.time_required(@distribution)\n end\n\n return\n end\n\n # create a signature for this distribution so that we don't test\n # equivalent distributions.\n # ex: [[5, 4], [5, 4], [3, 3, 3]] and [[4, 5], [5, 4], [3, 3, 3]]\n # are equivalent and only one of them needs to be tested.\n signature = String.new\n distrib.each_with_index {|e, index| distrib[index] = e.sort }\n distrib.sort {|a,b| a.inject(0.0) { |sum, n| sum + n } <=> b.inject(0.0) { |sum, n| sum + n } }.each do |press|\n press.each { |job| signature << \"#{job};\" }\n signature << \"|\"\n end\n\n # have we tried yet this distribution?\n if @signatures.key?(signature) == false\n\n # we have exceeded the @time_required of our current best\n # distribution, we don't need to test this distribution\n if FairDistribution.time_required(distrib) <= @time_required\n # mark this distribution has tried\n @signatures[signature] = 1\n\n jobs.each_with_index do |job, index|\n\n # we create two new distributions\n # First one : we add one job in last press\n # Second one: we add one job in last press and we add one\n # more press\n distrib_copy = FairDistribution.dup_distrib(distrib)\n distrib_copy.last << job\n distrib_copy2 = FairDistribution.dup_distrib(distrib_copy)\n distrib_copy2 << Array.new\n\n # copying remaining jobs list and removing the job we added\n # in the two new distributions\n jobs_copy = jobs.dup\n jobs_copy.slice!(index)\n\n distribute_jobs distrib_copy, jobs_copy\n distribute_jobs distrib_copy2, jobs_copy.dup\n end\n end\n end\n end", "def put(entry)\n grow if should_grow?\n @slots[find_slot(entry)] = entry\n @count += 1\n end", "def update!(**args)\n @growth_factor = args[:growth_factor] if args.key?(:growth_factor)\n @num_finite_buckets = args[:num_finite_buckets] if args.key?(:num_finite_buckets)\n @scale = args[:scale] if args.key?(:scale)\n end", "def slice_fill!(remaining_partitions)\n # Total number of sites that need to be distributed\n total_sites_remaining = remaining_partitions.total_sites\n total_free_space = self.total_free_space\n\n # Fill each bin starting with the least filled\n self.each do |bin|\n\n # How many sites need to go into the current bin\n number_of_sites = ((@operations_lower_bound - bin.size).to_f / total_free_space * total_sites_remaining).ceil # FIXME: It's probably better to round down and save overflow in last bin\n\n # Fill \"number_of_sites\" sites taken from \"remaining_partitions\" into the bin. The rest stays in \"remaining_partitions\"\n dropped_partitions = remaining_partitions.drop_sites!(number_of_sites)\n bin.add!(dropped_partitions)\n end\n end", "def fully_extend_all reps=nil\n dist.branches.times do |i|\n hits = mapee(i).hits\n len = mapee(i).length\n mapee(i).clear_hits\n reps = (@len.to_f / len).round if reps.nil?\n mapee(i).length = @len\n reps.times do |j|\n new_hits = HitSq.new\n new_hits << hits\n new_hits * (1.0/reps)\n new_hits + (j.to_f / reps)\n# puts new_hits.hits.inspect\n mapee(i) << new_hits\n end\n# puts mapee(i).hits.hits.inspect\n end\n end", "def redistribute(input)\n number_to_redistribute = input.max\n index_to_redistribute = input.index(number_to_redistribute)\n input[index_to_redistribute] = 0\n\n while number_to_redistribute > 0\n index_to_redistribute = (index_to_redistribute + 1) % input.length\n input[index_to_redistribute] += 1\n number_to_redistribute -= 1\n end\n input\nend", "def sweep\n @accessed_keys.each { |k| @values.delete k }\n @accessed_keys = []\n end", "def resize!\n #dobule capacity\n #new store\n #place existing elements into new store\n capacity2 = @capacity * 2\n store2 = StaticArray.new(capacity2)\n @length.times { |i| store2[i] = @store[i] }\n @capacity = capacity2\n @store = store2\n end", "def updateRoutingTable()\n @routingTable = Hash.new\n\n # get a map hostname => (hostname, cost)\n weightsHash = @validWeights.hnameMap\n\n # implementation of Djikstra's algorithm -- follows Wikipedia psuedocode\n # pretty closely\n unvisited = Array.new\n\n weightsHash.keys.each { |node|\n @routingTable[node] = [nil, Float::MAX]\n unvisited.push(node)\n }\n\n @routingTable[@hostname] = [@hostname, 0]\n\n while !unvisited.empty?\n # find node in [unvisited] with minimum distance\n node = unvisited[0]\n unvisited.each { |nNode|\n if (@routingTable[nNode][1] < @routingTable[node][1]) then\n node = nNode\n end\n }\n\n # delete it from the set\n unvisited.delete(node)\n\n # for each neighbor that this node is connected to, that is still in the unvisited set\n weightsHash[node].keys.each { |neighbor|\n if unvisited.include?(neighbor) then\n altRoute = @routingTable[node][1] + weightsHash[node][neighbor]\n \n if (altRoute < @routingTable[neighbor][1])\n @routingTable[neighbor][0] = node\n @routingTable[neighbor][1] = altRoute\n end\n end\n }\n end\n end", "def flush\n to_be_processed = nil\n @hash_lock.synchronize do\n to_be_processed = @hash\n @hash = {}\n end\n process_hash(to_be_processed)\n end", "def upsert key, value\n # Check if there is already an entry for the given key. If there is one, we have to update the value and return.\n if (slot = find_slot(key))\n slot.value = value\n return\n end \n \n #If the entry does not exist, we have to check if there is enough room to add it to the table. \n # If the number of slots is too small, \n # we have to trigger a rebuild operation to ensure that the new entry fits into the internal storage\n rebuild if self.size > (@slots / 2)\n\n # Once we are sure that there is enough space, we have to hash the key and map it to a position into the internal storage. \n # In our case, we do that by double hashing the key’s hash code until we find an empty slot or run out of positions\n 0.upto(@slots - 1) do |i|\n index = double_hash key.hash, i\n slot = @table[index]\n if slot.nil? || slot.vacated \n # Once we successfully mapped a key to a position in the internal array, we increase the table size and return\n @table[index] = Slot.new key, value\n self.size += 1\n return\n end\n end\n raise \"Weak hash function.\"\nend", "def __add_keys_to(set) # used by parser # [\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n k = self.__at(kofs)\n if k._not_equal?(RemoteNil)\n set.add(k) # k,v pair\n else\n v = self.__at(kofs + 1)\n if v._not_equal?(RemoteNil)\n if v._isFixnum\n # internal collision chain\n idx = v\n begin\n ck = self.__at(idx)\n if ck._not_equal?(RemoteNil)\n set.add(ck)\n end\n idx = self.__at(idx + 2)\n end while idx._isFixnum\n else\n # a collision bucket , which is a small Hash \n v.__add_keys_to(set)\n end\n end\n end\n kofs += 2\n end\n end", "def my_hash_modification_method!(hash, num)\n hash.collect {|key,value|\n hash[key] = value + num}\n return hash\n end", "def modify\n each_with_object self.class.new do |hash_pair, ꜧ|\n key, val = yield hash_pair\n ꜧ[key] = val\n end\n end", "def compute_bucket(value, size = table.length)\n value.hash % size\n end", "def initialize\n @buckets = {}\n end", "def copy &alter\n Rumor.new(hash).tap &alter\n end", "def greedy1_initial_alt3!(remaining_partitions)\n bin_index = 0\n virtual_size = 0\n remaining_partitions.each do |partition|\n average_site_size = partition.size / partition.sites.size\n z = 0\n while z < partition.sites.size && bin_index < @list.size\n # Number of sites of this partition to go in bin bin_index\n z_prime = [((@operations_lower_bound - @list[bin_index].size - virtual_size).to_f/average_site_size).ceil,\n partition.sites.size - z].min\n\n # Assign site to bin\n mid_site = partition.sites[z + z_prime / 2]\n dropped_partition = partition.drop_specific_site!(mid_site)\n @list[bin_index].add!([dropped_partition])\n\n # -1 because we dropped one site, so the index z is also -1\n z += z_prime - 1\n if z >= partition.sites.size\n virtual_size = z_prime * average_site_size - @operations_worst_case\n else\n virtual_size = 0\n bin_index += 1\n end\n end\n end\n remaining_partitions\n end", "def greedy1_initial_alt!(remaining_partitions)\n\n virtual_remaining_partitions = DeepClone.clone remaining_partitions\n\n total_sites_remaining = remaining_partitions.total_sites\n total_free_space = self.total_free_space\n\n # Fill each bin starting with the least filled\n self.each_with_index do |bin, bin_index|\n\n # How many sites need to go into the current virtual bin\n sites_for_bin = ((@operations_lower_bound - bin.size).to_f / total_free_space * total_sites_remaining).ceil\n\n # Get partitions that need to go into the current virtual bin\n dropped_partitions = virtual_remaining_partitions.drop_sites!(sites_for_bin, compute = false)\n\n dropped_partitions.each do |partition|\n # Get site in the middle of partition\n mid_site = partition.sites[partition.sites.size / 2]\n\n # Actual assignment of site\n dropped_partition = remaining_partitions.list[partition.name].drop_specific_site!(mid_site)\n bin.add!([dropped_partition])\n end\n end\n\n remaining_partitions\n end", "def each\n @buckets.each_with_index do |count, index|\n yield(to_bucket(index), count)\n end\n end", "def greedy2_fill!(remaining_partitions)\n remaining_partitions.each do |src_partition|\n src_partition.sites.each do |site|\n\n smallest_bin = self.update_bin_sizes!.min\n target_partition = smallest_bin.list[src_partition.name]\n if target_partition.nil?\n smallest_bin.add!([Partition.new(src_partition.name, [site], src_partition.tree)])\n else\n target_partition.incr_add_sites!([site])\n end\n\n end\n end\n end", "def index(key, size)\n if @items[key.sum % size] && @items[key.sum % size].key != key\n resize\n key.sum % size\n else\n key.sum % size\n end\n end", "def []=(key, value)\n puts \"-\" * 10\n hash_index = index(key, @items.size)\n if @items[hash_index] == nil\n # puts \"No collision. Inserting into Hash...\"\n new_hash_item = HashItem.new(key, value)\n @items[hash_index] = new_hash_item\n elsif @items[hash_index].value == value\n # puts \"This is already in the hash...exiting insertion\"\n return\n elsif @items[hash_index].key == key\n # puts \"This item has a duplicate key...resizing and exiting\"\n self.resize\n elsif @items[hash_index] != value\n # puts \"This index is taken - resizing...\"\n self.resize\n self[key] = value\n end\n puts \"Key Inserted: #{key}\"\n puts \"Value Inserted: #{value}\"\n puts \"Hash Index: #{hash_index}\"\n puts \"Hash Size: #{@items.size}\"\n puts \"Hash: #{@items}\"\n puts \"-\" * 10\n end", "def flush_slots_cache\n @slots = Array.new(RedisClusterHashSlots)\n end", "def greedy1_initial_alt2!(remaining_partitions)\n\n virtual_remaining_partitions = DeepClone.clone remaining_partitions\n\n sites_in_current_partition = 0\n # Fill each bin starting with the least filled\n self.each_with_index do |bin, bin_index|\n\n free_space = (@operations_lower_bound - bin.size)\n\n # condition can be equal since the first remaining partition might be split\n dropped_partitions = if virtual_remaining_partitions.first.op_optimized == free_space || (virtual_remaining_partitions.size == 1 && virtual_remaining_partitions.first.op_optimized <= free_space)\n virtual_remaining_partitions.drop!(1)\n sites_in_current_partition = 0\n elsif virtual_remaining_partitions.first.op_optimized < free_space\n partition = virtual_remaining_partitions.drop!(1).first\n sites_in_current_partition = virtual_remaining_partitions.first.sites.size\n space_per_site = (virtual_remaining_partitions.first.op_optimized / sites_in_current_partition).floor\n [partition,\n virtual_remaining_partitions.drop_sites!(((free_space - partition.op_optimized).to_f/space_per_site).ceil, compute = false)]\n else\n sites_in_current_partition = virtual_remaining_partitions.first.sites.size if sites_in_current_partition == 0\n space_per_site = (virtual_remaining_partitions.first.op_optimized / sites_in_current_partition).floor\n virtual_remaining_partitions.drop_sites!((free_space.to_f/space_per_site).ceil, compute = false)\n end\n\n # Phase 2: Add site in the middle of each partition to the bin\n dropped_partitions.each do |partition|\n # Get site in the middle of partition\n mid_site = partition.sites[partition.sites.size / 2]\n\n # Actual assignment of site\n dropped_partition = remaining_partitions.list[partition.name].drop_specific_site!(mid_site)\n bin.add!([dropped_partition])\n end\n end\n\n remaining_partitions\n end", "def resize!\n new_array = StaticArray.new(@store.length * 2)\n self.each_with_index do |el, i|\n new_array[i] = el\n end\n @store = new_array\n end", "def finalize\n yield [key, size]\n end", "def recycle_bin_space\n recycle_bin_space = 0\n @bins.each do |bin|\n if bin.type == 'Recycle'\n recycle_bin_space = bin.bin_level.to_i + recycle_bin_space\n end \n end\n recycle_bin_space\n end", "def before_mapping_hash(gid_array)\n @log.info \"BEFORE_MAPPING_HASH\"\n ##TODO test test test\n\n hash = Hash.new\n gid_array.each { |gid| hash[gid] = @redis_connector.real_partition_of_node(gid).to_i }\n hash\n end", "def initialize()\n @buckets = []\n end", "def lru_update(key)\n @lru.unshift(@lru.delete(key)|| key)\n end", "def []=(key, item)\n item = super\n item.lru_key = key\n lru_insert(item)\n end", "def put(key, value)\n \treturn if @capacity.zero?\n if @cache.key?(key) || !@cache.key?(key) && @cache.size < @capacity\n @cache[key] = value\n @frequency[key] += 1\n i = @frequency[key]\n if i == 1 # a new item\n @rentused[1] = { key => nil } if @rentused[1].nil?\n @rentused[1][key] = nil\n else\n @rentused[i - 1].delete(key)\n @rentused[i] = { key => nil } if @rentused[i].nil?\n @rentused[i][key] = nil\n end\n else\n 1.upto(100).each do |i|\n next unless !@rentused[i].nil? && !@rentused[i].empty?\n k = @rentused[i].keys.first\n @cache.delete(k)\n @frequency.delete(k)\n @rentused[i].delete(k)\n break\n end\n @cache[key] = value\n @frequency[key] = 1\n @rentused[1] = { key => nil } if @rentused[1].nil?\n @rentused[1][key] = nil\n # p @cache, @frequency, @rentused\n end\n end", "def reinstall_demands\n @cached_demands.each do |key, demand|\n @energy_graph.node(key).demand = demand\n end\n end", "def put(key, value)\n if @hash.has_key? key\n @dlink.move_to_head key\n @hash[key] = value\n return @hash\n end\n if @hash.keys.size >= @capacity\n node = @dlink.remove_tail\n @hash.delete node.val\n end\n @hash[key] = value\n @dlink.add key\n @hash\n end", "def collate!\n @buckets = @buckets.sort { |a,b| b.time <=> a.time }\n @ordered = {}\n @buckets.map { |o| o.identity }.uniq.each do |identity|\n @ordered[identity] = @buckets.select { |o| o.identity == identity }\n end\n return @buckets\n end", "def []=(key, value)\n there_is_a_collision = @items[index(key, size)] != nil && @items[index(key,@items.length)].key != key \n\n #When a collision occurs, expand the size of the hash by doubling its existing size.\n while there_is_a_collision\n resize\n there_is_a_collision = @items[index(key, size)] != nil\n end\n @items[index(key,@items.length)] = HashItem.new(key, value)\n\n end", "def put(namespace, key, entry)\n @lock.synchronize do\n now = Time.now.utc.to_i\n prune_expired(now)\n @entries[full_key(namespace, key)] = entry\n prune_size\n end\n end", "def my_hash_modification_method!(source, thing_to_modify)\n# source = Hash[source.map {|k,v| [k, thing_to_modify + v ]}]\nsource.each do |key, value|\n source[key] = value + thing_to_modify\nend\nend", "def update!(**args)\n @score_buckets = args[:score_buckets] if args.key?(:score_buckets)\n end", "def reset!\n @significant_keys = nil\n @orders = Hash.new{|h,k| h[k] = Hash.new{|h2, k2| h2[k2] = []}}\n @key_count = Hash.new(0)\n @cache = {}\n end", "def sort_by_size\n @mappers << Proc.new do |allocations|\n allocations.sort_by { |key, value| -value.size }\n .inject({}) { |hash, pair| hash[pair[0]] = pair[1]; hash }\n end\n\n self\n end", "def update_slots(hash)\n hash.each do |k, v|\n self[k] = v\n end\n\n self\n end", "def bucket_sort\n buckets = {}\n #Ideal for known and uniformly distributed range. Sort age of employees for eg.:\n @array.each do |age|\n bucket = age/10\n buckets[bucket] ||= []\n buckets[bucket] << age\n end\n\n result = []\n for i in 0..20\n arr = buckets[i]\n puts \"i=#{i}, buckets[i]=#{arr}\"\n puts \"result=#{result}, sorted value=#{insertion_sort(arr)}\" if arr\n result << insertion_sort(arr) if arr && arr != []\n end\n @array = result.flatten\n end", "def adjust_prob(hash, position)\n hash.each_key do | pos |\n diff = (pos - position).abs\n # 1 Mb is the cut off on either side\n cutoff = 1000000\n if diff < cutoff\n adj = hash[pos] * (diff/cutoff)\n hash[pos] = adj.to_i\n end\n end\n hash\nend", "def my_hash_modification_method!(my_family_pets_ages, n)\n my_family_pets_ages.each {|key, value| my_family_pets_ages[key] = value + n}\nend", "def each(&block)\n @monitor.synchronize do\n expire!\n @stash.map { |key, entry| [key, entry.value] }.each(&block)\n end\n end", "def rekey_as_needed; end", "def greedy1_initial!(remaining_partitions)\n # Initialize\n site_list = remaining_partitions.sites\n site_index = 0\n partition_index = 0\n total_sites_remaining = remaining_partitions.total_sites\n\n\n total_free_space = self.total_free_space\n\n # Fill each bin starting with the least filled\n self.each_with_index do |bin, bin_index|\n\n # How many sites need to go into the current bin\n sites_for_bin = ((@operations_lower_bound - bin.size).to_f / total_free_space * total_sites_remaining).floor\n\n # Pick (random) site of partition, add to bin and drop from \"remaining_partitions\"\n dropped_partition = remaining_partitions.list.values[partition_index].drop_random_site!\n bin.add!([dropped_partition])\n\n # Do we need to fill two partitions in this bin?\n if site_list[site_index].values.first != site_list[site_index + sites_for_bin - 1].values.first\n partition_index += 1\n\n # Pick (random) site of partition, add to bin and drop from \"remaining_partitions\"\n dropped_partition = remaining_partitions.list.values[partition_index].drop_random_site!\n bin.add!([dropped_partition])\n\n elsif bin_index < @list.size - 1 # Prevent index out of bound\n # Is there a partition switch directly at the beginning of the next bin?\n if site_list[site_index + sites_for_bin - 1].values.first != site_list[site_index + sites_for_bin].values.first\n partition_index += 1\n end\n end\n\n site_index += sites_for_bin\n end\n\n remaining_partitions\n end", "def my_hash_modification_method(source, things_to_modify)\n source.each {|k, v| source[k] = v + things_to_modify}\nend", "def remap\n # This is Ruby magic for turning a hash into an array into a hash again\n Hash[*self.map do |key, value|\n yield key, value\n end.compact.flatten]\n end", "def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end", "def rehash\n out = {}\n each_pair { |k, v| out[k] = v }\n replace out\n end", "def my_hash_modification_method!(source, thing_to_modify)\n\tsource.each {|k, v| source[k] = v + thing_to_modify}\nend", "def _process_hashed(hashed)\n hashed.each_pair do |key, value|\n if value.equal?(Utils::DeletedMarker)\n hashed.delete(key)\n elsif Utils.hashable?(value)\n _process_hashed(value.to_hash).freeze\n end\n end\n\n hashed\n end" ]
[ "0.6982203", "0.675086", "0.6451028", "0.605086", "0.57184774", "0.5632947", "0.56229144", "0.55872303", "0.5548985", "0.54727006", "0.54340965", "0.5432246", "0.5380388", "0.5318216", "0.528489", "0.51877475", "0.517789", "0.5117986", "0.5104547", "0.50954103", "0.5089018", "0.5086315", "0.5071407", "0.5063105", "0.49968344", "0.49955", "0.4972254", "0.49598554", "0.4957336", "0.49526566", "0.49289238", "0.49194154", "0.491061", "0.49022117", "0.48934457", "0.48897377", "0.4885419", "0.48493242", "0.48417827", "0.48065585", "0.48015192", "0.47796932", "0.47766745", "0.47711912", "0.47475964", "0.47317544", "0.472579", "0.47252467", "0.47124583", "0.47059685", "0.47050425", "0.46940136", "0.46881258", "0.46863765", "0.46860948", "0.4674836", "0.4625704", "0.46190616", "0.46151456", "0.46047467", "0.46046463", "0.4595158", "0.4594547", "0.45935702", "0.45909333", "0.4577431", "0.45715702", "0.45612842", "0.45591596", "0.45589256", "0.45377967", "0.45369673", "0.4535838", "0.45302662", "0.45276472", "0.4518862", "0.4509898", "0.45012438", "0.4496085", "0.44765145", "0.4466465", "0.44656977", "0.44656205", "0.44648755", "0.44631308", "0.44443393", "0.44424796", "0.4442353", "0.44404292", "0.44364694", "0.44334838", "0.4432988", "0.4430094", "0.44271746", "0.44236138", "0.44226143", "0.44200972", "0.4418228", "0.44173926", "0.44106582" ]
0.68818825
1
ensure user account is active
def active_for_authentication? super && !deleted_at end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_active_user\n unless current_user && current_user.status == UserStatus::ACTIVE\n flash[:alert]= I18n.t 'auth.msg.lock_account'\n redirect_to new_user_sessions_url\n return false\n end\n end", "def activate\n @user.activate! if @user.pending?\n redirect_to root_url\n end", "def check_user_account!\n if(current_user.present? && (current_user.service_type == 'pending' || !current_user.is_active?))\n service_type = current_user.service_type\n sign_out(current_user)\n redirect_to root_path, :flash => {:notice => \"Your account is in waiting list for approval by Aa Express Staff.You will be notified when your account is ready.\"} and return if service_type == 'pending'\n redirect_to root_path, :flash => {:notice => \"Your account is de-activated by Aa Express Staff, please contact to Aa Express Staff for account activation.\"}\n end\n end", "def activate \r\n redirect_to(home_url) && return unless Setting.self_registration? && params[:token]\r\n token = Token.find_by_action_and_value('signup', params[:token])\r\n redirect_to(home_url) && return unless token and !token.expired?\r\n user = token.user\r\n redirect_to(home_url) && return unless user.status == User::STATUS_REGISTERED\r\n user.status = User::STATUS_ACTIVE\r\n if user.save\r\n token.destroy\r\n flash[:notice] = l(:notice_account_activated)\r\n end\r\n redirect_to :action => 'login'\r\n end", "def active_user\n redirect_to(root_path) unless (current_user != nil && current_user.active == true)\n end", "def active_user\n user = pending_user\n user.activate! if user.valid?\n user\n end", "def check_for_pending_account\n user = User.pending.find_by_login(params[:login]) || User.pending.find_by_identity_url(params[:openid_identifier])\n user = nil unless (user && user.authenticated?(params[:password])) unless params[:openid_identifier]\n flash.now[:notice] = 'Please activate your account first by clicking on the link emailed to you' if user\n end", "def is_active(user)\n user.status_id != 0\n end", "def activate\n if @user.inactive? && @user.created_by_admin?\n if @user.is_regular? && @user.profile.penultimate_step_complete?\n @user.activate!\n @user.save_profinda_profile\n render json: { status: 'active' }\n elsif @user.is_external? && @user.profile.first_step_completed?\n @user.activate!\n render json: { status: 'active' }\n else\n render json: { status: 'user can\\'t be activate' }\n end\n else\n render json: { status: 'user is active' }\n end\n end", "def require_active_account\n get_current_account_and_membership\n return user_not_authorized unless @current_account\n\n if @current_account.billing_error?\n if @current_membership.owner?\n redirect_to account_billing_path(@current_account), alert: 'Your account is past due. Please enter payment details to reactivate.'\n else\n redirect_to account_past_due_path(@current_account), alert: \"This account is past due. Please contact your account owner (#{@current_account.owner.first_name} #{@current_account.owner.last_name}).\"\n end\n end\n end", "def valid_user\n if logged_in?\n user = current_user\n unless (user.activated?)\n redirect_to root_url\n end\n end\n end", "def update? ; user.account.active? ; end", "def activate\n user = User.find_by_username params[:username]\n if user && user.activation == params[:activation]\n user.activation = \"ACTIVATION_ACTIVE\"\n user.save()\n render status: 200, json: {error: false}\n else\n render status: 403, json: {error: true}\n end\n end", "def active_for_authentication?\n super && !suspended_account\n end", "def valid_user\n unless (@user && !@user.activated? &&\n @user.authenticated?(:activation, params[:id]))\n flash[:danger] = \"Invalid credentials\"\n redirect_to root_path\n end\n end", "def verify_active\n account = Account.find(params[:id])\n if account.active_until < Time.now.utc\n if account.stripe_customer_id\n flash[:subscription_expired] = \"Your subscription has expired! Don't worry, your data is perfectly fine, but you'll need to update your payment information -- it looks like there was a problem charging your card on file.\"\n session[\"preferred_account_id\"] = account.id\n redirect_to edit_subscription_path\n else\n flash[:subscription_expired] = \"Your subscription has expired! Don't worry, your data is perfectly fine, but you'll need to enter your payment information and become a paying subscriber.\"\n session[\"preferred_account_id\"] = account.id\n redirect_to new_subscription_path\n end\n end\n end", "def activate\n authorize current_user\n\n user = User.find(params[:id])\n return if user.blank?\n\n begin\n user.active = !user.active\n user.save!\n render json: {\n code: 1,\n msg: format(_(\"Successfully %{action} %{username}'s account.\"),\n action: user.active ? _('activated') : _('deactivated'),\n username: user.name(false))\n }\n rescue StandardError\n render json: {\n code: 0,\n msg: format(_('Unable to %{action} %{username}'),\n action: user.active ? _('activate') : _('deactivate'),\n username: user.name(false))\n }\n end\n end", "def activate\n @user = User.find(:first, :conditions => [ 'id = ? AND token = ? AND token_expiry >= ?',\n @params[:id], @params[:token], 0.minutes.from_now ])\n if @user\n reset_session # Reset old sessions if exists\n @user.update_attributes({ :userstatus_id => 2,\n :token => nil, :token_expiry => nil })\n url = url_for(:controller => 'user', :action => 'login')\n UserNotifier.deliver_activation(@user, url) \n render :action => 'activated'\n else\n render :action => 'invalid'\n end\n end", "def check_user_status\n user = current_user\n if user && user.status != 2\n redirect_to signupcode_settings_path\n end\n end", "def check_user_background\n self.status = Status::PENDING_ADMIN_ACTION if offender && offender.new_user?\n end", "def activated_current_user?\n unless current_user.activated?\n flash[:warning] = \"please activate your account first\"\n redirect_to help_path(anchor: 'activation')\n end\n end", "def valid_user\n # unless (@user && @user.activated? && @user.authenticated?(:reset, params[:id])) \n unless(@user && @user.activated?)\n redirect_to root_url\n end\n end", "def active_user\n redirect_to(root_url) unless current_user.active?\n end", "def activate\n user = User.find_by_token(params[:token])\n unless user.nil?\n unless user.activated?\n user.activate\n user.save\n #notify admins\n UserMailer.deliver_notify_admins_signup(User.admins, user)\n #login\n self.current_user = user\n flash[:notice] = 'Account successfuly activated.'\n redirect_to profile_path(user.login)\n else\n render :partial => '/sessions/already_activated', :layout => true\n end\n else\n render :text => '<strong>Invalid Request!</strong>', :layout => true\n end\n end", "def on_users_account\n true\n end", "def valid_user\n unless (@user && @user.activated? &&\n @user.authenticated?(:email_change, params[:id]))\n flash[:danger] = \"Invalid credentials\"\n redirect_to root_path\n end\n end", "def active_account(email)\n raise StandardError, 'The account can not be activate' if\n email.nil? || email.user.id != self.id\n\n email.update!(checked: true, primary: true)\n self.update!(status: true)\n\n Notifier.send_signup_verify_email(email.email, self).deliver_later\n end", "def activate_account!\n update_attribute :is_active, true\n end", "def ensure_user_logged_in\n bounce_user unless current_user\n end", "def check_active_user\n if !current_user.active?\n current_user.plan = nil\n end\n end", "def activated?\n self.user && self.user.activated?\n end", "def activate\n @user = User.find(params[:id])\n\n if @user.activated?\n flash[:fail] = \"Account already activated\"\n redirect_to root_url\n\n elsif @user.activation_token && params[:activation_token] == @user.activation_token\n @user.activated = true\n @user.activation_token = nil\n\n if @user.save\n flash[:success] = \"Activated account\"\n sign_in!(@user)\n redirect_to user_url(@user)\n else\n flash[:errors] = [\"Unable to activate account\"] + @user.errors.full_messages\n redirect_to root_url\n end\n\n else\n flash[:fail] = \"Invalid activation token\"\n redirect_to root_url\n end\n\n end", "def activate\r\n Marketplace::Database.instance.delete_deactivated_user(self)\r\n Marketplace::Database.instance.add_user(self)\r\n Marketplace::Activity.create(Activity.USER_REACTIVATE, self, \"#{self.name} has been reactivated\")\r\n end", "def active_for_authentication?\n super && account_active?\n end", "def active_for_authentication?\n super && activation_status == true\nend", "def activate\n self.current_user = params[:activation_code].blank? ? :false : User.find_by_activation_code(params[:activation_code])\n if logged_in? && !current_user.active?\n current_user.activate\n # flash[:notice] = 'Your account has been activated.'\n end\n redirect_to embassy_path\n end", "def activate\n @user = User.find(params[:format])\n @user.update(:active_flag => true)\n flash[:info] = \"User Activated\"\n ## email user and line management to indicate the profile has been activated\n UserMailer.activated_user_email(@user).deliver\n redirect_to users_path\n end", "def active_for_authentication?\r\n super && active_status?\r\n end", "def activate\n (redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present?\n token = Token.find_token('register', params[:token].to_s)\n (redirect_to(home_url); return) unless token and !token.expired?\n user = token.user\n (redirect_to(home_url); return) unless user.registered?\n user.activate\n if user.save\n token.destroy\n flash[:notice] = l(:notice_account_activated)\n end\n redirect_to signin_path\n end", "def is_activated\r\n\t\tif !current_user.activated\r\n\t\t\tlog_out\r\n\t\t\tredirect_to root_path\r\n\t\t\tflash[:error] = \"You have been logged out.\"\r\n\t\tend\r\n\tend", "def activate_user(user)\n user.status_id=0\n user.save\n end", "def activate_account\n user = User.find_by_confirmation_token(params[:confirmation_token])\n if user && (Time.diff(Time.now, user.confirmation_sent_at)[:day] <= 2)\n user.update_attributes!(:confirmed_at => Time.now,\n :confirmation_status => true)\n sign_in user, :bypass => true\n flash[:success] = 'Your account has been activated successfully.'\n else\n flash[:error] = 'Hey Buddy, You are late :( The URL has expired.'\n end\n redirect_to root_path\n end", "def active?\n\t\t\treturn account_life_cycle_status == ACTIVE \n\t\tend", "def active_user\n User.find_by(activated: true)\n end", "def valid_user\n \tunless(@user && @user.activated? && @user.authenticated?(:reset, params[:id]))\n \t\tredirect_to root_url\n \tend\n end", "def active?\n self.employee_authenticate && self.employee_profile\n end", "def confirm\n user = User.find(params[:id])\n authorize user\n if user.state != \"active\"\n user.confirm\n user.make_user_a_member\n\n # assume this type of user just activated someone from somewhere else in the app\n flash['notice'] = \"Activation of #{user.name_and_login} complete.\"\n redirect_to(session[:return_to] || root_path)\n end\n end", "def active?\n !expired? && !revoked?\n end", "def banned?\r\n if current_user.present? && !current_user.activated?\r\n sign_out current_user\r\n flash[:error] = \"This account has been suspended....\"\r\n redirect_to new_user_session_path\r\n end\r\n end", "def activate!(user)\n return false if self.active?\n\n @user = user\n\n create_hook!\n\n self.active = true\n self.save!\n end", "def requires_user_existence!\n if not e.user_exists?\n error \"You have to setup your user before you can perform this action.\"\n exit\n end\n end", "def activate\n self.current_user = params[:activation_code].blank? ? false : User.find_by_activation_code(params[:activation_code])\n if logged_in? && !current_user.active?\n current_user.activate\n flash[:notice] = \"Signup complete!\"\n end\n redirect_back_or_default('/')\n end", "def valid_user\n unless ( @user && @user.activated? &&\n @user.authenticated?( :reset, params[ :id]))\n redirect_to root_url\n end\n end", "def check_user_status\n if current_user.is_a?(User) && (current_user.suspended? || current_user.banned?)\n if current_user.suspended? \n flash[:error] = t('suspension_notice', :default => \"Your account has been suspended. You may not add or edit content until your suspension has been resolved. Please contact us for more information.\")\n else\n flash[:error] = t('ban_notice', :default => \"Your account has been banned. You are not permitted to add or edit archive content. Please contact us for more information.\")\n end\n redirect_to current_user\n end\n end", "def valid_user\n unless (@user && @user.authenticated?(:activation, params[:id]))\n flash[:danger] = \"Invalid activation link\"\n redirect_to login_url\n return\n end\n if @user.password_set?\n flash[:danger] = \"Password already set\"\n redirect_to login_url\n end\n end", "def active_for_authentication?\n !deactivated? && super\n end", "def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end", "def valid_user\n\t\t\tunless (@user && @user.activated? && \n\t\t\t\t\t\t\t@user.authenticated?(:reset, params[:id]))\n\t\t\t\tredirect_to root_url\n\t\t\tend\t\n\t\tend", "def user_active?\n\t\treturn true if teacher? && !activated\n\tend", "def activate\n current_user = params[:activation_code].blank? ? false : User.find_by_activation_code(params[:activation_code])\n if current_user && !user_signed_in? && !current_user.account_active?\n current_user.activate\n # current_user.save_ip(request.remote_ip)\n redirect_to new_user_session_path,:notice => \"Congratulations! Your account has now been activated!\"\n else\n redirect_to :root\n end\n end", "def active_for_authentication?\n super && !expired?\n end", "def activate\n self.current_user = params[:activation_code].blank? ? false : User.find_by_activation_code(params[:activation_code])\n if logged_in? && !current_user.active?\n current_user.activate\n flash[:notice] = \"Signup complete! Go ahead and log in.\"\n end\n redirect_to :controller => \"sessions\", :action => \"new\"\n end", "def active_for_authentication?\n super && !deactivated_at\n end", "def active_for_authentication?\n super && !deactivated_at\n end", "def active_for_authentication?\n super && !deactivated_at\n end", "def user_onoff_flag\n @requested_user = User.find_by_account_number(params[:id])\n if @requested_user.is_active?\n @requested_user.update_columns(:is_active => false)\n redirect_to admin_index_path, :flash => {:notice => \"Requested user(#{@requested_user.first_name} #{@requested_user.last_name}) account successfully de-activated.\"}\n else\n @requested_user.update_columns(:is_active => true)\n redirect_to admin_index_path, :flash => {:notice => \"Requested user(#{@requested_user.first_name} #{@requested_user.last_name}) account successfully activated.\"}\n end\n end", "def inactive_user?\n self.status == \"Inactive\"\n end", "def ensure_user_has_profile\n bounce_user unless current_user and current_user.profile\n end", "def activate\n @user = User.find_by(activation_token: params[:activation_token])\n @user.activate!\n login_user!(@user)\n flash[:notice] = 'Successfully activated your account!'\n redirect_to root_url\n end", "def activate\n logout_keeping_session!\n @user = ::User.find_by_activation_code(params[:ac]) unless params[:ac].blank?\n case\n when (!params[:ac].blank?) && @user && !@user.is_active?\n flash[:info] = \"Account activated. please login.\"\n @user.activate!\n redirect_to login_url\n when params[:ac].blank?\n flash[:error] = \"The activation code was missing. Please follow the URL from your email.\"\n redirect_to(root_url)\n else\n flash[:error] = \"We couldn't find a user with that activation code -- check your email? Or maybe you've already activated -- try signing in.\"\n redirect_to(root_url)\n end\n end", "def activate\n unless self.recently_activated?\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.status = \"active\" if has_role?(:employer_admin) || has_role?(:applicant)\n \n save(:validate => false)\n end\n end", "def valid_user\n unless (@user && @user.activated? &&\n @user.authenticated?(:reset, params[:id]))\n redirect_to root_url\n end\n end", "def activate\n @user = User.new(params)\n @user.salt = params[:token]\n\n true_user = User.find_by_email(@user.email)\n if true_user.nil?\n @user.errors.add(:email, \"the email is not registed in the system\")\n else\n @user.errors.add(:token, \"invalid authoization token\") if true_user.salt != @user.salt\n end\n\n respond_to do |format|\n if @user.errors.empty?\n true_user.active = true\n true_user.save\n self.current_user = true_user\n flash[:success] = t \"flash.msg.activation-success\"\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"activation_instructions\" }\n end\n end\n end", "def verify_and_activate!\n self.verify! unless self.verified?\n \n # hack to make sure people who come in via yammer get their verified_at column\n # set properly\n self.update_column(:verified_at, Time.now) if self.verified_at.blank?\n\n #this used to be in signups controller and password resets controller\n #but moving to here, because we use this method in more spots\n #and i made management of perishable token manual(instead of authlogic handling it)\n #so be safe and reset it whenever we verify\n self.reset_perishable_token!\n \n #activate if all the info is good\n self.set_status!(:active) if self.ok_to_login?\n end", "def enforce_logged_in\n bounce unless current_user\n end", "def activate\n\t\t#puts \"sessions_controller.activate\"+params.inspect\n\t\tuser = User.find(params[:id]) if User.exists?(params[:id])\n\t\tunless user.nil?\n\t\t\tif user.may_connect?\n\t\t\t\ttype=Typesobject.find_by_forobject_and_name(\"user\", PlmServices.get_property(:TYPE_USER_PERSON))\n\t\t\t\tuser.typesobject=type\n\t\t\t\tif user.save\n\t\t\t\t\t@current_user = user\n\t\t\t\t\tsession[:user_id] = user.id\n\t\t\t\t\tflash[:notice] = t(:ctrl_role_needed)\n\t\t\t\t\trespond_to do |format|\n\t\t\t\t\t\tformat.html { render :action => :edit }\n\t\t\t\t\t\tformat.xml { head :ok }\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tflash[:notice] = t(:ctrl_new_account_not_validated, :user=>user.login)\n\t\t\t\t\t#puts \"sessions_controller.activate new_account_not_validated :\"+user.to_s\n\t\t\t\t\trespond_to do |format|\n\t\t\t\t\t#format.html { render :action => :new }\n\t\t\t\t\t\tformat.html { redirect_to user}\n\t\t\t\t\t\tformat.xml {render :xml => errs, :status => :unprocessable_entity }\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_user_not_valid,:user=>user )\n\t\t\t\t@current_user=nil\n\t\t\t\t#puts \"sessions_controller.activate user_not_valid :\"+user.to_s\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tformat.html { redirect_to user }\n\t\t\t\t\tformat.xml {render :xml => errs, :status => :unprocessable_entity }\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tflash[:notice] = t(:ctrl_new_account_not_existing, :user=>nil)\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { render :action => :new }\n\t\t\t\tformat.xml {render :xml => errs, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\n\tend", "def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.make_admin_if_first_user\n save(false)\n end", "def logged_in?\n current_account != :false && current_account.active?\n end", "def activate\n self.current_user = params[:activation_code].blank? ? :false : User.find_by_activation_code(params[:activation_code])\n if logged_in? && !current_user.active?\n current_user.activate\n redirect_to(user_path(self.current_user) + '?welcome')\n else\n redirect_to '/'\n end\n end", "def verify\n unless params[:user].nil?\n begin\n @user = User.find(params[:member_id].to_i)\n rescue\n redirect_to \"/main\"\n return\n end\n unless @user.nil?\n if params[:security_code] == @user.signup_validation\n @user.validated = 1\n @user.activated = 1\n if @user.save\n flash[:success] = \"Your account is now activated!\"\n end\n end\n end\n end\n redirect_to \"/main\"\n end", "def active_for_authentication?\n # logger.debug self.to_yaml\n super && account_active?\n end", "def activate\n @user = User.find(params[:id])\n @user.activate\n redirect_to :back\n end", "def can_activate?\n self.person && self.person_match? && self.has_not_expired?\n end", "def account_active?\n blocked_at.nil?\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 active_for_authentication?\n #remember to call the super\n #then put our own check to determine \"active\" state using \n #our own \"is_active\" column\n super and self.is_active?\n end", "def active_for_authentication?\n #remember to call the super\n #then put our own check to determine \"active\" state using \n #our own \"is_active\" column\n super and self.is_active?\n end", "def active_for_authentication?\n #remember to call the super\n #then put our own check to determine \"active\" state using\n #our own \"is_active\" column\n super and self.is_active?\n end", "def active_for_authentication?\n #remember to call the super\n #then put our own check to determine \"active\" state using\n #our own \"is_active\" column\n super and self.is_active?\n end", "def active_for_authentication?\n #remember to call the super\n #then put our own check to determine \"active\" state using\n #our own \"is_active\" column\n super and self.is_active?\n end", "def activate_user\n self.save\n self.send_user_notification_email\n end", "def activate_if_invited\n invited_user = Invite.find_by_invited_user_email(self.email)\n if ! invited_user.nil?\n invited_user.update_attribute(:invited_user_id, self.id)\n self.account_active = 1\n self.save!\n end\n end", "def activate!\n @activated = true\n\n self.active = true\n \n # Authlogic resets the perishable token by default on save, but I'm leaving the call\n # to reset_perishable_token! here directly to help reveal intent (which's is kinda a\n # dead purpose after this long comment, but who cares).\n #\n # This also saves the record.\n #\n reset_perishable_token!\n end", "def active_for_authentication? \n \tsuper && approved?\n \t\n\tend", "def active_for_authentication?\n super && !self.deactivated # i.e. super && self.is_active\n end", "def is_active?\n # Alternatively in the future we may have\n # a role which is considered a non-active role\n true\n end", "def ensure_user_created\n if User.find_by_ldap_uid(ldap_user.uid)\n Rails.logger.debug(\"User in user table.\")\n true\n else\n Rails.logger.debug(\"User not in user table, redirecting to new user form.\")\n redirect_to(new_users_url) and return\n end\n end", "def handle_activation(user)\n\t\t\n\tend", "def active_for_authentication?\n super && isActive\n end", "def active_for_authentication? \n super && approved? \n end", "def active_for_authentication?\n super && active\n end" ]
[ "0.7820145", "0.73031145", "0.7296796", "0.72714067", "0.72605324", "0.7186465", "0.7184313", "0.7182273", "0.7140091", "0.70876205", "0.7038106", "0.7035326", "0.7020518", "0.699827", "0.69793344", "0.6973365", "0.6956432", "0.69559634", "0.69512725", "0.6950539", "0.69385093", "0.6932442", "0.69199115", "0.69018686", "0.68798816", "0.6865215", "0.68465483", "0.6843079", "0.6824744", "0.6808344", "0.68067837", "0.6805385", "0.67963004", "0.679565", "0.6777184", "0.6764612", "0.67311895", "0.67092294", "0.6692956", "0.668438", "0.6682959", "0.6676932", "0.66721797", "0.6665885", "0.66518945", "0.6631125", "0.6628759", "0.6627563", "0.6622255", "0.6614107", "0.66046274", "0.6602763", "0.6599426", "0.6597388", "0.6595856", "0.65746486", "0.6570267", "0.65654856", "0.655616", "0.6556082", "0.6548471", "0.6538687", "0.6530963", "0.6530963", "0.6530963", "0.65212375", "0.65020037", "0.6489989", "0.64813757", "0.6475498", "0.647465", "0.6471701", "0.6447744", "0.6431068", "0.642827", "0.64272296", "0.64247733", "0.64217806", "0.64214426", "0.6415731", "0.64078933", "0.6400414", "0.63952583", "0.63905525", "0.63845193", "0.63830936", "0.63830936", "0.63669133", "0.63669133", "0.63669133", "0.63664365", "0.63600767", "0.6356655", "0.635067", "0.6344738", "0.63378245", "0.633704", "0.63335437", "0.63287956", "0.6327968", "0.6320665" ]
0.0
-1
provide a custom message for a deleted account
def inactive_message !deleted_at ? super : :deleted_account end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inactive_message\n \t!delete_flag ? 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 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 !is_deleted ? super : :deleted_account \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 account_deleted(user)\n setup_email(user)\n @subject += head_encode(\"%s's account was deleted\" / user.login)\n @body[:user] = user\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message \n \t!deleted_at ? super : :deleted_account \n end", "def inactive_message\n !self.deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account \n end", "def inactive_message\n !disabled_at ? super : :deleted_account\n end", "def inactive_message\n deleted_at ? :deleted : super\n end", "def user_deleted\n UserMailer.user_deleted\n end", "def delete_account\n UserMailer.delete_account(current_user, confirm_delete_users_url(code: ApplicationHelper.encrypt_text(\"#{Date.today}::#{current_user.id}\"))).deliver_later\n redirect_to :back, notice: 'We sent you an email to confirm your request. Please review your email and confirm the action.'\n end", "def destroy\n current_user.destroy\n json_response({ message: Message.account_deleted }.to_json)\n end", "def confirm_delete_message\n <<-TEXT\n Are you sure you want to delete this page,\n all its children and all its slices and other content?\n TEXT\n end", "def delete_message(data); end", "def delete_message(data); end", "def destroy\n # delete a specific message\n end", "def deleted(name, person_id)\n @person = Person.find(person_id)\n @person_deleted = name\n\n mail to: @person.email\n end", "def destroy\n # delete a specific message\n end", "def destroy\n # delete a specific message\n end", "def deleted_order_notification(order, user)\n ModelMailer.deleted_order_notification\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 deleted\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def confirmation_message\n title_message(\"Forks Deleted\")\n end", "def after_destroy\n\n UserMailer.deliver_deleted_message(user)\n\n end", "def delete_message(id)\n record \"/msg/delete/#{id}\"\n end", "def delete_account\n @connection.request({\n :method => 'DELETE'\n }) \n end", "def delete_account\n @connection.request({\n :method => 'DELETE'\n })\n end", "def delete_account_helper\n current_user = User.find(self.user.id)\n current_user.delete\n puts \"Your account has successfully been deleted.\"\n sleep(2)\n welcome\n end", "def messagedelete\n TDirmessage.find_by(\"dirmsg_id=?\", params[:messagedelete]).delete\n redirect_back(fallback_location: dirmsgcreate_path)\n end", "def destroy\n @custom_message.destroy\n respond_to do |format|\n format.html { redirect_to custom_messages_url, notice: 'Custom message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def flash_destroyed_message\n flash_message_builder(:destroy, flash_status_type, 'destroyed')\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.send_account_denied_email\n Customer.find(params[:id]).destroy\n flash[:success] = \"The account for #{@customer.customer_name} has been denied. They have been notified via email.\"\n redirect_to pending_customers_url\n end", "def destroy\n get_message().delete\n end", "def delete\n @client.post('/api/del_msg', id: get_attribute(:name))\n end", "def destroy\n @fdn_received_message = Fdn::ReceivedMessage.find(params[:id])\n #@fdn_received_message.destroy\n @fdn_received_message.be_trashed(current_user)\n\n respond_to do |format|\n format.html { redirect_to fdn_messages_url }\n format.json { head :no_content }\n end\n end", "def inactive_message\n \"This account has been deactivated or doesn't have account.\"\n end", "def inactive_message\n 'Sorry, this account has been deactivated.'\n end", "def delete_msg()\n MsgUtil.delete_msg(params[:ch])\n end", "def destroy\n @message = Message.find(params[:id])\n @message.make_deleted(current_user.id)\n response_message = {:message => 'Message deleted successfully.'}\n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end", "def destroy\n flash[:error] = 'Accounts can only be deleted by admins!'\n redirect_to edit_user_registration_path\n end", "def delete_message(status)\n response = post(\"secret_mails/destroy/#{status.id}.json\")\n Croudia::Object::SecretMail.new(response)\n end", "def project_deleted(user, project)\n setup_email(user)\n @subject += head_encode(project.login + \" was deleted\".t)\n @body[:user] = user\n @body[:project] = project\n end", "def destroy\n @account.update(active: false, disabled_at: Time.now)\n\n # ----------------------------- produce event -----------------------\n event = {\n **account_event_data,\n event_name: 'AccountDeleted',\n data: { public_id: @account.public_id }\n }\n result = SchemaRegistry.validate_event(event, 'accounts.deleted', version: 1)\n\n if result.success?\n WaterDrop::SyncProducer.call(event.to_json, topic: 'accounts-stream')\n end\n # --------------------------------------------------------------------\n\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Account was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def inactive_message\n !deactivated_at ? super : :deactivated_account\n end", "def project_deleted(project, admin, destination)\n @project = project\n @admin = admin\n\n mail to: destination\n end", "def delete\n @service.delete_message(self)\n end", "def destroy\n @admin_message.destroy \n respond_to do |format|\n format.html { redirect_to admin_messages_url, notice: \"#{ t 'activerecord.successful.messages.message_deleted' }\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @mosquitto_account.destroy\n respond_to do |format|\n flash_message 'danger', 'Mosquitto account was successfully destroyed.'\n\n format.html { redirect_to mosquitto_accounts_url }\n format.json { head :no_content }\n end\n end", "def user_deleted_query _user, query\n data = {\n category: 'Queries',\n action: 'Deleted a Query',\n label: query.query_text,\n value: nil,\n bounce: false,\n }\n\n create_event data\n end", "def destroy\n flash[:notice] = \"Destroying accounts is not enabled.\"\n redirect_to root_path\n end", "def send_message_post_fav_deleted(subscriber, msg)\n if msg == \"success\"\n text = \"L'annonce a été supprimée de vos favoris !\"\n response = handle_manychat_response(send_content(subscriber, [create_message_text_hash(text)]))\n else\n text = \"Oops, il semblerait qu'une erreur se soit produite, l'annonce n'a pas été supprimée de vos favoris\"\n response = handle_manychat_response(send_content(subscriber, [create_message_text_hash(text)]))\n end\n return response\n end", "def destroy\n \tif @message = Message.related(current_user.id).find(params[:id])\n\n if @message.destroy\n flash[:notice] = \"Message deleted.\"\n else\n flash[:error] = \"Message could not deleted.\"\n end\n\n else\n flash[:error] = \"Message could not be deleted. You are not the owner of the message.\"\n end\n redirect_to messages_path\n end", "def remove_notification\n \n @ac = AttachContact.find(params[:user_id])\n RecentActivity.create(:transaction_id => @transaction.id, \n :user_id => current_user.id, \n :message => \"Removed Contact: #{@ac.user.fullname} as #{@ac.role.name if @ac.role}\")\n \n render :nothing => true\n end", "def destroy\n\n begin\n\n @account = Account.find_by_email(params[:id])\n @account = Account.find(params[:id]) if @account.nil?\n\n Account.transaction do\n\n @account.status = VersaFile::AccountStates.Deleted\n @account.created_by = @super_user.name\n @account.updated_by = @super_user.name\n\n unless @account.save\n raise @account.errors.full_messages().join(';')\n end\n\n end\n\n respond_to do |format|\n format.html { redirect_to @account, notice: 'Account was successfully deleted.' }\n format.json { render :text => \"\" }\n end\n\n rescue => e\n logger.error \"Account deletion failed => #{e.message}\"\n respond_to do |format|\n format.json { render :json => e.message, :status => :unprocessable_entity }\n end\n end\n\n end", "def delete\n if ensure_same_as_logged_person(@message.poster.guid)\n @message.delete\n render :status => :ok and return\n elsif ensure_same_as_logged_person(@channel.owner.guid)\n @message.delete\n render :status => :ok and return\n end\n render :status => :forbidden and return\n end", "def deleted; status[:deleted]; end", "def delete_account\n puts 'Woah there! Deleting your account is serious business, and cannot be undone.'.colorize(:light_red)\n selection = @prompt.yes?('Are you sure you want to delete your account?'.colorize(:light_red))\n if selection\n delete_from_file\n else\n menu = Menu.new(Login.user)\n menu.account_details\n end\n end", "def delete(id)\n # The call uses a begin/rescue block so any errors can be handled properly\n begin\n Account.filter(:id => id).destroy\n flash[:success] = 'The specified Account has been removed'\n rescue => e\n Ramaze::Log.error(e.message)\n flash[:error] = 'The specified Account could not be removed'\n end\n Action.add_record(@account.id, session[:email], 'deleted', 'account', @account.name)\n redirect(Accounts.r(:index))\n end", "def delete_accounts\n end", "def delete_candidate(accountID)\n\t\tputs \"DB::delete #{accountID}\"\n\tend", "def destroy\n user&.destroy\n render json: {message: 'Sorry to see you go! Your account has been successfully deleted.'}\n end", "def user_deleted_case _user, the_case\n data = {\n category: 'Cases',\n action: 'Deleted a Case',\n label: the_case.case_name,\n value: nil,\n bounce: false,\n }\n\n create_event data\n end", "def inactive_message\n\t\t\"Sorry, this account not active by admin. Will Contact you soon.\"\n\tend", "def destroy\n @broker_account.destroy\n respond_to do |format|\n flash_message 'danger', 'Broker account was successfully destroyed.'\n\n format.html { redirect_to broker_accounts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@message = Message.find(params[:id])\n #@message.destroy\n #redirect_to projects_path\n current_user.delete_message(ActsAsMessageable::Message.find(params[:id]))\n redirect_to trash_url\n end", "def destroy\n @message.destroy\n \n flash[:success] = \"Your message was successfully deleted.\"\n redirect_to @message\n end", "def delete_message(display_id, message_id)\n delete \"commandcenter/displays/#{display_id}/messages/#{message_id}\"\n end", "def destroy\n @message = Message.find(params[:id])\n @message.mark_deleted(current_user)\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :ok }\n end\n end", "def delete_account\n @user = current_user\n if @user.twitter_account.destroy\n flash[:notice] = 'You are not connected to twitter anymore $green'\n else \n flash[:notice] = 'Something went wrong. Please try again $red'\n end \n redirect_to controller: 'users', action: 'connect_social_accounts'\n end", "def destroy\n begin\n @user.destroy\n flash[:notice] = t('activerecord.attributes.user.messages.deleted', user: @user.name)\n rescue StandardError => e\n flash[:notice] = e.message\n end\n\n respond_to do |format|\n format.html do\n redirect_to users_url,\n notice: t('activerecord.attributes.user.messages.deleted', name: @user.name)\n end\n format.json { head :no_content }\n end\n end", "def newsletter_subscriber_delete_alert(subscription, email)\n\t\t@list_name = User.human_attribute_name subscription\n\t\t@email = email\n\t\tsendgrid_category 'Newsletter Subscriber Delete Alert'\n\t\tmail subject: \"User with email #{email} was deleted from \\\"#{@list_name}\\\" newsletter list\", to: ADMIN_EMAIL\n\tend", "def message_delete(id)\n request(:delete, \"messages/#{id.to_s}\")\n end", "def post_delete_email\n NotificationMailer.post_delete_email('default@email.com')\n end", "def destroy\n @message = Message.find(params[:id])\n if current_user.received_messages.find(@message)\n MessageRecipient.find_by_user_id_and_message_id(current_user, @message.id).destroy\n\n else\n @message.destroy\n end\n \n\n respond_to do |format|\n format.html { redirect_to account_messages_url }\n format.xml { head :ok }\n end\n end", "def display_kit_deleted(kit_deleted_response)\n if kit_deleted_response['error'].nil?\n @console.ok \"Kit successfully deleted!\"\n else\n print_error kit_deleted_response['error']\n end\n end", "def delete\n ret_val = error_if_exists('delete')\n super if ret_val\n return ret_val\n end", "def delete_message(token, id, user = nil)\n request_url = user_context(user) << \"/Messages/\" << id\n\n delete_response = make_api_call \"DELETE\", request_url, token\n\n return nil if delete_response.nil? || delete_response.empty?\n\n parse_response(delete_response)\n end", "def remove_message(name)\n\t\tend", "def reason_not_to_delete\n d = @data_object\n if d.order_amount_paid > 0.0\n return \"Cannot delete an order after it has been partially paid\"\n end\n\n pays = Pays.for_order(self)\n unless pays.empty?\n return \"Cannot delete an order after payments have been applied\"\n end\n\n each_line do |line|\n if line.li_date_shipped\n return \"Cannot delete: '#{line.li_desc}' has been shipped\"\n end\n end\n\n nil\n end", "def destroy\n authorize_admin or return\n\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to(messages_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.77490103", "0.761186", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.7335921", "0.7304492", "0.72610474", "0.7252312", "0.72507036", "0.7237712", "0.72362304", "0.72050923", "0.69030046", "0.6700996", "0.6640928", "0.66021645", "0.65377337", "0.64666146", "0.6447453", "0.6447453", "0.6367007", "0.63664025", "0.63573426", "0.6307064", "0.62974995", "0.62564474", "0.62425274", "0.6235963", "0.6201385", "0.61613363", "0.6111304", "0.61079365", "0.6059689", "0.604953", "0.60289514", "0.6028468", "0.59861314", "0.5984504", "0.59716624", "0.5958949", "0.59544176", "0.5933011", "0.59162897", "0.5882602", "0.58243847", "0.5817835", "0.5811698", "0.5781407", "0.57751864", "0.57692695", "0.5767068", "0.5759285", "0.57541865", "0.5749198", "0.5743508", "0.57317156", "0.57260126", "0.57246166", "0.57231784", "0.5718465", "0.57075775", "0.57012725", "0.5698935", "0.5687027", "0.5685283", "0.5683186", "0.5679987", "0.5665039", "0.56634843", "0.56587416", "0.5654001", "0.5644847", "0.5643291", "0.56430566", "0.563801", "0.56377614", "0.56269026", "0.5619343", "0.56192154", "0.56137794", "0.5598882", "0.5577629", "0.5577293", "0.55693704", "0.55659735" ]
0.7341333
19
Accessors to make the subscription toggle available via forms
def subscription_active active_subscription.present? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toggle_subscription!\n self.unsubscribed = !unsubscribed\n save\n end", "def toggle_subscription\n authorize model\n authorize Subscription\n subscription_toggle\n @model = model\n render 'toggle_subscription'\n end", "def toggle_comment_subscription user\n subscription = find_or_build_comment_subscription user\n subscription.subscribed = !subscription.subscribed \n subscription.save!\n end", "def accessible\n has_toggles\n end", "def subscribed?\n self.subscription == :subscribed\n end", "def toggle\n\t\t@toggle ||= Toggle.new(self)\n\tend", "def suscription_on?\n is_subscribed == true\n end", "def subscribe_to_newsletter\n @attributes[:subscribe_to_newsletter]\n end", "def subscription\n attributes[:subscription].to_sym if attributes[:subscription]\n end", "def subscribe\n self.subscribed = true\n end", "def toggle\n @toggle ||= toggle_class.new(self)\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\nend", "def set_subscription\n @subscription = Subscription.find(params[:id])\nend", "def IsSubscribed=(arg0)", "def IsSubscribed=(arg0)", "def toggle!\n self.featured = !self.featured\n save\n end", "def subscribed?\n self.type == :subscribed\n end", "def toggle_subscriber(user) \n if subscribers.include?(user)\n subscribers.delete(user) \n elsif not user.public? and user.permitted?(:tickets, :watch, :project => project)\n subscribers << user\n end\n subscribers.include?(user)\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def subscribe?\n self.type == :subscribe\n end", "def get_subscription_button(f)\n\t\tif !current_teacher.subscribed_to?(@teacher.id)\n\t\t\t#return \"Subscribe to #{@teacher.full_name}\"\n\t\t\tf.submit \"Subscribe to #{@teacher.full_name}\", :confirm => 'Are you sure?'\n\t\telse\n\t\t\t#return \"Unsubscribe from #{@teacher.full_name}\"\n\t\t\tf.submit \"Unsubscribe from #{@teacher.full_name}\", :confirm => 'Are you sure?'\n\t\tend\n\tend", "def toggle\n cmd = \"{\\\"id\\\":7,\\\"method\\\":\\\"toggle\\\",\\\"params\\\":[]}\\r\\n\"\n request(cmd)\n end", "def subscription_term; end", "def subscription\n case attributes['subscription']\n when 'both' then :both\n when 'from' then :from\n when 'none' then :none\n when 'remove' then :remove\n when 'to' then :to\n else nil\n end\n end", "def toggle_status\n self.published = !published\n self.save\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def subscription=(val)\n case val\n when :both then attributes['subscription'] = 'both'\n when :from then attributes['subscription'] = 'from'\n when :none then attributes['subscription'] = 'none'\n when :remove then attributes['subscription'] = 'remove'\n when :to then attributes['subscription'] = 'to'\n else attributes['subscription'] = nil\n end\n end", "def subscription\n @current\n end", "def subscribed?(user)\n user.subscription.subscribed==true\n end", "def toggle_field(resource, field, action = 'toggle', options = {})\n ''.tap do |html|\n title = resource[field] ? t('enable') : t('disable')\n options[:id] ||= resource.id\n\n check_box_options = {\n alt: title,\n title: title,\n class: 'toggle'\n }\n\n link_options = options.merge(\n method: :put,\n alt: title,\n title: title\n )\n\n url_options = options.merge(\n action: action,\n id: options[:id],\n field: field\n )\n if test_permission (options[:controller] || controller_name), action\n checkbox = check_box_tag(field, resource[field], resource[field], check_box_options)\n html << link_to(checkbox, url_options, link_options)\n else\n check_box_options = check_box_options.merge(disabled: true)\n html << check_box_tag(field, resource[field], resource[field], check_box_options)\n end\n end\n end", "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "def toggle_officer\n self.is_officer = !self.is_officer\n save!(:validate => false)\n end", "def set_subscribe\n @subscribe = Subscribe.find(params[:id])\n end", "def set_subscribe\n @subscribe = Subscribe.find(params[:id])\n end", "def set_subscribe\n @subscribe = Subscribe.find(params[:id])\n end", "def set_subscribe\n @subscribe = Subscribe.find(params[:id])\n end", "def set_admin_subscription\n @admin_subscription = Subscription.find(params[:id])\n end", "def create\n @book = Book.find(params[:book_id])\n current_user.subscribe!(@book)\n respond_to do |format|\n # format.html\n format.js { render 'toggle' }\n end\n end", "def toggle(data)\n resource = Resource.find(data[\"id\"])\n resource.toggle_availability\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def select_publicly_viewable\n frm.radio(:id=>\"pubview\").set\n end", "def toggle\n # put user_id business_id in params\n user = User.where(:unique_id => params[:device_id])\n if user.empty?\n user = User.new(:unique_id => params[:device_id])\n user.save\n else\n user = user.first #WHERE RETURNS AN ARRAY\n end\n user_id = user.id\n @subscription = Subscription.where(:business_id => params[:business_id], :user_id => user_id)\n if @subscription.empty?\n @subscription = Subscription.new(:business_id => params[:business_id], :user_id => user_id)\n @subscription.save\n render :json => \"subscribed\"\n else\n @subscription.first.destroy\n render :json => \"unsubscribed\"\n end\n end", "def subscribed; end", "def toggle_officer\n do_toggle_role :officer\n end", "def subscriptions_list f, me\n # subscription_tokens is a virtual attribute, an array of booleans for checking and unchecking followees\n f.fields_for :subscription_tokens do |builder|\n \t Feed.where(approved: true).map { |feed|\n \t\t builder.check_box(feed.id.to_s, :checked => me.feeds.exists?(id: feed.id)) + builder.label(feed.id.to_s, feed.description)\n \t }.compact.join('<br>').html_safe\n end\n end", "def toggle\n action(action: Actions::TOGGLE)\n self\n end", "def toggle\n fire\n end", "def toggle_field(attrs = {})\n if attrs.has_key?(:checked)\n if attrs[:checked]\n attrs[:checked] = \"checked\"\n else\n attrs.delete(:checked)\n end\n end\n \n check_box(attrs)\n end", "def enable=(value); self.is_enable = value end", "def toggle\n if on?\n off\n else\n on\n end\n end", "def subscribed?\n !@attributes.nil? && @attributes.include?(:Subscribed)\n end", "def subscription=(new_subscription)\n if !new_subscription.nil?\n case new_subscription\n when true\n unless subscribed?\n @attributes << :Subscribed\n subscription_changed!\n end\n when false\n if subscribed?\n @attributes.delete(:Subscribed)\n subscription_changed!\n end\n end\n end\n end", "def select_show\n frm.radio(:id=>\"hidden_false\").set\n end", "def unsubscribe\n user = Subscriber.find_by_unique_identifier(params[:id])\n user.update_attribute(:is_subscribed, false)\n user.save!\n render\n end", "def non_billable_button\n @subscriber = Subscriber.find(params[:id])\n if @subscriber.non_billable == false\n @subscriber.update_attributes(non_billable: true)\n end\n @json_data = { \"non_billable\" => @subscriber.non_billable }\n render json: @json_data\n end", "def radio_button; end", "def toggle\n set_switch(!self.switch) if @switch\n end", "def subscription=(subscription)\n attributes[:subscription] = subscription\n end", "def subscriptions\n\t\t@subscriptions = current_user.customer.subjects\n\tend", "def subscriber?\n self.subscription.plan_id != nil && self.subscription.plan_id >= 1\n end", "def toggle\n if visible?\n hide\n\n else\n show\n\n end\n end", "def set_subscription\n @subscription = ::Pushar::Core::Subscription.unscoped.find(params[:id])\n end", "def subscribe\n \nend", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def toggle_status\n if can_unpublish?\n self.published = !published\n self.save\n else\n return false\n end\n end", "def toggle\n @user.toggle\n redirect_to :back\n end", "def subscribed?\n status == 1 || status == 2\n end", "def toggle_publish\n @course.published = !@course.published\n @course.save\n end", "def set_action\n @email = params.fetch(:user)[:email]\n if params.fetch(:user)[:subscription] == \"1\"\n @action = \"subscribed_to_users\"\n @updated_subscription = true\n else\n @action = \"unsubscribed_from_users\"\n @updated_subscription = false\n end\n end", "def request?\n self.type == :subscribe\n end", "def get_module_subscription(mod)\n (mod) ? I18n.t(:bool_yes) : I18n.t(:bool_no)\n end", "def is_subscribable?\n is_partner_subscription? || is_premium_subscription?\n end", "def subscription_id\n @event.attributes[:subscription_id]\n end", "def create / update_subscriptions\n end", "def toggle\n @raid.toggle\n redirect_to :back\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def check_subscription\n !subscribed || subscription_present?\n end", "def billable_button\n @subscriber = Subscriber.find(params[:id])\n if @subscriber.non_billable == true\n @subscriber.update_attributes(non_billable: false)\n end\n @json_data = { \"billable\" => @subscriber.non_billable }\n render json: @json_data\n end", "def toggle!\n\t\tif self.can_mark_complete?\n\t\t\tself.mark_complete!\n\t\telsif self.can_re_open?\n\t\t\tself.re_open!\n\t\tend\n\tend", "def subscription_enabled?\n _notification_subscription_allowed ? true : false\n end", "def toggle_active\n @question = Question.find(params[:id])\n @question.toggle :active\n @question.save\n redirect_to :back\n end", "def ask=(val)\n case val\n when :subscribe then attributes['ask'] = 'subscribe'\n else attributes['ask'] = nil\n end\n end", "def toggle(instance)\n # do nothing\n end" ]
[ "0.7289069", "0.7285285", "0.62209094", "0.6070989", "0.6051465", "0.5994141", "0.59850216", "0.5976862", "0.5966283", "0.5954533", "0.5888644", "0.5837743", "0.5837743", "0.58372706", "0.58372706", "0.58346313", "0.5832813", "0.58259267", "0.5819059", "0.5819059", "0.5819059", "0.58096933", "0.5805836", "0.5797529", "0.5769989", "0.5763071", "0.5720582", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.5720355", "0.56921357", "0.5644859", "0.5622987", "0.56161714", "0.5608593", "0.56045735", "0.5586276", "0.5586276", "0.5586276", "0.5586276", "0.5576662", "0.5563071", "0.5550402", "0.5538954", "0.5538021", "0.5515584", "0.5513866", "0.5508584", "0.55034477", "0.54945606", "0.54732364", "0.54709226", "0.5461779", "0.54545987", "0.5419702", "0.54170525", "0.54161566", "0.54106164", "0.5406159", "0.5399824", "0.53971547", "0.53718364", "0.53650504", "0.535905", "0.53578985", "0.5357578", "0.5357435", "0.53459334", "0.53459334", "0.53459334", "0.5331562", "0.53243226", "0.53185457", "0.5317903", "0.52933216", "0.5289417", "0.52853477", "0.5271926", "0.52676934", "0.52655685", "0.5263725", "0.5260105", "0.52536094", "0.5249372", "0.52445996", "0.5225854", "0.5225616", "0.52240056", "0.5218847" ]
0.5921847
10
Extract any payment errors from pending offer orders
def payment_error_notifications payment_logs = order_logs .joins(:order => :offer_order) .where("orders.status IN ('pending') AND lower(order_logs.action) IN ('bill', 'payment')") .order('order_logs.created_at') payment_logs.group_by(&:order_id).reduce([]) do |a, (order_id, logs)| logs.sort_by(&:created_at).reverse.first.tap do |log| a.push log unless log.succeeded? end a end.flatten end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def errors\n p = build_payment\n p.valid?\n p.errors\n end", "def paypal_errors_msg\n \"We are sorry, but the purchase was not completed due the following errors: #{errors.full_messages.join(', ')}\"\n end", "def return_shipment_errors\n [\"#{@shipment}.buy(no rates found for this shipment)\", @shipment, @shipment]\n end", "def capture_pending_payments\n success = true\n order.payments.pending.each do |payment|\n unless payment.capture!\n copy_errors(payment)\n success = false\n end\n end\n success\n end", "def settle_payments_if_desired\n @settlement_results = { \"errors\" => [], \"status\" => [] }\n\n op = nil\n\n unless @order.canceled?\n while options[\"ok_capture\"] && @order.outstanding_balance > 0 && op = pick_payment { |opp| opp.pending? && opp.amount > 0 && opp.amount <= @order.outstanding_balance }\n rescue_gateway_error { op.capture! }\n end\n\n while options[\"ok_partial_capture\"] && @order.outstanding_balance > 0 && op = pick_payment { |opp| opp.pending? && opp.amount > 0 && opp.amount > @order.outstanding_balance }\n # Spree 2.2.x allows you to pass an argument to\n # Spree::Payment#capture! but this does not seem to do quite\n # what we want. In particular the payment system treats the\n # remainder of the payment as pending.\n op.amount = @order.outstanding_balance\n rescue_gateway_error { op.capture! }\n end\n\n while options[\"ok_void\"] && @order.outstanding_balance <= 0 && op = pick_payment { |opp| opp.pending? && opp.amount > 0 }\n rescue_gateway_error { op.void_transaction! }\n end\n\n while options[\"ok_refund\"] && @order.outstanding_balance < 0 && op = pick_payment { |opp| opp.completed? && opp.can_credit? }\n rescue_gateway_error { op.credit! } # remarkably, THIS one picks the right amount for us\n end\n end\n\n # collect payment data\n @order.payments.select{|op| op.amount > 0}.each do |op|\n @settlement_results[\"status\"] << { \"id\" => op.id, \"state\" => op.state, \"amount\" => op.amount, \"credit\" => op.offsets_total.abs }\n end\n end", "def error(order)\n @order = order\n\n mail to: 'mrigney@yozu.co.uk', subject: 'Pragmatic Store Order Error'\n end", "def rescue_gateway_error\n yield\n rescue Spree::Core::GatewayError => e\n @settlement_results[\"errors\"] << e.message\n ensure\n @order.reload\n end", "def log_shipping_errors\n humanized_errors = errors.full_messages.to_sentence\n Spree::DmiEvent.create_error(\"Couldn't ship order #{order.number}: #{humanized_errors}\")\n order.dmi_notes = humanized_errors\n order.dmi_status = 'error'\n order.save\n end", "def test_failed\n initial_mbox_length = ActionMailer::Base.deliveries.length\n # Get any order.\n an_order = orders(:santa_next_christmas_order)\n \n # Create a standard failure response when cc number is wrong. Parameters: success, message, params = {}, options = {}\n a_negative_response = ActiveMerchant::Billing::Response.new(\n false,\n \"(TESTMODE) The credit card number is invalid\",\n {\n :response_reason_text => \"(TESTMODE) The credit card number is invalid.\",\n :response_reason_code => \"6\",\n :response_code => \"3\",\n :avs_message => \"Address verification not applicable for this transaction\",\n :transaction_id => \"0\",\n :avs_result_code => \"P\",\n :card_code => nil\n }, {\n :test => true,\n :authorization => \"0\",\n :fraud_review => false\n }\n )\n \n # Stub the purchase method to not call home (using commit) and return a standard failure response.\n ActiveMerchant::Billing::AuthorizeNetGateway.any_instance.stubs(:purchase).returns(a_negative_response)\n\n # Assert that with a failure response the method will return the response message.\n assert_equal an_order.run_transaction_authorize, a_negative_response.message \n assert_equal ActionMailer::Base.deliveries.length, initial_mbox_length + 1\n \n response_mail = ActionMailer::Base.deliveries.first\n \n assert_equal response_mail.subject, 'An order has failed on the site'\n assert_match /Order #: #{an_order.order_number}/, response_mail.body\n assert_equal response_mail.to.to_a, Preference.find_by_name('mail_copy_to').value.split(',')\n \n end", "def create_orders!\n raise Error, \"Need to set a parser before you can create orders.\" unless @parser\n raise Error, \"No orders found to parse\" unless parser_orders = @parser.orders\n # todo, should be able to handle split orders where some pass and some fail here\n orders, errors = [], []\n\n begin\n Order.transaction do\n parser_orders.each do |order|\n begin\n orders << create_order(order)\n rescue OrderAlreadyExistsError => e # if the order already existed, no problem really, just notify\n errors << e\n rescue => e\n errors << e\n orders = [] # clear out the orders array, b/c we're about to roll everything back\n raise AtLeastPartialFailure # raise an error here b/c we dont need to even look at the order orders\n end\n end\n # raise AtLeastPartialFailure if errors.size > 0 # or raise it here?\n end # end the transaction\n\n rescue AtLeastPartialFailure\n ActiveRecord::Base.logger.warn \"got a partial failure when trying to create orders\"\n # do nothing, this is just to DB rollback\n end\n [orders, errors]\n end", "def process_error(exp)\n return exp.shift\n end", "def loose_errors\n err = []\n err << title\n err << authors\n err << s3_error_uploads\n err << url_error_validating\n\n err.flatten\n end", "def map_fake_pay_failure(result)\n if result.failure?\n case result.failure\n when FakePay::Errors::InvalidCreditCardNumber; Failure({:payment => {:billing_details => {:card_number => [\"is invalid\"]}}})\n when FakePay::Errors::InvalidZipCode; Failure({:payment => {:billing_details => {:zip_code => [\"is invalid\"]}}})\n when FakePay::Errors::InsufficientFunds; Failure({:payment => {:billing_details => {:card_number => [\"has insufficient funds\"]}}})\n when FakePay::Errors::SecurityCodeCheckFailure; Failure({:payment => {:billing_details => {:security_code => [\"is invalid\"]}}})\n when FakePay::Errors::ExpiredCard; Failure({:payment => {:billing_details => {:expirationMonth => [\"is expired\"], :expirationYear => [\"is expired\"]}}})\n end\n else\n result\n end\n end", "def e_validate_related_orders\n errors.add(:base, I18n.t('plugins.ecommerce.message.not_deletable_product')) if Plugins::Ecommerce::ProductItem.where(product_id: id).any?\n end", "def process_order_payment\n \n return \"No Order Paid Date not found, order NOT PROCESSED\" if self.paid_date.blank?\n return \"No Order Paid Amount not found, order NOT PROCESSED\" if self.paid_amount.blank?\n return \"No Order Ref Name not found, order NOT PROCESSED\" if self.name.blank? \n return \"No Order Ref Id not found, order NOT PROCESSED\" if self.order_master_id.blank? \n \n return \"Paid Amount #{self.paid_amount} is less than ORDER AMOUNT #{self.order_master.grand_total}\" if self.paid_amount.to_i < self.order_master.grand_total.to_i\n \n order_master = OrderMaster.new\n return order_master.process_order self.order_master_id\n \n end", "def errors\n error_messages = []\n\n [:remote].each do |key|\n error_messages << \"include_policy for #{name} is missing key #{key}\" unless source_options[key]\n end\n\n error_messages\n end", "def find_service_line_having_reason_codes(service_payment_eobs)\r\n service_payment_eobs.reverse.each do |service_payment|\r\n adjustment_reason_elements.each do |element|\r\n if service_payment.send(\"#{element}_reason_code_id\")\r\n return service_payment\r\n end\r\n end\r\n end\r\n return nil\r\n end", "def failed_purchase_response\n end", "def test_failed_purchase_decline\n response = @gateway.purchase(@amount, @declined_card, @options)\n assert_failure response\n assert_equal 1, response.responses.count\n assert_equal 'Card declined.', response.message\n assert_equal 'card_declined', response.error_code\n end", "def problematicOrder\n order = Order.last\n user = User.find(Contract.find(order.contract_id).buyer_id)\n MagicMailer.problematicOrder(order, user)\n end", "def successful_purchase_response\n '\n {\n \"bill\": {\n \"id\": 7440626,\n \"code\": null,\n \"amount\": \"100.0\",\n \"installments\": 1,\n \"status\": \"paid\",\n \"seen_at\": null,\n \"billing_at\": null,\n \"due_at\": null,\n \"url\": \"https://sandbox-app.vindi.com.br/customer/bills/7440626?token=2099fc97-8a73-48b8-bb1d-c3e4d2db5b90\",\n \"created_at\": \"2022-06-07T18:38:20.000-03:00\",\n \"updated_at\": \"2022-06-07T18:38:21.000-03:00\",\n \"bill_items\": [\n {\n \"id\": 14136625,\n \"amount\": \"100.0\",\n \"quantity\": null,\n \"pricing_range_id\": null,\n \"description\": null,\n \"pricing_schema\": null,\n \"product\": {\n \"id\": 160701,\n \"name\": \"Produto VINDI\",\n \"code\": null\n },\n \"product_item\": null,\n \"discount\": null\n }\n ],\n \"charges\": [\n {\n \"id\": 7245405,\n \"amount\": \"100.0\",\n \"status\": \"paid\",\n \"due_at\": \"2022-06-07T23:59:59.000-03:00\",\n \"paid_at\": \"2022-06-07T18:38:21.000-03:00\",\n \"installments\": 1,\n \"attempt_count\": 1,\n \"next_attempt\": null,\n \"print_url\": null,\n \"created_at\": \"2022-06-07T18:38:20.000-03:00\",\n \"updated_at\": \"2022-06-07T18:38:21.000-03:00\",\n \"last_transaction\": {\n \"id\": 7542009,\n \"transaction_type\": \"charge\",\n \"status\": \"success\",\n \"amount\": \"100.0\",\n \"installments\": 1,\n \"gateway_message\": \"Transacao aprovada\",\n \"gateway_response_code\": null,\n \"gateway_authorization\": \"03508DDF8C9C0B5B61E1067AC69E5C12\",\n \"gateway_transaction_id\": \"936f8b41-8df9-49b4-8efc-30c95cd40555\",\n \"gateway_response_fields\": {\n \"nsu\": \"BC7F44F6E2E1D565A63CD051783AFAA6\"\n },\n \"fraud_detector_score\": null,\n \"fraud_detector_status\": null,\n \"fraud_detector_id\": null,\n \"created_at\": \"2022-06-07T18:38:20.000-03:00\",\n \"gateway\": {\n \"id\": 3153,\n \"connector\": \"fake\"\n },\n \"payment_profile\": {\n \"id\": 1021243,\n \"holder_name\": \"LONGBOB LONGSEN\",\n \"registry_code\": null,\n \"bank_branch\": null,\n \"bank_account\": null,\n \"card_expiration\": \"2023-09-30T23:59:59.000-03:00\",\n \"allow_as_fallback\": null,\n \"card_number_first_six\": \"444444\",\n \"card_number_last_four\": \"4448\",\n \"renewed_card\": {\n \"card_number_last_four\": null,\n \"card_expiration\": null\n },\n \"card_renewed_at\": null,\n \"token\": \"cb0d8927-c067-4a9c-a065-95b735592f26\",\n \"created_at\": \"2022-06-07T18:38:19.000-03:00\",\n \"payment_company\": {\n \"id\": 13,\n \"name\": \"Visa\",\n \"code\": \"visa\"\n }\n }\n },\n \"payment_method\": {\n \"id\": 6230,\n \"public_name\": \"Cartão de crédito\",\n \"name\": \"Cartão de crédito\",\n \"code\": \"credit_card\",\n \"type\": \"PaymentMethod::CreditCard\"\n }\n }\n ],\n \"customer\": {\n \"id\": 1485236,\n \"name\": \"Jane Doe\",\n \"email\": \"jane@doe.com\",\n \"code\": null\n },\n \"period\": null,\n \"subscription\": null,\n \"metadata\": {},\n \"payment_profile\": {\n \"id\": 1021243,\n \"holder_name\": \"LONGBOB LONGSEN\",\n \"registry_code\": null,\n \"bank_branch\": null,\n \"bank_account\": null,\n \"card_expiration\": \"2023-09-30T23:59:59.000-03:00\",\n \"allow_as_fallback\": null,\n \"card_number_first_six\": \"444444\",\n \"card_number_last_four\": \"4448\",\n \"renewed_card\": {\n \"card_number_last_four\": null,\n \"card_expiration\": null\n },\n \"card_renewed_at\": null,\n \"token\": \"cb0d8927-c067-4a9c-a065-95b735592f26\",\n \"created_at\": \"2022-06-07T18:38:19.000-03:00\",\n \"payment_company\": {\n \"id\": 13,\n \"name\": \"Visa\",\n \"code\": \"visa\"\n }\n },\n \"payment_condition\": null\n }\n }\n '\n end", "def failed_purchase_response\n 'response=2&responsetext=DECLINE&authcode=&transactionid=1869031793&avsresponse=N&cvvresponse=N&orderid=1&type=sale&response_code=200&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id='\n end", "def last_failed_payment_reason\n last_failed_payment = payments.with_state(:declined).order(:created_at).last\n\n last_failed_payment && last_failed_payment.comment.present? ? last_failed_payment.comment : \"\"\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def retry_failed_payment\n end", "def validate_order(orders)\n raise App::InvalidParameter, 'incorrect input provided, expects Array' if orders.class != Array\n raise App::InvalidParameter, \"machine serves #{@outlets} at a time\" if orders.length > @outlets\n\n invalid_o = orders.reject { |x| @beverages.key?(x) }\n raise App::InvalidParameter, \"machine does not serve #{invalid_o.join('')}\" unless invalid_o.empty?\n end", "def failed_purchase_response\n <<~RESPONSE\n {\n \"error\": {\n \"message\": \"The card number is invalid. Make sure the number entered matches your credit card.\",\n \"caused_by\": \"buyer\",\n \"param\": \"number\",\n \"type\": \"card_error\",\n \"code\": \"incorrect_number\"\n }\n }\n RESPONSE\n end", "def return_error\n [nil, nil, @ship_carrier.present? ? 'Order shipment not avialable' : 'Shipment carrier integration not found']\n end", "def parse_error(body)\n message = \"\"\n if body['reasons']\n reasons = body['reasons'].map do |reason|\n \"Error #{reason['code']}: #{reason['message']}\"\n end\n message += reasons.join(', ')\n end\n message\n end", "def fetch_qoo10_delivered_orders(smp)\n @message = []\n @all_cart_numbers = []\n fba_complete_states = ['complete', 'customer_complete', 'self_collect_complete', 'collect_complete', 'return_complete']\n market_place = smp.market_place\n #qoo10_statuses = {\"5\"=>\"Delivered\", \"4\"=>\"On delivery\"}\n qoo10_statuses = {\"5\"=>\"Delivered\"}\n for j in 1..10\n begin\n s_date = j.day.ago.strftime(\"%Y%m%d\")\n e_date = (j-1).day.ago.strftime(\"%Y%m%d\")\n qoo10_statuses.keys.each do |k|\n uri = URI(market_place.domain_url+'/ShippingBasicService.api/GetShippingInfo')\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data({'key'=>smp.api_secret_key,'ShippingStat'=>k,'search_Sdate'=>s_date,'search_Edate'=>e_date})\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|http.request(req)end\n if res.code == \"200\"\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n begin\n if res_body[:ShippingAPIService][:ResultMsg] == \"Success\"\n for i in 1..res_body[:ShippingAPIService][:TotalOrder].to_i\n order = res_body[:ShippingAPIService][(\"Order\"+i.to_s).to_sym]\n # find out the order\n @order = nil\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:orderNo], smp.seller_id).try(:first)\n # check order present or not and order should not be cancelled already\n if @order.present? && !@order.is_cancel?\n # code to delivered the order\n if @order.update_attributes!(:market_place_order_status => \"Delivered\")\n @all_cart_numbers << @order.cart_no if @order.market_place_order_status == \"Delivered\" && (!fba_complete_states.include?@order.fulflmnt_state)\n else\n @message << \"Order not found!\"\n end # End of success status change in SF if\n end # End if order nil\n end # End of for loop\n end # End of success if\n @all_cart_numbers = @all_cart_numbers.uniq\n #Call to FBA to change status\n Spree::Order.update_fba_state(@all_cart_numbers.uniq, smp, \"Completed\") if @all_cart_numbers.present?\n rescue Exception => e\n @message << e.message\n end\n else\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=> true)\n @message << res_body[:ShippingAPIService][:ResultMsg]\n end\n end # End of status do\n rescue Exception => e\n @message << e.message\n end\n end # End for loop for day\n return @message.join(\"; \")\n end", "def payment_failed?\n cancel_reason == PAYMENT_FAILED\n end", "def get_undelivered_order_ids\n\n #enable this one for previous restricted conditioned(pause/resume)\n #orders =self.orders.select('id, delivery_date').where('spree_orders.delivery_date > ?', Time.now).limit(3)\n orders = self.orders.select('id, delivery_date').where('spree_orders.state in (?) ', ['confirm', 'placed']).limit(3)\n\n order_ids = {}\n\n orders.each_with_index do |order, index|\n order_ids.merge!(index => order.id)\n end\n\n order_ids\n end", "def seriously_all_of_the_errors\n messages = errors.full_messages.reject { |e| e == \"#{I18n.t('nouns.extension').capitalize} version is invalid\" }\n\n extension_versions.each do |version|\n almost_everything = version.errors.full_messages.reject { |x| x =~ /Tarball can not be/ }\n messages += almost_everything\n end\n\n messages\n end", "def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end", "def ins_billing_eob_payments(billing)\n payment = 0\n billing.eobs.each do |eob|\n payment += eob.payment_amount\n end\n return payment\n end", "def validate(order)\n raise \"Total price is incorrect!\" if calculate_price != expected_price\n end", "def errors(show_resolved=false)\n options = {}\n options[:show_resolved] = 1 if show_resolved\n page = 1\n errors = []\n begin\n options[:page] = page\n doc = Nokogiri::XML(api_get(\"/errors.xml\", options))\n new_errors = doc.xpath(\"/groups/group\").map {|node| Airbrake::Error.from_xml(node) }\n errors += new_errors\n page += 1\n end while new_errors.any?\n return errors\n end", "def accept\n load_order\n # If the order has been canceled, the retailer can no longer accept it\n if @order.state == 'canceled'\n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.payments.blank?\n flash[:error] = \"Something went wrong with the payment on this order. Please hold off on shipping and contact ReserveBar.\"\n Spree::OrderMailer.no_payment_error_notification(@order).deliver\n elsif @order.accepted_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n @order.update_attribute(:accepted_at, Time.now)\n @order.create_profit_and_loss\n\n # If the order only has one payment on it (all order here should have only a single payment)\n # and the total order amount is lower than the payment amount, due to adjustments made after the order was submitted\n # reduce the amount in the payment to the order total\n if @order.payments.count == 1 && @order.payment.pending? && @order.total < @order.payment.amount\n @order.payment.update_attribute(:amount, @order.total)\n @order.payments.reload\n end\n\n begin\n @order.payments.each do |payment|\n payment.payment_source.send(\"capture\", payment)\n end\n rescue Spree::Core::GatewayError => error\n # Try to authorize and capture a new payment on the same source\n begin\n unless @order.payments.count > 1\n payment = @order.payment\n credit_card = payment.payment_source\n # check retailer matches merchant account of payment_source, in case order was moved\n if credit_card.bt_merchant_id == @order.retailer.bt_merchant_id\n new_payment = payment.dup\n new_payment.response_code = nil\n new_payment.save\n # authorize and capture new payment\n credit_card.authorize(new_payment.amount, new_payment)\n credit_card.send(\"capture\", new_payment)\n else\n raise 'Order changed Retailers'\n end\n else\n raise 'More than one payment'\n end\n rescue\n @order.update_attribute(:accepted_at, nil)\n # Handle messaging to retailer - error flash that something\n flash[:error] = \"Something went wrong with the payment on this order. Please hold off on shipping and contact ReserveBar.\"\n # Dump error to separate log\n log_payment_error(error)\n # Send email to reservbar that something went wrong\n Spree::OrderMailer.capture_payment_error_notification(@order, error).deliver\n end\n end\n end\n redirect_to admin_order_url(@order)\n end", "def update_errors\n @errors = []\n @errors << 'One of the cards needs attention' unless cards.all?(&:valid?)\n if email\n @errors << 'Email is not in correct format' unless email_well_formed?\n else\n @errors << 'Email is a required field'\n end\n @errors << 'Wallet token is a required field' unless wallet_token\n @errors\n end", "def render_order_with_errors(*error_messages)\n @order.errors[:base].push(*error_messages) unless error_messages.empty?\n invalid_resource!(@order)\n end", "def edit\n @user = current_user\n @order = Order.find(params[:id])\n @price_plan = Country.get_price_plan_by_country_and_id(current_user.account.country_short, @order.price_plan_id)\n\n if @price_plan.country.paypal_email.blank?\n @order.set(:express_subject, Rails.application.config.paypal_options[:subject])\n else\n @order.set(:express_subject, @price_plan.country.paypal_email)\n end\n\n express_gateway = Order.paypal_express_gateway(@order.express_subject)\n @paypal_details = express_gateway.details_for(params[:token])\n\n begin\n PaypalDetail.log_details(params, @paypal_details, @order, 'edit')\n rescue => e\n NotificationMailer.oddity(\"Could not log PayPal details in edit. Error #{e}\").deliver\n end\n\n error_code_token_already_used = \"10415\"\n respond_to do |format|\n if (@paypal_details.params['ack'] == \"Failure\" or @paypal_details.payer_id.nil?) and @paypal_details.params['error_codes'] != error_code_token_already_used\n @order.update_attributes(state: 'failed', express_token: params[:token], express_payer_id: @paypal_details.payer_id)\n format.html { redirect_to(action: 'failure') }\n else\n @order.update_attributes(state: 'review', express_token: params[:token], express_payer_id: @paypal_details.payer_id)\n format.html {render(layout: 'registration')}\n end\n end\n end", "def parse_error(err)\n if err[:errors]\n err[:errors].values.flatten.map { |nested_err| parse_error(nested_err) }\n elsif err[:failed_attribute] == 'Required'\n parse_error_for_required_attr(err)\n else\n parse_error_default(err)\n end\n end", "def error_list(strict, add_type)\n res = []\n\n unless self.empty?\n a = @data_object\n\n res << \"Missing #{add_type} address line 1\" if a.add_line1.empty?\n res << \"Missing #{add_type} city\" if a.add_city.empty?\n res << \"Missing #{add_type} state\" if a.add_state.empty?\n\n normalize_country\n\n if a.add_country == USA\n \n state = a.add_state.strip.upcase\n \n state = STATE_TO_ABBREV[state]\n\n if state.nil?\n res << \"Unknown state #{a.add_state} in #{add_type} address\"\n else\n zip = a.add_zip.strip\n if zip.empty?\n res << \"Missing #{add_type} zip code\" \n else\n if zip =~ /^(\\d{5})(-\\d{4})?$/\n unless valid_zip(state, $1)\n res << \"Zip code #{zip} does not belong in #{state}\"\n end\n else\n res << \"Invalid format for #{add_type} zip code (five digits expected)\"\n end\n end\n end\n end\n\n check_length(res, a.add_line1, 100, \"address line 1\")\n check_length(res, a.add_line2, 100, \"address line 2\")\n check_length(res, a.add_city, 100, \"city\")\n check_length(res, a.add_county, 100, \"county\")\n check_length(res, a.add_state, 20, \"address line 1\")\n check_length(res, a.add_zip, 12, \"zip/postal code\")\n check_length(res, a.add_country, 100, \"zip/postal code\")\n end\n\n res\n end", "def send_failure_report\n return if @failed_orders.blank?\n failed_orders = ['Order, Tracking, ParcelId, Quantity, Date, Error_Message, Country'] + @failed_orders\n Spree::AsendiaMailer.csv(failed_orders.join(\"\\n\"), 'asendia', \"Sand & Sky : ASENDIA Failed Shipments Report(#{Time.now.strftime('%d/%m/%Y')})\").deliver\n end", "def check_for_payment_addresses(parties)\n out = []\n parties.each do |party|\n res = party.self_check\n party.errors.map{|err| @errors << \"Party #{ party.name } #{ err }\"} unless res == true\n out << res\n end\n \n out.include?(false)\n end", "def step_errors\n each_step_error.to_a\n end", "def send_failure_report\n return if @failed_orders.blank?\n failed_orders = ['Order, Tracking, ParcelId, Quantity, Date, Error_Message, Country'] + @failed_orders\n Spree::InnotracMailer.csv(failed_orders.join(\"\\n\"), 'innotrac', \"Sand & Sky : INNOTRAC Failed Shipments Report(#{Time.now.strftime('%d/%m/%Y')})\").deliver\n end", "def failed_purchase_response\n 'NUMTRANS=0000000000&NUMAPPEL=0000000000&NUMQUESTION=0000000000&SITE=1999888&RANG=99&AUTORISATION=&CODEREPONSE=00014&COMMENTAIRE=Demande trait?e avec succ?s ✔漢'\n end", "def create\n @order = Order.payment(current_user, @parking_place, order_params[:booked_time].to_i, order_params[:payment])\n\n begin\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t(:parking_place_successfully_booked) }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Order::NeedPayment\n respond_to do |format|\n format.html { render :payment }\n format.json { render json: @order.errors, status: :payment_required }\n end\n rescue Order::NotEnoughMoney\n respond_to do |format|\n format.html { render :payment }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n rescue Order::ParkingPlaceNotFree\n respond_to do |format|\n format.html { redirect_to root_path, alert: t(:parking_place_not_free) }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def pending_refund_payments\n payments.joins(contribution: :project).where({\n projects: {\n state: 'failed'\n },\n state: 'paid',\n gateway: 'Pagarme',\n payment_method: 'BoletoBancario'\n }).reject do |payment|\n payment.already_in_refund_queue?\n end\n end", "def unpaid_payment\n self.payments.where(status: nil).or(self.payments.where(status: :failed)).last\n end", "def errors\n error_messages = []\n\n [:path].each do |key|\n error_messages << \"include_policy for #{name} is missing key #{key}\" unless source_options[key]\n end\n\n error_messages\n end", "def payment_orders\n xml do |xml|\n xml.css(\"paymentOrdersResult > paymentOrders > paymentOrder\").map do |node|\n SubscriptionPaymentOrder.load_from_xml(node)\n end\n end\n end", "def process_ingest_errors(result, *records, **opt)\n\n # If there were no errors then indicate that all items succeeded.\n errors = ExecReport[result].error_table(**opt)\n return records, {} if errors.blank?\n\n # Otherwise, all items will be assumed to have failed.\n errors = errors.dup\n failed = {}\n\n # Errors associated with the position of the item in the request.\n by_index = errors.select { |idx| idx.is_a?(Integer) && records[idx-1] }\n if by_index.present?\n errors.except!(*by_index.keys)\n by_index.transform_keys! { |idx| manifest_item_id(records[idx-1]) }\n by_index.transform_values! { |msg| Array.wrap(msg) }\n failed.rmerge!(by_index)\n end\n\n # Errors associated with item submission ID.\n by_sid = errors.extract!(*records.map(&:submission_id))\n if by_sid.present?\n sid_id = records.map { |rec| [rec.submission_id, rec] }.to_h\n by_sid.transform_keys! { |sid| manifest_item_id(sid_id[sid]) }\n by_sid.transform_values! { |msg| Array.wrap(msg) }\n failed.rmerge!(by_sid)\n end\n\n # Remaining (general) errors indicate that there was a problem with the\n # request and that all items have failed.\n if errors.present?\n general = errors.values.presence || ['unknown error'] # TODO: I18n\n general = records.map { |rec| [manifest_item_id(rec), general] }.to_h\n failed.rmerge!(general)\n end\n\n return [], failed\n\n end", "def paypal_shipping_and_handling_costs(order)\n {}\n end", "def validate_pos_invoice\n if self.customer_id && !self.pos_invoice_addresses\n raise_error('Billing address Required!!!!')\n end\nend", "def no_error(order)\n\torder.order_type.tasks.each do |task|\n\t\tValidation.create(\n\t\t\tapproval: false,\n\t\t\torder_id: order.id,\n\t\t\ttask_id: task.id)\n\tend\nend", "def stripe_invoice_payment_failed(event, req)\n invoice = event['data']['object']\n # NOTE: If no next attempt we are on the last, subscription will be cancelled\n return false unless invoice['next_payment_attempt']\n # NOTE: Make sure we didn't misfire this hook\n return false if invoice['paid']\n dealership = dealer_dao.get_by_customer_id(invoice['customer'])\n customer = Stripe::Customer.retrieve(dealership.customer_id)\n attempt = case invoice['attempt_count']\n when 1 then '1st'\n when 2 then '2nd'\n when 3 then '3rd'\n end\n Lynr.producer('job').publish(Lynr::Queue::EmailJob.new('payment/charge_failed', {\n to: dealership.identity.email,\n subject: \"We couldn't process payment for your Lynr account\",\n base_url: req.base_url,\n attempt_count: attempt,\n last4: customer.active_card.last4,\n next_attempt: Time.at(invoice['next_payment_attempt']),\n support_email: Lynr.config('app').support_email,\n }))\n end", "def parse_response(resp)\n doc = Hpricot(resp)\n\n find_error_and_raise(doc) if errors_exist?(doc)\n\n codes = []\n doc.search('//ratedshipment/service/code') do |ele|\n codes << SERVICE_CODES[ele.innerHTML]\n end\n costs = []\n doc.search('//ratedshipment/totalcharges/monetaryValue') do |ele|\n costs << ele.innerHTML\n end\n\n quotes = codes.zip costs\n end", "def validate_billing_info\n errors = {}\n\n if (posted['stripeToken'].nil? || posted['stripeToken'].empty?)\n errors['stripeToken'] = \"Your card wasn't accepted.\"\n end\n\n errors\n end", "def api_result_errors(result)\n return result.to_h['errors'].map { |item| item['message'] }\n end", "def invalid_order(invalid) \n @misplaced = invalid\n mail :to => \"honzik@localhost\", :subject => 'Invalid order requested'\n end", "def validate\n raise ArgumentError, \"Params emtpy\" if @params.nil? \n @errors = []\n @errors << 'reason must be provided' if @params.reason.nil? \n @errors << 'txn_id must be provided' if @params.txn_id.nil? \n @errors << 'order.id must be provided' if @params.order.id.nil? \n @errors << 'order.total must be provided' if @params.order.total.nil? \n @errors << 'order.shipping_value must be provided' if @params.order.shipping_value.nil? \n @errors << 'order.tax must be provided' if @params.order.tax.nil? \n\n raise ZipMoney::RequestError.new(\"Following error(s) occurred while making request, please resolve them to make the request: #{@errors}\") if @errors.any?\n end", "def payment_gateway_response_exception(payment_gateway_response, message = \"\")\n recipients \"payment_gateway@halomonitoring.com\"\n from \"no-reply@halomonitoring.com\"\n subject \"[\" + ServerInstance.current_host_short_string + \"]\" + \"Exception while creating a credit card transaction log\"\n body :response => payment_gateway_response, :message => message\n end", "def merge_reservation_errors\n @order_detail.reservation.errors.each do |error|\n field = error.attribute\n field = Reservation.human_attribute_name(field) if field != :base\n message = error.message\n\n @order_detail.errors.add(field, message)\n end\n end", "def handle_error(line_item)\n order.errors[:base] << line_item.errors.full_messages\n end", "def errors(queue, limit, offset)\n conditions = {:error.not => nil}\n conditions[:record_class_name] = queue.class_names unless queue.class_names.empty?\n all(conditions.merge(:limit => limit, :offset => offset, :order => :id))\n end", "def reason_not_to_delete\n d = @data_object\n if d.order_amount_paid > 0.0\n return \"Cannot delete an order after it has been partially paid\"\n end\n\n pays = Pays.for_order(self)\n unless pays.empty?\n return \"Cannot delete an order after payments have been applied\"\n end\n\n each_line do |line|\n if line.li_date_shipped\n return \"Cannot delete: '#{line.li_desc}' has been shipped\"\n end\n end\n\n nil\n end", "def status_to_error(status)\n case status\n when 1\n 'InvalidRequest'\n when 2\n 'InvalidCredentials'\n when 3\n 'NonExistentOrder'\n when 4\n 'NonExistentOrderItem'\n when 5\n 'InvalidStateChange'\n when 6\n 'InvalidStorno'\n when 7\n 'AnotherError'\n when 8\n 'OrderNotExported'\n when 9\n 'AutomaticDeliveryError'\n end\n end", "def find_expired_orders_row\n\n orders = []\n row = nil\n offset = 0\n\n while row.nil? || row.size > 0\n row = Order.where(gateway_id: self.id).order(Sequel.desc(:keychain_id), Sequel.desc(:reused)).limit(Config.reuse_address_orders_threshold).offset(offset).to_a\n\n row.reject! do |o|\n reject = false\n row.each do |o2|\n reject = true if o.keychain_id == o2.keychain_id && o.reused < o2.reused\n end\n reject\n end\n\n row.sort! { |o1, o2| o2.id <=> o1.id }\n\n row.each do |o|\n if o.status == Order::STATUSES[:expired]\n orders.unshift(o)\n elsif o.status == Order::STATUSES[:new]\n next\n else\n return orders[0...Config.reuse_address_orders_threshold]\n end\n end\n offset += Config.reuse_address_orders_threshold\n end\n\n orders\n\n end", "def validate_push_to_fba\n @order = Spree::Order.find_by_number(params[:id])\n cart_no = @order.cart_no if @order.present?\n @orders = Spree::Order.where(:cart_no => cart_no)\n @errors = []\n if @orders.present?\n @orders.each do |order|\n @line_items = order.line_items if order.line_items.present?\n if @line_items.present?\n @line_items.each do |line_item|\n @errors << line_item.variant.sku.to_s+\" sku is out of stock on FBA\" if line_item.variant.fba_quantity < 0\n end\n else\n flash[:error] = order.market_place_order_no.to_s+\" : No line items found...\" \n end\n end\n end\n if @errors.present? && @errors.count > 0\n flash[:error] = \"Ooop's \"+ @errors.join(', ') \n redirect_to modify_order_admin_order_path(@order)\n else\n cart_numbers = []\n cart_numbers << cart_no\n Spree::Order.push_to_fba(cart_numbers)\n flash[:success] = \"Order Pushed to FBA Successfully !\"\n redirect_to admin_order_path(@order)\n end\n end", "def test_invalid_transaction\n\t\tassert_raise(Payment::PaymentError) {\n\t\t\t@transaction = @bad_order.get_auth_transaction\n\t\t\tassert_equal @transaction.test_transaction, true\n\t\t\t@transaction.submit\n\t\t}\n\tend", "def process_order\n result = begin\n JSON.parse(@response)['Result'].first\n rescue\n nil\n end\n return if result.blank?\n result['Status'].casecmp('success').zero? ? update_order(result) : create_asendia_shipment_record(result['Status'], result['Error'])\n end", "def test_transaction_failed\n response = @gateway.setup_purchase(500, @options)\n\n # now try to authorize the payment, issuer simulator lets the payment fail\n response = @gateway.capture(response.transaction['transactionID'])\n assert_failure response\n assert_equal 'Failure', response.transaction['status'], 'Transaction should fail'\n end", "def completed\n\n @order = current_order\n \n posted_xml = params[:xml]\n\n # Remove XHTML character encoding (hopefully won't need to do this when we receive XML message from RomanCart!)\n xml = posted_xml.sub(\"<?xml version='1.0' encoding='UTF-8'?>\", \"\")\n \n xml_doc = Nokogiri::XML(xml) \n \n if @order = current_order\n \n @order.email = xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/email\").first.content\n \n @order.user_id = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content\n \n @order.number = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content \n flash[:message] = \"Order number taken from current time!\"\n @order.number = Time.now.to_i.to_s\n \n # ----------------------- Billing Address -------------------------------\n @order.bill_address = romancartAddress(xml_doc)\n # ----------------------- Delivery Address ------------------------------ \n #<delivery-address1/>\n if xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/delivery-address1\").first.content.empty?\n @order.use_billing = true\n else\n @order.ship_address = romancartAddress(xml_doc, \"delivery-\")\n end\n \n # Spree StateMachine = 1)cart -> 2)address -> 3)delivery -> 4)payment -> 5)confirm -> 6)complete\n\n # If the order is just for samples then it'll be free so no payment is required\n if @order.item_total == 0\n \n while @order.state != \"complete\"\n @order.next!\n end\n \n else\n \n while @order.state != \"payment\"\n @order.next!\n end\n \n if xml_doc.xpath(\"/romancart-transaction-data/paid-flag\").first.content.eql?(\"True\")\n\n unless @order.payments.exists?\n @order.payments.create!(:amount => @order.total)\n @order.payments.last.payment_method = Spree::PaymentMethod.find_by_name(\"RomanCart\")\n end\n \n # '@order.payments' is an array so need to get last one entered to access 'Spree::Payment' methods\n @order.payments.last.complete\n \n @order.payment_total = @order.total\n\n # To 6 - Complete\n @order.state = \"complete\"\n @order.completed_at = Time.now\n \n @order.save!\n end\n end\n\n end\n\n end", "def order_fetch_qoo10(smp)\n @message = []\n @cart_numbers = []\n cm_user = smp.seller.is_cm_user\n #qoo10_statuses = {\"1\"=>\"Waiting for Shipping\", \"2\"=>\"Request Shipping\", \"3\"=>\"Check Order\"}\n qoo10_statuses = {\"2\"=>\"Request Shipping\", \"3\"=>\"Check Order\"}\n market_place = Spree::MarketPlace.find(smp.market_place_id)\n qoo10_statuses.keys.each do |k|\n uri = URI(market_place.domain_url+'/ShippingBasicService.api/GetShippingInfo')\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data({'key'=>smp.api_secret_key,'ShippingStat'=>k,'search_Sdate'=>'','search_Edate'=>''})\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|http.request(req) end\n if res.code == \"200\"\n begin\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n if res_body[:ShippingAPIService][:ResultMsg] == \"Success\"\n for i in 1..res_body[:ShippingAPIService][:TotalOrder].to_i\n begin\n @order = nil\n order = res_body[:ShippingAPIService][(\"Order\"+i.to_s).to_sym]\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:orderNo], smp.seller_id).try(:first)\n @shpping_address = nil\n @billing_address = nil\n @is_customer_pickup = nil\n if !@order.present?\n gift = order[:Gift].present? ? false : true\n shipping_country = Spree::Country.find_by_iso(order[:shippingCountry])\n billing_country = Spree::Country.find_by_iso(order[:senderNation])\n name = order[:receiver].present? ? order[:receiver] : (order[:buyer].present? ? order[:buyer] : \"NA\")\n telno = order[:receiverTel].present? ? order[:receiverTel] : (order[:buyerTel].present? ? order[:buyerTel] : \"NA\")\n mobileno = order[:receiverMobile].present? ? order[:receiverMobile] : (order[:buyerMobile].present? ? order[:buyerMobile] : \"NA\")\n if order[:OrderType] == \"Pickup\"\n @is_customer_pickup = true\n # Our Singapore warehouse address\n address1 = \"151 Pasir Panjang Road\"\n address2 = \"#02-02 Pasir Panjang Distripark\"\n zipcode = \"118480\"\n phone = \"+65 6271 0524\"\n @shpping_address = Spree::Address.create!(:firstname=>name, :lastname=>name, :address1=>address1, :address2=>address2, :city=>shipping_country.name, :zipcode=>zipcode, :phone=>phone, :alternative_phone=>\"\", :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n if order[:Addr1].present?\n @billing_address = Spree::Address.create!(:firstname=>name, :lastname=>name, :address1=>order[:Addr1], :address2=>order[:Addr2], :city=>shipping_country.name, :zipcode=>order[:zipCode], :phone=>telno, :alternative_phone=>mobileno, :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n end\n else\n @is_customer_pickup = false\n @shpping_address = Spree::Address.create!(:firstname=>name, :lastname=>name, :address1=>order[:Addr1], :address2=>order[:Addr2], :city=>shipping_country.name, :zipcode=>order[:zipCode], :phone=>telno, :alternative_phone=>mobileno, :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n end\n if !order[:senderName].present? && !order[:senderAddr].present? && !order[:senderNation].present? && !order[:senderZipCode].present? && !order[:senderTel].present? && !billing_country.nil?\n @billing_address = Spree::Address.create!(:firstname=>order[:senderName], :lastname=>order[:senderName], :address1=>order[:senderAddr], :address2=>\"\", :city=>billing_country.name,\n :zipcode=>order[:senderZipCode], :phone=>order[:senderTel], :alternative_phone=>\"\", :country_id=>billing_country.id, :state_name=>billing_country.name)\n end\n billing_address = (!@billing_address.nil? && !@billing_address.blank?) ? @billing_address.id : nil\n if @shpping_address.present?\n @order = Spree::Order.create!(:number=>order[:orderNo], :order_date=> order[:PaymentDate], :market_place_details=>order, :item_total=>order[:orderPrice], :total=>order[:total].to_f, :payment_total=>order[:total], :email=>order[:buyerEmail], :currency=>order[:Currency], :send_as_gift=>gift, :market_place_id=>smp.market_place_id, :market_place_order_no=>order[:orderNo], :market_place_order_status=>qoo10_statuses[k], :bill_address_id=>billing_address, :ship_address_id=> @shpping_address.id, :cart_no=> order[:packNo], :seller_id=>smp.seller_id, :is_bypass=>!cm_user)\n else\n @message << order[:orderNo]+\": \"+ \"Ooops..Shipping address is missing\"\n end\n if cm_user\n @mp_product = nil\n @mp_product = Spree::SellersMarketPlacesProduct.find_by_market_place_product_code(order[:itemCode])\n if @order.present?\n if order[:option] == \"\"\n @variant = Spree::Variant.includes(:product).where(\"spree_products.seller_id=? AND sku=?\", smp.seller_id, order[:sellerItemCode]).try(:first) if order[:sellerItemCode].present?\n @variant = Spree::Variant.find_by_sku(@mp_product.product.sku) if !@variant.present? && @mp_product.present? \n if @variant.present? && @variant.product.kit.present?\n kit = @variant.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>order[:total])\n stock = lt_variant.product.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Variant Kit 003'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>((stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 )) if stock.present? && lt_variant.quantity_inflations.present?\n end\n elsif @variant.present?\n if @variant.parent_id.present?\n @parent = Spree::Variant.find(@variant.parent_id)\n if @parent.product.kit.present?\n kit = @parent.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>order[:total])\n stock = lt_variant.product.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Variant Family 002'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>((stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 )) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>order[:total])\n type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - order[:orderQty].to_i)) if !@parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 parent Family kit 001'\n @parent.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present? && @parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Kit 001'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @parent.quantity_inflations.present?\n end\n child_type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n if (child_type != \"flat_quantity\") || (child_type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).try(:first)\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && (@parent.quantity_inflations.present? || @variant.quantity_inflations.present?)\n end\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>order[:total])\n type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Only Variant Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n end\n else\n option_code_count = 1\n option_codes = []\n if order[:optionCode] == \"\" || !order[:optionCode].present?\n option_arr = order[:option].split(\":\")\n if option_arr[1].split(\"(+\").count > 1\n option_arr[1] = option_arr[1].split(\"(+\")[0]\n elsif option_arr[1].split(\"(-\").count > 1\n option_arr[1] = option_arr[1].split(\"(-\")[0]\n end\n @variant = nil\n @mp_product.product.variants.each do |v|\n @variant = v if !v.option_values.blank? && (v.option_values.map(&:presentation).include?option_arr[1].strip)\n option_codes = [@variant.sku] if @variant.present?\n end if @mp_product.present? && @mp_product.product && @mp_product.product.option_types && @mp_product.product.option_types.present? && (@mp_product.product.option_types.map(&:presentation).include?option_arr[0])\n else\n option_codes = order[:optionCode].to_s.split(\",\")\n option_code_count = option_codes.length\n end\n for j in 0..(option_code_count - 1)\n @line_item = nil\n @stock = nil\n @variant = nil\n @variant = Spree::Variant.includes(:product).where(\"spree_products.seller_id=? AND sku=?\", smp.seller_id, option_codes[j]).try(:first) if order[:sellerItemCode].present?\n @variant = @mp_product.product.variants_including_master.find_by_sku(option_codes[j]) if !@variant.present? && @mp_product.present?\n if @variant.present?\n if @variant.product.kit.present?\n kit = @variant.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>(order[:total].to_f/option_code_count))\n stock = lt_variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).try(:first)\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Only Kit If'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>(stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 ) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n if @variant.parent_id.present?\n @parent = Spree::Variant.find(@variant.parent_id)\n # @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup)\n if @parent.product.kit.present?\n l_items = @parent.product.kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>(order[:total].to_f/option_code_count))\n stock = lt_variant.product.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Kit If'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>((stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 )) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>(order[:total].to_f/option_code_count))\n type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - order[:orderQty].to_i)) if !@parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Parent Family Kit Else'\n @parent.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present? && @parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Kit Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @parent.quantity_inflations.present?\n end\n child_type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n if (child_type != \"flat_quantity\") || (child_type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && (@parent.quantity_inflations.present? && @variant.quantity_inflations.present?)\n end\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>(order[:total].to_f/option_code_count))\n type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 without Family Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n\n end\n end\n # if @variant.parent_id.present?\n # @parent = Spree::Variant.find(@variant.parent_id)\n # type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n # @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - order[:orderQty].to_i)) if !@parent.quantity_inflations.present?\n # if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n # @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n # @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock && @parent.quantity_inflations.present?\n # end\n # else\n # type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n # @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present?\n # if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n # @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n # @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock\n # end\n # end\n\n end # end of option codes loop\n end\n end\n else # is CM user else\n Spree::MpOrderLineItem.create!(:order_id=>@order.id, :market_place_details=>@order.market_place_details)\n end\n @order.update_column(:total, order[:total])\n @order.reload\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => @order})\n @cart_numbers << order[:packNo]\n else # else for the order check condition\n if @order.market_place_order_status != qoo10_statuses[k]\n @order.update_attributes(:market_place_order_status=>qoo10_statuses[k])\n end\n end\n @message << (@order && @order.present? ? (@order.market_place_order_no.to_s+\": \"+ \"Success\") : nil)\n rescue Exception => e\n @message << e.message\n end\n end # End of for loop\n end\n rescue Exception => e\n @message << e.message\n end\n else\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n @message << res_body[:ShippingAPIService][:ResultMsg]\n end\n end\n @cart_numbers = @cart_numbers.uniq\n @message << \"FBA: \"+ Spree::Order.push_to_fba(@cart_numbers) if @cart_numbers.present?\n return @message.join(\"; \")\n end", "def cancel_order_fetch_qoo10(smp)\n @message = []\n market_place = Spree::MarketPlace.find(smp.market_place_id)\n #qoo10_claim_statuses = {\"1\"=>\"Cancel Request\", \"2\"=>\"Cancelling\", \"3\"=>\"Cancel Completed\", \"4\"=>\"Return Request\", \"5\"=>\"Returning\", \"6\"=>\"Return completed\"}\n #qoo10_claim_statuses.keys.each do |k|\n uri = URI(market_place.domain_url+'/ShippingBasicService.api/GetClaimInfo')\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data({'key'=> smp.api_secret_key, 'ClaimStat'=> '3', 'search_Sdate'=> '', 'search_Edate'=>''})\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|http.request(req)end\n if res.code == \"200\"\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=> true)\n begin\n if res_body[:ShippingAPIService][:ResultMsg] == \"Success\"\n for i in 1..res_body[:ShippingAPIService][:TotalOrder].to_i\n order = res_body[:ShippingAPIService][(\"Order\"+i.to_s).to_sym]\n # find out the order\n @order = nil\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:orderNo], smp.seller_id).try(:first)\n # check order present or not and order should not be cancelled already\n if @order.present? && !@order.is_cancel?\n # code to cancel the order\n if @order.update_attributes(:is_cancel=> true)\n cm_user = !@order.is_bypass rescue true\n if cm_user\n seller_id = @order.seller_id\n market_place_id = @order.market_place_id.present? ? @order.market_place_id : nil\n product_id = @order.products.present? ? @order.products.first.id : nil\n seller_market_place_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", seller_id, market_place_id, product_id)\n if seller_market_place_product.present?\n # code to add the stock after cancelling the order\n # if @order.line_items.present?\n # @order.line_items.each do |line_item|\n # stock = seller_market_place_product.first.product.stock_products.where(\"variant_id=? AND sellers_market_places_product_id=?\", line_item.variant.id, seller_market_place_product.first.id).first\n # stock.variant.update_attributes(:fba_quantity=>stock.variant.fba_quantity + line_item.quantity) if stock && !stock.variant.quantity_inflations.present?\n # stock.update_attributes(:count_on_hand=>stock.count_on_hand + line_item.quantity) if stock\n # end\n # end\n @order.update_attributes!(:market_place_order_status => \"cancel\", :order_canceled_date=>order[:cancelRefundDate])\n # call api in FBA to cancel the order\n #@order.cancel_order_on_fba(smp)\n @message << @order.market_place_order_no.to_s+\": \"+ \"Success\"\n end # End if seller_product\n else\n @order.update_attributes!(:market_place_order_status => \"cancel\", :order_canceled_date=>order[:cancelRefundDate])\n @order.mp_order_line_items.update_all(:is_cancel=>true)\n end\n else\n @order.update_attributes(:is_cancel=> false, :order_canceled_date=>nil)\n @message << @order.market_place_order_no.to_s+\": \"+ \"Failure\"\n end # End if update order\n else\n @message << \"Order not found!\"\n end # End if order nil\n end # End of for loop\n end # End of if\n # Order cancelation on FBA\n order_cancelation_on_fba(smp)\n rescue Exception => e\n @message << e.message\n end\n else\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=> true)\n @message << res_body[:ShippingAPIService][:ResultMsg]\n end\n #end # End of do\n return @message.join(\"; \")\n end", "def _get_current_expected(orders, comments)\n\n orders.each do |user_hash|\n\n users = user_hash.keys\n\n if users.nil? or users.empty?\n\n next\n\n else\n\n self.item.comments.each do |comment|\n next unless comment.xtype == Comment::XTYPE_ACK\n users.delete comment.user_id\n end\n\n if users.empty?\n next\n else\n return users\n end\n\n end\n end\n\n # Accepted\n return []\n end", "def get_payment_message\n final_price =self.subscription.plan_price.to_f\n coupon_found = self.orders.where(state: 'paused').first.coupon.present?\n payment_message = \"You will be charged $#{final_price}/month for this subscription.\"\n payment_message = self.coupon.price_with_coupon(final_price) if coupon_found\n payment_message\n end", "def failed order\n @order = order\n \n mail(to: order.email, \n from: \"#{Store.settings.name} <#{Store.settings.email}>\",\n subject: \"#{Store.settings.name} Order ##{@order.id} failed\"\n ) do |format|\n format.html { render \"themes/#{Store.settings.theme.name}/emails/orders/failed\", layout: \"../themes/#{Store.settings.theme.name}/layout/email\" }\n format.text { render \"themes/#{Store.settings.theme.name}/emails/orders/failed\", layout: \"../themes/#{Store.settings.theme.name}/layout/email\" }\n end\n end", "def update_errors\n @errors = []\n @errors << 'Expiration date is a required field' unless expiration_date\n @errors << 'Expiration Date is not a valid date' unless expiration_date.is_a? Date\n @errors << 'Card type is a required field' unless card_type\n @errors << 'Card type is not supported' unless check_card_type\n @errors << 'Card number is not valid' unless card_number_valid?\n @errors\n end", "def invalid_items\n items.select { |item| item.errors.present? }\n end", "def derive_errors_from_error(error)\n @errors = self.errors.merge(error.details)\n end", "def process_payment cart, params\n # type will be 'credit_card' or something similar\n unless type = select_payment_type(params)\n msg = \"#{cart.customer.email}: Unable to determine payment type\"\n log_error \"Payment\", msg\n return PaymentResponse.new(\n :success => false,\n :message => msg,\n :body => params[:payment][:method].to_s\n )\n end\n\n # processors will be [AuthorizeNet] or something similar\n if (processors = select_payment_processors(type)).empty?\n msg = \"#{cart.customer.email}: Unable to find payment processor\"\n log_error \"Payment\", msg\n return PaymentResponse.new(\n :success => false,\n :message => msg,\n :body => params[:payment][:method].to_s\n )\n end\n\n invalid_responses = []\n first_valid_response = false\n processors.detect do |pr|\n # can be per-processor/method\n # or global\n pm = params[\"#{pr.name}_#{type}\"] || params[:payment]\n begin\n rv = pr.process(type, cart, pm)\n rescue Exception => ex\n msg = \"#{cart.customer.email}: \" + \n \"Exception Caught during processing: #{ex.message}\" +\n \"\\n-- #{ex.backtrace.join(\"\\n-- \")}\"\n rv = PaymentResponse.new(\n :success => false,\n :message => msg,\n :body => \"\"\n )\n log_error \"Payment\", msg\n end\n invalid_responses << rv unless rv.success?\n rv.success? ? first_valid_response = rv : nil\n end\n\n return first_valid_response || invalid_responses\n end", "def order_billing_address_lines\n order.bill_address.try(:full_address_array)\n end", "def filter_low_priority_errors(errors)\n list = errors.split(\"\\n\")\n list.reject! do |line|\n line.include?(\"is not approved by W3C\") ||\n line.include?('proprietary attribute \"ng-') || # AngularJS custom attributes\n line.include?(\"inserting implicit <body>\") ||\n line =~ /trimming empty <(i|em|span)>/ # Used for icons and presentation\n end\n return nil if list.size==0\n return list.join(\"\\n\")\n end", "def pay!\n #soap_server = VendorPayment.generate_soap_server\n #token = VendorPayment.generate_usa_epay_security_token\n #custNum = observed.vendor_payment_period.store.id\n #paymentMethodID = nil\n #parameters = generate_transaction_request\n #response = soap_server.runCustomerTransaction(token, custNum, paymentMethodID, parameters)\n #\n if self.vendor_payment_period.store.usa_epay_customer_number.blank?\n self.errors['usa_epay_customer_number'] = \"The USA ePay custNum must be set before a payment can be made.\"\n return\n end\n gateway = VendorPayment.gateway\n payment_methods_response = gateway.get_customer_payment_methods(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number)\n monthly_transfer_method = nil\n items = if payment_methods_response.params['get_customer_payment_methods_return']\n payment_methods_response.params['get_customer_payment_methods_return']['item']\n else\n []\n end\n \n if items.is_a?(Hash)\n items = [items]\n end\n \n items.each do |payment_method|\n if payment_method['method_name'].strip == 'Monthly ACH Transfer'\n monthly_transfer_method = payment_method\n end\n end\n \n if monthly_transfer_method\n response = gateway.run_customer_transaction(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number,\n :command => 'CheckCredit',\n # USA ePay does pennies for the amount, so it needs to be\n # multiplied by 100\n :payment_method_id => monthly_transfer_method['method_id'],\n :amount => self.amount * 100)\n \n \n self.state = if response.message['result_code'].strip == 'A'\n VendorPayment.status_codes[response.message['status_code']]\n else\n VendorPayment.status_codes[\"E\"]\n end\n self.response_data = YAML::dump(response)\n if !response.message['ref_num'].blank?\n self.response_code = response.message['ref_num']\n save\n else\n save\n self.errors['transaction'] = \"State: #{self.state}. There was an error with code #{response.message['error_code']}, while trying to make the payment. Check USA ePay for reference number #{response.message['ref_num']} if necessary.\\n\\nFull Message: #{response.message.inspect}\"\n end\n self.vendor_payment_period.update_payment_total!\n self.vendor_payment_period.update_state!\n else\n self.errors['payment_method'] = \"There is no payment method on the vendor called 'Monthly ACH Transfer'\"\n end\n end", "def get_order_ids_for_cancel_or_pause\n #here sending back the order ids which are supposed to be marked canceled.\n #delivery_date > (ORDER_UPDATE_LIMIT+1).days.from_now.to_date)\n self.orders.where(\"state = ? and payment_state = ? and shipment_state = ? and delivery_date > ?\",\n 'confirm', 'pending', 'pending',(ORDER_UPDATE_LIMIT+1).days.from_now.to_date).pluck(:id)\n end", "def error_list(strict = false)\n c = @data_object\n res = []\n\n res << \"Missing name\" if c.con_first_name.empty? || c.con_last_name.empty?\n\n if strict\n if c.con_day_tel.empty? && c.con_eve_tel.empty? && c.con_fax_tel.empty? \n res << \"Must supply at least one contact telephone number\" \n end\n end\n\n check_length(res, c.con_first_name, 50, \"first name\")\n check_length(res, c.con_last_name, 50, \"first name\")\n check_length(res, c.con_day_tel, 20, \"daytime telephone number\")\n check_length(res, c.con_eve_tel, 20, \"evening telephone number\")\n check_length(res, c.con_fax_tel, 20, \"fax telephone number\")\n check_length(res, c.con_email, 60, \"e-mail address\")\n\n unless c.con_email.empty?\n msg = Mailer.invalid_email_address?(c.con_email)\n res << msg if msg \n end\n\n res.concat mail.error_list(strict, \"mailing\")\n res.concat ship.error_list(strict, \"shipping\")\n\n if strict && @mail.empty?\n res << \"Please specify a mailing address\"\n end\n\n if strict && !c.con_ship_to_mail && ship.empty?\n res << \"Please specify a shipping address (or click box to indicate\" +\n \" that your mailing address is your shipping address\"\n end\n\n res\n end", "def extract_error_details response\n if\n (response.http_response.status >= 300 ||\n response.request_type == :complete_multipart_upload) and\n body = response.http_response.body and\n error = Core::XML::Parser.parse(body) and\n error[:code]\n then\n [error[:code], error[:message]]\n end\n end", "def failed_email_delivery_contacts\n \n failed_email_delivery_contacts = Array.new \n \n mailout_contacts.each do |mc|\n failed_email_delivery_contacts.push(mc) if !mc.delivery_timestamp.blank? && mc.delivery_failed\n end\n \n return failed_email_delivery_contacts\n end", "def errors\n error_messages = []\n [:git].each do |key|\n error_messages << \"include_policy for #{name} is missing key #{key}\" unless source_options[key]\n end\n\n error_messages\n end", "def process_error(errors)\n\n res = {\n :msg => '',\n :fields => []\n }\n errors.each do |err|\n res[:fields].push(err[0])\n res[:msg] += \"<p>#{err[0]} #{err[1]}</p>\"\n end\n res\n end", "def errors\n @raw_response.parsed_response&.dig(\"errorList\", \"error\") || []\n end", "def valid_response_pairs\n split_into_pairs_response.select do |pair|\n (pair - currency_codes).size.zero?\n end\n end", "def no_paypal_content\n errors.add_to_base(\"Please, no thirdparty websites.\") if content =~ /paypal/i\n end", "def failed_purchase_response\n <<~XML\n <ccTxnResponseV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n <confirmationNumber>126740506</confirmationNumber>\n <decision>DECLINED</decision>\n <code>3009</code>\n <actionCode>D</actionCode>\n <description>Your request has been declined by the issuing bank.</description>\n <avsResponse>B</avsResponse>\n <cvdResponse>M</cvdResponse>\n <detail>\n <tag>InternalResponseCode</tag>\n <value>160</value>\n </detail>\n <detail>\n <tag>SubErrorCode</tag>\n <value>1005</value>\n </detail>\n <detail>\n <tag>InternalResponseDescription</tag>\n <value>auth declined</value>\n </detail>\n <txnTime>2009-01-08T17:00:46.529-05:00</txnTime>\n <duplicateFound>false</duplicateFound>\n </ccTxnResponseV1>\n XML\n end", "def get_unshipped_orders\n @orders = Order.by_state('paid').find(:all, :conditions => ['downloaded_at IS NULL'], :include => [:line_items])\n \n respond_to do |format| \n #format.html\n format.xml\n end\n \n end", "def response_errors\n parsed_response['error']\nend", "def getErrorRecepientEmailList()\n return @errorRecepients\n end" ]
[ "0.6203334", "0.61273426", "0.6099045", "0.59701705", "0.56007934", "0.55140173", "0.5483827", "0.53790593", "0.5370483", "0.52740854", "0.5249226", "0.52462", "0.5234787", "0.5234353", "0.52242297", "0.51837796", "0.5175309", "0.5161314", "0.5143378", "0.5122039", "0.510268", "0.5087848", "0.5081148", "0.50750476", "0.5072743", "0.50679386", "0.50580466", "0.5045263", "0.5038933", "0.5025874", "0.50246227", "0.49947664", "0.49947223", "0.49945667", "0.49936152", "0.49852875", "0.49820128", "0.4980774", "0.4964286", "0.4963505", "0.49615896", "0.49533284", "0.49531195", "0.49454144", "0.4938524", "0.49321756", "0.49253032", "0.49202722", "0.49133283", "0.48835298", "0.48804376", "0.48798653", "0.48649564", "0.48596647", "0.48589575", "0.4856517", "0.48440322", "0.48235697", "0.48223093", "0.48146388", "0.48098153", "0.48096246", "0.48058563", "0.4803654", "0.48028845", "0.47928753", "0.4788667", "0.47883084", "0.47862548", "0.47809872", "0.47760236", "0.47691065", "0.4767864", "0.4756259", "0.47558475", "0.4751842", "0.47387755", "0.4735741", "0.47303864", "0.47283298", "0.47224185", "0.4716693", "0.4709826", "0.47050142", "0.47048685", "0.4701155", "0.46985492", "0.46969634", "0.46954897", "0.46940935", "0.4692811", "0.46900484", "0.46774268", "0.46747157", "0.46701628", "0.46659017", "0.46649867", "0.46618384", "0.4661788", "0.46588424" ]
0.689593
0
This overwrites the default implementation provided by Devise::Models::Validatable. It ignores blanks strings.
def password_required? !persisted? || !password.blank? || !password_confirmation.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_and_sanitize\n super\n end", "def validate_and_sanitize\n r = super\n return r unless r.success?\n\n @email = @email.to_s.downcase.strip\n @name = @name.to_s.downcase.strip\n\n return error_with_data(\n 'am_au_i_vas_1',\n 'Invite User Error',\n 'Please enter a valid email address',\n GlobalConstant::ErrorAction.default,\n {}\n ) if !Util::CommonValidateAndSanitize.is_valid_email?(@email)\n\n return error_with_data(\n 'am_au_i_vas_2',\n 'Invite User Error',\n 'Name cannot be blank',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @name.blank?\n\n return error_with_data(\n 'am_au_i_vas_3',\n 'Invite User Error',\n 'Name can be of maximum 100 characters',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @name.length > 100\n\n success\n end", "def strip_spaces \n # these are conditionalized because it is called before the validation\n # so the validation will make sure they are setup correctly\n if self.first_name? then self.first_name.strip! end \n if self.last_name? then self.last_name.strip! end \n if self.login? then self.login.strip! end \n if self.email? then self.email.strip! end \n end", "def normalize_fields\n\t\tself.email.downcase!\n\tend", "def validate_and_sanitize\n r = super\n return r unless r.success?\n\n success\n end", "def normalize_fields\n self.email.downcase!\n end", "def normalize_fields\n self.email.downcase!\n end", "def normalize_fields\n self.email.downcase!\n end", "def normalize_fields\n self.email.downcase!\n end", "def normalize_fields\n self.email.downcase!\n end", "def normalize_fields\n self.email.downcase!\n end", "def normalize_fields\n self.email.downcase!\n end", "def validate\n validate_string_attributes\n end", "def prepare_params_for_validation\n self.username = username.downcase.strip unless username.blank?\n self.name = name.strip unless name.blank?\n self.email = email.downcase.strip unless email.blank?\n self.password = password.strip unless password.blank?\n end", "def before_validation\n\t\tself.class.columns.each do |c|\n\t\t\tif self[c.name] and [:string, :text].include?(c.class)\n\t\t\t\tself[c.name] = RailsSanitize.full_sanitizer.sanitize(self[c.name]) \n\t\t\tend\n\t\tend\t\t\n\tend", "def before_validation()\n self.attribute_names.each do |n|\n self[n] = self[n].strip if self[n].kind_of?(String)\n end\n end", "def validate_and_sanitize\n validate\n end", "def apply_validations_for_string\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a String\") if value && (! value.kind_of?(String)) && (! value.kind_of?(Symbol))\n end\n end", "def normalize_blank_strings\n attributes.each do |column, value|\n self[column] = nil if value.is_a? String and value.blank?\n end\n end", "def before_import_save(record)\n self.allow_blank_password = true\n self.allow_blank_email = true\n end", "def devise_parameter_sanitizer; end", "def validate_and_sanitize\n r = super\n return r unless r.success?\n\n r = validate_matches\n return r unless r.success?\n\n success\n end", "def sanitize_input\n\t\t# to remove whitespace, use \n\t\t# self.<fieldname>.strip!\n\t\tself.homephone = self.homephone.gsub(/\\D/,'') if !self.homephone.blank?\n\t\tself.workphone = self.workphone.gsub(/\\D/,'') if !self.workphone.blank?\n\t\tself.cellphone = self.cellphone.gsub(/\\D/,'') if !self.cellphone.blank?\n\t\tself.fax = self.fax.gsub(/\\D/,'') if !self.fax.blank?\n\t\tself.prefcontactmethod = :Email if self.prefcontactmethod.blank?\n #\t\tself.email = self.email.downcase if self.email.present?\n\tend", "def valid_attributes\n { \"username\" => \"MyString\" }\n end", "def email_validator\n [\n ActiveModel::Validations::FormatValidator,\n {\n :allow_blank => true,\n :with => /\\A[^@\\s]+@[^@\\s]+\\.(\\S+)\\z/,\n :message => :invalid_email\n }\n ]\n end", "def sanitize_user\r\n self.first_name = Sanitize.clean(self.first_name).gsub('&amp;','&').gsub('&gt;', '>') unless self.first_name.blank?\r\n end", "def normalize_attributes\n self.first_name = self.first_name.downcase.titleize\n self.last_name = self.last_name.downcase.titleize\n self.email.downcase!\n end", "def disable_empty_password_validation()\n @password = \"non-empty\"\n end", "def _validates_default_keys\n %i[if unless on allow_blank allow_nil strict]\n end", "def validates\n temp = \"\"\n if (@name == '') || (@email == '') || (@phone == '') || (@password == '')\n temp = \"false\"\n else\n temp = \"true\"\n end\n end", "def validation\n # Rails.logger.debug \"#{self.class}.#{__method__} Default validator is empty\"\n end", "def apply_validations_for_text\n apply_validations_for_string\n end", "def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n success\n\n end", "def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_email\n return r unless r.success?\n\n r = add_user_allowed?\n return r unless r.success?\n\n r = fetch_and_validate_user\n return r unless r.success?\n\n success\n end", "def password_required?\n allow_blank_password ? false : super\n end", "def password_required?\n allow_blank_password ? false : super\n end", "def validate_and_sanitize\n\n @email = @email.to_s.downcase.strip\n\n validation_errors = {}\n if !Util::CommonValidateAndSanitize.is_valid_email?(@email)\n validation_errors[:email] = 'Please enter a valid email address'\n end\n\n if @password.length < 8\n validation_errors[:password] = 'Password should be minimum 8 characters'\n end\n\n return error_with_data(\n 'um_su_1',\n 'Registration Error',\n '',\n GlobalConstant::ErrorAction.default,\n {},\n validation_errors\n ) if validation_errors.present?\n\n # NOTE: To be on safe side, check for generic errors as well\n r = validate\n return r unless r.success?\n\n success\n end", "def validate_and_sanitize\n r = validate\n return r unless r.success?\n success\n end", "def ignore_blank_passwords(value = nil)\n rw_config(:ignore_blank_passwords, value, true)\n end", "def validator=(_); end", "def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n @email = @email.downcase.strip\n\n unless Util::CommonValidator.is_valid_email?(@email)\n return validation_error(\n 'am_w_e_1',\n 'invalid_api_params',\n ['invalid_email'],\n GlobalConstant::ErrorAction.default\n )\n end\n\n success\n\n end", "def is_valid; end", "def validate_custom_field_values\n true\n end", "def setting_validations\n errors.add(:value, I18n.t(:blank, :scope => 'activerecord.errors.messages')) if validators['presence'] && ['1','true',true].include?(validators['presence']) && self.value.nil?\n errors.add(:value, I18n.t(:inclusion, :scope => 'activerecord.errors.messages')) if valid_values && !valid_values.include?(self.value)\n errors.add(:value, I18n.t(:invalid, :scope => 'activerecord.errors.messages')) if validators['format'] && !(Regexp.new(validators['format']) =~ self.value)\n end", "def check_create_user_name_is_valid\n return self.name != \"\" ? true : false\n end", "def validator; end", "def literal_validation; end", "def literal_validation; end", "def validate_fields\n %w[email author].each do |field|\n value = self.send(field)\n abort \"Hoe #{field} value not set. aborting\" if value.nil? or value.empty?\n end\n end", "def email_address=(val)\n super(val.strip)\n end", "def errors\n super.tap do |errors|\n errors.add(:'user.email', 'is invalid') if errors[:'user.email'].empty?\n end\n end", "def lower_email\n self.email.downcase!\n self.name.downcase!\n end", "def letters_only\n\t\tregex = /\\A[^0-9`!@#\\$%\\^&*+_=]+\\z|\\A\\z/\n\t\tvalidates_format_of :name, :with => regex\n\t\tvalidates_format_of :university, :with => regex\n\t\tvalidates_format_of :department, :with => regex\n\tend", "def validate\n super\n if root? && (self.email.to_s.empty? || errors.invalid?(:email)) && self.phone.to_s.empty?\n errors.add(:base, \"Phone number or email address must be provided\".t)\n end\n if self.email\n unless self.organization.worldwide.map(&:site_domain).compact.include?(self.email_domain)\n errors.add(:email, \"not a valid email address at %{org}\".t % {:org => self.organization.root.name})\n end\n end\n end", "def subclass_validations ; true ; end", "def sanitize_inputs\n attributes.each do |attr_name, attr_value|\n next unless attr_value.is_a? String\n self[attr_name] = strip_markup attr_value\n end\n end", "def check_characters\n attributes.each do |key, val|\n next unless val.present? && val.is_a?(String)\n\n invalid_chars = val.gsub(Regexp.new(Constants::CHAR_WHITELIST), '')\n next if invalid_chars.empty?\n\n uniq_invalid_chars = invalid_chars.split('').uniq.join\n error_msgs = []\n error_msgs << SPACES_NOT_ALLOWED if uniq_invalid_chars.match(/ /)\n uniq_invalid_chars.delete!(' ')\n if uniq_invalid_chars.present?\n error_msgs << \"#{CHARS_NOT_ALLOWED} #{uniq_invalid_chars}\"\n end\n error_msgs.each { |msg| errors.add(key, msg) }\n end\n end", "def password_non_blank\n errors.add_to_base(\"Missing Password\") if hashed_password.blank?\n end", "def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_gateway_type\n return r unless r.success?\n\n success\n end", "def ensure_username\n return unless username.blank?\n\n self.username = email.gsub(/@.*$/, '')\n end", "def first_name_is_valid?\n return false unless not_nil_and_string(self.first_name)\n return self.first_name.length > 0\n end", "def is_validated\n\tif $user_name.size <= 1 #string have \\n \n\t\tre_enter_name\n\telse\n\t\treturn true;\t\n\tend\t\nend", "def validate\n super \n end", "def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end", "def validation_default; true; end", "def validation_default; true; end", "def validate\n super\n validates_presence :account\n validates_unique :account\n end", "def skip_validations\n true\n end", "def validates_not_string(atts, opts={})\n validatable_attributes(atts, opts) do |a,v,m|\n next unless v.is_a?(String)\n next m if m\n (sch = db_schema[a] and typ = sch[:type]) ? \"is not a valid #{typ}\" : \"is a string\"\n end\n end", "def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_parameters\n return r unless r.success?\n\n success\n end", "def validate_username_format\n return if valid_username_format?\n\n errors.add(:username, :invalid_characters)\n end", "def blank_username\n self.username = ''\n end", "def validate_and_sanitize\n\n # NOTE: To be on safe side, check for generic errors as well\n r = validate\n return r unless r.success?\n\n validation_errors = []\n\n validation_errors.push('invalid_is_super_admin') unless Util::CommonValidator.is_boolean_string?(@is_super_admin)\n\n return validation_error(\n 's_mm_sa_usar_1',\n 'invalid_api_params',\n validation_errors,\n GlobalConstant::ErrorAction.default\n ) if validation_errors.present?\n\n success\n\n end", "def downcase_case_insensitive_attributes\n self.email&.downcase!\n end", "def basic_validate_and_sanitize_string(entity_val, validations)\n entity_val = entity_val.to_s.strip\n\n max_length = validations[GlobalConstant::CmsConfigurator.max_length_key]\n return error_result_obj(\"Length cannot be more than #{max_length}\") if max_length && entity_val.length > max_length\n\n min_length = validations[GlobalConstant::CmsConfigurator.min_length_key]\n return error_result_obj(\"Length cannot be less than #{min_length}\") if min_length && entity_val.length < min_length\n\n basic_validate_includes(entity_val, validations)\n end", "def scrub_email_address\n self.email_address.downcase\n end", "def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_client_and_admin\n return r unless r.success?\n\n r = validate_allowed_keys\n return r unless r.success?\n\n success\n end", "def setting_validations\n if errors.empty?\n errors.add(:value, :blank) if validators['presence'] && ['1','true',true].include?(validators['presence']) && self.value.nil?\n errors.add(:value, :inclusion) if valid_values && !valid_values.include?(self.value)\n errors.add(:value, :invalid) if validators['format'] && !(Regexp.new(validators['format']) =~ self.value)\n end\n end", "def validation_default; false; end", "def _before_validation\n end", "def nullify_fields\n user_fields = %W(\n name\n email\n address\n )\n\n user_fields.each do |field|\n next if self[field].nil?\n self[field] = nil if self[field].empty?\n end\n end", "def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n r = validate_and_sanitize_params\n return r unless r.success?\n\n success\n end", "def validate\n errors.add_to_base('password', 'and confirmation do not match') unless password_confirmation == password\n errors.add_to_base(\"Your User ID is to long, can only store 4 characters!\") if self.userId.to_s.length > 4\n errors.add_to_base(\"Your User Name is to long, can only store 50 characters!\")if self.userName.to_s.length > 50\n errors.add_to_base(\"Your First Name is to long, can only store 50 characters!\")if self.firstName.to_s.length > 50\n errors.add_to_base(\"Your Last Name is to long, can only store 50 characters!\")if self.lastName.to_s.length > 50\n errors.add_to_base(\"Your Title is to long, can only store 50 characters!\") if self.title.to_s.length > 50\n errors.add_to_base(\"Your Photo is to long, can only store 50 characters!\") if self.photo.to_s.length > 50\n errors.add_to_base(\"Your Email is to long, can only store 30 characters!\") if self.email.to_s.length > 30\n errors.add_to_base(\"Your Byline ID is to long, can only store 11 characters!\") if self.bylineID.to_s.length > 11\n end", "def validate\n super\n end", "def validate\n return HESResponder(\"Field and value required.\", \"ERROR\") unless params[:field] && params[:value]\n fs = ['email','username', 'altid']\n f = params[:field]\n if !fs.include?(f)\n return HESResponder(\"Can't check this field.\", \"ERROR\")\n end\n f = f.to_sym\n v = params[:value]\n if @promotion.users.where(\"LOWER(#{f}) = ?\", v.downcase).count > 0\n return HESResponder(f.to_s.titleize + \" is not unique within promotion.\", \"ERROR\")\n else\n return HESResponder()\n end\n end", "def validate \n errors.add(:email, \"must be valid.\") unless email.include?(\"@\") \n if account.include?(\" \") \n errors.add(:account,\"cannot include spaces.\") \n end \n end", "def clean_space_in_email\n self.unconfirmed_email.gsub!(' ', '') if self.unconfirmed_email.present?\n self.email.gsub!(' ', '') if self.email.present?\n end", "def trim_all_fields\n self.attributes.each{|a| a.strip! if a.class == 'String'}\n end", "def downcase_fields\n self.email.downcase!\n end", "def downcase_fields\n self.email.downcase!\n end", "def normalize\n @normalized_email = email.downcase\n normalized_email\n end", "def password_required?\n super && uid.blank?\n end", "def first_name_is_valid\n errors.add(:first_name,'Invalid empty string for first name.') unless first_name_is_valid?\n end", "def full_name_format\n valid_full_name = true\n\n if !self.name.nil?\n # Must contains white space\n valid_full_name = false if (/^(.*\\s+.*)+$/i =~ self.name).nil?\n # Must be alpha\n valid_full_name = false if(/^[A-Z]+$/i =~ self.name.remove(' ')).nil?\n else\n valid_full_name = false\n end\n\n if !valid_full_name\n self.errors.add(:name, 'deve ser Completo')\n raise ActiveRecord::Rollback\n end\n end", "def without_validations\n with_validations(false)\n end", "def clean_data( field )\n\tfield.to_s.strip\nend", "def is_valid\n\tend", "def is_valid\n\tend", "def validation; end", "def validation; end", "def initialize\n super :presence\n end" ]
[ "0.65571713", "0.65002215", "0.63973045", "0.62082416", "0.61323094", "0.61208147", "0.610173", "0.610173", "0.610173", "0.610173", "0.610173", "0.610173", "0.60779613", "0.60002655", "0.59819067", "0.59806836", "0.5974878", "0.58948916", "0.5894875", "0.58794737", "0.58784544", "0.58654827", "0.5806433", "0.57194763", "0.57113063", "0.5700381", "0.56147635", "0.56119215", "0.55791193", "0.553989", "0.55357355", "0.55148363", "0.55142623", "0.55060536", "0.5501785", "0.5501785", "0.5495911", "0.5451119", "0.5432473", "0.5421734", "0.5399222", "0.53881073", "0.5386681", "0.5384267", "0.53785676", "0.536179", "0.53439486", "0.53439486", "0.5342532", "0.53372025", "0.5328715", "0.5320692", "0.5308845", "0.5303738", "0.52962214", "0.5291998", "0.5291502", "0.528441", "0.52831036", "0.52723545", "0.5267929", "0.5265833", "0.5261085", "0.5260644", "0.5248074", "0.5248074", "0.5242704", "0.52411956", "0.5238285", "0.52340007", "0.5224606", "0.52244765", "0.5222863", "0.52218425", "0.52200484", "0.5217949", "0.5215492", "0.52143294", "0.5210027", "0.5208519", "0.52085036", "0.52062756", "0.5203853", "0.5198538", "0.51925886", "0.5176509", "0.51475525", "0.5146882", "0.5143707", "0.5143707", "0.5142151", "0.5138058", "0.51362884", "0.51236874", "0.5120974", "0.5117187", "0.5117098", "0.5117098", "0.5114993", "0.5114993", "0.5114689" ]
0.0
-1
Compute the actual value of a field for a given serializer instance.
def value(serializer) if block serializer.instance_eval(&block) else serializer.read_attribute_for_serialization(name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_field_value(obj, name)\n begin\n @struct_field_getter.call(obj, name)\n rescue\n 0\n end\n end", "def get_value(field)\n field = item_type.find_field(field) unless field.is_a? Field\n field.value_for_item(self)\n end", "def field_value(field)\n @object.respond_to?(field) ? @object.send(field) : ''\n end", "def value_for(field)\n value = instance_variable_get(:\"@#{field}\")\n value.nil? ? nil : value.to_s\n end", "def process_field_value(value)\r\n value\r\n end", "def value\n attributes['FieldValue']\n end", "def get_field(field, serialize = true)\n if _cached?(field)\n return _cached_field(field) if _in_cache?(field)\n end\n\n response = if respond_to?(field)\n send(field)\n elsif object.respond_to?(field)\n object.send(field)\n else\n fail InvalidField, \"#{field} could not be found\"\n end\n\n if response.respond_to?(:serializable_hash) && serialize\n response = response.serializable_hash\n end\n\n if _cached?(field)\n _set_cached_field(field, response)\n else\n response\n end\n end", "def get_value_from(message_field)\n return if message_field.nil?\n\n message_field.public_send(*field_value)\n end", "def actual_value\n JSON.parse(self.value)['actual_value']\n end", "def field_value field, options = {}\n field_values(field, options)\n end", "def predictable_field_value\n return nil unless self.team\n self.team.id.to_s\n end", "def get_integer_value(field_name)\n\t\tend", "def value\n record.send(name).value\n end", "def get_value_or_id(field)\n field = item_type.find_field(field) unless field.is_a? Field\n field.value_or_id_for_item(self)\n end", "def get_field_deserializers()\n return super.merge({\n \"unit\" => lambda {|n| @unit = n.get_string_value() },\n \"value\" => lambda {|n| @value = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def value\n @value.to_f\n end", "def get_coll_field_val(fedora_obj, desired_field)\n if (desired_field.is_a?(String))\n desired_field = desired_field.to_sym\n end\n if (fedora_obj.collections.size > 0)\n coll_obj = HypatiaCollection.load_instance(fedora_obj.collections[0].pid)\n return get_values_from_datastream(coll_obj, \"descMetadata\", desired_field).first\n elsif (fedora_obj.sets.size > 0)\n # we can load the parent object as a set because we are only going to check \"collections\" and \"sets\"\n return values = get_coll_field_val(HypatiaSet.load_instance(fedora_obj.sets[0].pid), desired_field)\n end\n return \"\"\n end", "def get(field)\n self.class.get(field, @data)\n end", "def field_value(field_identifier, options={})\n data[lookup_field_code(field_identifier, options)]\n end", "def localized_dynamic_attribute_value(field)\n if field.is_a?(String)\n field = self.content_type.find_field(field)\n end\n\n return nil if field.nil?\n\n value = (self.dynamic_attributes || {})[field.name.to_sym]\n\n # DEBUG puts \"[#{field.name.inspect}] #{value.inspect} / #{field.localized.inspect} / #{value.is_a?(Hash).inspect}\"\n\n if !field.is_relationship? && field.localized && value.is_a?(Hash)\n # get the localized value for the current locale\n _value = value[Locomotive::Mounter.locale]\n\n # no value for the current locale, give a try to the main one\n if _value.nil? && Locomotive::Mounter.locale != self.main_locale\n _value = value[self.main_locale]\n end\n\n value = _value\n end\n\n value # DEBUG .tap { |v| puts \"[#{field.name}] returning #{v.inspect}\" }\n end", "def get_field_value(field)\n field_values = get_fields(field)\n return nil if field_values.blank?\n if field_values.first.delegation_field.multiple\n field_values.map(&:to_value)\n else\n field_values.first.to_value\n end\n end", "def field_value(field_identifier, options={})\n data[lookup_field_id_string(field_identifier, options)]\n end", "def imported_field_value(field)\n resource.try(field) || resource.try(:primary_imported_metadata)&.[](field) || parent_resource&.try(field) || parent_resource&.try(:primary_imported_metadata)&.[](field)\n end", "def value; super.to_f; end", "def [](field_name)\n f = field(field_name)\n f && f.value\n end", "def value\n return self.actual\n end", "def value\n return self.actual\n end", "def get_value(object)\n case value_type\n when 'integer' then object.value_integer\n when 'float' then object.value_float\n when 'string' then object.value_string\n else raise_invalid_type\n end\n end", "def valGetter\n \"#{DataMetaDom.getterName(@fld)}()\" + ( isMapping ? '.getKey()' : '')\n end", "def subfield_value(field, subfield)\n sub = field.subfields.find {|s| s.code == subfield}\n if sub.nil?\n return nil\n end\n sub.value\nend", "def get_number(field)\n field['numberValue']\n end", "def value\n res = form_object_value\n res = override_with_form_value(res)\n res\n end", "def value\n @casted_value ||= type_cast_value(@value)\n end", "def test_reflection_value\n serializer_class = Class.new(ActiveModel::Serializer) do\n has_one :blog\n end\n serializer_instance = serializer_class.new(@model, @instance_options)\n\n # Get Reflection\n reflection = serializer_class._reflections.fetch(:blog)\n\n # Assert\n assert_nil reflection.block\n assert_equal Serializer.config.include_data_default, reflection.options.fetch(:include_data_setting)\n assert_equal true, reflection.options.fetch(:include_data_setting)\n\n include_slice = :does_not_matter\n assert_equal @model.blog, reflection.send(:value, serializer_instance, include_slice)\n end", "def value_for(field, env)\n raw = env.attributes.delete(field)\n raw.is_a?(Array) ? raw.map { |val| deserialize(val) } : deserialize(raw)\n end", "def get_struct(field)\n field['structValue']\n end", "def serialized\n @value\n end", "def get_value\n @value.to_i\n end", "def get_value\n @value\n end", "def value_raw\n @value\n end", "def value(field)\n if DATE_FIELDS.include? (name=attr(field))\n Time.parse(field.text) rescue field.text\n elsif USER_FIELDS.include? name\n users[field.text.downcase]\n else\n field.text\n end\n end", "def value\n return @val\n end", "def record_value(record, property)\n case record\n when Hash\n record.fetch(property, record[property.field])\n when Resource\n property.get!(record)\n end\n end", "def object_field_value(method)\n meth = \"#{method}_before_type_cast\"\n if object && object.respond_to?(meth)\n object.send(meth)\n elsif object && object.respond_to?(method)\n object.send(method)\n else\n method.to_s.humanize\n end\n end", "def value\n data.value\n end", "def value\n attributes.fetch(:value)\n end", "def relation_value_for(name)\n if serializer.respond_to?(name)\n serializer.send(name)\n else\n resource.send(name)\n end\n end", "def get_value\n value\n end", "def get_value\n value\n end", "def value\n @attributes[:value]\n end", "def value\n if @value_set\n @value\n else\n value_from_response\n end\n end", "def field_value(field, opt = nil)\n opt ||= {}\n super(field, opt.merge(raw: true, blacklight_config: configuration))\n end", "def get_field_deserializers()\n return super.merge({\n \"daylightBias\" => lambda {|n| @daylight_bias = n.get_number_value() },\n })\n end", "def value\n self.lazy_proc?(@value) ? self.coerce(@value.call) : @value\n end", "def raw_value\n @value\n end", "def get_double_value(field_name)\n\t\tend", "def get_field_deserializers()\n return super.merge({\n \"offsetInDays\" => lambda {|n| @offset_in_days = n.get_number_value() },\n \"timeBasedAttribute\" => lambda {|n| @time_based_attribute = n.get_enum_value(MicrosoftGraph::Models::IdentityGovernanceWorkflowTriggerTimeBasedAttribute) },\n })\n end", "def get_value\n if @value != nil\n return @value\n else\n return @df_int\n end\n end", "def get_field_deserializers()\n return super.merge({\n \"averageInboundBitRate\" => lambda {|n| @average_inbound_bit_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageInboundFrameRate\" => lambda {|n| @average_inbound_frame_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageOutboundBitRate\" => lambda {|n| @average_outbound_bit_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"averageOutboundFrameRate\" => lambda {|n| @average_outbound_frame_rate = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def get_value\n read_attribute('number_value')\n end", "def value\n self['value']\n end", "def effective_field field\n each do |container|\n return container.value.send(field) unless container.empty?\n end\n nil\n end", "def get_field_deserializers()\n return super.merge({\n \"completedDateTime\" => lambda {|n| @completed_date_time = n.get_date_time_value() },\n \"progress\" => lambda {|n| @progress = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"status\" => lambda {|n| @status = n.get_enum_value(MicrosoftGraph::Models::DataPolicyOperationStatus) },\n \"storageLocation\" => lambda {|n| @storage_location = n.get_string_value() },\n \"submittedDateTime\" => lambda {|n| @submitted_date_time = n.get_date_time_value() },\n \"userId\" => lambda {|n| @user_id = n.get_string_value() },\n })\n end", "def value\n @value ||= extract_value\n end", "def value_field_for(rc, v)\n case rc\n when 'datetime'; 'datetime_value'\n when 'date'; Date === v ? 'datetime_value' : 'date_value'\n when 'time'; 'time_value'\n when 'float'; 'float_value'\n when 'integer'; 'integer_value'\n when 'string'; 'string_value'\n when 'text'; 'text_value'\n end\n end", "def mongo_value\n value\n end", "def get_field_value(data, field_name)\n data[field_name]['__content__'] if data[field_name]\n end", "def value\n return @value\n end", "def value\n return @value\n end", "def value\n return @value\n end", "def to_f \n return self.value\n end", "def field_value(field)\n field_config = blacklight_config.show_fields[field]\n Blacklight::ShowPresenter.new(@document, self).field_value field_config\n end", "def get_field_deserializers()\n return {\n \"failedRuns\" => lambda {|n| @failed_runs = n.get_number_value() },\n \"failedTasks\" => lambda {|n| @failed_tasks = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"successfulRuns\" => lambda {|n| @successful_runs = n.get_number_value() },\n \"totalRuns\" => lambda {|n| @total_runs = n.get_number_value() },\n \"totalTasks\" => lambda {|n| @total_tasks = n.get_number_value() },\n \"totalUsers\" => lambda {|n| @total_users = n.get_number_value() },\n }\n end", "def fwer_p_value\n @fwer_p_value ||= @fields[7].to_f\n end", "def get_field_deserializers()\n return {\n \"guestsCount\" => lambda {|n| @guests_count = n.get_number_value() },\n \"membersCount\" => lambda {|n| @members_count = n.get_number_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"ownersCount\" => lambda {|n| @owners_count = n.get_number_value() },\n }\n end", "def selector_field_value\n parent.record[@selector_for] rescue nil\n end", "def value\n @value\n end", "def value\n @value\n end", "def field_value(name, field)\n placement_collection[name].collect{|entry| entry[field]}\n end", "def value\n typecast.present? ? typecasted_value : super\n end", "def get_field_deserializers()\n return super.merge({\n \"cloudIdentityScore\" => lambda {|n| @cloud_identity_score = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"cloudManagementScore\" => lambda {|n| @cloud_management_score = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"cloudProvisioningScore\" => lambda {|n| @cloud_provisioning_score = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"healthStatus\" => lambda {|n| @health_status = n.get_enum_value(MicrosoftGraph::Models::UserExperienceAnalyticsHealthState) },\n \"manufacturer\" => lambda {|n| @manufacturer = n.get_string_value() },\n \"model\" => lambda {|n| @model = n.get_string_value() },\n \"modelDeviceCount\" => lambda {|n| @model_device_count = n.get_number_value() },\n \"windowsScore\" => lambda {|n| @windows_score = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n \"workFromAnywhereScore\" => lambda {|n| @work_from_anywhere_score = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def parented_field_value(field)\n if parent_resource\n [parent_resource.send(field), resource.send(field)].flatten.compact.join(\", \")\n else\n resource.send(field)\n end\n end", "def get_field_deserializers()\n return super.merge({\n \"bias\" => lambda {|n| @bias = n.get_number_value() },\n \"daylightOffset\" => lambda {|n| @daylight_offset = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::DaylightTimeZoneOffset.create_from_discriminator_value(pn) }) },\n \"standardOffset\" => lambda {|n| @standard_offset = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::StandardTimeZoneOffset.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"cidrAddress\" => lambda {|n| @cidr_address = n.get_string_value() },\n })\n end", "def serialize_value(value)\r\n value\r\n end", "def get_field_values document, _field, field_config, options = {}\n presenter(document).field_values field_config, options\n end", "def value\n parsed_value\n end", "def deserialize_value(value)\r\n value\r\n end", "def field_content\n value\n end", "def value\n Reac.value(self)\n end", "def get_field_deserializers()\n return {\n \"assignedUserCount\" => lambda {|n| @assigned_user_count = n.get_number_value() },\n \"completedUserCount\" => lambda {|n| @completed_user_count = n.get_number_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def get_field_deserializers()\n return super.merge({\n \"configurationVersion\" => lambda {|n| @configuration_version = n.get_number_value() },\n \"errorCount\" => lambda {|n| @error_count = n.get_number_value() },\n \"failedCount\" => lambda {|n| @failed_count = n.get_number_value() },\n \"lastUpdateDateTime\" => lambda {|n| @last_update_date_time = n.get_date_time_value() },\n \"notApplicableCount\" => lambda {|n| @not_applicable_count = n.get_number_value() },\n \"pendingCount\" => lambda {|n| @pending_count = n.get_number_value() },\n \"successCount\" => lambda {|n| @success_count = n.get_number_value() },\n })\n end", "def custom_field_value_by_id(field_id)\n @acl_cfv_hash = {} if @acl_cfv_hash.blank?\n return @acl_cfv_hash[field_id.to_s] if @acl_cfv_hash.has_key?(field_id.to_s)\n if self.acl_available_custom_fields.has_key?(field_id.to_i)\n x = CustomFieldValue.new\n x.custom_field = self.acl_available_custom_fields[field_id.to_i]\n x.customized = self\n @acl_cfv_hash[field_id.to_s] = x\n x\n else\n nil\n end\n end", "def get\n data[\"_value\"]\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end" ]
[ "0.6748203", "0.6200198", "0.6184239", "0.61141616", "0.6105577", "0.60647213", "0.60548264", "0.58782715", "0.5868786", "0.5817276", "0.5768793", "0.57410145", "0.5691646", "0.56735164", "0.5661844", "0.5659576", "0.56276053", "0.5621258", "0.5609502", "0.56037843", "0.5600924", "0.5600266", "0.5567815", "0.5567043", "0.55519134", "0.55421484", "0.55421484", "0.55119485", "0.54991645", "0.5475016", "0.54743385", "0.54666793", "0.5450118", "0.5434952", "0.5421965", "0.54185396", "0.54168034", "0.54114664", "0.54063207", "0.5403529", "0.53884643", "0.53862095", "0.5386032", "0.5366134", "0.5358416", "0.5349747", "0.5346441", "0.53426456", "0.53426456", "0.5340565", "0.5336683", "0.5335865", "0.53299505", "0.53244364", "0.5323523", "0.5319215", "0.5308152", "0.5293561", "0.5278788", "0.5274915", "0.5274736", "0.5274289", "0.5264677", "0.5245437", "0.52137834", "0.52101433", "0.52068335", "0.51882327", "0.51882327", "0.51882327", "0.5184713", "0.5180249", "0.5170473", "0.5169067", "0.5165257", "0.51596224", "0.5154911", "0.5154911", "0.5153262", "0.5150359", "0.51474416", "0.5144922", "0.51438296", "0.5136804", "0.51286024", "0.51284355", "0.5116398", "0.5116327", "0.5111411", "0.5103744", "0.5095849", "0.50948536", "0.509245", "0.5090648", "0.5088888", "0.5088888", "0.5088888", "0.5088888", "0.5088888", "0.5088888" ]
0.6846504
0
Decide whether the field should be serialized by the given serializer instance.
def excluded?(serializer) case condition_type when :if !evaluate_condition(serializer) when :unless evaluate_condition(serializer) else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialized?\n false\n end", "def serializable?(value)\n true\n end", "def use_serializer(serializer)\n @serializer = serializer\n end", "def deserialized?\n !!@deserialized\n end", "def deserialized?\n true\n end", "def serializer(name)\n @_serializer = name <= Malba::Serializer ? name : nil\n end", "def valid_against_schema?(schema, serializer)\n JSON::Validator.fully_validate(schema, serializer.to_json)\n end", "def get_field_deserializers()\n return super.merge({\n \"isUsableForSignIn\" => lambda {|n| @is_usable_for_sign_in = n.get_boolean_value() },\n })\n end", "def serialize!(object, serializer_instance)\n serializer = serializer(object, serializer_instance)\n return unless serializer\n serializer.call(object)\n end", "def requires_serialization_on_save?(model)\n maybe_flex_object = model._flex_column_object_for(column_name, false)\n out = true if maybe_flex_object && maybe_flex_object.deserialized?\n out ||= true if ((! column.null) && (! model[column_name]))\n out\n end", "def serialize?(argument)\n argument.is_a?(klass)\n end", "def serialize?(argument)\n argument.is_a?(klass)\n end", "def serializer\n return @serializer if defined?(@serializer)\n\n _serializer = injected_options.fetch(:serializer, serializer_class)\n\n @serializer = instantiated_serializer_for(_serializer)\n end", "def get_field_deserializers()\n return super.merge({\n \"isActive\" => lambda {|n| @is_active = n.get_boolean_value() },\n })\n end", "def with_serializer(object, serializer); end", "def serializer=(serializer) # :nodoc:\n @serializer = serializer\n serializer_methods = serializer::SerializerMethods\n for const in serializer_methods.constants\n klass = deep_const_get(const)\n modul = serializer_methods.const_get(const)\n klass.class_eval do\n instance_methods(false).each do |m|\n m.to_s == 'to_amf' and remove_method m\n end\n include modul\n end\n end\n self.serializer_state = serializer::State\n const_set :SerializerState, self.serializer_state\n end", "def with_serializer(serializer)\n @serializer = serializer\n self\n end", "def type_conforms?(obj, field)\n true\n end", "def field?\n true \n end", "def get_serializer_class\n return self.class.serializer_class || RESTFramework::NativeSerializer\n end", "def serializers\n self._additional_serializers # standard:disable Style/RedundantSelf\n end", "def serializer_by_options(options)\n serializer = options[:serializer]\n return unless serializer\n\n # If the given serializer is a class return it.\n return serializer if serializer.is_a? Class\n\n \"#{serializer.to_s.classify}Serializer\".safe_constantize\n end", "def method_defined?(method)\n return true if instance_methods(false).include?(method)\n return false if superclass == Surrealist::Serializer\n\n super\n end", "def test_reflection_value\n serializer_class = Class.new(ActiveModel::Serializer) do\n has_one :blog\n end\n serializer_instance = serializer_class.new(@model, @instance_options)\n\n # Get Reflection\n reflection = serializer_class._reflections.fetch(:blog)\n\n # Assert\n assert_nil reflection.block\n assert_equal Serializer.config.include_data_default, reflection.options.fetch(:include_data_setting)\n assert_equal true, reflection.options.fetch(:include_data_setting)\n\n include_slice = :does_not_matter\n assert_equal @model.blog, reflection.send(:value, serializer_instance, include_slice)\n end", "def serialize( att, val=send(att) )\n serializer = _serializer(att)\n serializer ? serializer.to_str(val) || val : super\n end", "def get_serializer_class\n return self.class.serializer_class\n end", "def custom_fields_for?(name)\n self.class.custom_fields_for?(name)\n end", "def serialize(serializer = nil, options = {})\n serializer ||= self.class::DEFAULT_SERIALIZER\n serializer.new(self, options: options).attributes\n end", "def _serializer(name)\n self.class.send(:_serializer, name)\n end", "def includes_for_serializer\n {}\n end", "def serializer_for(renderable, options = {})\n serializer_by_options(options) || serializer_by_renderable(renderable)\n end", "def get_field_deserializers()\n return super.merge({\n \"useDeviceContext\" => lambda {|n| @use_device_context = n.get_boolean_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"distributeForStudentWork\" => lambda {|n| @distribute_for_student_work = n.get_boolean_value() },\n \"resource\" => lambda {|n| @resource = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::EducationResource.create_from_discriminator_value(pn) }) },\n })\n end", "def serializer_class\n \"#{self.class.to_s}Serializer\".constantize\n end", "def render_field?(field_config)\n view_context.should_render_field?(field_config, document)\n end", "def serialize(with: nil)\n serializer = case with\n when nil\n @_serializer || empty_serializer\n when ->(obj) { obj.is_a?(Class) && obj <= Malba::Serializer }\n with\n when Proc\n inline_extended_serializer(with)\n else\n raise ArgumentError, 'Unexpected type for with, possible types are Class or Proc'\n end\n serializer.new(self).serialize\n end", "def _serializer(name)\n type = types[name]\n # flatten and cache all the serializers up the tree\n @_serializers ||= all_ancestors(serializers(nil)).reverse.reduce(&:merge)\n @_serializers[name] || @_serializers[type] || ( serializers(base)[type] ||= Serializer.default(type) if type )\n end", "def field?\n false \n end", "def serializer_class\n AccountSerializer\n end", "def value(serializer)\n if block\n serializer.instance_eval(&block)\n else\n serializer.read_attribute_for_serialization(name)\n end\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_boolean_value(\"isUsableForSignIn\", @is_usable_for_sign_in)\n end", "def member_uses_custom_type?(field)\n field.type.schemas.any? do |klass|\n Avromatic.type_registry.fetch(klass) != NullCustomType\n end\n end", "def serialization_options\n @serialization_options || self.class.serialization_options || self.class.superclass.serialization_options\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_boolean_value(\"isActive\", @is_active)\n end", "def get_field_deserializers()\n return super.merge({\n \"uninstallOnDeviceRemoval\" => lambda {|n| @uninstall_on_device_removal = n.get_boolean_value() },\n })\n end", "def serializer=(value)\n PaperTrail.config.serializer = value\n end", "def scrooged?\n @attributes.is_a?(ScroogedAttributes)\n end", "def generic_should_render_field?(config_field, document, field)\n send(:\"should_render_#{config_field}?\", document, field)\n end", "def generic_should_render_field?(config_field, document, field)\n send(:\"should_render_#{config_field}?\", document, field)\n end", "def serialized\n serializer_class.new(self).serializable_hash\n end", "def supports?(another_object)\n another_object.class.ancestors.include?(ActivityFeed::Serializable) &&\n instance[another_object.class.af_type_id.to_sym]\n end", "def get_field_deserializers()\n return super.merge({\n })\n end", "def get_field_deserializers()\n return super.merge({\n })\n end", "def get_field_deserializers()\n return super.merge({\n })\n end", "def should_render_show_field? document, field_config\n should_render_field?(field_config, document) && document_has_value?(document, field_config)\n end", "def get_field_deserializers()\n return super.merge({\n \"isExpirationRequired\" => lambda {|n| @is_expiration_required = n.get_boolean_value() },\n \"maximumDuration\" => lambda {|n| @maximum_duration = n.get_duration_value() },\n })\n end", "def caprese_is_field?(field)\n respond_to?(field = field.to_sym) || caprese_is_attribute?(field) || self.class.caprese_field_aliases[field]\n end", "def find_serializer(klass)\n klass.instance_variable_get(SERIALIZER_CLASS)\n end", "def allow_input_serializer(serializer, view: nil, views: nil, **filter_opts)\n raise SerializersAlreadyFrozenError if defined? @serialization_frozen\n raise ArrayInViewParameterError, :allow_input_serializer if view.is_a? Array\n views = [view] if views.nil?\n raise ViewsNotAnArrayError unless views.is_a? Array\n\n before_action do\n @serialization_available_serializers ||= {}\n @serialization_available_serializers[:input] ||= {}\n actions = filter_opts[:only] || :all_actions\n actions = [actions] unless actions.is_a?(Array)\n actions.each do |action|\n @serialization_available_serializers[:input][action.to_s] ||= []\n views.each do |v|\n @serialization_available_serializers[:input][action.to_s].push({serializer: serializer, view: v})\n end\n end\n end\n\n before_action(**filter_opts) do\n raise SerializersAlreadyFrozenError if defined? @serialization_frozen\n\n @serialization_input_registrations ||= SerializationRegistration.new(:input)\n\n mergeable_inputs = serializer.inputs_for(views: views)\n raise AddedEmptyInputSerializer, serializer.name if mergeable_inputs.registrations.empty?\n\n @serialization_input_registrations = @serialization_input_registrations.merge(mergeable_inputs)\n end\n end", "def get_field_deserializers()\n return super.merge({\n \"options\" => lambda {|n| @options = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WorkbookWorksheetProtectionOptions.create_from_discriminator_value(pn) }) },\n \"protected\" => lambda {|n| @protected = n.get_boolean_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"useDeviceLicensing\" => lambda {|n| @use_device_licensing = n.get_boolean_value() },\n \"vpnConfigurationId\" => lambda {|n| @vpn_configuration_id = n.get_string_value() },\n })\n end", "def serializer_class\n UserSerializer\n end", "def encoded?\n self.encoded.not_nil?\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_object_value(\"logicalTest\", @logical_test)\n writer.write_object_value(\"valueIfFalse\", @value_if_false)\n writer.write_object_value(\"valueIfTrue\", @value_if_true)\n writer.write_additional_data(@additional_data)\n end", "def is_resource_like\n return (self.is_resource || self.is_collection_object)\n end", "def encode\n raise Errors::SerializerNotConfigured if serializer_missing?\n\n serializer.encode(self)\n end", "def set_serializer(self_class, serializer_class)\n self_class.instance_variable_set(SERIALIZER_CLASS, serializer_class)\n end", "def params_ownerable(user); serializer_options.send :define_singleton_method, :params_ownerable do; user; end; end", "def get_field_deserializers()\n return {\n \"logicalTest\" => lambda {|n| @logical_test = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"valueIfFalse\" => lambda {|n| @value_if_false = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"valueIfTrue\" => lambda {|n| @value_if_true = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end", "def field?(name)\n @attributes.key?(name)\n end", "def get_field_deserializers()\n return super.merge({\n \"childSelectability\" => lambda {|n| @child_selectability = n.get_enum_value(MicrosoftGraph::Models::SecurityChildSelectability) },\n \"childTags\" => lambda {|n| @child_tags = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::SecurityEdiscoveryReviewTag.create_from_discriminator_value(pn) }) },\n \"parent\" => lambda {|n| @parent = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SecurityEdiscoveryReviewTag.create_from_discriminator_value(pn) }) },\n })\n end", "def persisted?\n super && parent.persisted?\n end", "def persisted?\n super && parent.persisted?\n end", "def active_model_serializer\n self.tire_active_model_serializer || self.class.active_model_serializer\n end", "def get_field_deserializers()\n return {\n \"allowCustomAssignmentSchedule\" => lambda {|n| @allow_custom_assignment_schedule = n.get_boolean_value() },\n \"enableOnBehalfRequestorsToAddAccess\" => lambda {|n| @enable_on_behalf_requestors_to_add_access = n.get_boolean_value() },\n \"enableOnBehalfRequestorsToRemoveAccess\" => lambda {|n| @enable_on_behalf_requestors_to_remove_access = n.get_boolean_value() },\n \"enableOnBehalfRequestorsToUpdateAccess\" => lambda {|n| @enable_on_behalf_requestors_to_update_access = n.get_boolean_value() },\n \"enableTargetsToSelfAddAccess\" => lambda {|n| @enable_targets_to_self_add_access = n.get_boolean_value() },\n \"enableTargetsToSelfRemoveAccess\" => lambda {|n| @enable_targets_to_self_remove_access = n.get_boolean_value() },\n \"enableTargetsToSelfUpdateAccess\" => lambda {|n| @enable_targets_to_self_update_access = n.get_boolean_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"onBehalfRequestors\" => lambda {|n| @on_behalf_requestors = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::SubjectSet.create_from_discriminator_value(pn) }) },\n }\n end", "def collection_serializer_class\n return @collection_serializer_class if defined?(@collection_serializer_class)\n\n if serializer_class.is_a?(Proc) # TODO: maybe we should do duck typing instead?\n @collection_serializer_class = injected_options[:collection_serializer]\n if @collection_serializer_class.nil?\n raise 'In case of a proc serializer, you need to specify a collection_serializer'\n end\n else\n @collection_serializer_class = serializer_class\n end\n\n @collection_serializer_class\n end", "def yaml_field? name\n !!self.yaml_fields[name]\n end", "def get_field_deserializers()\n return super.merge({\n \"appLockerApplicationControl\" => lambda {|n| @app_locker_application_control = n.get_enum_value(MicrosoftGraph::Models::AppLockerApplicationControlType) },\n \"applicationGuardAllowPersistence\" => lambda {|n| @application_guard_allow_persistence = n.get_boolean_value() },\n \"applicationGuardAllowPrintToLocalPrinters\" => lambda {|n| @application_guard_allow_print_to_local_printers = n.get_boolean_value() },\n \"applicationGuardAllowPrintToNetworkPrinters\" => lambda {|n| @application_guard_allow_print_to_network_printers = n.get_boolean_value() },\n \"applicationGuardAllowPrintToPDF\" => lambda {|n| @application_guard_allow_print_to_p_d_f = n.get_boolean_value() },\n \"applicationGuardAllowPrintToXPS\" => lambda {|n| @application_guard_allow_print_to_x_p_s = n.get_boolean_value() },\n \"applicationGuardBlockClipboardSharing\" => lambda {|n| @application_guard_block_clipboard_sharing = n.get_enum_value(MicrosoftGraph::Models::ApplicationGuardBlockClipboardSharingType) },\n \"applicationGuardBlockFileTransfer\" => lambda {|n| @application_guard_block_file_transfer = n.get_enum_value(MicrosoftGraph::Models::ApplicationGuardBlockFileTransferType) },\n \"applicationGuardBlockNonEnterpriseContent\" => lambda {|n| @application_guard_block_non_enterprise_content = n.get_boolean_value() },\n \"applicationGuardEnabled\" => lambda {|n| @application_guard_enabled = n.get_boolean_value() },\n \"applicationGuardForceAuditing\" => lambda {|n| @application_guard_force_auditing = n.get_boolean_value() },\n \"bitLockerDisableWarningForOtherDiskEncryption\" => lambda {|n| @bit_locker_disable_warning_for_other_disk_encryption = n.get_boolean_value() },\n \"bitLockerEnableStorageCardEncryptionOnMobile\" => lambda {|n| @bit_locker_enable_storage_card_encryption_on_mobile = n.get_boolean_value() },\n \"bitLockerEncryptDevice\" => lambda {|n| @bit_locker_encrypt_device = n.get_boolean_value() },\n \"bitLockerRemovableDrivePolicy\" => lambda {|n| @bit_locker_removable_drive_policy = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::BitLockerRemovableDrivePolicy.create_from_discriminator_value(pn) }) },\n \"defenderAdditionalGuardedFolders\" => lambda {|n| @defender_additional_guarded_folders = n.get_collection_of_primitive_values(String) },\n \"defenderAttackSurfaceReductionExcludedPaths\" => lambda {|n| @defender_attack_surface_reduction_excluded_paths = n.get_collection_of_primitive_values(String) },\n \"defenderExploitProtectionXml\" => lambda {|n| @defender_exploit_protection_xml = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },\n \"defenderExploitProtectionXmlFileName\" => lambda {|n| @defender_exploit_protection_xml_file_name = n.get_string_value() },\n \"defenderGuardedFoldersAllowedAppPaths\" => lambda {|n| @defender_guarded_folders_allowed_app_paths = n.get_collection_of_primitive_values(String) },\n \"defenderSecurityCenterBlockExploitProtectionOverride\" => lambda {|n| @defender_security_center_block_exploit_protection_override = n.get_boolean_value() },\n \"firewallBlockStatefulFTP\" => lambda {|n| @firewall_block_stateful_f_t_p = n.get_boolean_value() },\n \"firewallCertificateRevocationListCheckMethod\" => lambda {|n| @firewall_certificate_revocation_list_check_method = n.get_enum_value(MicrosoftGraph::Models::FirewallCertificateRevocationListCheckMethodType) },\n \"firewallIPSecExemptionsAllowDHCP\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_d_h_c_p = n.get_boolean_value() },\n \"firewallIPSecExemptionsAllowICMP\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_i_c_m_p = n.get_boolean_value() },\n \"firewallIPSecExemptionsAllowNeighborDiscovery\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_neighbor_discovery = n.get_boolean_value() },\n \"firewallIPSecExemptionsAllowRouterDiscovery\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_router_discovery = n.get_boolean_value() },\n \"firewallIdleTimeoutForSecurityAssociationInSeconds\" => lambda {|n| @firewall_idle_timeout_for_security_association_in_seconds = n.get_number_value() },\n \"firewallMergeKeyingModuleSettings\" => lambda {|n| @firewall_merge_keying_module_settings = n.get_boolean_value() },\n \"firewallPacketQueueingMethod\" => lambda {|n| @firewall_packet_queueing_method = n.get_enum_value(MicrosoftGraph::Models::FirewallPacketQueueingMethodType) },\n \"firewallPreSharedKeyEncodingMethod\" => lambda {|n| @firewall_pre_shared_key_encoding_method = n.get_enum_value(MicrosoftGraph::Models::FirewallPreSharedKeyEncodingMethodType) },\n \"firewallProfileDomain\" => lambda {|n| @firewall_profile_domain = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WindowsFirewallNetworkProfile.create_from_discriminator_value(pn) }) },\n \"firewallProfilePrivate\" => lambda {|n| @firewall_profile_private = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WindowsFirewallNetworkProfile.create_from_discriminator_value(pn) }) },\n \"firewallProfilePublic\" => lambda {|n| @firewall_profile_public = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WindowsFirewallNetworkProfile.create_from_discriminator_value(pn) }) },\n \"smartScreenBlockOverrideForFiles\" => lambda {|n| @smart_screen_block_override_for_files = n.get_boolean_value() },\n \"smartScreenEnableInShell\" => lambda {|n| @smart_screen_enable_in_shell = n.get_boolean_value() },\n })\n end", "def polymorphic_field? name\n return unless polymorphic?\n name == \"#{polymorphic_as}_type\" || name == \"#{polymorphic_as}_id\"\n end", "def get_field_deserializers()\n return super.merge({\n \"isDefault\" => lambda {|n| @is_default = n.get_boolean_value() },\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"locale\" => lambda {|n| @locale = n.get_string_value() },\n \"messageTemplate\" => lambda {|n| @message_template = n.get_string_value() },\n \"subject\" => lambda {|n| @subject = n.get_string_value() },\n })\n end", "def serializer\n ArticleSerializer\n end", "def serializer\n ArticleSerializer\n end", "def preferred_representation?\n InboundRelationships.new(self).preferred_representation.present?\n end", "def has_attribute?(attr)\n if config = self.class.serialized_columns[attr.to_sym]\n super(config.first)\n else\n super(attr)\n end\n end", "def should_encode?\n !@raw\n end", "def attribute(field, options = {})\n # set defaults \n options[:deserialize] = true unless options.has_key?(:deserialize)\n options[:serialize] = true unless options.has_key?(:serialize)\n options[:squash_nil] = true unless options.has_key?(:squash_nil)\n options[:name] ||= field\n options[:name] = options[:name].to_sym unless Symbol === options[:name]\n options[:field] = field\n # make sure we're not breaking the serialization rule\n if serialized_attributes.any? { |o| o[:serialize] && options[:serialize] && o[:name] == options[:name] }\n raise CerealEyes::AttributeError.new \"Unable to set duplicate attribute for serialization with name: #{options[:name]}\"\n end\n if serialized_attributes.any? { |o| o[:deserialize] && options[:deserialize] && o[:field] == options[:field] }\n raise CerealEyes::AttributeError.new \"Unable to set duplicate attribute for deserialization on field: #{options[:field]}\"\n end\n # add to hash\n key = options[:name].is_a?(Symbol) ? options[:name] : options[:name].to_sym\n serialized_attributes << options\n # create the reader if deserializable\n attr_reader(field) if options[:deserialize]\n attr_writer(field) if options[:serialize]\n nil\n end", "def get_field_deserializers()\n return super.merge({\n \"allowedMembers\" => lambda {|n| @allowed_members = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ConversationMember.create_from_discriminator_value(pn) }) },\n \"isHostTeam\" => lambda {|n| @is_host_team = n.get_boolean_value() },\n })\n end", "def formatter?\n subscribers.any? { |s| s.respond_to?(:is_formatter?) && s.is_formatter? }\n end", "def get_field_deserializers()\n return {\n \"allowCustomMemes\" => lambda {|n| @allow_custom_memes = n.get_boolean_value() },\n \"allowGiphy\" => lambda {|n| @allow_giphy = n.get_boolean_value() },\n \"allowStickersAndMemes\" => lambda {|n| @allow_stickers_and_memes = n.get_boolean_value() },\n \"giphyContentRating\" => lambda {|n| @giphy_content_rating = n.get_enum_value(MicrosoftGraph::Models::GiphyRatingType) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end", "def json?\n raw_options[:format] == :json\n end", "def field?(name)\n ! self[name].nil?\n end", "def get_field_deserializers()\n return super.merge({\n \"group\" => lambda {|n| @group = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Group.create_from_discriminator_value(pn) }) },\n \"includedSources\" => lambda {|n| @included_sources = n.get_enum_value(MicrosoftGraph::Models::SecuritySourceType) },\n })\n end", "def fetch_allowed_options\n _serializer_class = serializer_class\n _serializer_class = collection_serializer_class if _serializer_class.is_a?(Proc)\n\n unless _serializer_class.respond_to?(:simple_ams?)\n raise \"#{_serializer_class} does not respond to SimpleAMS methods, did you include the DSL module?\"\n end\n\n _serializer_class&.options\n end", "def respond_to?(sym)\n case\n when @attributes.keys.include?(sym)\n true\n when @collection.respond_to?(sym)\n true\n else\n super\n end\n end", "def _before_validation\n serialize_deserialized_values\n super\n end", "def is_attribute?; end", "def get_field_deserializers()\n return super.merge({\n \"includeTargets\" => lambda {|n| @include_targets = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AuthenticationMethodTarget.create_from_discriminator_value(pn) }) },\n \"isOfficePhoneAllowed\" => lambda {|n| @is_office_phone_allowed = n.get_boolean_value() },\n })\n end", "def base_doc?\n !@casted_by\n end", "def get_field_deserializers()\n return super.merge({\n \"allowPartnerToCollectIOSApplicationMetadata\" => lambda {|n| @allow_partner_to_collect_i_o_s_application_metadata = n.get_boolean_value() },\n \"allowPartnerToCollectIOSPersonalApplicationMetadata\" => lambda {|n| @allow_partner_to_collect_i_o_s_personal_application_metadata = n.get_boolean_value() },\n \"androidDeviceBlockedOnMissingPartnerData\" => lambda {|n| @android_device_blocked_on_missing_partner_data = n.get_boolean_value() },\n \"androidEnabled\" => lambda {|n| @android_enabled = n.get_boolean_value() },\n \"androidMobileApplicationManagementEnabled\" => lambda {|n| @android_mobile_application_management_enabled = n.get_boolean_value() },\n \"iosDeviceBlockedOnMissingPartnerData\" => lambda {|n| @ios_device_blocked_on_missing_partner_data = n.get_boolean_value() },\n \"iosEnabled\" => lambda {|n| @ios_enabled = n.get_boolean_value() },\n \"iosMobileApplicationManagementEnabled\" => lambda {|n| @ios_mobile_application_management_enabled = n.get_boolean_value() },\n \"lastHeartbeatDateTime\" => lambda {|n| @last_heartbeat_date_time = n.get_date_time_value() },\n \"microsoftDefenderForEndpointAttachEnabled\" => lambda {|n| @microsoft_defender_for_endpoint_attach_enabled = n.get_boolean_value() },\n \"partnerState\" => lambda {|n| @partner_state = n.get_enum_value(MicrosoftGraph::Models::MobileThreatPartnerTenantState) },\n \"partnerUnresponsivenessThresholdInDays\" => lambda {|n| @partner_unresponsiveness_threshold_in_days = n.get_number_value() },\n \"partnerUnsupportedOsVersionBlocked\" => lambda {|n| @partner_unsupported_os_version_blocked = n.get_boolean_value() },\n \"windowsDeviceBlockedOnMissingPartnerData\" => lambda {|n| @windows_device_blocked_on_missing_partner_data = n.get_boolean_value() },\n \"windowsEnabled\" => lambda {|n| @windows_enabled = n.get_boolean_value() },\n })\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n end" ]
[ "0.63052595", "0.6021169", "0.59802556", "0.58818585", "0.5848223", "0.5766111", "0.5580565", "0.5555198", "0.5526788", "0.55017895", "0.5501461", "0.5501461", "0.54995996", "0.54956186", "0.5441833", "0.5422963", "0.5386071", "0.53638804", "0.5346086", "0.532033", "0.52901757", "0.5269963", "0.5267323", "0.5260699", "0.5204181", "0.51933175", "0.5184509", "0.51806676", "0.5141217", "0.5125908", "0.5111011", "0.50818926", "0.5049977", "0.5049534", "0.50391954", "0.5038474", "0.50110793", "0.50016415", "0.49966556", "0.49946126", "0.49944726", "0.49785566", "0.49771103", "0.49310464", "0.48996264", "0.48935464", "0.48908645", "0.48839632", "0.48839632", "0.48772228", "0.48726115", "0.4861859", "0.4861859", "0.4861859", "0.4859315", "0.48559764", "0.4846879", "0.4840327", "0.4835932", "0.48359218", "0.48276013", "0.48237", "0.47987455", "0.4795791", "0.47919634", "0.47784033", "0.47754943", "0.47691652", "0.47481775", "0.47238454", "0.4708507", "0.46920303", "0.46920303", "0.4691726", "0.46915737", "0.46902257", "0.46811122", "0.46757448", "0.46757331", "0.46727082", "0.46709245", "0.46709245", "0.46662655", "0.46639404", "0.46636647", "0.46540114", "0.4650324", "0.46483704", "0.46467596", "0.46407783", "0.46378332", "0.4637783", "0.46353427", "0.46342096", "0.4632379", "0.46319196", "0.4630375", "0.46271235", "0.46269217", "0.46201074" ]
0.54653513
14
See the wiki for details:
def initialize(user) ############################## Household ############################## can :administrate, Household do |household| user.administrates?(household) end can :add_admin, Household do |household| user == household.head_admin end ############################## Completable ############################## can :accept, Completable do |todo| household = todo.household can?(:edit, todo) && todo.completed? && !todo.accepted? && can?(:administrate, household) end can :complete, Completable do |todo| household = todo.household user.household == household && !todo.completed? && !todo.accepted? end can :destroy, Completable do |todo| household = todo.household user.household == household && ( can?(:administrate, household) || todo.creator_id == user.id && !todo.accepted? ) end can :edit, Completable do |todo| household = todo.household todo.creator_id == user.id || can?(:administrate, household) end can :reorder, Completable do |todo| can?(:complete, todo) || can?(:uncomplete, todo) end can :uncomplete, Completable do |todo| household = todo.household user.household == household && !todo.accepted? && todo.completed? && (todo.completor_id == user.id || can?(:edit, todo)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def probers; end", "def schubert; end", "def refutal()\n end", "def implementation; end", "def implementation; end", "def verdi; end", "def who_we_are\r\n end", "def operations; end", "def operations; end", "def weber; end", "def internal; end", "def terpene; end", "def suivre; end", "def berlioz; end", "def identify; end", "def custom; end", "def custom; end", "def spec; end", "def spec; end", "def usage; end", "def usage; end", "def r; end", "def r; end", "def init; end", "def init; end", "def init; end", "def init; end", "def formation; end", "def extra; end", "def rossini; end", "def stderrs; end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def loc; end", "def loc; end", "def loc; end", "def operation; end", "def zuruecksetzen()\n end", "def signature; end", "def signature; end", "def signature; end", "def signature; end", "def signature; end", "def signature; end", "def signature; end", "def signature; end", "def signature; end", "def signature; end", "def desc; end", "def wrapper; end", "def sitemaps; end", "def used?; 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 dh; end", "def trd; end", "def flags; end", "def initialize\n\t\t\n\tend", "def handle; end", "def hd\n \n end", "def interface; end", "def interface; end", "def intensifier; end", "def ibu; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def state; end", "def initialize\n\n end", "def initialize\n\n end", "def hints; end", "def ref; end", "def what_is\n end", "def how_it_works\r\n end", "def accessibility; end", "def from; end", "def from; end", "def from; end", "def from; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end" ]
[ "0.82539827", "0.7248938", "0.7248938", "0.7248938", "0.7248938", "0.71688086", "0.6990566", "0.6774227", "0.6738524", "0.6738524", "0.6698437", "0.6693817", "0.6595375", "0.6595375", "0.6557783", "0.6554582", "0.64854026", "0.64631957", "0.6449498", "0.6434066", "0.6420554", "0.6420554", "0.63864756", "0.63864756", "0.6381341", "0.6381341", "0.63693744", "0.63693744", "0.6364531", "0.6364531", "0.6364531", "0.6364531", "0.6356105", "0.6338998", "0.63208336", "0.6308104", "0.6306417", "0.6306417", "0.6306417", "0.6306417", "0.6286983", "0.6286983", "0.6286983", "0.6270776", "0.62662995", "0.6262971", "0.6262971", "0.6262971", "0.6262971", "0.6262971", "0.6262971", "0.6262971", "0.6262971", "0.6262971", "0.6262971", "0.6256679", "0.62329733", "0.62247396", "0.6224672", "0.6223581", "0.6223581", "0.6223581", "0.6223581", "0.6223581", "0.6223581", "0.6223581", "0.6223581", "0.6223581", "0.6222164", "0.62195504", "0.6215922", "0.6215649", "0.6210271", "0.62075037", "0.6200287", "0.6200287", "0.61917156", "0.619115", "0.61839676", "0.61839676", "0.61839676", "0.61839676", "0.61839676", "0.61839676", "0.61839676", "0.61839676", "0.61812633", "0.61812633", "0.6179131", "0.6158537", "0.6158442", "0.6157558", "0.6156539", "0.6152064", "0.6152064", "0.6152064", "0.6152064", "0.61462605", "0.61462605", "0.61462605", "0.61462605" ]
0.0
-1
Just parse the json
def parse_json content json = ActiveSupport::JSON.decode(content) # validation validate json.kind_of?(Array), "JSON was not an array" json.each do |item| validate item.kind_of?(Hash), "JSON was not an array of objects" validate (item.keys.to_set == json.first.keys.to_set), "JSON objects did not have consistent keys" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse json; return JSON.parse File.read json end", "def parse json; return JSON.parse File.read json end", "def parse\n return if @id\n\n data = @json.is_a?(String) ? JSON.parse(@json) : @json\n @id = data[\"id\"]\n @time = data[\"created_at\"]\n @text = parse_text(data[\"text\"])\n end", "def parsed_json\n @parsed_json ||= JSON.parse(@json)\n end", "def parse(json)\n JSON.parse(json) rescue nil\n end", "def parse_json\n people = JSON.parse(self.get_response_body)\n end", "def parse_data data\n JSON.parse(data.body)\n end", "def parseJSON(data)\n return JSON.parse data.body.read\nend", "def parse_json(json_)\n from_json_object(::JSON.parse(json_))\n end", "def parse_json(json)\n ::JSON.parse(json, :create_additions => false)\n end", "def parse_body\n JSON.load(body)\n end", "def parse\n JSON.parse(raw)\n rescue RuntimeError\n raise \"cannot read from #{path}\"\n end", "def json_parse(body)\n json = JSON.parse body\n convert_to_obj(json[\"response\"][\"result\"])\n end", "def parse response\n JSON.parse(response, symbolize_names: true)\n end", "def json_parse(json)\n JSON.parse(json, symbolize_names: true)\n end", "def parse_json(body)\n JSON.parse(body, { symbolize_names: true })\n end", "def parse_fetched_json(json_from_url)\n JSON.parse(json_from_url)\n end", "def parse_response(response)\n JSON.parse response if response && !response.blank\n end", "def parse_json(res)\n return if res.blank?\n JSON.parse(res)\n rescue JSON::ParserError\n nil\n end", "def parsed_json\n @parsed_json ||= JSON.parse(open(url).read)\n end", "def load(json)\n require 'json'\n from_json(JSON.parse(json))\n end", "def readable_json(json)\n\t\t JSON.parse(json) rescue nil\n\t\tend", "def parse\n file = File.read(@file)\n @data = JSON.parse(file)\n end", "def parse_json(body)\n JSON.parse(body)\n rescue JSON::ParserError\n {}\n end", "def from_json\n return nil unless okay?\n\n require \"json\"\n\n JSON.parse(body)\n end", "def parse(json)\n res = super(json)\n res[\"response\"] == \"ok\"\n end", "def parse_json(json)\n case json[\"type\"]\n when \"track\"\n {\n title: json[\"name\"],\n artist: json[\"artists\"].map { |i| i[\"name\"] }.join(\", \"),\n album: json[\"album\"][\"name\"],\n thumbnail: json[\"album\"][\"images\"].sort_by { |i| i[\"height\"] }.last[\"url\"],\n length: json[\"duration_ms\"].to_i / 1000.0,\n preview_url: json[\"preview_url\"],\n }\n when \"album\"\n {\n\n }\n end\nend", "def parse_payload(json)\n JSON.parse(json)\n end", "def json_response\n JSON.parse(response.body)\n end", "def json_response\n JSON.parse(response.body)\n end", "def parse_json(json_)\n ::NTable.parse_json(json_)\n end", "def parse_user_response(response)\n\tJSON.parse(response.body)\n\nend", "def json\n JSON.parse(response.body)\n end", "def json\n JSON.parse(response.body)\n end", "def json\n JSON.parse(response.body)\n end", "def json\n JSON.parse(response.body)\n end", "def parse(content)\n @response = []\n if ( content.respond_to?(:body) )\n @response = JSON.parse(content.body)\n else\n @response = JSON.parse(content)\n end\n @complete_items = @response[\"items\"]\n @raw_items = @response[\"items\"].map{|i| i['raw']}\n end", "def json\n @json ||= JSON.parse(response.body, symbolize_names: true)\n end", "def prepare_response(response)\n JSON.parse(response)\n end", "def json_response response\n JSON.parse response.body\n end", "def parse_json( url )\n result = @http.get( url )\n\n begin\n json = JSON.parse( result.body )\n rescue JSON::ParserError => e\n ap \"JSON::ParserError: #{e}\"\n end\n\n return json\nend", "def json(response)\n JSON.parse(response.body)\n end", "def from_json(json)\n deserialize JSON.parse(json)\n end", "def parse_json(res)\n return if res.blank?\n JSON.parse(res)\n rescue JSON::ParserError\n nil\n end", "def from_json\n JSON.parse(self)\n end", "def parse_content(content)\n MultiJson.decode(content.body)\n end", "def parse(response)\n begin\n result = JSON.parse(response.body)\n rescue\n result = false\n end\n \n return result\n end", "def reparsed_from_json\n self.is_a?(String) ? JSON.parse(self) : JSON.parse(self.to_json)\n end", "def parse_response(response)\n # @todo Parse the response based on the @format (\"txt\", \"json\" or \"xml\")\n JSON.parse(response)\n end", "def parse_response(response)\n # @todo Parse the response based on the @format (\"txt\", \"json\" or \"xml\")\n JSON.parse(response)\n end", "def parse_json(stream)\n ::JSON.parse(stream)\n end", "def parse(body)\n MultiJson.load(body, symbolize_keys: true)\n rescue MultiJson::ParseError\n body\n end", "def parse_rendered(rendered)\n JSON.parse(rendered)\n end", "def parse_json str\n JSON.parse str rescue raise ConfigError, \"Invalid JSON\"\n end", "def parse_response(response)\n check_version_and_warn(response.headers[X_KONTENA_VERSION])\n\n if response.headers[CONTENT_TYPE] =~ JSON_REGEX\n parse_json(response)\n else\n response.body\n end\n end", "def parse_user_response(response)\n\n user = JSON.parse(response.body)\n\nend", "def json\n JSON.parse @body\n end", "def parse_request\n unless request.body.read.empty?\n @json = JSON.parse(request.body.read.html_safe)\n end\n end", "def parse_json(json_file)\r\n\t\t\tjfile = File.read(json_file)\r\n\t\t\treturn JSON.parse(jfile)\r\n\t\tend", "def parse(json_str)\n Oj.load(json_str)\n end", "def parse_response(response)\n if response.headers['Content-Type'] == \"application/json\"\n JSON.parse(response.body) rescue nil\n else\n response.body\n end\n end", "def json\n JSON.parse(response.body, symbolize_names: true)\n end", "def parse_json(result)\n @gsearch_result_class = result['GsearchResultClass']\n @unescaped_url = result['unescapedUrl']\n @url = result['url']\n @visible_url = result['visibleUrl']\n @cached_url = result['cacheUrl']\n @title = result['title']\n @title_no_formatting = result['titleNoFormatting']\n @content = result['content']\n end", "def json\n response.parsed_body\n end", "def parsed_body\n @parsed_body ||= JSON.parse(@body, symbolize_names: true)\n end", "def json\n JSON.parse(@body)\n end", "def parseJsonString(jsonString) \n $jsonObjectMain = JSON.parse(jsonString);\n return $jsonObjectMain;\nend", "def parse_response(response)\n case response.content_type\n when JSON_CONTENT_TYPE\n JSON.parse(response.body, quirks_mode: true, symbolize_names: true)\n else\n response.body\n end\n end", "def json\n data = yield\n raise_error = false\n\n begin\n JSON.parse(data)\n rescue JSON::JSONError\n # We retried already, raise the issue and be done\n raise VagrantPlugins::Parallels::Errors::JSONParseError, data: data if raise_error\n\n # Remove garbage before/after json string[GH-204]\n data = data[/({.*}|\\[.*\\])/m]\n\n # Remove all control characters unsupported by JSON [GH-219]\n data.tr!(\"\\u0000-\\u001f\", '')\n\n raise_error = true\n retry\n end\n end", "def parse_json_response(body)\n begin\n response_data = JSON.parse(body)\n response_data = response_data.first if response_data.is_a?(Array)\n rescue => e\n raise Megar::MegaRequestError.new(body.to_i) if body =~ /^[-\\d]+$/\n raise Megar::BadApiResponseError.new(e)\n end\n raise Megar::MegaRequestError.new(response_data) if response_data.is_a?(Fixnum)\n response_data\n end", "def parse_json(res)\n return if res.blank?\n JSON.parse(res)\nrescue JSON::ParserError\n nil\nend", "def parse\n (type, subtype) = parse_object([@name], JSON.parse(@json))\n (subtype || type).to_s.gsub(/\\n\\n$/, \"\\n\")\n end", "def parse(json_file)\r\n CoreLogger.instance.logger.info(\"JsonTools - parse\") { \"Parsing du fichier '#{json_file}'\" }\r\n cars_array = nil\r\n rentals_array = nil\r\n begin\r\n # Check file\r\n check_json_file_path(json_file)\r\n json_data = JSON.parse(File.read(json_file))\r\n # Binding json data to obj\r\n cars_array = json_data_cars_to_array json_data\r\n rentals_array = json_data_rentals_to_array json_data\r\n rescue JSON::ParserError => j\r\n CoreLogger.instance.logger.info(\"JsonTools - parse\") { \"Parsing du fichier '#{json_file}'\" }\r\n raise JsonLoaderTechnicalException.new(\"JsonLoader - parse : Structural problem in json file.\\nJSON::ParserError => #{j.message}\")\r\n rescue JsonLoaderTechnicalException => t\r\n raise t\r\n rescue JsonLoaderFonctionalException => f\r\n raise f\r\n end\r\n return cars_array, rentals_array\r\n end", "def _convertJSON() \n js=\"\"\n \tbegin\n gem \"json\"\n\t\t js = JSON.parse(self.response)\n rescue\n puts \"Error during JSON. #{$!}\"\n end\n\n return js\n\tend", "def parse_json(json)\n return nil if json.nil?\n h = JSON.parse(json)\n data = h['results']['bindings']\n {\n :headings => h['head']['vars'], \n :rows => data.map {|i| i.to_a.map {|x| x[1]['value']}}\n }\nend", "def parse_json(str)\n Yajl::Parser.parse(str)\n end", "def json_response\n @json_response ||= JSON.parse(response.body, symbolize_names: true)\n end", "def json\n @hash ||= ::JSON.parse(data)\n end", "def parse(json_str)\n e = Pointer.new(:object)\n NSJSONSerialization.JSONObjectWithData(\n json_str.dataUsingEncoding(NSUTF8StringEncoding),\n options: 0,\n error: e)\n end", "def parse_response(response)\n object = nil\n\n if response.body and !response.body.empty?\n object = MultiJson.load response.body\n end\n\n object\n end", "def parse\n @parsed\n end", "def parse_json\n @current_json = HTTParty.get(\"http://api.wunderground.com/api/#{@options['apikey']}/conditions/lang:EN/q/#{@options['current_location']}.json\")\n @astronomy_json = HTTParty.get(\"http://api.wunderground.com/api/#{@options['apikey']}/astronomy/lang:EN/q/#{@options['current_location']}.json\")\n @forecast_json = HTTParty.get(\"http://api.wunderground.com/api/#{@options['apikey']}/forecast10day/lang:EN/q/#{@options['forecast_location']}.json\")\n end", "def parse_faraday(response)\n JSON.parse(response)\n end", "def json_parse(json, opts = {})\n ret = {}\n if json.empty?\n return ret\n end\n begin\n ::JSON.parse(json)\n rescue ::JSON::ParserError => e\n return ErrorUsage::Parsing.new(\"JSON parsing error #{e} in file\", opts[:file_path], Opts.new(log_error: false)) if opts[:do_not_raise]\n raise ErrorUsage::Parsing.new(\"JSON parsing error #{e} in file\", opts[:file_path])\n end\n end", "def parse_json(message)\n begin\n parsed_message = ::JSON.parse(message) # parse json message\n rescue => e\n puts 'Error'\n puts e\n rescue JSON::ParserError => e\n return message, e.to_s + \"\\n\"\n end\n [parsed_message, nil]\n end", "def parsed_darksky_response_data\n JSON.parse(darksky_response.body, symbolize_names: true)\n end", "def json_parse (s)\n\n #defined?(ActiveSupport::JSON) ? ActiveSupport::JSON.decode(s) :\n #JSON.parse(s)\n OpenWFE::Json.decode( s )\nend", "def parse(resp)\n resp = resp[0] if resp.is_a?(Array)\n resp = resp.body\n begin\n JSON.parse resp\n rescue JSON::ParserError, TypeError\n nil\n end\n end", "def parse_message(message)\n begin\n JSON.parse(message)\n rescue => e\n raise \"Failed trying to parse response: #{e}\"\n end\n end", "def json(response_body)\n JSON.parse(response_body)\n end", "def parse_results(json:)\n results = []\n return results unless json.present? && json.fetch('items', []).any?\n\n json['items'].each do |item|\n next unless item['id'].present? && item['name'].present?\n\n results << {\n ror: item['id'],\n name: item['name'],\n url: item.fetch('links', []).first,\n domain: org_website(item: item),\n country: org_country(item: item),\n abbreviation: item.fetch('acronyms', []).first,\n types: item.fetch('types', []),\n aliases: item.fetch('aliases', []),\n acronyms: item.fetch('acronyms', []),\n labels: item.fetch('labels', [{}]).map { |lbl| lbl[:label] }.compact\n }\n end\n results\n end", "def parse_body\n return unless body.is_a?(String)\n JSON.parse(body)\n rescue\n # not a valid json body\n nil\n end", "def parse(value)\n data = ::JSON.parse(value)\n Result.success(data)\n rescue ::JSON::ParserError, TypeError\n Result.error.code!(:invalid_json)\n end", "def parse_response(body)\n json = JSON.parse body, symbolize_names: true\n @success = json[:success]\n @failed = json[:failure]\n @canonical_ids = json[:canonical_ids]\n @results = (json[:results] || []).map { |result| gcm_result_for result }\n end", "def json_response\n ActiveSupport::JSON.decode @response.body\n end", "def parse_response(resp)\n return resp unless resp.respond_to?(:body)\n\n JSON.parse(resp.body, symbolize_names: true)\n rescue StandardError => e\n puts \"Error parsing response from #{api_path}\"\n handle_error(e)\n end", "def initialize(response)\n @data = JSON.parse(response)\n end", "def parse_body(str)\n begin\n data = JSON.parse(str)\n if data.key?('initials') and data.key?('score')\n data\n else\n nil\n end\n rescue JSON::ParserError\n nil\n end\nend", "def convert_json(json)\n\n return JSON.parse(json)\n\nend", "def parse_response(response)\n return response unless response.respond_to?(:body)\n\n JSON.parse(response.body, symbolize_names: true)\n rescue StandardError => e\n puts \"Error parsing response from #{api_path}\"\n handle_error(e)\n end" ]
[ "0.82131994", "0.82131994", "0.7791423", "0.7739692", "0.76633525", "0.7576196", "0.75624394", "0.74237925", "0.74210227", "0.7412259", "0.7392964", "0.73841506", "0.733591", "0.72919303", "0.72065187", "0.7084971", "0.7078051", "0.7049218", "0.703197", "0.69876367", "0.69451153", "0.69299227", "0.6918328", "0.690937", "0.69079554", "0.69048554", "0.6896501", "0.6891562", "0.6864742", "0.6864742", "0.68103534", "0.6803805", "0.67901313", "0.67901313", "0.67901313", "0.67901313", "0.676828", "0.6762635", "0.6746889", "0.6736203", "0.67113245", "0.67062366", "0.670571", "0.67045766", "0.669725", "0.66835976", "0.66750056", "0.66576934", "0.66545695", "0.66545695", "0.664528", "0.6644637", "0.6644212", "0.66329366", "0.66282517", "0.6627687", "0.66224253", "0.6617411", "0.6605963", "0.6590939", "0.65891135", "0.6575005", "0.65509313", "0.6549309", "0.6547388", "0.65472096", "0.6543166", "0.65278953", "0.6517979", "0.6515922", "0.65122473", "0.6501208", "0.64982617", "0.6494393", "0.6490412", "0.6446714", "0.64238816", "0.6416217", "0.64142036", "0.6413519", "0.64050394", "0.6390855", "0.639038", "0.6390029", "0.63771564", "0.6369659", "0.6364219", "0.6357111", "0.63434774", "0.63430417", "0.6339808", "0.63309985", "0.6324446", "0.63243973", "0.6321071", "0.6316143", "0.6306129", "0.630406", "0.62901366", "0.6288749" ]
0.7187587
15
Convert the CSV to the equivalent JSON
def parse_csv content, sep CSV.parse(content, :col_sep => sep, :converters => [:numeric], :headers => true, :skip_blanks => true). map{ |row| row.to_hash } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv_to_json(rows)\n\n objs = []\n \n headers = rows[0]\n \n for i in 1..rows.size - 1\n row = rows[i]\n obj = {}\n for j in 0..headers.size - 1\n header = headers[j].to_s\n val = row[j]\n obj[header] = val\n end\n objs << obj \n end\n\n return objs\n\nend", "def csvtojson(path, delimiter)\n\t\tdata = CSV.open(path, 'r', :col_sep => delimiter, :headers => true)\n\t\treturn data.map { |row| row.to_hash }\n\tend", "def convert_to_JSON(name, response)\n output = CSV.parse(response).flatten\n result = { :symbol => name,\n :name => output[0],\n :price => output[1] }\n result.to_json\nend", "def product_CSV_to_JSON(import_file, export_file)\n\n export_data = JSON.pretty_generate(CSV.open(import_file, :quote_char => \"|\", headers: true).map do |row|\n \n ### Creating variables to pass to JSON object ###\n quantity_on_hand = row['quantity_on_hand'] != nil ? string_to_integer(row['quantity_on_hand']) : nil\n price = row['price'] != nil ? currency_to_integer(row['price']) : nil\n cost = row['cost'] != nil ? check_formatting(row['cost']) : nil\n id = string_to_integer(row['item id'])\n description = description_formatting(row['description'])\n\n\n ### Creating modifiers object as a variable ###\n modifiers = modifier_object(row['modifier_1_name'],\n \t\t\t\t\t\t\t row['modifier_1_price'],\n \t\t\t\t\t\t\t row['modifier_2_name'],\n \t\t\t\t\t\t\t row['modifier_2_price'], \n \t\t\t\t\t\t\t row['modifier_3_name'],\n \t\t\t\t\t\t\t row['modifier_3_price'])\t\n\n\n ### Creating each object entered into JSON file ###\n\n \t{ id: id,\n \t description: description,\n price: price,\t\t\t\t\t\t\t\t ## variable passed from ternary operator value\n \t cost: cost,\t\t\t\t\t\t\t\t ## variable passed from ternary operator value\n \t price_type: row['price_type'],\t\t\t\n quantity_on_hand: quantity_on_hand,\t\t ## variable passed from ternary operator value\n modifiers: modifiers\t\t\t\t\t\t ## object passed in dependent on existence of modifiers\n }\n\n end)\n\n File.write(export_file, export_data)\t\t\t\t ## Exports the desired data to the target file specified previously in importerExporter.rb\n\n puts \"Conversion complete, please check the target export file.\"\n\nend", "def csv_to_js \n csv.gsub('\"', '\\\\\"').gsub(\"\\r\\n\", '\\\\n').strip\n end", "def convert_csv(original_csv)\n csv_options = {}\n csv_options[:col_sep] = option(:csv_col_sep) unless option(:csv_col_sep).blank?\n csv_options[:row_sep] = option(:csv_row_sep) unless option(:csv_row_sep).blank?\n csv_options[:quote_char] = option(:csv_quote_char) unless option(:csv_quote_char).blank?\n value_converter = option(:csv_value_proc)\n\n converted_csv = \"#{original_csv}.converting\"\n CSV.open(converted_csv, 'wb', csv_options) do |csv|\n CSV.foreach(original_csv) do |row|\n row = row.map{ |value| value.blank? ? '' : value_converter.call(value) } if value_converter\n csv << row\n end\n end\n FileUtils.remove(original_csv)\n FileUtils.move(converted_csv, original_csv)\n end", "def csv_row_to_map(row_values)\n {\n type: row_values[0],\n key: row_values[1],\n revision: row_values[2],\n last_modified: row_values[3],\n details: JSON.parse(row_values[4])\n }\n end", "def chart_data\n\t# This is a a reference to the file so that it can be read\n\t@data = File.new(\"./public/data/clean_train.csv\", \"r\")\n\n\t# Initializes a CSV representation for Ruby\n\t@csv = CSV.new(@data, :headers => true, :converters => :all)\n\n\t# Parses the CSV to the @accounts_to_create array as JSON object\n\t@csv.to_a.map {|row| ret = row.to_hash; ret.delete(ret.keys.first); ret.slice(\"Overall Qual\",\"Year Built\",\"Overall Cond\", \"SalePrice\",\"Year Remod/Add\", \"Yr Sold\") }.to_json\nend", "def csv_to_array(csv); end", "def to_json\n i = 0\n datas = Array.new\n td = Array.new\n\n ds = @data\n ds.each_with_index do |row,index|\n data = \"{\"\n td.clear\n row.each_pair do |key,value|\n td.push(\"#{format(key)}: #{format(value)}\")\n end\n\n data +=td.join(\",\")\n data += \"}\"\n datas.push(data)\n end\n data = \"[#{datas.join(\",\")}]\"\n data\n end", "def to_json\n if corrupt_asn?\n CSV.parse(content.gsub(\"Price|\", \"\"), headers: true, col_sep: \"|\").\n map { |x| x.to_h }.\n group_by { |x| x[\"PO Number\"] }\n else\n CSV.parse(content, headers: true, col_sep: \"|\").\n map { |x| x.to_h }.\n group_by { |x| x[\"PO Number\"] }\n end\n end", "def parse\n output = File.open out_file, 'w'\n File.open(inp_file).each do |line|\n # CSV parse returns an array of rows - we need only the first\n parsed_line = CSV.parse(line.chomp, col_sep: \"\\t\", liberal_parsing: true).first\n value_map = csv_row_to_map(parsed_line)\n puts value_map[:details]['name'] if verbose\n output.puts value_map.to_json\n end\n output.close\n end", "def parse_json(csv_file)\n data_frame = Daru::DataFrame.from_csv(csv_file)\n data_frame\nend", "def parse(input, output, headers=nil, options={})\n result = Array.new\n\n FasterCSV.new(input, options).each do |row|\n # treat first row as headers if the caller didn't provide them\n unless headers \n headers = row\n next\n end\n \n # build JSON snippet and append it to the result\n snippet = Hash.new\n headers.each_index { |i| snippet[headers[i]] = self.convert(row[i]) }\n result << snippet\n end\n \n output << JSON.pretty_generate(result)\n end", "def get_build_status_json_from_csv_file\n build_status_history = Hash.new\n \n jenkins_job_entries = Array.new\n \n job_index = 0\n CSV.foreach(JOB_STATUS_HISTORY_FILENAME) do |job_status_history_row|\n \n #extract job name\n job_name = job_status_history_row[0]\n \n #create object for Jenkins job\n job_history_entry = Hash.new\n job_history_entry[\"job_name\"] = trim_filename(job_name)\n \n job_status_entries = Array.new\n\n #iterate across status values for the job_status_history_row\n for status_index in 1 ... job_status_history_row.size\n job_status_item = job_status_history_row[status_index]\n job_status_entries << {\"status\" => job_status_item}\n end\n \n job_history_entry.merge!(\"build_status\" => job_status_entries)\n \n jenkins_job_entries << job_history_entry\n \n #increment job index\n job_index = job_index + 1\n end \n \n build_status_history.merge!(\"jenkins_jobs\" => jenkins_job_entries)\nend", "def convert_json_to_csv(parsed_json)\r\n\t\t\traise ParserError, \"The JSON to parse is empty.\" if parsed_json.length <= 0\r\n\r\n\t\t\tcsv_string = CSV.generate do |csv|\r\n\t\t\t\tcsv << parsed_json[0].keys\r\n\t\t \t\tparsed_json.each do |hash|\r\n\t\t \t\t\tcsv << hash.values\r\n\t\t \t\tend\r\n\t\t\tend\r\n\t\t\treturn CSV.parse(csv_string, :encoding => 'bom|utf-8')\r\n\t\tend", "def csv_parsed\n transform_to_hash(@csv_array, @header)\n end", "def parse_csv_file\n csv_data = CSV.read(\"../artists_for_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash\n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n \n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painter_num => painter_row_arr[6]\n }\n painter_object_array.push(painter_object)\n end\n painter_object_array.flatten\nend", "def fileToJSON(filename)\n\tFile.open(filename) do |file|\n\t\tJSON.parse(\"[#{file.readlines.join(\",\")}]\")\n\tend\nend", "def parse_csv\n if self.csv_file.present?\n csv_text = Paperclip.io_adapters.for(self.csv_file).read\n csv = CSV.parse(csv_text, :headers => false)\n\n csv_columns = ['l', 'r', 'units']\n\n csv_to_save = {}\n\n csv.each_with_index do |row, i|\n if i == 0\n csv_to_save['weight'] = row[1].split(':')[1] # string is like Weight:201, only want the number\n csv_to_save['shoe_size'] = row[2].split(':')[1] # string is like Shoe Size:9\n elsif i >= 3\n row.each_with_index do |field, j|\n if j >= 1 and !field.blank?\n csv_to_save[generate_csv_row_key(csv_columns, row, i, j)] = field\n end\n end\n end\n end\n\n # Check to see if any of the fields are nil, then we must have not received the correct file\n is_clean = true\n csv_to_save.each do |key, val|\n if val.nil?\n is_clean = false\n break\n end\n end\n\n CsvFile.create!(csv_to_save) if is_clean\n end\n end", "def grades_to_hash(csv)\n csv.map { |r| r.to_hash }\n end", "def build_payload_from_csv(csv, obj)\n payload = {}\n csv.each do |row|\n payload.store(row.first,get_nested_val(row.last.split('.'),obj))\n end\n return payload\n end", "def translate_csv csv, options\n fields_to_convert = options[:convert]\n fields_to_convert = [fields_to_convert].compact unless fields_to_convert.is_a?(Array)\n\n fields_to_translate = options[:translate]\n fields_to_translate = [fields_to_translate].compact unless fields_to_translate.is_a?(Array)\n to = options[:to] || 'en'\n from_country_code = options[:from]\n from = fields_to_translate.empty? ? nil : language(country(from_country_code))\n translator = self.new(from, to)\n\n items = Morph.from_csv csv, 'Item'\n keys = items.first.class.morph_attributes.select {|x| !x.to_s[/^t_/] }\n\n items.each do |item|\n keys.each do |key|\n translator.translate_value(item, key) if fields_to_translate.include?(key) \n translator.convert_value(item, key) if fields_to_convert.include?(key)\n end\n end\n\n keys = keys.map do |key|\n if fields_to_translate.include?(key) || fields_to_convert.include?(key)\n [\"t_#{key}\", key]\n else\n key\n end\n end.flatten\n\n output = FasterCSV.generate do |csv|\n csv << keys.collect(&:to_s)\n items.each do |item|\n csv << keys.collect { |key| item.respond_to?(key) ? item.send(key) : nil }\n end\n end\n end", "def parse_csv_row(csv_row)\n {\n s_no: csv_row['Sr. No'],\n ticket_no: csv_row['Ticket No'],\n email: csv_row['Email'],\n name: csv_row['Name'],\n new_eth_address: csv_row['New Ethereum Add']\n }\n end", "def format_data(csv_row)\n\t\tklass = @import_type.classify.constantize\n\t\tklass_object = klass.new({original_row: csv_row})\n\t\tformatted_data = klass_object.get_data\n\t\tformatted_data\n\tend", "def to_json\n to_parsed.to_json\n end", "def set_json_data\n csvfile = params[:csvfile]\n return unless csvfile\n # See if the file was uploaded as a multipart file.\n if csvfile.respond_to?(:tempfile)\n params[:json_data] = load(csvfile.tempfile)\n else\n # Load from a local file provided\n params[:json_data] = load(csvfile) if File.file?(csvfile)\n end\n end", "def parse_painter_csv_file\n csv_data = CSV.read(\"db/painter_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash \n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painting_num => painter_row_arr[6],\n :portrait => painter_row_arr[7]\n }\n painter_object_array.push(painter_object) \n end\n painter_object_array.flatten\nend", "def to_json\n Yajl::Encoder.encode(@raw_data)\n end", "def json2csv(file_path, output)\n json = JSON.parse(open(file_path).read())\n json_headers = json.map { |e| labels(e) }.flatten.uniq\n CSV.open(output, 'wb', col_sep: \";\") do |csv|\n csv << json_headers\n json.each do |item|\n csv << json_headers.map do |key|\n csvize(get_value(item, key.split('.')))\n end\n end\n end\nend", "def to_json\n to_raw.to_json\n end", "def to_json (someObject)\n return self.row\n end", "def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end", "def csv_attributes\n [\n \"Nimi\" => \"name\",\n \"Järjestys\" => \"numbering_order\",\n \"Lyhenne\" => \"shorten\",\n \"Ehdokkaita\" => :candidate_count,\n \"Vaalirengas\" => :coalition_name\n ]\n end", "def to_json(filename)\n load if all.empty?\n JSONFromDataCollection.new(self).convert(filename)\n end", "def convert_csv_file_to_object\n begin\n CSV.foreach(@file_name) do |row|\n @csv_object.push(row)\n end \n rescue => exception\n raise FileReadError, exception\n end\n end", "def load_csv()\n f = File.read(INPUT_CSV)\n CSV.parse(f, :headers => true, :col_sep => \",\").map do |row|\n as_hash = row.to_hash\n\n geom = { \n type: \"Point\",\n coordinates: as_hash['coordinates'].split.map { |num| num.to_f }\n }\n\n as_hash.delete('coordinates')\n as_hash['geom'] = geom\n\n if (as_hash['pic_url'].strip.length < 1)\n as_hash.delete('pic_url')\n end\n\n if (as_hash['place_image'].strip.length < 1)\n as_hash.delete('place_image')\n end\n\n as_hash\n end\nend", "def to_json(_ = nil)\n JSON.unparse(fields)\n end", "def meta_to_json(str)\n key_pairs = str.split(',')\n h_kp = {}\n key_pairs.each do | kp |\n a_kp = kp.split('=')\n key = a_kp[0]\n val = a_kp[1]\n h_kp[key] = val\n end\n return h_kp.to_json\n end", "def parse_csv(csv)\n objects = CSV.parse(csv)\n headers = objects.shift\n objects.to_a.map! { |row| Hash[headers.zip(row)] }\n end", "def parse_customers_as_json\n JSON.parse(\n \"[\" + File.readlines(\"./lib/customers.txt\").reject(&:blank?).join(\", \") + \"]\"\n )\nend", "def header_to_json(header)\n @log.info \"[#{Time.now.iso8601}] In header: #{header.to_s} \"\n header = Yajl.load(header)\n\n if header[\"error\"]\n # Raise this as a Ruby exception of the MentosError class.\n # Stop so we don't leave the pipe in an inconsistent state.\n @log.error \"[#{Time.now.iso8601}] Failed to convert header to JSON.\"\n stop header[\"error\"]\n raise MentosError, header[\"error\"]\n else\n header\n end\n end", "def import_data\n @formatted_data = []\n @customers.shift\n @customers.each do |customer|\n customer_data = {\n name: \"#{customer[0]} #{customer[1]}\",\n emails: [\n {\n type: \"\",\n email: customer[2]\n }\n ],\n phones: [\n {\n type: @home_phone_type,\n phone: customer[4]\n },\n {\n type: @work_phone_type,\n phone: customer[5]\n }\n ],\n type: customer[6],\n birthdayAt: customer[3]\n # socials: [\n # {\n # type: \"\",\n # userid: \"\",\n # username: \"\",\n # url: \"\"\n # }\n # ],\n # urls: [\n # {\n # url: \"\"\n # }\n # ],\n # locations: [\n # {\n # type: \"\",\n # address: \"\"\n # }\n # ],\n # locale: \"\",\n # gender: \"\",\n # tags: [\n # ]\n }\n # p @formatted_data << JSON.pretty_generate(customer_data)\n\n @formatted_data << customer_data\n end\n File.open(\"data.json\",\"w\") do |f|\n f.write(@formatted_data.to_json)\n end\n File.open(\"nojsondata.json\",\"w\") do |f|\n f.write(@formatted_data)\n end\n end", "def to_json\n JSON(as_json)\n end", "def user_csv_import(row)\n {\n 'user' => {\n 'content' => {\n 'email' => row[0],\n 'login' => row[1],\n 'firstname' => row[2],\n 'lastname' => row[3]\n },\n 'meta' => {}\n }\n }\n end", "def as_json\n JSON.parse self.to_json\n end", "def to_json\n data.to_json\n end", "def csv_convert(file)\n data_rows = []\n f = File.open(file, 'r')\n f.each_line do |line|\n data_rows.push line.chomp.split(',')\n end\n f.close\n return data_rows\nend", "def load_from_csv(row)\n payload = {\n emails: [{ email: row['email'] }],\n firstname: row['first_name'],\n lastname: row['last_name'],\n external_ids: { controlshift: row['id'] },\n updated_at: row['updated_at']\n }\n UpsertMember.call(payload)\n end", "def create_movies_db(csv)\nmovies_db = []\n\nCSV.foreach(csv, headers: true, header_converters: :symbol) do |row|\nmovie = {\n id: row[:id],\n title: row[:title],\n year: row[:year],\n synopsis: row[:synopsis],\n rating: row[:rating],\n genre: row[:genre],\n studio: row[:studio]\n }\n\n movies_db << movie\n end\n movies_db\n\nend", "def to_json(*a)\n dataset.to_json(*a)\n end", "def to_json\n\t\tto_h.to_json\n\tend", "def to_json\n\t\tto_h.to_json\n\tend", "def as_json\n to_s.as_json\n end", "def collection_to_csv(filepaths, csv_name)\n output_file = CSV.open(csv_name, \"w\")\n header = JSON.parse!(File.read(filepaths[0])).keys\n output_file << header\n\n filepaths.each do |path|\n data = JSON.parse!(File.read(path))\n output_file << data.values\n end\nend", "def to_json\n to_a.to_json\n end", "def parse_csv(csv_name, schema)\n CSV.read(csv_name).map {|row| map_row_to_entity(row, schema) }\nend", "def to_json\n to_h.to_json\n end", "def to_json\n to_h.to_json\n end", "def to_json\n MultiJson.dump(raw)\n end", "def to_json\n MultiJson.dump(raw)\n end", "def create_league(csv)\n league = []\n CSV.foreach(csv, headers: true, header_converters: :symbol) do |row|\n hash = Hash[row]\n league << hash\n end\n league\n\nend", "def to_csv\n @csv ||= format_csv\n end", "def rs_to_json_file(rs, file_object, formatter)\n # default formatter outputs json objects for each row\n formatter = json_formatter unless formatter\n\n # get basic metadata for the recordset\n meta = rs.getMetaData\n cols = meta.getColumnCount.to_i\n\n record_count = 0\n # loop through the records to add them into hash\n while rs.next do\n\n # r is a temporary hash for the row being processed\n r = Hash.new\n\n # add each row to r\n (1..cols).each do |c|\n r[meta.get_column_name(c)] = rs.getObject(c)\n if convert_to_ruby_time_classes.include?(r[meta.get_column_name(c)].class)\n r[meta.get_column_name(c)] = Time.at(r[meta.get_column_name(c)].get_time / 1000).utc\n end\n end # each cols\n\n # formatter handles output of r to file\n formatter.call(file_object, r)\n record_count += 1\n end # while\n return record_count\n end", "def process_csv(file)\n data = CSV.read(file, {encoding: \"UTF-8\", headers: true, header_converters: :symbol, converters: :all})\n hashed_data = data.map { |d| d.to_hash } \n \n puts \"CSV Loaded...\"\n\n return hashed_data\n end", "def import_csv_smart\n \n end", "def parse\n data = CSV.parse(@input_data)\n data.shift # remove header row\n headers = [:player_key, :birth_year, :first_name, :last_name]\n data.map {|row| Hash[ *(headers.zip(row).flatten) ] }\n end", "def to_csv\n map {|row|\n row.map {|f|\n f =~ /[[:punct:]]/ ? '\"' + f.gsub(/\"/, '\"\"') + '\"' : f }.\n join(\",\")}.\n join(\"\\n\")\n end", "def prod_to_hash(csv_name)\n\tprod_array = CSV.read(csv_name)\n\tprod_array.each_with_index do |line, index|\n\t\tnext if line[0] == \"Opportunity ID\" \n\t\tbreak if line[0] == nil\n\t\t@current_opp_list[line[0]] = Opportunity.new(line[@prods_opp], line[@prods_prod], line[@prods_access], line[@prods_status], \"unknown\")\n\t\t\n\tend\n\t\nend", "def row2json (row, query)\n\t\tstr_json = '{\"concept_uuid\":\"\",\"concept_url\":\"\",\"tag_uuid\":\"\",\"tag_label\":\"\",'\n\t\tcounter = 0\n\t\ttabs = row.strip.split(\"\\t\")\n\t\tmatch = false # to have only ONE match\n\n\t\tfor elem in tabs\n\n#\t\t\tmatch = elem.include? query\n\t\t\tnew_elem = elem\n\t\t\tnew_elem = new_elem.gsub(/(#{query})/i, '<b>\\1</b>')\n\t\t\tif match == false && new_elem != elem\n\t\t\t\tstr_json += '\"match\":\"' + new_elem + '\",'\n\t\t\t\tmatch = true\n\t\t\tend\n\n\t\t\tif counter == 0 # this is the entry\n\t\t\t\tstr_json += '\"define_url\":\"'+URL_FETCH_ENTRY + elem.strip()+'\",'\n\t\t\t\tstr_json += '\"concept_url\":\"'+URL_FETCH_ENTRY + elem.strip()+'\",'\n\t\t\t\tstr_json += '\"concept_uuid\":\"'+elem.strip()+'\",'\n\n\t\t\telsif counter == 1 # set of protein names, only the first one is got\n\t\t\t\tprot_names = elem.split (\"(\")\n\t\t\t\tstr_json += '\"concept_label\":\"'+prot_names[0]+'\",'\n\n\t\t\telsif counter == 4 # gene names\n\t\t\t\tgenes = elem.split(\" \")\n\t\t\t\tgene_str = ''\n\t\t\t\tgenes.each { |gene|\n\t\t\t\t\tgene_str += gene +\"; \"\n\t\t\t\t}\n\t\t\t\tgene_str = gene_str.slice(0, gene_str.length-1)\n\n\t\t\t\tstr_json += '\"concept_alt_labels\":\"'+gene_str+'\",'\n\t\t\tend\n\t\t\tcounter += 1\n\n\t\tend # EO for ... in\n\t\tstr_json = str_json.slice(0, str_json.length-1)+'},'\n\tend", "def csv_to_array(csv)\n csv.split(\",\").map(&:strip)\n end", "def csv_to_array(csv)\n csv.split(\",\").map(&:strip)\n end", "def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n end", "def to_json\n to_s.to_json\n end", "def prepare_json\n\t\tjson_header\n\t\tjson_assemble\n\t\t#order_by_line_id(@file)\n\t\t#json_sections\n\t\t#json_order_line_by_section\n\n\tend", "def csv_hash\n {\n vendor: self.vendor_name,\n name: self.name,\n url: self.url,\n enable_proxy: self.access == 2 ? 1 : 0,\n description: self.description,\n more_info: '',\n enable_new: self.new_database.to_i,\n enable_trial: self.trial_database.to_i,\n types: self.resources.pluck(:name).join(';'),\n keywords: '',\n target: 0,\n slug: '',\n best_bets: self.curated.pluck(:name).join(';'),\n subjects: self.subjects.pluck(:name).join(';'),\n desc_pos: 1,\n lib_note: 0,\n enable_popular: self.popular.to_i,\n enable_hidden: 0,\n internal_note: '',\n owner: '',\n resource_icons: '',\n thumbnail: '',\n content_id: self.libguides_id\n }\n end", "def reprocess_csv(file)\n raw = open(file).read.force_encoding(\"UTF-8\")\n csv = CSV.parse(raw, headers: true, header_converters: :symbol)\n csv.each do |row|\n data = row.to_hash.each { |k, v| v = v.to_s.gsub(/[[:space:]]+/, ' ').strip }\n data[:area_id] = data[:area].downcase\n data[:gender] = data[:gender].downcase\n data[:term] = '2013'\n %i(num).each { |i| data.delete i }\n ScraperWiki.save_sqlite([:name, :name, :term], data)\n end\nend", "def as_json\n record\n end", "def update_csv(rows)\n CSV.open($out_path, \"wb\") do |csv| \n\n csv << rows.first.keys\n\n rows.each do |row| \n csv << row.values\n end\n end\nend", "def as_json(*)\n values\n end", "def convert_csv(path, table_name)\n \n # csv file has a header row\n header_row = true\n\n # delimiter for csv file\n delimiter = ','\n\n # variable used to skip header row\n skip_row = true\n\n\n CSV.open(path, 'r', delimiter ) do |row|\n\n row.each_with_index do |col,index|\n if col==nil then \n row[index]='NULL'\n else\n \n col.gsub!(\"'\",\"`\")\n row[index] = \"'#{ col }'\"\n end\n end\n\n # Are we reading the header row of the csv file?\n if header_row\n row.each_with_index do |col,index|\n row[index] = \"\\\"#{ col.gsub(\"'\",'').gsub(/\\s+/,'') }\\\"\"\n end\n header_row = false\n print \"INSERT INTO #{table_name} (#{row.join delimiter }) VALUES\"\n next\n end\n\n # Only skip the first (header) row\n if skip_row == true\n # dont skip further rows\n skip_row = false\n else\n # Print end of line insert delimeter\n puts delimiter\n end\n \n # Print to stdout\n print \"(#{row.join delimiter})\"\n \n end\nend", "def json(data, *)\n build_string(data, \"\\n\", '{', '}') do |key, value, index:, last:, first:|\n json_row(key, value, index: index, first: first, last: last)\n end\n end", "def to_json\n @values.inject({}) { |result, (k, v)| result.update(k => v.to_s) }\n end", "def to_json\n hash = {}\n hash['dataSetName'] = dataset_name\n if column_metadata.nil? == false\n hash['columns'] = {}\n column_metadata.each do |column|\n hash['columns'].merge!(column.to_hash)\n end\n end\n hash['joins'] = []\n joins.each do |join|\n hash['joins'] << join.to_hash\n end\n hash.to_json\n end", "def to_json\n MultiJson.encode(result)\n end", "def to_json\n hash = to_h\n\n hash.each do |k, v|\n hash[k] = self.class.convert(v, k, :to_json)\n end\n\n Oj.dump(hash, omit_nil: true)\n end", "def serialize_to_json\n @data.to_json\n end", "def process\n validate_file_type(@file_name, 'csv')\n convert_csv_file_to_object\n end", "def to_json\n JSON.generate(to_h)\n end", "def to_json\n j = \"{\\n\"\n @data.each_pair {|k,v| j += \"#{k}:'#{v}'\\n\"}\n j += '}'\n end", "def parse_to_load_file(csv)\n csv.each_with_index do |student, index|\n student = {month: csv[index][0] , name: csv[index][1], city: csv[index][2], hobby: csv[index][3]}\n @students << student\n end\nend", "def transform_csv_file(csv_file)\n @logger.info(\"Transforming CSV file\")\n transformed = []\n headers = csv_file.shift\n headers.map!(&method(:prepare_custom_headers))\n\n csv_file.each do |row|\n transformed << Hash[headers.zip row]\n end\n prefix_sf_attribute_names transformed\n end", "def convert_to_geojson\n\t\tgeojson = RGeo::GeoJSON.encode(@features_collection).to_json\n\t\tsave_geojson_to_file(geojson)\n\t\tgeojson\n\tend", "def format_data\n formatted_rows = []\n @data.each do |row|\n values = []\n row.each_with_index do |entry,index|\n # Format/escape individual values for javascript, checking column types, and the ruby value as a failsafe\n safe_val = if @column_types[index] == \"date\" || entry.is_a?(Date)\n # Format a date object as a javascript date\n entry.is_a?(String) ? entry : \"new Date (#{entry.year},#{entry.month - 1},#{entry.day})\"\n elsif @column_types[index] == \"datetime\" || entry.is_a?(Time)\n # Format a Time (datetime) as a javascript date object down to seconds\n entry.is_a?(String) ? entry : \"new Date (#{entry.year},#{entry.month - 1},#{entry.day},#{entry.hour},#{entry.min},#{entry.sec})\"\n else\n # Non date/time values can be JS escaped/formatted safely with # to_json\n entry.to_json\n end\n values << safe_val\n end\n rowstring = \"[#{values.join(\", \")}]\"\n formatted_rows << rowstring\n end\n \"[#{formatted_rows.join(', ')}]\"\n end", "def tojson\n\t\tend", "def parse_csv(decoded_data)\n csv = CSV.parse(decoded_data)\n headers = csv.shift\n csv.to_a.map! { |row| Hash[headers.zip(row)] }\n end", "def to_json arg\n as_json.to_json\n end", "def loadCSV\n csvFile = File.open(\"app/assets/csv/test.csv\", \"r\") #Open file with readpermissions\n if csvFile #if file was successfully opened \n csvRowArray = IO.readlines(csvFile) # Turn each row into an array element\n rowId=1 #0 is the Header Row, 1 is the first dataset.\n recordsArray = Array.new(csvRowArray.size-1)\n while csvRowArray[rowId] do #for each row that exists \n rowEntry = csvRowArray[rowId]\n rowEntry.gsub!(/\"/,'') # Remove all the '\"'s\n wordArr = rowEntry.split(\",\") #Split the array on ','s into a new array \n newRecord = Record.new\n newRecord.REF_DATE = wordArr[0]\n newRecord.GEO = wordArr[1]\n newRecord.DGUID = wordArr[2]\n newRecord.Sex = wordArr[3]\n newRecord.Age_group = wordArr[4]\n newRecord.Student_response = wordArr[5]\n newRecord.UOM = wordArr[6]\n newRecord.UOM_ID = wordArr[7]\n newRecord.SCALAR_FACTOR = wordArr[8]\n newRecord.SCALAR_ID = wordArr[9]\n newRecord.VECTOR = wordArr[10]\n newRecord.COORDINATE = wordArr[11]\n newRecord.VALUE = wordArr[12]\n newRecord.STATUS = wordArr[13]\n newRecord.SYMBOL = wordArr[14]\n newRecord.TERMINATED = wordArr[15]\n newRecord.DECIMALS = wordArr[16]\n newRecord.save\n puts rowId\n rowId = rowId+1 \n end\n return recordsArray\n else #file not opened\n puts \"Unable to open file\" \n return \n end \n end", "def to_json\n\n end", "def convert\n # Create an object to store *all* lines of the *output* CSV\n @csv_out_data = FasterCSV.generate(FCSV_OUT_OPTS){|csv_out| \n\n # Iterate thru each *input* line\n line_in_count = 0\n FasterCSV.foreach(@in_file, FCSV_IN_OPTS) {|line_in|\n line_in_count += 1\n if line_in_count == 1\n self.class.verify_csv_in_headers(line_in.headers)\n # The output CSV shall be indentical to the input CSV but with\n # the COLUMN_ITEM_HANDLE replaced with COLUMN_ITEM_ID.\n @csv_out_headers = line_in.headers.deep_copy\n @index = @csv_out_headers.index(COLUMN_ITEM_HANDLE) # Index of column to be replaced\n @csv_out_headers[@index] = COLUMN_ITEM_ID\t# Replace this column in the header\n end\n\n # Iterate thru each *output* column\n line_out = []\n @csv_out_headers.each_with_index{|col,i|\n csv_out << @csv_out_headers if line_in_count == 1 && i == 0\t# Header line\n\n unless i == @index\n line_out << line_in[col]\n else\t\t\t\t\t\t# Replace with item_id\n h = DSpaceResource.new(line_in[COLUMN_ITEM_HANDLE], :item)\n if h && h.resource_id\n line_out << h.resource_id\t\t\t# The item_id corresponding to handle\n else\n STDERR.puts <<-MSG_HANDLE_LOOKUP.gsub(/^\\t*/, '')\n\t\tERROR: Either the handle '#{line_in[COLUMN_ITEM_HANDLE]}' was not found or it was\n\t\tfound but the corresponding item_id is NULL (eg. perhaps the item was\n\t\tdeleted from the database).\n MSG_HANDLE_LOOKUP\n exit ERROR_HANDLE_LOOKUP\n end\n end\n }\n csv_out << line_out\n }\n }\n end", "def to_json\n FFI_Yajl::Encoder.encode(@data, pretty: true)\n end" ]
[ "0.7817338", "0.7480153", "0.68120503", "0.6781689", "0.6759254", "0.6533264", "0.6384062", "0.6341786", "0.63136166", "0.62600416", "0.62183356", "0.60903275", "0.60695463", "0.6049749", "0.5975226", "0.59274507", "0.5923353", "0.5853881", "0.5850669", "0.5830756", "0.58007944", "0.5799782", "0.57866335", "0.57523924", "0.57216656", "0.5717571", "0.56827694", "0.56822497", "0.56735224", "0.5669366", "0.56611735", "0.565569", "0.5655191", "0.5642369", "0.5638649", "0.5617738", "0.56143415", "0.5610154", "0.5573739", "0.5554517", "0.5553901", "0.5537382", "0.5510526", "0.5500896", "0.5500139", "0.5487682", "0.54715973", "0.5465569", "0.54585755", "0.5436699", "0.5423674", "0.5421806", "0.5421806", "0.53917295", "0.53879416", "0.5379871", "0.53785944", "0.5377139", "0.5377139", "0.53759515", "0.53759515", "0.5375839", "0.5368915", "0.5366464", "0.53552747", "0.5355239", "0.5352248", "0.5339563", "0.5334944", "0.5331153", "0.53307724", "0.53307724", "0.5307295", "0.52923936", "0.5286076", "0.5284588", "0.5269367", "0.5264319", "0.5261217", "0.52585334", "0.5253403", "0.5251836", "0.52507716", "0.5242671", "0.5233936", "0.52318835", "0.52304906", "0.52299494", "0.5222734", "0.52180445", "0.5206032", "0.5199752", "0.5199027", "0.5197373", "0.51885027", "0.5187711", "0.5181611", "0.5179654", "0.51785535", "0.5167963", "0.51625943" ]
0.0
-1
:callseq: add(MyReleaseClass) Add a Release implementation to the list of available Release classes.
def add(release) @list ||= [] @list |= [release] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_on_distro_release(distro, release, name, version=nil)\n distro_releases[[distro, release]] << [name, version]\n end", "def add_class(new_class)\n @classes << new_class\n end", "def add(klass)\n @known_classes << klass\n end", "def add(klass, position = registered_items.size)\n self.instance.add(klass, position)\n end", "def find\n unless @release\n klass = list.detect { |impl| impl.applies_to? }\n @release = klass.new if klass\n end\n @release\n end", "def find\n unless @release\n klass = list.detect { |impl| impl.applies_to? }\n @release = klass.new if klass\n end\n @release\n end", "def add_release( dbh, name )\n\n # Return the release's id value if it is found in the db\n e = get_release(dbh, name )\n return e if e\n\n stmtb = \"INSERT INTO releases(name, description, created_at, updated_at) VALUES('#{name}', 'Package release for #{name}', NOW(), NOW())\"\n rsb = dbh.query( stmtb )\n rsa = dbh.query( \"SELECT id AS count FROM releases WHERE name = '#{name}'\" )\n row = rsa.first\n return row['count']\nend", "def add(pkg)\n packages_by_name[pkg.name] = pkg\n end", "def add_item( klass, name, action )\n fail SyntaxError, \"Undefined class #{klass} found in #{self}\" unless library_defined?(klass)\n library_handler[klass].define(name, action) \n end", "def push(*args)\n check_classes(allowed_class, *args)\n @collection.push(*args)\n end", "def add_release(release_name, package_id, *files)\n page = \"/frs/admin/qrs.php\"\n\n options = (Hash===files.last ? files.pop : {}).rekey\n files = files.flatten\n\n processor = options[:processor]\n release_date = options[:release_date]\n release_changes = options[:release_changes]\n release_notes = options[:release_notes]\n\n release_date ||= Time::now.strftime(\"%Y-%m-%d %H:%M\")\n\n file = files.shift\n puts \"Adding file #{File.basename(file)}...\"\n userfile = open(file, 'rb')\n\n type_id = userfile.path[%r|\\.[^\\./]+$|]\n type_id = FILETYPES[type_id]\n processor_id = PROCESSORS[processor.downcase]\n\n preformatted = '1'\n\n form = {\n \"group_id\" => group_id,\n \"package_id\" => package_id,\n \"release_name\" => release_name,\n \"release_date\" => release_date,\n \"type_id\" => type_id,\n \"processor_id\" => processor_id,\n \"release_notes\" => release_notes,\n \"release_changes\" => release_changes,\n \"preformatted\" => preformatted,\n \"userfile\" => userfile,\n \"submit\" => \"Release File\"\n }\n\n boundary = Array::new(8){ \"%2.2d\" % rand(42) }.join('__')\n boundary = \"multipart/form-data; boundary=___#{ boundary }___\"\n\n html = http_post(page, form, 'content-type' => boundary)\n\n release_id = html[/release_id=\\d+/][/\\d+/].to_i\n puts \"RELEASE ID = #{release_id}\" if $DEBUG\n\n files.each do |file|\n puts \"Adding file #{File.basename(file)}...\"\n add_file(file, release_id, package_id, processor)\n end\n\n release_id\n end", "def add_play(play_class)\n @plays << play_class.new\n end", "def create_release(node)\n if node.attributes['id'] and @releases[node.attributes['id']]\n release = @releases[node.attributes['id']]\n else\n release = @factory.new_release\n @releases[node.attributes['id']] = release\n end\n \n # Read all defined data fields\n release.id = node.attributes['id']\n release.title = node.elements['title'].text if node.elements['title']\n release.asin = node.elements['asin'].text if node.elements['asin']\n release.artist = create_artist(node.elements['artist']) if node.elements['artist']\n \n # Read the types\n node.attributes['type'].split(' ').each {|type|\n release.types << Utils.add_namespace(type)\n } if node.attributes['type']\n \n # Read the text representation information.\n if text_representation = node.elements['text-representation']\n release.text_language = text_representation.attributes['language']\n release.text_script = text_representation.attributes['script']\n end\n \n # Read the track list\n read_track_list(node.elements['track-list'], release.tracks) {|track|\n track.artist = release.artist unless track.artist\n track.releases << release\n }\n \n # Read the release event list\n read_release_event_list(node.elements['release-event-list'], release.release_events)\n \n # Read the disc list\n read_disc_list(node.elements['disc-list'], release.discs)\n \n # Read the relation list\n if node.elements['relation-list']\n node.elements.each('relation-list') {|relation_node|\n read_relation_list(relation_node) {|relation|\n release.add_relation relation\n }\n }\n end\n \n # Read the tag list\n read_tag_list(node.elements['tag-list'], release.tags)\n \n return release\n end", "def add(tag, klass, position = -1)\n @registered_items[tag] ||= []\n arr = self.registered_items[tag]\n position = arr.size if position == -1\n \n arr.insert(position, klass)\n arr.uniq!\n arr.compact!\n end", "def add(tag, klass, position = -1)\n self.instance.add(tag, klass, position)\n end", "def add(klass, dependencies)\n signatures[klass] = dependencies.map { |name| name.to_s.classify.constantize }\n end", "def add(conf, package)\n raise NoMethodError.new \"Not implemented\"\n end", "def add(klass, position = self.registered_items.size)\n self.registered_items.insert(position, klass)\n self.registered_items.uniq!\n self.registered_items.compact!\n end", "def add(klass)\n @models << klass\n end", "def trackClass(clazz)\n @classes.push clazz\n end", "def add(el)\n raise NotImplementedError\n end", "def add_to_classes_or_modules mod\n @classes_or_modules << mod\n end", "def add(event_klass, options)\n # TODO raise if events reach batch size?\n events << event_klass.new(self, options)\n end", "def add(gemspec)\n @specs << gemspec\n end", "def add(component)\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end", "def add(component)\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end", "def add(*gemspecs)\n @specs.push(*gemspecs)\n end", "def add(*args, &block)\n all << new(*args, &block)\n end", "def releases\n Release.branch(self)\n end", "def add klass, name, comment\n if RDoc::Extend == klass then\n ext = RDoc::Extend.new name, comment\n add_extend ext\n elsif RDoc::Include == klass then\n incl = RDoc::Include.new name, comment\n add_include incl\n else\n raise NotImplementedError, \"adding a #{klass} is not implemented\"\n end\n end", "def add_class(name)\n @catalog.add_class(name) unless name == \"\"\n end", "def register(name, klass, description = nil)\n return false unless self.get(name).nil?\n\n self._list << OpenStruct.new({\n name: name.to_sym,\n klass: klass,\n description: description ? description.strip.gsub(\"\\n\", '') : nil\n })\n\n self._list.last\n end", "def refresh_release_tags(releases)\n [true, false].each do |type|\n releases[type.to_s.to_sym].sort.uniq.each do |release|\n release_tags << ReleaseTag.for(self, release, type)\n end\n end\n end", "def add(entry)\n entries << entry\n end", "def release\n @@release[self] ||= if prerelease?\n segments = self.segments\n segments.pop while segments.any? {|s| String === s }\n self.class.new segments.join('.')\n else\n self\n end\n end", "def add(library)\n library = Library.new(library) unless Library === library\n\n #raise TypeError unless Library === library\n #begin\n entry = (@ledger[library.name] ||= [])\n\n case entry\n #when NilClass\n # raise \"serious shit! nil entry in ledger table!\"\n when Array\n entry << library unless entry.include?(library)\n else\n # Library is already active so compare and make sure they are the\n # same, otherwise warn. (Should this ever raise an error?)\n if entry != library # TODO: Is this the right equals comparison?\n warn \"Added library has already been activated.\"\n end\n end\n #rescue Exception => error\n # warn error.message if ENV['debug']\n #end\n\n library\n end", "def add_class(name); end", "def add_class(name); end", "def add(*args); end", "def add(class_name, object)\n @data = get_all()\n \n @data[class_name].push(object.to_hash())\n \n save()\n end", "def add(object)\n @objects << object\n end", "def register(clazz)\n @listers << clazz.instance\n self\n end", "def create_release(attrs = {})\n release = build_release(attrs)\n release.save\n release\n end", "def addIssue(issue)\n @issues << issue if issue\n end", "def add(entry)\n push entry\n return self\n end", "def add_bullet(bullet)\n @bullets << bullet\n end", "def add(paths = '.', **options)\n self.lib.add(paths, options)\n end", "def add(name, options = {}, &block)\n class_name = options.fetch(:class) { constantize(name) }\n instance = Checks.const_get(class_name).new\n\n if block_given?\n checks << instance.tap(&block)\n else\n checks << instance\n end\n end", "def releases\n self.class.releases\n end", "def releases\n self.class.releases\n end", "def add_key_and_product_to_releases(releases, key, product)\n releases.each do |release|\n release[:repo_key] ||= key unless key.nil?\n release[:product] = product\n end\n end", "def release\n fail AlreadyRelease unless prerelease?\n @special = ''\n @metadata = ''\n end", "def add(my_namespace = nil)\n return nil if my_namespace.nil?\n\n @namespaces.add(my_namespace)\n end", "def add(name)\n self.class.add(name, @jira_key)\n end", "def add(params = {})\n @hydra.queue(request('add', params))\n end", "def add(o); addObject o end", "def add_tags\n raise NotImplementedError\n end", "def add_class(klass, opts={})\n DoesKeyValue.log(\"State: Add support for class #{klass.to_s} with opts:#{opts.inspect}\")\n @classes ||= Hash.new\n @classes[klass.to_s] = opts\n end", "def add_revision(revision, keys)\n raise NotImplementedError\n end", "def add(entry)\n @entries[entry.tag] = entry\n end", "def releases\n repo.releases(changelog.changes)\n end", "def _active_add_facade! cls, new_target = nil\n @mutex.synchronize do\n target = new_target || \n (Proc === @target ? @target.call : @target.dup)\n @target_list << cls.new(target)\n end\n end", "def add(hook)\n @hooks << hook\n self\n end", "def add(filename)\n not_implemented('add')\n end", "def release\n end", "def add(repos)\n @list.push(repos).flatten!\n self\n end", "def update(dir, name = nil)\n since = Changelog.last_sha(@releases)\n release = Release.new(name)\n release.update(dir, since)\n add_release(release)\n end", "def method_missing(method, *args)\n add_module(method, *args)\n end", "def addSubscription(subscr)\n subscriptions = Hash.new\n if @subscriptionLists.hasKey(\"subscriptions\")\n subscriptions = @subscriptionLists.getRepositoryObject(\"subscriptions\").getObject\n end\n subscriptions[subscr] = Subscription.new(subscr)\n @subscriptionLists.commitObject(\"subscriptions\", subscriptions, false)\n end", "def add_entry(name)\n Library.create(name: name)\n end", "def add_item(element_class, options = {})\n @items << add_child(@id.next, element_class, options).sym\n end", "def add_class(*names)\n classes = class_names + names\n\n unless classes.empty?\n `#@native.className = #{classes.uniq.join ' '}`\n end\n\n self\n end", "def add_class klass\n @display.print_class klass\n end", "def release\n \n latest_release = Checklist.latest_release\n\n self.minor_rev_number = 0\n self.major_rev_number = latest_release.major_rev_number + 1\n self.released = 1\n self.released_on = Time.now\n self.new_design_self_check_count = self.full_review_self_check_count\n self.new_design_peer_check_count = self.full_review_peer_check_count\n self.bareboard_design_self_check_count = self.partial_review_self_check_count\n self.bareboard_design_peer_check_count = self.partial_review_peer_check_count\n\n if self.save\n return 'Checklist successfully released'\n else\n return 'Checklist release failed - Contact DTG.'\n end\n\n end", "def add(*); end", "def add\n end", "def add\n end", "def install\n # Delayed so that Rake doesn't need to be loaded to run this file.\n extend ::Rake::DSL\n\n # Rename the original release task.\n release_task = ::Rake.application.lookup('release')\n if release_task\n release_actions = release_task.actions.dup\n task 'release:original' => release_task.prerequisites.dup do\n release_actions.map(&:call)\n end\n release_task.clear\n end\n\n # No-op Bundler's release:source_control_push task.\n source_control_push_task = ::Rake.application.lookup('release:source_control_push')\n source_control_push_task.clear if source_control_push_task\n\n # Tag the release.\n task 'release:tag' do\n tag_release!(commit: false)\n end\n\n # Make the new release tasks.\n desc \"Bump, tag, and release #{gem_name}\"\n task 'release' do\n release_gem!(:patch)\n end\n\n desc \"Bump minor, tag, and release #{gem_name}\"\n task 'release:minor' do\n release_gem!(:minor)\n end\n\n desc \"Bump major, tag, and release #{gem_name}\"\n task 'release:major' do\n release_gem!(:major)\n end\n end", "def release(opts = {})\n unique(QTest::Release, project: @id, id: opts[:id])\n end", "def release\n return self unless prerelease?\n rel_parts = parts.dup\n rel_parts.pop while rel_parts.any? { |part| part.alpha? }\n self.class.new(rel_parts.join('.'))\n end", "def add(drink_name, drink_prices)\n # Feature to be added\n end", "def add_release_version( dbh, rlsid, pkgid )\n #puts \"Deleting existing entry: DELETE FROM package_version_releases WHERE release_id = '#{rlsid}' AND package_version_id = '#{pkgid}'\"\n dbh.query( \"DELETE FROM package_version_releases WHERE release_id = '#{rlsid}' AND package_version_id = '#{pkgid}'\" )\n #puts \"Adding new entry with: INSERT INTO package_version_releases(release_id, package_version_id) VALUES( '#{rlsid}', '#{pkgid}')\"\n dbh.query( \"INSERT INTO package_version_releases(release_id, package_version_id) VALUES( '#{rlsid}', '#{pkgid}')\" )\nend", "def add task\n @tasks << task\n end", "def add(adapter)\n adapters << adapter\n end", "def register(klass)\n storage.add(klass) if klass\n end", "def register(name, klass)\n @registry[name] = klass\n end", "def add(classes)\n classes = classes.to_s.split(' ')\n classes.each { |cls| super cls }\n self\n end", "def add(item)\r\n fail \"missing item\" if item.nil?\r\n fail \"item is not active, it cannot be put in your wish list\" unless item.is_active?\r\n\r\n self.items << item\r\n item.add_observer(self)\r\n end", "def github_released\n puts green(\"Release completed\")\n end", "def addlease(name, ip_addr)\n call_rpc_for_target(VN_METHODS[:addlease], name, ip_addr)\n end", "def addItem(item)\n @items << item\n end", "def add_handler_class handler_class\n unless (handler_class.is_a? Class) && (handler_class <= RubyArchive::Handler)\n raise TypeError, \"#{handler_class} is not a RubyArchive::Handler\"\n end\n @@archive_handlers << handler_class\n true\n end", "def releases\n all(QTest::Release, project: @id)\n end", "def add(queue=nil)\n queue = Queue.new(queue) unless Queue.kind_of? Queue\n @handle = queue.java_queue.add(_task)\n self\n end", "def write_release(payload)\n info 'Creating new release on GitHub'\n rel = payload[:data][:github_kit].delete(:release)\n release = github_client.create_release(\n rel[:repository],\n rel[:tag_name],\n :name => rel[:name],\n :target_commitish => rel[:reference],\n :prerelease => rel[:prerelease],\n :body => rel[:body]\n )\n\n api_release_url = release.rels[:self].href\n public_release_url = release.rels[:html].href\n\n info 'New release created on GitHub. Uploading assets.'\n assets = rel[:assets].map do |asset|\n debug \"Uploading release asset - #{asset}\"\n response = github_client.upload_asset(\n api_release_url,\n asset_store.get(asset),\n :name => asset.sub(/^.+?_/, ''),\n :content_type => 'application/octet-stream'\n )\n debug \"Completed release asset upload - #{asset}\"\n Smash.new(\n :url => response[:url],\n :browser_url => response[:browser_download_url],\n :name => response[:name],\n :id => response[:id]\n )\n end\n payload.set(:data, :github_kit, :release, :assets, assets)\n payload.set(:data, :github_kit, :release, :api_url, api_release_url)\n payload.set(:data, :github_kit, :release, :public_url, public_release_url)\n\n true\n end", "def add(*args, &block)\n end", "def execute(iUserID, iTicketID, iBranchName, iReleaseVersion, iReleaseUser, iReleaseComment)\n return executeRedmine(\n SQL_AddReleaseComment.new,\n [ iUserID, iTicketID, iBranchName, iReleaseVersion, iReleaseUser, iReleaseComment ]\n )\n end", "def created_release(version)\n puts green(\"Release #{version} created\")\n end", "def release\n end" ]
[ "0.5785558", "0.5385419", "0.5381441", "0.53082067", "0.51846546", "0.51846546", "0.51443654", "0.5133686", "0.50745404", "0.5027424", "0.50091416", "0.50054693", "0.49902195", "0.49484912", "0.49325216", "0.49302375", "0.49039114", "0.4899441", "0.48849308", "0.48402685", "0.48326278", "0.48259613", "0.48053622", "0.47801775", "0.47750956", "0.47750956", "0.47610065", "0.47537544", "0.47091582", "0.4697461", "0.4686622", "0.46854582", "0.46816882", "0.46814072", "0.4680005", "0.46705568", "0.46404633", "0.46404633", "0.4637462", "0.46370676", "0.4626972", "0.46180287", "0.46101886", "0.4605", "0.45993346", "0.45772424", "0.45769334", "0.45595837", "0.45565718", "0.45565718", "0.45444354", "0.45389175", "0.45374724", "0.45347315", "0.45342535", "0.4528888", "0.4515834", "0.4515392", "0.45006794", "0.44911116", "0.44899455", "0.4489069", "0.44853553", "0.44795692", "0.44769308", "0.447637", "0.44724086", "0.44671175", "0.44670686", "0.4453249", "0.44444126", "0.44426253", "0.44352132", "0.44335255", "0.44331282", "0.44167256", "0.44167256", "0.44164956", "0.44118193", "0.4409408", "0.4399729", "0.43982986", "0.43979913", "0.4397886", "0.43957368", "0.4393569", "0.4385326", "0.43814042", "0.43778026", "0.43742067", "0.43681645", "0.43640122", "0.4362117", "0.4358789", "0.43586367", "0.43575802", "0.43479002", "0.43451416", "0.43448672" ]
0.69061494
1
The list of supported Release implementations
def list @list ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def supported_versions\n raise NotImplementedError\n end", "def supported\n @supported ||= []\n end", "def released_specs\n specs.select { |s| not s.prerelease? }\n end", "def prerelease_specs\n specs.select { |s| s.prerelease? }\n end", "def current_releases(release_type, is_pdc:)\n if is_pdc\n release_type.current.enabled.pdc\n else\n release_type.current.enabled.legacy\n end\n end", "def released_specs\n collect_specs_via(:released_specs)\n end", "def releases\n self.class.releases\n end", "def releases\n self.class.releases\n end", "def prerelease_specs; end", "def supported_pkgs\n {\"rpm\"=>1, \"deb\"=>1}\nend", "def released_specs; end", "def prerelease_specs\n collect_specs_via(:prerelease_specs)\n end", "def native_release_packages\n @attributes[:native_release_packages]\n end", "def platforms; platform_names; end", "def available_versions\n raise \"available_versions API is only available for Artifactory backend.\"\n end", "def available_versions\n Mixlib::Install.available_versions(project, channel)\n end", "def platform_list; ['all','xbox-360']; end", "def supported_platforms\n _platforms = {\n #\n # os: 'linux'\n # platform_family: 'debian'\n 'debian' => %w(jessie/sid 7.6 7.5 7.4 7.2 7.1 7.0 6.0.5),\n 'ubuntu' => %w(14.10 14.04 13.10 13.04 12.04 10.04),\n # platform_family: 'rhel'\n 'amazon' => %w(2014.09 2014.03 2013.09 2012.09),\n 'centos' => %w(7.0.1406 6.6 6.5 6.4 6.3 6.0 5.11 5.10 5.9 5.8),\n 'oracle' => %w(6.5 5.10),\n 'redhat' => %w(7.0 6.5 6.4 6.3 6.2 6.1 6.0 5.10 5.9 5.8 5.7 5.6)\n }\nend", "def map_releases\n releases.sort! {|x,y| x[1] <=> y[1] }\n .map { |release|\n {\n \"version\" => release[1],\n \"status\" => \"active\",\n \"description_html\" => \"<p>#{release[0]}</p>\",\n \"description_markdown\" => release[0],\n \"providers\" => [\n {\"name\" => \"virtualbox\", \"url\" => \"#{RELEASE_URL}#{release[0]}\"}\n ]\n }\n }\n end", "def releases\n all(QTest::Release, project: @id)\n end", "def to_check\n @releases = Release.all\n end", "def supported_platforms\n _platforms = {\n #\n # os: 'linux'\n # platform_family: 'debian'\n 'debian' => %w(jessie/sid\n 8.4 8.2 8.1 8.0\n 7.10 7.9 7.8 7.7 7.6 7.5 7.4 7.2 7.1 7.0\n 6.0.5),\n 'ubuntu' => %w(16.04\n 15.10 15.04\n 14.10 14.04\n 13.10 13.04\n 12.04 10.04),\n # platform_family: 'rhel'\n 'amazon' => %w(2016.03\n 2015.09 2015.03\n 2014.09 2014.03\n 2013.09 2012.09),\n 'centos' => %w(7.2.1511 7.1.1503 7.0.1406\n 6.8 6.7 6.6 6.5 6.4 6.3 6.2 6.1 6.0\n 5.11 5.10 5.9 5.8 5.7 5.6 5.5 5.4 5.3 5.2),\n 'oracle' => %w(7.1 7.0\n 6.6 6.5\n 5.10),\n 'redhat' => %w(7.1 7.0\n 6.6 6.5 6.4 6.3 6.2 6.1 6.0\n 5.10 5.9 5.8 5.7 5.6)\n }\nend", "def supported_archs\n @supported_archs ||= Dir.glob(File.join(__dir__, 'consts', 'sys_nr', '*.rb'))\n .map { |f| File.basename(f, '.rb').to_sym }\n .sort\n end", "def supported_platforms\n latest_extension_version.try(:supported_platforms) || []\n end", "def unsupported_adapters\n []\n end", "def distro_ruby_versions\n case distribution_class\n when :ubuntu\n if is_distribution?(\"<= artful\")\n [\"2.3\"]\n elsif is_distribution?(\"<= eoan\")\n [\"2.5\"]\n elsif is_distribution?(\"<= impish\")\n [\"2.7\"]\n elsif is_distribution?(\"<= kinetic\")\n [\"3.0\"]\n else\n [\"3.1\"]\n end\n when :debian\n if is_distribution?(\"<= jessie\")\n [\"2.1\"]\n elsif is_distribution?(\"<= stretch\")\n [\"2.3\"]\n elsif is_distribution?(\"<= buster\")\n [\"2.5\"]\n elsif is_distribution?(\"<= bullseye\")\n [\"2.7\"]\n else\n [\"3.1\"]\n end\n else\n raise \"Unknown distribution class\"\n end\nend", "def release_variants\n variants\n end", "def default_platform_list\n [\n metadata.platform,\n *ruby_versions,\n *platforms,\n RbConfig::CONFIG['build']\n ]\n end", "def releases\n Release.branch(self)\n end", "def refresh_release_tags(releases)\n [true, false].each do |type|\n releases[type.to_s.to_sym].sort.uniq.each do |release|\n release_tags << ReleaseTag.for(self, release, type)\n end\n end\n end", "def platforms\n [ RUBY_PLATFORM ].tap do |list|\n list.push \"JVM #{java_version}\" if jruby?\n end\n end", "def available_versions\n Mixlib::Install.new(\n product_name: project_name,\n channel: channel_name.to_sym,\n user_agent_headers: ['omnitruck']\n ).available_versions\n rescue Mixlib::Install::Backend::ArtifactsNotFound\n # Return an empty array if no artifacts are found\n []\n end", "def fetch_releases\n require \"open-uri\"\n\n open(RELEASE_URL) { |f| f.read.scan RELEASE_REGEXP }\n end", "def installed_versions; end", "def versions\n self.apar_defect_version_maps.map { |m| m.version }\n end", "def get_all_versions()\n return []\n end", "def supported_features\n\t\treturn self.supported_feature_oids.collect {|oid| FEATURE_NAMES[oid] || oid }\n\tend", "def applicable_architectures\n return @applicable_architectures\n end", "def versions\n registered_versions.keys\n end", "def latest_specs(include_prerelease = T.unsafe(nil)); end", "def detect_jobs\n release_detector.latest_dev_release_job_names\n end", "def detect_jobs\n release_detector.latest_dev_release_job_names\n end", "def operating_systems\n collect\n end", "def get_class_descriptions(klass)\n available_versions.map do |version|\n get_class_description(klass, version)\n end.compact\n end", "def capabilities; end", "def capabilities; end", "def capabilities; end", "def available_platform\n downloads.collect(&:platform).flatten.uniq\n end", "def supports?\n !@version.nil?\n end", "def matching_release?(key, active_release_names)\n supported_releases = key.split(\",\")\n # key - from osdeps file, e.g., \"18.04,bionic,beaver,default\"\n # release - from autoproj's autodetection [\"18.04\", \"18.04.5\", \"lts\", \"bionic\", \"beaver\", \"default\"]\n\n active_release_names.each do |name|\n if name == \"default\"\n next\n end\n\n if supported_releases.include?(name)\n return true\n end\n end\n false\n end", "def release\n warn 'Rhino does not yet support --release' if options[:release]\n 'rhino1_7R2'\n end", "def describe_changes_within_release(enum)\n change = enum.peek\n span \"Product #{change.release} [#{change.level}]\"\n ul.release do\n list_changes_within_release(enum)\n end\n end", "def releases\n repo.releases(changelog.changes)\n end", "def platforms\n return @platforms\n end", "def puppetdb_supported_platforms()\n [\n /debian-7/,\n /debian-8/,\n /el/, # includes cent6,7 and redhat6,7\n /ubuntu-12/,\n /ubuntu-14/,\n ]\n end", "def get_all_versions\n []\n end", "def interfaces\n Vedeu::Interfaces.registered\n end", "def available_versions\n return unless @version\n the_gem_line = gem_remote_list_output.scan(/^#{name}\\s.*$/).first\n the_gem_line.scan /\\d+\\.\\d+\\.\\d+/\n end", "def supported_tags\n [\n # attributes\n :port, :svc_name, :protocol, :severity, :plugin_id, :plugin_name, :plugin_family,\n # simple tags\n :solution, :risk_factor, :description, :plugin_publication_date,\n :metasploit_name, :cvss_vector, :cvss_temporal_vector, :synopsis,\n :exploit_available, :patch_publication_date, :plugin_modification_date,\n :cvss_temporal_score, :cvss_base_score, :plugin_output,\n :plugin_version, :exploitability_ease, :vuln_publication_date,\n :exploit_framework_canvas, :exploit_framework_metasploit,\n :exploit_framework_core,\n # multiple tags\n :bid_entries, :cve_entries, :see_also_entries, :xref_entries,\n # compliance tags\n :cm_actual_value, :cm_audit_file, :cm_check_id, :cm_check_name, :cm_info,\n :cm_output, :cm_policy_value, :cm_reference, :cm_result, :cm_see_also,\n :cm_solution\n ]\n end", "def available_versions\n the_gem_line = gem_remote_list_output.scan(/^#{name}\\s.*$/).first\n the_gem_line.scan /\\d+\\.\\d+\\.\\d+/\n end", "def getlist\r\n result = SUPPORTED_LANG_LIST\r\n end", "def add(release)\n @list ||= []\n @list |= [release]\n end", "def add(release)\n @list ||= []\n @list |= [release]\n end", "def test_method_release\n value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)\n value2_ = value_.release\n assert_equal([1, 9, 2, 0, :final, 0, 0], value2_.values_array)\n value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2)\n value2_ = value_.release\n assert_equal(value_, value2_)\n end", "def stable_gem_versions(http_response)\n http_response.blank? ? [] : http_response.select { |val| val['prerelease'] == false }\n end", "def gems\n provisioner, version = @impl.split('-')\n get_gem_list(provisioner, version)\n end", "def releases()\n releases_including_skipped.delete_if {|r| r =~ /^skip-/}\n end", "def supported_rubies\n @supported_rubies ||= supported_mri_rubies + jrubies\n end", "def release\n warn 'Envjs does not yet support --release' if options[:release]\n 'edge'\n end", "def get_resource_descriptions(resource)\n available_versions.map do |version|\n get_resource_description(resource, version)\n end.compact\n end", "def names\n platforms.map { |m| m.realname }\n end", "def runtime_specific_gems\n []\n end", "def [](release)\n all.find { |r| r.release == release }\n end", "def get_repo_list\n Chef::Log.debug(\n \"Fetching all versions of #{new_resource.module_name} \" +\n \"from #{new_resource.repository}.\",\n )\n latest = powershell_out!(\n <<-EOH,\n $splat = @{\n Name = \"#{new_resource.module_name}\"\n Repository = \"#{new_resource.repository}\"\n AllVersions = $True\n }\n (Find-Module @splat).Version.ForEach({$_.ToString()})\n EOH\n ).stdout.to_s.chomp.split(\"\\r\\n\")\n Chef::Log.debug(\"Available versions: #{latest.join(', ')}\")\n\n return latest.map { |v| Gem::Version.new(v) }\n end", "def platforms\n expose Metadata.platforms(@oauth_token)\n end", "def define_platforms\n [define_centos_5, define_centos_6, define_run_list]\n end", "def supported_languages\n return self.supported_locales.present? ? self.supported_locales : [\"en\"]\n end", "def collection_protocols\n collection_registrations.map { |reg| reg.protocol }.uniq\n end", "def define_platform_classes\n platform_classes = Array.new\n\n platform_classes.push('pe_repo::platform::el_5_x86_64')\n platform_classes.push('pe_repo::platform::el_7_x86_64')\n platform_classes.push('pe_repo::platform::ubuntu_1404_amd64')\n platform_classes.push('pe_repo::platform::debian_7_amd64')\n platform_classes.push('pe_repo::platform::sles_11_x86_64')\n platform_classes.push('pe_repo::platform::solaris_10_i386')\n platform_classes.push('pe_repo::platform::solaris_11_i386')\n\n # Return the array of platform classes\n platform_classes\nend", "def define_platform_classes\n platform_classes = Array.new\n\n platform_classes.push('pe_repo::platform::el_5_x86_64')\n platform_classes.push('pe_repo::platform::el_7_x86_64')\n platform_classes.push('pe_repo::platform::ubuntu_1404_amd64')\n platform_classes.push('pe_repo::platform::debian_7_amd64')\n platform_classes.push('pe_repo::platform::sles_11_x86_64')\n platform_classes.push('pe_repo::platform::solaris_10_i386')\n platform_classes.push('pe_repo::platform::solaris_11_i386')\n\n # Return the array of platform classes\n platform_classes\nend", "def versions\n info[:versions]\n end", "def examples_releases(count = 6)\n all.each_with_object([]).with_index do |(branch, array), index|\n size = [0, 1].include?(index) ? 2 : 1\n array.concat(branch.releases.take(size).map(&:to_s))\n end.first(count)\n end", "def compatible_encoders\n encoders = []\n\n c_platform, c_arch = normalize_platform_arch\n\n framework.encoders.each_module_ranked(\n 'Arch' => c_arch, 'Platform' => c_platform) { |name, mod|\n encoders << [ name, mod ]\n }\n\n return encoders;\n end", "def test_method_release\n value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)\n value2_ = value_.release\n assert_equal([1, 9, 2, 0, 0, 0, 0, 0], value2_.values_array)\n value_ = ::Versionomy.create([1, 9, 2, 5, 2], :rubygems)\n value2_ = value_.release\n assert_equal(value_, value2_)\n 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 printGetSupportedDBs()\n printDebugMessage('printGetSupportedDBs', 'Begin', 1)\n dbInfoList = getDatabaseInfoList()\n dbInfoList.each{ |dbInfo|\n puts dbInfo.elements['name'].text\n }\n printDebugMessage('printGetSupportedDBs', 'End', 1)\n end", "def stable_gem_versions(http_response)\n http_response.blank? ? [] : http_response.select { |val| val['prerelease'] == false }\nend", "def supported_tags\n [\n # attributes\n :name,\n\n # simple tags\n\n # multiple tags\n :fingerprints, :configurations, :tests\n ]\n end", "def available_components\n @available_components ||= {}\n end", "def build_browser_support_field(feature)\n supported = []\n feature[\"stats\"].each do |browser|\n name = get_browser_name(browser.first)\n versions = browser.last.select{ |k, v| v.match(\"y\") }.first\n unless versions.nil?\n versions = \"#{versions.first.split(\"-\").first}\"\n supported << \"#{name} #{versions}\"\n end\n end\n {\n :title => \"Browsers with full support (prefixed & unprefixed)\",\n :value => supported.sort_by!{ |browser| browser.downcase }.join(\"\\n\")\n }\nend", "def tracklist\n releases = @release_group_data[\"releases\"]\n if releases.count > 0\n tracklist = get_best_release(releases)[\"media\"].first[\"tracks\"]\n return get_best_release(releases)[\"media\"].first[\"tracks\"]\n else\n return []\n end\n end", "def get_supported_games\r\n return @supported_game_map\r\n end", "def interfaces_list\n\t\t[\n\t\t\t{\n\t\t\t\t'uri' => '/',\n\t\t\t\t'method' => 'GET',\n\t\t\t\t'purpose' => 'REST API Structure and Capability Discovery'\n\t\t\t}\n\t\t]\n\tend", "def all_platforms\n Msf::Module::Platform.subclasses.collect { |c| c.realname.downcase }\n end", "def display_releases(releases)\n url = \"\"\n releases.each do |release|\n puts \"\\n\\n#{release.name} by #{release.artist} on #{release.label}\\n\"\n release.tracks.each_with_index do |track, index|\n puts \"-#{track.name}\"\n url = track.url\n end\n end\n end", "def supported_algorithms\n {\n None: [],\n SHA: %w{HS256 HS384 HS512},\n RSA: %w{RS256 RS384 RS512},\n ESDSA: %w{ES256 ES384 ES512}\n }\n end", "def platforms\n get(\"project/platforms\")[\"platforms\"]\n end", "def release_properties\n release_detector.latest_dev_release_properties\n end", "def release_properties\n release_detector.latest_dev_release_properties\n end", "def get_last_versions\n @last_release_mods = {}\n helper = PuppetfileHelper.new(@options[:last_release_puppetfile], @options[:root_dir], false)\n helper.modules.each do |mod|\n @last_release_mods[mod[:name]] = mod[:desired_ref]\n end\n end", "def get_last_versions\n @last_release_mods = {}\n helper = PuppetfileHelper.new(@options[:last_release_puppetfile], @options[:root_dir], false)\n helper.modules.each do |mod|\n @last_release_mods[mod[:name]] = mod[:desired_ref]\n end\n end" ]
[ "0.6722644", "0.6671164", "0.6608091", "0.63739526", "0.6267588", "0.6239261", "0.6217117", "0.6217117", "0.61964744", "0.6194433", "0.60981023", "0.6090361", "0.60682416", "0.6067655", "0.60629797", "0.6034048", "0.6011994", "0.597705", "0.5936987", "0.59355795", "0.59255844", "0.58757335", "0.5869568", "0.58685285", "0.5864744", "0.58577913", "0.5848739", "0.584667", "0.583556", "0.58262", "0.5782966", "0.5778451", "0.5765225", "0.57599837", "0.5753106", "0.57476133", "0.57059735", "0.5697811", "0.567781", "0.566052", "0.5645952", "0.5645952", "0.56378174", "0.563257", "0.5625007", "0.5625007", "0.5625007", "0.5611225", "0.5601887", "0.55937606", "0.558568", "0.5569297", "0.55451876", "0.55172676", "0.5504467", "0.5502371", "0.5496859", "0.54600173", "0.5451993", "0.5438501", "0.5432842", "0.53971064", "0.53971064", "0.5387661", "0.5386156", "0.53783613", "0.53623223", "0.534557", "0.5335371", "0.53288627", "0.5328655", "0.532655", "0.532301", "0.53116727", "0.53035843", "0.53020096", "0.52715623", "0.52696157", "0.5266736", "0.5266736", "0.52657795", "0.5259445", "0.5254545", "0.5248321", "0.52479094", "0.524454", "0.5243688", "0.5236586", "0.5231125", "0.5230189", "0.5218286", "0.52109236", "0.521064", "0.52082616", "0.52048266", "0.51963276", "0.51909786", "0.5183568", "0.5183568", "0.5175889", "0.5175889" ]
0.0
-1
Finds and returns the Release instance for this project.
def find unless @release klass = list.detect { |impl| impl.applies_to? } @release = klass.new if klass end @release end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_release(release_id)\n query_and_build \"releases/#{release_id}\"\n end", "def get_release(project)\n info = get_github_api(project, \"releases\")\n release = 'master'\n if info.length > 0\n unpublishedDraftLimit = 5\n x = 0\n release = info[x]['tag_name']\n # Unpublished drafts need to be skipped.\n while (unpublishedDraftLimit > x) && info[x]['draft']\n release = info[x]['tag_name']\n x += 1\n end\n end\n release\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def release\n _init\n\n @release = Release.find_by_name(params[:release]) if params[:release]\n @release = Release.actived.first unless @release\n\n render :template => 'sprint/release', :layout => 'release'\n end", "def [](release)\n all.find { |r| r.release == release }\n end", "def set_release\n @release = Admin::Release.find(params[:id])\n end", "def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end", "def get_release( dbh, name )\n\tstmta = \"SELECT id, COUNT(id) AS count FROM releases WHERE name = '#{name}'\"\n\trsa = dbh.query( stmta )\n\tif rsa.any?\n\t rsa.each do |release|\n\t c = release['count']\n\t return release['id'] unless c == 0\n\t end\n\tend\n\treturn nil\nend", "def session_release\n session[:release_id] ? PfitmapRelease.find_by_id(session[:release_id]) : PfitmapRelease.find_current_release\n end", "def first_release\n self.releases.where(status: STATUS[:completed]).first\n end", "def latest\n releases.first\n end", "def release_info\n @release_info ||= @connection.get(RELEASE_INFO_PATH)['release']\n end", "def find\n self.class.find(self.version_key)\n end", "def release\n fetch(:@release) { |grid_string| grid_string[7,10] }\n end", "def releases\n self.class.releases\n end", "def releases\n self.class.releases\n end", "def create_release(node)\n if node.attributes['id'] and @releases[node.attributes['id']]\n release = @releases[node.attributes['id']]\n else\n release = @factory.new_release\n @releases[node.attributes['id']] = release\n end\n \n # Read all defined data fields\n release.id = node.attributes['id']\n release.title = node.elements['title'].text if node.elements['title']\n release.asin = node.elements['asin'].text if node.elements['asin']\n release.artist = create_artist(node.elements['artist']) if node.elements['artist']\n \n # Read the types\n node.attributes['type'].split(' ').each {|type|\n release.types << Utils.add_namespace(type)\n } if node.attributes['type']\n \n # Read the text representation information.\n if text_representation = node.elements['text-representation']\n release.text_language = text_representation.attributes['language']\n release.text_script = text_representation.attributes['script']\n end\n \n # Read the track list\n read_track_list(node.elements['track-list'], release.tracks) {|track|\n track.artist = release.artist unless track.artist\n track.releases << release\n }\n \n # Read the release event list\n read_release_event_list(node.elements['release-event-list'], release.release_events)\n \n # Read the disc list\n read_disc_list(node.elements['disc-list'], release.discs)\n \n # Read the relation list\n if node.elements['relation-list']\n node.elements.each('relation-list') {|relation_node|\n read_relation_list(relation_node) {|relation|\n release.add_relation relation\n }\n }\n end\n \n # Read the tag list\n read_tag_list(node.elements['tag-list'], release.tags)\n \n return release\n end", "def set_press_release\n @press_release = PressRelease.find(params[:id])\n end", "def campaign_release(id)\n rest.get(:releasesms, id: id)['data']\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 release(opts = {})\n unique(QTest::Release, project: @id, id: opts[:id])\n end", "def show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def release\n variables[:release]\n end", "def find_project\n identifier = params[:project_id]\n scope = Project.active.has_module(:repository)\n project = scope.find_by_identifier(identifier.downcase)\n raise ActiveRecord::RecordNotFound unless project\n return project\n end", "def releases\n all(QTest::Release, project: @id)\n end", "def show\n @release = Release.find(params[:id])\n \n # send to release page if not archived\n redirect_to(:controller => 'releases', :action => 'show', :id => @release.id) and return if !@release.archived\n \n # populate release fixes from mantis\n if @release.mantis_project_version_id\n @issues = Issue.fixed(@release.mantis_project_id, @release.mantis_project_version_name)\n end\n @version_released = @release.released?\n @version_release_date = Time.at(@release.release_date).strftime(\"%Y-%m-%d\") if @version_released && @release.release_date\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @release }\n end\n end", "def to_release\n user.releases.find_or_initialize_by(discogs_release_id: discogs_release_id).tap do |release|\n release.catalog_number = catalog_number\n release.label = label\n release.artist = artist\n release.name = name\n release.year = year\n release.genre = genre\n release.format = format\n release.format_quantity = format_quantity\n release.discogs_community_have = discogs_community_have\n release.discogs_community_want = discogs_community_want\n release.discogs_lowest_price = discogs_lowest_price\n release.discogs_number_for_sale = discogs_number_for_sale\n release.discogs_cover_thumb_url = discogs_cover_thumb_url\n release.discogs_api_resource_url = discogs_api_resource_url\n release.discogs_uri = discogs_uri\n end\n end", "def show\n @release_reason = ReleaseReason.find(params[:id])\n end", "def set_press_release\n @press_release = PressRelease.friendly.find(params[:id])\n end", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def set_object_release\n @object_release = ObjectRelease.find(params[:id])\n end", "def releases\n Release.branch(self)\n end", "def find_project\n identifier = get_project_identifier\n project = Project.find_by_identifier(identifier.downcase)\n raise ActiveRecord::RecordNotFound, \"No project found with identifier '#{identifier}'\" if project.nil?\n return project\n end", "def release\n @release ||= ENV[\"RELEASE\"] || \"1\"\n end", "def get_master_release(master_release_id)\n query_and_build \"masters/#{master_release_id}\"\n end", "def get_released_version(date)\n @minor_versions.each do |pv|\n if pv.release_date == date then\n return pv\n end\n end\n return nil\n end", "def release\n @@release[self] ||= if prerelease?\n segments = self.segments\n segments.pop while segments.any? {|s| String === s }\n self.class.new segments.join('.')\n else\n self\n end\n end", "def get_last_release\n r = api_get(\"/releases\")\n\n return r[0]['tag_name']\nend", "def set_release_item\n @release_item = ReleaseItem.find(params[:id])\n end", "def find_stemcell_release(version, product_name)\n version = OpsManager::Semver.new(version)\n releases = stemcell_releases(product_name).collect do |r|\n {\n release_id: r['id'],\n version: OpsManager::Semver.new(r['version']),\n }\n end\n releases.keep_if{ |r| r[:version].major == version.major }\n exact_version = releases.select {|r| r[:version] == version }\n return exact_version.first[:release_id] unless exact_version.empty?\n releases_sorted_by_version = releases.sort_by{ |r| r[:version].minor }.reverse\n return releases_sorted_by_version.first[:release_id] unless releases_sorted_by_version.empty?\n end", "def get_latest_release_tag\n\trooturl = get_svn_repo_root()\n\treleaseurl = rooturl + \"/#{SVN_RELEASES_DIR}\"\n\t\n\ttags = svn_ls( releaseurl ).grep( RELEASE_VERSION_PATTERN ).sort_by do |tag|\n\t\ttag[RELEASE_VERSION_PATTERN].split('.').collect {|i| Integer(i) }\n\tend\n\treturn nil if tags.empty?\n\n\treturn releaseurl + '/' + tags.last\nend", "def releases_in_group(release_group_id, options = {})\n get \"release_groups/#{release_group_id}/releases\", options\n end", "def to_check\n @releases = Release.all\n end", "def release?(release_name, package_id)\n id = @release_ids[[release_name,package_id]]\n return id if id\n\n release_id = nil\n\n page = \"/frs/admin/showreleases.php\"\n\n form = {\n \"package_id\" => package_id,\n \"group_id\" => group_id\n }\n scrape = http_post( page, form )\n\n restr = ''\n restr << Regexp.escape( %{\"editrelease.php?group_id=#{group_id}} )\n restr << Regexp.escape( %{&amp;package_id=#{package_id}} )\n restr << Regexp.escape( %{&amp;release_id=} )\n restr << '(\\d+)'\n restr << Regexp.escape( %{\">#{release_name}} )\n re = Regexp.new( restr )\n\n md = re.match( scrape )\n if md\n release_id = md[1]\n end\n\n @release_ids[[release_name,package_id]] = release_id\n end", "def create_release(attrs = {})\n release = build_release(attrs)\n release.save\n release\n end", "def set_release_main\n @release_main = ReleaseMain.find(params[:id])\n end", "def release( release_attributes= {},option={})\n unless option[:page_only]\n template_release = self.template_releases.build\n template_release.name = \"just a test\"\n template_release.save!\n end\n self.reload # release_id shoulb be template_release.id\n @lg = PageGenerator.releaser( self )\n @lg.release \n self.current_template_release \n end", "def lastest_package_release\n self.packages.where(:latest => 1).order(:release_date => :desc).first\n end", "def release_date\n release_dates.first[:date] rescue nil\n end", "def determine(distro, release)\n return distro_releases[[distro, release]] if distro_releases.has_key? [distro, release]\n return distros[distro] if distros.has_key? distro\n default\n end", "def set_release_status\n @release_status = ReleaseStatus.find(params[:id])\n end", "def find_project\n identifier = get_identifier\n project = Project.find_by_identifier(identifier.downcase)\n fail(\n ActiveRecord::RecordNotFound,\n \"No project found with identifier '#{identifier}'\"\n ) if project.nil?\n project\n end", "def get_softwarerepository_release_by_moid(moid, opts = {})\n data, _status_code, _headers = get_softwarerepository_release_by_moid_with_http_info(moid, opts)\n data\n end", "def prerelease_tag\n prerelease_regex = if commits_since_tag > 0\n /^\\d+\\.\\d+\\.\\d+(?:-|\\.)([0-9A-Za-z.-]+)-\\d+-g[0-9a-f]+$/\n else\n /^\\d+\\.\\d+\\.\\d+(?:-|\\.)([0-9A-Za-z.-]+)$/\n end\n match = prerelease_regex.match(git_describe)\n match ? match[1] : nil\n end", "def find_object(project, id)\n find_milestone_with_finder(project, id: id)\n end", "def latest_version\n (Release.where(:manifest_id => manifest_id).max(:version) || 0)\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 next_release\n return @next_release if @next_release\n list = `git branch -a | grep origin\\/RB-`\n list_numbers = []\n list.each do |item|\n item =~ /RB-([0-9].*)/\n list_numbers << $1.to_i\n end\n @next_release = list_numbers.sort.last.to_i + 1\nend", "def release\n warn 'Rhino does not yet support --release' if options[:release]\n 'rhino1_7R2'\n end", "def get_project\n @project ||= Project.find(params[:project_id])\n end", "def index\n @releases = Release.all\n end", "def index\n @releases = Release.all\n end", "def info\n release = args.shift.downcase.strip rescue nil\n raise(CommandFailed, \"Specify a release\") unless release\n\n release = heroku.release(app, release)\n\n display \"=== Release #{release['name']}\"\n display_info(\"Change\", release[\"descr\"])\n display_info(\"By\", release[\"user\"])\n display_info(\"When\", time_ago(Time.now.to_i - Time.parse(release[\"created_at\"]).to_i))\n display_info(\"Addons\", release[\"addons\"].join(\", \"))\n display_vars(release[\"env\"])\n end", "def fetch_releases\n require \"open-uri\"\n\n open(RELEASE_URL) { |f| f.read.scan RELEASE_REGEXP }\n end", "def published_revision\n self.revision_model.find(:first, :conditions => { klass + '_id' => self.id, :number => self.published_revision_number })\n end", "def add_release( dbh, name )\n\n # Return the release's id value if it is found in the db\n e = get_release(dbh, name )\n return e if e\n\n stmtb = \"INSERT INTO releases(name, description, created_at, updated_at) VALUES('#{name}', 'Package release for #{name}', NOW(), NOW())\"\n rsb = dbh.query( stmtb )\n rsa = dbh.query( \"SELECT id AS count FROM releases WHERE name = '#{name}'\" )\n row = rsa.first\n return row['count']\nend", "def find_by(attribute, value)\n if @@project_cache.has_key?(value)\n project = @@project_cache[value]\n else\n project_id = lookup_id_for(attribute, value)\n project = get_project(project_id)\n end\n return project\n end", "def find_repo_by_project_name(project_name)\n Repo.all.find_by(project_name: project_name)\n end", "def data\n return @data if @data\n\n remote = fetch(ref: RELEASES_REF, path: RELEASES_PATH)\n @sha = remote.sha\n\n content = parse(remote.content)\n raise self::ValidationError unless valid?(content)\n\n unsorted = content.filter_map do |release|\n version_string = release['version']\n release_date = release['date']\n\n next if version_string < self::ENABLED_MIN\n\n if version_string < self::SEMVER_MIN\n version_fix = version_string.gsub(/-p(\\d+)/, '.\\1')\n version_comparable = Gem::Version.new(version_fix)\n else\n version_comparable = Gem::Version.new(version_string)\n end\n\n Release.new(version_string, version_comparable, release_date)\n end\n\n @data ||= unsorted.sort_by(&:comparable).reverse\n end", "def project\n self.projects.first unless projects.empty?\n end", "def find_by_id(id)\n hash = Backlogjp.base._command \"getProject\", id\n\n Project.new(hash) unless hash.empty?\n end", "def revision\n @revision ||= begin\n unless info(:latest_available_revision)\n self.class.find(info(:id)).revision\n else\n Data::SongRevision.new(info(:latest_available_revision))\n end\n end\n end", "def find_published\n return self if PidUtils.published?(pid)\n self.class.find(PidUtils.to_published(pid))\n end", "def find_current_release_mr(source_branch, target_branch)\n Gitlab.merge_requests(@project_name, state: :opened).find do |mr|\n mr.source_branch == source_branch && mr.target_branch == target_branch\n end\n end", "def release\n return self unless prerelease?\n rel_parts = parts.dup\n rel_parts.pop while rel_parts.any? { |part| part.alpha? }\n self.class.new(rel_parts.join('.'))\n end", "def next_release_number\n latest_samson_number = project.releases.last&.number || \"0\"\n next_samson_number = next_number(latest_samson_number)\n return next_samson_number if commit.blank?\n\n return next_samson_number unless fuzzy_tag = project.repository.fuzzy_tag_from_ref(commit)&.split('-', 2)\n return next_samson_number unless latest_github_number = fuzzy_tag.first[VERSION_REGEX, 1]\n next_github_number = (fuzzy_tag.size == 1 ? latest_github_number : next_number(latest_github_number))\n\n if Gem::Version.new(next_samson_number) > Gem::Version.new(next_github_number)\n next_samson_number\n else\n next_github_number\n end\n end", "def find_project(project_id)\n # check if we already fetched the project\n @projects.each do |proj|\n return proj if proj.id == project_id\n end\n # project not found, fetch it\n @projects << PivotalTracker::Project.find(project_id)\n @projects.last\n end", "def index\n @press_releases = PressRelease.all\n end", "def version(revision_number)\n self.versions.find_by_revision_number(revision_number)\n end", "def latest_tag\n releases_url = 'https://github.com/david942j/one_gadget/releases/latest'\n @latest_tag ||= url_request(releases_url).split('/').last\n end", "def rel_version_select(project, version)\n project_find(project)\n release = @project.all('a[class=released-link]', text: \"#{version}\").first\n release.click\n end", "def release_hashref\n @release_hashref ||= `git rev-parse HEAD`.chomp\n end", "def release_date\n @ole.ReleaseDate\n end", "def resource\n @project ||= Project.find_by_slug!(params[:id])\n end", "def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend", "def set_release_reason\n @release_reason = ReleaseReason.find(params[:id])\n end", "def get_revision(rev_num)\n if @current_revision.revision_identifier.to_s == rev_num\n return @current_revision\n end\n @revision_history.each do |revision|\n if revision.revision_identifier.to_s == rev_num\n return revision\n end\n end\n # revision with the specified revision number does not exist,\n # so raise error\n raise Repository::RevisionDoesNotExist\n end", "def resolve_instance(name=nil)\n\t\t\tif name\n\t\t\t\t@mgr.setparam(\"name\", name)\n\t\t\t\t@mgr.normalize_name_parameters()\n\t\t\tend\n\t\t\tname, dbname = @mgr.getparams(\"name\", \"dbname\")\n\t\t\tdbi = @resource.db_instance(dbname)\n\t\t\tbegin\n\t\t\t\t# Innocuous call that will raise an exception if it doesn't exist\n\t\t\t\tdbi.db_instance_arn\n\t\t\trescue\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn dbi\n\t\tend", "def project(id)\n self.projects(\"all\").detect { |p| p.id == id }\n end", "def project(name)\n @projects.find { |p| p.name == name }\n end", "def page(path, version = nil, global_match = false)\n ::Gollum::Page.find(self, path, version.nil? ? @ref : version, false, global_match)\n end", "def find_draft\n return self if draft?\n self.class.find(PidUtils.to_draft(pid))\n end", "def revision\n revisions.first\n end", "def get(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\" , arguments.params)\n end", "def index\n @object_releases = ObjectRelease.all\n end", "def release\n configs = store(:get, 'configs').to_s.gsub(\"\\n\", \" \")\n \n # TODO: if error, user need to deploy code first (nothing to deploy) => use a special exit code \n # when code is not pushed or only deploy if app has a correct build\n version = @api.release(@name, configs).to_s.chomp.gsub(\"\\n\", \" \")\n backend = @api.run(@name, :web, version).to_s.chomp.gsub(\"\\n\", \" \")\n @api.route @name, backend\n return version\n end" ]
[ "0.7268631", "0.68467784", "0.6148033", "0.6148033", "0.6148033", "0.6148033", "0.61349833", "0.6049865", "0.60407513", "0.60337824", "0.6030666", "0.59262", "0.5924428", "0.5877056", "0.5791091", "0.5622114", "0.5621887", "0.5546335", "0.5546335", "0.5526048", "0.5518329", "0.5507188", "0.5502263", "0.5498942", "0.5487972", "0.5477619", "0.544853", "0.54397684", "0.54278386", "0.54225016", "0.53808993", "0.53641444", "0.535315", "0.53523", "0.5279347", "0.5274672", "0.5268636", "0.52056205", "0.52026933", "0.5198628", "0.51826465", "0.5178663", "0.5154843", "0.51336443", "0.5129067", "0.5116417", "0.51150185", "0.50960815", "0.509222", "0.50884366", "0.50875586", "0.50548446", "0.50455207", "0.5032025", "0.5018715", "0.501096", "0.49942127", "0.4974992", "0.496072", "0.49555734", "0.49477708", "0.49423712", "0.49362263", "0.4932737", "0.4932737", "0.4922934", "0.490938", "0.49083674", "0.49046364", "0.49004114", "0.4894632", "0.4894156", "0.48917615", "0.48890546", "0.48855108", "0.4878322", "0.48734835", "0.4839121", "0.48374602", "0.48082075", "0.48024017", "0.47806945", "0.47775075", "0.475627", "0.47481513", "0.4743209", "0.47324157", "0.47264078", "0.47255477", "0.47247055", "0.47147778", "0.47081277", "0.47075003", "0.47052583", "0.47017813", "0.46858412", "0.46831995", "0.46815735", "0.4676824" ]
0.7010312
2
:callseq: make() Make a release.
def make(options) @this_version = extract_version check with_release_candidate_version do |release_candidate_buildfile| args = '-S', 'rake', '--rakefile', release_candidate_buildfile if options args += options.split(' ') else args << 'clean' << 'build' << 'DEBUG=no' end ruby *args end tag_release resolve_tag update_version_to_next if this_version != resolve_next_version(this_version) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def release\n end", "def release\n end", "def create_release(attrs = {})\n release = build_release(attrs)\n release.save\n release\n end", "def release\n action('release')\n end", "def release\n end", "def release\n fail AlreadyRelease unless prerelease?\n @special = ''\n @metadata = ''\n end", "def release(number)\n \n end", "def make_prerelease\n fail AlreadyPreRelease if prerelease?\n @special = PRE_RELEASE.first\n end", "def make\n @this_version = extract_version\n check\n with_release_candidate_version do |release_candidate_buildfile|\n args = []\n args << 'buildr' << '--buildfile' << release_candidate_buildfile\n args << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?\n args << 'clean' << 'upload' << 'DEBUG=no'\n sh *args\n end\n tag_release resolve_tag\n update_version_to_next if this_version != resolve_next_version(this_version)\n end", "def release!\n welcome\n return if uncommitted_changes?\n\n # Check if everything is up to date with git remotes\n if branch_behind_remote?\n if want_to_pull? \n cmd \"git pull\"\n cmd \"git pull --tags\"\n else\n inform \"Please pull the changes, then run `rake release` again\"\n return\n end\n end\n\n # Gather user input about the release\n get_release_message\n get_release_version_type\n\n # Confirm and execute\n if you_sure?\n update_dist\n update_bower_file\n cmd \"git add .\"\n cmd \"git commit -am '#{@commit_message}'\"\n cmd \"git tag -a v#{@next_version} -m '#{@commit_message}'\"\n cmd \"git push\"\n cmd \"git push --tags\"\n publish! # to github pages\n\n robot_says \"All done :) Thanks for contributing!\"\n else\n inform \"Release cancelled\"\n end\n end", "def release\n variables[:release]\n end", "def release\n git :archive, fetch(:branch), fetch(:project_root), '| tar -x -C', release_path, \"--strip=#{fetch(:project_root).count('/')+1}\"\n end", "def release(resource); end", "def release( release_attributes= {},option={})\n unless option[:page_only]\n template_release = self.template_releases.build\n template_release.name = \"just a test\"\n template_release.save!\n end\n self.reload # release_id shoulb be template_release.id\n @lg = PageGenerator.releaser( self )\n @lg.release \n self.current_template_release \n end", "def make; end", "def release(opts = {})\n unique(QTest::Release, project: @id, id: opts[:id])\n end", "def release(c, ci, de, cr, cv)\n if state(COMMITMENT, c, ci, de, cr) and active(c, ci, cv)\n apply([[RELEASED, c, ci, cv]], [])\n end\nend", "def install\n # Delayed so that Rake doesn't need to be loaded to run this file.\n extend ::Rake::DSL\n\n # Rename the original release task.\n release_task = ::Rake.application.lookup('release')\n if release_task\n release_actions = release_task.actions.dup\n task 'release:original' => release_task.prerequisites.dup do\n release_actions.map(&:call)\n end\n release_task.clear\n end\n\n # No-op Bundler's release:source_control_push task.\n source_control_push_task = ::Rake.application.lookup('release:source_control_push')\n source_control_push_task.clear if source_control_push_task\n\n # Tag the release.\n task 'release:tag' do\n tag_release!(commit: false)\n end\n\n # Make the new release tasks.\n desc \"Bump, tag, and release #{gem_name}\"\n task 'release' do\n release_gem!(:patch)\n end\n\n desc \"Bump minor, tag, and release #{gem_name}\"\n task 'release:minor' do\n release_gem!(:minor)\n end\n\n desc \"Bump major, tag, and release #{gem_name}\"\n task 'release:major' do\n release_gem!(:major)\n end\n end", "def creating_github_release\n github = \"Generating Github release\"\n puts bold(github)\n puts github.length.times.map {\"=\"}.join\n puts\n end", "def release\n context.execute \"[ $(ls -A #{release_path} | wc -l) -gt 0 ] || ( cd #{release_path} && tar -xzf #{repo_path}/#{release_timestamp}.tar.gz )\"\n end", "def release\n _init\n\n @release = Release.find_by_name(params[:release]) if params[:release]\n @release = Release.actived.first unless @release\n\n render :template => 'sprint/release', :layout => 'release'\n end", "def release\n warn 'Rhino does not yet support --release' if options[:release]\n 'rhino1_7R2'\n end", "def create_release(build)\n release = Kubernetes::Release.create_release(\n deploy_id: @job.deploy.id,\n deploy_groups: deploy_group_configs,\n build_id: build.try(:id),\n git_sha: @job.commit,\n git_ref: @reference,\n user: @job.user,\n project: @job.project\n )\n\n unless release.persisted?\n raise Samson::Hooks::UserError, \"Failed to create release: #{release.errors.full_messages.inspect}\"\n end\n\n @output.puts(\"Created release #{release.id}\\nConfig: #{deploy_group_configs.to_json}\")\n release\n end", "def release\n return self unless prerelease?\n rel_parts = parts.dup\n rel_parts.pop while rel_parts.any? { |part| part.alpha? }\n self.class.new(rel_parts.join('.'))\n end", "def created_release(version)\n puts green(\"Release #{version} created\")\n end", "def release(n = 1)\n raise NotImplementedError\n end", "def release_task\n puts\n puts \"Release successful.\"\n end", "def release(options = {})\n current_claimant = claimant\n with_hooks(:release, current_claimant, options) do\n log(:release)\n set_claimant(nil)\n end\n end", "def create_release(node)\n if node.attributes['id'] and @releases[node.attributes['id']]\n release = @releases[node.attributes['id']]\n else\n release = @factory.new_release\n @releases[node.attributes['id']] = release\n end\n \n # Read all defined data fields\n release.id = node.attributes['id']\n release.title = node.elements['title'].text if node.elements['title']\n release.asin = node.elements['asin'].text if node.elements['asin']\n release.artist = create_artist(node.elements['artist']) if node.elements['artist']\n \n # Read the types\n node.attributes['type'].split(' ').each {|type|\n release.types << Utils.add_namespace(type)\n } if node.attributes['type']\n \n # Read the text representation information.\n if text_representation = node.elements['text-representation']\n release.text_language = text_representation.attributes['language']\n release.text_script = text_representation.attributes['script']\n end\n \n # Read the track list\n read_track_list(node.elements['track-list'], release.tracks) {|track|\n track.artist = release.artist unless track.artist\n track.releases << release\n }\n \n # Read the release event list\n read_release_event_list(node.elements['release-event-list'], release.release_events)\n \n # Read the disc list\n read_disc_list(node.elements['disc-list'], release.discs)\n \n # Read the relation list\n if node.elements['relation-list']\n node.elements.each('relation-list') {|relation_node|\n read_relation_list(relation_node) {|relation|\n release.add_relation relation\n }\n }\n end\n \n # Read the tag list\n read_tag_list(node.elements['tag-list'], release.tags)\n \n return release\n end", "def release(key, value)\n return\n end", "def release\n @@release[self] ||= if prerelease?\n segments = self.segments\n segments.pop while segments.any? {|s| String === s }\n self.class.new segments.join('.')\n else\n self\n end\n end", "def release!\n @ec.release_temp self\n end", "def release(options)\n options = options.rekey\n\n unixname = self.unixname\n\n package = options[:package] || metadata.name\n version = options[:version] || metadata.version\n\n date = options[:date] || metadata.released || Time::now.strftime('%Y-%m-%d %H:%M')\n\n changes = options[:changes] || project.history.releases[0].changes\n notes = options[:notes] || project.history.releases[0].note\n\n release = options[:release] || version\n\n files = options[:files] || options[:file] || []\n\n #store = options[:store] || 'pkg'\n\n processor = options[:processor] || 'Any'\n\n is_public = !options[:private]\n\n #raise ArgumentError, \"missing unixname\" unless unixname\n raise ArgumentError, \"missing package\" unless package\n raise ArgumentError, \"missing release\" unless release\n\n # package name has to be 3+ characters.\n if package.size < 3\n package = package + \"'s\"\n end\n\n # sub in for version if %s is used in release name.\n release = release % version if release.index(\"%s\")\n\n release_notes = notes\n release_changes = changes\n\n # Gather package files to release.\n if files.empty?\n files = find_packages(version)\n else\n files = files.map do |file|\n if File.directory?(file)\n find_packages(version, file)\n else\n file\n end\n end\n files = files.flatten\n end\n files = files.select{ |f| File.file?(f) }\n\n abort \"No package files.\" if files.empty?\n\n files.each do |file|\n abort \"Not a file -- #{file}\" unless File.exist?(file)\n puts \"Release file: #{File.basename(file)}\"\n end\n\n # which package types\n #rtypes = [ 'tgz', 'tbz', 'tar.gz', 'tar.bz2', 'deb', 'gem', 'ebuild', 'zip' ]\n #rtypes -= exclude\n #rtypes = rtypes.collect{ |rt| Regexp.escape( rt ) }\n #re_rtypes = Regexp.new('[.](' << rtypes.join('|') << ')$')\n\n puts \"Releasing #{package} #{release} to #{unixname} project...\" #unless options['quiet']\n\n login do\n\n raise ArgumentError, \"missing group_id\" unless group_id\n\n unless package_id = package?(package)\n if trial?\n puts \"Package '#{package}' does not exist.\"\n puts \"Create package #{package}.\"\n abort \"Cannot continue in trial mode.\"\n else\n #unless options['force']\n q = \"Package '#{package}' does not exist. Create?\"\n a = ask(q, 'yN')\n abort \"Task canceled.\" unless ['y', 'yes', 'okay'].include?(a.downcase)\n #end\n puts \"Creating package #{package}...\"\n create_package(package, is_public)\n unless package_id = package?(package)\n raise \"Package creation failed.\"\n end\n end\n end\n if release_id = release?(release, package_id)\n #unless options[:force]\n if trial?\n puts \"Release #{release} already exists.\"\n else\n q = \"Release #{release} already exists. Re-release?\"\n a = ask(q, 'yN')\n abort \"Task canceled.\" unless ['y', 'yes', 'okay'].include?(a.downcase)\n #puts \"Use -f option to force re-release.\"\n #return\n end\n files.each do |file|\n fname = File.basename(file)\n if file_id = file?(fname, package)\n if trial?\n puts \"Remove file #{fname}.\"\n else\n puts \"Removing file #{fname}...\"\n remove_file(file_id, release_id, package_id)\n end\n end\n if trial?\n puts \"Add file #{fname}.\"\n else\n puts \"Adding file #{fname}...\"\n add_file(file, release_id, package_id, processor)\n end\n end\n else\n if trial?\n puts \"Add release #{release}.\"\n else\n puts \"Adding release #{release}...\"\n add_release(release, package_id, files,\n :processor => processor,\n :release_date => date,\n :release_changes => release_changes,\n :release_notes => release_notes,\n :preformatted => '1'\n )\n unless release_id = release?(release, package_id)\n raise \"Release creation failed.\"\n end\n end\n #files.each do |file|\n # puts \"Added file #{File.basename(file)}.\"\n #end\n end\n end\n puts \"Release complete!\" unless trial?\n end", "def create_release(tag, message)\n\n if not is_valid_tag(tag)\n raise \"Invalid tag.\"\n end\n\n if message.empty?\n raise \n message = \"Release for #{tag}\"\n end\n\n message = {\n \"tag_name\": tag,\n \"target_commitish\": \"master\",\n \"name\": tag,\n \"body\": message,\n \"draft\": false,\n \"prerelease\": false\n }.to_json\n\n r = api_post(\"/releases\", message)\n\n if not r.kind_of? Net::HTTPCreated\n raise \"Creation of release unsuccessful.\"\n end\nend", "def on_release(&blk)\n opts[:on_release] = blk\n end", "def release(job = ALL_JOBS)\n DRMAA.control(job, DRMAA::ACTION_RELEASE)\n end", "def build_release\n build_dependency\n puts '### release build ###'\n `gulp release`\n puts '### release build done ###'\n post_build\nend", "def release!\n version = Origen.app.version\n body = { version: version.to_s }\n if version.production?\n body[:type] = :production\n else\n body[:type] = :development\n end\n post(\"plugins/#{Origen.app.name}/release\", body: body)\n end", "def release\n fetch(:@release) { |grid_string| grid_string[7,10] }\n end", "def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def release\n @start_script[:run] = start_run_script\n end", "def release\n locked? && release!\n end", "def create!\n doc.kubernetes_release.builds = [builds(:docker_build)]\n Kubernetes::ReleaseDoc.create!(\n doc.attributes.except('id', 'resource_template').merge(kubernetes_release: doc.kubernetes_release)\n )\n end", "def release(job = ALL_JOBS)\n DRMAA.control(job, DRMAA::ACTION_RELEASE)\n end", "def release(ptr = nil)\n V2.raptor_free_term(self) unless ptr.null?\n end", "def release\n @refresh_mutex.synchronize {\n @unlock = true\n\n delete\n\n @refresh_signal.signal\n }\n\n\n @refresh_thread.join if @refresh_thread\n @event_manager.create_event(\n {\n user: Config.current_job.username,\n action: 'release',\n object_type: 'lock',\n object_name: @name,\n task: @task_id,\n deployment: @deployment_name,\n }\n )\n end", "def release(plane)\n\n end", "def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end", "def define_on_distro_release(distro, release, name, version=nil)\n distro_releases[[distro, release]] << [name, version]\n end", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def release(force: false)\n return false if !force && under_lease?\n return true if lease.visibility_after_lease.nil?\n\n resource.visibility = lease.visibility_after_lease\n end", "def release\n # @invObj.releaseObj(self)\n end", "def release(entry)\n @lock.synchronize do\n unlocked_release(entry.id)\n end\n end", "def release\n begin\n unless auto_release?\n print \"Have you merged your code? Did you fetch and rebase against the upstream? Want to continue (y/n)?: \".yellow\n answer = gets.downcase.chomp\n if answer == 'n'\n return false\n end\n print \"Ready to release version #{version.next} to #{puppet_module.source}\\n and forever change history(y/n)?: \".yellow\n answer = gets.downcase.chomp\n if answer != 'y'\n puts \"Nah, forget it, this release wasn't that cool anyways.\".yellow\n return false\n end\n end\n # updates the metadata.js file to the next version\n bump\n # updates the changelog to the next version based on the metadata file\n id = bump_log\n # tags the r10k-module with the version found in the metadata.json file\n tag(id)\n rescue Rugged::TagError => e\n logger.fatal(e.message)\n logger.fatal(\"You might need to rebase your branch\")\n exit 1\n end\n end", "def write_release(payload)\n info 'Creating new release on GitHub'\n rel = payload[:data][:github_kit].delete(:release)\n release = github_client.create_release(\n rel[:repository],\n rel[:tag_name],\n :name => rel[:name],\n :target_commitish => rel[:reference],\n :prerelease => rel[:prerelease],\n :body => rel[:body]\n )\n\n api_release_url = release.rels[:self].href\n public_release_url = release.rels[:html].href\n\n info 'New release created on GitHub. Uploading assets.'\n assets = rel[:assets].map do |asset|\n debug \"Uploading release asset - #{asset}\"\n response = github_client.upload_asset(\n api_release_url,\n asset_store.get(asset),\n :name => asset.sub(/^.+?_/, ''),\n :content_type => 'application/octet-stream'\n )\n debug \"Completed release asset upload - #{asset}\"\n Smash.new(\n :url => response[:url],\n :browser_url => response[:browser_download_url],\n :name => response[:name],\n :id => response[:id]\n )\n end\n payload.set(:data, :github_kit, :release, :assets, assets)\n payload.set(:data, :github_kit, :release, :api_url, api_release_url)\n payload.set(:data, :github_kit, :release, :public_url, public_release_url)\n\n true\n end", "def around_release\n yield\n end", "def release_state\n \"public_release\"\n end", "def to_release\n user.releases.find_or_initialize_by(discogs_release_id: discogs_release_id).tap do |release|\n release.catalog_number = catalog_number\n release.label = label\n release.artist = artist\n release.name = name\n release.year = year\n release.genre = genre\n release.format = format\n release.format_quantity = format_quantity\n release.discogs_community_have = discogs_community_have\n release.discogs_community_want = discogs_community_want\n release.discogs_lowest_price = discogs_lowest_price\n release.discogs_number_for_sale = discogs_number_for_sale\n release.discogs_cover_thumb_url = discogs_cover_thumb_url\n release.discogs_api_resource_url = discogs_api_resource_url\n release.discogs_uri = discogs_uri\n end\n end", "def build_release(resolve_build: true)\n Kubernetes::Release.build_release_with_docs(\n builds: resolve_build ? build_finder.ensure_succeeded_builds : [],\n deploy: @job.deploy,\n grouped_deploy_group_roles: grouped_deploy_group_roles,\n git_sha: @job.commit,\n git_ref: @reference,\n user: @job.user,\n project: @job.project\n )\n end", "def release(point)\n\t\t\n\tend", "def release(point)\n\t\t\n\tend", "def release(point)\n\t\t\n\tend", "def release(point)\n\t\t\n\tend", "def release\n @release ||= ENV[\"RELEASE\"] || \"1\"\n end", "def release!(feature_key, resource_id)\n warn \"[DEPRECATION] `release!` is deprecated. Please use `release` instead.\"\n release(feature_key, resource_id)\n end", "def release(resource)\n\t\t\t\t\t# A resource that is not good should also not be reusable.\n\t\t\t\t\t# unless resource.closed?\n\t\t\t\t\t\treuse(resource)\n\t\t\t\t\t# else\n\t\t\t\t\t# \tretire(resource)\n\t\t\t\t\t# end\n\t\t\t\tend", "def build\n sh './configure -u couchdb -c'\n make :release\n end", "def call(_obj, args, _ctx)\n \toptions = { \n \t\tmake_id: args[:make_id],\n \t\tmake_name: args[:make_name]\n \t}\n\n Make.create(options)\n end", "def release(ip, ar_id=-1)\n return Error.new('ID not defined') if !@pe_id\n\n addr_name = address_type(ip)\n\n return addr_name if OpenNebula.is_error?(addr_name)\n\n lease_template = \"LEASES = [ #{addr_name} = #{ip}\"\n lease_template << \", AR_ID = #{ar_id}\" if ar_id != -1\n lease_template << \"]\"\n\n rc = @client.call(VN_METHODS[:release], @pe_id, lease_template)\n rc = nil if !OpenNebula.is_error?(rc)\n\n return rc\n end", "def test_method_release\n value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)\n value2_ = value_.release\n assert_equal([1, 9, 2, 0, 0, 0, 0, 0], value2_.values_array)\n value_ = ::Versionomy.create([1, 9, 2, 5, 2], :rubygems)\n value2_ = value_.release\n assert_equal(value_, value2_)\n end", "def create(name, start_date, end_date)\n file_name = name.downcase\n unless file_exists?(file_name) \n release = Release.new(name, start_date, end_date)\n save_release(file_name, release)\n else\n raise ReleaseExists.new\n end\n end", "def to_make\n Target.new(@output, @objects, [command, \"ranlib #{output}\"])\n end", "def release_lot(lot_name, release_signature)\n select_lot(lot_name)\n release.click\n release_agree.set(true)\n release_audit.set release_signature\n confirm_release.click\n end", "def release_actions; end", "def make(name, path)\n Log.info(\"package make name=#{name} path=#{path} bucket=#{options[:bucket]}\")\n\n unless options[:bucket]\n raise EngineFailure, '--bucket was not specified and $AWS_DEFAULT_BUCKET is not set'\n end\n ::Taxi::Package.make(name, path, bucket: options[:bucket])\n end", "def release(builder)\n raise TypeError unless builder.is_a? @klass\n builder.reset\n @pool.push builder\n nil\n end", "def github_release_task\n sh git, 'push', '--tags', remote, remote_branch\n end", "def make(thing) end", "def release(pattern, options)\n log.header 'Release'\n each_solution(pattern) do |solution|\n semver = Versioning.find(solution.dir)\n semver.release if semver.prerelease?\n Versioning.save semver\n end\n compile(pattern, debug: false, update_version: true)\n test(pattern, {})\n options[:debug] = false\n package(pattern, options)\n end", "def release\n # dynatrace paths within the droplet\n pwd = ENV['PWD']\n dynatrace_home_dir = \"#{pwd}/app/#{DYNATRACE_HOME_DIR}\"\n dynatrace_one_agent = File.join(dynatrace_home_dir, 'agent', lib_name, 'liboneagentloader.so')\n dynatrace_one_agent = File.join(dynatrace_home_dir, 'agent', lib_name, 'libruxitagentloader.so') unless File.file?(File.join(@app_dir, DYNATRACE_HOME_DIR, 'agent', lib_name, 'liboneagentloader.so'))\n\n @logger.debug(\"dynatrace_one_agent: #{dynatrace_one_agent}\")\n\n # create the dynatrace agent command as java_opts\n @java_opts << \"-agentpath:#{dynatrace_one_agent}\"\n end", "def getNewReleases(time=nil,start=nil,count=nil,extras=nil)\n method = 'getNewReleases'\n type = Album\n args = {}\n args[:time] = time if time\n args[:start] = start if start\n args[:count] = count if count\n args[:extras] = extras if extras\n return_object type,method,args\n end", "def release(resource)\n\t\t\t\t@available << resource\n\t\t\t\t\t\n\t\t\t\tif task = @waiting.pop\n\t\t\t\t\ttask.resume\n\t\t\t\tend\n\t\t\tend", "def create\n @release = Release.new(release_params)\n @release.project = @project\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to [@release.project, @release], notice: 'Release criada com sucesso.' }\n else\n format.html { render :new }\n end\n end\n end", "def release\n result = eval_script(\n RedisScripts::RELEASE_SCRIPT,\n RedisScripts::RELEASE_SCRIPT_HASH,\n keys: [redis_key],\n argv: [owner]\n )\n result != 0\n end", "def release\n return self unless prerelease?\n\n segments = self.segments.dup\n segments.pop while segments.any? { |s| String === s }\n self.class.new segments.join('.')\n end", "def create\n @cashier = Cashier.find(params[:cashier_id])\n @release = @cashier.releases.build(params[:release])\n\n #@release.date_release = post_date Date.today\n respond_to do |format|\n if @release.save\n format.html { redirect_to cashier_path(@cashier), notice: 'Release was successfully created.' }\n #format.html { redirect_to cashier_release_path(@release.cashier, @release), notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def release\n\n a = self.to_a\n self.close\n a\n end", "def create!\n prepare\n create_software_license_files\n create_project_license_file\n end", "def release\n # dynatrace paths within the droplet\n pwd = ENV['PWD']\n dt_home_dir = \"#{pwd}/app/#{DT_HOME_DIR}\"\n dt_agent = File.join(dt_home_dir, 'agent', agent_unpack_path, lib_name, 'libdtagent.so')\n @logger.debug(\"dt_agent: #{dt_agent}\")\n\n # create the dynatrace agent command as java_opts\n @java_opts << \"-agentpath:#{dt_agent}=#{get_service_options}\"\n @java_opts << '-Xshare:off'\n end", "def build_cardio()\n CommandProcessor.command(\"VERSION=#{@current_release.version} ./releasinator.sh\", live_output=true)\nend", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def after_release_email(tag, note, type, selector, options) \n command = \"origen web compile --remote --api\" \n Dir.chdir Origen.root do \n system command \n end \n end", "def create(*args)\n arguments(args, required: [:owner, :repo]) do\n assert_required :tag_name\n end\n\n post_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases\",\n arguments.params)\n end", "def release_a_resource(resource_descr, type_to_release, authorizer)\n debug \"release_a_resource: resource_descr: #{resource_descr}, type_to_create: #{type_to_release}\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end", "def release(resource)\n\t\t\t\t# A resource that is not good should also not be reusable.\n\t\t\t\tif resource.reusable?\n\t\t\t\t\treuse(resource)\n\t\t\t\telse\n\t\t\t\t\tretire(resource)\n\t\t\t\tend\n\t\t\tend", "def release(resource)\n\t\t\t\t# A resource that is not good should also not be reusable.\n\t\t\t\tif resource.reusable?\n\t\t\t\t\treuse(resource)\n\t\t\t\telse\n\t\t\t\t\tretire(resource)\n\t\t\t\tend\n\t\t\tend", "def release(point)\n\t\t\t\t\n\t\t\tend" ]
[ "0.64916646", "0.64916646", "0.64575815", "0.63807654", "0.6346428", "0.62295675", "0.58892614", "0.58656013", "0.5859781", "0.5768092", "0.57487524", "0.57013816", "0.5693733", "0.56701195", "0.5611331", "0.5546409", "0.5535584", "0.55115175", "0.55000645", "0.5468179", "0.5463926", "0.5449073", "0.54358107", "0.54253775", "0.5414789", "0.5380633", "0.5377131", "0.53593993", "0.53112733", "0.52989256", "0.52963674", "0.52726394", "0.5268896", "0.52326155", "0.5223867", "0.51798", "0.51661164", "0.5159543", "0.5155398", "0.5150922", "0.5144392", "0.51349777", "0.50883603", "0.5083006", "0.5068884", "0.50667745", "0.5050603", "0.504087", "0.50339514", "0.50214314", "0.5016474", "0.5014077", "0.50062877", "0.5004795", "0.50000453", "0.4977775", "0.4960696", "0.49238467", "0.49238253", "0.48986495", "0.48986495", "0.48986495", "0.48986495", "0.4897224", "0.4878719", "0.48775712", "0.4863389", "0.4862222", "0.4853081", "0.48463613", "0.48445636", "0.48311585", "0.4821409", "0.4813188", "0.48119238", "0.4797274", "0.47958827", "0.47836435", "0.4776379", "0.47707483", "0.47591794", "0.47505882", "0.47314456", "0.47223273", "0.4717737", "0.47158566", "0.4697577", "0.4696144", "0.46941316", "0.46864703", "0.46788183", "0.46788183", "0.46788183", "0.46788183", "0.4673118", "0.46609604", "0.4646988", "0.46337524", "0.46337524", "0.4629661" ]
0.57080096
11
:callseq: extract_version() => this_version Extract the current version number from the buildfile. Raise an error if not found.
def extract_version buildfile = File.read(Rake.application.rakefile).force_encoding("ISO-8859-1").encode("utf-8", replace: nil) buildfile.scan(THIS_VERSION_PATTERN)[0][2] rescue fail 'Looking for THIS_VERSION = "1.0.0-rc1" in your Buildfile, none found' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_version\n buildfile = File.read(version_file)\n buildfile.scan(THIS_VERSION_PATTERN)[0][2]\n rescue\n fail 'Looking for THIS_VERSION = \"...\" in your Buildfile, none found'\n end", "def build_version\n string = plist_buddy.plist_read(\"CFBundleVersion\", info_plist_path)\n begin\n version = RunLoop::Version.new(string)\n rescue\n if string && string != \"\"\n RunLoop.log_debug(\"CFBundleVersion: '#{string}' is not a well formed version string\")\n else\n RunLoop.log_debug(\"CFBundleVersion is not defined in Info.plist\")\n end\n version = nil\n end\n version\n end", "def get_version(project)\n branch = get_release(project)\n build_file = get_github_file(project, branch, \"build-dkan.make\")\n version = build_file.scan(/\\[tag\\] = (.+)/)\n if version.to_a.length == 0\n version = build_file.scan(/\\[branch\\] = (.+)/)\n end\n version\n end", "def version\n @version ||= File.read(file)[version_regex]\n end", "def extractVersion(filename)\n firstUnderscoreInd = filename.index(\"_\")\n return nil unless !firstUnderscoreInd.nil? \n\n secondUnderscoreInd = filename.index(\"_\", firstUnderscoreInd + 1)\n return nil unless !secondUnderscoreInd.nil?\n return filename[firstUnderscoreInd + 1...secondUnderscoreInd].to_i\n end", "def current_version\r\n version = File.read(\"VERSION\").strip\r\n fail \"Invalid version information\" unless version =~ /\\./\r\n version\r\nend", "def version\n unless @version\n\n # Extract version information (if available)\n @version = metadata['bundleShortVersionString'] || metadata['bundleVersion'] rescue nil\n\n # Otherwise, use the filename\n unless @version\n @version = filename[FILENAME_VERSION_REGEX, 1]\n end\n\n end\n\n @version\n end", "def read_version_from_version_file #:nodoc:\n if version_file\n if match = File.read(version_file).match(version_pattern)\n match[1]\n else\n fail \"No version match %p in %p.\" % [ version_file, version_pattern ]\n end\n else\n fail \"No version or version_file specified.\"\n end\n end", "def version\n path = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__\n dir = File.dirname(path)\n if File.exist?(dir+'/version.stamp')\n version = File.read(dir+'/version.stamp')\n else\n version = \"Unknown version\"\n end\n version\n end", "def version\n @version ||= File.read(path('version.txt')).strip\n end", "def version\n Cleaner.extract_version @id\n end", "def current_version\n version_number rev\n end", "def get_version!(version)\n version.gsub!('_', '.')\n\n if version == 'latest'\n latest_extension_version\n else\n extension_versions.find_by!(version: version)\n end\n end", "def version\n return @version unless @version.nil?\n @version = @config_source['version'] || maven_version() || 'unknown' \n @version.gsub!(/revision/, current_revision.to_s) \n @version\n end", "def version\n @version ||= File.read(path('version.txt')).strip\n end", "def version\n [ \"lib/#{ name }.rb\", \"lib/#{ name }/version.rb\" ].each do |v|\n path = project_path( v )\n line = path.read[/^\\s*VERSION\\s*=\\s*.*/]\n if line then\n return line.match(/.*VERSION\\s*=\\s*['\"](.*)['\"]/)[1]\n end\n end\n end", "def version\n return last_version if versionable?\n version_number\n end", "def get_version_build\n version = self.peers_version\n if version[\"success\"]\n return version[\"build\"]\n else\n return nil\n end\n end", "def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end", "def get_version(url, regex)\n abs_url = @base_url + url\n Rails.cache.fetch(\"/build_number/#{abs_url}\", expires_in: 10.minutes) do\n begin\n meta = meta_file(abs_url)\n name_elem = meta.xpath(\"//m:metalink//m:file//@name\", 'm' => 'urn:ietf:params:xml:ns:metalink').to_s\n matches = regex.match(name_elem.to_s)\n matches[1]\n rescue OpenURI::HTTPError, RuntimeError => e\n filename = File.basename(URI.parse(abs_url).path)\n raise MetadataError, \"Could not get version of #{filename}: #{e}\"\n end\n end\n end", "def version_number\n @version ||= nil\n end", "def version\n @version ||= File.open(@filename) do |io|\n io.read(8)[5..-1].to_sym\n end\n end", "def get_version(version)\n decode_doc(@ram_versions[version])\n end", "def find_version\n\t\tversion_file = self.version_from\n\n\t\tunless version_file.readable?\n\t\t\tself.prompt.warn \"Version could not be read from %s\" % [ version_file ]\n\t\t\treturn nil\n\t\tend\n\n\t\tversion_line = version_file.readlines.find {|l| l =~ VERSION_PATTERN } or\n\t\t\tabort \"Can't read the VERSION from #{version_file}!\"\n\t\tversion = version_line[ VERSION_PATTERN, :version ] or\n\t\t\tabort \"Couldn't find a semantic version in %p\" % [ version_line ]\n\n\t\treturn Gem::Version.new( version )\n\tend", "def read_version\n # The version string is usually in one of the following formats:\n #\n # * 4.1.8r1234\n # * 4.1.8r1234_OSE\n # * 4.1.8_MacPortsr1234\n #\n # Below accounts for all of these:\n execute(\"--version\").split(\"_\")[0].split(\"r\")[0]\n end", "def version_info\n # thanks to Roger Pack on ruby-forum for how to get to the version\n # file\n filename = File.open(File.dirname(__FILE__) + \"/../../../VERSION\")\n v = nil\n if File.exists?(filename)\n v = File.open(filename).read.chomp if File.exists?(filename)\n #else\n #$stderr.puts \"could not locate file #{filename}. \" \n #puts `pwd`\n end\n v\n end", "def readVersionNumber\n\tconfig = fileRead(\"./www/config.xml\")\n\n\t# Get version number from config.xml.\n\tmatch = config.scan(/version=\"(.*?)\"/)\n\tif(match.empty?)\n\t\traise \"Version not found in config.xml\"\n\tend\n\n\treturn match[0][0]\nend", "def version_info\n # thanks to Roger Pack on ruby-forum for how to get to the version\n # file\n filename = File.open(File.dirname(__FILE__) + \"/../../VERSION\")\n v = nil\n if File.exists?(filename)\n v = File.open(filename).read.chomp if File.exists?(filename)\n #else\n #$stderr.puts \"could not locate file #{filename}. \" \n #puts `pwd`\n end\n v\n end", "def update_version_to_next\n super\n info \"Current version is now #{extract_version}\"\n Hg.commit File.basename(version_file), message\n Hg.push if Hg.remote\n end", "def latest_version\n files.last && files.last.versionnumber\n end", "def version\n output = @filer.invoke(\"system-get-version\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.child_get_string(\"version\")\n end\n end", "def get_version!(version)\n version.gsub!(/_/, '.')\n\n if version == 'latest'\n cookbook_versions.first!\n else\n cookbook_versions.find_by!(version: version)\n end\n end", "def version_from_ruby_version_file\n shell_return = run_shell(\"cat .ruby-version\")\n shell_return.nil? ? nil : shell_return.stdout\n end", "def find_version_entry(url, version)\n finalversion = nil\n version = '1.'.concat(version.to_s) unless version.to_s.include?('.')\n yaml_content = open(url.to_s, &:read)\n entries = YAML.safe_load(yaml_content)\n entries.each do |entry|\n finalversion = entry[1] if entry[0].to_s.start_with?(version.to_s)\n end\n finalversion\n end", "def lookup_version_from_sbt_build(sbt_build_file)\n sbt_proj_version = '0.0.0'\n has_hadoop = false\n has_spark = false\n File.open(sbt_build_file, \"r\") do |f|\n file_content = f.read\n if file_content =~ /version := \"(\\d*\\.\\d*.\\d*)(-hadoop\\d\\.\\d)?(-spark\\d\\.\\d)?\"[,]?$/i\n sbt_proj_version = $1\n if $2\n has_hadoop = true\n\tsbt_proj_version += $2\n end\n if $3\n has_spark = true\n\tsbt_proj_version += $3\n end\n end\n end\n [sbt_proj_version, has_hadoop, has_spark]\nend", "def module_version(repo_dir, config, build)\n version = config[\"module_version\"] || git_current_branch(repo_dir) || \"unknown\"\n \n if (not build.nil?) && build.length > 0\n return version + \"-\" + build\n else\n return version\n end\n end", "def version\n\t\treturn @version ||= self.find_version\n\tend", "def version\n copy_file('VERSION', 'VERSION')\n end", "def extract_os_version(version)\n #version.unpack('CCS').join('.')\n begin\n os_version = NTLM::OSVersion.read(version)\n rescue IOError\n return ''\n end\n return \"#{os_version.major}.#{os_version.minor}.#{os_version.build}\"\n end", "def base_version\n base_file\n\n base_file.scan(/version\\s+(.+),/).first.first.delete!(\"'\")\n end", "def get_current_version(version)\n # 0 would be if we are looking for latest\n if version.to_s.eql?('0')\n Chef::Log.debug(\n 'No version filtering. Grabbing the highest version from disk',\n )\n # Current_resource.version is string.\n return Gem::Version.new(current_resource.version.max)\n else\n Chef::Log.debug(\"Grabbing the highest version of v#{version} from disk.\")\n # Grab the highest version that meets the major, minor, build given\n list = current_resource.version.map { |v| Gem::Version.new(v) }\n Chef::Log.debug(\"Installed versions found: #{list.join(', ')}\")\n\n # Reducing by version can result in nil array.\n max = reduce_by_version(list, version).max\n return max.nil? ? Gem::Version.new(0) : max\n end\n end", "def version_number\n @version\n end", "def get_rem_ver(app_name)\n app_url = get_app_url(app_name)\n if $verbose == 1\n puts \"Getting version (or date) of latest release from #{app_url}\"\n end\n rem_ver = eval(\"get_#{app_name.downcase.gsub(/ |-/,'_')}_rem_ver(app_name,app_url)\")\n if rem_ver.to_s !~ /[0-9]/\n puts \"Remote build version (or date) not found\"\n exit\n end\n if !rem_ver.class.to_s.match(/Date/)\n rem_ver = rem_ver.gsub(/\\.$/,\"\")\n end\n return rem_ver\nend", "def version(version = nil)\n @version = version if version\n @version\n end", "def version\n m = VERSION_REGEX.match(@text)\n return -1 unless m\n\n m[1].to_i\n end", "def version\n logger.debug \"Parsing version from output using #{description}\"\n matches = output.match PARSE_VERSION_FROM_OUTPUT\n raise InvalidFormat.new output if matches.nil?\n matches.captures[0]\n end", "def version\n version = \"\"\n\n # it is very simple to check the version when not 'latest' - just read the .version file. \n if (File.directory?(@resource_copy[:path]))\n if (File.exists?(\"#{@resource_copy[:path]}/.version\"))\n # read the version from its version file.\n file = File.open(\"#{@resource_copy[:path]}/.version\")\t\n version = file.read.chomp\n file.close\n end\n else\n err \"Error! Sorry, I couldn't find the version of #{resource[:name]} yet I know it exists!\" \n raise \"Error! Sorry, I couldn't find the version of #{resource[:name]} yet I know it exists!\" \n end\n\n # if the original version was set to latest we need to return 'latest' if the local resource is at the latest\n # version, otherwise return the actual version number...\n info \"Local #{@resource_copy[:path]} is at version #{version}\"\n if (resource[:version] == 'latest' && @resource_copy[:version] == version )\n return 'latest'\n end\n version\n end", "def version_number\n return @version_number\n end", "def get_version_argument\n version = ENV['VERSION']\n if version.to_s.empty?\n raise \"No version specified: Add VERSION=X.Y.Z to the command line\"\n end\n begin\n Gem::Version.create(version.dup)\n rescue ArgumentError\n raise \"Invalid version specified in `VERSION=#{version}'\"\n end\nend", "def version_without_build\n version.split('-')[0]\n end", "def current_version\n versions.first\n end", "def determine_revision\n # Note the revision number we're running, and a\n # more-informative string containing it.\n revision_path = File.dirname(__FILE__) + \"/../../REVISION\"\n begin\n digits = 8\n if File.exist? revision_path\n mod_date = File.mtime(revision_path)\n full_number = File.read(revision_path).strip\n number = full_number[0...digits]\n extra = mod_date.strftime(\"%H:%M %a, %b %d %Y\").gsub(\" 0\",\" \")\n else\n if File.exist?(\".git\")\n full_number = `git log -1`.split(\" \")[1]\n number = full_number[0...digits]\n extra = `git branch`.split(\"\\n\").grep(/^\\*/)[0].split(' ')[-1]\n else\n # We don't use --xml anymore, because CentOS's svn doesn't have it.\n number = `svn info`.grep(%r\"^Revision: \")[0].split(\" \")[1]\n extra = ''\n end\n end\n rescue\n number = '???'\n extra = ''\n end\n details = \"#{Rails.env} #{number} #{extra} #{Socket.gethostname}\"\n return full_number, number, details\nend", "def get_version(version)\n decode_doc(@tc_storage.get(version))\n end", "def version_number\n self.name =~ /RHEL-([0-9]+)/\n return $1.to_i\n end", "def latest_version\n @latest_version ||= with_cache(file_name) { normalize_version(Network.get_url(\"#{base_url}/latest\")[/[^v]*$/]) }\n end", "def fetch_version(number)\n @versions[number] || raise(ArgumentError, \"No such version #{number.inspect}; I have: #{@versions.keys.sort_by(&:to_s).inspect}\")\n end", "def retrieve_version(name, version)\n path = downloaded_gem_path name, version\n parse :gem => path\n end", "def extract_latest_version (xml)\n doc = REXML::Document.new(xml)\n\n latest = nil\n REXML::XPath.each(doc, \"/metadata/versioning/versions/version\") do |el|\n if latest.nil?\n latest = el.text\n elsif gt(latest, el.text)\n latest = el.text\n end\n end\n\n unless latest.nil? then\n latest\n else\n raise LatestVersionNotDefinedError\n end\n end", "def version(revision_number)\n self.versions.find_by_revision_number(revision_number)\n end", "def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end", "def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end", "def version\n return @version if defined?(@version)\n \n @version = JSON.parse(File.read('package.json'))['version']\nend", "def version_number(version_id)\n version_id.gsub(VERSION_REGEX, '\\1').to_i\n end", "def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile }\n end", "def version\n @version ||= if token.nil? || Array(packages).empty?\n '0.1.0'\n else\n packages.map do |p|\n Gem::Version.new(p['version'])\n end.sort.last.bump.to_s << '.0'\n end\n end", "def check_version_or_latest_version(version = nil)\n version ||= latest_version\n raise Ajaxlibs::Exception::VersionNotFound unless self.class::Versions.include?(version)\n version\n end", "def target_version=(_arg0); end", "def pkg_version(item)\n # refactoring! :revision points to same revision as item!\n v = revision.checkout.extract_version\n return \"#{v}pre.#{item.version}.#{item.id}\"\n end", "def version\n @version ||= create_version\n end", "def get_latest_build_number(project)\n raise \"#{self.class}#get_latest_build_number not implemented\"\n end", "def get_version_info\n version_file = Rails.root.join('lib', 'version.json')\n\n File.exist?(version_file) ? read_version_file(version_file) : development_version_info\nend", "def file_version(filepath)\n file_version_info_size = client.railgun.version.GetFileVersionInfoSizeA(\n filepath,\n nil\n )['return']\n\n buffer = session.railgun.kernel32.VirtualAlloc(\n nil,\n file_version_info_size,\n MEM_COMMIT|MEM_RESERVE,\n PAGE_READWRITE\n )['return']\n\n client.railgun.version.GetFileVersionInfoA(\n filepath,\n 0,\n file_version_info_size,\n buffer\n )\n\n result = client.railgun.version.VerQueryValueA(buffer, \"\\\\\", 4, 4)\n ffi = client.railgun.memread(result['lplpBuffer'], result['puLen'])\n\n vs_fixed_file_info = ffi.unpack('V13')\n\n unless vs_fixed_file_info and (vs_fixed_file_info.length == 13)\tand\n(vs_fixed_file_info[0] = 0xfeef04bd)\n return nil\n end\n\n major = hiword(vs_fixed_file_info[2])\n minor = loword(vs_fixed_file_info[2])\n build = hiword(vs_fixed_file_info[3])\n revision = loword(vs_fixed_file_info[3])\n branch = revision.to_s[0..1].to_i\n\n return major, minor, build, revision, branch\n end", "def version_needed_to_extract\n 0x0014\n end", "def version_needed_to_extract\n 0x0014\n end", "def get_xcode_version\n result = `xcodebuild -version`\n first_line = result.split(\"\\n\")[0]\n version = first_line.split(' ')[1]\n version\nend", "def get_version(version)\n unless version > 0\n raise OcflTools::Errors::NonCompliantValue, \"Requested value '#{version}' for object version does not comply with specification.\"\n end\n if @versions.key?(OcflTools::Utils.version_int_to_string(version))\n @versions[OcflTools::Utils.version_int_to_string(version)]\n else\n # Otherwise, construct a new Version [Hash] and return that.\n @versions[OcflTools::Utils.version_int_to_string(version)] = create_version_hash\n\n # If version -1 exists, copy prior version state over.\n if @versions.key?(OcflTools::Utils.version_int_to_string(version - 1))\n @versions[OcflTools::Utils.version_int_to_string(version)]['state'] = OcflTools::Utils.deep_copy(@versions[OcflTools::Utils.version_int_to_string(version - 1)]['state'])\n end\n\n @versions[OcflTools::Utils.version_int_to_string(version)]\n end\n end", "def fetch_revision\n context.capture \"cat #{repo_path}/#{release_timestamp}_REVISION\"\n end", "def version_file\n version_rb_file = File.dirname(Buildr.application.buildfile.to_s) + '/version.rb'\n return version_rb_file if File.exists?(version_rb_file)\n return Buildr.application.buildfile.to_s\n end", "def version value = nil\n return @version if value.nil?\n @version = value\n end", "def version\n @version ||= __determine_version\n end", "def current_version\n @version\n end", "def initialize\n if File.exist?(Version.path)\n read_version_from_file\n else\n @major = 0\n @minor = 0\n @patch = 0\n end\n end", "def version\n @version ||= `git --version`.split(/\\s/).last.split(\".\").collect {|i| i.to_i}\n end", "def propagate_version(**args)\n return unless ENV.key? 'CI'\n\n version = get_package_key(key: :version)\n build = current_build_number(track: args[:track] || nil)\n\n UI.message \"Propagating version: #{version}\"\n UI.message 'into the Info.plist and build.gradle files'\n\n UI.message \"Setting build number to #{build}\"\n\n version = \"#{version.split('-')[0]}-pre\" if should_nightly?\n UI.message \"Actually putting #{version} into the binaries (because we're doing a nightly)\"\n\n # encode build number into js-land – we've already fetched it, so we'll\n # never set the \"+\" into the binaries\n unless version.include? '+'\n # we always want the CI build number in js-land\n set_package_data(data: { version: \"#{version}+#{build}\" })\n end\n\n case lane_context[:PLATFORM_NAME]\n when :android\n set_gradle_version_name(version_name: version, gradle_path: lane_context[:GRADLE_FILE])\n set_gradle_version_code(version_code: build, gradle_path: lane_context[:GRADLE_FILE])\n when :ios\n # we're splitting here because iTC can't handle versions with dashes in them\n increment_version_number(version_number: version.split('-')[0], xcodeproj: ENV['GYM_PROJECT'])\n increment_build_number(build_number: build, xcodeproj: ENV['GYM_PROJECT'])\n end\nend", "def sub_version\n \">= \".concat(version.split('.').first(2).join('.'))\n end", "def load_versioning\n if @project_root and Pkg::Util::Git.describe\n @ref = Pkg::Util::Git.sha_or_tag\n @short_ref = Pkg::Util::Git.sha_or_tag(7)\n @version = Pkg::Util::Version.dash_version\n @gemversion = Pkg::Util::Version.dot_version\n @debversion = Pkg::Util::Version.debversion\n @origversion = Pkg::Util::Version.origversion\n @rpmversion = Pkg::Util::Version.rpmversion\n @rpmrelease = Pkg::Util::Version.rpmrelease\n else\n puts \"Skipping determination of version via git describe, Pkg::Config.project_root is not set to the path of a tagged git repo.\"\n end\n end", "def get_version(number)\n version = versions_dataset.where(:version_number => number).first\n raise NoSuchVersionError if version.nil?\n version\n end", "def logical_version_number\n @logical_version_number || self.current_version\n end", "def revision\n @revision ||= if token.nil? || relevant_packages.empty?\n 1\n else\n relevant_packages.map do |p|\n p['release'].to_i\n end.sort.last + 1\n end\n end", "def package_version(package)\n # use module version if it exists\n go_mod = package[\"Module\"]\n return go_mod[\"Version\"] if go_mod\n\n package_directory = package[\"Dir\"]\n return unless package_directory && File.exist?(package_directory)\n\n # find most recent git SHA for a package, or nil if SHA is\n # not available\n Dir.chdir package_directory do\n contents_version(*contents_version_arguments)\n end\n end", "def version\n version_file = File.join(RAILS_ROOT, \"config\", \"version.ini\")\n current_version = if File.exists? version_file\n File.read(version_file)\n else\n \"0.0.1\"\n end\n current_version.strip\n end", "def __determine_version\n path_to_lib = File.dirname(arguments[:command]) + '/../lib/'\n version = if arguments[:version]\n arguments[:version]\n elsif File.exist?(path_to_lib) && !(jar = Dir.entries(path_to_lib).select { |f| f =~ /^elasticsearch\\-\\d/ }.first).nil?\n __log \"Determining version from [#{jar}]\" if ENV['DEBUG']\n if m = jar.match(/elasticsearch\\-(\\d+\\.\\d+\\.\\d+).*/)\n m[1]\n else\n raise RuntimeError, \"Cannot determine Elasticsearch version from jar [#{jar}]\"\n end\n else\n __log \"[!] Cannot find Elasticsearch .jar from path to command [#{arguments[:command]}], using `#{arguments[:command]} --version`\" if ENV['DEBUG']\n\n unless File.exist? arguments[:command]\n __log \"File [#{arguments[:command]}] does not exists, checking full path by `which`: \", :print if ENV['DEBUG']\n\n begin\n full_path = `which #{arguments[:command]}`.strip\n __log \"#{full_path.inspect}\\n\", :print if ENV['DEBUG']\n rescue Exception => e\n raise RuntimeError, \"Cannot determine full path to [#{arguments[:command]}] with 'which'\"\n end\n\n if full_path.empty?\n raise Errno::ENOENT, \"Cannot find Elasticsearch launch script from [#{arguments[:command]}] -- did you pass a correct path?\"\n end\n end\n\n output = ''\n\n begin\n # First, try the new `--version` syntax...\n __log \"Running [#{arguments[:command]} --version] to determine version\" if ENV['DEBUG']\n io = IO.popen(\"#{arguments[:command]} --version\")\n pid = io.pid\n\n Timeout::timeout(arguments[:timeout_version]) do\n Process.wait(pid)\n output = io.read\n end\n\n rescue Timeout::Error\n # ...else, the old `-v` syntax\n __log \"Running [#{arguments[:command]} -v] to determine version\" if ENV['DEBUG']\n output = `#{arguments[:command]} -v`\n ensure\n if pid\n Process.kill('INT', pid) rescue Errno::ESRCH # Most likely the process has terminated already\n end\n io.close unless io.closed?\n end\n\n STDERR.puts \"> #{output}\" if ENV['DEBUG']\n\n if output.empty?\n raise RuntimeError, \"Cannot determine Elasticsearch version from [#{arguments[:command]} --version] or [#{arguments[:command]} -v]\"\n end\n\n if m = output.match(/Version: (\\d\\.\\d.\\d).*,/)\n m[1]\n else\n raise RuntimeError, \"Cannot determine Elasticsearch version from elasticsearch --version output [#{output}]\"\n end\n end\n\n case version\n when /^0\\.90.*/\n '0.90'\n when /^1\\..*/\n '1.0'\n when /^2\\..*/\n '2.0'\n when /^5\\..*/\n '5.0'\n when /^6\\..*/\n '6.0'\n when /^7\\..*/\n '7.0'\n else\n raise RuntimeError, \"Cannot determine major version from [#{version}]\"\n end\n end", "def source_version\n Rails.cache.fetch(\"source_version_for_#{name}\", expires_in: 10.minutes) do\n begin\n p = Xmlhash.parse(ActiveXML::backend.direct_http \"/source/#{name}/#{SOURCE_VERSION_FILE}?expand=1\")\n p.get('products').get('product').get('version')\n rescue ActiveXML::Transport::NotFoundError\n nil\n end\n end\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end", "def revision_number\n ver = version\n case\n when live? then\n versions.count\n when ver then\n ver.index\n else\n 0\n end\n end", "def get_version\n prepare\n @api.get_api_version\n end", "def current_version\n self._version ||= 0\n end" ]
[ "0.84408754", "0.6472261", "0.64500403", "0.6438712", "0.63816166", "0.63013315", "0.62654823", "0.6176433", "0.61686075", "0.61397475", "0.6132354", "0.6118228", "0.6117402", "0.6113286", "0.60789984", "0.607277", "0.60645723", "0.60093766", "0.59999335", "0.59854895", "0.5973469", "0.5952437", "0.59509915", "0.59421384", "0.59323215", "0.59117645", "0.5893539", "0.5887324", "0.5876396", "0.5871836", "0.586933", "0.5864751", "0.58514065", "0.5834766", "0.58075786", "0.5781613", "0.5770981", "0.57557327", "0.5751302", "0.5750825", "0.5742461", "0.57420194", "0.57131666", "0.5713159", "0.5713029", "0.5708164", "0.57022256", "0.56993574", "0.5692786", "0.5687999", "0.56791013", "0.56763446", "0.566689", "0.566367", "0.56595784", "0.56440884", "0.56440544", "0.56427026", "0.5641109", "0.56251365", "0.56251365", "0.5614481", "0.5611991", "0.5608909", "0.56019634", "0.55993295", "0.5593705", "0.5590089", "0.558898", "0.5575289", "0.5575042", "0.55651563", "0.5559566", "0.5559566", "0.5549951", "0.5544407", "0.55426216", "0.5535769", "0.55116034", "0.5510981", "0.5508413", "0.55069506", "0.5505659", "0.55033", "0.54934275", "0.5487954", "0.5486475", "0.5485106", "0.5476313", "0.54693544", "0.5466324", "0.5456408", "0.54524845", "0.5451925", "0.5451598", "0.5451598", "0.54499835", "0.54486185", "0.5433997", "0.54329914" ]
0.7951729
1
Return the name of the tag to tag the release with.
def resolve_tag version = extract_version tag = Release.tag_name || version tag = tag.call(version) if Proc === tag tag end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag_name\n return @tag_name\n end", "def _tag_name\n @tag_name\n end", "def tag_name\n @tag_name ||= name && name.to_s.split(\"::\")[-1].downcase\n end", "def name\n tag.name\n end", "def tagname\n @tagname.id2name\n end", "def getReleaseTag(release)\n return sh(\"git rev-parse qa | xargs git tag --points-at | egrep -v 'qa|prod' | tr -d '\\n'\")\nend", "def name\n _name = nil\n self.tags.each do |x|\n if x.tkey == \"name\"\n _name = x.tvalue\n end\n end\n _name\n end", "def release_name\n return nil unless @data['name'] && @data['version']\n [ dashed_name, @data['version'] ].join('-')\n end", "def tag_name; end", "def tag_name; end", "def tag_name; end", "def tag_name\n self.class.name.downcase.match(/[^:]+$/)[0]\n end", "def name\n tag['name'].gsub(/\\[\\]$/, '')\n end", "def name\n [self[:namespace], self[:short_name]].reject(&:blank?).join(Tag.namespace_separator)\n end", "def tag(name)\n tags[name.to_s] if tags\n end", "def docker_tag_name(name = nil)\n if name\n @docker_tag_name = name\n end\n @docker_tag_name\n end", "def tag_string\n config[:tag_prefix] ? \"#{config[:tag_prefix]}#{@target_version}\" : @target_version.to_s\n end", "def tag\n return @tag\n end", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def tag_name\n ''\n end", "def tag\n @model.tag.name if @model.tag\n end", "def release_name\n FFI::GDAL.GDALVersionInfo('RELEASE_NAME')\n end", "def tagname\n @node[0].gsub(/[^a-zA-Z]/, \"\")\n end", "def extract_resource_name_from_tag\n tags = resource[:tags] ? resource[:tags].map { |k,v| {key: k, value: v} } : []\n tags << {key: 'Name', value: name}\n end", "def tag_release(tag)\n unless this_version == extract_version\n puts \"Committing buildfile with version number #{extract_version}\"\n Perforce.p4 'edit', Rake.application.rakefile.to_s\n Perforce.commit message\n end\n puts \"Tagging release #{tag}\"\n Perforce.p4 'tag', '-l', tag, \"//#{ENV['P4CLIENT']}/...\"\n end", "def release_manifest_name\n \"#{name}-release-manifest\"\n end", "def tag tag_name\n find_element :tag_name, tag_name\n end", "def tag(name); end", "def tagname_symbol\n @tagname\n end", "def get_last_release\n r = api_get(\"/releases\")\n\n return r[0]['tag_name']\nend", "def get_tag_name(element)\n element.tag_name\n end", "def tags_string\n tags.map(&:name).join(\" \")\n end", "def tag_with_name(tag_name, message=\"automated tagging\")\r\n tag_url = build_tag_url_for_base(tag_name)\r\n tag(@repository_trunk, tag_url, message)\r\n end", "def taggable_name string\n string = string.downcase\n case string\n when 'article' then 'wiki article'\n when 'post' then 'blog post'\n else\n string\n end\n end", "def tag\n @tag\n end", "def version_tag\n version_composition.join(\".\")\n end", "def tagging_raw_handle\n name\n end", "def tagging_raw_handle\n name\n end", "def tag\n if @tag.is_a? String\n @tag\n end\n end", "def to_tag_name\n tag_name = if @is_route_engine\n @request.gsub('::', '/').underscore\n else\n @request.split('#').first.singularize\n end\n\n tag_name = tag_name.split('/').last unless use_tag_namespace\n\n tag_name\n end", "def package_name\n @version ? \"#{@name}-#{@version}\" : @name\n end", "def tag_release(version)\n system \"git tag v#{version}\"\n system \"git push origin v#{version}\"\n end", "def tag_name=(_arg0); end", "def package_name(project)\n \"#{project.name}-#{project.version}-#{project.release}.#{@architecture}.pkg.gz\"\n end", "def tag_release(tag)\n unless this_version == extract_version\n puts \"Committing buildfile with version number #{extract_version}\"\n Git.commit File.basename(Rake.application.rakefile.to_s), message\n Git.push if Git.remote\n end\n puts \"Tagging release #{tag}\"\n # Git.git 'tag', '-d', tag rescue nil\n Git.git 'push', Git.remote, \":refs/tags/#{tag}\" rescue nil if Git.remote\n Git.git 'tag', '-f', '-a', tag, '-m', \"[rake_release] Cutting release #{tag}\"\n Git.git 'push', Git.remote, 'tag', tag if Git.remote\n end", "def tag(tag_name)\n Git::Object.new(self, tag_name, 'tag', true)\n end", "def tagName\n ''\n end", "def tag!\n interface.create_tags(tags: [{ key: 'Name', value: name }])\n end", "def use_tag(tag_name)\n raw \"_#{tag_name}\"\n end", "def tag\n `#{@el}.tagName`.downcase\n end", "def tag\n `#{@el}.tagName`.downcase\n end", "def getTag\n\t\treturn @tag\n\tend", "def release_tag_pattern\n\t\tprefix = self.release_tag_prefix\n\t\treturn /#{prefix}\\d+(\\.\\d+)+/\n\tend", "def extract_tag_name(tag)\n match = /\\A<\\/?(#{@@name})/.match(tag)\n return match[1] if match\n raise \"Cannot find tag name in tag: #{tag}\"\n end", "def tag_release(tag)\n unless this_version == extract_version\n info \"Committing buildfile with version number #{extract_version}\"\n Git.commit File.basename(version_file), message\n Git.push if Git.remote\n end\n info \"Tagging release #{tag}\"\n Git.git 'tag', '-d', tag rescue nil\n Git.git 'push', Git.remote, \":refs/tags/#{tag}\" rescue nil if Git.remote\n Git.git 'tag', '-a', tag, '-m', \"[buildr] Cutting release #{tag}\"\n Git.git 'push', Git.remote, 'tag', tag if Git.remote\n end", "def package_name\n # TODO: verify renamed packages\n resource['title']\n end", "def prerelease_tag\n prerelease_regex = if commits_since_tag > 0\n /^\\d+\\.\\d+\\.\\d+(?:-|\\.)([0-9A-Za-z.-]+)-\\d+-g[0-9a-f]+$/\n else\n /^\\d+\\.\\d+\\.\\d+(?:-|\\.)([0-9A-Za-z.-]+)$/\n end\n match = prerelease_regex.match(git_describe)\n match ? match[1] : nil\n end", "def get_tag tag_key_name\n self.tags.joins(:tag_key).where('tagging_tag_keys.name = ?', tag_key_name).first\n end", "def tag_version_task\n sh git, 'tag', '-a', \"#{gemspec.name}-#{gemspec.version}\", '-m', \"Released #{gemspec.name} gem version #{gemspec.version}.\"\n end", "def getName(tags)\n name_tag = tags.find { |tag| tag.key == \"Name\" }\n name_tag ? name_tag.value : nil\nend", "def tag_release(tag)\n unless this_version == extract_version\n info \"Committing buildfile with version number #{extract_version}\"\n Hg.commit File.basename(version_file), message\n Hg.push if Hg.remote\n end\n info \"Tagging release #{tag}\"\n Hg.hg 'tag', tag, '-m', \"[buildr] Cutting release #{tag}\"\n Hg.push if Hg.remote\n end", "def name_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.label.className(create_ats_regex_string(\"ats-namelbl\")), format_method(__method__))\n end", "def latest_stable_tag\n tags = `git tag`.strip.split(\"\\n\").map do |v|\n begin\n Semantic::Version.new(v)\n rescue ArgumentError\n nil\n end\n end.compact.sort.reverse\n (tags.find {|t| !t.pre} || tags.first).to_s\n end", "def tags_names\n\t\t@tags_names ||= self.tags.nil? ? '' : self.tags.collect(&:name).join(' ')\n\tend", "def get_latest_release_tag\n\trooturl = get_svn_repo_root()\n\treleaseurl = rooturl + \"/#{SVN_RELEASES_DIR}\"\n\t\n\ttags = svn_ls( releaseurl ).grep( RELEASE_VERSION_PATTERN ).sort_by do |tag|\n\t\ttag[RELEASE_VERSION_PATTERN].split('.').collect {|i| Integer(i) }\n\tend\n\treturn nil if tags.empty?\n\n\treturn releaseurl + '/' + tags.last\nend", "def tag(name, options = {})\n get_path(\n path_to_tag(name),\n options,\n get_parser(:collection, Tinybucket::Model::Commit)\n )\n end", "def tag_list_name\n self.tag_list if tag_list\n end", "def to_sym\n self.tag\n end", "def name_with_version\n if self.version.nil?\n return name\n else\n return [name, version].join(':')\n end\n end", "def tag(name)\n name.strip!\n tag = Tag.find_or_create_by(name: name)\n self.taggings.find_or_create_by(tag_id: tag.id)\n end", "def full_tag(local_tag, registry)\n \"#{registry}/#{local_tag}\"\n end", "def product_tag\n @product_id ||= node.product_id\n case @product_id\n when /N3K-C35/\n tag = 'n35'\n when /N3/\n tag = Utils.fretta? ? 'n3k-f' : 'n3k'\n when /N5/\n tag = 'n5k'\n when /N6/\n tag = 'n6k'\n when /N7/\n tag = 'n7k'\n when /N9/\n tag = Utils.fretta? ? 'n9k-f' : 'n9k'\n else\n fail \"Unrecognized product_id: #{@product_id}\"\n end\n tag\n end", "def tag_names\n @tag_names ||= tags.map(&:name).join(' ')\n end", "def tagger_format tag\n \"<a href='/tags/#{tag}'>#{tag}</a>\"\n end", "def tag_name\n artist_name\n end", "def yaml_tag_class_name\n self.name\n end", "def tag\n Tag.find(tag_id)\n end", "def repository_name\n @repository_name ||= \"#{project_name}-boshrelease\"\n end", "def tag\n try_opt(:tag)\n end", "def latest_tag\n releases_url = 'https://github.com/david942j/one_gadget/releases/latest'\n @latest_tag ||= url_request(releases_url).split('/').last\n end", "def tag_names\n self.tags.map(&:name).join(\", \")\n end", "def tag; end", "def tag; end", "def tag(t)\n tag = get url: \"tags/#{generate_slug(t)}\", filter: @everything_filter\n tag.tag if tag\n end", "def detailed_name\n \"#{label} ( #{name}_V#{version} )\"\n end", "def to_obj(tag_name)\n @tags.each do |tag|\n if tag_name == tag.name\n Log4r::Logger.log_internal { \"Get tag: #{tag_name}\" }\n return tag\n end\n end\n nil\n end", "def tag_name_fields\n Tag::TAGGABLE_TYPES.map do |tag_type|\n \"#{tag_type.humanize.pluralize}.name\"\n end + [\"tags.name\", \"meta_tags.name\"]\n end", "def release\n @release ||= ENV[\"RELEASE\"] || \"1\"\n end", "def tag_name(locator)\n find_element(locator).tag_name\n end", "def tag\n end", "def tag\n end", "def tag(tag)\n @tagname = tag\n end", "def kind() @tag.sub( /_.*/, '' ) end", "def kind() @tag.sub( /_.*/, '' ) end", "def element_name() @stag.element_name end", "def tag_names\n self.tags.map{ |t| t.name }.join(\", \")\n end", "def package_name(buildno=nil)\n if buildno\n buildno = Time.now.strftime(\"%H*60+%M\")\n versnum = \"#{version}.#{buildno}\"\n else\n versnum = version\n end\n\n if platform\n \"#{name}-#{versnum}-#{platform}\"\n else\n \"#{name}-#{versnum}\"\n end\n end", "def tag(arg)\n @tag = arg.to_s\n self\n end", "def find_name_tag(tags)\n name_tag = tags.find { |tag| tag[:key] == \"Name\" }\n name_tag ? name_tag[:value] : nil\n end" ]
[ "0.7451726", "0.736835", "0.73360884", "0.7268493", "0.71349627", "0.705389", "0.6893099", "0.6864708", "0.678296", "0.678296", "0.678296", "0.67488974", "0.67329144", "0.67293864", "0.6674817", "0.6633394", "0.66200745", "0.6561663", "0.65083766", "0.6489976", "0.64248496", "0.64243275", "0.64216554", "0.6396791", "0.63883513", "0.6357016", "0.6320019", "0.63074654", "0.62808055", "0.627763", "0.6243563", "0.62184656", "0.619649", "0.61593604", "0.61528623", "0.61395425", "0.6139081", "0.6139081", "0.6123428", "0.61184734", "0.6114607", "0.6107224", "0.60701317", "0.60019994", "0.59996337", "0.5991852", "0.5991192", "0.59794986", "0.5972549", "0.5950631", "0.5950631", "0.59417707", "0.5927385", "0.59183586", "0.59130114", "0.5910808", "0.5900413", "0.58658636", "0.58505744", "0.58469325", "0.58452344", "0.5820546", "0.5807498", "0.57851005", "0.5782149", "0.5770582", "0.5761655", "0.5744018", "0.5743286", "0.5742542", "0.57271403", "0.57128555", "0.5706346", "0.570457", "0.5698941", "0.56916755", "0.56909215", "0.569057", "0.56843585", "0.5683602", "0.5681519", "0.56722116", "0.56722116", "0.56710917", "0.5670327", "0.56618106", "0.56538355", "0.56451756", "0.5640868", "0.56399375", "0.56399375", "0.563931", "0.56381536", "0.56381536", "0.56260073", "0.56190735", "0.560825", "0.5601104", "0.5599858" ]
0.69965696
7
Return the new value of THIS_VERSION based on the version passed. This method receives the existing value of THIS_VERSION
def resolve_next_version(current_version) next_version = Release.next_version next_version ||= lambda { |v| snapshot = v.match(/-SNAPSHOT$/) version = v.gsub(/-SNAPSHOT$/, "").split(/\./) if snapshot version[-1] = sprintf("%0#{version[-1].size}d", version[-1].to_i + 1) + '-SNAPSHOT' end version.join('.') } next_version = ENV['NEXT_VERSION'] if ENV['NEXT_VERSION'] next_version = ENV['next_version'] if ENV['next_version'] next_version = next_version.call(current_version) if Proc === next_version next_version end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_version\n @version = Time.now.to_i\n end", "def set_version\n self.version ||= latest_version + 1\n end", "def version value = nil\n return @version if value.nil?\n @version = value\n end", "def version(version = nil)\n @version = version if version\n @version\n end", "def version(value = nil)\n if value.nil?\n @version\n else\n @version = value\n end\n end", "def current_version\n self._version ||= 0\n end", "def current_version\n version_number rev\n end", "def set_version(version = nil)\n begin\n if (defined?(version) && not(version.nil? ))\n then\n return version\n else\n return Settings[:CURRENT_VERSION]\n end\n rescue\n return Settings[:CURRENT_VERSION]\n end\n end", "def version\n @version.dup\n end", "def version\n @version.dup\n end", "def version\n @version ||= create_version\n end", "def version=(v)\n @version = v\n end", "def get_version(version)\n unless version > 0\n raise OcflTools::Errors::NonCompliantValue, \"Requested value '#{version}' for object version does not comply with specification.\"\n end\n if @versions.key?(OcflTools::Utils.version_int_to_string(version))\n @versions[OcflTools::Utils.version_int_to_string(version)]\n else\n # Otherwise, construct a new Version [Hash] and return that.\n @versions[OcflTools::Utils.version_int_to_string(version)] = create_version_hash\n\n # If version -1 exists, copy prior version state over.\n if @versions.key?(OcflTools::Utils.version_int_to_string(version - 1))\n @versions[OcflTools::Utils.version_int_to_string(version)]['state'] = OcflTools::Utils.deep_copy(@versions[OcflTools::Utils.version_int_to_string(version - 1)]['state'])\n end\n\n @versions[OcflTools::Utils.version_int_to_string(version)]\n end\n end", "def current_version\n @version\n end", "def version=(arg)\n @version = arg.to_s\n end", "def version s=nil; @version = s if s; @version end", "def version\n @version ||= '1.0'\n end", "def set(new_version)\n self.version = new_version\n end", "def version\n return last_version if versionable?\n version_number\n end", "def _version\n special_attribute('@version'.freeze)\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version\n return @version unless @version.nil?\n @version = @config_source['version'] || maven_version() || 'unknown' \n @version.gsub!(/revision/, current_revision.to_s) \n @version\n end", "def version(arg=nil)\n arg.nil? ? @version : (@version = arg)\n end", "def version\n\t\treturn @version ||= self.find_version\n\tend", "def version\n @version ||= __determine_version\n end", "def version\n next_version\n end", "def version_number\n @version\n end", "def version_number\n @version ||= nil\n end", "def current_version\n versions.first\n end", "def version\n @version ||= '1.0'\n end", "def version\n version_property ? version_property.ruby_value : nil\n end", "def version\n @version ||= config(\"version\", \"0.0.1\")\n end", "def version\n @version ||= data.version\n end", "def get_version\n\t\tend", "def version(arg = nil)\n set_or_return(:version, arg, kind_of: String, default: 'latest')\n end", "def version(arg = nil)\n set_or_return(:version, arg, kind_of: String, default: 'latest')\n end", "def version\n @version || 0\n end", "def default_version; end", "def ver\n @values.fetch('ver') { \n @values['ver'] = 1\n }\n end", "def version\n self[:version]\n end", "def version_number\n return @version_number\n end", "def set_version(value)\n if value.nil?\n @version = 'latest'\n else\n return skip_resource 'Invalid character in version' unless value.to_s =~ /^(latest|[\\d\\.-]+)$/\n @version = value\n end\n end", "def real_version\n @real_version ||= fetcher.version_for_cache || version\n end", "def set_version revision\n # this call is idempotent for a given kudu run\n return if version_updated\n if /\\d+\\.\\d+\\.\\d+/ =~ revision\n self.version = revision\n else\n major_minor_file = File.join(directory, 'MAJOR_MINOR_VER')\n major_minor = File.exist?(major_minor_file) ? IO.read(major_minor_file) : '1.0'\n self.version = major_minor + \".\" + revision\n end\n ver_file = File.join(directory, 'VERSION')\n IO.write(ver_file, self.version)\n end", "def version=(version)\n @version = version\n end", "def version=(version)\n mutate_config(:version) { version.dup }\n end", "def default_version=(v)\n @default_version = v\n end", "def app_version=(value)\n @app_version = value\n end", "def app_version=(value)\n @app_version = value\n end", "def target_version=(_arg0); end", "def __assign_version(data)\n data[self.class::VERSION_MEMBER] = self.class::VERSION_NUMBER\n end", "def choose_version(version)\n if version =~ /(\\d+)\\.(\\d+)\\.(\\d+)/\n major = $1\n minor = $2\n patch = $3\n if config[:major]\n major = major.to_i + 1\n minor = 0\n patch = 0\n end\n if config[:minor]\n minor = minor.to_i + 1\n patch = 0\n end\n patch = patch.to_i + 1 if config[:patch]\n version = \"#{major}.#{minor}.#{patch}\"\n Chef::Log.debug(\"New version is #{version}\")\n else\n Chef::Log.error(\"Version is in a format I cannot auto-update\")\n exit 1\n end\n version\n end", "def version=(_arg0); end", "def version=(_arg0); end", "def version=(_arg0); end", "def version=(_arg0); end", "def version=(_arg0); end", "def setVersion(version)\r\n\t\t\t\t\t@version = version\r\n\t\t\t\tend", "def version(arg = nil)\n set_or_return(:version,\n arg,\n kind_of: String,\n default: 'latest',\n callbacks: {\n \"Valid versions are 'latest' or 'x.y.z'\" =>\n ->(a) { valid_version?(a) }\n })\n end", "def update_version_method(version)\nend", "def version_number=(value)\n @version_number = value\n end", "def get_version()\n\t\tend", "def ver=(value)\n if value == @defaults['ver']\n @values.delete 'ver' if @values.key? 'ver'\n else\n @values['ver'] = value\n end\n end", "def current_version\n self.historical? ? self.class.find(self.id) : self\n end", "def current_version\n self.historical? ? self.class.find(self.id) : self\n end", "def version=(value)\n @children['version'][:value] = value\n end", "def version=(value)\n @children['version'][:value] = value\n end", "def getVersion\r\n\t\t\t\t\treturn @version\r\n\t\t\t\tend", "def version\n new_resource.version || latest_version\n end", "def version\n LOG_STAT()\n id = id_gen()\n LOG_CALL(id, true, __method__)\n defer { LOG_CALL(id, false, 'version') }\n return VERSION\n end", "def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end", "def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end", "def set_new_version\n @saving_version = new_record? || save_version?\n self.send(\"#{self.class.version_column}=\", next_version) if new_record? || (!locking_enabled? && save_version?)\n end", "def version\n @version\n end", "def version\n @table[:version] ||= Version::Number.new('0.0.0')\n end", "def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end", "def version_number\n \"#{self.major}.#{self.minor}\"\n end", "def version\n '1.5.1.2' # Version number <major>.<minor>.<patch>.<monthly commit>\n end", "def logical_version_number\n @logical_version_number || self.current_version\n end", "def version(ver)\n Runner.instance.version = ver\n end", "def update_version\n multi_stack? && v2_endpoint? ? 'v2' : 'v1'\n end", "def versioned(version)\n version_named(version.to_sym)\n end", "def version=(version)\n @version = Gem::Version.create(version)\n # skip to set required_ruby_version when pre-released rubygems.\n # It caused to raise CircularDependencyError\n if @version.prerelease? && (@name.nil? || @name.strip != \"rubygems\")\n self.required_rubygems_version = '> 1.3.1'\n end\n invalidate_memoized_attributes\n\n return @version\n end", "def version_helper=(_arg0); end", "def version_helper=(_arg0); end", "def version_helper=(_arg0); end", "def patch_version\n @version_helper.patch\n end", "def patch_version\n @version_helper.patch\n end", "def patch_version\n @version_helper.patch\n end", "def current_version\n v = nil\n v = (self.class.name.split(\"::\").first(2).join(\"::\") + '::VERSION').constantize unless defined?((self.class.name.split(\"::\").first(2).join(\"::\") + '::VERSION').constantize.to_s).nil?\n env['tracking'].current_version = v\n return v\n end", "def version\n @version ||= if token.nil? || Array(packages).empty?\n '0.1.0'\n else\n packages.map do |p|\n Gem::Version.new(p['version'])\n end.sort.last.bump.to_s << '.0'\n end\n end", "def version\n build_string\n end", "def current_version\n versions.current_versions.first\n end" ]
[ "0.7604738", "0.7596295", "0.7528393", "0.7474805", "0.7422443", "0.7383106", "0.7378605", "0.7223136", "0.7203363", "0.7203363", "0.7195645", "0.7177888", "0.717154", "0.71639985", "0.71573514", "0.71052223", "0.7053746", "0.7041835", "0.7016261", "0.7011862", "0.70042044", "0.70042044", "0.70042044", "0.70042044", "0.70042044", "0.70042044", "0.70042044", "0.70042044", "0.70042044", "0.69961625", "0.69860405", "0.6980602", "0.6959524", "0.6938041", "0.68716556", "0.68642724", "0.68466264", "0.68355", "0.6830533", "0.6818249", "0.68119967", "0.6806043", "0.6788458", "0.6788458", "0.6786457", "0.6779475", "0.67355597", "0.6734199", "0.67252487", "0.6717876", "0.6705853", "0.6691781", "0.6681417", "0.66415876", "0.66413283", "0.6639204", "0.6639204", "0.66257834", "0.6621174", "0.66152143", "0.6598808", "0.6598808", "0.6598808", "0.6598808", "0.6598808", "0.6598789", "0.658115", "0.65708184", "0.6551537", "0.6544538", "0.6541508", "0.6539122", "0.6539122", "0.65176815", "0.65176815", "0.6503368", "0.65006906", "0.649759", "0.6491931", "0.6491931", "0.6490354", "0.64785784", "0.6466782", "0.6463459", "0.6461907", "0.6446248", "0.64390725", "0.643671", "0.64344037", "0.6424459", "0.64213276", "0.64161664", "0.64161664", "0.64161664", "0.64030665", "0.64030665", "0.64030665", "0.63939154", "0.6393104", "0.6392593", "0.6392337" ]
0.0
-1
Move the version to next and save the updated buildfile
def update_buildfile buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT resolve_next_version(this_version) # THIS_VERSION } File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end", "def update_version_to_next\n super\n info \"Current version is now #{extract_version}\"\n Hg.commit File.basename(version_file), message\n Hg.push if Hg.remote\n end", "def bump\n parts = new_version\n text = '\\1' + [\"MAJOR = #{parts[:major]}\",\n \"MINOR = #{parts[:minor]}\",\n \"PATCH = #{parts[:patch]}\",\n \"BUILD = #{parts[:build] || 'nil'}\"].join('\\1')\n\n out_data = File.read(@filename).gsub(PATTERN, text)\n # puts out_data\n File.open(@filename, 'w') { |out| out << out_data }\n puts \"Bumped version to #{self}\"\n end", "def increment_version_code()\n path = '../app/build.gradle'\n re = /versionCode\\s+(\\d+)/\n \n s = File.read(path)\n versionCode = s[re, 1].to_i\n s[re, 1] = (versionCode + 1).to_s\n \n f = File.new(path, 'w')\n f.write(s)\n f.close\n end", "def update_version_file\n version_file = @spec.version_file\n updated_version = Olag::Version::update(version_file)\n abort(\"Updated gem version; re-run rake\") if @spec.version.to_s != updated_version\n end", "def update_version_file(version)\n if File.exists?('VERSION')\n File.open('VERSION', 'w') { |f| f << version.to_s }\n modified_files << 'VERSION'\n end\n end", "def updateVersion\n # We add 1 because the next commit is probably one more - though this is a race\n commits = %x[git log #{$0} | grep '^commit ' | wc -l].to_i + 1\n vers = \"1.%0.3d\" % commits\n\n t = File.read($0)\n t.gsub!(/^MYVERSION = '(.*)'$/, \"MYVERSION = '#{vers}'\")\n bak = $0+'.bak'\n File.open(bak,'w') { |f| f.puts t }\n perm = File.stat($0).mode & 0xfff\n File.rename(bak,$0)\n File.chmod(perm,$0)\n exit\nend", "def rebuild_version name, version\n FileUtils.mkdir_p @temp_root\n auto = automation_by_name(name)\n if auto\n version = SDocSite::Version.new(version)\n version = auto.available_versions.find {|v| v == version }\n build_version auto, version if version\n else\n debug_msg \"Can't find automation for #{name}\"\n end\n clean_up\n end", "def update_android_version()\n version = ARGV[2]\n result = File.read('android/app/build.gradle')\n result = result.gsub(/(?<=versionCode\\s)\\d+/, version.gsub(/\\./, ''))\n result = result.gsub(/(?<=versionName\\s\")\\d+\\.\\d+.\\d+/, version)\n File.write('android/app/build.gradle', result)\nend", "def versionbump(workdir = nil)\n version = ENV['VERSION'] || Pkg::Config.version.to_s.strip\n new_version = '\"' + version + '\"'\n\n version_file = \"#{workdir ? workdir + '/' : ''}#{Pkg::Config.version_file}\"\n\n # Read the previous version file in...\n contents = IO.read(version_file)\n\n # Match version files containing 'VERSION = \"x.x.x\"' and just x.x.x\n if version_string = contents.match(/VERSION =.*/)\n old_version = version_string.to_s.split[-1]\n else\n old_version = contents\n end\n\n puts \"Updating #{old_version} to #{new_version} in #{version_file}\"\n if contents.match(\"@DEVELOPMENT_VERSION@\")\n contents.gsub!(\"@DEVELOPMENT_VERSION@\", version)\n elsif contents.match('version\\s*=\\s*[\\'\"]DEVELOPMENT[\\'\"]')\n contents.gsub!(/version\\s*=\\s*['\"]DEVELOPMENT['\"]/, \"version = '#{version}'\")\n elsif contents.match(\"VERSION = #{old_version}\")\n contents.gsub!(\"VERSION = #{old_version}\", \"VERSION = #{new_version}\")\n elsif contents.match(\"#{Pkg::Config.project.upcase}VERSION = #{old_version}\")\n contents.gsub!(\"#{Pkg::Config.project.upcase}VERSION = #{old_version}\", \"#{Pkg::Config.project.upcase}VERSION = #{new_version}\")\n else\n contents.gsub!(old_version, Pkg::Config.version)\n end\n\n # ...and write it back on out.\n File.open(version_file, 'w') { |f| f.write contents }\n end", "def next_version\n work.next_version\n end", "def bumpBuild()\n\t\t\t\t@build += 1\n\t\t\tend", "def next_version #:nodoc:\n parts = version.split('.')\n parts[-1] = (parts[-1].to_i + 1).to_s\n parts.join('.')\n end", "def next_version\n (self.class.directories(original_destination).size + 1).to_s\n end", "def bump_minor_version; end", "def update!\n if path = vendorized?\n type = File.symlink?(path) ? :symlink : :copy\n FileUtils.rm_rf normalize(:lib)\n send \"vendorize_with_#{type}\"\n say \"updated #{type} #{path} -> #{program(:version)}\"\n else\n ['dom.html', 'rhino.js', 'node.js'].each do |path|\n path = normalize path\n next unless File.exists? path\n contents = File.read(path).gsub /jspec-(\\d+\\.\\d+\\.\\d+)/, \"jspec-#{program(:version)}\"\n if program(:version) == $1\n say \"skipping #{path}; already #{$1}\"\n next\n end\n File.open(path, 'r+'){ |file| file.write contents } \n say \"updated #{path}; #{$1} -> #{program(:version)}\"\n end\n end\n end", "def bump_major_version; end", "def update_version_constant(version)\n if main_include && File.exist?(main_include)\n file_contents = File.read(main_include)\n if file_contents.sub!(/^(\\s+VERSION\\s*=\\s*)[^\\s].*$/) { $1 + version.to_s.inspect }\n File.open(main_include, 'w') { |f| f << file_contents }\n modified_files << main_include\n end\n end\n end", "def update_specfiles(version)\n spec_files.each do |spec_file|\n spec = File.read(spec_file)\n spec.gsub!(/^(\\s*)Version:(\\s*).*$/, \"\\\\1Version:\\\\2#{version}\")\n File.write(spec_file, spec)\n end\nend", "def bumpMinor()\n\t\t\t\t@minor += 1\n\t\t\t\t@build = 0\n\t\t\tend", "def update_version(new_version)\n contents = File.read(@gradle_properties)\n contents = contents.gsub(/(version[=:])#{@version}/, \"\\\\1#{new_version}\")\n File.open(@gradle_properties, 'w') { |file| file.write(contents) }\n end", "def update_version_and_write_to_version_file(version) #:nodoc:\n contents = File.read(version_file)\n if match = contents.match(version_pattern)\n old_version_line = match[0]\n new_version_line = old_version_line.sub(match[1], version)\n contents.sub! old_version_line, new_version_line\n File.open(version_file, 'wb') { |io| io.write(contents) }\n else\n fail \"Project version not found in #{version_file} (pattern: %p).\" % version_pattern\n end\n end", "def next_version\n # x.y.z\n v = version.split '.'\n # bump z\n v[-1] = v[-1].to_i + 1\n v.join '.'\nend", "def bump_version(version_bump_type)\n parse_bower\n @current_version = @bower_file[\"version\"]\n versions = @current_version.split('.').map(&:to_i)\n \n case version_bump_type\n when \"patch\"\n versions[2] += 1\n when \"minor\"\n versions[1] += 1\n versions[2] = 0\n when \"major\"\n versions[0] += 1\n versions[1] = 0\n versions[2] = 0\n else\n raise \"UnknownVersionType\"\n end\n @next_version = versions.join('.')\n end", "def rollback_version(version)\n FileUtils.copy(@media_asset.fs_path(:version => version.to_s), \n @media_asset.fs_path())\n if @media_asset.has_preview? then\n @@variants.keys.each { |v| \n FileUtils.move(@media_asset.fs_path(:size => v), \n @media_asset.fs_path(:size => v, :version => @media_asset.version.to_s))\n FileUtils.copy(@media_asset.fs_path(:size => v, :version => version.to_s), \n @media_asset.fs_path(:size => v))\n }\n end\n end", "def replace_project_versions proj_files\r\n\r\n begin\r\n # iterate each package file, replace version numbers and save\r\n proj_files.each{ |file|\r\n puts \"Updating references in: #{file}...\"\r\n doc = Nokogiri::XML File.read file\r\n nodes = doc.search 'Reference'\r\n nodes.each { |node|\r\n ref_val = node['Include']\r\n # grab the identifier\r\n id = ref_val.split(',')[0]\r\n # clean out file version\r\n node['Include'] = id\r\n\r\n # replace version in hint path\r\n hint_path = node.search 'HintPath'\r\n if hint_path && hint_path[0] != nil\r\n hint_path_value = hint_path[0].children.to_s\r\n # this identifier is not the same as the node['Include'] one.\r\n # For ex., Runtime, Core and Storage assemblies will be referred to from within other packages like Management, Test etc\r\n hint_path_id = id_from_hint_path hint_path_value\r\n if @versions.has_key? hint_path_id\r\n hint_path_parts = hint_path_value.split '\\\\'\r\n hint_path_parts[2] = hint_path_id + GlobalConstants::DOT + @versions[hint_path_id]\r\n hint_path[0].children = hint_path_parts.join '\\\\'\r\n end\r\n end\r\n }\r\n File.write file, doc.to_xml\r\n }\r\n rescue\r\n puts $!\r\n return false\r\n end\r\n\r\n return true\r\n\r\n end", "def get_next_build_step\n @build_step += 1\n end", "def increment_version_code(options={})\n version_code_regex = /versionCode\\s+(\\d+)/\n\n # This path structure assumes we have seperate ios and android fastlane setups (android/fastlane)\n Dir.glob(\"../**/app/build.gradle\") do |path|\n UI.message(\" -> Found a build.gradle file at path: (#{path})!\")\n build_gradle = File.read(path)\n current_version_code = build_gradle[version_code_regex, 1].to_i\n new_version_code = options[:version_code] || current_version_code + 1\n UI.message(\" -> Setting versionCode to: #{new_version_code}\")\n build_gradle[version_code_regex, 1] = new_version_code.to_s\n\n f = File.new(path, 'w')\n f.write(build_gradle)\n f.close\n end\n end", "def increase_version version\n puts 'increased'\n new_version = \"#{version[1]}.#{version[2]}.#{version[3]}.\" +\n \"#{version[4].to_i + 1}\"\n end", "def migrate_version!\n current_version = @options[:language_version]\n current_version_index = SassSpec::LANGUAGE_VERSIONS.index(current_version)\n if current_version_index == 0\n puts \"Cannot migrate test. There's no version earlier than #{current_version}.\"\n return\n end\n\n start_version_index = SassSpec::LANGUAGE_VERSIONS.index(\n @test_case.metadata.start_version.to_s)\n\n if start_version_index >= current_version_index\n puts \"Cannot migrate test. Test does not apply to an earlier version.\"\n return\n end\n\n previous_version = SassSpec::LANGUAGE_VERSIONS[current_version_index - 1]\n\n new_folder = @test_case.folder + \"-#{current_version}\"\n\n if File.exist?(new_folder)\n choice = interact(:migrate_over_existing, :abort) do |i|\n i.prompt(\"Target folder '#{new_folder}' already exists.\")\n\n i.choice('x', \"Don't migrate the test.\") do\n return\n end\n\n i.choice('O', \"Remove it.\") do\n unless delete_dir!(new_folder)\n i.restart!\n end\n end\n end\n\n if choice == :abort\n puts \"Cannot migrate test. #{new_folder} already exists.\"\n return\n end\n end\n\n FileUtils.cp_r @test_case.folder, new_folder\n\n new_test_case = SassSpec::TestCase.new(new_folder, @options)\n change_options(end_version: previous_version)\n change_options(new_test_case.options_path, start_version: current_version)\n\n overwrite_test!(new_test_case)\n end", "def bump_patch_version; end", "def bump_minor\n @minor += 1\n @patch = 0\n self.save\n end", "def after_source_download\n Dir.chdir cachedir/name do\n sh \"git checkout #{version}\"\n sh 'git submodule update --init'\n end\n end", "def upgrade(version)\n \n end", "def redo!\n version = log_data.next_version\n return false if version.nil?\n\n switch_to!(version.version)\n end", "def up_version(version)\n while true do\n ui.info(\"Trying to deploy version #{version}\")\n if @versions.include?(version)\n ui.info(\"Version #{version} is already in chef\")\n vt = choose_version(version)\n ui.confirm(\"Shall I bump the version to #{vt} (No to Cancel)\")\n version = choose_version(version)\n else\n break\n end\n end\n version\n end", "def bump\n parts = parse_parts_from_version_string\n parts.pop while parts.any? { |part| part.alpha? }\n parts.pop if parts.size > 1\n parts[-1] = parts[-1].succ\n self.class.new(parts.join(\".\"))\n end", "def bazel_update(from_version, to_version)\n upgrade_description = \"Update the bazel version #{from_version.nil? ? '' : \"from #{from_version} \"}to #{to_version}\"\n desc upgrade_description\n command(:\"patch_bazel_version_to_#{to_version}\") do |app|\n patched = patch_file('.bazelversion') do |content|\n from_version.nil? ? \"#{to_version}\\n\" : content.gsub(from_version, to_version)\n end\n if patched\n mysystem(\"git commit -m \\\"#{upgrade_description}\\\"\")\n end\n end\n end", "def version_task\n update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']\n update_gemspec(:date, Date.today)\n\n update_version_file(gemspec.version)\n update_version_constant(gemspec.version)\n end", "def update_app_version_numbers()\n \n version_string = ENV[\"FORCED_VERSION_NUMBER_STRING\"]\n xcode_project_version = nil\n \n if version_string != nil && version_string.length > 0\n\n puts \"using forced version \\\"#{version_string}\\\"\"\n\n else\n\n version_string = get_semver_from_branch\n\n if version_string == nil\n\n app_store_build_number(live: false)\n latest_app_store_version = lane_context[SharedValues::LATEST_VERSION]\n xcode_project_version = get_project_xcode_version\n\n # use largest version (note ascii comparison - not sure if accurate enough)\n version_string = latest_app_store_version > xcode_project_version ? latest_app_store_version : xcode_project_version\n puts \"using version #{version_string} (latest app store = #{latest_app_store_version}, project version = #{xcode_project_version})\"\n\n end\n\n end\n\n # increment build number\n forced_build_number = ENV[\"FORCED_BUILD_NUMBER\"]\n unless forced_build_number == nil || forced_build_number.empty?\n puts \"using forced build number \\\"#{forced_build_number}\\\"\"\n build_number = forced_build_number\n increment_build_number(build_number: build_number)\n else\n current_build_number = latest_testflight_build_number(version: version_string, initial_build_number: 0)\n\n if current_build_number == 0\n if m = version_string.match($semver_regex)\n # if no existing number was found we need to check variations of the same version\n # since Apple handles 1, 1.0, and 1.0.0 independently, but they share build number\n puts \"build number is 0 - checking version variations in case there's a match\"\n\n major = m.captures[0]\n minor = m.captures[1]\n patch = m.captures[2]\n\n puts \"major=#{major} minor=#{minor} patch=#{patch}\"\n if patch == \"0\"\n variation = \"#{major}.#{minor}\"\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n \n if current_build_number == 0 && minor == \"0\"\n variation = major\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n end\n end\n else\n UI.important \"build number is 0 and version is not semantically correct - unable to check version variations (build number may be incorrect)\"\n end\n \n end\n\n build_number = current_build_number + 1\n increment_build_number(build_number: build_number)\n end\n\n # set version number\n current_version_string = xcode_project_version || get_project_xcode_version\n increment_version_number(version_number: version_string)\n\n\n puts \"build_number #{current_build_number} => #{build_number}\"\n puts \"version_number #{current_version_string} => #{version_string}\"\n end", "def update_project(from_version, to_version, tx)\n Installer.copy(tx, \"#{@service_dir}/pieces/public\", get_path(:web))\n true\n end", "def make\n @this_version = extract_version\n check\n with_release_candidate_version do |release_candidate_buildfile|\n args = []\n args << 'buildr' << '--buildfile' << release_candidate_buildfile\n args << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?\n args << 'clean' << 'upload' << 'DEBUG=no'\n sh *args\n end\n tag_release resolve_tag\n update_version_to_next if this_version != resolve_next_version(this_version)\n end", "def after_packaging\n suffixes = chunk_suffixes\n first_suffix = \"a\" * suffix_length\n if suffixes == [first_suffix]\n FileUtils.mv(\n File.join(Config.tmp_path, \"#{package.basename}-#{first_suffix}\"),\n File.join(Config.tmp_path, package.basename)\n )\n else\n package.chunk_suffixes = suffixes\n end\n end", "def upgrade_version!\n raise \"standard forms should not be versioned\" if is_standard?\n\n if current_version\n self.current_version = current_version.upgrade\n else\n self.build_current_version(:form_id => id)\n end\n\n # since we've upgraded, we can lower the upgrade flag\n self.upgrade_needed = false\n\n # reset downloads since we are only interested in downloads of present version\n self.downloads = 0\n\n save(:validate => false)\n end", "def post_install_actions\n Dir.chdir(@project_name) do\n SemVer.new.save(SemVer::FILE_NAME)\n end\n end", "def migrate(version = nil)\n pending = ->(_) { File.pending.map(&:version).include?(_) }\n migrated = ->(_) { File.migrated.map(&:version).include?(_) }\n\n case version\n when nil\n files = File.pending\n Migrate::Up.new(files).perform\n\n when pending\n files = File.pending.select { |f| f.version <= version }\n Migrate::Up.new(files).perform\n\n when migrated\n files = File.migrated.select { |f| f.version > version }.reverse\n Migrate::Down.new(files).perform\n\n else\n out.puts(\"Invalid Version: #{version} does not exist.\")\n end\n end", "def propagate_version(**args)\n\tversion = get_package_key(key: :version)\n\n\tUI.message \"Propagating version: #{version}\"\n\tUI.message 'into the Info.plist and build.gradle files'\n\n\tnumber = build_number\n\tUI.message \"Version code is #{number}\"\n\n\tversion = \"#{version.split('-')[0]}-pre\" if should_nightly?\n\tUI.message \"Actually putting #{version} into the binaries (because we're doing a nightly)\"\n\n\t# encode build number into js-land --- we've already fetched it, so we'll\n\t# never set the \"+\" into the binaries\n\tunless version.include? '+'\n\t\t# we always want the CI build number in js-land\n\t\tset_package_data(data: { version: \"#{version}+#{number}\" })\n\tend\n\n\tcase lane_context[:PLATFORM_NAME]\n\twhen :android\n\t\tset_gradle_version_name(version_name: version, gradle_path: lane_context[:GRADLE_FILE])\n\t\tset_gradle_version_code(version_code: number, gradle_path: lane_context[:GRADLE_FILE])\n\twhen :ios\n\t\t# we're splitting here because iTC can't handle versions with dashes in them\n\t\tincrement_version_number(version_number: version.split('-')[0], xcodeproj: ENV['XCODE_PROJECT'])\n\t\tincrement_build_number(build_number: number, xcodeproj: ENV['XCODE_PROJECT'])\n\tend\nend", "def write_versionlock_file\n transform_str = \"<transform pkg depend -> default facet.version-lock.*> false>\"\n File.write(\"#{staging_dir}/version-lock\", transform_str)\n end", "def bumpMajor()\n\t\t\t\t@major += 1\n\t\t\t\t@minor = 0\n\t\t\t\t@build = 0\n\t\t\tend", "def set_new_cb_version\n metadata_file = File.join(@cb_path, 'metadata.rb')\n fi = File.read(metadata_file)\n fi.gsub!(/version(\\s+)('|\")#{@cb_version.to_s}('|\")/, \"version\\\\1\\\\2#{@target_version}\\\\3\")\n File.open(metadata_file, 'w') { |file| file.puts fi }\n end", "def replace_version(doc, dir, loc)\n doc.elements.each(loc) do |ele|\n if ele.text.eql? @v1\n puts \"Replacing Version: #{ele} in #{dir}/pom.xml\"\n ele.text = @v2\n end\n end \n end", "def bumpChangelogVersion\n version = versionNumber(most_recent).split(\".\")\n major_version = version[0].to_i\n minor_version = version[1].to_i\n\n changelog = '../CHANGELOG.md'\n new_changelog = changelog + '.new'\n\n new_version = major_version.to_s + \".\" + (minor_version + 1).to_s\n Dir.mkdir '../Changelogs/' + new_version\n sh \"touch ../Changelogs/\" + new_version + \"/.keep\"\n version_bump_text = \"## \" + new_version + \"\\n\" + \"Automatically starting the next sprint, no changes just yet (Replace this line when changes are merged in) \" + \"\\n\\n\"\n\n ensure_git_branch(branch: \"master\")\n git_add(path: \"Changelogs/\" + new_version + \"/.keep\")\n git_commit(path: [\"Changelogs/\" + new_version + \"/.keep\"], message: \"Automatically bumping CHANGELOG version via fastlane\")\n push_to_git_remote(tags: false)\n end", "def propagate_version(**args)\n return unless ENV.key? 'CI'\n\n version = get_package_key(key: :version)\n build = current_build_number(track: args[:track] || nil)\n\n UI.message \"Propagating version: #{version}\"\n UI.message 'into the Info.plist and build.gradle files'\n\n UI.message \"Setting build number to #{build}\"\n\n version = \"#{version.split('-')[0]}-pre\" if should_nightly?\n UI.message \"Actually putting #{version} into the binaries (because we're doing a nightly)\"\n\n # encode build number into js-land – we've already fetched it, so we'll\n # never set the \"+\" into the binaries\n unless version.include? '+'\n # we always want the CI build number in js-land\n set_package_data(data: { version: \"#{version}+#{build}\" })\n end\n\n case lane_context[:PLATFORM_NAME]\n when :android\n set_gradle_version_name(version_name: version, gradle_path: lane_context[:GRADLE_FILE])\n set_gradle_version_code(version_code: build, gradle_path: lane_context[:GRADLE_FILE])\n when :ios\n # we're splitting here because iTC can't handle versions with dashes in them\n increment_version_number(version_number: version.split('-')[0], xcodeproj: ENV['GYM_PROJECT'])\n increment_build_number(build_number: build, xcodeproj: ENV['GYM_PROJECT'])\n end\nend", "def update_app_version_numbers\n version_string = ENV['FORCED_VERSION_NUMBER_STRING']\n xcode_project_version = nil\n\n if !version_string.nil? && version_string.length > 0\n\n puts \"using forced version \\\"#{version_string}\\\"\"\n\n else\n\n version_string = get_semver_from_branch(ENV['GIT_HEAD_REF'])\n\n if version_string.nil?\n\n app_store_build_number(live: false)\n latest_app_store_version = lane_context[SharedValues::LATEST_VERSION]\n xcode_project_version = get_project_xcode_version\n\n # use largest version (note ascii comparison - not sure if accurate enough)\n version_string = latest_app_store_version > xcode_project_version ? latest_app_store_version : xcode_project_version\n puts \"using version #{version_string} (latest app store = #{latest_app_store_version}, project version = #{xcode_project_version})\"\n\n end\n\n end\n\n # increment build number\n forced_build_number = ENV['FORCED_BUILD_NUMBER']\n if forced_build_number.nil? || forced_build_number.empty?\n current_build_number = parse_latest_testflight_build_number(version_string)\n\n if current_build_number == 0\n if m = version_string.match(semver_regex)\n # if no existing number was found we need to check variations of the same version\n # since Apple handles 1, 1.0, and 1.0.0 independently, but they share build number\n puts \"build number is 0 - checking version variations in case there's a match\"\n\n major = m.captures[0]\n minor = m.captures[1]\n patch = m.captures[2]\n\n puts \"major=#{major} minor=#{minor} patch=#{patch}\"\n if patch == '0'\n variation = \"#{major}.#{minor}\"\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n\n if current_build_number == 0 && minor == '0'\n variation = major\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n end\n end\n else\n UI.important 'build number is 0 and version is not semantically correct - unable to check version variations (build number may be incorrect)'\n end\n\n end\n\n build_number = current_build_number + 1\n increment_build_number(build_number: build_number)\n else\n puts \"using forced build number \\\"#{forced_build_number}\\\"\"\n build_number = forced_build_number\n increment_build_number(build_number: build_number)\n end\n\n # set version number\n current_version_string = xcode_project_version || get_project_xcode_version\n increment_version_number(version_number: version_string)\n update_package_version(version_string)\n\n puts \"build_number #{current_build_number} => #{build_number}\"\n puts \"version_number #{current_version_string} => #{version_string}\"\nend", "def build_version(yaml_root, version)\n # yaml_dump = File.join(yaml_root, version.commit.gsub(\"/\", \"-\"))\n # return if File.exist? yaml_dump\n\n version.build\n version.clean\n #File.open(yaml_dump, \"w\") { |f| f.write(Psych.dump(version)) }\n #exit\nend", "def put_build_into_production!(app, version_number)\n begin\n verify_app(app)\n open_app_page(app)\n\n Helper.log.info(\"Choosing the latest build on iTunesConnect for release\")\n\n click_on \"Prerelease\"\n\n wait_for_preprocessing\n\n ################# Apple is finished processing the ipa file #################\n\n Helper.log.info(\"Apple finally finished processing the ipa file\")\n open_app_page(app)\n\n begin\n first('a', :text => BUTTON_ADD_NEW_BUILD).click\n wait_for_elements(\".buildModalList\")\n sleep 5\n rescue\n if page.has_content?\"Upload Date\"\n # That's fine, the ipa was already selected\n return true\n else\n raise \"Could not find Build Button. It looks like the ipa file was not properly uploaded.\"\n end\n end\n\n if page.all('td', :text => version_number).count > 1\n Helper.log.fatal \"There were multiple submitted builds found. Don't know which one to choose. Just choosing the top one for now\"\n end\n\n result = page.first('td', :text => version_number).first(:xpath,\"./..\").first(:css, \".small\").click\n click_on \"Done\" # Save the modal dialog\n click_on \"Save\" # on the top right to save everything else\n\n error = page.has_content?BUTTON_ADD_NEW_BUILD\n raise \"Could not put build itself onto production. Try opening '#{current_url}'\" if error\n\n return true\n rescue => ex\n error_occured(ex)\n end\n end", "def prep_build(version)\n # Reset back to master and ensure the build branch is removed\n %x( cd #{@work_dir} && git checkout -f master && git branch -D build &> /dev/null )\n\n # Checkout version as build branch\n %x( cd #{@work_dir} && git checkout #{version} -b build )\n\n # Clean everything\n %x( cd #{@work_dir} && git clean -f -d -x )\n end", "def deploy!\n write_previous_revision\n update_repository\n write_revision\n end", "def set_version\n self.version ||= latest_version + 1\n end", "def set!(new_version)\n current_spec = IO.read(filename)\n\n new_spec = current_spec.gsub(REGEX) do\n m = Regexp.last_match\n next [m[1], m[3], new_version, m[4], m[6]].join\n end\n\n File.open(filename, 'w') { |f| f.write new_spec }\n end", "def bump_minor_version()\n Juwelier::Commands::Version::BumpMinor.build_for(self).run\n end", "def bump_major_version()\n Juwelier::Commands::Version::BumpMajor.build_for(self).run\n end", "def move_binaries\n Dir.mkdir(RESULT_DIR) unless Dir.exist?(RESULT_DIR)\n changes = Dir.glob(\"#{BUILD_DIR}/../*.changes\")\n\n changes.reject! { |e| e.include?('source.changes') }\n\n unless changes.size == 1\n warn \"Not exactly one changes file WTF -> #{changes}\"\n return\n end\n\n system('dcmd', 'mv', '-v', *changes, 'result/')\n end", "def next\n versionable.versions.next_version( self.number )\n end", "def update\n is_valid_project\n $VERBOSE = !options[:verbose].nil?\n name = File.basename(CURR_DIR)\n project_dir = CURR_DIR\n overwrite_config = !options[:overwrite_config].nil?\n version = options[:version]\n unless version == nil or OK_OBD_VERSIONS.include?(version)\n throw \"Specified version \\\"#{version}\\\" isn't supported.\\nTry one of the following:\\n #{OK_OBD_VERSIONS.join(\"\\n \")}\"\n end\n rebuild = !options[:rebuild].nil?\n download_openbd(version, rebuild) unless version.nil?\n update_project(name, version, false, overwrite_config, true) \n display \"#{name} updated to OpenBD #{version}\" unless version.nil?\n end", "def bump_major\n @major += 1\n @minor = 0\n @patch = 0\n self.save\n end", "def set_version(version, rootdir = Dir.pwd, options = {})\n exit_status = 0\n type = (options[:type]) ? options[:type] : FalkorLib.config[:versioning][:type]\n source = (options[:source]) ? options[:source] : FalkorLib.config[:versioning][:source][ type ]\n versionfile = File.join( rootdir, source[:filename] ) unless source[:filename].nil?\n major, minor, patch = major(version), minor(version), patch(version)\n #tocommit = \"\"\n case type\n when 'file'\n info \"writing version changes in #{source[:filename]}\"\n File.open(versionfile, 'w') { |f| f.puts version } #if File.exist? ( versionfile )\n when 'gem'\n info \"=> writing version changes in #{source[:filename]}\"\n File.open(versionfile, 'r+') do |f|\n text = f.read\n text.gsub!(/^(\\s*)MAJOR\\s*,\\s*MINOR,\\s*PATCH\\s*=\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)(.*)$/,\n '\\1' + \"MAJOR, MINOR, PATCH = #{major}, #{minor}, #{patch}\" + '\\5')\n f.rewind\n f.write(text)\n end\n when 'puppet_module'\n info \"=> writing version changes in #{source[:filename]}\"\n metadata = JSON.parse( IO.read( versionfile ) )\n metadata[\"version\"] = version\n File.open(versionfile, \"w\") do |f|\n f.write JSON.pretty_generate( metadata )\n end\n #exit 1\n end\n if FalkorLib::Git.init?(rootdir)\n filelist = FalkorLib::Git.list_files( rootdir )\n Dir.chdir( rootdir ) do\n next if source[:filename].nil?\n unless filelist.include?( source[:filename] )\n warning \"The version file #{source[:filename]} is not part of the Git repository\"\n answer = ask(\"Adding the file to the repository? (Y|n)\", 'Yes')\n next if answer =~ /n.*/i\n exit_status = FalkorLib::Git.add(versionfile, \"Adding the version file '#{source[:filename]}', inialized to the '#{version}' version\" )\n next\n end\n run %( git diff #{source[:filename]} )\n answer = ask(cyan(\"=> Commit the changes of the version file to the repository? (Y|n)\"), 'Yes')\n next if answer =~ /n.*/i\n run %( git commit -s -m \"bump to version '#{version}'\" #{source[:filename]} )\n exit_status = $?.to_i\n # if (type == 'gem' && File.exists?(File.join(rootdir, 'Gemfile')) )\n # run %{\n # sleep 2\n # bundle update falkorlib\n # git commit -s -m \"Update Gemfile.lock accordingly\" Gemfile.lock\n # } if command?( 'bundle' )\n # end\n end\n end\n exit_status\n end", "def write_version(major, minor, patch, build, _options = T.unsafe(nil)); end", "def remove_version_info name\n add \"find . -maxdepth 1 -name '#{name}*' -a -type d | xargs -I xxx mv xxx #{name}\", check_file(name)\n end", "def update_self\n updated_version = open('https://gist.github.com/raw/857843/C.rb').read\n File.open(__FILE__, 'w+') do |f|\n f.puts updated_version\n end\nend", "def store_version\n path = 'lib/bootstrap/version.rb'\n content = File.read(path).sub(/BOOTSTRAP_SHA\\s*=\\s*['\"][^'\"]*['\"]/, \"BOOTSTRAP_SHA = '#@branch_sha'\")\n File.open(path, 'w') { |f| f.write(content) }\n end", "def update_version\n self.update_attributes(version: self.version + 1)\n new_algorithm = self.deep_copy\n self.update_attributes(next: new_algorithm)\n new_algorithm\n end", "def save\n require 'git'\n git = Git.open('.', :log => Logger.new($stdout))\n git.pull # origin master\n write_version_to_file\n git.add(Version.path)\n git.commit(\"Bump version to #{self}.\")\n git.add_tag(self.to_s)\n git.push('origin', 'master', true) # including tags\n notify_campfire(git)\n rescue LoadError\n raise LoadError, \"You must have the git gem installed to make a release.\"\n end", "def write!\n @manifest.version_code = @version_code\n @manifest.version_name = @version\n @manifest.save!\n end", "def update_component_versions\n logger.info(\n 'Updating component versions',\n project: project_path,\n branch: target_branch\n )\n\n version_files = VERSION_FILES\n\n # Prior to 13.10.0, Workhorse is still a separate component from the\n # Rails application.\n #\n # This check will be removed as part of\n # https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1628.\n if @gitlab_version.major <= 13 && @gitlab_version.minor < 10\n version_files = [Project::GitlabWorkhorse.version_file, *version_files]\n end\n\n branch = ee_stable_branch\n versions = version_files.each_with_object({}) do |file, hash|\n hash[file] = read_version(ee_project_path, file, branch).to_s\n end\n\n commit_version_files(\n target_branch,\n versions,\n message: 'Update component version files'\n )\n end", "def freeze_rails\n new_version = rails_version_to_freeze\n\n version_file = File.join(install_directory,'vendor','rails-version')\n vendor_rails = File.join(install_directory,'vendor','rails')\n \n old_version = File.read(version_file).chomp rescue nil\n \n if new_version == old_version\n return\n elsif old_version != nil\n rm_rf(vendor_rails)\n end\n\n mkdir_p(vendor_rails)\n \n package_map = {\n 'rails' => File.join(vendor_rails,'railties'),\n 'actionmailer' => File.join(vendor_rails,'actionmailer'),\n 'actionpack' => File.join(vendor_rails,'actionpack'),\n 'actionwebservice' => File.join(vendor_rails,'actionwebservice'),\n 'activerecord' => File.join(vendor_rails,'activerecord'),\n 'activesupport' => File.join(vendor_rails,'activesupport'),\n }\n \n specs = Gem.source_index.find_name('rails',[new_version])\n \n unless specs.to_a.size > 0\n raise InstallFailed, \"Can't locate Rails #{new_version}!\"\n end\n \n copy_gem(specs.first, package_map[specs.first.name])\n \n specs.first.dependencies.each do |dep|\n next unless package_map[dep.name]\n \n dep_spec = Gem.source_index.find_name(dep.name,[dep.version_requirements.to_s])\n if dep_spec.size == 0\n raise InstallFailed, \"Can't locate dependency #{dep.name} #{dep.version_requirements.to_s}\"\n end\n \n copy_gem(dep_spec.first, package_map[dep.name])\n end\n \n File.open(version_file,'w') do |f|\n f.puts @@rails_version\n end\n end", "def write_version(major, minor, patch, build, options = {})\n command = Juwelier::Commands::Version::Write.build_for(self)\n command.major = major\n command.minor = minor\n command.patch = patch\n command.build = build\n\n command.run\n end", "def update!\n log(:info, \"Updating source: #{@host}\")\n Downloader.get(specs_url, work_archive_file)\n Unpacker.gzip(work_archive_file)\n FileUtils.mv(work_index_file, index_file)\n end", "def nextVersion(version)\n return version.to_i.next.to_s if !version.include? '.'\n\n top, bottom = version.split('.', 2)\n bottom = bottom.split('.').join\n\n new_bottom = bottom.to_i.next.to_s\n\n if new_bottom.length > bottom.length\n top = top.to_i.next\n new_bottom = new_bottom.chars.drop(1).join\n end\n\n [top, new_bottom.chars.join('.')].join '.'\nend", "def bump_major_version()\n Jeweler::Commands::Version::BumpMajor.build_for(self).run\n end", "def write_version(files = [ScmVersion::VERSION_FILENAME])\n files.each do |ver_file|\n File.open(ver_file, 'w+') do |f| \n f.write self.to_s\n end\n end\n self\n end", "def next_logical_version(increment = 1)\n return false if patchlevel_is_significant?\n split_version = @version_without_patchlevel.split(\".\")\n teeny = split_version.pop\n split_version << teeny.to_i + increment\n split_version.join(\".\")\n end", "def bump_minor_version()\n Jeweler::Commands::Version::BumpMinor.build_for(self).run\n end", "def fixCMakeFiles(st)\n\t# Once things have been added/backedup, we don't need to do this again\n\t#sh \"git add #{st}\"\n\t#sh \"cp #{st} #{st}.bak\"\n\n\t# We don't need to work on backup copies\n\tif st =~ /bak$/\n\t\treturn\n\tend\n\n\tfr = File.open(\"#{st}.bak\", \"r\") \n\tfw = File.open(\"#{st}\", \"w\") \n\tfr.each{ |line|\n\t\tnewline = line.gsub(\"kde4\", \"kde5\")\n\t\tnewline = newline.gsub(\"KDE4\", \"KDE5\")\n\t\tnewline = newline.gsub(\"QT4\", \"QT5\")\n\t\tnewline = newline.gsub(\"qt4\", \"qt5\")\n\t\tputs newline\n\t\tfw.write(newline)\n\t}\n\tfw.close()\n\tfr.close()\nend", "def revert_to version\r\n while !@data.nil? && @data.version > version\r\n @data = @data.prev_version\r\n end\r\n !@data.nil?\r\n end", "def resolve_next_version(current_version)\n next_version = Release.next_version\n next_version ||= lambda { |v|\n snapshot = v.match(/-SNAPSHOT$/)\n version = v.gsub(/-SNAPSHOT$/, \"\").split(/\\./)\n if snapshot\n version[-1] = sprintf(\"%0#{version[-1].size}d\", version[-1].to_i + 1) + '-SNAPSHOT'\n end\n version.join('.')\n }\n next_version = ENV['NEXT_VERSION'] if ENV['NEXT_VERSION']\n next_version = ENV['next_version'] if ENV['next_version']\n next_version = next_version.call(current_version) if Proc === next_version\n next_version\n end", "def nextVersion(version)\n\n current_version = version.split('.').reverse;\n new_version = [];\n\n if version.split('.').length == 1\n (version.to_i + 1).to_s\n else\n current_version.map.with_index do |n,i|\n if i == 0\n new_n = (n.to_i + 1).to_s\n if new_n == '10'\n new_version.push('0')\n current_version[i+1] = (current_version[i+1].to_i + 1).to_s\n else\n new_version.push(new_n)\n end\n else\n if n == '10'\n if i == (current_version.length - 1)\n new_version.push(n)\n else\n new_version.push('0')\n current_version[i+1] = (current_version[i+1].to_i + 1).to_s\n end\n else\n new_version.push(n)\n end\n end\n end\n new_version.reverse.join('.')\n end\n\nend", "def move(options = {})\n self.class.move(self.version_key, options)\n end", "def updated_source_file; end", "def add_version(version); GuidesGenerator::Migrator::migrated_versions.push(version); version end", "def nextVersion\n newRevision(@year, @month, @revCount.nil? ? 1 : @revCount + 1)\n end", "def choose_version(version)\n if version =~ /(\\d+)\\.(\\d+)\\.(\\d+)/\n major = $1\n minor = $2\n patch = $3\n if config[:major]\n major = major.to_i + 1\n minor = 0\n patch = 0\n end\n if config[:minor]\n minor = minor.to_i + 1\n patch = 0\n end\n patch = patch.to_i + 1 if config[:patch]\n version = \"#{major}.#{minor}.#{patch}\"\n Chef::Log.debug(\"New version is #{version}\")\n else\n Chef::Log.error(\"Version is in a format I cannot auto-update\")\n exit 1\n end\n version\n end", "def upgrade_version!\n if current_version\n self.current_version = current_version.upgrade\n else\n self.build_current_version(:form_id => id)\n end\n \n # since we've upgraded, we can lower the upgrade flag\n self.upgrade_needed = false\n \n save(:validate => false)\n end", "def bump_it_to(version:)\n Bump::Bump.run(version.to_s, commit: false, bundle: false, tag: false)\n $current_version = Bump::Bump.current\n say(\"Bumped to version: #{$current_version}!\".bold)\nend", "def next_revision_number(existing_model)\n existing_model.revision_number + 1\n end", "def copy_to_version(version)\n# backup_existing_file #always backup the current file and move it out of the way\n if self.options[:copy_to_versions] == false\n self\n else\n copy = self.clone\n copy.suffix = version\n \n if copy_file(File.join(self.dir, copy.filename))\n return copy\n end\n end\n end", "def update_build_number(build_number)\n result = ''\n client = Helpers.create_aws_ec2_client\n client.create_tags(dry_run: false,\n resources: [@aws_instance_data.instance_id],\n tags: [{ key: 'Build-Number', value: build_number }])\n result += run_ssh_command(\"echo #{build_number} | sudo tee /home/bz-app/build_number.txt\")\n result += run_ssh_command(\"sudo service #{@repository} restart\")\n result\n end", "def deintegrate_if_different_major_version\n return unless lockfile\n return if lockfile.cocoapods_version.major == Version.create(VERSION).major\n UI.section('Re-creating CocoaPods due to major version update.') do\n projects = Pathname.glob(config.installation_root + '*.xcodeproj').map { |path| Xcodeproj::Project.open(path) }\n deintegrator = Deintegrator.new\n projects.each do |project|\n config.with_changes(:silent => true) { deintegrator.deintegrate_project(project) }\n project.save if project.dirty?\n end\n end\n end", "def commit_new_cb_version\n shellout('git add metadata.rb')\n @gitrepo.commit_index(\"release v#{@target_version}\")\n end", "def update_version\n if (VersionControl.any?) \n obj = VersionControl.all.first\n else\n obj = VersionControl.create(version: 3.0)\n end\n\n obj.version += 0.1\n obj.save\n end" ]
[ "0.77271146", "0.7209762", "0.63637227", "0.6313188", "0.6283097", "0.62792295", "0.62788224", "0.6259882", "0.61795384", "0.61575544", "0.61250705", "0.61115867", "0.60973257", "0.6060992", "0.6026321", "0.59850246", "0.5981068", "0.59690034", "0.5958315", "0.5954643", "0.59406704", "0.5931552", "0.58971214", "0.58163154", "0.5789545", "0.5750818", "0.57411796", "0.5699194", "0.5682955", "0.5662822", "0.56565106", "0.5655482", "0.56484085", "0.5612859", "0.56114006", "0.5596722", "0.55966276", "0.5570734", "0.5565508", "0.5565196", "0.55642366", "0.5558641", "0.5555653", "0.5553583", "0.5531297", "0.55310714", "0.5530927", "0.5530037", "0.55237055", "0.55144787", "0.5501891", "0.54997903", "0.54991156", "0.5496156", "0.54846346", "0.54730695", "0.5471905", "0.547173", "0.54558706", "0.54430944", "0.5440567", "0.5434465", "0.54283166", "0.5427251", "0.54241467", "0.53905946", "0.53868777", "0.53809273", "0.53749025", "0.5367541", "0.53614813", "0.5356617", "0.5347103", "0.53469235", "0.5345255", "0.53421885", "0.53363734", "0.5334413", "0.5330811", "0.5327985", "0.5316581", "0.5315708", "0.5311451", "0.5302557", "0.5297999", "0.5297103", "0.52959937", "0.52843684", "0.5279053", "0.5274329", "0.5248972", "0.52477026", "0.52463233", "0.52344275", "0.52340674", "0.52277905", "0.5227146", "0.52236295", "0.52215505", "0.5212983" ]
0.752837
1
Return the message to use to commit the buildfile with the next version
def message version = extract_version msg = Release.commit_message || "Changed version number to #{version}" msg = msg.call(version) if Proc === msg msg end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_version_to_next\n super\n info \"Current version is now #{extract_version}\"\n Hg.commit File.basename(version_file), message\n Hg.push if Hg.remote\n end", "def commit_message\n @commit.sub '%.%.%', @after_version\n end", "def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end", "def generate_commit_message\n [\n \"[fastlane]\",\n \"Updated\",\n self.type,\n \"and platform\",\n self.platform\n ].join(\" \")\n end", "def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile }\n end", "def commit_new_cb_version\n shellout('git add metadata.rb')\n @gitrepo.commit_index(\"release v#{@target_version}\")\n end", "def next_version\n work.next_version\n end", "def release_commit_message(release_name)\n \"#{RELEASE_COMMIT_PREFIX}#{release_name}\"\n end", "def updateVersion\n # We add 1 because the next commit is probably one more - though this is a race\n commits = %x[git log #{$0} | grep '^commit ' | wc -l].to_i + 1\n vers = \"1.%0.3d\" % commits\n\n t = File.read($0)\n t.gsub!(/^MYVERSION = '(.*)'$/, \"MYVERSION = '#{vers}'\")\n bak = $0+'.bak'\n File.open(bak,'w') { |f| f.puts t }\n perm = File.stat($0).mode & 0xfff\n File.rename(bak,$0)\n File.chmod(perm,$0)\n exit\nend", "def bumpChangelogVersion\n version = versionNumber(most_recent).split(\".\")\n major_version = version[0].to_i\n minor_version = version[1].to_i\n\n changelog = '../CHANGELOG.md'\n new_changelog = changelog + '.new'\n\n new_version = major_version.to_s + \".\" + (minor_version + 1).to_s\n Dir.mkdir '../Changelogs/' + new_version\n sh \"touch ../Changelogs/\" + new_version + \"/.keep\"\n version_bump_text = \"## \" + new_version + \"\\n\" + \"Automatically starting the next sprint, no changes just yet (Replace this line when changes are merged in) \" + \"\\n\\n\"\n\n ensure_git_branch(branch: \"master\")\n git_add(path: \"Changelogs/\" + new_version + \"/.keep\")\n git_commit(path: [\"Changelogs/\" + new_version + \"/.keep\"], message: \"Automatically bumping CHANGELOG version via fastlane\")\n push_to_git_remote(tags: false)\n end", "def build_version\n @semver.to_s '%M.%m.%p'\n end", "def commit(msg = nil)\n require_dep! 'awesome_spawn'\n require_cmd! git_cmd\n\n in_repo { AwesomeSpawn.run \"#{git_cmd} add #{pkg_files.join(' ')}\" }\n super(msg.nil? ? \"updated to #{version}\" : msg)\n self\n end", "def create_commit_msg(commit_msg_path, for_commit)\n File.open(commit_msg_path, 'w') do |file|\n file.puts(\"Automatic documentation update\\n\")\n file.puts(\"- Generated for #{for_commit}.\")\n end\n end", "def version\n '1.5.1.2' # Version number <major>.<minor>.<patch>.<monthly commit>\n end", "def commit_and_tag(new_version)\n git = Git.init\n git.add([VERSION_FILE, \"Gemfile.lock\"])\n git.commit(\"Update to #{new_version}\")\n git.add_tag(new_version.to_s)\n end", "def module_version(repo_dir, config, build)\n version = config[\"module_version\"] || git_current_branch(repo_dir) || \"unknown\"\n \n if (not build.nil?) && build.length > 0\n return version + \"-\" + build\n else\n return version\n end\n end", "def version\n '2.0.7.7' # Version number <major-update>.<minor-update>.<patch-update>.<commit-count>\n end", "def next_version #:nodoc:\n parts = version.split('.')\n parts[-1] = (parts[-1].to_i + 1).to_s\n parts.join('.')\n end", "def run\n usage \"[0.1.2 - version, 100/10/1 - bump major/minor/patch, .build - add build] Commit message goes here\" if @argv.empty?\n\n # First Arg may indicate version command if it matches pattern\n version_command = @argv[0] =~ COMMAND_PATTERN ? @argv.shift : nil\n\n # All the other args lumped into message, or default message\n if @argv.empty?\n commit_message = \"Commit #{Time.now.to_s[0..-6]}\"\n history_message = nil\n else\n commit_message = history_message = @argv.join(' ')\n end\n\n # Updating version only if version command set\n if version_command\n puts \"Updating version with #{version_command}\"\n if history_message\n system %Q{rake \"version[#{version_command},#{history_message}]\"}\n else\n system %Q{rake version[#{version_command}]}\n end\n end\n\n puts \"Adding all the changes\"\n system \"git add --all\"\n\n puts \"Committing everything with message: #{commit_message}\"\n system %Q[git commit -a -m \"#{commit_message}\" --author arvicco]\n\n current_branch = `git branch`.strip\n puts \"Pushing to (default) remote for branch: #{current_branch}\"\n system \"git push\"\n end", "def increment_version_code()\n path = '../app/build.gradle'\n re = /versionCode\\s+(\\d+)/\n \n s = File.read(path)\n versionCode = s[re, 1].to_i\n s[re, 1] = (versionCode + 1).to_s\n \n f = File.new(path, 'w')\n f.write(s)\n f.close\n end", "def version\n\t\t\tbegin\n\t\t\t\tv = \"#{GVB.major_version}.#{GVB.minor_version}.#{GVB.patch_version}\"\n\t\t\trescue\n\t\t\t\tv = File.read(\".gvb_version\") if File.exists?(\".gvb_version\")\n\t\t\tend\n\t\t\t# If we got a version then use it to construct a link to the github tag of the same\n\t\t\tif v\n\t\t\t\tl = link_to v, \"https://github.com/machiavellian/machiavelli/releases/tag/v#{v}\", target: \"blank\" if v\n\t\t\t\treturn \"version #{l} \".html_safe\n\t\t\tend\n\t\tend", "def getNextTagVersion\n current = sh(\"git fetch -q -f --all --tags > /dev/null 2>&1 && git tag -l | sort -n -t. -k1,1 -k2,2 -k3,3 -r | egrep -v 'qa|prod' | head -1 | tail -1 | tr -d '\\n'\")\n chunks = current.split('.')\n chunks[2] = chunks[2].to_i + 1\n\n return \"#{chunks[0]}.#{chunks[1]}.#{chunks[2]}\"\nend", "def mark\n \"(echo #{revision} > #{configuration[:release_path]}/REVISION)\"\n end", "def version\n build_string\n end", "def mark\n \"echo #{revision} > #{configuration[:deploy_release]}/REVISION\"\n end", "def versionbump(workdir = nil)\n version = ENV['VERSION'] || Pkg::Config.version.to_s.strip\n new_version = '\"' + version + '\"'\n\n version_file = \"#{workdir ? workdir + '/' : ''}#{Pkg::Config.version_file}\"\n\n # Read the previous version file in...\n contents = IO.read(version_file)\n\n # Match version files containing 'VERSION = \"x.x.x\"' and just x.x.x\n if version_string = contents.match(/VERSION =.*/)\n old_version = version_string.to_s.split[-1]\n else\n old_version = contents\n end\n\n puts \"Updating #{old_version} to #{new_version} in #{version_file}\"\n if contents.match(\"@DEVELOPMENT_VERSION@\")\n contents.gsub!(\"@DEVELOPMENT_VERSION@\", version)\n elsif contents.match('version\\s*=\\s*[\\'\"]DEVELOPMENT[\\'\"]')\n contents.gsub!(/version\\s*=\\s*['\"]DEVELOPMENT['\"]/, \"version = '#{version}'\")\n elsif contents.match(\"VERSION = #{old_version}\")\n contents.gsub!(\"VERSION = #{old_version}\", \"VERSION = #{new_version}\")\n elsif contents.match(\"#{Pkg::Config.project.upcase}VERSION = #{old_version}\")\n contents.gsub!(\"#{Pkg::Config.project.upcase}VERSION = #{old_version}\", \"#{Pkg::Config.project.upcase}VERSION = #{new_version}\")\n else\n contents.gsub!(old_version, Pkg::Config.version)\n end\n\n # ...and write it back on out.\n File.open(version_file, 'w') { |f| f.write contents }\n end", "def git_ver\n '(git commit:' + _git('reflog').split(' ').first + ')'\n end", "def bump\n parts = new_version\n text = '\\1' + [\"MAJOR = #{parts[:major]}\",\n \"MINOR = #{parts[:minor]}\",\n \"PATCH = #{parts[:patch]}\",\n \"BUILD = #{parts[:build] || 'nil'}\"].join('\\1')\n\n out_data = File.read(@filename).gsub(PATTERN, text)\n # puts out_data\n File.open(@filename, 'w') { |out| out << out_data }\n puts \"Bumped version to #{self}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def commit_message\n user_name = user ? user.login : \"anonymous\"\n \n if revisions.empty?\n \"initial #{user_name}\"\n elsif @rollback\n \"rollback #{self.log.first} #{user_name}\"\n else\n \"edit #{self.log.first} #{user_name}\"\n end\n end", "def test_version_message\n Repository.create()\n FileUtils.touch('.test_file1')\n a = ['.test_file1']\n Repository.add(a) \n Repository.commit()\n #Repository.version()\n end", "def bump_it_to(version:)\n Bump::Bump.run(version.to_s, commit: false, bundle: false, tag: false)\n $current_version = Bump::Bump.current\n say(\"Bumped to version: #{$current_version}!\".bold)\nend", "def versionString()\n\t\t\t\treturn \"#{major}.#{minor}.#{build}\"\n\t\t\tend", "def waiting_for_stable_build_comment_segment(branch, settings)\n \"#{CONTENT_WAITING_STABLE_BUILD} '#{branch_settings(branch, settings)['downstream_job_name']}'\"\nend", "def update_build_number(build_number)\n result = ''\n client = Helpers.create_aws_ec2_client\n client.create_tags(dry_run: false,\n resources: [@aws_instance_data.instance_id],\n tags: [{ key: 'Build-Number', value: build_number }])\n result += run_ssh_command(\"echo #{build_number} | sudo tee /home/bz-app/build_number.txt\")\n result += run_ssh_command(\"sudo service #{@repository} restart\")\n result\n end", "def commit!\n git add: \".\"\n git commit: \"-m '#{config.dig('commit_msg')}'\"\n end", "def next_version\n # x.y.z\n v = version.split '.'\n # bump z\n v[-1] = v[-1].to_i + 1\n v.join '.'\nend", "def commit_new_version\n @cocina = VersionService.open(identifier: cocina.externalIdentifier,\n significance: \"minor\",\n description: \"Descriptive metadata upload from #{original_filename}\",\n opening_user_name: ability.current_user.sunetid)\n end", "def increase_version version\n puts 'increased'\n new_version = \"#{version[1]}.#{version[2]}.#{version[3]}.\" +\n \"#{version[4].to_i + 1}\"\n end", "def next_release_number\n latest_samson_number = project.releases.last&.number || \"0\"\n next_samson_number = next_number(latest_samson_number)\n return next_samson_number if commit.blank?\n\n return next_samson_number unless fuzzy_tag = project.repository.fuzzy_tag_from_ref(commit)&.split('-', 2)\n return next_samson_number unless latest_github_number = fuzzy_tag.first[VERSION_REGEX, 1]\n next_github_number = (fuzzy_tag.size == 1 ? latest_github_number : next_number(latest_github_number))\n\n if Gem::Version.new(next_samson_number) > Gem::Version.new(next_github_number)\n next_samson_number\n else\n next_github_number\n end\n end", "def version_name\n if self.version.nil?\n 'First Submission'\n else\n \"#{self.version.ordinalize}\"\n end\n end", "def commit_message\n commit_message_lines.join\n end", "def msg(message)\n FileUtils.cd(@git_dir_path)\n\t# via http://ozmm.org/posts/git_msg.html\n # --allow-empty means git won't require a changed file; it will just store a\n # commit message.\n `git commit --allow-empty -m \"#{message}\" &>/dev/null`\n # Use sed to extract SHA1 hash from most recent log message\n hash = `git log master~1..master | sed -n '/commit/s/commit //p'`.chomp\n # Push to Github\n `git push origin master &>/dev/null`\n return hash\n end", "def create_release_meta_file!(current_commits, new_version)\n release_meta_path = \"#{RELEASE_META_DIR}/#{new_version}.toml\"\n\n # Grab all existing commits\n existing_commits = get_existing_commits!\n\n # Ensure this release does not include duplicate commits. Notice that we\n # check the parsed PR numbers. This is necessary to ensure we do not include\n # cherry-picked commits made available in other releases.\n #\n # For example, if we cherry pick a commit from `master` to the `0.8` branch\n # it will have a different commit sha. Without checking something besides the\n # sha, this commit would also show up in the next release.\n new_commits =\n current_commits.select do |current_commit|\n existing_commits.select do |existing_commit|\n existing_commit.fetch(\"sha\") == current_commit.fetch(\"sha\") ||\n existing_commit.fetch(\"pr_number\") == current_commit.fetch(\"pr_number\")\n end\n end\n if new_commits.any?\n if File.exists?(release_meta_path)\n words =\n <<~EOF\n I found #{new_commits.length} new commits since you last generated:\n\n #{release_meta_path}\n\n So I don't erase any other work in that file, please manually add the\n following commit lines:\n\n #{new_commits.to_toml.indent(4)}\n\n Done? Ready to proceed?\n EOF\n\n if Printer.get(words, [\"y\", \"n\"]) == \"n\"\n Printer.error!(\"Ok, re-run this command when you're ready.\")\n end\n else\n File.open(release_meta_path, 'w+') do |file|\n file.write(\n <<~EOF\n [releases.\"#{new_version}\"]\n date = #{Time.now.utc.to_date.to_toml}\n commits = #{new_commits.to_toml}\n EOF\n )\n end\n\n words =\n <<~EOF\n I've created a release meta file here:\n\n #{release_meta_path}\n\n I recommend reviewing the commits and fixing any mistakes.\n\n Ready to proceed?\n EOF\n\n if Printer.get(words, [\"y\", \"n\"]) == \"n\"\n Printer.error!(\"Ok, re-run this command when you're ready.\")\n end\n end\n end\n\n true\nend", "def explain\n if build_version\n \"Build Version: #{build_version}\"\n else\n if from_dependency?\n \"Build Version will be determined from software '#{version_dependency}'\"\n else\n \"Build Version is not determined yet.\"\n end\n end\n end", "def new_version\n %w(major minor patch).each do |level|\n changes = git_changelog.select(&\"#{level}?\".to_sym)\n return [ last_release.send(\"#{level}!\"), changes ] if changes.size > 0\n end\n raise \"No commit since last release (#{last_release})\"\n end", "def message\n # dynamically build a message, possibly appending a reason\n unless @build['message']\n reason = \", #{@build['reason']}\" if @build['reason']\n case @type\n when \"parse\"\n text = \".. Builds `#{self.output}` pressed with the template `#{self.template}`#{reason}.\"\n when \"render\"\n case self.backend\n when \"pdf\"\n text = \".. Uses Asciidoctor/Prawn to generate a PDF file `#{self.output}`\"\n text.concat(\"#{reason}\") if reason\n text.concat(\".\")\n when \"html5\"\n text = \".. Compiles a standard Asciidoctor HTML5 file, `#{self.output}`\"\n text.concat(\"#{reason}\") if reason\n text.concat(\".\")\n when \"jekyll\"\n text = \".. Uses Jekyll config files:\\n+\\n--\"\n files = self.props['files']\n if files.is_a? String\n if files.include? \",\"\n files = files.split(\",\")\n else\n files = files.split\n end\n else\n unless files.is_a? Array\n @logger.error \"The Jekyll configuration file must be a single filename, a comma-separated list of filenames, or an array of filenames.\"\n end\n end\n files.each do |file|\n text.concat(\"\\n * `#{file}`\")\n end\n text.concat(\"\\n\\nto generate a static site\")\n if self.props && self.props['arguments']\n text.concat(\" at `#{self.props['arguments']['destination']}`\")\n end\n text.concat(\"#{reason}\") if reason\n text.concat(\".\\n--\\n\")\n end\n return text\n end\n else\n @build['message']\n end\n end", "def get_message(output_path, spec)\n if Pathname.new(output_path).exist?\n message = \"[Fix] #{spec}\"\n elsif Pathname.new(File.join(repo_specs_dir, spec.name)).exist?\n message = \"[Update] #{spec}\"\n else\n message = \"[Add] #{spec}\"\n end\n message\n end", "def generate_git_commit_log(rev=ENV['LAST_SUCCESS_REV'])\n g = Git.open(Dir.getwd)\n change_log = g.log.between(rev).map { |c| \"- \" + c.message.lines.first.chomp }.join \"\\n\"\n \"Commit Log:\\n\\n#{change_log}\\n\"\nend", "def generate_git_commit_log(rev=ENV['LAST_SUCCESS_REV'])\n g = Git.open(Dir.getwd)\n change_log = g.log.between(rev).map { |c| \"- \" + c.message.lines.first.chomp }.join \"\\n\"\n \"Commit Log:\\n\\n#{change_log}\\n\"\nend", "def send_post_commit_mail(revision)\n body = post_commit_html(revision)\n mail = Emailer.create_svn_mail(config.mails,revision.subject,revision.number,body,revision.patch)\n Emailer.deliver(mail)\nend", "def version_saved_success_message\n save_success_txt.text\n end", "def tag_release(tag)\n unless this_version == extract_version\n puts \"Committing buildfile with version number #{extract_version}\"\n Perforce.p4 'edit', Rake.application.rakefile.to_s\n Perforce.commit message\n end\n puts \"Tagging release #{tag}\"\n Perforce.p4 'tag', '-l', tag, \"//#{ENV['P4CLIENT']}/...\"\n end", "def bump_minor_version; end", "def publish_latest_version \n publish_version(latest_version)\n end", "def to_s\n \"#{@major}.#{@minor}.#{@update} Build #{@build}\"\n end", "def commit\n @commit ||= $repo.log.object(@rev || 'master').path(@name).first\n end", "def update_commit_message(message)\n ::File.open(commit_message_file, 'w') do |file|\n file.write(message)\n end\n end", "def run(remote = false, branch = 'master')\n if already_released?\n logger.fatal \"Version #{version} had already been released, did you bump the version manually?\"\n exit 1\n end\n File.write(changelog_file, new_content) unless remote\n id = commit_changelog(nil, remote, branch) if options[:commit]\n logger.info \"The changelog has been updated to version #{version}\"\n id\n end", "def update_version_file(version)\n if File.exists?('VERSION')\n File.open('VERSION', 'w') { |f| f << version.to_s }\n modified_files << 'VERSION'\n end\n end", "def release_version!\n projects.each { |project| project.release_version!(tag_full_name) }\n print_log 'Versions released'\n slack_notifier.ping(release_message, icon_emoji: ':see_no_evil:')\n end", "def next_version\n (self.class.directories(original_destination).size + 1).to_s\n end", "def get_commit_log(last_version)\n range = \"v#{last_version}...\"\n `git log #{range} --no-merges --pretty=format:'%H\\t%s\\t%aN\\t%ad'`.chomp\nend", "def semver_version\n if Build::Check.on_tag?\n # timestamp is disabled in omnibus configuration\n Omnibus.load_configuration('omnibus.rb')\n Omnibus::BuildVersion.semver\n else\n latest_git_tag = Info.latest_tag.strip\n latest_version = latest_git_tag && !latest_git_tag.empty? ? latest_git_tag[0, latest_git_tag.match(\"[+]\").begin(0)] : '0.0.1'\n commit_sha = Build::Info.commit_sha\n ver_tag = \"#{latest_version}+\" + (Build::Check.is_nightly? ? \"rnightly\" : \"rfbranch\")\n [ver_tag, Gitlab::Util.get_env('CI_PIPELINE_ID'), commit_sha].compact.join('.')\n end\n end", "def generate_git_commit_log(rev=ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD^^^^^')\n g = Git.open(ENV['PWD'], :log => Logger.new(STDOUT))\n begin\n change_log = g.log.between(rev).map { |c| \"- \" + c.message.lines.first.chomp }.join \"\\n\"\n \"Commit Log:\\n\\n#{change_log}\\n\"\n rescue\n \"Unable to parse commit logs\"\n end\nend", "def set_version(version, rootdir = Dir.pwd, options = {})\n exit_status = 0\n type = (options[:type]) ? options[:type] : FalkorLib.config[:versioning][:type]\n source = (options[:source]) ? options[:source] : FalkorLib.config[:versioning][:source][ type ]\n versionfile = File.join( rootdir, source[:filename] ) unless source[:filename].nil?\n major, minor, patch = major(version), minor(version), patch(version)\n #tocommit = \"\"\n case type\n when 'file'\n info \"writing version changes in #{source[:filename]}\"\n File.open(versionfile, 'w') { |f| f.puts version } #if File.exist? ( versionfile )\n when 'gem'\n info \"=> writing version changes in #{source[:filename]}\"\n File.open(versionfile, 'r+') do |f|\n text = f.read\n text.gsub!(/^(\\s*)MAJOR\\s*,\\s*MINOR,\\s*PATCH\\s*=\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)(.*)$/,\n '\\1' + \"MAJOR, MINOR, PATCH = #{major}, #{minor}, #{patch}\" + '\\5')\n f.rewind\n f.write(text)\n end\n when 'puppet_module'\n info \"=> writing version changes in #{source[:filename]}\"\n metadata = JSON.parse( IO.read( versionfile ) )\n metadata[\"version\"] = version\n File.open(versionfile, \"w\") do |f|\n f.write JSON.pretty_generate( metadata )\n end\n #exit 1\n end\n if FalkorLib::Git.init?(rootdir)\n filelist = FalkorLib::Git.list_files( rootdir )\n Dir.chdir( rootdir ) do\n next if source[:filename].nil?\n unless filelist.include?( source[:filename] )\n warning \"The version file #{source[:filename]} is not part of the Git repository\"\n answer = ask(\"Adding the file to the repository? (Y|n)\", 'Yes')\n next if answer =~ /n.*/i\n exit_status = FalkorLib::Git.add(versionfile, \"Adding the version file '#{source[:filename]}', inialized to the '#{version}' version\" )\n next\n end\n run %( git diff #{source[:filename]} )\n answer = ask(cyan(\"=> Commit the changes of the version file to the repository? (Y|n)\"), 'Yes')\n next if answer =~ /n.*/i\n run %( git commit -s -m \"bump to version '#{version}'\" #{source[:filename]} )\n exit_status = $?.to_i\n # if (type == 'gem' && File.exists?(File.join(rootdir, 'Gemfile')) )\n # run %{\n # sleep 2\n # bundle update falkorlib\n # git commit -s -m \"Update Gemfile.lock accordingly\" Gemfile.lock\n # } if command?( 'bundle' )\n # end\n end\n end\n exit_status\n end", "def add_version_task\n desc(\"Bump application version [major, minor, patch]\")\n task(:version, [:semver]) do |_task, args|\n new_version = send(args[:semver]).format(\"%M.%m.%p\").to_s\n\n Helpers::Spinner.spin(\"Updating app version\", done_message: \"updated to v#{new_version}\") do\n update_version(new_version)\n update_lock\n commit_and_tag(new_version)\n end\n end\n end", "def commit(message)\n @repo.commit_index(\"Cron Job: #{message}\") # Commit.\nend", "def update_app_version_numbers()\n \n version_string = ENV[\"FORCED_VERSION_NUMBER_STRING\"]\n xcode_project_version = nil\n \n if version_string != nil && version_string.length > 0\n\n puts \"using forced version \\\"#{version_string}\\\"\"\n\n else\n\n version_string = get_semver_from_branch\n\n if version_string == nil\n\n app_store_build_number(live: false)\n latest_app_store_version = lane_context[SharedValues::LATEST_VERSION]\n xcode_project_version = get_project_xcode_version\n\n # use largest version (note ascii comparison - not sure if accurate enough)\n version_string = latest_app_store_version > xcode_project_version ? latest_app_store_version : xcode_project_version\n puts \"using version #{version_string} (latest app store = #{latest_app_store_version}, project version = #{xcode_project_version})\"\n\n end\n\n end\n\n # increment build number\n forced_build_number = ENV[\"FORCED_BUILD_NUMBER\"]\n unless forced_build_number == nil || forced_build_number.empty?\n puts \"using forced build number \\\"#{forced_build_number}\\\"\"\n build_number = forced_build_number\n increment_build_number(build_number: build_number)\n else\n current_build_number = latest_testflight_build_number(version: version_string, initial_build_number: 0)\n\n if current_build_number == 0\n if m = version_string.match($semver_regex)\n # if no existing number was found we need to check variations of the same version\n # since Apple handles 1, 1.0, and 1.0.0 independently, but they share build number\n puts \"build number is 0 - checking version variations in case there's a match\"\n\n major = m.captures[0]\n minor = m.captures[1]\n patch = m.captures[2]\n\n puts \"major=#{major} minor=#{minor} patch=#{patch}\"\n if patch == \"0\"\n variation = \"#{major}.#{minor}\"\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n \n if current_build_number == 0 && minor == \"0\"\n variation = major\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n end\n end\n else\n UI.important \"build number is 0 and version is not semantically correct - unable to check version variations (build number may be incorrect)\"\n end\n \n end\n\n build_number = current_build_number + 1\n increment_build_number(build_number: build_number)\n end\n\n # set version number\n current_version_string = xcode_project_version || get_project_xcode_version\n increment_version_number(version_number: version_string)\n\n\n puts \"build_number #{current_build_number} => #{build_number}\"\n puts \"version_number #{current_version_string} => #{version_string}\"\n end", "def build\n @build ||= '0.0.0'\n end", "def update_version_file\n version_file = @spec.version_file\n updated_version = Olag::Version::update(version_file)\n abort(\"Updated gem version; re-run rake\") if @spec.version.to_s != updated_version\n end", "def get_next_build_step\n @build_step += 1\n end", "def tag_version_task\n sh git, 'tag', '-a', \"#{gemspec.name}-#{gemspec.version}\", '-m', \"Released #{gemspec.name} gem version #{gemspec.version}.\"\n end", "def repo_commit(msg)\n git :add => '-u'\n git :add => '.'\n git :commit => \"-m \\\"#{msg}\\\"\" \n end", "def current_version\n version_number rev\n end", "def bumpBuild()\n\t\t\t\t@build += 1\n\t\t\tend", "def commit(message)\n p4 'submit', '-d', message\n end", "def semver\n build_tag = version_tag\n\n # PRERELEASE VERSION\n if prerelease_version?\n # ensure all dashes are dots per precedence rules (#12) in Semver\n # 2.0.0-rc.1\n prerelease = prerelease_tag.gsub(\"-\", \".\")\n build_tag << \"-\" << prerelease\n end\n\n # BUILD VERSION\n # Follows SemVer conventions and the build version begins with a '+'.\n build_version_items = []\n\n # By default we will append a timestamp to every build. This behavior can\n # be overriden by setting the OMNIBUS_APPEND_TIMESTAMP environment\n # variable to a 'falsey' value (ie false, f, no, n or 0).\n #\n # format: YYYYMMDDHHMMSS example: 20130131123345\n build_version_items << build_start_time.strftime(\"%Y%m%d%H%M%S\") if append_timestamp?\n\n # We'll append the git describe information unless we are sitting right\n # on an annotated tag.\n #\n # format: git.COMMITS_SINCE_TAG.GIT_SHA example: git.207.694b062\n unless commits_since_tag == 0\n build_version_items << [\"git\", commits_since_tag, git_sha_tag].join(\".\")\n end\n\n unless build_version_items.empty?\n build_tag << \"+\" << build_version_items.join(\".\")\n end\n\n build_tag\n end", "def to_s\n version = get_version_string\n version << \"-#{get_pre_string}\" unless @pre == nil\n version << \"+#{get_build_string}\" unless @build == nil\n version\n end", "def commit\n\t$VP.join('.git/refs/heads/master').read[0..8] rescue nil\nend", "def resolve_next_version(current_version)\n next_version = Release.next_version\n next_version ||= lambda { |v|\n snapshot = v.match(/-SNAPSHOT$/)\n version = v.gsub(/-SNAPSHOT$/, \"\").split(/\\./)\n if snapshot\n version[-1] = sprintf(\"%0#{version[-1].size}d\", version[-1].to_i + 1) + '-SNAPSHOT'\n end\n version.join('.')\n }\n next_version = ENV['NEXT_VERSION'] if ENV['NEXT_VERSION']\n next_version = ENV['next_version'] if ENV['next_version']\n next_version = next_version.call(current_version) if Proc === next_version\n next_version\n end", "def local_git_commit\n ErrorEmittingExecutor.execute(\"git commit -m '#{COMMIT_DESCRIPTION}' Gemfile.lock\")\nend", "def do_commit(version, push)\n cookbook_path = get_cookbook_path(@cookbook_path)\n Dir.chdir(\"#{cookbook_path}\")\n output = `git commit -a -m \"Deploy #{version}\" 2>&1`\n if $?.exitstatus != 0\n if output !~ /nothing to commit/\n Chef::Log.error(\"Could not commit #{@cookbook_name}\")\n puts output\n exit 1\n end\n end\n if push\n output = `git push --tags 2>&1`\n if $?.exitstatus != 0\n Chef::Log.error(\"Could not push tag for: #{@cookbook_name}\")\n exit 1\n end\n output = `git push 2>&1`\n end\n end", "def get_build_number()\n return ENV['DOCS_BUILD_NUMBER'] || \"HEAD\"\n end", "def write_version(major, minor, patch, build, _options = T.unsafe(nil)); end", "def commit_changes(description)\n git :add => '-A'\n git :commit => %Q(-qm \"thegarage-template: [#{@current_recipe}] #{description}\")\nend", "def prepend!\n return if description.empty?\n\n message = open(commit_message_file).read\n open(commit_message_file, 'w') do |f|\n f.puts \"#{description} #{message}\"\n end\n end", "def propagate_version(**args)\n return unless ENV.key? 'CI'\n\n version = get_package_key(key: :version)\n build = current_build_number(track: args[:track] || nil)\n\n UI.message \"Propagating version: #{version}\"\n UI.message 'into the Info.plist and build.gradle files'\n\n UI.message \"Setting build number to #{build}\"\n\n version = \"#{version.split('-')[0]}-pre\" if should_nightly?\n UI.message \"Actually putting #{version} into the binaries (because we're doing a nightly)\"\n\n # encode build number into js-land – we've already fetched it, so we'll\n # never set the \"+\" into the binaries\n unless version.include? '+'\n # we always want the CI build number in js-land\n set_package_data(data: { version: \"#{version}+#{build}\" })\n end\n\n case lane_context[:PLATFORM_NAME]\n when :android\n set_gradle_version_name(version_name: version, gradle_path: lane_context[:GRADLE_FILE])\n set_gradle_version_code(version_code: build, gradle_path: lane_context[:GRADLE_FILE])\n when :ios\n # we're splitting here because iTC can't handle versions with dashes in them\n increment_version_number(version_number: version.split('-')[0], xcodeproj: ENV['GYM_PROJECT'])\n increment_build_number(build_number: build, xcodeproj: ENV['GYM_PROJECT'])\n end\nend", "def git_commit(message=\"\")\n %x( git commit -m=#{message} )\n end", "def version_tag(text); end", "def write_version(major, minor, patch, build, options = {})\n command = Juwelier::Commands::Version::Write.build_for(self)\n command.major = major\n command.minor = minor\n command.patch = patch\n command.build = build\n\n command.run\n end", "def latest_version\n files.last && files.last.versionnumber\n end", "def build_file\n @file = \"#{build_publish_date}-#{build_file_name}.#{build_tags}.#{build_filter}\"\n end", "def nextVersion\n newRevision(@year, @month, @revCount.nil? ? 1 : @revCount + 1)\n end", "def release!\n welcome\n return if uncommitted_changes?\n\n # Check if everything is up to date with git remotes\n if branch_behind_remote?\n if want_to_pull? \n cmd \"git pull\"\n cmd \"git pull --tags\"\n else\n inform \"Please pull the changes, then run `rake release` again\"\n return\n end\n end\n\n # Gather user input about the release\n get_release_message\n get_release_version_type\n\n # Confirm and execute\n if you_sure?\n update_dist\n update_bower_file\n cmd \"git add .\"\n cmd \"git commit -am '#{@commit_message}'\"\n cmd \"git tag -a v#{@next_version} -m '#{@commit_message}'\"\n cmd \"git push\"\n cmd \"git push --tags\"\n publish! # to github pages\n\n robot_says \"All done :) Thanks for contributing!\"\n else\n inform \"Release cancelled\"\n end\n end", "def bump_minor_version()\n Juwelier::Commands::Version::BumpMinor.build_for(self).run\n end", "def version\n next_version\n end" ]
[ "0.7133768", "0.70819384", "0.6720151", "0.6618071", "0.65373284", "0.6351196", "0.62521625", "0.6127682", "0.60882264", "0.60267824", "0.59917647", "0.5972133", "0.5931828", "0.5928321", "0.592758", "0.58913636", "0.5838882", "0.5831469", "0.58167374", "0.5810524", "0.5788119", "0.57828975", "0.576196", "0.57572776", "0.57403475", "0.57391334", "0.57316124", "0.57047665", "0.57011884", "0.57011884", "0.5700125", "0.5696928", "0.5690177", "0.5675676", "0.5669517", "0.56357276", "0.56337583", "0.562994", "0.5604279", "0.55704856", "0.5560231", "0.55509067", "0.5538226", "0.5532543", "0.5526372", "0.5522682", "0.5490919", "0.5482816", "0.54714024", "0.54661924", "0.545382", "0.545382", "0.54507524", "0.5436747", "0.54213774", "0.5419718", "0.54094714", "0.5399331", "0.5394896", "0.5389129", "0.53801787", "0.53754485", "0.536311", "0.5362834", "0.53567344", "0.53527814", "0.53496015", "0.5346436", "0.53447974", "0.53371334", "0.5333261", "0.53325486", "0.5330375", "0.5324918", "0.53245175", "0.53228086", "0.53163064", "0.53156304", "0.5313644", "0.53098375", "0.5308067", "0.5300407", "0.5299589", "0.52959996", "0.5284933", "0.52834713", "0.52704024", "0.5267209", "0.5262495", "0.5259875", "0.52592295", "0.5258364", "0.5255208", "0.5252152", "0.5249057", "0.52448714", "0.52442855", "0.5234816", "0.523309" ]
0.7228319
1
:callseq: git(args) Executes a Git command and returns the output. Throws exception if the exit status is not zero. For example: git 'commit' git 'remote', 'show', 'origin'
def git(*args) cmd = "git #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}" output = `#{cmd}` fail "GIT command \"#{cmd}\" failed with status #{$?.exitstatus}\n#{output}" unless $?.exitstatus == 0 return output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def git(*args)\n cmd(*['git'] + args)\n end", "def git(*args)\n cmd(*['git'] + args)\n end", "def git(*args, &block)\n options = args.extract_options!\n system_args = ['--git-dir', root_url, '-c', 'core.quotepath=false']\n\n args = system_args + Array.wrap(args)\n args = args.map { |arg| self.class.shell_quote(arg.to_s) }.join(' ')\n cmd = [self.class.quoted_git_command, args].join(' ')\n\n ret = self.class.shell_out(cmd, options, &block)\n\n if $? && $?.exitstatus != 0\n raise CommandFailed, \"git exited with non-zero status: #{$?.exitstatus}\"\n end\n ret\n end", "def git(*args)\n IO.popen(\"-\", \"r\") do |io|\n if io\n yield io\n else\n #STDERR.puts [GIT_BIN, \"--git-dir\", @git_dir, *args].inspect\n exec(GIT_BIN, \"--git-dir\", @git_dir, *args)\n end\n end\n end", "def git(*args)\n Dir.chdir(@dir) do\n git = Process.spawn('git', *args)\n Process.wait(git)\n raise \"git #{args.join(' ')} (in #{@dir}) failed: #{$?.exitstatus}\" if $?.exitstatus != 0\n end\n end", "def git(*args)\n system \"git \" + args.join(\" \")\nend", "def git(*args)\n cd { run(*['git'] + args) }\n end", "def git_cmd(*args, &block)\n system_args = ['--git-dir', root_url, '-c', 'core.quotepath=false']\n args = (system_args + Array(args)).flatten\n args = args.map { |arg| self.class.shell_quote(arg.to_s) }.join(' ')\n cmd = [self.class.quoted_git_command, args].join(' ')\n\n exit_status, errors = self.class.shell_out(cmd, &block)\n\n raise Redmine::Scm::Adapters::CommandFailed, errors unless exit_status == 0\n end", "def execute_git(repo_dir, *args)\n system('git', '-C', repo_dir, *args)\n end", "def git command, *args\n run 'git', command.to_s, *args\nend", "def git_exec(command, *args)\n Dir.chdir(@grit_repo.working_dir) do\n %x{git #{command} #{args.join(' ')}}\n end\n end", "def git command\n output = `git #{command} 2>&1`.chomp\n unless $?.success?\n raise RuntimeError, output\n end\n output\n end", "def git_call(command, verbose = debug_mode, enforce_success = false)\n if verbose\n puts\n puts \" git #{command}\"\n puts\n end\n output = `git #{command}`\n puts output if verbose and not output.empty?\n # If we need sth. to succeed, but it doesn't, then stop right there.\n if enforce_success and not last_command_successful?\n puts output unless output.empty?\n raise UnprocessableState\n end\n output\n end", "def exec_cmd(cmd, flags, args)\n # always add the git dir to the cmd to ensure that git is executed\n # within the expected repo\n gd_flag = \"--git-dir=\\\"#{@git_dir}\\\"\"\n wt_flag = \"--work-tree=\\\"#{@repo_root}\\\"\"\n flag_str = flags.join(\" \")\n git_cmd = \"git #{gd_flag} #{wt_flag} #{cmd} #{flag_str} #{args}\"\n Giblog.logger.debug { \"running: #{git_cmd}\" }\n Open3.capture3(git_cmd.to_s)\n end", "def git(command, options = {})\n error = options[:error] || true\n unless which(\"git\") || which(\"git.exe\") || which(\"git.bat\")\n raise GitNotInstalled\n end\n\n response = Mixlib::ShellOut.new(%{git #{command}}, options)\n response.run_command\n\n if error && response.error?\n raise GitError.new \"#{command} #{cache_path}: #{response.stderr}\"\n end\n\n response.stdout.strip\n end", "def command( cmd )\r\n ## note: for now use Kernel#system for calling external git command\r\n ##\r\n\r\n cmdline = \"git #{cmd}\"\r\n puts \" trying >#{cmdline}< in (#{Dir.pwd})...\"\r\n \r\n result = nil\r\n result = system( cmdline )\r\n\r\n pp result\r\n\r\n # note: Kernel#system returns\r\n # - true if the command gives zero exit status\r\n # - false for non zero exit status\r\n # - nil if command execution fails\r\n # An error status is available in $?.\r\n\r\n if result.nil?\r\n puts \"*** error was #{$?}\"\r\n fail \"[Kernel.system] command execution failed >#{cmdline}< - #{$?}\" \r\n elsif result ## true => zero exit code (OK)\r\n puts 'OK' ## zero exit; assume OK\r\n true ## assume ok\r\n else ## false => non-zero exit code (ERR/NOK)\r\n puts \"*** error: non-zero exit - #{$?} !!\" ## non-zero exit (e.g. 1,2,3,etc.); assume error\r\n \r\n ## log error for now ???\r\n # File.open( './errors.log', 'a' ) do |f|\r\n # f.write \"#{Time.now} -- repo #{@owner}/#{@name} - command execution failed - non-zero exit\\n\"\r\n # end\r\n raise GitError.new( \"command execution failed >#{cmdline}< - non-zero exit (#{$?})\" )\r\n end\r\n end", "def git(command)\n there { `git #{command} 2>&1`.strip }\n end", "def git_command(cmd, opt_str, dir)\n run_in_shell(\"git #{cmd} #{opt_str}\", dir)\n end", "def native(cmd, opts = [], chdir = true, redirect = '', &block)\n validate\n\n ENV['GIT_DIR'] = @git_dir\n ENV['GIT_INDEX_FILE'] = @git_index_file\n ENV['GIT_WORK_TREE'] = @git_work_dir\n path = @git_work_dir || @git_dir || @path\n\n opts = [opts].flatten.map {|s| escape(s) }.join(' ')\n git_cmd = \"git #{cmd} #{opts} #{redirect} 2>&1\"\n\n out = nil\n if chdir && (Dir.getwd != path)\n Dir.chdir(path) { out = run_command(git_cmd, &block) }\n else\n out = run_command(git_cmd, &block)\n end\n\n if @logger\n @logger.info(git_cmd)\n @logger.debug(out)\n end\n\n if $?.exitstatus > 0\n if $?.exitstatus == 1 && out == ''\n return ''\n end\n raise Git::CommandFailed.new(git_cmd, $?.exitstatus, out.to_s)\n end\n out\n end", "def git(command={})\n if command.is_a?(Symbol)\n run \"git #{command}\"\n else\n command.each do |command, options|\n run \"git #{command} #{options}\"\n end\n end\n end", "def run\n # Pure git-feats command\n case @args[0]\n when \"feats\"\n run_feats_cmd\n\n # Overriden git command\n when \"version\" || \"--version\"\n version\n\n # Pure git command\n else\n exec_args\n end\n end", "def git(path, cmd, log=true)\n $stdout.puts(\"#{path.sub(ROOT_PATH, '')}: git #{cmd}\") if log\n git_path = path / '.git'\n git_index = git_path / 'index'\n\n # The env can become polluted; breaking git. This will avoid that.\n %x[GIT_DIR=#{git_path}; GIT_WORK_TREE=#{path}; GIT_INDEX_FILE=#{git_index}; git #{cmd}]\nend", "def git(command = {})\r\n in_root do\r\n if command.is_a?(Symbol)\r\n log 'running', \"git #{command}\"\r\n Git.run(command.to_s)\r\n else\r\n command.each do |command, options|\r\n log 'running', \"git #{command} #{options}\"\r\n Git.run(\"#{command} #{options}\")\r\n end\r\n end\r\n end\r\n end", "def command(cmd, opts = [], env_vars = [])\n # TODO:global config, pointing at correct working path and git dir\n global_opts = []\n global_opts << \"--git-dir=#{@git_dir}\" if @git_dir\n global_opts << \"--work-tree=#{@git_work_dir}\" if @git_work_dir\n\n global_opts = global_opts.flatten.join(' ') # TODO: should be escaped?\n\n opts = [opts].flatten.join(' ') # TODO: should be escaped?\n env_vars = [env_vars].flatten.join(' ') # ENV variables\n\n git_cmd = [env_vars, 'git', global_opts, 'annex', cmd, opts].join(' ')\n output, status = Open3.capture2e(git_cmd)\n exitstatus = status.exitstatus\n\n # Potentially might have to revisit this to not raise errors when status\n # code is 1 and there is no output. See `Git::Lib#command` implementation.\n if exitstatus != 0\n raise ExtendedGit::Error.new(\"#{git_cmd}:#{output}\".gsub(env_vars, '').strip) # Removing env variables from error message.\n end\n\n output.chomp\n end", "def test_git!\n result = `which git`\n if $?.exitstatus != 0\n raise IOError, \"Can't find git\"\n end\n end", "def git_fetch\n Command.new(\"git\", \"fetch\", \"--tags\", \"-f\").run!.raise!\nend", "def run\n logger.info(\"Running command : git-shell -c #{@cmd_cmd} '#{@real_path}'\")\n if system(Settings.git.shell, \"-c\", \"#{@cmd_cmd} '#{@real_path}'\")\n logger.info(\"\\t\\tOK\")\n else\n logger.info(\"\\t\\tKO\")\n end\n end", "def git_fetch\n Command.new(\"git\", \"fetch\", \"--tags\").run!.raise!\nend", "def exec_git(*args)\n exec_args = { failonfail: true, combine: true }\n if @resource.value(:user) && @resource.value(:user) != Facter['id'].value\n env = Etc.getpwnam(@resource.value(:user))\n exec_args[:custom_environment] = { 'HOME' => env['dir'] }\n exec_args[:uid] = @resource.value(:user)\n end\n Puppet::Util::Execution.execute([:git, args], **exec_args)\n end", "def git(commands={})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands={})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands={})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands = {})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands = {})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def command_git_cmd(path, git_cmd, chdir, block)\n out = nil\n if chdir and (Dir.getwd != path)\n Dir.chdir(path) { out = run_command(git_cmd, &block) }\n else\n out = run_command(git_cmd, &block)\n end\n return out\n end", "def get_output(cmd)\n log \"Running #{cmd}\"\n # git commands output fatal errors to stderr,\n # so capture that.\n # (ref http://blog.honeybadger.io/capturing-stdout-stderr-from-shell-commands-via-ruby/)\n stdout, stderr, status = nil, nil, nil\n Dir.chdir(@repo_dir) do |d|\n stdout, stderr, status = Open3.capture3(cmd)\n end\n\n if (stderr.strip != \"\" and stderr =~ /fatal/m) then\n msg = <<HERE\nstderr fatal error:\n#{stderr}\nRaised during git command:\n#{cmd}\nHERE\n raise msg\n end\n\n # Some git commit subject lines contained control characters (\"^M\")\n # which broke parsing. I tried using the methods given in\n # https://www.ruby-forum.com/topic/172061 to remove those bad chars,\n # but it didn't work. Below is adapted from\n # https://rosettacode.org/wiki/Strip_control_codes_and_extended_characters_from_a_string#Ruby\n clean_stdout = stdout.chars.each_with_object(\"\") do |char, str|\n displayable = (char.ascii_only? and char.ord.between?(32,126))\n str << char if (displayable || char == \"\\n\" || char == \"\\t\")\n end\n \n return clean_stdout.\n split(\"\\n\").\n map { |s| s.strip }.\n select { |s| s != '' }\n end", "def command(cmd, opts = [], chdir = true, redirect = '', &block)\n ENV['GIT_INDEX_FILE'] = File.join(workdir, '.git', 'index')\n ENV['GIT_DIR'] = File.join(workdir, '.git')\n ENV['GIT_WORK_TREE'] = workdir\n path = workdir\n\n git_cmd = create_git_command(cmd, opts, redirect)\n\n out = command_git_cmd(path, git_cmd, chdir, block)\n\n if logger\n logger.debug(git_cmd)\n logger.debug(out)\n end\n\n handle_exitstatus($?, git_cmd, out)\n end", "def run\n usage \"[0.1.2 - version, 100/10/1 - bump major/minor/patch, .build - add build] Commit message goes here\" if @argv.empty?\n\n # First Arg may indicate version command if it matches pattern\n version_command = @argv[0] =~ COMMAND_PATTERN ? @argv.shift : nil\n\n # All the other args lumped into message, or default message\n if @argv.empty?\n commit_message = \"Commit #{Time.now.to_s[0..-6]}\"\n history_message = nil\n else\n commit_message = history_message = @argv.join(' ')\n end\n\n # Updating version only if version command set\n if version_command\n puts \"Updating version with #{version_command}\"\n if history_message\n system %Q{rake \"version[#{version_command},#{history_message}]\"}\n else\n system %Q{rake version[#{version_command}]}\n end\n end\n\n puts \"Adding all the changes\"\n system \"git add --all\"\n\n puts \"Committing everything with message: #{commit_message}\"\n system %Q[git commit -a -m \"#{commit_message}\" --author arvicco]\n\n current_branch = `git branch`.strip\n puts \"Pushing to (default) remote for branch: #{current_branch}\"\n system \"git push\"\n end", "def git_on(host, git_sub_command, git_repo_path, opts = {})\n git_command = \"git --git-dir=#{git_repo_path}/.git --work-tree=#{git_repo_path} #{git_sub_command}\"\n\n on(host, git_command, opts)\nend", "def git(args, &block)\n Sprout::GitTask.define_task(args, &block)\nend", "def gitworld(command)\n home = ENV[\"PWD\"]\n paths = [ \\\n\t\"vendor/bundles/Cordova/Bundle/FormModelBundle\",\t\\\n\t\"vendor/phpspec\",\t\\\n\t\"vendor/phpspec-symfony2\",\t\\\n\t\"vendor/PHPAutotest\",\t\\\n ]\n paths.each do |path|\n fullpath = \"#{home}/#{path}\"\n if File.directory? fullpath\n Dir.chdir(\"#{fullpath}\")\n popen3(\"git #{command}\") do |stdin, stdout, stderr, wait_thr|\n output = stdout.read\n error = stderr.read\n printf \"============================[ %30s ]=======\\n%s\", path, output\n puts \"\" if output.length > 0\n print stderr.read\n puts \"\" if error.length > 0\n end\n end\n end\nend", "def create_git_command(cmd, opts, redirect)\n opts = [opts].flatten.map { |s| escape(s) }.join(' ')\n return \"git #{cmd} #{opts} #{redirect} 2>&1\"\n end", "def push(arg='')\n `git push #{arg} 2>&1`\n end", "def exec_git_cmd( cmd, actor=nil )\n old_aname = ENV['GIT_AUTHOR_NAME']\n old_aemail = ENV['GIT_AUTHOR_EMAIL']\n old_cname = ENV['GIT_COMMITTER_NAME']\n old_cemail = ENV['GIT_COMMITTER_EMAIL']\n old_pager = ENV['GIT_PAGER']\n\n if actor\n ENV['GIT_AUTHOR_NAME'] = actor.name\n ENV['GIT_AUTHOR_EMAIL'] = actor.email\n ENV['GIT_COMMITTER_NAME'] = actor.name\n ENV['GIT_COMMITTER_EMAIL'] = actor.email\n end\n ENV['GIT_PAGER'] = ''\n\n # Note: we cannot use Grit#raw_git_call as it requires an index file\n rv = exec_in_git_dir do \n `#{cmd}`\n raise CommandError, rv if $? != 0\n end\n\n ENV['GIT_AUTHOR_NAME'] = old_aname\n ENV['GIT_AUTHOR_EMAIL'] = old_aemail\n ENV['GIT_COMMITTER_NAME'] = old_cname\n ENV['GIT_COMMITTER_EMAIL'] = old_cemail\n ENV['GIT_PAGER'] = old_pager\n\n rv\n end", "def cmd(*args)\n command = Shellwords.join(args)\n out = `#{command}`.strip\n fail!(puts \"command failed: #{command}\", $?.exitstatus) unless $?.success?\n out\nend", "def execute\n cmd = FetchGitCommits.new(@from, @to, @repo, @author)\n cmd.execute\n @commits = cmd.commits\n nil end", "def check_git_repo\n # check local dir\n\n # use Open3 in order to get stderr output from child process\n # `` syntax only returns stdout output which is not enough\n\n # since command are all executed in newly spawned child processes so there's no need to record old dir path\n stdout, stderr = Open3.popen3(\"cd #{@local_path} && git status\")[1..2]\n\n local_branch_name = stdout.gets.to_s.match(/^On branch ([^\\s]+)/)[1]\n unless local_branch_name\n raise GitRepoException, \"local path #{@local_path} is not a git repository\"\n end\n\n # check remote dir\n valid = true\n remote_branch_name = ''\n @ssh.exec!(\"cd #{@remote_path} && git status\") do |ch, stream, data|\n case stream\n when :stdout\n valid = false unless (remote_branch_name = data.match(/^On branch ([^\\s]+)/)[1])\n when :stderr\n valid = false unless (data.nil? or data == '')\n end\n end\n unless valid\n raise GitRepoException, \"remote path #{@remote_path} is not a git repository\"\n end\n\n # check match\n if local_branch_name != remote_branch_name\n raise GitRepoException, \"local branch(#{local_branch_name}) and remote branch(#{remote_branch_name}) don't match\"\n end\n end", "def run_command\n # this should probably be run without bundle exec, I guess\n 'git status --porcelain'\n end", "def call\n if git_remote_command =~ /git@github.com:(.+).git/\n \"https://github.com/#{Regexp.last_match(1)}\"\n else\n git_remote_command.sub('.git', '').chomp\n end\n end", "def git_changes?\n Dir.chdir(@dir) do\n git = Process.spawn('git', 'diff-index', '--cached', '--quiet', 'HEAD')\n Process.wait(git)\n raise \"git diff-index failed weirdly: #{$?.exitstatus}\" if $?.exitstatus > 1\n $?.exitstatus == 1\n end\n end", "def info args\n # Find base of git directory\n until Dir.glob('.git').length > 0 do\n if '/'==Dir.pwd\n @out.puts \"can't find .git directory this or any parent folder!\"\n return\n end\n Dir.chdir('..')\n end\n\n @out.puts \"(in \"+Dir.pwd+')'\n\n # Show various information about this git directory\n @out.puts \"== Remote URL: \"\n @out.puts `git remote -v`\n\n @out.puts \"== Remote Branches: \"\n @out.puts `git branch -r`\n\n @out.puts \"== Local Branches:\"\n @out.puts `git branch`\n @out.puts \"\\n\"\n\n @out.puts \"== Configuration (.git/config)\"\n File.open('.git/config'){|fh| @out.puts fh.read }\n @out.puts \"\\n\"\n\n @out.puts \"== Most Recent Commit\"\n @out.puts `git log --max-count=1`\n @out.puts \"\\n\"\n\n @out.puts \"Type 'git log' for more commits, or 'git show' for full commit details.\"\n\n end", "def git_checkout_and_push_u(name, opts={})\n cmd = \"git checkout -b #{name}\"\n puts cmd\n out = `#{cmd}`\n if $? == 0\n cmd = \"git push -u origin #{name}\"\n puts cmd\n out = `#{cmd}`\n if $? == 0\n # nothing\n else\n $stderr.puts \"ERROR: failed to push '#{name}' to origin\"\n end\n else\n $stderr.puts \"ERROR: failed to checkout '#{name}'\"\n end\nend", "def git\n\tend", "def execute(initial_args, options = {})\n if initial_args.include?('|')\n raise Overcommit::Exceptions::InvalidCommandArgs,\n 'Cannot pipe commands with the `execute` helper'\n end\n\n result =\n if (splittable_args = options.fetch(:args) { [] }).any?\n debug(initial_args.join(' ') + \" ... (#{splittable_args.length} splittable args)\")\n Overcommit::CommandSplitter.execute(initial_args, options)\n else\n debug(initial_args.join(' '))\n Overcommit::Subprocess.spawn(initial_args, options)\n end\n\n debug(\"EXIT STATUS: #{result.status}\")\n debug(\"STDOUT: #{result.stdout.inspect}\")\n debug(\"STDERR: #{result.stderr.inspect}\")\n\n result\n end", "def cmd\n c = [\"git checkout #{other_branch}\"]\n c << argument_string(unknown_options) unless unknown_options.empty?\n c.join(\"\\n\")\n end", "def run_shell_cmd(args)\n system(*args)\n raise \"command exited with a nonzero status code #{$?.exitstatus} (command: #{args.join(' ')})\" if !$?.success?\n end", "def is_git?\n `git status 2> /dev/null` != \"\"\nend", "def git_wrapper (dpath = Dir.pwd)\n\n\tbegin\n\t\tRugged::Repository.new(dpath)\n\n\trescue Rugged::RepositoryError => err\n\n\t\tputs \"could not find repository at #{dpath}\"\n\t\texit 1\n\n\trescue Exception => err\n\n\t\tputs \"an error occurred while opening .git repository for #{dpath}\"\n\t\tputs err.message\n\t\texit 1\n\n\tend\n\nend", "def GitSimple(*args) # rubocop:disable Naming/MethodName\n GitSimple.new(*args)\nend", "def sh_exec(*args)\n unless args.last.kind_of? Hash\n args << {}\n end\n\n opts = args.last\n opts[:err] = [:child, :out] # write stdout and stderr to pipe, so we can read it later\n\n out = IO.popen(args, 'r') {|io| io.read}\n success = $? == 0\n\n return success, out\n end", "def exec(command)\n #logger.debug { \"Github: Executing command: '#{command}'\" }\n #p \"Github: Executing command: '#{command}'\"\n \n # Get a path to a temp file\n #logfile = Tempfile.new('github__exec')\n #logfile.close\n \n #success = system(\"#{command} > #{logfile.path} 2>&1\")\n #output_from_command = File.readlines(logfile.path)\n #output_from_command = %x[command]\n shell = Shell.new(command)\n shell.run\n success = (shell.exitstatus == 0)\n output_from_command = shell.output\n if success\n #logger.debug { \"Github: Command output: #{output_from_command.inspect}\"}\n #p \"Github: Command output: #{output_from_command.inspect}\"\n return output_from_command\n else\n #logger.error { \"Github: Command '#{command}' didn't exit properly. Full output: #{output_from_command.inspect}\"}\n p \"Github: Command failed '#{command}' didn't exit properly. Full output: #{output_from_command.inspect}\"\n end\n \n #ensure\n #logfile.unlink\n end", "def git_clone(repo, destination)\n result = `git clone -q #{repo} #{destination}`\n if $?.exitstatus != 0\n error \"Failed to clone #{repo} into #{destination} (Exit status: #{$?.exitstatus})!\"\n error \"Result: #{result}\" unless result.empty?\n exit $?.exitstatus\n end\n end", "def git_get(dir=nil)\n if dir.nil?\n directory = Dir.pwd\n else\n directory = dir\n end\n Dir.chdir(directory) do \n system('git clone https://github.com/offensive-security/exploit-database.git ~/src/exploit-db-git')\n end\nend", "def git_tag tag\n system \"git tag #{tag}\"\n raise \"tag failed\" unless $?\nend", "def rev_parse(*args)\n return args if args.empty?\n \n sandbox do |git,w,i|\n shas = git.run('', :rev_parse, '', {}, args).split(\"\\n\")\n \n # Grit::Git#run only makes stdout available, not stderr, and so this\n # wonky check relies on the fact that git rev-parse will print the\n # unresolved ref to stdout and quit if it can't succeed. That means\n # the last printout will not look like a sha in the event of an error.\n unless shas.last.to_s =~ SHA\n raise \"could not resolve to a sha: #{shas.last}\"\n end\n \n shas\n end\n end", "def run(args)\n parse_command_line(args)\n return 0 if @options.help_requested\n\n verify_gitlab_running\n\n # This logic block is fragile, but the best we can do due to limitations\n # of the gitlab-rails console. Here are details for maintainers:\n #\n # - This logic was developed with gitlab-ce-13.7.1, but verified to also work\n # with gitlab-ce-12.3.0.\n # - The gitlab-rails console uses IRB from the gitlab-provided Ruby.\n # - IRB will not exit with a bad error code when any command fails. This\n # means we have to scrape the command output to determine if the\n # commands succeed.\n # - When the input is piped to the gitlab-rails console, IRB determines\n # that the input is not from a TTY, and\n # * does not emit any prompts, which could have been customized via IRB\n # configuration\n # * does not prepend successful command results with '\\t=> ' or a\n # configured string\n # * does not use ANSI cursor-moving command sequences that provide a more\n # IDE-like experience; a feature introduced with Ruby 2.7.0.\n #\n # The suppression of the prompt and result prefix prevents this script from\n # failing due to user IRB configuration. The suppression of the ANSI\n # cursor-moving behavior allows easier support of different versions of\n # GitLab. (See NOTE below).\n # - Rails allows customization of the application that provides the console,\n # so it is possible (not necessarily likely) that the console could change\n # to a non-IRB implementation in a future GitLab release.\n #\n # NOTE: Previous versions of this script used expect and parsed the\n # output based on the command prompt and results prefix for each individual\n # command in gitlab_ruby_commands below. This is no longer viable because of\n # the ANSI cursor-moving character sequences that Ruby 2.7's IRB uses when a\n # user enters a command. The cursor-moving sequences are used every time\n # a user enters a character. For example, the command prompt is modified to\n # contain a '?' character, when the input does not yet pass Ruby syntax\n # validation. Even though the final characters displayed on the console\n # look largely the same as what was displayed in earlier Ruby IRB versions,\n # this behavior completely changes the characters sequences sent to the\n # console and gathered by expect.\n\n debug(\"Loading gitlab-rails console and executing change (this can take some time)...\\n\")\n\n # Password will be wrapped in double quotes within a single-quoted bash string.\n safe_password = @options.password.gsub(/\"/,'\\\\\"')\n gitlab_ruby_commands = [\n 'user = User.where(username: \"root\")[0]',\n \"user.password = \\\"#{safe_password}\\\"\",\n \"user.password_confirmation = \\\"#{safe_password}\\\"\",\n 'user.save!'\n ].join('; ')\n\n command = \"echo '#{gitlab_ruby_commands}' | #{GITLAB_CONSOLE_COMMAND}\"\n debug(\"Executing: #{command}\\n\")\n\n begin\n Timeout::timeout(@options.load_timeout) do\n console_out = `#{command} 2>&1`\n debug(console_out)\n\n # The last Ruby command executed in the Rails console (`user.save!`)\n # returns true when the valid User record has been saved. This is true\n # even if you are overwriting the User record with the same information.\n # Any failures in that command or a prior command in the semi-colon\n # separated command list will spew out error messages instead.\n\n lines = console_out.split(\"\\n\").delete_if { |line| line.empty? }\n\n if lines.last !~ /^true$/\n raise('Password set operation failed.')\n end\n end\n rescue Timeout::Error\n err_msg = \"Password set operation timed out after #{@options.load_timeout} seconds.\"\n raise(err_msg)\n end\n\n puts 'GitLab root password set'\n\n debug(\"Writing marker file #{MARKER_FILE}\\n\")\n FileUtils.touch(MARKER_FILE)\n\n return 0\n\n rescue Exception => e\n err_msg = \"\\nFAILED to set GitLab root password\"\n err_msg += \":\\n #{e.message}\" unless e.message.strip.empty?\n err_msg += \"\\n\"\n\n unless @options.debug\n # don't print out the actual password in this message so it\n # doesn't end up in a Puppet log\n debug_cmd = \"#{PROGRAM_NAME} -v -t #{@options.load_timeout} <password>\"\n err_msg += \"\\nRun '#{debug_cmd}' manually to debug\"\n end\n\n warn(err_msg)\n return 1\n end", "def command_runner cmd:, repo:nil, branch:nil\n status = run_cmd(cmd)\n status\n end", "def go_with_args(argv=[])\n catch(:exit_err) { catch(:exit_zero) { @cli_obj.go(argv) } }\n end", "def get(*args)\n arguments(args, required: [:user, :repo, :sha])\n\n get_request(\"/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}\", arguments.params)\n end", "def sh(cmd)\n output = `#{cmd}`\n if !$?.success?\n puts \"Command exited with failure code: #{cmd}\"\n puts \"Aborting.\"\n exit(1)\n end\n output\nend", "def git\n # log \"Thread.current[:repo] nil? \" + Thread.current[:repo].nil?.to_s\n Thread.current[:repo] ||= clone(ARGV[0], ARGV[1])\n Thread.current[:repo]\n end", "def run_command(cmd, *args)\n r,w = IO.pipe\n\n pid = fork do\n r.close\n STDIN.close\n STDOUT.reopen(w)\n STDERR.reopen(w)\n\n exec(cmd, *args)\n end\n\n w.close\n output = r.read.force_encoding('binary')\n pid, status = Process::wait2(pid)\n\n [output, status]\n end", "def system cmd, *args\n ohai \"#{cmd} #{args*' '}\".strip\n\n if ARGV.verbose?\n safe_system cmd, *args\n else\n rd, wr = IO.pipe\n pid = fork do\n rd.close\n $stdout.reopen wr\n $stderr.reopen wr\n exec(cmd, *args) rescue nil\n exit! 1 # never gets here unless exec threw or failed\n end\n wr.close\n out = ''\n out << rd.read until rd.eof?\n Process.wait\n unless $?.success?\n puts out\n raise\n end\n end\n rescue SystemCallError\n # usually because exec could not be find the command that was requested\n raise\n rescue \n raise BuildError.new(cmd, args, $?)\n end", "def execute(*args)\n set_config('gist.api-url', DEFAULT_GITHUB_API_BASE_URL) if !config('gist.api-url')\n set_config('gist.default-url', DEFAULT_GITHUB_API_BASE_URL) if !config('gist.default-url')\n\n begin\n option_parser.parse!(args)\n\n if $stdin.tty? && options.setup_credentials\n api_url # make sure API URL selection happens, if need be\n setup_credentials\n exit 1\n end\n\n if $stdin.tty? && args[0] != '-'\n # Run without stdin.\n usage if args.empty?\n\n files = args.inject([]) { |list, file|\n # Check if arg is a file. If so, grab the content.\n abort \"Can't find #{file}\" unless File.exists?(file)\n\n list.push({\n :input => File.read(file),\n :filename => file,\n :extension => file.include?('.') ? File.extname(file) : options.gist_extension\n })\n }\n else\n # Read from standard input.\n input = $stdin.read\n files = [{:input => input, :extension => options.gist_extension}]\n end\n\n url = write(files, options.private_gist, options.description)\n browse(url) if options.browse_enabled\n $stdout.puts copy(to_embed(url)) if options.embed_enabled\n $stdout.puts copy(url) unless options.embed_enabled\n rescue Interrupt\n $stderr.puts \"\\nQuit.\"\n exit 1\n rescue OptionParser::InvalidOption => e\n warn e; puts\n usage\n exit 1\n rescue StandardError => e\n options.debug ? warn(e) : raise(e)\n end\n end", "def run(*args)\n logger.info(\"Running `#{args.shelljoin}`...\") if PrlBackup.config[:verbose]\n output = `#{args.shelljoin} 2>&1`\n status = $?\n unless status.success?\n logger.error(\"Command `#{args.shelljoin}` failed with exit status #{status.exitstatus}:\\n#{output}\")\n exit(1)\n end\n output\n end", "def cmd\n c = ['git commit']\n c << '-a' if all?\n c << %(-m \"#{options.message}\") if message?\n c << %(-m \"#{message}\") unless story_ids.empty?\n c << argument_string(unknown_options) unless unknown_options.empty?\n c.join(' ')\n end", "def run\n if self.is_git?\n self.aqlog(\"Running command : git-shell -c #{@cmd_cmd} '#{@real_path}'\")\n if system(Settings.git.shell, \"-c\", \"#{@cmd_cmd} '#{@real_path}'\")\n self.aqlog(\"\\t\\tOK\")\n else\n self.aqlog(\"\\t\\tKO\")\n end\n elsif self.is_hg?\n hg_commands = self.fresh_cmd.split(\" \")\n added_path = Settings.aq_sh.user_home + \"/\" +\n Settings.aq_sh.user_name + \"/\" +\n Settings.hg.repo_path\n hg_command = \"#{hg_commands[0]} #{hg_commands[1]} #{added_path}/#{hg_commands[2]} #{hg_commands[3]} #{hg_commands[4]}\"\n cmd_to_run = hg_command\n self.aqlog(\"Running command : #{cmd_to_run}\")\n if system(cmd_to_run)\n self.aqlog(\"\\t\\tOK\")\n else\n self.aqlog(\"\\t\\tKO\")\n end\n end\n end", "def run_git_first_commit\n raise \"Git 1st commit failed\" unless system(\"set +x; git commit\")\n end", "def test_gitgo_different_from_remote_gitgo\n assert !sh(a, 'git branch -a').include?('gitgo')\n assert !sh(b, 'git branch -a').include?('gitgo')\n assert !sh(c, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"bshasum\") {|io| io << \"b content\" }\n sh(b, 'git add bshasum')\n sh(b, 'git commit -m \"added document\"')\n \n # setup remote from c\n sh(c, 'git branch gitgo')\n sh(c, 'git checkout gitgo')\n method_root.prepare(c, \"cshasum\") {|io| io << \"c content\" }\n sh(c, 'git add cshasum')\n sh(c, 'git commit -m \"added document\"')\n sh(c, 'git push origin gitgo')\n \n # now try to push back, fails\n assert sh(b, 'git push origin gitgo').include?(\"! [rejected] gitgo -> gitgo (non-fast forward)\")\n \n sh(a, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # merge\n sh(b, 'git fetch')\n assert sh(b, 'git branch').include?('gitgo')\n assert sh(b, 'git branch -a').include?('origin/gitgo')\n sh(b, 'git merge origin/gitgo')\n \n # now push works\n sh(b, 'git push origin gitgo')\n sh(a, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # fetch for c leaves changes unmerged\n sh(c, 'git fetch')\n sh(c, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n \n # manual merge fixes\n sh(c, 'git merge gitgo origin/gitgo')\n sh(c, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n end", "def git_init\n\tsystem('git init')\nend", "def system_cmd(cmd)\n exit_val = nil\n cmd_to_run = cmd\n cmd_to_run = \"#{@git_ssh_cmd} #{cmd}\" if cmd.start_with? 'git'\n Open3.popen3(cmd_to_run) do |stdin, stdout, stderr, wait_thr|\n stdin.close\n\n block_size = 1\n io_buffers = {stdout: '', stderr: ''}\n output_buffer = []\n outputs = {stdout => :stdout, stderr => :stderr}\n\n begin\n until outputs.keys.all?(&:eof) do\n ready = IO.select(outputs.keys)\n if ready\n readable = ready[0]\n readable.each do |f|\n file_type = outputs[f]\n begin\n data = f.read_nonblock(block_size)\n\n io_buffers[file_type] << data\n if data == \"\\n\"\n payload = {file_type => io_buffers[file_type]}\n puts payload.inspect\n output_buffer << payload\n\n io_buffers[file_type] = \"\"\n end\n rescue EOFError\n end\n end\n end\n end\n rescue IOError\n end\n\n exit_val = wait_thr.value\n @build.build_logs.create(\n text: output_buffer.to_json,\n cmd: cmd_to_run,\n exit_code: exit_val,\n )\n end\n\n exit_val\n end", "def cmd\n \"git checkout #{other_branch}\"\n end", "def git_commit_all message\n system \"git add --all .\"\n return false unless $?\n system \"git commit -q -m '#{message.gsub(/'/, \"\\'\")}'\"\n return $?\nend", "def shell(*args)\n Open3.popen3(*args) do |_stdin, stdout, stderr, wait_thr|\n if wait_thr.value != 0\n puts \"\\nCommand '#{args.join ' '}' has failed\"\n puts \"STDOUT: #{stdout.gets nil}\"\n puts \"STDERR: #{stderr.gets nil}\"\n\n raise\n end\n end\n end", "def git_commit(repo, sha, options = {})\n get \"#{Repository.path repo}/git/commits/#{sha}\", options\n end", "def find_pass(command, args={})\n args = {\n :step => 1,\n :fail => @options[:fail],\n :pass => @options[:pass]\n }.merge(args)\n\n if !system(\"git reset --hard -q #{@options[:fail]} && git reset --hard -q #{args[:pass]} 2> /dev/null\")\n puts \" couldn't find any pass commit, fell off the history\"\n args[:pass] = nil\n return args\n end\n\n print \" looking #{args[:step]} commits back at: #{oneline_for(args[:pass])} ... \"\n File.open(@options[:command_log], 'w+') {|fh| fh.puts command}\n success = system(\"#{command} >>#{@options[:command_log]} 2>&1\")\n if success\n puts ' pass!'\n args\n else\n puts 'failing'\n args[:step] = args[:step] * 2\n args[:fail] = commit_for('HEAD')\n args[:pass] = commit_for(\"HEAD~#{args[:step]}\")\n find_pass(command, args)\n end\n end", "def discover_git_executable\n @git_executable ||= begin\n guessing_locations = [git_cmd]\n\n #:nocov:\n if RHC::Helpers.windows?\n guessing_locations << \n discover_windows_executables do |base|\n [ \n \"git.exe\",\n \"#{base}\\\\Git\\\\bin\\\\git.exe\", \n \"#{base}\\\\git.exe\", \n ]\n end\n end\n\n # make sure commands can be executed and finally pick the first one\n guessing_locations.flatten.uniq.select do |cmd| \n ((File.exist?(cmd) && File.executable?(cmd)) || exe?(cmd)) && \n (begin\n git_version(cmd)\n $?.success?\n rescue ; false ; end)\n end.collect{|cmd| cmd =~ / / ? '\"' + cmd + '\"' : cmd}.first\n #:nocov:\n end\n end", "def git_clone_main\n raise \"oops, not done\"\nend", "def fetch_command\n if usable_repository?\n prune_c = \"#{git} remote prune origin 2>&1\"\n fetch_c = \"#{git} fetch --force --prune --update-head-ok #{quiet} origin '+refs/heads/*:refs/remotes/origin/*' '+refs/tags/*:refs/tags/*' 2>&1\"\n\n \"#{prune_c} && #{fetch_c}\"\n else\n \"rm -rf #{repository_cache} && git clone #{quiet} #{uri} #{repository_cache} 2>&1\"\n end\n end", "def git_fetch path\n Open3.popen2e *%W(git fetch origin), chdir: path do |stdin, stdout, _wait|\n not stdout.read.chomp.empty?\n end\n end", "def git_null(command)\n git(\"#{command} 2>#{Bundler::NULL}\", false)\n end", "def main()\n\n # check that 3 arguments have been given, otherwise exit\n if ARGV.length < 3\n puts \"You haven't given enough arguments.\"\n exit\n end\n\n # the first argument should be the path to the local repository\n repo_path = ARGV[0]\n\n # the second argument should be the relevant GitHub username\n username = ARGV[1]\n\n # the third argument should be the repository name on GitHub\n repo_name = ARGV[2]\n\n # invoke link_commits with the arguments\n link_commits(repo_path, username, repo_name).each { |link| puts link }\nend", "def git_HEAD\n Dir.chdir(@dir) do\n commit = `git rev-parse HEAD`\n raise \"git rev-parse HEAD failed: #{$?.exitstatus}\" if $?.exitstatus != 0\n commit.chomp\n end\n end", "def commit\n @git = YMDP::GitHelper.new\n @git.do_commit(@message)\n @git_hash = git.get_hash(options[:branch]) \n end", "def git_describe\n @git_describe ||= begin\n git_cmd = \"git describe\"\n shell = Mixlib::ShellOut.new(git_cmd,\n :cwd => Omnibus.root)\n shell.run_command\n shell.error!\n shell.stdout.chomp\n end\n end", "def initialize(args = [])\n @args = args\n command = args.shift\n if command && self.respond_to?(command)\n unless command == 'help'\n @user, @repo = repo_info\n return unless @user && @repo && configure_github_access\n update unless command == 'clean'\n end\n self.send command\n else\n unless command.nil? || command.empty? || %w(-h --help).include?(command)\n puts \"git-review: '#{command}' is not a valid command.\\n\\n\"\n end\n help\n end\n rescue UnprocessableState\n puts 'Execution of git-review command stopped.'\n end", "def cmd\n lines = [\"git checkout #{target_branch}\"]\n c = [\"git merge --no-ff --log\"]\n c << %(-m \"#{message}\") unless story_ids.empty?\n c << argument_string(unknown_options) unless unknown_options.empty?\n c << story_branch\n lines << c.join(' ')\n lines.join(\"\\n\")\n end", "def git_check\n # May throw InvalidRepositoryException\n # - because of invalid path\n # - or broken git repository\n @repo = GitLib::Repo.new(path)\n end", "def add_git_facts\n # see if we're in a git repo. first, we need a directory that exists\n dir = @path.expand_path.ascend.find {|p| p.directory? }\n \n Dir.chdir(dir) do\n root_result = Cmds.new \"git rev-parse --show-toplevel\"\n \n unless root_result.ok?\n @result.in_git_repo = false\n @result.is_git_root = false\n return\n end\n \n @result.in_git_repo = true\n \n git = @result.git = Result.new\n git.root = Pathname.new root_result.out.chomp\n @result.is_git_root = @path == git.root\n \n user = git.user = Result.new\n \n ['name', 'email'].each {|key|\n user[key] = begin\n Cmds.chomp! \"git config user.#{ key }\"\n rescue\n end\n }\n \n git.origin = begin\n Cmds.chomp! \"git remote get-url origin\"\n rescue\n end\n \n match = GITHUB_SSH_URL_RE.match(git.origin) ||\n GITHUB_HTTPS_URL_RE.match(git.origin)\n \n git.is_github = !! match\n \n return unless match\n \n git.owner = match['owner']\n git.name = match['name']\n git.full_name = \"#{ git.owner }/#{ git.name }\"\n \n if true == @args['github_api']\n github = git.github = Result.new\n github.api_url = \"https://api.github.com/repos/#{ git.owner }/#{ git.name }\"\n \n response = Net::HTTP.get_response URI(github.api_url)\n \n if response.is_a? Net::HTTPSuccess\n # parse response body and add everything to github result\n parsed = JSON.parse response.body\n parsed.each {|k, v| github[k] = v}\n else\n # assume it's private if we failed to find it\n github.private = true\n end\n \n end\n end\n end" ]
[ "0.80866045", "0.80866045", "0.7993441", "0.798694", "0.79055065", "0.7795743", "0.7695566", "0.7680668", "0.76475877", "0.7645145", "0.76142055", "0.75880176", "0.75628316", "0.73071253", "0.7188069", "0.7121762", "0.7066952", "0.68923753", "0.67880005", "0.67830676", "0.6700506", "0.66800946", "0.6651336", "0.65340817", "0.64157796", "0.6409228", "0.638074", "0.6365477", "0.62766075", "0.6249", "0.6249", "0.6249", "0.6236824", "0.6236824", "0.6211047", "0.6168101", "0.6165185", "0.61082184", "0.6101689", "0.60855114", "0.6059997", "0.6014949", "0.5996995", "0.59946436", "0.5975389", "0.5957451", "0.5935308", "0.58664167", "0.5849285", "0.5838673", "0.5806069", "0.5784284", "0.5758368", "0.57438105", "0.57310975", "0.5728835", "0.570559", "0.5684643", "0.56590825", "0.5621294", "0.56133306", "0.5606072", "0.55997574", "0.5576337", "0.55681366", "0.5544603", "0.5542552", "0.5499866", "0.54982895", "0.5497314", "0.548748", "0.5459734", "0.5457477", "0.5448075", "0.5434236", "0.543028", "0.5426833", "0.5413954", "0.54059845", "0.53847927", "0.53789693", "0.5367269", "0.53665566", "0.53601533", "0.5356579", "0.53489834", "0.5346728", "0.53445673", "0.5343013", "0.5334243", "0.53289944", "0.53197473", "0.5309858", "0.5309616", "0.5307695", "0.53039205", "0.530362", "0.5284785", "0.5276802" ]
0.8750967
1
Returns list of uncommited/untracked files as reported by git status.
def uncommitted_files `git status`.scan(/^#(\t|\s{7})(\S.*)$/).map { |match| match.last.split.last } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_uncommitted_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-n', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"Changed files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend", "def uncommitted_files\n svn('status', '--ignore-externals').split(\"\\n\").reject { |line| line =~ /^X\\s/ }\n end", "def uncommitted_files\n files = nil\n p4 (['change','-o']).each do |line|\n files << line.strip if files\n files = [] if line.start_with?('Files:')\n end\n files ||= []\n end", "def uncommitted_files\n `hg status`.scan(/^(A|M|R|!|\\?) (\\S.*)$/).map{ |match| match.last.split.last }\n end", "def tracked_files\n all_files.reject { |f| ignore_matcher.matched?(f) }\n end", "def uncommitted_merge_files\n merge_state.uncommitted_merge_files\n end", "def check_changed_files(git)\n git.status.select {|file| file.type || file.untracked }\n end", "def currently_changed_files\n `git status --porcelain`.split(\"\\n\").map{ |file| file.split.last }\n end", "def get_unknown_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-un', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"New files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend", "def previously_changed_files\n `git show --pretty=\"format:\" --name-only`.split(\"\\n\")\n end", "def all_files_except_git\n Dir.glob('*', File::FNM_DOTMATCH).delete_if { |file| file =~ /\\A\\.{1,2}\\z|\\A\\.git\\z/ }\n end", "def all_files\n @all_files ||= `git ls-files 2> /dev/null`.split(\"\\n\")\n end", "def modified_files\n `git diff --cached --name-only --diff-filter=ACM --ignore-submodules=all`.split \"\\n\"\n end", "def get_files_modified\r\n\tgit_result = IO.popen('git status -u --porcelain').read\r\n\tgit_result.split(/[\\r\\n]+/).uniq.map!{|file| file.slice 3..-1}\r\nend", "def modified_files\n diff = git.diff(local_branch, remote_branch(local_branch))\n diff.stats[:files].keys\n end", "def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end", "def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end", "def gitignores\n %w[/tmp/librarian/]\n end", "def diff_files_from(commit)\n git_args = ['diff', '--stat', '--name-only', commit]\n result = default_repository.git_output(git_args).lines.map { |line| line.strip }.sort\n # not sure if git would ever mention directories in a diff, but ignore them.\n result.delete_if { |item| ::File.directory?(item) }\n return result\n end", "def excluded_files() = []", "def has_untracked_changes? \n not [repo.changed, repo.untracked].flatten.select do |k| \n k.include?(\".craft\") || k.eql?(\"persistent.sfs\") || k.eql?(\"quicksave.sfs\") \n end.empty?\n end", "def all_changed_files\n Set.new\n .merge(git.added_files.to_a)\n .merge(git.modified_files.to_a)\n .merge(git.renamed_files.map { |x| x[:after] })\n .subtract(git.renamed_files.map { |x| x[:before] })\n .to_a\n .sort\n end", "def files\n return unless git_repo?\n output = Licensed::Shell.execute(\"git\", \"ls-files\", \"--full-name\", \"--recurse-submodules\")\n output.lines.map(&:strip)\n end", "def staged\n @files.select { |k, f| f.sha_index != \"0000000000000000000000000000000000000000\" && f.type != nil }\n end", "def svn_status(current_dir)\n modified_files = []\n `svn status #{current_dir}`.split(/\\n/).map do |file|\n file =~ /(\\?|\\!|\\~|\\*|\\+|A|C|D|I|M|S|X)\\s*([\\w\\W]*)/\n\n if file =~ /^M/\n modified_files << file.split[-1]\n elsif file =~ /^C/\n raise \"ERROR: file found in conflict: #{file.split[-1]}\"\n end\n end\n return modified_files\nend", "def list_of_directories\n Dir.entries(\"./inspections\").select {|d| !d.start_with?(\".\") }\n end", "def unprocessed_files\n Dir.glob(@data_location + '/*.jl').sort\n end", "def ignored_files\n all_files.select { |f| ignore_matcher.matched?(f) }\n end", "def filter_git_diff_issues(issues)\n modified_files_info = git_modified_files_info()\n return issues.select { |i| \n modified_files_info[\"#{i['file']}\"] != nil\n }\n end", "def ignored\n @ignored ||= []\n @ignored.map(&:to_s)\n end", "def modified_files\n staged = squash?\n refs = 'HEAD^ HEAD' if merge_commit?\n @modified_files ||= Overcommit::GitRepo.modified_files(staged: staged, refs: refs)\n end", "def check_for_inexistent_files\n inexistent_files = []\n @files.each do |file|\n inexistent_files << file unless File.exists? file\n end\n\n inexistent_files\n end", "def working_files\n files.map {|f| working_file f}\n end", "def ignorable_paths\n []\n end", "def files_to_analyze\n require 'find'\n ignore_dirs = ['.git','bin','test','assets','lib','log','vendor','tmp','img', 'images', 'uploads', 'fonts']\n ignore_files = Regexp.union(/^\\..*$/i, /^.*(.md)$/i, /^.*(.json)$/i, /^.*(.yml)$/i, /^.*(.log)$/i, /^.*(.png)$/i, /^.*(.jpg)$/i, /^.*(.jpeg)$/i)\n final_files = []\n # for every file in repository - keep the files to process\n Find.find('.') do |path|\n path_name = File.basename(path)\n if FileTest.directory?(path)\n if ignore_dirs.include?(path_name)\n Find.prune\n else\n next\n end\n else\n if path_name.match(ignore_files)\n next\n else\n path.gsub!(/^\\.\\//, '')\n final_files.push(path)\n end\n end\n end\n return final_files\n end", "def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACM --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end", "def get_exclusions\n return \"\" if !has_git_ignores? || !has_git? \n git_ignore = File.join PWD, \".gitignore\"\n exclusions = `cat #{git_ignore}`.split(\"\\n\") \n # ensure we remove any commented out .gitignores\n exclusions = exclusions.select { |exclusion| exclusion[0,1] != '#' }\n exclusions = exclusions - @task_config[:always_include] \n if @dry_run\n puts wrap_top(\"EXCLUSIONS:\")\n puts exclusions.join(\"\\n\") \n end\n exclusions\n end", "def file_listing(commit)\n # The only reason this doesn't work 100% of the time is because grit doesn't :/\n # if i find a fix, it'll go upstream :D\n count = 0\n out = commit.diffs.map do |diff|\n count = count + 1\n if diff.deleted_file\n %(<li class='file_rm'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n else\n cla = diff.new_file ? \"add\" : \"diff\"\n %(<li class='file_#{cla}'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n end\n end\n \"<ul id='files'>#{out.join}</ul>\"\n end", "def target_files\n @target_files ||= (git.modified_files - git.deleted_files) + git.added_files\n end", "def check_clean_status_task\n raise \"The current working copy contains modifications\" if `#{git} ls-files -m`.split(\"\\n\").any?\n end", "def filter_git_diff_issues(issues)\n modified_files_info = git_modified_files_info\n return [] if modified_files_info.empty?\n\n filtered_issues = []\n issues.each do |issue|\n file = issue[\"file\"].to_s\n next if modified_files_info[file].nil? || modified_files_info[file].empty?\n\n filtered_errors = issue[\"errors\"].select { |error| modified_files_info[file].include?(error[\"line\"].to_i) }\n filtered_issues << { \"file\" => file, \"errors\" => filtered_errors } unless filtered_errors.empty?\n end\n filtered_issues\n end", "def files\n @files ||= Dir.glob(File.join(@root, '**/*'), GLOB_FLAGS).select do |path|\n File.file?(path) && path !~ IGNORE_REGEX\n end\n end", "def find_all_ignored\n skipped = []\n\n rubocop = YAML.load_file('./.rubocop.yml')\n rubocop['AllCops']['Exclude'].each do |ignored|\n skipped << ignored.split('/')[0]\n end\n\n skipped\nend", "def ignored\n [\n '.agignore',\n '.cvsignore',\n '.gitignore',\n '.hgignore',\n ].map do |file_with_ignore_patterns|\n if File.exist? file_with_ignore_patterns\n patterns = File.read(file_with_ignore_patterns).split(\"\\n\")\n patterns.map do |pattern|\n next if pattern =~ /^#/\n next if pattern =~ /^\\s*$/\n \"-not \\\\( -path \\\"*#{pattern}*\\\" -prune \\\\)\"\n end.compact.join(' ')\n else\n ''\n end\n end.join(' ') + [\n \"-not \\\\( -path \\\"*\\\\.git*\\\" -prune \\\\)\"\n ].join(' ')\nend", "def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACMR --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end", "def gitignore_list(dir)\n @gitignore_list ||= {}\n @gitignore_list[dir] ||= []\n\n ilist = []\n if File.exists?(dir + '/.gitignore')\n File.read(dir + '/.gitignore').split(\"\\n\").each do |line|\n Dir[dir + '/' + line].each do |f|\n fn = f.sub(/^#{dir}\\//, '')\n ilist << fn unless ilist.include?(fn)\n end\n end\n end\n @gitignore_list[dir] = ilist\n end", "def excluded_files\n # TODO: also append files marked as %{exclude} (or handle elsewhere?)\n missing_files_for(upstream_gem)\n end", "def changed_files\n # FIXME: Implement properly once changed detection is available.\n files\n end", "def ignored\n ignores.map {|ignore| ignore.ignoreable}\n end", "def filter_nonexistent(modified_files); end", "def tracked?(path)\n Overcommit::Utils.execute(%W[git ls-files #{path} --error-unmatch]).success?\n end", "def files\n @@files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n end", "def dependent_files\n processed.map(&:abs_path).compact.select { |fn| File.exist?(fn) }\n end", "def tracked_files; end", "def dirty?(exclude_spec=false)\n repo_status = false\n\n return repo_status unless File.directory?(path)\n\n Dir.chdir(path) do\n %x(git update-index -q --ignore-submodules --refresh)\n repo_status = \"Could not update git index for '#{path}'\" unless $?.success?\n\n unless repo_status\n %x(git diff-files --quiet --ignore-submodules --)\n repo_status = \"'#{path}' has unstaged changes\" unless $?.success?\n end\n\n unless repo_status\n %x(git diff-index --cached --quiet HEAD --ignore-submodules --)\n repo_status = \"'#{path}' has uncommitted changes\" unless $?.success?\n end\n\n unless repo_status\n # Things that may be out of date but which should stop the updating\n # of the git repo\n our_exclusions=[\n 'build/rpm_metadata',\n 'dist/'\n ]\n\n untracked_files = %x(git ls-files -o -d --exclude-standard --exclude=#{our_exclusions.join(' --exclude=')})\n\n if $?.success?\n unless untracked_files.empty?\n untracked_files.strip!\n\n if untracked_files.lines.count > 0\n repo_status = \"'#{path}' has untracked files\"\n end\n end\n else\n # We should never get here\n raise Error, \"Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'\"\n end\n end\n end\n\n repo_status\n end", "def releases_including_skipped()\n files = []\n\n cmd.ssh(\"ls -m #{releases_dir}\") do |stdout|\n files.concat(stdout.read.split(/[,\\s]+/))\n end\n\n return files\n end", "def all_incomplete_todos\n (global_incomplete_todos + local_incomplete_todos).uniq\n end", "def committed_files sha\n array_output_of \"git diff-tree --no-commit-id --name-only -r #{sha}\"\nend", "def repository_status(repo)\n untracked_files = 0\n modified_files = 0\n deleted_files = 0\n\n #- +:index_new+: the file is new in the index\n #- +:index_modified+: the file has been modified in the index\n #- +:index_deleted+: the file has been deleted from the index\n #- +:worktree_new+: the file is new in the working directory\n #- +:worktree_modified+: the file has been modified in the working directory\n #- +:worktree_deleted+: the file has been deleted from the working directory\n repo.status do |status|\n if status[1].include?(:worktree_new) || status[1].include?(:index_new)\n untracked_files += 1\n elsif status[1].include?(:worktree_modified) || status[1].include?(:index_modified)\n modified_files += 1\n elsif status[1].include?(:worktree_deleted) || status[1].include?(:index_deleted)\n deleted_files += 1\n end\n end\n\n return {\n untracked_files: untracked_files,\n modified_files: modified_files,\n deleted_files: deleted_files,\n clean: modified_files == 0 && deleted_files == 0\n }\nend", "def check_results\n bin = prettier_path\n raise \"prettier is not installed\" unless bin\n return run_check(bin, \".\") unless filtering\n ((git.modified_files - git.deleted_files) + git.added_files)\n .select { |f| f[matching_file_regex] }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", \"\") }\n .map { |f| run_check(bin, f) }\n end", "def unmanifested_files\n mfs = manifested_files.map { |f| File.join bag_dir, f }\n bag_files.reject { |f| mfs.member? f }\n end", "def unmanifested_files\n mfs = manifested_files.map { |f| File.join bag_dir, f }\n bag_files.reject { |f| mfs.member? f }\n end", "def files\n %x{\n find . -type f ! -path \"./.git/*\" ! -path \"./node_modules/*\"\n }.\n split(\"\\n\").\n map { |p| Pathname.new(p) }\n end", "def ignored_tracked_fields\n @ignored_tracked_fields ||= HistoryTracker.ignored_tracked_fields\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_changed_as_set(files)\n changed_files = files.select { |file| git.modified_files.include? file }\n not_changed_files = files.select { |file| !changed_files.include? file }\n all_files_changed = not_changed_files.empty?\n no_files_changed = changed_files.empty?\n return all_files_changed || no_files_changed\nend", "def files(dir)\n Dir[dir + '/**/*'].reject do |filename|\n File.directory?(filename) ||\n filename =~ /(~|\\.orig|\\.rej|\\.bak)$/\n end\n end", "def modified_files\n file_stats.count { |file| file.status == :modified }\n end", "def ignore\n @ignore ||= []\n end", "def ls\n table Dir.entries( Dir.pwd ).reject { |f| f.match /^\\..*$/ }\n end", "def report_files_that_dont_have_st_sync_active(options)\n inactive_files = []\n active_files = []\n total_file_count = 0\n\n Repositext::Cli::Utils.read_files(\n config.compute_glob_pattern(\n options['base-dir'] || :content_dir,\n options['file-selector'] || :all_files,\n options['file-extension'] || :at_extension\n ),\n options['file_filter'],\n nil,\n \"Reading content AT files\",\n options\n ) do |content_at_file|\n data_json_file = content_at_file.corresponding_data_json_file\n total_file_count += 1\n lang_and_date_code = [\n content_at_file.language_code_3_chars,\n content_at_file.extract_date_code\n ].join\n if data_json_file.contents.index('\"st_sync_active\":false')\n inactive_files << lang_and_date_code\n $stderr.puts \" - doesn't have st_sync_active\".color(:blue)\n else\n active_files << lang_and_date_code\n end\n end\n inactive_files_count = inactive_files.length\n active_files_count = active_files.length\n if inactive_files_count > 0\n $stderr.puts \"\\n\\n#{ inactive_files_count } files that DON'T HAVE st_sync_active:\"\n $stderr.puts '-' * 80\n inactive_files.each { |e| $stderr.puts e }\n $stderr.puts\n end\n if active_files_count > 0\n $stderr.puts \"\\n\\n#{ active_files_count } files that HAVE st_sync_active:\"\n $stderr.puts '-' * 80\n active_files.each { |e| $stderr.puts e }\n $stderr.puts\n end\n summary_line = \"Found #{ inactive_files_count } of #{ total_file_count } files that don't have st_sync_active at #{ Time.now.to_s }.\"\n $stderr.puts summary_line\n end", "def affected_files\n Dir[@result_dir + '/*.{ttf,eot,woff,svg}'].reject { |f| f[@file] }\n end", "def target_files\n @target_files ||= git.modified_files + git.added_files\n end", "def files\n if !@files\n files = Dir.glob(\"#{working_dir}/*\").map {|f| f.split(working_dir)[1][1..-1]}\n files.delete config_file\n @files = files\n end\n return @files\n end", "def get_file_names path\n Dir.entries(path).select { |file| !File.directory? File.join(path, file) }\n end", "def show_changed_files(status)\n status.each_line do |line|\n if line =~ /^#\\t/ # only print out the changed files (I think)\n if line =~ /new file:|modified:|deleted:/\n puts \" #{line}\" \n else\n puts \" #{line.chop}\\t\\t(may need to be 'git add'ed)\" \n end\n end\n end\nend", "def modified_files\n @modified_files ||= begin\n @modified_files = []\n\n rewritten_commits.each do |rewritten_commit|\n refs = \"#{rewritten_commit.old_hash} #{rewritten_commit.new_hash}\"\n @modified_files |= Overcommit::GitRepo.modified_files(refs: refs)\n end\n\n filter_modified_files(@modified_files)\n end\n end", "def all_commits\n `git --git-dir=#{git_dir} log --all --pretty='%H'`.split(/\\n/).uniq\n end", "def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end", "def get_svn_filelist( dir='.' )\n\tlist = IO.read( '|-' ) or exec 'svn', 'st', '-v', '--ignore-externals', dir\n\n\t# Split into lines, filter out the unknowns, and grab the filenames as Pathnames\n\t# :FIXME: This will break if we ever put in a file with spaces in its name. This\n\t# will likely be the least of our worries if we do so, however, so it's not worth\n\t# the additional complexity to make it handle that case. If we do need that, there's\n\t# always the --xml output for 'svn st'...\n\treturn list.split( $/ ).\n\t\treject {|line| line =~ /^(\\?|(\\s*|--- .*)$)/ }.\n\t\tcollect {|fn| Pathname(fn[/\\S+$/]) }\nend", "def files\n result = []\n @my_files.each do |f|\n result << f.fname if FileTest.file?(f.fname)\n end\n result\n end", "def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end", "def files_in branch:\n array_output_of(\"git ls-tree -r --name-only #{branch}\")\nend", "def deleted_files\n file_stats.count { |file| file.status == :deleted }\n end", "def removed_infections\n return [] unless prev_scan\n current_infections = scan.infections.collect{|infection| infection.file}\n prev_scan.infections.select{|infection| !current_infections.include?(infection.file)}\nend", "def blacklisted_dir_entries\n %w[. ..]\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 lint_results\n bin = eslint_path\n raise 'eslint is not installed' unless bin\n return run_lint(bin, '.') unless filtering\n ((git.modified_files - git.deleted_files - git.renamed_files.map { |r| r[:before] }) + git.added_files + git.renamed_files.map { |r| r[:after] })\n .select { |f| target_extensions.include?(File.extname(f)) }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", '') }\n .map { |f| run_lint(bin, f).first }\n end", "def getFilesFromDiff(diff)\n files = []\n diff.lines.map(&:chomp).each do |line|\n if line.start_with? '+++ b/'\n line[\"+++ b/\"] = \"\"\n # try to remove anything after a tab character\n # this is needed by --check 0\n begin\n line[/\\t.*$/] = \"\"\n # IndexError is raised if no tab characters are found\n rescue IndexError\n end\n files << line\n end\n end\n return files\n end", "def removed; status[:removed] || []; end", "def prompt_git_status\n if !is_git?\n return \"\"\n end\n stat = `git status`\n res = \"\"\n res += ( stat.include?(\"ahead\") ? \"^\" : \"\" )\n res += ( stat.include?(\"modified\") ? \"*\" : \"\" )\n res += ( stat.include?(\"untracked\") ? \"+\" : \"\" )\n res += ( stat.include?(\"deleted\") ? \"-\" : \"\" )\n res!=\"\" ? \"[#{res}]\".magenta : \"\"\nend", "def all_commit_times\n `git --git-dir=#{git_dir} log --all --pretty='%at'`.split(/\\n/).uniq\n end", "def diff_gitignore\n system(\"diff .gitignore ~/code/tmpl/gitignore-gem\")\n end", "def diff_gitignore\n system(\"diff .gitignore ~/code/tmpl/gitignore-gem\")\n end", "def all_modified_files_coverage\n unless @project.nil?\n @all_modified_files_coverage ||= begin\n modified_files = git.modified_files.nil? ? [] : git.modified_files\n added_files = git.added_files.nil? ? [] : git.added_files\n all_changed_files = modified_files | added_files\n @project.coverage_files.select do |file|\n all_changed_files.include? file.source_file_pathname_relative_to_repo_root.to_s\n end\n end\n\n @all_modified_files_coverage\n end\n end", "def get_repo_status\n args = {:clone => CONFIG[\"local\"][\"clone\"]}\n st = `#{Templates.status(args)}`\n current_branch = st.split(\"\\n\")[0][3..-1].split(\"...\")[0]\n modified_files = st.split(\"\\n\")[1..-1].join(\"\\n\")\n [current_branch, modified_files]\n end", "def get_files_in_commit(commit)\n\tfiles = {}\n\tcommit.diffs.each do | diff |\n\t\tfiles[diff.a_path] = nil unless files.has_key? diff.a_path\n\t\tfiles[diff.b_path] = nil unless files.has_key? diff.b_path\n\t\t# what about diff.deleted_file and diff.new_file?\n\tend\n\treturn files.keys\nend", "def files\n @files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n # This returns:\n # [\"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Thundercat - For Love I Come - dance.mp3\"]\n end", "def test_clean_checkout_should_not_remove_tracked_files\n with_sandboxed_git do |proj_dir, git|\n tracked_file = File.join(proj_dir, 'tracked.txt')\n FileUtils.touch tracked_file\n sandbox_git_add_and_commit(proj_dir, File.basename(tracked_file))\n untracked_file = File.join(proj_dir, 'untracked.txt')\n git.clean_checkout\n assert File.exist? tracked_file\n assert_false File.exist? untracked_file\n end\n end" ]
[ "0.7949743", "0.7858256", "0.7604518", "0.7592769", "0.6977188", "0.69291365", "0.686998", "0.684934", "0.6786466", "0.65984774", "0.64842325", "0.6372661", "0.6371909", "0.63645184", "0.62491596", "0.62377334", "0.62377334", "0.60348916", "0.59823763", "0.5968926", "0.59613127", "0.5939124", "0.5914351", "0.59036195", "0.588318", "0.58778757", "0.5849836", "0.5845368", "0.57831866", "0.5762898", "0.57563627", "0.5690795", "0.5666799", "0.5642597", "0.56310165", "0.56195754", "0.56105286", "0.558248", "0.5557556", "0.5518641", "0.55181915", "0.5517877", "0.55063623", "0.5500994", "0.5499686", "0.5487082", "0.5484937", "0.54810995", "0.5476519", "0.5451705", "0.5432232", "0.5431258", "0.5421109", "0.542053", "0.5394791", "0.5371157", "0.5353194", "0.5352558", "0.53492063", "0.53432286", "0.5342672", "0.5342672", "0.5337086", "0.5312971", "0.5308359", "0.52988225", "0.52971655", "0.52775913", "0.5269563", "0.52542317", "0.52364296", "0.52286696", "0.5228098", "0.5227171", "0.5227159", "0.5226767", "0.52250355", "0.5211563", "0.52102727", "0.5207861", "0.520597", "0.5204721", "0.51959354", "0.5195625", "0.5195497", "0.51907563", "0.5187076", "0.51804674", "0.51767933", "0.51625234", "0.5159434", "0.5158998", "0.51495624", "0.51495624", "0.5147426", "0.5142706", "0.5137655", "0.5135932", "0.5123794" ]
0.836846
1
Commit the given file with a message. The file has to be known to Git meaning that it has either to have been already committed in the past or freshly added to the index. Otherwise it will fail.
def commit(file, message) git 'commit', '-m', message, file end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit(file, message)\n hg 'commit', '-m', message, file\n end", "def commit(message = nil)\n # Write current index back to the repository\n index = @repo.index\n commit_tree = index.write_tree @repo\n\n # Commit message\n message = \"Affected files: #{@affected_files.uniq.join(', ')}\" if message.nil?\n\n # User handling\n user = ENV['USER']\n user = \"cir-out-commit\" if user.nil?\n\n # Commit author structure for git\n commit_author = {\n email: 'cir-auto-commit@nowhere.cz',\n name: user,\n time: Time.now\n }\n\n # And finally commit itself\n Rugged::Commit.create @repo,\n author: commit_author,\n committer: commit_author,\n message: message,\n parents: @repo.empty? ? [] : [ @repo.head.target ].compact,\n tree: commit_tree,\n update_ref: 'HEAD'\n\n # Reset list of files that were changed since last commit\n @affected_files = []\n end", "def commit(repopath, file, contents, message)\n # set up repo and index\n repo = Grit::Repo.new repopath\n index = Grit::Index.new repo\n # write file to repo\n fullpath = File.join repopath, file\n File.open(fullpath, 'wb') {|f| f.write contents}\n # commit file\n index.add file, contents\n parent = repo.commits.count > 0 ? [repo.commits.first] : nil\n index.commit message, parent\n end", "def update_commit_message(message)\n ::File.open(commit_message_file, 'w') do |file|\n file.write(message)\n end\n end", "def commit(msg=status)\n setup unless head\n \n sha = git.commit(msg)\n index.write(sha)\n sha\n end", "def save message\n raise NothingToCommitError if nothing_to_commit?\n @git.index.add_all\n @git.index.write\n usr = {name: @git.config['user.name'],\n email: @git.config['user.email'],\n time: Time.now}\n opt = {}\n opt[:tree] = @git.index.write_tree\n opt[:author] = usr\n opt[:committer] = usr\n opt[:message] = message\n opt[:parents] = unless @git.empty?\n begin\n [@git.head.target].compact\n rescue Rugged::ReferenceError\n []\n end\n else [] end\n opt[:update_ref] = 'HEAD'\n Rugged::Commit.create(@git, opt)\n end", "def commit!(message)\n git \"commit -m \\\"#{message}\\\"\"\n end", "def commit!(msg=status)\n setup unless head\n \n sha = git.commit!(msg)\n index.write(sha)\n sha\n end", "def commit(message)\n Dubya.logger.info \"Updating Git repository...\"\n system %(cd #{path} && git commit -am \"#{message}\" && git push)\n end", "def commit(message)\n @repo.commit_index(\"Cron Job: #{message}\") # Commit.\nend", "def commit(message, opts = {})\n self.lib.commit(message, opts)\n end", "def save message\n Dir.chdir @root do\n cmd = \"git add --all && git commit -m \\\"#{message}\\\"\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n if /nothing to commit/.match stdout\n raise NothingToCommitError\n elsif /Not a git repository/.match stderr\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n end\n end", "def commit(message, options={})\n raise \"no changes to commit\" if status.empty?\n commit!(message, options)\n end", "def git_commit(message)\n yield\n git add: '.'\n git commit: %{ -m #{message.inspect} }\n end", "def commit(author, message)\n GIT.add relative_path\n GIT.commit message, :author => \"#{ author.name } <#{ author.email }>\"\n end", "def commit(message = nil, oneline = nil)\n commit_message = oneline || \"Committing changeset #{repository.commits.size + 1}\"\n commit_message << \"\\n\\n\" << message unless message.nil?\n self.repository.commit_all commit_message\n end", "def stage_and_commit_file(repo_base_path, relpath_to_file, commit_message = nil)\n commit_message = \"Updated #{relpath_to_file} via website\" unless !commit_message.blank?\n gitRepo = Repo.new(repo_base_path)\n olddir = Dir.pwd\n Dir.chdir(repo_base_path)\n gitRepo.add(relpath_to_file)\n gitRepo.commit_index(commit_message)\n Dir.chdir(olddir)\n end", "def commit( commit_msg )\n\n log.info(x) { \"[git] commit msg => #{commit_msg}\" }\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_commit_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} commit -m \\\"#{commit_msg}\\\";\"\n log.info(x) { \"[git] commit command => #{git_commit_cmd}\" }\n %x[#{git_commit_cmd}];\n log.info(x) { \"[git] has committed resources into the local repository.\" }\n\n end", "def commit\n self.index.commit(@commit_msg, @commit_author)\n end", "def commit(branch, message)\n zombie_check\n on_worktree(branch) { |repo| repo.commit(message) }\n end", "def commit!(message, options={})\n now = Time.now\n \n sha = options.delete(:tree) || tree.write_to(self).at(1)\n parents = options.delete(:parents) || (head ? [head] : [])\n author = options[:author] || self.author\n authored_date = options[:authored_date] || now\n committer = options[:committer] || author\n committed_date = options[:committed_date] || now\n\n # commit format:\n #---------------------------------------------------\n # tree sha\n # parent sha\n # author name <email> time_as_int zone_offset\n # committer name <email> time_as_int zone_offset\n # \n # messsage\n # \n #---------------------------------------------------\n # Note there is a trailing newline after the message.\n #\n lines = []\n lines << \"tree #{sha}\"\n parents.each do |parent|\n lines << \"parent #{parent}\"\n end\n lines << \"author #{author.name} <#{author.email}> #{authored_date.strftime(\"%s %z\")}\"\n lines << \"committer #{committer.name} <#{committer.email}> #{committed_date.strftime(\"%s %z\")}\"\n lines << \"\"\n lines << message\n lines << \"\"\n \n @head = set('commit', lines.join(\"\\n\"))\n grit.update_ref(branch, head)\n \n head\n end", "def commit(message)\n p4 'submit', '-d', message\n end", "def commit(message, opts = {})\n arr_opts = ['-m', message]\n arr_opts << '-a' if opts[:add_all]\n arr_opts << '--amend' if opts[:amend]\n arr_opts << '--allow-empty' if opts[:allow_empty]\n arr_opts << \"--author\" << opts[:author] if opts[:author]\n command('commit', arr_opts)\n end", "def commit(msg = nil)\n require_dep! 'awesome_spawn'\n require_cmd! git_cmd\n\n in_repo { AwesomeSpawn.run \"#{git_cmd} add #{pkg_files.join(' ')}\" }\n super(msg.nil? ? \"updated to #{version}\" : msg)\n self\n end", "def commit\n system(\"cd #{repo_path};git commit -m 'to the cloud'\")\n end", "def git_commit(message=\"\")\n %x( git commit -m=#{message} )\n end", "def commit(message = '', author = User.from_config, committer = author)\n root.write\n\n commit = Commit.new(self)\n commit.tree = root\n commit.parent << head.id if head\n commit.author = author\n commit.committer = committer\n commit.message = message\n commit.write\n\n open(head_path, \"wb\") do |file|\n file.write(commit.id)\n end\n\n @head = commit\n end", "def commit!\n git add: \".\"\n git commit: \"-m '#{config.dig('commit_msg')}'\"\n end", "def commit(files, no_edit: false, amend: false, message: nil, author: nil)\n run_git ['add', *Array(files)] if files\n\n cmd = %w[commit]\n cmd << '--no-edit' if no_edit\n cmd << '--amend' if amend\n cmd << %[--author=\"#{author}\"] if author\n cmd += ['--message', %[\"#{message}\"]] if message\n\n output, status = run_git(cmd)\n\n status.success? || raise(CannotCommitError.new(output))\n end", "def git_commit_push(message)\n\t\t \t\tshell_command(\"git commit -a -m #{message}\")\n\t\t \t\tshell_command(\"git commit\")\n\t\t \tend", "def commit(message = '', author = nil, committer = nil)\n return if !root.modified?\n\n author ||= default_user\n committer ||= author\n root.save\n\n commit = Commit.new(:repository => self,\n :tree => root,\n :parents => head,\n :author => author,\n :committer => committer,\n :message => message)\n commit.save\n\n write_head_id(commit.id)\n load\n\n commit\n end", "def commit(name, message)\n git = git(name)\n\n git.config('user.name', GIT_AUTHOR[:name])\n git.config('user.email', GIT_AUTHOR[:email])\n\n git.add(all: true)\n git.commit(message)\n end", "def repo_commit(msg)\n git :add => '-u'\n git :add => '.'\n git :commit => \"-m \\\"#{msg}\\\"\" \n end", "def cmd_commit(msg)\n comment = msg[2].tr('\"', '')\n run_cmd(\"cd /etc;git add . && git commit -a -m \\\"#{comment}\\\"\")\n end", "def commit_files(author: nil, message: nil, parent: nil, files: {})\n # check parameters\n raise \"no author given\" if author.nil?\n raise \"no message given\" if message.nil?\n\n # get parent commit\n if not parent.nil?\n parent = @wiki.commit_for(parent)\n elsif parent.nil? and not @wiki.repo.head.commit.nil?\n parent = @wiki.commit_for(@wiki.repo.head.commit.id)\n end\n\n unless parent.nil?\n log_debug \" checkpoint (parent #{parent})\"\n if parent.id != @wiki.repo.head.commit.id\n log_debug \" (parent #{parent} is not head)\"\n\n # now check version of each file individually, if it has been\n # changed in one of the changes since parent.\n #\n # if so, raise error, else proceed\n\n files.each do |path,contents|\n next if @wiki.repo.log(nil, path, {:since => parent.authored_date}).empty?\n log_debug \" file has changed\"\n raise \"repo has changed\"\n end\n end\n end\n\n options = {\n :message => message,\n :author => author,\n }\n unless parent.nil?\n options[:parent] = parent\n end\n\n committer = Gollum::Committer.new(@wiki, options)\n\n files.each do |path,contents|\n path = path.dup.gsub(/^\\.\\//, '')\n if contents.nil?\n committer.index.delete(path)\n else\n committer.index.add(path, normalize(contents))\n end\n # if wikifile_exists? path, parent\n # log_debug \" U path: #{path}, contents: #{normalize(contents)}\"\n # committer.index.add(path.dup, normalize(contents))\n # else\n # log_debug \" A path: #{path}, contents: #{normalize(contents)}\"\n # dir, name, format = split_path path\n # committer.add_to_index(dir, name, format, contents)\n # end\n end\n\n committer.after_commit do |index, sha|\n log_debug \" after_commit: #{index}, #{sha}\"\n @wiki.clear_cache\n\n files.each do |path,contents|\n path = path.gsub(/^\\.\\//, '')\n #dir, name, format = split_path path\n unless @wiki.repo.bare\n Dir.chdir(::File.join(@wiki.repo.path, \"..\")) do\n if contents.nil?\n @wiki.repo.git.rm(path, :force => true)\n else\n @wiki.repo.git.checkout(path, 'HEAD')\n end\n end\n end\n end\n\n @wiki_manager.add_to_index(@wiki, index, sha, files)\n end\n\n sha = committer.commit\n log_debug \"sha #{sha}\"\n end", "def update(content, message=nil)\n # normalise content\n content = Page.normalise_body(content)\n \n # create subdirectory if needed\n dirname = File.dirname(@filename)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n \n # Write changes to file\n File.open(@filename, 'w') { |f| f << content }\n \n # Create commit message\n commit_message = tracked? ? \"edited #{@basename.wikify}\" : \"created #{@basename.wikify}\"\n commit_message += ' : ' + message unless message.blank?\n \n # Commit changes\n begin\n $repo.add(@name)\n $repo.commit(commit_message)\n rescue\n nil\n end\n end", "def save(message)\n to_be_added = pending_changes.select{|f|\n f.untracked && f.type.nil?\n }\n git.add(git_opts, *to_be_added.map{|f| f.path})\n git.commit(git_opts(), '-a', '-m', message)\n self\n end", "def save(commit_msg = nil)\n # Add all changes to index (staging area)\n index = repo.index\n\n # Process config file (if loaded, i.e. may be modified)\n save_config_file(index) if @config\n\n # Process ssh keys (if loaded, i.e. may be modified)\n save_ssh_keys(index) if @ssh_keys\n\n # Write index to git and resync fs\n commit_tree = index.write_tree(repo)\n index.write\n\n author = commit_author.merge(time: Time.now)\n\n opts = {\n parents: [repo.head.target],\n tree: commit_tree,\n update_ref: 'HEAD',\n message: (commit_msg || @settings[:commit_msg]),\n author: author,\n committer: author\n }\n Rugged::Commit.create(repo, opts)\n end", "def git_commit_push(host, branch, message, git_repo_path)\n git_on(host, \"commit -m \\\"#{message}\\\"\", git_repo_path)\n git_push(host, branch, git_repo_path)\nend", "def git_commit(message, fail_on_error = true)\n begin\n mysystem(\"git commit -m \\\"#{message}\\\" 2> /dev/null > /dev/null\")\n return true\n rescue Exception => e\n raise e if fail_on_error\n return false\n end\n end", "def commit_all(_message)\n puts 'TODO: Implement Git.commit_all'\n end", "def save_changes!(files_to_commit: [], custom_message: nil)\n not_implemented(__method__)\n end", "def satellite_commit(repo, message, author, branch)\n options = rugged_commit_options(author, repo, message)\n commit_id = Rugged::Commit.create repo, options\n repo.index.write\n pushtobare branch\n touch # use current updated_at time\n commit_id\n end", "def add_file(file)\n index = @repo.index\n index.add path: file, oid: (Rugged::Blob.from_workdir @repo, file), mode: 0100644\n index.write\n\n @affected_files << file\n end", "def commit\n @git = YMDP::GitHelper.new\n @git.do_commit(@message)\n @git_hash = git.get_hash(options[:branch]) \n end", "def commit_changes\n @message = \"commiting changes for #{@issue_key}\"\n begin\n ui.info \"Commiting changes...\"\n @git.commit_all(@user_message.empty? ? @message : @user_message)\n rescue Git::GitExecuteError => e\n error_message = e.message.split(':').last\n ui.info error_message\n unless error_message =~ /nothing to commit/\n exit 1\n end\n end\n push_changes\n end", "def satellite_commit(repo, message, author, branch)\n options = rugged_commit_options(author, repo, message)\n commit_id = Rugged::Commit.create repo, options\n repo.index.write\n pushtobare branch\n commit_id\n end", "def commit\n @repo.commit\n end", "def commit!\n rsp = post(\"<commit/>\")\n success?(rsp.body) or log_error(rsp.body)\n end", "def git_commit(message, &block)\n yield if block_given?\n git :add => '.'\n git :commit => \"--quiet --message '#{message}'\"\nend", "def commit_message\n @commit.sub '%.%.%', @after_version\n end", "def commit args = {}\n action = :deleted if self.deleted?\n action ||= self.is_new? ? :added : (self.is_changed? ? :updated : :nothing_to_commit) \n args[:skip_part_data] ||= false\n \n unless action.eql?(:nothing_to_commit)\n message = \"#{action} #{name}\"\n message = args[:m] if args[:m] \n if action.eql?(:deleted)\n repo.remove(self.file_name)\n self.history_count += 1\n else\n repo.add(self.file_name)\n end\n\n active_message = self.commit_messages[:most_recent]\n message = \"#{active_message.gsub(message,\"\")}\" unless self.deleted? || active_message.blank? || active_message.eql?(message)\n self.remove_message_from_temp_store(:most_recent) unless active_message.blank?\n \n repo.commit(message)\n self.last_commit = repo.log(self.local_path, :limit => 1).first.to_s\n end\n unless action.eql?(:deleted) \n self.part_count = parts.count\n self.part_count ||= 0 \n update_part_data unless args[:skip_part_data]\n\n self.history_count = self.history.size\n self.history_count = 1 if self.history_count.eql?(0) \n end\n self.save if self.changed?\n \n synchronize unless args[:dont_sync] || self.attributes[\"sync\"].blank? #rather than calling sync.blank? to skip the JSON parsing step.\n return action\n end", "def commit!(message)\n date = Time.now\n @status_add.each{|name, body|\n json = Article.new(name, body, date).to_json\n zcard = @redis.zcard name\n @redis.zadd name, zcard+1, json\n @redis.sadd KEY_SET, name\n @summary_redis.update MarkdownBody.new(name, body, date).summary\n }\n @remove_add.each{|name, latest_rank|\n @redis.zremrange(name, 0, latest_rank)\n }\n @redis.set MODIFIED_DATE, date.to_s\n end", "def quick_commit(repo, msg='WARNING: This commit was made automatically by a script, and should be reviewed!')\n log = File.open \"#{LOG_DIR}/git.txt\", 'a'\n Dir.chdir Pathname(repo).expand_path do |p|\n print \"Performing quick commit for '#{File.basename repo}'...\\n\" unless $cli_opts[:quiet]\n log.puts `git add -A`\n log.puts `git commit -m \"#{msg}\"`\n log.puts\n result = `git push origin`\n log.puts result\n puts result.empty? ? 'Done.' : 'Failed!'\n end\n end", "def commit( *files, **options )\n\t\tself.server.run( :commit, *files, **options )\n\t\treturn true\n\tend", "def add_file(*args)\n context = args.pop\n file_path_hash_or_string, content, commit_msg = args\n file_path_hash = file_path_hash_form(file_path_hash_or_string)\n get_adapter_repo(context).add_file(file_path_hash, content, commit_msg)\n end", "def commit_and_push_to_repo(oauth_token, commit_message, \n tree_sha, head_sha, ref_name)\n client = Octokit::Client.new(access_token: oauth_token)\n sha_new_commit = client.create_commit(full_repo_name, commit_message, tree_sha, head_sha)[:sha]\n client.update_ref(full_repo_name, ref_name, sha_new_commit)\n end", "def git_add(file, msg)\r\n `git add #{file} && git commit -m \\\"#{msg}\\\"`\r\nend", "def add(file)\n # add file to object db\n return false if !File.exists?(file)\n return false if !File.file?(file)\n \n sha = get_raw_repo.put_raw_object(File.read(file), 'blob')\n \n # add it to the index\n @git_index.add(file, sha)\n end", "def commit_file\n\t\tlogger.info(\"[File Attribute #{sprintf('0x%08x', self.object_id)}] Committing file for #{@obj.class}(#{@obj.id}).#{attribute_name} ...\")\n\t\tif @file\n\t\t\tlogger.info(\"[File Attribute] Saving file #{local_file_name} ...\")\n\t\t\t@file.rewind if @file.respond_to?(:rewind)\n\t\t\tFile.makedirs(File.dirname(local_file_name))\n\t\t\tFile.open(local_file_name, \"w\") do |f|\n\t\t\t\tf.write(@file.read)\n\t\t\tend\n\t\t\tlogger.info(\"[File Attribute] Done.\")\n\t\telse\n\t\t\tlogger.info(\"[File Attribute] Skipping file save of #{@file.inspect}.\")\n\t\tend\n\t\ttrue\n\tend", "def create_local_commit author: nil, branch:, file_name:, file_content:, message:, push: false\n on_branch(branch) do\n if (folder_name = File.dirname file_name) != '.'\n Dir.mkdir folder_name\n end\n File.write file_name, file_content\n run \"git add '#{file_name}'\"\n run \"git commit -m '#{message}' #{\"--author='#{author}'\" if author}\"\n run 'git push' if push\n end\nend", "def git_commit_all message\n system \"git add --all .\"\n return false unless $?\n system \"git commit -q -m '#{message.gsub(/'/, \"\\'\")}'\"\n return $?\nend", "def vcs_commit(evt)\n sel = @tblChanges.selection_model.selected_items\n msg = @cmbCommitMsg.value\n if sel.length == 0\n fx_alert_error \"Cannot commit on empty changes selection. Please select at least a file from the table above.\", \"No Files Selected\", main_stage\n elsif (msg.nil? or msg.empty?)\n fx_alert_error \"Commit message must be present.\", \"Empty Commit Message\", main_stage\n else\n commit_changes(sel, msg)\n if not @msgHistory.include?(msg)\n @cmbCommitMsg.items.add(msg)\n @msgHistory << msg\n end\n refresh_tab_state\n end\n end", "def create_commit_msg(commit_msg_path, for_commit)\n File.open(commit_msg_path, 'w') do |file|\n file.puts(\"Automatic documentation update\\n\")\n file.puts(\"- Generated for #{for_commit}.\")\n end\n end", "def write(filename, message, client)\n afile = File.new(filename, \"r+\")\n if afile\n afile.syswrite(message)\n client.puts(\"Changes made to \"+ filename)\n else\n client.puts \"Unable to write to file!\"\n end\nend", "def upload!(file_path)\n raise GitCloud::FileException.new(\"NotFound\") unless File.exists? file_path\n file = File.new(File.expand_path(file_path))\n add(file)\n commit\n push\n end", "def add(file)\n @file = file\n FileUtils.cp_r(file.path,folder_path)\n unless system(\"cd #{repo_path};git add .\")\n raise GitCloud::GitException.new(\"Add\")\n end\n end", "def commit(m)\n git(:add => '.')\n git(:commit => \"-a -m 'Rails Template Commit: #{m}'\")\nend", "def commit_all(message, opts = {})\n opts = {:add_all => true}.merge(opts)\n self.lib.commit(message, opts)\n end", "def commit_message\n user_name = user ? user.login : \"anonymous\"\n \n if revisions.empty?\n \"initial #{user_name}\"\n elsif @rollback\n \"rollback #{self.log.first} #{user_name}\"\n else\n \"edit #{self.log.first} #{user_name}\"\n end\n end", "def write(content, message, author = nil)\n if !content.respond_to? :read\n content.gsub!(\"\\r\\n\", \"\\n\")\n\treturn if @object && @object.data == content\n end\n\n Wiki.check do |errors|\n errors << :already_exists.t(:path => @path) if new? && Resource.find(@repository, @path)\n errors << :empty_commit_message.t if message.blank?\n end\n\n repository.transaction(message, author && author.to_git_user) do\n content = content.read if content.respond_to? :read # FIXME\n repository.root[@path] = Gitrb::Blob.new(:data => content)\n end\n\n reload\n @commit = repository.log(1, nil).first\n @object = @commit.tree[@path] || raise(NotFound, path)\n @current = true\n end", "def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end", "def commit\n sanity_check\n @handle.commit\n end", "def commit_to_git\n puts `git add .`\n puts `git commit -a -m \"New poshts for the syhtt\"`\n puts `git push blahg master`\n end", "def commit(repo)\n # First, ensure everything up-to-date\n # The fourth argument as true tells update to ignore externals.\n repo.ctx.update(repo.wc_path, \"HEAD\", nil, true)\n \n root = Directory.new(repo.ctx, repo.wc_path)\n root.instance_eval(&@block) if @block\n ci = repo.ctx.ci(repo.wc_path)\n unless ci.revision == Svn::Core::INVALID_REVNUM\n rev = ci.revision\n repo.repos.fs.set_prop('svn:log', @message, rev) if @message\n repo.repos.fs.set_prop('svn:author', @author, rev) if @author\n repo.repos.fs.set_prop('svn:date', @date, rev) if @date\n @revprops.each do | key, val |\n val = SvnFixture.svn_time(val) if val.respond_to?(:strftime)\n repo.repos.fs.set_prop(key.to_s, val.to_s, rev)\n end\n else\n puts \"Warning: No change in revision #{name} (SvnFixture::Revision#commit)\"\n end\n return true\n end", "def send_file(message, file)\n response = self.class.post(@api.send_file_config[:url],\n :query => { :auth_token => @token },\n :body => file_body({ :message => message }.send(@api.send_config[:body_format]), file),\n :headers => file_body_headers(@api.headers)\n )\n\n ErrorHandler.response_code_to_exception_for :user, user_id, response\n true\n end", "def git_add_commit_push(host, branch, message, git_repo_path)\n git_add_everything(host, git_repo_path)\n git_commit_push(host, branch, message, git_repo_path)\nend", "def commit(newrevision, content_io=nil)\n if not get_indexfile_with_revision(newrevision).nil?\n raise \"Committing already-existing revision: #{newrevision} for #{@fname}\"\n end\n if content_io.nil?\n compress_file_lines = Deflate.deflate(File.read(@fname))\n else\n cont = content_io.read\n compress_file_lines = Deflate.deflate(cont)\n end\n\n # append current file fname to datafile\n length = IO.readlines(@datafile).size\n\n File.open(@datafile, \"a\") do |append|\n append.puts compress_file_lines\n end\n length = IO.readlines(@datafile).size - length\n\n # new version is the old version plus 1\n # new offset is the last length + last offset\n parse_last_line = parse_indexfile_line get_indexfile_with_line(-1)\n new_offset = parse_last_line[1] + parse_last_line[2]\n\n File.open(@indexfile, \"a\") do |f|\n index_write_row(f, newrevision.to_s,\n new_offset.to_s, length.to_s)\n end\n end", "def add sha:, message:, branch_name:, author:\n local_branch_name = local_branch_name branch_name\n @commits[local_branch_name] ||= {}\n if @commits[local_branch_name].key? sha\n # We already have this commit in a different location --> just append the location to the existing commit\n @commits[local_branch_name][sha]['LOCATION'] << branch_location(branch_name)\n else\n # We don't have this commit in another location --> create an entry for this commit\n @commits[local_branch_name][sha] = commit_data local_branch_name: local_branch_name,\n branch_name: branch_name,\n message: message,\n sha: sha,\n author: author\n end\n end", "def test_add_existing_file\n @gitit.add('hello.txt', 'Hello, dsyph3r')\n @gitit.commit('modifying hello world')\n\n file = @gitit.get_file('hello.txt')\n\n assert_not_nil(file)\n\n assert_equal('Hello, dsyph3r', file['data'], 'File data is incorrect')\n end", "def msg(message)\n FileUtils.cd(@git_dir_path)\n\t# via http://ozmm.org/posts/git_msg.html\n # --allow-empty means git won't require a changed file; it will just store a\n # commit message.\n `git commit --allow-empty -m \"#{message}\" &>/dev/null`\n # Use sed to extract SHA1 hash from most recent log message\n hash = `git log master~1..master | sed -n '/commit/s/commit //p'`.chomp\n # Push to Github\n `git push origin master &>/dev/null`\n return hash\n end", "def image_commit(project, imagefile)\n if logged_in?\n commit project.path, imagefile.original_filename, imagefile.read, \"Add new file #{imagefile.original_filename}.\" \n end\n end", "def commit_modified_files_task\n really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split(\"\\n\")\n if really_modified.any?\n really_modified.each { |file| sh git, 'add', file }\n sh git, 'commit', '-m', \"Released #{gemspec.name} gem version #{gemspec.version}.\"\n end\n end", "def commit_file\n if @upload.public? && @upload.file_type.public? && @upload.address.blank? && (@upload.creating? || @upload.failed?)\n BlockchainCommitJob.perform_later(@upload.id)\n end\n end", "def add_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_add_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} add #{file_path}\"\n log.info(x) { \"[git] single file add command => #{git_add_cmd}\" }\n %x[#{git_add_cmd}];\n log.info(x) { \"[git] has added #{file_path} into the git repository.\" }\n\n end", "def commit_all(message)\n yield if block_given?\n\n git add: '.'\n git commit: %(-aqm \"#{message}\")\nend", "def test_version_message\n Repository.create()\n FileUtils.touch('.test_file1')\n a = ['.test_file1']\n Repository.add(a) \n Repository.commit()\n #Repository.version()\n end", "def write(message)\n f = open(@filename, 'a')\n f.puts(message)\n f.close()\n end", "def save_file(file, name = '')\n if name.size > 0\n filename = name + File.extname(file[:filename])\n else\n filename = file[:filename]\n end\n FileUtils.mkdir_p(attach_dir) unless File.exists?(attach_dir)\n new_file = File.join(attach_dir, filename)\n\n f = File.new(new_file, 'w')\n f.write(file[:tempfile].read)\n f.close\n\n commit_message = \"uploaded #{filename} for #{@name}\"\n begin\n $repo.add(new_file)\n $repo.commit(commit_message)\n rescue\n # FIXME why!??\n nil\n end\n end", "def commit\n rError = nil\n rCommitID = nil\n\n lStrPassword = ''\n if (@CommitPassword != nil)\n lStrPassword = \"--password #{@CommitPassword}\"\n end\n change_dir(@LocalRepository) do\n lOutput = `svn ci --message \"#{@Comment}\" --username #{@CommitUser} #{lStrPassword} #{@StrFiles}`.split(\"\\n\")\n lReturnCode = $?.exitstatus\n if (lReturnCode == 0)\n # Get back the revision number from the output\n lOutput.each do |iLine|\n lMatch = iLine.match(/^Committed revision (.*)\\.$/)\n if (lMatch != nil)\n rCommitID = lMatch[1].to_i\n end\n end\n if ((rCommitID == nil) or\n (rCommitID == 0))\n rError = CommitInvalidError.new(\"Failed to retrieve SVN commit revision. Here is the output: #{lOutput}\")\n end\n else\n rError = CommitConflictError.new(\"SVN returned error #{lReturnCode} upon commit.\")\n end\n end\n\n return rError, rCommitID\n end", "def in_branch(message = nil)\n old_ref = @repo.head\n checkout\n yield @repo\n\n if message\n @repo.commit_index message\n @repo.head.commit\n end\n ensure\n old_ref.checkout\n end", "def commit_all(index, last_commit, last_tree)\n callback = self.git_settings.commit_message\n # $stderr.puts self.git_settings.inspect\n message = case callback\n when Symbol\n self.send(callback)\n when Proc\n callback.call(self)\n else\n \"new version of #{self.class}, id: #{self.id.to_s}\" \n end\n lc = (last_commit ? [last_commit.id] : nil)\n index.commit(message, lc, @model_user)\n end", "def commit(id)\n @commit = @repo.commit(id)\n raise(Ginatra::InvalidCommit.new(id)) if @commit.nil?\n add_refs(@commit,{})\n @commit\n end", "def patch_gemfile(commit_message, options = {}, &block)\n filename = \"#{Dir.pwd}/Gemfile\"\n if File.exist?(filename)\n contents = IO.read(filename)\n new_contents = block.call(contents.dup)\n if contents != new_contents || options[:force]\n File.open(filename, 'wb') {|f| f.write new_contents}\n mysystem('rm -f Gemfile.lock')\n rbenv_exec('bundle install')\n mysystem('git add Gemfile')\n begin\n # Not all repos have lock files checked in\n mysystem('git ls-files Gemfile.lock --error-unmatch > /dev/null 2> /dev/null && git add Gemfile.lock')\n rescue\n end\n begin\n mysystem(\"git commit -m \\\"#{commit_message}\\\"\") unless options[:no_commit]\n rescue\n # The assumption is that we are here because there was no changes but :force was specified\n return false\n end\n return true\n end\n end\n false\n end", "def commit_message\n msg = (params[:message].nil? or params[:message].empty?) ? \"[no message]\" : params[:message]\n commit_message = { :message => msg }\n author_parameters = session['gollum.author']\n commit_message.merge! author_parameters unless author_parameters.nil?\n commit_message\n end", "def patch_file(file, &block)\n filename = \"#{Dir.pwd}/#{file}\"\n if File.exist?(filename)\n contents = IO.read(filename)\n new_contents = block.call(contents.dup)\n if contents != new_contents\n File.open(filename, 'wb') {|f| f.write new_contents}\n mysystem(\"git add #{file}\")\n return true\n end\n end\n false\n end", "def commit_message\n commit_message_lines.join\n end", "def commit\n File.open(file_path, \"w\") do |f|\n f.write(to_json)\n end\n end", "def commit_file(revision)\n c = @gerrit.commit(@id, revision)\n file = []\n file += c['parents'].map do |parent|\n \"Parent: #{parent['commit'][0..6]} (#{parent['subject']})\"\n end\n file += %w(committer author).map do |t|\n [\n \"#{t.capitalize}: #{c[t]['name']} <#{c[t]['email']}>\",\n \"#{t.capitalize}Date: #{c[t]['date']}\"\n ]\n end.flatten\n file << ''\n file << c['message']\n file.join(\"\\n\")\n end" ]
[ "0.7875317", "0.75850695", "0.7332475", "0.72253996", "0.70301443", "0.7004379", "0.69789493", "0.6968867", "0.6931715", "0.6870631", "0.6769182", "0.6611701", "0.6474825", "0.64290655", "0.6427936", "0.6417664", "0.6413019", "0.63693213", "0.636375", "0.63595146", "0.6358841", "0.6356722", "0.6334236", "0.63087696", "0.629772", "0.6291531", "0.62893397", "0.62292707", "0.6224264", "0.6172782", "0.6169469", "0.6158897", "0.6156677", "0.6141471", "0.60837716", "0.60734904", "0.6056591", "0.6032777", "0.6008463", "0.6007207", "0.5983827", "0.5967862", "0.5935576", "0.5887883", "0.584978", "0.58478016", "0.57903147", "0.57799333", "0.577229", "0.5764593", "0.57613856", "0.57464206", "0.5725615", "0.571366", "0.5699077", "0.5684881", "0.5646062", "0.56307644", "0.56163454", "0.5604342", "0.5583001", "0.5581775", "0.55766726", "0.55663526", "0.5543048", "0.5542072", "0.5530482", "0.55232084", "0.55155694", "0.55077267", "0.5500882", "0.5482719", "0.5469396", "0.5455857", "0.54477215", "0.5440386", "0.5404128", "0.5399971", "0.5393885", "0.53887063", "0.53700393", "0.5364266", "0.5325568", "0.53177637", "0.53118193", "0.53114396", "0.5311161", "0.53007156", "0.52841145", "0.5283022", "0.52716446", "0.5269773", "0.5264631", "0.52578145", "0.5250402", "0.5246245", "0.52230114", "0.52209723", "0.5217728" ]
0.8352529
1
Update the remote refs using local refs By default, the "remote" destination of the push is the the remote repo linked to the current branch. The default remote branch is the current local branch.
def push(remote_repo = remote, remote_branch = current_branch) git 'push', remote, current_branch end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateRepo()\n $repo.checkout(BRANCH)\n\n # fetch\n remote = $repo.remotes['' << REMOTE]\n remote.fetch()\n\n # merge\n distant_commit = $repo.branches['' << REMOTE << '/' << BRANCH].target\n $repo.references.update($repo.head, distant_commit.oid)\nend", "def apply\n repo.push('origin', ['refs/heads/master'], credentials: credentials)\n end", "def pushToGitRemotes(branch = 'develop', force = 0)\n if force\n force = \"-f\"\n else\n force = \"\"\n end\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pushing #{branch} to remote: #{branch}\\\"\")\n sh(\"git push #{force} #{remote} #{branch}\")\n end\nend", "def update!(**args)\n @remote_branch = args[:remote_branch] if args.key?(:remote_branch)\n end", "def push_to_remote(local_branch, remote_branch, remote_name, opts)\n remote_name ||= 'origin'\n\n args = [remote_name]\n\n local_branch ||= branches.current\n remote_branch ||= local_branch\n args << '-f' if opts[:force]\n\n logger.info do\n if local_branch == remote_branch\n \"Pushing to '#{remote_branch}' on '#{remote_name}'.\"\n else\n \"Pushing #{local_branch} to '#{remote_branch}' on '#{remote_name}'.\"\n end\n end\n\n args << \"#{local_branch}:#{remote_branch}\"\n return command(:push, args)\n end", "def git_push(remote = 'origin')\n mysystem(\"git push --set-upstream #{remote} #{git_current_branch}\")\n end", "def push(remote)\n namehost, folder, _barefolder = split_url(remote.name)\n puts 'simple_push'\n simple_push(remote('origin'))\n puts 'bare_repo.push'\n bare_repo.push(remote)\n try_system %[ssh #{namehost} \"cd #{folder} && git pull origin\"]\n end", "def push(options={})\n raise MissingRemote unless has_remotes?\n options.merge! :remote => DEFAULT_REMOTE, :ref => DEFAULT_LOCAL_REF\n remotes[options[:remote]].push([options[:ref]], {:credentials => credentials})\n end", "def sync_addon_branch_to_blessed_repo(repoName, remoteBranch, localBranch, pushForce = false)\n self.log(INFO,repoName,\"Checkout #{remoteBranch} branch (it is perhaps not the default) for #{repoName}...\")\n s = system(\"git checkout #{localBranch}\")\n if !s\n print(\"[ERROR] No #{remoteBranch} branch in repository #{repoName}, Skip this repo!!!\\n\")\n self.log(INFO,repoName,\"Done.\")\n # Let's process the next one\n else\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Reset #{localBranch} to #{remoteBranch} for #{repoName} ...\")\n s = system(\"git reset --hard #{remoteBranch}\")\n if !s\n abort(\"[ERROR] Reset #{localBranch} to #{remoteBranch} for #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Push #{localBranch} branch content from exo-addons repository to blessed repository ...\")\n\n forceParam = \"\"\n if pushForce\n forceParam = \"--force\"\n end\n\n s = system(\"git push #{forceParam} blessed #{localBranch}\")\n if !s\n abort(\"[ERROR] Push of #{localBranch} branch updates to repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n end\n end", "def sync_remotes_to_local(repo)\n local_branches = {}\n remote_branches = {}\n\n repo.branches.each {|branch|\n before, after = branch.name.split('/')\n if after.nil? # Test if this is a local branch\n local_branches[before] = branch\n else\n if branch.type == :direct # Ignore origin/HEAD etc.\n remote_branches[after] = [] unless remote_branches.key? after\n remote_branches[after].push branch\n end\n end\n }\n\n remote_branches.each {|name, remotes|\n begin\n max = remotes.max {|a, b|\n commit_compare repo, a.target, b.target\n }\n rescue ArgumentError\n raise Exception.new(\"Could not fast-forward sync #{a.name} with #{b.name}\")\n else\n if local_branches.key? name\n if repo.descendant_of? local_branches[name].target, max.target\n max.target = local_branches[name].target\n else\n logged_refupdate(repo, local_branches[name], max)\n end\n else\n puts \"Creating branch: #{name} <= #{max.name}\"\n local_branches[name] = repo.branches.create(name, max.target.oid)\n end\n end\n }\n local_branches\n end", "def update\n Repository.new(self).add_git_remote\n Hook.new(self).setup\n end", "def pull(remote)\n namehost, folder, _barefolder = split_url(remote.name)\n try_system %[ssh #{namehost} \"cd #{folder} && git push origin\"]\n Dir.chdir(bare_repo.repo.to_s) do\n try_system(\"git fetch #{remote.name} master:master\")\n end\n #bare_repo.fetch(remote)\n simple_pull(remote('origin'))\n end", "def update\n # Reset --hard repo before update\n reset! if @settings[:reset_before_update]\n\n # Fetch changes from origin\n repo.fetch('origin', credentials: credentials)\n\n # Create the merged index in memory\n merge_index = repo.merge_commits(local_branch, remote_branch)\n\n # Complete the merge by comitting it\n opts = {\n parents: [local_branch, remote_branch],\n tree: merge_index.write_tree(repo),\n update_ref: update_ref,\n message: update_message,\n author: commit_author,\n committer: commit_author\n }\n Rugged::Commit.create(repo, opts)\n\n reload!\n end", "def git_push(*remotes)\n remotes.each do |remote|\n git(:push => \"#{remote} master\")\n end\n end", "def push(remote_store, local_branch, remote_branch)\n VCSToolkit::Utils::Sync.sync object_store, local_branch, remote_store, remote_branch\n end", "def push_repo_changes_aux(repo, opts={})\n diffs = DiffSummary.new()\n\n # adding untracked files (newly added files)\n repo.stage_changes()\n\n # commit if there has been changes\n if repo.changed?\n repo.commit(opts[:commit_msg]||\"Pushing changes from client\") #TODO: make more descriptive\n end\n\n if opts[:remote_repo] and opts[:remote_repo_url]\n repo.add_remote(opts[:remote_repo],opts[:remote_repo_url])\n end\n\n unless opts[:no_fetch]\n repo.fetch(remote(opts[:remote_repo]))\n end\n\n local_branch = repo.local_branch_name\n\n remote_branch_ref = remote_branch_ref(local_branch, opts)\n\n #check if merge needed\n commit_shas = Hash.new\n merge_rel = repo.merge_relationship(:remote_branch,remote_branch_ref, :ret_commit_shas => commit_shas)\n commit_sha = nil\n diffs = DiffSummary.new_version(repo)\n\n if merge_rel == :equal\n commit_sha = commit_shas[:other_sha]\n elsif [:branchpoint,:local_behind].include?(merge_rel)\n if opts[:force]\n diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)\n if diffs.any_diffs?()\n repo.push(remote_branch_ref, {:force => opts[:force]})\n end\n commit_sha = repo.find_remote_sha(remote_branch_ref)\n else\n where = opts[:where] || 'server'\n msg = \"Merge needed before module (#{pp_module(repo)}) can be pushed to #{where}. \"\n if where.to_sym == :catalog\n msg << \" Either a merge into the local module can be done with pull-dtkn command, followed by push-dtkn or force\"\n else\n msg << \"Force\"\n end\n msg << \" push can be used with the '--force' option, but this will overwrite remote contents\"\n raise ErrorUsage.new(msg)\n end\n elsif merge_rel == :no_remote_ref\n repo.push(remote_branch_ref)\n commit_sha = commit_shas[:local_sha]\n elsif merge_rel == :local_ahead\n # see if any diffs between fetched remote and local branch\n # this has be done after commit\n diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)\n\n if diffs.any_diffs?()\n repo.push(remote_branch_ref, {:force => opts[:force]})\n end\n\n commit_sha = repo.find_remote_sha(remote_branch_ref)\n else\n raise Error.new(\"Unexpected merge_rel (#{merge_rel})\")\n end\n\n {\"diffs\" => diffs, \"commit_sha\" => commit_sha, \"repo_obj\" => repo}\n end", "def update\n working_dir do\n git 'fetch', 'origin'\n git 'checkout', branch\n git 'reset', '--hard', \"origin/#{branch}\"\n git 'submodule', 'update', '--init'\n end\n end", "def pull(remote, options={})\n raise RuntimeError, \"Unknown remote #{remote}\" unless remote_list.include?(remote)\n\n git.fetch({}, remote)\n git.fetch({:tags => true}, remote)\n\n ref_rx = /^#{Regexp.quote(remote)}\\//\n remote_branches = Hash[remotes.map{|r| [$',r] if r.name =~ ref_rx }.compact]\n\n # FIXME: should we depend on Vendorificator::Config here?\n Vendorificator::Config.each_module do |mod|\n remote_head = remote_branches[mod.branch_name]\n ours = mod.head && mod.head.commit.sha\n theirs = remote_head && remote_head.commit.sha\n\n if remote_head\n if not mod.head\n say_status 'new', mod.branch_name, :yellow\n git.branch({:track=>true}, mod.branch_name, remote_head.name) unless options[:dry_run]\n elsif ours == theirs\n say_status 'unchanged', mod.branch_name\n elsif fast_forwardable?(theirs, ours)\n say_status 'updated', mod.name, :yellow\n unless options[:dry_run]\n mod.in_branch do\n git.merge({:ff_only => true}, remote_head.name)\n end\n end\n elsif fast_forwardable?(ours, theirs)\n say_status 'older', mod.branch_name\n else\n say_status 'complicated', mod.branch_name, :red\n indent do\n say 'Merge it yourself.'\n end\n end\n else\n say_status 'unknown', mod.branch_name\n end\n end\n\n private\n\n def conf\n Vendorificator::Config\n end\n\n def say_status(*args)\n conf[:shell].say_status(*args) if conf[:shell]\n end\n end", "def sync\n pull && push\n end", "def pull(remote = nil, branch = nil)\n self.lib.pull(remote, branch)\n end", "def update_remote(remote, remote_name='origin')\n if @_rugged_repo\n logger.debug2(_(\"Remote URL is different from cache, updating %{orig} to %{update}\") % {orig: remotes[remote_name], update: remote})\n @_rugged_repo.remotes.set_url(remote_name, remote)\n end\n end", "def push!\n notify.write(\"Pushing to origin\")\n proj.push('origin', proj_branch)\n proj.push('origin', report_branch)\n end", "def push(name, internal_repository)\n ensure_remote(name, internal_repository)\n\n git = git(name)\n branch = git.current_branch\n\n git.config \\\n \"remote.#{REMOTE}.push\",\n \"refs/heads/#{branch}:refs/heads/#{branch}\"\n\n git.push(REMOTE, branch)\n end", "def git_pull\n if `git branch -a` =~ /remotes\\/#{@remote}\\/#{@branch}/ ||\n `git ls-remote #{@remote}` =~ /refs\\/heads\\/#{@branch}/\n `git pull #{@remote} #{@branch}`\n end\n end", "def update_remote\n last_commit = @connection.last_commit(self.id)\n files = Repository.diff(last_commit)\n \n if files.length > 0\n puts \"#{files.length} changes since last delivery\"\n pbar = ProgressBar.new(\"Uploading\", files.length)\n files.each do |file|\n @connection.send(Gift::Connection.file_method(file.last.action), file.last)\n pbar.inc\n end\n pbar.finish\n \n last_commit = Gift::Repository.last_commit_hash unless last_commit && last_commit != \"\"\n self.save_state(last_commit)\n else\n puts \"Everything up to date!\"\n end\n \n @connection.close\n end", "def git_push(host, branch, git_repo_path)\n git_on(host, \"push origin #{branch}\", git_repo_path)\nend", "def pull\n ui.info(\"Pulling from origin\")\n git.pull(REMOTE, [ REMOTE, BRANCH ], AUTO_MERGE_MSG)\n end", "def fetch(remote_store, remote_branch, local_branch)\n VCSToolkit::Utils::Sync.sync remote_store, remote_branch, object_store, local_branch\n end", "def update!(**args)\n @author = args[:author] if args.key?(:author)\n @remote_branch = args[:remote_branch] if args.key?(:remote_branch)\n end", "def pre_push(remote, opts={})\n common = {}\n remote_heads = remote.heads\n inc = common_nodes remote, :base => common, :heads => remote_heads, :force => true\n inc = inc[1]\n update, updated_heads = find_outgoing_roots remote, :base => common, :heads => remote_heads\n \n if opts[:revs]\n btw = changelog.nodes_between(update, opts[:revs])\n missing_cl, bases, heads = btw[:between], btw[:roots], btw[:heads]\n else\n bases, heads = update, changelog.heads\n end\n if bases.empty?\n UI::status 'no changes found'\n return nil, 1\n elsif !opts[:force]\n # check if we're creating new remote heads\n # to be a remote head after push, node must be either\n # - unknown locally\n # - a local outgoing head descended from update\n # - a remote head that's known locally and not\n # ancestral to an outgoing head\n \n warn = false\n if remote_heads == [NULL_ID]\n warn = false\n elsif (opts[:revs].nil? || opts[:revs].empty?) and heads.size > remote_heads.size\n warn = true\n else\n new_heads = heads\n remote_heads.each do |r|\n if changelog.node_map.include? r\n desc = changelog.heads r, heads\n l = heads.select {|h| desc.include? h }\n \n new_heads << r if l.empty?\n else\n new_heads << r\n end\n end\n \n warn = true if new_heads.size > remote_heads.size\n end\n \n if warn\n UI::status 'abort: push creates new remote heads!'\n UI::status '(did you forget to merge? use push -f to forge)'\n return nil, 0\n elsif inc.any?\n UI::note 'unsynced remote changes!'\n end\n end\n \n if opts[:revs].nil?\n # use the fast path, no race possible on push\n cg = get_changegroup common.keys, :push\n else\n cg = changegroup_subset update, revs, :push\n end\n \n [cg, remote_heads]\n end", "def push_to_server(local_branch, remote_branch, opts = {})\n if opts[:local]\n logger.debug('Not pushing to the server because the user selected local-only.')\n elsif not has_a_remote?\n logger.debug('Not pushing to the server because there is no remote.')\n elsif local_branch == config.master_branch\n logger.warn('Not pushing to the server because the current branch is the mainline branch.')\n else\n opts[:prepush].call if opts[:prepush]\n\n push(remote.name, local_branch, remote_branch, :force => opts[:force])\n\n opts[:postpush].call if opts[:postpush]\n end\n end", "def git_clone_or_pull(repo,dest,ref=\"master\")\n run \"#{sudo} mkdir -p #{File.dirname(dest)}; #{sudo} chown -R #{user} #{File.dirname(dest)}\"\n cmd = compressed_join %Q{\n if [ -d #{dest} ]; then\n cd #{dest};\n git fetch;\n else\n git clone #{repo} #{dest};\n cd #{dest};\n git checkout -b deploy;\n fi\n }\n run_with_input(cmd,%r{\\(yes/no\\)}, \"yes\\n\")\n run_compressed %Q{\n if [ `cd #{dest} && git tag | grep -c #{ref}` = '1' ]; then\n cd #{dest}; git reset --hard #{ref};\n else\n cd #{dest}; git reset --hard origin/#{ref};\n fi\n }\n end", "def pullFromGitRemotes(branch)\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pulling #{branch} from remote: #{branch}\\\"\")\n sh(\"git pull --no-edit #{remote} #{branch}\")\n end\nend", "def update_deploy_to_master\n unless params[:ref] == 'refs/heads/master'\n render(plain: 'Not on master; not interested') && return\n end\n\n new_sha1 = params[:after]\n\n # false indicates a not-force-push\n Octokit.update_ref 'Charcoal-SE/SmokeDetector', 'heads/deploy', new_sha1, false\n\n # See https://developer.github.com/v3/activity/events/types/#webhook-payload-example-26\n # for what’s in `params`\n ActionCable.server.broadcast 'smokedetector_messages', deploy_updated: params\n ApiChannel.broadcast_to 'ref_update', event_type: 'update', event_class: 'Ref', object: params\n end", "def initial_push_command\n \"git remote add origin git@github.com:#{owner.login}/#{name}.git &&\\n\" +\n \"git push origin master &&\\n\" +\n \"git config --add branch.master.remote origin &&\\n\" +\n \"git config --add branch.master.merge refs/heads/master\" \n end", "def remote\n grit.config[\"branch.#{branch}.remote\"] || 'origin'\n end", "def merge(branch_name)\n remote_commit = last_commit(remote_branch_from_local(branch_name))\n\n @rugged_repository.references.update(rugged_repository.head, remote_commit.oid)\n end", "def push(downstream, upstream, remote_branch='svn_git_port')\n name=get_dir_name(downstream, upstream)\n upstream_dir=File.join(name, 'upstream')\n Dir.chdir(upstream_dir) do\n puts `git checkout -b push`\n puts `git push upstream HEAD:#{remote_branch}`\n end\nend", "def files_remote_update(options = {})\n post('files.remote.update', options)\n end", "def fetch_update\n remote_branch = ErrorEmittingExecutor.execute(\"git branch -r --list origin/#{BRANCH_NAME}\")\n if remote_branch == 'origin/cocina-level2-updates'\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS} #{GIT_BRANCH_FETCH_REFS}\")\n else\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS}\", exit_on_error: true)\n end\nend", "def push!(local)\n if remote_id = local.remote_id(project.id)\n type = local.is_a?(Milestone) ? 'Milestone' : local.class.name\n remote = lighthouse.send type.downcase, remote_id\n remote.update_attributes! local.attributes\n else\n remote = lighthouse.from_local(local)\n if remote.save\n local.update_attributes :remote_id => remote.id\n else\n # TODO raise remote.errors\n end\n end\n end", "def pull(options={})\n fetch(options[:remote])\n merge(options)\n end", "def update_remote(path, git_remote)\n updated = false\n\n Dir.chdir(path) do\n @logger.debug(\"update git remote urls for #{path}\")\n\n git_remote.each do |remote_name, remote_url|\n stdout, _stderr, _status = Open3.capture3(\"git remote get-url #{remote_name}\")\n\n current_remote_url = stdout.strip\n\n next if remote_url.nil? || current_remote_url == remote_url\n\n `git remote remove #{remote_name}` unless current_remote_url.empty?\n\n `git remote add #{remote_name} #{remote_url}`\n\n updated = true\n end\n end\n\n updated\n end", "def push(remote_repo, opts={:force => false, :revs => nil})\n if remote_repo.capable? \"unbundle\"\n push_unbundle remote_repo, opts\n else\n push_add_changegroup remote_repo, opts\n end\n end", "def push_repo\n reference_point = git_branch_name || git_tag_name || 'master'\n callback(:push_repo) do\n notify(:push_repo, reference_point: reference_point, app_name: app_name, force: force)\n force_flag = force ? \"-f \" : \"\"\n system_call \"git push #{force_flag}#{deployment_remote} #{reference_point}:refs/heads/master\"\n end\n end", "def update_info\n git.remote(git_opts.merge(:raise => false), \"update\")\n self\n end", "def apply\n #TODO: generate a better commit message\n @gl_admin.commit_index(\"Commit by gitolite gem\")\n @gl_admin.git.push({}, \"origin\", \"master\")\n end", "def set_push_origin_url push_origin_url\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_loggable_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} remote set-url --push origin\"\n git_set_push_origin_url_cmd = \"#{git_loggable_cmd} #{push_origin_url}\"\n log.info(x) { \"[git] set push origin url command without url => #{git_loggable_cmd}\" }\n %x[#{git_set_push_origin_url_cmd}];\n log.info(x) { \"[git] has set the remote origin url for pushing.\" }\n\n end", "def git_pull(remote = '')\n mysystem(\"git pull #{remote}\")\n end", "def update_remote\n # TODO\n end", "def update\n context.execute :rm, '-rf', \"#{deploy_path}/local_file/*\"\n context.upload! fetch(:repo_url), \"#{deploy_path}/local_file/#{fetch(:repo_url)}\"\n end", "def fast_forward\n `git #{@git_args} fetch`\n `git #{@git_args} rebase origin/#{@master}`\n end", "def update\n [\n git('checkout', '.'),\n git('clean', '-ffd'),\n git('fetch', 'origin'),\n git('checkout', branch),\n git('pull', '--recurse-submodules=yes'),\n git('checkout', commit_hash_for_checkout),\n git('submodule', 'update', '--init'),\n git('clean', '-ffd')\n ].join(\"\\n\")\n end", "def pushtobare(branch = 'master')\n remote = satelliterepo.remotes['bare']\n remote = satelliterepo.remotes.create 'bare', barerepo.path unless remote\n satelliterepo.push remote, [\"refs/heads/#{branch}\"]\n end", "def pushtobare(branch = 'master')\n remote = satelliterepo.remotes['bare']\n remote = satelliterepo.remotes.create 'bare', barerepo.path unless remote\n satelliterepo.push remote, [\"refs/heads/#{branch}\"]\n end", "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 working_dir do\n git 'checkout', working_dir\n git 'clean', '-fd'\n git 'checkout', 'master'\n git 'pull'\n git 'fetch', 'origin'\n git 'checkout', branch\n git 'submodule', 'update', '--init'\n end\n end", "def push(repo)\n before_push(repo)\n\n repo.cmd \"git remote add #{name} #{clone_url(repo)}\"\n repo.cmd \"git push --all #{name}\"\n after_push(repo)\n end", "def push_repo\n UI.puts \"\\nPushing the `#{@repo}' repo\\n\".yellow\n repo_git('push', 'origin', 'HEAD')\n end", "def push\n if @tags.empty?\n gash.send(:git, 'push', @push_to, @refspec)\n else\n gash.send(:git, 'push', '--tags', @push_to, @refspec)\n end\n end", "def to_checkout\n @to_checkout ||= begin\n clean_local_branch\n remote_branch? ? \"origin/#{ref}\" : ref\n end\n end", "def fetch_and_pull_branch(branch_name)\n `cd #{project_repo_path} && git fetch && git checkout #{branch_name} && git pull origin #{branch_name} && git checkout #{self.trunk_branch}`\n end", "def test_gitgo_different_from_remote_gitgo\n assert !sh(a, 'git branch -a').include?('gitgo')\n assert !sh(b, 'git branch -a').include?('gitgo')\n assert !sh(c, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"bshasum\") {|io| io << \"b content\" }\n sh(b, 'git add bshasum')\n sh(b, 'git commit -m \"added document\"')\n \n # setup remote from c\n sh(c, 'git branch gitgo')\n sh(c, 'git checkout gitgo')\n method_root.prepare(c, \"cshasum\") {|io| io << \"c content\" }\n sh(c, 'git add cshasum')\n sh(c, 'git commit -m \"added document\"')\n sh(c, 'git push origin gitgo')\n \n # now try to push back, fails\n assert sh(b, 'git push origin gitgo').include?(\"! [rejected] gitgo -> gitgo (non-fast forward)\")\n \n sh(a, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # merge\n sh(b, 'git fetch')\n assert sh(b, 'git branch').include?('gitgo')\n assert sh(b, 'git branch -a').include?('origin/gitgo')\n sh(b, 'git merge origin/gitgo')\n \n # now push works\n sh(b, 'git push origin gitgo')\n sh(a, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # fetch for c leaves changes unmerged\n sh(c, 'git fetch')\n sh(c, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n \n # manual merge fixes\n sh(c, 'git merge gitgo origin/gitgo')\n sh(c, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n end", "def pull(tracking_branch=upstream_branch)\n sandbox do |git, work_tree, index_file|\n remote, remote_branch = parse_tracking_branch(tracking_branch)\n git.fetch({}, remote, \"#{remote_branch}:remotes/#{tracking_branch}\")\n merge(tracking_branch)\n end\n reset\n end", "def push\n if File.exist?(@local)\n check_branch\n init_repo\n puts \"Syncing #{@local.sub(Dir.pwd.strip+'/', '')} files to #{@repo}.\"\n FileUtils.cd @deploy_dir do\n git_pull\n clean_deploy\n copy_site\n git_push\n end\n else\n abort \"Cannot find site build at #{@local}. Be sure to build your site first.\"\n end\n end", "def git_push_commits\n shellout(\"git push #{config[:remote]} #{config[:branch]}\")\n end", "def push\n ensure_git_and_cucumber_available\n ensure_repository\n\n puts \"Not implemented yet... pull request for push please!\"\n end", "def create_remote_repo\n `git init --bare #{REMOTE_PATH}/#{@name}.git`\n\n # Connect local repository to remote and push local master branch to remote.\n Dir.chdir(\"#{LOCAL_PATH}/#{@name}\") do\n `git remote add #{UPSTREAM_NAME} #{REMOTE_PATH}/#{@name}.git && git push -u #{UPSTREAM_NAME} master`\n end\n end", "def update_master\n execute_cmd 'git checkout master'\n execute_cmd 'git pull'\nend", "def update_master\n execute_cmd 'git checkout master'\n execute_cmd 'git pull'\nend", "def update!(**args)\n @remote_path = args[:remote_path] if args.key?(:remote_path)\n end", "def pull\n fetch\n merge\n end", "def git_remote\n repos = begin\n %x{git remote --verbose 2>/dev/null}.split(\"\\n\").map(&:split).map {|x| [x[0],x[1]] }.uniq\n rescue\n []\n end\n default = repos.find { |x| x.first == 'origin'}\n items = repos.map { |x| x.last }\n\n menu_with_default \"Select repository \", items.compact, default\n end", "def set_remote\n return if @remote_type == :none\n\n url = \"git@github.com:pixelastic/#{@name}.git\" if @remote_type == :github\n if @remote_type == :bitbucket\n url = \"git@bitbucket.org:pixelastic/#{@name}.git\"\n end\n\n if create_remote('origin', url)\n puts '✔ Configuring remote'\n else\n puts '✘ Failed to configure remote'\n exit 1\n end\n end", "def push_unbundle(remote, opts={})\n # local repo finds heads on server, finds out what revs it\n # must push. once revs transferred, if server finds it has\n # different heads (someone else won commit/push race), server\n # aborts.\n \n ret = pre_push remote, opts\n \n if ret[0]\n cg, remote_heads = *ret\n remote_heads = ['force'] if opts[:force]\n remote.unbundle cg, remote_heads, :push\n else\n ret[1]\n end\n end", "def change_git!\n @jobs.each_value do |job|\n job[:value][:scm_branch] = \"origin/pr/#{@number}/head\"\n job[:value][:scm_params] = {} unless job[:value][:scm_params]\n job[:value][:scm_params][:refspec] = 'refs/pull/*:refs/remotes/origin/pr/*'\n end\n end", "def git_checkout_and_push_u(name, opts={})\n cmd = \"git checkout -b #{name}\"\n puts cmd\n out = `#{cmd}`\n if $? == 0\n cmd = \"git push -u origin #{name}\"\n puts cmd\n out = `#{cmd}`\n if $? == 0\n # nothing\n else\n $stderr.puts \"ERROR: failed to push '#{name}' to origin\"\n end\n else\n $stderr.puts \"ERROR: failed to checkout '#{name}'\"\n end\nend", "def upstream_branch\n remote = grit.config[\"branch.#{branch}.remote\"]\n merge = grit.config[\"branch.#{branch}.merge\"]\n \n # No remote, no merge, no tracking.\n if remote.nil? || merge.nil?\n return nil\n end\n \n unless merge =~ /^refs\\/heads\\/(.*)$/\n raise \"invalid upstream branch\"\n end\n \n \"#{remote}/#{$1}\"\n end", "def commit_and_push_to_repo(oauth_token, commit_message, \n tree_sha, head_sha, ref_name)\n client = Octokit::Client.new(access_token: oauth_token)\n sha_new_commit = client.create_commit(full_repo_name, commit_message, tree_sha, head_sha)[:sha]\n client.update_ref(full_repo_name, ref_name, sha_new_commit)\n end", "def update_repo\n UI.puts \"Updating the `#{@repo}' repo\\n\".yellow\n git!(%W(-C #{repo_dir} pull))\n end", "def push\n unless system(\"cd #{repo_path};git push origin #{branch}\")\n raise GitCloud::GitException.new(\"Push\")\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 push(_branch)\n puts 'TODO: Implement Git.push'\n end", "def test_gitgo_tracking_a_remote_branch\n # setup remote from c\n sh(c, 'git branch gitgo')\n sh(c, 'git checkout gitgo')\n method_root.prepare(c, \"cshasum1\") {|io| io << \"c content\" }\n sh(c, 'git add cshasum1')\n sh(c, 'git commit -m \"added document\"')\n sh(c, 'git push origin gitgo')\n \n # fetch gitgo\n sh(b, 'git fetch')\n assert !sh(b, 'git branch').include?('gitgo')\n assert sh(b, 'git branch -a').include?('origin/gitgo')\n \n sh(b, 'git branch gitgo --track origin/gitgo')\n sh(b, 'git checkout master')\n \n # make changes from c\n method_root.prepare(c, \"cshasum2\") {|io| io << \"C content\" }\n sh(c, 'git add cshasum2')\n sh(c, 'git commit -m \"added document\"')\n sh(c, 'git push origin gitgo')\n \n # pull changes\n sh(b, 'git pull')\n assert_equal false, File.exists?(method_root.path(b, \"cshasum1\"))\n assert_equal false, File.exists?(method_root.path(b, \"cshasum2\"))\n \n # not fast-forwarded\n sh(b, 'git checkout gitgo')\n assert_equal \"c content\", File.read(method_root.path(b, \"cshasum1\"))\n assert_equal false, File.exists?(method_root.path(b, \"cshasum2\"))\n \n # fast forward\n sh(b, 'git merge origin/gitgo')\n assert_equal \"c content\", File.read(method_root.path(b, \"cshasum1\"))\n assert_equal \"C content\", File.read(method_root.path(b, \"cshasum2\"))\n end", "def update!(**args)\n @branches = args[:branches] if args.key?(:branches)\n end", "def update!(**args)\n @push_config = args[:push_config] unless args[:push_config].nil?\n end", "def update!(**args)\n @pull_deps = args[:pull_deps] if args.key?(:pull_deps)\n @source = args[:source] if args.key?(:source)\n end", "def update!(**args)\n @pull_deps = args[:pull_deps] if args.key?(:pull_deps)\n @source = args[:source] if args.key?(:source)\n end", "def push\n cfm.send_to_remote if do_push?\n end", "def push_tags(remote_name, id = nil)\n remote = find_or_create_remote(remote_name)\n raise RemoteNotFound, \"Remote named: #{remote_name} was not found\" unless remote\n all_refs = repo.tags.map(&:canonical_name)\n refs = if id\n tag = find_tag(id)\n tag.canonical_name if tag\n else\n all_refs\n end\n raise NoTagsExists, \"No tags were pushed\" if refs.empty?\n logger.debug(\"Pushing refs #{refs}\")\n logger.info(\"Pushing tags to remote #{remote.url}\")\n remote.push(refs, credentials: credentials)\n end", "def fetch_origin_task\n sh git, 'fetch', remote\n end", "def remote_branches\n @remote_branches ||= @project.branches.remote.map(&:full)\n end", "def push(uuid, repo, from_repo_uuid = nil, to_repo_uuid = nil)\n from_repo_uuid ||= @uuid\n to_repo_uuid ||= repo.uuid\n remote_head = repo.head(uuid, to_repo_uuid)\n # TODO: receiver must store received versions somewhere, \n # then try fast-forward merge or report an error.\n # Find out what this \"somewhere\" is. Maybe, a temporary\n # repo/branch.\n end", "def update_pull_branch(repo, pull_number, options = {})\n opts = options.dup\n opts[:accept] = 'application/vnd.github.lydian-preview+json' if opts[:accept].nil?\n\n put \"#{Repository.path repo}/pulls/#{pull_number}/update-branch\", opts\n end", "def fetch(remote=self.remote)\n sandbox {|git,w,i| git.fetch({}, remote) }\n self\n end", "def add_remote(uri, name)\n @repository.add_remote(name,uri)\n \n self.remotes\n end", "def related\n\t\t\tup=upstream\n\t\t\tpu=push\n\t\t\tpu=new_branch(nil) if up==pu\n\t\t\treturn up, pu\n\t\tend", "def checkout(branch_name)\n local_branches = @rugged_repository.branches.each_name.to_a\n if !local_branches.include?(branch_name) && self.remote_branch_from_local(branch_name)\n @rugged_repository.branches.create(branch_name, self.remote_branch_from_local(branch_name))\n end\n @rugged_repository.checkout(branch_name)\n end", "def git_update(target)\n cmd = \"git fetch\"\n\n FileUtils.cd(target) do\n sysexec(cmd)\n end\nend" ]
[ "0.67076653", "0.6661574", "0.6569846", "0.65409166", "0.64433914", "0.6433975", "0.63664246", "0.6357785", "0.6330111", "0.62794983", "0.62723064", "0.62672", "0.6245432", "0.6143999", "0.61360043", "0.60852474", "0.6076615", "0.60738564", "0.6001373", "0.59698576", "0.5880783", "0.5874868", "0.5840748", "0.58337414", "0.58307177", "0.58299035", "0.5757175", "0.5739408", "0.5731034", "0.57078356", "0.5694855", "0.5688902", "0.5680943", "0.56740373", "0.5655051", "0.56391513", "0.56298876", "0.5622702", "0.5608685", "0.56020814", "0.56011564", "0.556343", "0.55556554", "0.5536916", "0.5494691", "0.5490297", "0.5482319", "0.54778147", "0.54738563", "0.54678285", "0.54673713", "0.54653805", "0.5460068", "0.54254186", "0.54254186", "0.541324", "0.5411807", "0.5408279", "0.53685606", "0.5353033", "0.53204", "0.5313497", "0.5311296", "0.5303774", "0.5301345", "0.52976227", "0.52956086", "0.5289526", "0.52839196", "0.52839196", "0.52717364", "0.52582383", "0.52533805", "0.5251262", "0.52492374", "0.52429295", "0.5236827", "0.5235169", "0.52337337", "0.52307284", "0.52242285", "0.5217362", "0.5208108", "0.5207813", "0.5207336", "0.5200036", "0.51935345", "0.51935345", "0.5187747", "0.51791465", "0.51730734", "0.51620245", "0.5159289", "0.51541305", "0.51501954", "0.5148865", "0.5144702", "0.5143641", "0.514245" ]
0.65835553
3
Return the name of the remote repository whose branch the current local branch tracks, or nil if none.
def remote(branch = current_branch) remote = git('config', '--get', "branch.#{branch}.remote").to_s.strip remote if !remote.empty? && git('remote').include?(remote) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def branch_remote_name(branch_name)\n `git config branch.#{branch_name}.remote`.strip\n end", "def branch_name\n $repo.current_branch\n end", "def branch\n %x[cd #{repo_path};git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}].chomp\n end", "def branch\n `git rev-parse --abbrev-ref HEAD`.strip.presence\n rescue\n nil\n end", "def current_branch\n repo.branches.find(&:head?)\n end", "def determine_branch_name(repo)\n name = \"\"\n repo.branches.each do |branch|\n if branch.head?\n name = branch.name\n break\n end\n end\n return name\nend", "def current_branch\n repo.branches.find(&:head?)\n end", "def remote_name\n # git remote\n command('remote')[0].strip\n end", "def current_branch\n ref = Rugged::Reference.lookup(@git, 'HEAD').resolve\n if not ref.branch?\n raise Error, \"Not currently on a branch.\"\n end\n ref.name.split('/').last\n end", "def remote\n grit.config[\"branch.#{branch}.remote\"] || 'origin'\n end", "def discover_default_branch\n now_head = Ref.extract_branch_name(rugged_head.name)\n return now_head if now_head.to_s != \"\"\n\n names = local_branch_names\n if names.length == 0\n nil\n elsif names.include?(\"master\")\n \"master\"\n else\n names.first\n end\n end", "def current_branch\n `git symbolic-ref --short -q HEAD`.chomp\n end", "def default_branch(remote)\n remote_url = `git config remote.#{Shellwords.escape remote}.url`.chomp\n repo_name = begin\n URI.parse(remote_url).path[1..-5]\n rescue ::URI::InvalidURIError\n remote_url.split(':', 2).last[0..-5]\n end\n\n if File.basename(repo_name).end_with? '.github.io'\n 'master'\n else\n 'gh-pages'\n end\n end", "def branch\n return git_fork_config.branch\n end", "def current_branch\n `git symbolic-ref --short HEAD`.strip\n end", "def current_branch\n git.branch.name\n end", "def branch\n case @vcs\n when 'github'\n if @data.key? 'ref'\n @data['ref'].sub('refs/heads/', '')\n else\n @data['repository']['default_branch']\n end\n when 'gitlab'\n @data['ref'].sub('refs/heads/', '')\n when 'bitbucket-server'\n @data['changes'][0]['refId'].sub('refs/heads/', '')\n when 'bitbucket'\n return @data['push']['changes'][0]['new']['name'] unless deleted?\n\n @data['push']['changes'][0]['old']['name']\n when 'stash'\n @data['refChanges'][0]['refId'].sub('refs/heads/', '')\n when 'tfs'\n @data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '')\n end\n end", "def current_branch\n %x(git branch | grep '*' | cut -d' ' -f2).chomp\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n logger.info \"Deploying branch #{branch}\"\n branch\nend", "def remote_branch_from_local(branch_name)\n remote_branches.find { |x| x.ends_with?(branch_name) }\n end", "def branch_name\n @branch_name ||= ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.chomp\n end", "def get_remote_repository_name\n return @registry_server + \"/\" + @repository_name\n end", "def current_branch\n return @branch unless @branch.blank?\n @branch = case @svninfo.url\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else @config_source[\"branch\"]\n end \n @branch || \"unkown\"\n end", "def discover_default_branch\n names = branch_names\n\n return if names.empty?\n\n return names[0] if names.length == 1\n\n if rugged_head\n extracted_name = Ref.extract_branch_name(rugged_head.name)\n\n return extracted_name if names.include?(extracted_name)\n end\n\n if names.include?('master')\n 'master'\n else\n names[0]\n end\n end", "def current_branch\n Dir.chdir @root do\n cmd = \"git rev-parse --abbrev-ref HEAD\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /unknown revision/\n raise Error, \"could not determine branch of repo with no commits\"\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.strip\n end\n end", "def current_branch\n hg('branch').to_s.strip\n end", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def branch_name\n `git name-rev --name-only HEAD`.strip\n end", "def branchname\n @branchname ||= self.branch.name\n end", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def get_branch_name\r\n\tputs IO.popen('git branch --no-abbrev').read.slice(2..-1)\r\nend", "def get_branch \n branch = case @os_svninfo['URL']\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /patches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else fail(\"Can't determine which branch I'm operating on\")\n end\n branch\n end", "def current_branch\n git('branch')[/^\\* (.*)$/, 1]\n end", "def current_branch\n git('branch')[/^\\* (.*)$/, 1]\n end", "def derive_branch_name\n @config[:git][:branch] == 'preview' ? preview_branches.last : @config[:git][:branch]\n end", "def git_get_current_branch()\n current_branch = `git branch`.split(/\\n/).find{ |l| l.start_with?(\"*\") }\n \n if current_branch\n current_branch =~ /\\*\\s+(.+)/\n $~[1]\n end \nend", "def get_current_branch_from_git\n %x{ git rev-parse --abbrev-ref HEAD }.chomp\nend", "def repository_name\n Repository.context.any? ? Repository.context.last.name : default_repository_name\n end", "def getMainGitRemote\n remotes = sh(\"git remote\", log: false).split\n if remotes.include?(\"upstream\")\n return \"upstream\"\n else\n return \"origin\"\n end\nend", "def upstream_branch\n remote = grit.config[\"branch.#{branch}.remote\"]\n merge = grit.config[\"branch.#{branch}.merge\"]\n \n # No remote, no merge, no tracking.\n if remote.nil? || merge.nil?\n return nil\n end\n \n unless merge =~ /^refs\\/heads\\/(.*)$/\n raise \"invalid upstream branch\"\n end\n \n \"#{remote}/#{$1}\"\n end", "def branch\n @branch ||= `git branch 2> /dev/null`[/\\*\\s(.+)$/, 1]\n end", "def currentbranch\n %x{git branch | grep \"*\" | sed \"s;* ;;\"}.squish\n end", "def local_branch_information\n #This is sensitive to checkouts of branches specified with wrong case\n\n listing = capture_process_output(\"#{LOCAL_BRANCH_LISTING_COMMAND}\")[1]\n\n raise(NotOnGitRepositoryError, listing.chomp) if listing =~ /Not a git repository/i\n if listing =~ /\\(no branch\\)/\n raise InvalidBranchError, [\"Couldn't identify the current local branch. The branch listing was:\",\n LOCAL_BRANCH_LISTING_COMMAND.red, listing].join(\"\\n\")\n end\n\n current_branch = nil\n branches = listing.split(\"\\n\").map do |line|\n current = line.include? '*'\n clean_line = line.gsub('*','').strip\n current_branch = clean_line if current\n clean_line\n end\n\n return current_branch, branches\n end", "def current_branch\n @current_branch ||= `git rev-parse --abbrev-ref HEAD`.strip\n end", "def source_branch\n git_call('branch').chomp.match(/\\*(.*)/)[0][2..-1]\n end", "def branch\n (@options[:branch] || 'master').to_s\n end", "def branch\n (@options[:branch] || 'master').to_s\n end", "def branch\n 'refs/heads/master'\nend", "def get_git_branch()\n return `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e \"s/* \\\\(.*\\\\)/\\\\1/\"`.strip\nend", "def remote_name\n unless @remote_name\n @remote_name = config['gitProcess.remoteName']\n if @remote_name.nil? or @remote_name.empty?\n remotes = self.remote_names\n if remotes.empty?\n @remote_name = nil\n else\n @remote_name = remotes[0]\n raise \"remote name is not a String: #{@remote_name.inspect}\" unless @remote_name.is_a? String\n end\n end\n logger.debug { \"Using remote name of '#{@remote_name}'\" }\n end\n @remote_name\n end", "def git_repo_name\n path = File.expand_path(File.dirname(__FILE__))\n # the path looks like /repos/bender.git/hooks\n path.split(%r{/})[-2]\nend", "def repo_name\n # the repo is the last part of the path\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n end", "def repo_name\n unless @repo_name\n url = config[\"remote.#{name}.url\"]\n raise GitProcessError.new(\"There is no #{name} url set up.\") if url.nil? or url.empty?\n uri = Addressable::URI.parse(url)\n @repo_name = uri.path.sub(/\\.git/, '').sub(/^\\//, '')\n end\n @repo_name\n end", "def git_project_name\n Pkg::Util.in_project_root do\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{GIT} config --get remote.origin.url\")\n stdout.split('/')[-1].chomp(\".git\").chomp\n end\n end", "def other_branch\n @other_branch ||= `git branch | grep #{pattern}`.strip\n end", "def default_branch\n @default_branch ||= Nokogiri::HTML(open(branches_url)).at_css('tr.base td.name h3').text.strip.chomp\n rescue OpenURI::HTTPError => err\n raise GithubMetadata::RepoNotFound, err.to_s\n end", "def get_branch(status = `git status`)\n branch = nil\n if match = Regexp.new(\"^# On branch (.*)\").match(status)\n branch = match[1]\n end\nend", "def has_remote_tracking_branch(repo)\n return false if $branch_name.empty?\n\n begin\n return !repo.branches[$remote_branch].nil?\n rescue\n return false\n end\nend", "def repo_github_path\n descrip = %x{git remote -v}.match(/^.+git@github\\.com:(.+\\/.+)\\.git/)\n raise \"Could not find a Github remote\" if descrip.nil?\n descrip[1]\n end", "def getProjectName()\n\tcurl = 'git config --local remote.origin.url|sed -n \"s#.*/\\([^.]*\\)\\.git#\\1#p\"'\n\tresult = `#{curl}`\n\treturn result.strip()\nend", "def origin_remote\n origin = git(\"remote\", \"-v\").lines.grep(/^origin\\s/).first\n origin && origin.split[1]\n end", "def repo_name\n return unless @url\n @repo_name ||= Octokit::Repository.from_url(@url).to_s.chomp('.git')\n end", "def url_of_git_repo(remote_name)\n `git config remote.#{remote_name}.url`.strip\n end", "def repository\n result = veeamconfig('job', 'info', '--name', \"#{@resource[:name]}\").lines\n if result.length > 1\n result.each_with_index do |line, index|\n if line.strip.start_with?('Repository name:')\n bits = line.strip.split(': ')\n return bits[1].strip\n end\n end\n\n # the job's repository is not set if the job does not exist\n :absent\n else\n # the job's repository is not set if no job exists\n :absent\n end\n end", "def other_branch\n @other_branch ||= `git branch | grep #{pattern}`.split.first\n end", "def git_name\n (!GitHosting.multi_repos? || identifier.blank?) ? project.identifier : identifier\n end", "def current_branch\n self.lib.branch_current\n end", "def repo_name\n if @vcs == 'gitlab'\n @data['project']['name']\n elsif @vcs == 'tfs'\n @data['resource']['repository']['name']\n else\n @data['repository']['name']\n end\n end", "def get_branch_sha\n cmd = \"git ls-remote '#@repo_url' | awk '/#@branch/ {print $1}'\"\n puts cmd\n @branch_sha ||= %x[#{cmd}].chomp\n raise 'Could not get branch sha!' unless $?.success?\n @branch_sha\n end", "def branch(group:nil)\n case group\n when :remote\n flag = \"-r\"\n when :all\n flag = \"-a\"\n when nil, :local\n flag = \"\"\n end\n\n `git branch #{flag}`.lines.map do |line|\n fields = line.split\n\n if fields.first['*']\n fields[1].strip\n else\n fields.first.strip\n end\n end\nend", "def find_branch(repo_slug, pattern)\n list = `git ls-remote --heads --sort=version:refname https://github.com/#{repo_slug} #{pattern}`\n list.split(\"\\n\")\n .map { |line| line.sub(%r{[0-9a-f]+\\trefs/heads/}, '').chomp }\n .last # Latest ref found, in \"version:refname\" semantic order\n end", "def default_branch\n branch_name = `git symbolic-ref --short refs/remotes/origin/HEAD \\\n | sed 's@^origin/@@'`.strip\n if branch_name.empty?\n $stderr.puts \"Repository configuration error\"\n $stderr.puts \"Missing reference to refs/remotes/origin/HEAD\"\n $stderr.puts \"Run\"\n $stderr.puts\n $stderr.puts \" git remote set-head origin <default branch>\"\n $stderr.puts\n $stderr.puts \"where <default branch> is the default branch name\"\n $stderr.puts \"(typically `main`, `master`, or `trunk`)\"\n $stderr.puts \"and then rerun the command\"\n exit(1)\n end\n @default_branch ||= branch_name\n end", "def find_branch(repo, branch)\n name, num = branch.split('-')\n\n variations = [ branch, \"#{name}#{num}\", \"#{name}_#{num}\" ]\n\n branches = %x( cd #{repo} ; git branch --list ).gsub('*', '').split(\"\\n\")\n branches.each do |b|\n b.strip!\n variations.each do |v|\n return b if (b == v)\n end\n end\n\n return nil\nend", "def repo_name(repo)\n name = nil\n case repo\n when 'stable'\n name = 'omnibus-stable-local'\n when 'current'\n name = 'omnibus-current-local'\n when nil # pass through\n else\n raise \"#{repo} not supported. must be current or stable\"\n end\n name\nend", "def gitolite_repository_name\n if (parent_path = get_full_parent_path).empty?\n project.identifier\n else\n File.join(parent_path, project.identifier)\n end\n end", "def default_branch(repo)\n api.repository(repo).default_branch\n end", "def local_branches\n @local_branches ||= begin\n branches = []\n if not git.branches.local.empty?\n branches << git.branches.local.select{ |b| b.current }[0].name\n branches << git.branches.local.select{ |b| not b.current }.map{ |b| b.name }\n end\n branches.flatten\n end\n end", "def discover(branch)\n return branch if is_branch?(branch)\n\n resp = Application.config.callback :on_branch_discover, @git_path, branch\n\n unless resp.nil?\n return resp\n end\n \n local_search = \"^\" + branch.gsub(/-/, \".\") + \"$\"\n remote_search = \"^remotes/origin/(\" + branch.gsub(/-/, \".\") + \")$\"\n local_r = Regexp.new(local_search, Regexp::IGNORECASE)\n remote_r = Regexp.new(remote_search, Regexp::IGNORECASE)\n\n git('branch -a').split(\"\\n\").each do |b|\n b = b.gsub('*', '').strip\n \n return b if local_r.match(b)\n if remote_r.match(b)\n return remote_r.match(b)[1]\n end\n end \n\n raise \"Unable to automatically detect branch. Given = #{branch}\"\n end", "def gitolite_repository_name\n if (parent_path = get_full_parent_path).empty?\n project.identifier\n else\n File.join(parent_path, project.identifier)\n end\n end", "def head_path\n \"#{path}/refs/heads/#{branch}\"\n end", "def remote_branch_revision?(revision = @resource.value(:revision))\n # git < 1.6 returns '#{@resource.value(:remote)}/#{revision}'\n # git 1.6+ returns 'remotes/#{@resource.value(:remote)}/#{revision}'\n branch = at_path { branches.grep %r{(remotes/)?#{@resource.value(:remote)}/#{revision}$} }\n branch unless branch.empty?\n end", "def repo_name\n if self.is_git?\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n elsif self.is_hg?\n return self.cmd_opt.split(\" \")[1].split(\"/\")[-1] if !self.cmd_opt.empty?\n end\n end", "def head_path\n \"#{git_path}/refs/heads/#{branch}\"\n end", "def repository\n # Match on hostname\n settings.repositories.each do |repository|\n next if repository.cname.nil?\n if repository.cname.upcase == request.host.upcase\n return repository\n end\n end\n\n # If no match, use the first repository as the default.\n settings.repositories.first\n end", "def repository\n # Match on hostname\n settings.repositories.each do |repository|\n next if repository.cname.nil?\n if repository.cname.upcase == request.host.upcase\n return repository\n end\n end\n \n # If no match, use the first repository as the default\n settings.repositories.first\n end", "def latest\n if !@resource.value(:revision) && (branch = on_branch?)\n branch\n else\n @resource.value(:revision)\n end\n end", "def gitorious_remote_url\n output = `git remote -v`.scan(/^#{remote}\\s+(.*).git(.*)/)\n if output\n output.first[0]\n end\n end", "def repo_named(full_name)\n pry(Git::Multi.repositories.find { |repo| repo.full_name == full_name })\nend", "def get_repository_name(fedora_obj)\n return (get_coll_field_val(fedora_obj, :repository))\n end", "def full_name repo\n \"#{repo.owner.login}/#{repo.name}\"\n end", "def branch_from_repo_url(repo_url)\n if repo_url =~ /#\\S+[^\\/]/\n @branch = repo_url.split('#')[1]\n else\n @branch = 'master'\n end\n end", "def remote_repository\n url = \"#{configuration[:user]}@#{configuration[:domain]}:\"\n @remote_repository ||= if configuration[:repository].include?(url)\n tmp = configuration[:repository].sub(url, \"file://\")\n if tmp.include?(\"~\")\n tmp.sub!(\"~\", \"/home/#{configuration[:user]}\")\n end\n tmp\n else\n configuration[:repository]\n end\n @remote_repository\n end", "def gitreponame\n g = Git.open(Dir.pwd)\n control_repo = g.config('remote.origin.url').to_s\n control_repo = control_repo.split('/')\n control_repo = control_repo[-1].chomp.split('.')\n control_repo = control_repo[0]\n output = \"\\\"control_repo\\\": \" + '\"' + control_repo + '\",'\n puts output\nend" ]
[ "0.7634662", "0.7627754", "0.7370738", "0.7323804", "0.7300565", "0.7287466", "0.72450316", "0.7174111", "0.71588176", "0.70677924", "0.70431435", "0.7028649", "0.6997016", "0.69865197", "0.6963658", "0.69410735", "0.6904603", "0.68913186", "0.68551034", "0.6850846", "0.68384504", "0.6830796", "0.6811029", "0.68029684", "0.67552185", "0.6747096", "0.6743017", "0.6743017", "0.67280096", "0.6714827", "0.67086375", "0.67086375", "0.67086375", "0.67086375", "0.67086375", "0.67086375", "0.6700835", "0.66955245", "0.66865975", "0.66865975", "0.6684101", "0.6661273", "0.6656617", "0.66478807", "0.66385543", "0.66166896", "0.66143996", "0.6605046", "0.6598375", "0.6573626", "0.6526843", "0.6513808", "0.6513808", "0.6488125", "0.64552474", "0.64054567", "0.64038086", "0.63906175", "0.6368459", "0.6358472", "0.6358005", "0.63001865", "0.62994456", "0.6297815", "0.6291445", "0.6286925", "0.62754536", "0.6273867", "0.6258203", "0.62547535", "0.625285", "0.62527996", "0.6250149", "0.62276644", "0.618205", "0.61751175", "0.6174921", "0.6173384", "0.6162846", "0.61572665", "0.61557853", "0.61556005", "0.61552405", "0.6149748", "0.6132824", "0.60787404", "0.60763484", "0.6075636", "0.6069676", "0.6065561", "0.6058592", "0.6046841", "0.6041128", "0.6032659", "0.6028476", "0.601738", "0.60088897", "0.60052407", "0.5992525" ]
0.7011398
13
Return the name of the current branch
def current_branch git('branch')[/^\* (.*)$/, 1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def branch_name\n $repo.current_branch\n end", "def branch_name\n `git name-rev --name-only HEAD`.strip\n end", "def current_branch\n git.branch.name\n end", "def branchname\n @branchname ||= self.branch.name\n end", "def current_branch\n hg('branch').to_s.strip\n end", "def branch_name\n @branch_name ||= ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.chomp\n end", "def current_branch\n ref = Rugged::Reference.lookup(@git, 'HEAD').resolve\n if not ref.branch?\n raise Error, \"Not currently on a branch.\"\n end\n ref.name.split('/').last\n end", "def currentbranch\n %x{git branch | grep \"*\" | sed \"s;* ;;\"}.squish\n end", "def current_branch\n %x(git branch | grep '*' | cut -d' ' -f2).chomp\nend", "def get_branch_name\r\n\tputs IO.popen('git branch --no-abbrev').read.slice(2..-1)\r\nend", "def current_branch\n `git symbolic-ref --short -q HEAD`.chomp\n end", "def current_branch\n @current_branch ||= `git rev-parse --abbrev-ref HEAD`.strip\n end", "def determine_branch_name(repo)\n name = \"\"\n repo.branches.each do |branch|\n if branch.head?\n name = branch.name\n break\n end\n end\n return name\nend", "def branch\n case @vcs\n when 'github'\n if @data.key? 'ref'\n @data['ref'].sub('refs/heads/', '')\n else\n @data['repository']['default_branch']\n end\n when 'gitlab'\n @data['ref'].sub('refs/heads/', '')\n when 'bitbucket-server'\n @data['changes'][0]['refId'].sub('refs/heads/', '')\n when 'bitbucket'\n return @data['push']['changes'][0]['new']['name'] unless deleted?\n\n @data['push']['changes'][0]['old']['name']\n when 'stash'\n @data['refChanges'][0]['refId'].sub('refs/heads/', '')\n when 'tfs'\n @data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '')\n end\n end", "def current_branch\n `git symbolic-ref --short HEAD`.strip\n end", "def derive_branch_name\n @config[:git][:branch] == 'preview' ? preview_branches.last : @config[:git][:branch]\n end", "def current_branch\n repo.branches.find(&:head?)\n end", "def current_branch\n repo.branches.find(&:head?)\n end", "def branch\n %x[cd #{repo_path};git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}].chomp\n end", "def branch\n `git rev-parse --abbrev-ref HEAD`.strip.presence\n rescue\n nil\n end", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n logger.info \"Deploying branch #{branch}\"\n branch\nend", "def get_current_branch_from_git\n %x{ git rev-parse --abbrev-ref HEAD }.chomp\nend", "def current_branch; end", "def current_branch; end", "def current_branch\n return @branch unless @branch.blank?\n @branch = case @svninfo.url\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else @config_source[\"branch\"]\n end \n @branch || \"unkown\"\n end", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def current_branch\n self.lib.branch_current\n end", "def branch\n return git_fork_config.branch\n end", "def to_label\n branch_name\n end", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_branch\n Dir.chdir @root do\n cmd = \"git rev-parse --abbrev-ref HEAD\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /unknown revision/\n raise Error, \"could not determine branch of repo with no commits\"\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.strip\n end\n end", "def get_branch_name\n puts 'Please provide a name for the branch:'\n branch_name = gets.chomp\n branch_name.gsub(/\\W+/, '_').downcase\n end", "def branch_name\n @branch_name ||= (0...19).map { (65 + rand(26)).chr }.join.downcase\n end", "def branch\n @branch ||= `git branch 2> /dev/null`[/\\*\\s(.+)$/, 1]\n end", "def git_get_current_branch()\n current_branch = `git branch`.split(/\\n/).find{ |l| l.start_with?(\"*\") }\n \n if current_branch\n current_branch =~ /\\*\\s+(.+)/\n $~[1]\n end \nend", "def branch_name\n if name.in?(['Cole Taylor Bank', 'MB Financial Bank, N.A.'])\n sfx = Channel.consumer_direct.identifier.eql?(channel) ? ' CD' : ''\n \"MB #{city}#{sfx}\"\n else\n name\n end\n end", "def human_friendly_branch_information\n return git_fork_config.branch if git_fork_config.branch.to_s.length > 0\n return sha[0...7]\n end", "def get_git_branch()\n return `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e \"s/* \\\\(.*\\\\)/\\\\1/\"`.strip\nend", "def branch\n (@options[:branch] || 'master').to_s\n end", "def branch\n (@options[:branch] || 'master').to_s\n end", "def branch_name\n ENV['TRAVIS_BRANCH'] || ENV['CI_BRANCH']\n end", "def branch(tag=@current_branch)\n get_head(tag)\n end", "def entry_name_from_branch(commit_hash)\n Git::Parser.branch_of_commit(commit_hash).tr('-', ' ')\n end", "def get_branch \n branch = case @os_svninfo['URL']\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /patches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else fail(\"Can't determine which branch I'm operating on\")\n end\n branch\n end", "def source_branch\n git_call('branch').chomp.match(/\\*(.*)/)[0][2..-1]\n end", "def branch\n @env.fetch( :branch, \"N/A\" )\n end", "def getUserBranchInfoObjName\r\n\t\t return \"mfiforce__user_branch_info__c\"\r\n\t\tend", "def current_branch\n return @current_branch if @current_branch\n\n project_root = File.absolute_path(File.join(File.dirname(__FILE__),'..'))\n git = Git.open(project_root)\n\n unless git.status.changed.empty?\n exit_with_message \"There are currently uncommitted changes in your index.\nCommit these changes and push the branch to GitHub so Jenkins can have access to the most recent test code.\"\n end\n \n @current_branch = git.current_branch\n current_sha = git.log.first.sha\n upstream_current_sha = begin\n git.branch(\"origin/#{@current_branch}\").gcommit.sha\n rescue Git::GitExecuteError => e\n exit_with_message \"The current branch #{@current_branch} does not appear to have an upstream branch.\nBe sure you have pushed it to github so that Jenkins can access it when running the tests.\n\n#{e}\n\"\n end\n if current_sha != upstream_current_sha\n exit_with_message \"The current branch commit doesn't match the sha of the upstream branch on the origin remote.\nThis probably means you haven't pushed this branch up to GitHub.\nMake sure you do that so that Jenkins can run the latest test code.\n\nBranch: #{current_branch}\nLocal commit: #{current_sha}\nRemote commit: #{upstream_current_sha}\n\"\n end\n @current_branch\n end", "def next_step_name(impl_context)\n branch = first_applicable_branch(impl_context)\n return if branch.nil?\n\n branch.name\n end", "def branch\n 'refs/heads/master'\nend", "def current_branch\n fail \"The #{self.class} driver does not support the current_branch method!\"\n end", "def branch\n ENV[\"CI_BUILD_REF_NAME\"]\n end", "def proper_name\n @proper_name ||= @raw_name.lstrip.sub(CURRENT_BRANCH_REGEX, '')\n end", "def discover_default_branch\n names = branch_names\n\n return if names.empty?\n\n return names[0] if names.length == 1\n\n if rugged_head\n extracted_name = Ref.extract_branch_name(rugged_head.name)\n\n return extracted_name if names.include?(extracted_name)\n end\n\n if names.include?('master')\n 'master'\n else\n names[0]\n end\n end", "def discover_default_branch\n now_head = Ref.extract_branch_name(rugged_head.name)\n return now_head if now_head.to_s != \"\"\n\n names = local_branch_names\n if names.length == 0\n nil\n elsif names.include?(\"master\")\n \"master\"\n else\n names.first\n end\n end", "def branch_name_value(branch_index=1)\n if @match_data.nil? || @match_data[branch_index].nil?\n branch_name = value_of_or_default(params[:branch_field], 'branch')\n else\n branch_name = @match_data[branch_index]\n end\n end", "def branch_remote_name(branch_name)\n `git config branch.#{branch_name}.remote`.strip\n end", "def git_name(directory)\n `cd #{directory} && git log -n 1 | head -1`.split.last\nend", "def branch(name, options = {})\n get_path(\n path_to_branch(name),\n options,\n get_parser(:collection, Tinybucket::Model::Commit)\n )\n end", "def get_branch(status = `git status`)\n branch = nil\n if match = Regexp.new(\"^# On branch (.*)\").match(status)\n branch = match[1]\n end\nend", "def branch_to\n label\n end", "def branch\n Branch[comparable.segments.first(2).join('.')]\n end", "def to_s\n branch.to_s\n end", "def get_branch_names(repo)\n repo.heads.collect(&:name)\n end", "def branch \n extra[\"branch\"] \n end", "def getBranchLocationObjName\r\n\t\t\treturn \"mfiforce__Branch_Location__c\"\r\n\t\tend", "def local_branch_information\n #This is sensitive to checkouts of branches specified with wrong case\n\n listing = capture_process_output(\"#{LOCAL_BRANCH_LISTING_COMMAND}\")[1]\n\n raise(NotOnGitRepositoryError, listing.chomp) if listing =~ /Not a git repository/i\n if listing =~ /\\(no branch\\)/\n raise InvalidBranchError, [\"Couldn't identify the current local branch. The branch listing was:\",\n LOCAL_BRANCH_LISTING_COMMAND.red, listing].join(\"\\n\")\n end\n\n current_branch = nil\n branches = listing.split(\"\\n\").map do |line|\n current = line.include? '*'\n clean_line = line.gsub('*','').strip\n current_branch = clean_line if current\n clean_line\n end\n\n return current_branch, branches\n end", "def current\n branch = list.find{|b| b.match /\\*/ }\n branch.gsub(/\\* /, '')\n end", "def check_current_branch_task\n raise \"Currently not on #{local_branch} branch!\" unless `#{git} branch`.split(\"\\n\").detect { |b| /^\\* / =~ b } == \"* #{local_branch}\"\n end", "def display_branch\n colored_active_branch = build_magenta_text_with_condition(@name, @is_active_branch)\n colored_issue_state = build_colored_issue_state\n colored_issue_title = build_magenta_text_with_condition(@issue_title, @is_active_branch)\n\n build_branch_view(colored_issue_state, colored_active_branch, colored_issue_title)\n end", "def head\n git.get_head(branch)\n end", "def head\n git.get_head(branch)\n end", "def branch\n if request.args.first == \"list\"\n request.args[1]\n else\n request.args.first\n end\n end", "def branch(environment)\n env_path = File.join(@path, \"config/deploy/#{environment}.rb\")\n content = File.read(env_path)\n content.match(REGEX_BRANCH)[1]\n end", "def last_commit(branch_name)\n @rugged_repository.branches[branch_name].target\n end", "def branch(group:nil)\n case group\n when :remote\n flag = \"-r\"\n when :all\n flag = \"-a\"\n when nil, :local\n flag = \"\"\n end\n\n `git branch #{flag}`.lines.map do |line|\n fields = line.split\n\n if fields.first['*']\n fields[1].strip\n else\n fields.first.strip\n end\n end\nend", "def prompt_git_branch\n if !is_git?\n return \"\"\n end\n stat = `git status`\n \"[#{stat.split(\"\\n\")[0].split(\" \")[-1]}]\".yellow\nend", "def initial_ref\n %x[git rev-parse #{branch}].chomp\nend", "def git_name\n (!GitHosting.multi_repos? || identifier.blank?) ? project.identifier : identifier\n end", "def head_path\n \"#{git_path}/refs/heads/#{branch}\"\n end", "def patch_branch\n num = 1\n branch_name = form_data[\"title\"].parameterize\n return branch_name unless branch_exists?(branch_name)\n branch = \"#{branch_name}-#{num}\"\n while branch_exists?(branch) do\n num = num + 1\n branch = \"#{branch_name}-#{num}\"\n end\n branch\n end", "def getProjectName()\n\tcurl = 'git config --local remote.origin.url|sed -n \"s#.*/\\([^.]*\\)\\.git#\\1#p\"'\n\tresult = `#{curl}`\n\treturn result.strip()\nend", "def ls_branches\n working_branches = get_branches\n if working_branches.empty?\n $stdout.puts \"No branches\"\n exit\n end\n working_branches.map.with_index { |branch, idx| \"#{idx}. #{branch}\" }\nend", "def branch(name)\n gitrepo.create_branch(name)\n end", "def normalize_branch(name)\n\n # verify supplied arguments\n raise ArgumentError,\n 'name must be specified' unless name\n\n raise TypeError,\n 'name must be of type String' unless name.is_a?(String)\n\n raise ArgumentError,\n 'name string must not be empty' if name.empty?\n\n name.strip!\n if %w{master trunk default}.include?(name)\n normalize(name)\n elsif (matches = /^v?(\\d+)(\\.(?:\\d+|[xX*]))?(\\.(?:\\d+|[xX*]))?(\\.(?:\\d+|[xX*]))?$/i.match(name))\n version = ''\n matches.captures.each { |match| version << (match != nil ? match.tr('*', 'x').tr('X', 'x') : '.x') }\n \"#{version.gsub('x', '9999999')}-dev\"\n else\n \"dev-#{name}\"\n end\n end", "def current\n R10K::Git::Head.new('HEAD', self)\n end", "def default_branch\n config.deploy_branch\n end", "def name\n\n tree[0]\n end", "def git_repo_name\n path = File.expand_path(File.dirname(__FILE__))\n # the path looks like /repos/bender.git/hooks\n path.split(%r{/})[-2]\nend", "def head_path\n \"#{path}/refs/heads/#{branch}\"\n end", "def branch_from_git_or_continuous_build\n git_branch = branch_from_git\n ci_branch = ContinousBuild.infos[:branch]\n branch = 'master'\n if ci_branch.to_s.strip.size > 0\n branch = ci_branch\n elsif git_branch.to_s.strip.size > 0 && !git_branch.to_s.strip.start_with?('(')\n branch = git_branch\n end\n cleanup_branch(branch)\n end", "def determine_branch_or_tag_name(repo)\n name = \"\"\n type = :none\n\n # first check if repo is in detached HEAD state\n if repo.head_detached?\n # check if current commit has a tag\n repo.tags.each do |tag|\n if tag.target.oid == repo.head.target_id\n name = tag.name\n type = :tag\n break\n end\n end\n\n # check if we got a tag name, otherwise it's a wild commit\n if type == :none\n name = repo.head.target_id[0..7]\n type = :commit\n end\n else\n # HEAD is not detached, so we are in a branch\n name = $branch_name\n type = :branch\n end\n\n return { name: name, type: type }\nend", "def in_branch(name, &block)\n previous_branch = current_branch\n\n if name != previous_branch\n git \"branch\", name unless branches.include?(name)\n git \"checkout\", name\n end\n \n yield\n rescue StandardError\n STDERR.puts $!\n raise\n ensure\n unless current_branch == previous_branch\n git \"reset\", \"--hard\"\n git \"checkout\", previous_branch\n end\n end" ]
[ "0.90367657", "0.8721565", "0.86619645", "0.86010396", "0.8582537", "0.8473796", "0.8352805", "0.83074737", "0.8234233", "0.8144074", "0.81439143", "0.804588", "0.8009763", "0.79761547", "0.79706085", "0.7922965", "0.7849014", "0.7828018", "0.78195804", "0.775794", "0.7756447", "0.77169126", "0.7711954", "0.7711954", "0.7697456", "0.7693109", "0.7693109", "0.7686933", "0.7678127", "0.75988495", "0.7593861", "0.7593861", "0.7593861", "0.7593861", "0.7593861", "0.7593861", "0.7580093", "0.75111425", "0.7457527", "0.7421848", "0.74121034", "0.7359329", "0.7330607", "0.7250572", "0.72352356", "0.72352356", "0.7083944", "0.70777756", "0.7016563", "0.6989523", "0.6955024", "0.693519", "0.68612206", "0.6848427", "0.6815176", "0.67998827", "0.6790295", "0.67769927", "0.6753022", "0.67409945", "0.6725578", "0.67183095", "0.671784", "0.67135024", "0.6694294", "0.6610168", "0.65890807", "0.65868723", "0.6586046", "0.6564218", "0.6561059", "0.6551549", "0.65505606", "0.6531304", "0.6516696", "0.6468909", "0.6447972", "0.6447972", "0.6445151", "0.64351004", "0.64315754", "0.6385571", "0.63823944", "0.6364517", "0.6350071", "0.6345018", "0.63051325", "0.63005346", "0.62681276", "0.62603986", "0.6259054", "0.62469846", "0.62038887", "0.61586106", "0.61476356", "0.61407673", "0.61214685", "0.6121341", "0.60986394" ]
0.80956787
12
:callseq: git(args) Executes a Git command and returns the output. Throws exception if the exit status is not zero. For example: git 'commit' git 'remote', 'show', 'origin'
def p4(*args) port = ENV['P4PORT'] user = ENV['P4USER'] password = ENV['P4PASSWD'] client = ENV['P4CLIENT'] fail 'perforce release missing required P4PORT environment' unless port fail 'perforce release missing required P4USER environment' unless user fail 'perforce release missing required P4PASSWORD environment' unless password fail 'perforce release missing required P4CLIENT environment' unless client cmd = "p4 -p #{port} -u #{user} -P #{password} -c #{client} #{args.map { |arg| arg.inspect }.join(' ')}" output = `#{cmd}` fail "P4 command \"#{cmd}\" failed with status #{$?.exitstatus}\n#{output}" unless $?.exitstatus == 0 return output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def git(*args)\n cmd = \"git #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}\"\n output = `#{cmd}`\n fail \"GIT command \\\"#{cmd}\\\" failed with status #{$?.exitstatus}\\n#{output}\" unless $?.exitstatus == 0\n return output\n end", "def git(*args)\n cmd = \"git #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}\"\n output = `#{cmd}`\n fail \"GIT command \\\"#{cmd}\\\" failed with status #{$?.exitstatus}\\n#{output}\" unless $?.exitstatus == 0\n return output\n end", "def git(*args)\n cmd(*['git'] + args)\n end", "def git(*args)\n cmd(*['git'] + args)\n end", "def git(*args, &block)\n options = args.extract_options!\n system_args = ['--git-dir', root_url, '-c', 'core.quotepath=false']\n\n args = system_args + Array.wrap(args)\n args = args.map { |arg| self.class.shell_quote(arg.to_s) }.join(' ')\n cmd = [self.class.quoted_git_command, args].join(' ')\n\n ret = self.class.shell_out(cmd, options, &block)\n\n if $? && $?.exitstatus != 0\n raise CommandFailed, \"git exited with non-zero status: #{$?.exitstatus}\"\n end\n ret\n end", "def git(*args)\n IO.popen(\"-\", \"r\") do |io|\n if io\n yield io\n else\n #STDERR.puts [GIT_BIN, \"--git-dir\", @git_dir, *args].inspect\n exec(GIT_BIN, \"--git-dir\", @git_dir, *args)\n end\n end\n end", "def git(*args)\n Dir.chdir(@dir) do\n git = Process.spawn('git', *args)\n Process.wait(git)\n raise \"git #{args.join(' ')} (in #{@dir}) failed: #{$?.exitstatus}\" if $?.exitstatus != 0\n end\n end", "def git(*args)\n system \"git \" + args.join(\" \")\nend", "def git(*args)\n cd { run(*['git'] + args) }\n end", "def git_cmd(*args, &block)\n system_args = ['--git-dir', root_url, '-c', 'core.quotepath=false']\n args = (system_args + Array(args)).flatten\n args = args.map { |arg| self.class.shell_quote(arg.to_s) }.join(' ')\n cmd = [self.class.quoted_git_command, args].join(' ')\n\n exit_status, errors = self.class.shell_out(cmd, &block)\n\n raise Redmine::Scm::Adapters::CommandFailed, errors unless exit_status == 0\n end", "def execute_git(repo_dir, *args)\n system('git', '-C', repo_dir, *args)\n end", "def git command, *args\n run 'git', command.to_s, *args\nend", "def git_exec(command, *args)\n Dir.chdir(@grit_repo.working_dir) do\n %x{git #{command} #{args.join(' ')}}\n end\n end", "def git command\n output = `git #{command} 2>&1`.chomp\n unless $?.success?\n raise RuntimeError, output\n end\n output\n end", "def git_call(command, verbose = debug_mode, enforce_success = false)\n if verbose\n puts\n puts \" git #{command}\"\n puts\n end\n output = `git #{command}`\n puts output if verbose and not output.empty?\n # If we need sth. to succeed, but it doesn't, then stop right there.\n if enforce_success and not last_command_successful?\n puts output unless output.empty?\n raise UnprocessableState\n end\n output\n end", "def exec_cmd(cmd, flags, args)\n # always add the git dir to the cmd to ensure that git is executed\n # within the expected repo\n gd_flag = \"--git-dir=\\\"#{@git_dir}\\\"\"\n wt_flag = \"--work-tree=\\\"#{@repo_root}\\\"\"\n flag_str = flags.join(\" \")\n git_cmd = \"git #{gd_flag} #{wt_flag} #{cmd} #{flag_str} #{args}\"\n Giblog.logger.debug { \"running: #{git_cmd}\" }\n Open3.capture3(git_cmd.to_s)\n end", "def git(command, options = {})\n error = options[:error] || true\n unless which(\"git\") || which(\"git.exe\") || which(\"git.bat\")\n raise GitNotInstalled\n end\n\n response = Mixlib::ShellOut.new(%{git #{command}}, options)\n response.run_command\n\n if error && response.error?\n raise GitError.new \"#{command} #{cache_path}: #{response.stderr}\"\n end\n\n response.stdout.strip\n end", "def command( cmd )\r\n ## note: for now use Kernel#system for calling external git command\r\n ##\r\n\r\n cmdline = \"git #{cmd}\"\r\n puts \" trying >#{cmdline}< in (#{Dir.pwd})...\"\r\n \r\n result = nil\r\n result = system( cmdline )\r\n\r\n pp result\r\n\r\n # note: Kernel#system returns\r\n # - true if the command gives zero exit status\r\n # - false for non zero exit status\r\n # - nil if command execution fails\r\n # An error status is available in $?.\r\n\r\n if result.nil?\r\n puts \"*** error was #{$?}\"\r\n fail \"[Kernel.system] command execution failed >#{cmdline}< - #{$?}\" \r\n elsif result ## true => zero exit code (OK)\r\n puts 'OK' ## zero exit; assume OK\r\n true ## assume ok\r\n else ## false => non-zero exit code (ERR/NOK)\r\n puts \"*** error: non-zero exit - #{$?} !!\" ## non-zero exit (e.g. 1,2,3,etc.); assume error\r\n \r\n ## log error for now ???\r\n # File.open( './errors.log', 'a' ) do |f|\r\n # f.write \"#{Time.now} -- repo #{@owner}/#{@name} - command execution failed - non-zero exit\\n\"\r\n # end\r\n raise GitError.new( \"command execution failed >#{cmdline}< - non-zero exit (#{$?})\" )\r\n end\r\n end", "def git(command)\n there { `git #{command} 2>&1`.strip }\n end", "def git_command(cmd, opt_str, dir)\n run_in_shell(\"git #{cmd} #{opt_str}\", dir)\n end", "def native(cmd, opts = [], chdir = true, redirect = '', &block)\n validate\n\n ENV['GIT_DIR'] = @git_dir\n ENV['GIT_INDEX_FILE'] = @git_index_file\n ENV['GIT_WORK_TREE'] = @git_work_dir\n path = @git_work_dir || @git_dir || @path\n\n opts = [opts].flatten.map {|s| escape(s) }.join(' ')\n git_cmd = \"git #{cmd} #{opts} #{redirect} 2>&1\"\n\n out = nil\n if chdir && (Dir.getwd != path)\n Dir.chdir(path) { out = run_command(git_cmd, &block) }\n else\n out = run_command(git_cmd, &block)\n end\n\n if @logger\n @logger.info(git_cmd)\n @logger.debug(out)\n end\n\n if $?.exitstatus > 0\n if $?.exitstatus == 1 && out == ''\n return ''\n end\n raise Git::CommandFailed.new(git_cmd, $?.exitstatus, out.to_s)\n end\n out\n end", "def git(command={})\n if command.is_a?(Symbol)\n run \"git #{command}\"\n else\n command.each do |command, options|\n run \"git #{command} #{options}\"\n end\n end\n end", "def run\n # Pure git-feats command\n case @args[0]\n when \"feats\"\n run_feats_cmd\n\n # Overriden git command\n when \"version\" || \"--version\"\n version\n\n # Pure git command\n else\n exec_args\n end\n end", "def git(path, cmd, log=true)\n $stdout.puts(\"#{path.sub(ROOT_PATH, '')}: git #{cmd}\") if log\n git_path = path / '.git'\n git_index = git_path / 'index'\n\n # The env can become polluted; breaking git. This will avoid that.\n %x[GIT_DIR=#{git_path}; GIT_WORK_TREE=#{path}; GIT_INDEX_FILE=#{git_index}; git #{cmd}]\nend", "def git(command = {})\r\n in_root do\r\n if command.is_a?(Symbol)\r\n log 'running', \"git #{command}\"\r\n Git.run(command.to_s)\r\n else\r\n command.each do |command, options|\r\n log 'running', \"git #{command} #{options}\"\r\n Git.run(\"#{command} #{options}\")\r\n end\r\n end\r\n end\r\n end", "def command(cmd, opts = [], env_vars = [])\n # TODO:global config, pointing at correct working path and git dir\n global_opts = []\n global_opts << \"--git-dir=#{@git_dir}\" if @git_dir\n global_opts << \"--work-tree=#{@git_work_dir}\" if @git_work_dir\n\n global_opts = global_opts.flatten.join(' ') # TODO: should be escaped?\n\n opts = [opts].flatten.join(' ') # TODO: should be escaped?\n env_vars = [env_vars].flatten.join(' ') # ENV variables\n\n git_cmd = [env_vars, 'git', global_opts, 'annex', cmd, opts].join(' ')\n output, status = Open3.capture2e(git_cmd)\n exitstatus = status.exitstatus\n\n # Potentially might have to revisit this to not raise errors when status\n # code is 1 and there is no output. See `Git::Lib#command` implementation.\n if exitstatus != 0\n raise ExtendedGit::Error.new(\"#{git_cmd}:#{output}\".gsub(env_vars, '').strip) # Removing env variables from error message.\n end\n\n output.chomp\n end", "def test_git!\n result = `which git`\n if $?.exitstatus != 0\n raise IOError, \"Can't find git\"\n end\n end", "def git_fetch\n Command.new(\"git\", \"fetch\", \"--tags\", \"-f\").run!.raise!\nend", "def run\n logger.info(\"Running command : git-shell -c #{@cmd_cmd} '#{@real_path}'\")\n if system(Settings.git.shell, \"-c\", \"#{@cmd_cmd} '#{@real_path}'\")\n logger.info(\"\\t\\tOK\")\n else\n logger.info(\"\\t\\tKO\")\n end\n end", "def git_fetch\n Command.new(\"git\", \"fetch\", \"--tags\").run!.raise!\nend", "def exec_git(*args)\n exec_args = { failonfail: true, combine: true }\n if @resource.value(:user) && @resource.value(:user) != Facter['id'].value\n env = Etc.getpwnam(@resource.value(:user))\n exec_args[:custom_environment] = { 'HOME' => env['dir'] }\n exec_args[:uid] = @resource.value(:user)\n end\n Puppet::Util::Execution.execute([:git, args], **exec_args)\n end", "def git(commands={})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands={})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands={})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands = {})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def git(commands = {})\n if commands.is_a?(Symbol)\n run \"git #{commands}\"\n else\n commands.each do |cmd, options|\n run \"git #{cmd} #{options}\"\n end\n end\n end", "def command_git_cmd(path, git_cmd, chdir, block)\n out = nil\n if chdir and (Dir.getwd != path)\n Dir.chdir(path) { out = run_command(git_cmd, &block) }\n else\n out = run_command(git_cmd, &block)\n end\n return out\n end", "def get_output(cmd)\n log \"Running #{cmd}\"\n # git commands output fatal errors to stderr,\n # so capture that.\n # (ref http://blog.honeybadger.io/capturing-stdout-stderr-from-shell-commands-via-ruby/)\n stdout, stderr, status = nil, nil, nil\n Dir.chdir(@repo_dir) do |d|\n stdout, stderr, status = Open3.capture3(cmd)\n end\n\n if (stderr.strip != \"\" and stderr =~ /fatal/m) then\n msg = <<HERE\nstderr fatal error:\n#{stderr}\nRaised during git command:\n#{cmd}\nHERE\n raise msg\n end\n\n # Some git commit subject lines contained control characters (\"^M\")\n # which broke parsing. I tried using the methods given in\n # https://www.ruby-forum.com/topic/172061 to remove those bad chars,\n # but it didn't work. Below is adapted from\n # https://rosettacode.org/wiki/Strip_control_codes_and_extended_characters_from_a_string#Ruby\n clean_stdout = stdout.chars.each_with_object(\"\") do |char, str|\n displayable = (char.ascii_only? and char.ord.between?(32,126))\n str << char if (displayable || char == \"\\n\" || char == \"\\t\")\n end\n \n return clean_stdout.\n split(\"\\n\").\n map { |s| s.strip }.\n select { |s| s != '' }\n end", "def command(cmd, opts = [], chdir = true, redirect = '', &block)\n ENV['GIT_INDEX_FILE'] = File.join(workdir, '.git', 'index')\n ENV['GIT_DIR'] = File.join(workdir, '.git')\n ENV['GIT_WORK_TREE'] = workdir\n path = workdir\n\n git_cmd = create_git_command(cmd, opts, redirect)\n\n out = command_git_cmd(path, git_cmd, chdir, block)\n\n if logger\n logger.debug(git_cmd)\n logger.debug(out)\n end\n\n handle_exitstatus($?, git_cmd, out)\n end", "def run\n usage \"[0.1.2 - version, 100/10/1 - bump major/minor/patch, .build - add build] Commit message goes here\" if @argv.empty?\n\n # First Arg may indicate version command if it matches pattern\n version_command = @argv[0] =~ COMMAND_PATTERN ? @argv.shift : nil\n\n # All the other args lumped into message, or default message\n if @argv.empty?\n commit_message = \"Commit #{Time.now.to_s[0..-6]}\"\n history_message = nil\n else\n commit_message = history_message = @argv.join(' ')\n end\n\n # Updating version only if version command set\n if version_command\n puts \"Updating version with #{version_command}\"\n if history_message\n system %Q{rake \"version[#{version_command},#{history_message}]\"}\n else\n system %Q{rake version[#{version_command}]}\n end\n end\n\n puts \"Adding all the changes\"\n system \"git add --all\"\n\n puts \"Committing everything with message: #{commit_message}\"\n system %Q[git commit -a -m \"#{commit_message}\" --author arvicco]\n\n current_branch = `git branch`.strip\n puts \"Pushing to (default) remote for branch: #{current_branch}\"\n system \"git push\"\n end", "def git_on(host, git_sub_command, git_repo_path, opts = {})\n git_command = \"git --git-dir=#{git_repo_path}/.git --work-tree=#{git_repo_path} #{git_sub_command}\"\n\n on(host, git_command, opts)\nend", "def git(args, &block)\n Sprout::GitTask.define_task(args, &block)\nend", "def gitworld(command)\n home = ENV[\"PWD\"]\n paths = [ \\\n\t\"vendor/bundles/Cordova/Bundle/FormModelBundle\",\t\\\n\t\"vendor/phpspec\",\t\\\n\t\"vendor/phpspec-symfony2\",\t\\\n\t\"vendor/PHPAutotest\",\t\\\n ]\n paths.each do |path|\n fullpath = \"#{home}/#{path}\"\n if File.directory? fullpath\n Dir.chdir(\"#{fullpath}\")\n popen3(\"git #{command}\") do |stdin, stdout, stderr, wait_thr|\n output = stdout.read\n error = stderr.read\n printf \"============================[ %30s ]=======\\n%s\", path, output\n puts \"\" if output.length > 0\n print stderr.read\n puts \"\" if error.length > 0\n end\n end\n end\nend", "def create_git_command(cmd, opts, redirect)\n opts = [opts].flatten.map { |s| escape(s) }.join(' ')\n return \"git #{cmd} #{opts} #{redirect} 2>&1\"\n end", "def push(arg='')\n `git push #{arg} 2>&1`\n end", "def exec_git_cmd( cmd, actor=nil )\n old_aname = ENV['GIT_AUTHOR_NAME']\n old_aemail = ENV['GIT_AUTHOR_EMAIL']\n old_cname = ENV['GIT_COMMITTER_NAME']\n old_cemail = ENV['GIT_COMMITTER_EMAIL']\n old_pager = ENV['GIT_PAGER']\n\n if actor\n ENV['GIT_AUTHOR_NAME'] = actor.name\n ENV['GIT_AUTHOR_EMAIL'] = actor.email\n ENV['GIT_COMMITTER_NAME'] = actor.name\n ENV['GIT_COMMITTER_EMAIL'] = actor.email\n end\n ENV['GIT_PAGER'] = ''\n\n # Note: we cannot use Grit#raw_git_call as it requires an index file\n rv = exec_in_git_dir do \n `#{cmd}`\n raise CommandError, rv if $? != 0\n end\n\n ENV['GIT_AUTHOR_NAME'] = old_aname\n ENV['GIT_AUTHOR_EMAIL'] = old_aemail\n ENV['GIT_COMMITTER_NAME'] = old_cname\n ENV['GIT_COMMITTER_EMAIL'] = old_cemail\n ENV['GIT_PAGER'] = old_pager\n\n rv\n end", "def cmd(*args)\n command = Shellwords.join(args)\n out = `#{command}`.strip\n fail!(puts \"command failed: #{command}\", $?.exitstatus) unless $?.success?\n out\nend", "def execute\n cmd = FetchGitCommits.new(@from, @to, @repo, @author)\n cmd.execute\n @commits = cmd.commits\n nil end", "def check_git_repo\n # check local dir\n\n # use Open3 in order to get stderr output from child process\n # `` syntax only returns stdout output which is not enough\n\n # since command are all executed in newly spawned child processes so there's no need to record old dir path\n stdout, stderr = Open3.popen3(\"cd #{@local_path} && git status\")[1..2]\n\n local_branch_name = stdout.gets.to_s.match(/^On branch ([^\\s]+)/)[1]\n unless local_branch_name\n raise GitRepoException, \"local path #{@local_path} is not a git repository\"\n end\n\n # check remote dir\n valid = true\n remote_branch_name = ''\n @ssh.exec!(\"cd #{@remote_path} && git status\") do |ch, stream, data|\n case stream\n when :stdout\n valid = false unless (remote_branch_name = data.match(/^On branch ([^\\s]+)/)[1])\n when :stderr\n valid = false unless (data.nil? or data == '')\n end\n end\n unless valid\n raise GitRepoException, \"remote path #{@remote_path} is not a git repository\"\n end\n\n # check match\n if local_branch_name != remote_branch_name\n raise GitRepoException, \"local branch(#{local_branch_name}) and remote branch(#{remote_branch_name}) don't match\"\n end\n end", "def run_command\n # this should probably be run without bundle exec, I guess\n 'git status --porcelain'\n end", "def call\n if git_remote_command =~ /git@github.com:(.+).git/\n \"https://github.com/#{Regexp.last_match(1)}\"\n else\n git_remote_command.sub('.git', '').chomp\n end\n end", "def git_changes?\n Dir.chdir(@dir) do\n git = Process.spawn('git', 'diff-index', '--cached', '--quiet', 'HEAD')\n Process.wait(git)\n raise \"git diff-index failed weirdly: #{$?.exitstatus}\" if $?.exitstatus > 1\n $?.exitstatus == 1\n end\n end", "def info args\n # Find base of git directory\n until Dir.glob('.git').length > 0 do\n if '/'==Dir.pwd\n @out.puts \"can't find .git directory this or any parent folder!\"\n return\n end\n Dir.chdir('..')\n end\n\n @out.puts \"(in \"+Dir.pwd+')'\n\n # Show various information about this git directory\n @out.puts \"== Remote URL: \"\n @out.puts `git remote -v`\n\n @out.puts \"== Remote Branches: \"\n @out.puts `git branch -r`\n\n @out.puts \"== Local Branches:\"\n @out.puts `git branch`\n @out.puts \"\\n\"\n\n @out.puts \"== Configuration (.git/config)\"\n File.open('.git/config'){|fh| @out.puts fh.read }\n @out.puts \"\\n\"\n\n @out.puts \"== Most Recent Commit\"\n @out.puts `git log --max-count=1`\n @out.puts \"\\n\"\n\n @out.puts \"Type 'git log' for more commits, or 'git show' for full commit details.\"\n\n end", "def git_checkout_and_push_u(name, opts={})\n cmd = \"git checkout -b #{name}\"\n puts cmd\n out = `#{cmd}`\n if $? == 0\n cmd = \"git push -u origin #{name}\"\n puts cmd\n out = `#{cmd}`\n if $? == 0\n # nothing\n else\n $stderr.puts \"ERROR: failed to push '#{name}' to origin\"\n end\n else\n $stderr.puts \"ERROR: failed to checkout '#{name}'\"\n end\nend", "def git\n\tend", "def execute(initial_args, options = {})\n if initial_args.include?('|')\n raise Overcommit::Exceptions::InvalidCommandArgs,\n 'Cannot pipe commands with the `execute` helper'\n end\n\n result =\n if (splittable_args = options.fetch(:args) { [] }).any?\n debug(initial_args.join(' ') + \" ... (#{splittable_args.length} splittable args)\")\n Overcommit::CommandSplitter.execute(initial_args, options)\n else\n debug(initial_args.join(' '))\n Overcommit::Subprocess.spawn(initial_args, options)\n end\n\n debug(\"EXIT STATUS: #{result.status}\")\n debug(\"STDOUT: #{result.stdout.inspect}\")\n debug(\"STDERR: #{result.stderr.inspect}\")\n\n result\n end", "def cmd\n c = [\"git checkout #{other_branch}\"]\n c << argument_string(unknown_options) unless unknown_options.empty?\n c.join(\"\\n\")\n end", "def run_shell_cmd(args)\n system(*args)\n raise \"command exited with a nonzero status code #{$?.exitstatus} (command: #{args.join(' ')})\" if !$?.success?\n end", "def is_git?\n `git status 2> /dev/null` != \"\"\nend", "def git_wrapper (dpath = Dir.pwd)\n\n\tbegin\n\t\tRugged::Repository.new(dpath)\n\n\trescue Rugged::RepositoryError => err\n\n\t\tputs \"could not find repository at #{dpath}\"\n\t\texit 1\n\n\trescue Exception => err\n\n\t\tputs \"an error occurred while opening .git repository for #{dpath}\"\n\t\tputs err.message\n\t\texit 1\n\n\tend\n\nend", "def GitSimple(*args) # rubocop:disable Naming/MethodName\n GitSimple.new(*args)\nend", "def sh_exec(*args)\n unless args.last.kind_of? Hash\n args << {}\n end\n\n opts = args.last\n opts[:err] = [:child, :out] # write stdout and stderr to pipe, so we can read it later\n\n out = IO.popen(args, 'r') {|io| io.read}\n success = $? == 0\n\n return success, out\n end", "def exec(command)\n #logger.debug { \"Github: Executing command: '#{command}'\" }\n #p \"Github: Executing command: '#{command}'\"\n \n # Get a path to a temp file\n #logfile = Tempfile.new('github__exec')\n #logfile.close\n \n #success = system(\"#{command} > #{logfile.path} 2>&1\")\n #output_from_command = File.readlines(logfile.path)\n #output_from_command = %x[command]\n shell = Shell.new(command)\n shell.run\n success = (shell.exitstatus == 0)\n output_from_command = shell.output\n if success\n #logger.debug { \"Github: Command output: #{output_from_command.inspect}\"}\n #p \"Github: Command output: #{output_from_command.inspect}\"\n return output_from_command\n else\n #logger.error { \"Github: Command '#{command}' didn't exit properly. Full output: #{output_from_command.inspect}\"}\n p \"Github: Command failed '#{command}' didn't exit properly. Full output: #{output_from_command.inspect}\"\n end\n \n #ensure\n #logfile.unlink\n end", "def git_clone(repo, destination)\n result = `git clone -q #{repo} #{destination}`\n if $?.exitstatus != 0\n error \"Failed to clone #{repo} into #{destination} (Exit status: #{$?.exitstatus})!\"\n error \"Result: #{result}\" unless result.empty?\n exit $?.exitstatus\n end\n end", "def git_get(dir=nil)\n if dir.nil?\n directory = Dir.pwd\n else\n directory = dir\n end\n Dir.chdir(directory) do \n system('git clone https://github.com/offensive-security/exploit-database.git ~/src/exploit-db-git')\n end\nend", "def git_tag tag\n system \"git tag #{tag}\"\n raise \"tag failed\" unless $?\nend", "def rev_parse(*args)\n return args if args.empty?\n \n sandbox do |git,w,i|\n shas = git.run('', :rev_parse, '', {}, args).split(\"\\n\")\n \n # Grit::Git#run only makes stdout available, not stderr, and so this\n # wonky check relies on the fact that git rev-parse will print the\n # unresolved ref to stdout and quit if it can't succeed. That means\n # the last printout will not look like a sha in the event of an error.\n unless shas.last.to_s =~ SHA\n raise \"could not resolve to a sha: #{shas.last}\"\n end\n \n shas\n end\n end", "def run(args)\n parse_command_line(args)\n return 0 if @options.help_requested\n\n verify_gitlab_running\n\n # This logic block is fragile, but the best we can do due to limitations\n # of the gitlab-rails console. Here are details for maintainers:\n #\n # - This logic was developed with gitlab-ce-13.7.1, but verified to also work\n # with gitlab-ce-12.3.0.\n # - The gitlab-rails console uses IRB from the gitlab-provided Ruby.\n # - IRB will not exit with a bad error code when any command fails. This\n # means we have to scrape the command output to determine if the\n # commands succeed.\n # - When the input is piped to the gitlab-rails console, IRB determines\n # that the input is not from a TTY, and\n # * does not emit any prompts, which could have been customized via IRB\n # configuration\n # * does not prepend successful command results with '\\t=> ' or a\n # configured string\n # * does not use ANSI cursor-moving command sequences that provide a more\n # IDE-like experience; a feature introduced with Ruby 2.7.0.\n #\n # The suppression of the prompt and result prefix prevents this script from\n # failing due to user IRB configuration. The suppression of the ANSI\n # cursor-moving behavior allows easier support of different versions of\n # GitLab. (See NOTE below).\n # - Rails allows customization of the application that provides the console,\n # so it is possible (not necessarily likely) that the console could change\n # to a non-IRB implementation in a future GitLab release.\n #\n # NOTE: Previous versions of this script used expect and parsed the\n # output based on the command prompt and results prefix for each individual\n # command in gitlab_ruby_commands below. This is no longer viable because of\n # the ANSI cursor-moving character sequences that Ruby 2.7's IRB uses when a\n # user enters a command. The cursor-moving sequences are used every time\n # a user enters a character. For example, the command prompt is modified to\n # contain a '?' character, when the input does not yet pass Ruby syntax\n # validation. Even though the final characters displayed on the console\n # look largely the same as what was displayed in earlier Ruby IRB versions,\n # this behavior completely changes the characters sequences sent to the\n # console and gathered by expect.\n\n debug(\"Loading gitlab-rails console and executing change (this can take some time)...\\n\")\n\n # Password will be wrapped in double quotes within a single-quoted bash string.\n safe_password = @options.password.gsub(/\"/,'\\\\\"')\n gitlab_ruby_commands = [\n 'user = User.where(username: \"root\")[0]',\n \"user.password = \\\"#{safe_password}\\\"\",\n \"user.password_confirmation = \\\"#{safe_password}\\\"\",\n 'user.save!'\n ].join('; ')\n\n command = \"echo '#{gitlab_ruby_commands}' | #{GITLAB_CONSOLE_COMMAND}\"\n debug(\"Executing: #{command}\\n\")\n\n begin\n Timeout::timeout(@options.load_timeout) do\n console_out = `#{command} 2>&1`\n debug(console_out)\n\n # The last Ruby command executed in the Rails console (`user.save!`)\n # returns true when the valid User record has been saved. This is true\n # even if you are overwriting the User record with the same information.\n # Any failures in that command or a prior command in the semi-colon\n # separated command list will spew out error messages instead.\n\n lines = console_out.split(\"\\n\").delete_if { |line| line.empty? }\n\n if lines.last !~ /^true$/\n raise('Password set operation failed.')\n end\n end\n rescue Timeout::Error\n err_msg = \"Password set operation timed out after #{@options.load_timeout} seconds.\"\n raise(err_msg)\n end\n\n puts 'GitLab root password set'\n\n debug(\"Writing marker file #{MARKER_FILE}\\n\")\n FileUtils.touch(MARKER_FILE)\n\n return 0\n\n rescue Exception => e\n err_msg = \"\\nFAILED to set GitLab root password\"\n err_msg += \":\\n #{e.message}\" unless e.message.strip.empty?\n err_msg += \"\\n\"\n\n unless @options.debug\n # don't print out the actual password in this message so it\n # doesn't end up in a Puppet log\n debug_cmd = \"#{PROGRAM_NAME} -v -t #{@options.load_timeout} <password>\"\n err_msg += \"\\nRun '#{debug_cmd}' manually to debug\"\n end\n\n warn(err_msg)\n return 1\n end", "def command_runner cmd:, repo:nil, branch:nil\n status = run_cmd(cmd)\n status\n end", "def get(*args)\n arguments(args, required: [:user, :repo, :sha])\n\n get_request(\"/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}\", arguments.params)\n end", "def go_with_args(argv=[])\n catch(:exit_err) { catch(:exit_zero) { @cli_obj.go(argv) } }\n end", "def sh(cmd)\n output = `#{cmd}`\n if !$?.success?\n puts \"Command exited with failure code: #{cmd}\"\n puts \"Aborting.\"\n exit(1)\n end\n output\nend", "def git\n # log \"Thread.current[:repo] nil? \" + Thread.current[:repo].nil?.to_s\n Thread.current[:repo] ||= clone(ARGV[0], ARGV[1])\n Thread.current[:repo]\n end", "def run_command(cmd, *args)\n r,w = IO.pipe\n\n pid = fork do\n r.close\n STDIN.close\n STDOUT.reopen(w)\n STDERR.reopen(w)\n\n exec(cmd, *args)\n end\n\n w.close\n output = r.read.force_encoding('binary')\n pid, status = Process::wait2(pid)\n\n [output, status]\n end", "def system cmd, *args\n ohai \"#{cmd} #{args*' '}\".strip\n\n if ARGV.verbose?\n safe_system cmd, *args\n else\n rd, wr = IO.pipe\n pid = fork do\n rd.close\n $stdout.reopen wr\n $stderr.reopen wr\n exec(cmd, *args) rescue nil\n exit! 1 # never gets here unless exec threw or failed\n end\n wr.close\n out = ''\n out << rd.read until rd.eof?\n Process.wait\n unless $?.success?\n puts out\n raise\n end\n end\n rescue SystemCallError\n # usually because exec could not be find the command that was requested\n raise\n rescue \n raise BuildError.new(cmd, args, $?)\n end", "def execute(*args)\n set_config('gist.api-url', DEFAULT_GITHUB_API_BASE_URL) if !config('gist.api-url')\n set_config('gist.default-url', DEFAULT_GITHUB_API_BASE_URL) if !config('gist.default-url')\n\n begin\n option_parser.parse!(args)\n\n if $stdin.tty? && options.setup_credentials\n api_url # make sure API URL selection happens, if need be\n setup_credentials\n exit 1\n end\n\n if $stdin.tty? && args[0] != '-'\n # Run without stdin.\n usage if args.empty?\n\n files = args.inject([]) { |list, file|\n # Check if arg is a file. If so, grab the content.\n abort \"Can't find #{file}\" unless File.exists?(file)\n\n list.push({\n :input => File.read(file),\n :filename => file,\n :extension => file.include?('.') ? File.extname(file) : options.gist_extension\n })\n }\n else\n # Read from standard input.\n input = $stdin.read\n files = [{:input => input, :extension => options.gist_extension}]\n end\n\n url = write(files, options.private_gist, options.description)\n browse(url) if options.browse_enabled\n $stdout.puts copy(to_embed(url)) if options.embed_enabled\n $stdout.puts copy(url) unless options.embed_enabled\n rescue Interrupt\n $stderr.puts \"\\nQuit.\"\n exit 1\n rescue OptionParser::InvalidOption => e\n warn e; puts\n usage\n exit 1\n rescue StandardError => e\n options.debug ? warn(e) : raise(e)\n end\n end", "def run(*args)\n logger.info(\"Running `#{args.shelljoin}`...\") if PrlBackup.config[:verbose]\n output = `#{args.shelljoin} 2>&1`\n status = $?\n unless status.success?\n logger.error(\"Command `#{args.shelljoin}` failed with exit status #{status.exitstatus}:\\n#{output}\")\n exit(1)\n end\n output\n end", "def cmd\n c = ['git commit']\n c << '-a' if all?\n c << %(-m \"#{options.message}\") if message?\n c << %(-m \"#{message}\") unless story_ids.empty?\n c << argument_string(unknown_options) unless unknown_options.empty?\n c.join(' ')\n end", "def run\n if self.is_git?\n self.aqlog(\"Running command : git-shell -c #{@cmd_cmd} '#{@real_path}'\")\n if system(Settings.git.shell, \"-c\", \"#{@cmd_cmd} '#{@real_path}'\")\n self.aqlog(\"\\t\\tOK\")\n else\n self.aqlog(\"\\t\\tKO\")\n end\n elsif self.is_hg?\n hg_commands = self.fresh_cmd.split(\" \")\n added_path = Settings.aq_sh.user_home + \"/\" +\n Settings.aq_sh.user_name + \"/\" +\n Settings.hg.repo_path\n hg_command = \"#{hg_commands[0]} #{hg_commands[1]} #{added_path}/#{hg_commands[2]} #{hg_commands[3]} #{hg_commands[4]}\"\n cmd_to_run = hg_command\n self.aqlog(\"Running command : #{cmd_to_run}\")\n if system(cmd_to_run)\n self.aqlog(\"\\t\\tOK\")\n else\n self.aqlog(\"\\t\\tKO\")\n end\n end\n end", "def run_git_first_commit\n raise \"Git 1st commit failed\" unless system(\"set +x; git commit\")\n end", "def test_gitgo_different_from_remote_gitgo\n assert !sh(a, 'git branch -a').include?('gitgo')\n assert !sh(b, 'git branch -a').include?('gitgo')\n assert !sh(c, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"bshasum\") {|io| io << \"b content\" }\n sh(b, 'git add bshasum')\n sh(b, 'git commit -m \"added document\"')\n \n # setup remote from c\n sh(c, 'git branch gitgo')\n sh(c, 'git checkout gitgo')\n method_root.prepare(c, \"cshasum\") {|io| io << \"c content\" }\n sh(c, 'git add cshasum')\n sh(c, 'git commit -m \"added document\"')\n sh(c, 'git push origin gitgo')\n \n # now try to push back, fails\n assert sh(b, 'git push origin gitgo').include?(\"! [rejected] gitgo -> gitgo (non-fast forward)\")\n \n sh(a, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # merge\n sh(b, 'git fetch')\n assert sh(b, 'git branch').include?('gitgo')\n assert sh(b, 'git branch -a').include?('origin/gitgo')\n sh(b, 'git merge origin/gitgo')\n \n # now push works\n sh(b, 'git push origin gitgo')\n sh(a, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # fetch for c leaves changes unmerged\n sh(c, 'git fetch')\n sh(c, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n \n # manual merge fixes\n sh(c, 'git merge gitgo origin/gitgo')\n sh(c, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n end", "def git_init\n\tsystem('git init')\nend", "def system_cmd(cmd)\n exit_val = nil\n cmd_to_run = cmd\n cmd_to_run = \"#{@git_ssh_cmd} #{cmd}\" if cmd.start_with? 'git'\n Open3.popen3(cmd_to_run) do |stdin, stdout, stderr, wait_thr|\n stdin.close\n\n block_size = 1\n io_buffers = {stdout: '', stderr: ''}\n output_buffer = []\n outputs = {stdout => :stdout, stderr => :stderr}\n\n begin\n until outputs.keys.all?(&:eof) do\n ready = IO.select(outputs.keys)\n if ready\n readable = ready[0]\n readable.each do |f|\n file_type = outputs[f]\n begin\n data = f.read_nonblock(block_size)\n\n io_buffers[file_type] << data\n if data == \"\\n\"\n payload = {file_type => io_buffers[file_type]}\n puts payload.inspect\n output_buffer << payload\n\n io_buffers[file_type] = \"\"\n end\n rescue EOFError\n end\n end\n end\n end\n rescue IOError\n end\n\n exit_val = wait_thr.value\n @build.build_logs.create(\n text: output_buffer.to_json,\n cmd: cmd_to_run,\n exit_code: exit_val,\n )\n end\n\n exit_val\n end", "def git_commit_all message\n system \"git add --all .\"\n return false unless $?\n system \"git commit -q -m '#{message.gsub(/'/, \"\\'\")}'\"\n return $?\nend", "def cmd\n \"git checkout #{other_branch}\"\n end", "def shell(*args)\n Open3.popen3(*args) do |_stdin, stdout, stderr, wait_thr|\n if wait_thr.value != 0\n puts \"\\nCommand '#{args.join ' '}' has failed\"\n puts \"STDOUT: #{stdout.gets nil}\"\n puts \"STDERR: #{stderr.gets nil}\"\n\n raise\n end\n end\n end", "def git_commit(repo, sha, options = {})\n get \"#{Repository.path repo}/git/commits/#{sha}\", options\n end", "def find_pass(command, args={})\n args = {\n :step => 1,\n :fail => @options[:fail],\n :pass => @options[:pass]\n }.merge(args)\n\n if !system(\"git reset --hard -q #{@options[:fail]} && git reset --hard -q #{args[:pass]} 2> /dev/null\")\n puts \" couldn't find any pass commit, fell off the history\"\n args[:pass] = nil\n return args\n end\n\n print \" looking #{args[:step]} commits back at: #{oneline_for(args[:pass])} ... \"\n File.open(@options[:command_log], 'w+') {|fh| fh.puts command}\n success = system(\"#{command} >>#{@options[:command_log]} 2>&1\")\n if success\n puts ' pass!'\n args\n else\n puts 'failing'\n args[:step] = args[:step] * 2\n args[:fail] = commit_for('HEAD')\n args[:pass] = commit_for(\"HEAD~#{args[:step]}\")\n find_pass(command, args)\n end\n end", "def discover_git_executable\n @git_executable ||= begin\n guessing_locations = [git_cmd]\n\n #:nocov:\n if RHC::Helpers.windows?\n guessing_locations << \n discover_windows_executables do |base|\n [ \n \"git.exe\",\n \"#{base}\\\\Git\\\\bin\\\\git.exe\", \n \"#{base}\\\\git.exe\", \n ]\n end\n end\n\n # make sure commands can be executed and finally pick the first one\n guessing_locations.flatten.uniq.select do |cmd| \n ((File.exist?(cmd) && File.executable?(cmd)) || exe?(cmd)) && \n (begin\n git_version(cmd)\n $?.success?\n rescue ; false ; end)\n end.collect{|cmd| cmd =~ / / ? '\"' + cmd + '\"' : cmd}.first\n #:nocov:\n end\n end", "def fetch_command\n if usable_repository?\n prune_c = \"#{git} remote prune origin 2>&1\"\n fetch_c = \"#{git} fetch --force --prune --update-head-ok #{quiet} origin '+refs/heads/*:refs/remotes/origin/*' '+refs/tags/*:refs/tags/*' 2>&1\"\n\n \"#{prune_c} && #{fetch_c}\"\n else\n \"rm -rf #{repository_cache} && git clone #{quiet} #{uri} #{repository_cache} 2>&1\"\n end\n end", "def git_clone_main\n raise \"oops, not done\"\nend", "def git_fetch path\n Open3.popen2e *%W(git fetch origin), chdir: path do |stdin, stdout, _wait|\n not stdout.read.chomp.empty?\n end\n end", "def git_null(command)\n git(\"#{command} 2>#{Bundler::NULL}\", false)\n end", "def main()\n\n # check that 3 arguments have been given, otherwise exit\n if ARGV.length < 3\n puts \"You haven't given enough arguments.\"\n exit\n end\n\n # the first argument should be the path to the local repository\n repo_path = ARGV[0]\n\n # the second argument should be the relevant GitHub username\n username = ARGV[1]\n\n # the third argument should be the repository name on GitHub\n repo_name = ARGV[2]\n\n # invoke link_commits with the arguments\n link_commits(repo_path, username, repo_name).each { |link| puts link }\nend", "def git_HEAD\n Dir.chdir(@dir) do\n commit = `git rev-parse HEAD`\n raise \"git rev-parse HEAD failed: #{$?.exitstatus}\" if $?.exitstatus != 0\n commit.chomp\n end\n end", "def commit\n @git = YMDP::GitHelper.new\n @git.do_commit(@message)\n @git_hash = git.get_hash(options[:branch]) \n end", "def git_describe\n @git_describe ||= begin\n git_cmd = \"git describe\"\n shell = Mixlib::ShellOut.new(git_cmd,\n :cwd => Omnibus.root)\n shell.run_command\n shell.error!\n shell.stdout.chomp\n end\n end", "def cmd\n lines = [\"git checkout #{target_branch}\"]\n c = [\"git merge --no-ff --log\"]\n c << %(-m \"#{message}\") unless story_ids.empty?\n c << argument_string(unknown_options) unless unknown_options.empty?\n c << story_branch\n lines << c.join(' ')\n lines.join(\"\\n\")\n end", "def initialize(args = [])\n @args = args\n command = args.shift\n if command && self.respond_to?(command)\n unless command == 'help'\n @user, @repo = repo_info\n return unless @user && @repo && configure_github_access\n update unless command == 'clean'\n end\n self.send command\n else\n unless command.nil? || command.empty? || %w(-h --help).include?(command)\n puts \"git-review: '#{command}' is not a valid command.\\n\\n\"\n end\n help\n end\n rescue UnprocessableState\n puts 'Execution of git-review command stopped.'\n end", "def git_check\n # May throw InvalidRepositoryException\n # - because of invalid path\n # - or broken git repository\n @repo = GitLib::Repo.new(path)\n end", "def add_git_facts\n # see if we're in a git repo. first, we need a directory that exists\n dir = @path.expand_path.ascend.find {|p| p.directory? }\n \n Dir.chdir(dir) do\n root_result = Cmds.new \"git rev-parse --show-toplevel\"\n \n unless root_result.ok?\n @result.in_git_repo = false\n @result.is_git_root = false\n return\n end\n \n @result.in_git_repo = true\n \n git = @result.git = Result.new\n git.root = Pathname.new root_result.out.chomp\n @result.is_git_root = @path == git.root\n \n user = git.user = Result.new\n \n ['name', 'email'].each {|key|\n user[key] = begin\n Cmds.chomp! \"git config user.#{ key }\"\n rescue\n end\n }\n \n git.origin = begin\n Cmds.chomp! \"git remote get-url origin\"\n rescue\n end\n \n match = GITHUB_SSH_URL_RE.match(git.origin) ||\n GITHUB_HTTPS_URL_RE.match(git.origin)\n \n git.is_github = !! match\n \n return unless match\n \n git.owner = match['owner']\n git.name = match['name']\n git.full_name = \"#{ git.owner }/#{ git.name }\"\n \n if true == @args['github_api']\n github = git.github = Result.new\n github.api_url = \"https://api.github.com/repos/#{ git.owner }/#{ git.name }\"\n \n response = Net::HTTP.get_response URI(github.api_url)\n \n if response.is_a? Net::HTTPSuccess\n # parse response body and add everything to github result\n parsed = JSON.parse response.body\n parsed.each {|k, v| github[k] = v}\n else\n # assume it's private if we failed to find it\n github.private = true\n end\n \n end\n end\n end" ]
[ "0.8751879", "0.8751879", "0.8087265", "0.8087265", "0.7994413", "0.7986992", "0.79054403", "0.7796345", "0.7695725", "0.7681175", "0.76486105", "0.7645474", "0.76147425", "0.7589856", "0.7565014", "0.73084056", "0.718944", "0.71232164", "0.7067989", "0.68932986", "0.67885095", "0.6784425", "0.6699456", "0.66816217", "0.66523236", "0.6534899", "0.64167994", "0.6409871", "0.6381122", "0.6366098", "0.62764543", "0.62514037", "0.62514037", "0.62514037", "0.62392825", "0.62392825", "0.621194", "0.6169316", "0.6166233", "0.6108249", "0.6103165", "0.60847044", "0.6062482", "0.601587", "0.5997313", "0.59952754", "0.5975449", "0.59582365", "0.593621", "0.58673126", "0.5849488", "0.5839355", "0.58064395", "0.57864314", "0.5759182", "0.57439435", "0.5731404", "0.5727725", "0.57073486", "0.5685317", "0.56590164", "0.562094", "0.5614194", "0.56067574", "0.560078", "0.5577126", "0.55668545", "0.5544079", "0.5542189", "0.5498473", "0.5498186", "0.54978025", "0.5487369", "0.5459986", "0.5457499", "0.5447885", "0.5433442", "0.5430512", "0.542722", "0.5414322", "0.5407083", "0.5385666", "0.5379725", "0.53677076", "0.53676355", "0.5359483", "0.5357166", "0.5348331", "0.53475416", "0.53447735", "0.534405", "0.5335326", "0.5329654", "0.5319615", "0.5310248", "0.5309786", "0.53093874", "0.53044695", "0.5302843", "0.5285057", "0.527788" ]
0.0
-1
Returns list of uncommited/untracked files as reported by git status.
def uncommitted_files files = nil p4 (['change','-o']).each do |line| files << line.strip if files files = [] if line.start_with?('Files:') end files ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uncommitted_files\n `git status`.scan(/^#(\\t|\\s{7})(\\S.*)$/).map { |match| match.last.split.last }\n end", "def uncommitted_files\n `git status`.scan(/^#(\\t|\\s{7})(\\S.*)$/).map { |match| match.last.split.last }\n end", "def get_uncommitted_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-n', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"Changed files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend", "def uncommitted_files\n svn('status', '--ignore-externals').split(\"\\n\").reject { |line| line =~ /^X\\s/ }\n end", "def uncommitted_files\n `hg status`.scan(/^(A|M|R|!|\\?) (\\S.*)$/).map{ |match| match.last.split.last }\n end", "def tracked_files\n all_files.reject { |f| ignore_matcher.matched?(f) }\n end", "def uncommitted_merge_files\n merge_state.uncommitted_merge_files\n end", "def check_changed_files(git)\n git.status.select {|file| file.type || file.untracked }\n end", "def currently_changed_files\n `git status --porcelain`.split(\"\\n\").map{ |file| file.split.last }\n end", "def get_unknown_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-un', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"New files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend", "def previously_changed_files\n `git show --pretty=\"format:\" --name-only`.split(\"\\n\")\n end", "def all_files_except_git\n Dir.glob('*', File::FNM_DOTMATCH).delete_if { |file| file =~ /\\A\\.{1,2}\\z|\\A\\.git\\z/ }\n end", "def all_files\n @all_files ||= `git ls-files 2> /dev/null`.split(\"\\n\")\n end", "def modified_files\n `git diff --cached --name-only --diff-filter=ACM --ignore-submodules=all`.split \"\\n\"\n end", "def get_files_modified\r\n\tgit_result = IO.popen('git status -u --porcelain').read\r\n\tgit_result.split(/[\\r\\n]+/).uniq.map!{|file| file.slice 3..-1}\r\nend", "def modified_files\n diff = git.diff(local_branch, remote_branch(local_branch))\n diff.stats[:files].keys\n end", "def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end", "def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end", "def gitignores\n %w[/tmp/librarian/]\n end", "def diff_files_from(commit)\n git_args = ['diff', '--stat', '--name-only', commit]\n result = default_repository.git_output(git_args).lines.map { |line| line.strip }.sort\n # not sure if git would ever mention directories in a diff, but ignore them.\n result.delete_if { |item| ::File.directory?(item) }\n return result\n end", "def excluded_files() = []", "def has_untracked_changes? \n not [repo.changed, repo.untracked].flatten.select do |k| \n k.include?(\".craft\") || k.eql?(\"persistent.sfs\") || k.eql?(\"quicksave.sfs\") \n end.empty?\n end", "def all_changed_files\n Set.new\n .merge(git.added_files.to_a)\n .merge(git.modified_files.to_a)\n .merge(git.renamed_files.map { |x| x[:after] })\n .subtract(git.renamed_files.map { |x| x[:before] })\n .to_a\n .sort\n end", "def files\n return unless git_repo?\n output = Licensed::Shell.execute(\"git\", \"ls-files\", \"--full-name\", \"--recurse-submodules\")\n output.lines.map(&:strip)\n end", "def staged\n @files.select { |k, f| f.sha_index != \"0000000000000000000000000000000000000000\" && f.type != nil }\n end", "def svn_status(current_dir)\n modified_files = []\n `svn status #{current_dir}`.split(/\\n/).map do |file|\n file =~ /(\\?|\\!|\\~|\\*|\\+|A|C|D|I|M|S|X)\\s*([\\w\\W]*)/\n\n if file =~ /^M/\n modified_files << file.split[-1]\n elsif file =~ /^C/\n raise \"ERROR: file found in conflict: #{file.split[-1]}\"\n end\n end\n return modified_files\nend", "def list_of_directories\n Dir.entries(\"./inspections\").select {|d| !d.start_with?(\".\") }\n end", "def unprocessed_files\n Dir.glob(@data_location + '/*.jl').sort\n end", "def ignored_files\n all_files.select { |f| ignore_matcher.matched?(f) }\n end", "def filter_git_diff_issues(issues)\n modified_files_info = git_modified_files_info()\n return issues.select { |i| \n modified_files_info[\"#{i['file']}\"] != nil\n }\n end", "def ignored\n @ignored ||= []\n @ignored.map(&:to_s)\n end", "def modified_files\n staged = squash?\n refs = 'HEAD^ HEAD' if merge_commit?\n @modified_files ||= Overcommit::GitRepo.modified_files(staged: staged, refs: refs)\n end", "def check_for_inexistent_files\n inexistent_files = []\n @files.each do |file|\n inexistent_files << file unless File.exists? file\n end\n\n inexistent_files\n end", "def working_files\n files.map {|f| working_file f}\n end", "def ignorable_paths\n []\n end", "def files_to_analyze\n require 'find'\n ignore_dirs = ['.git','bin','test','assets','lib','log','vendor','tmp','img', 'images', 'uploads', 'fonts']\n ignore_files = Regexp.union(/^\\..*$/i, /^.*(.md)$/i, /^.*(.json)$/i, /^.*(.yml)$/i, /^.*(.log)$/i, /^.*(.png)$/i, /^.*(.jpg)$/i, /^.*(.jpeg)$/i)\n final_files = []\n # for every file in repository - keep the files to process\n Find.find('.') do |path|\n path_name = File.basename(path)\n if FileTest.directory?(path)\n if ignore_dirs.include?(path_name)\n Find.prune\n else\n next\n end\n else\n if path_name.match(ignore_files)\n next\n else\n path.gsub!(/^\\.\\//, '')\n final_files.push(path)\n end\n end\n end\n return final_files\n end", "def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACM --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end", "def get_exclusions\n return \"\" if !has_git_ignores? || !has_git? \n git_ignore = File.join PWD, \".gitignore\"\n exclusions = `cat #{git_ignore}`.split(\"\\n\") \n # ensure we remove any commented out .gitignores\n exclusions = exclusions.select { |exclusion| exclusion[0,1] != '#' }\n exclusions = exclusions - @task_config[:always_include] \n if @dry_run\n puts wrap_top(\"EXCLUSIONS:\")\n puts exclusions.join(\"\\n\") \n end\n exclusions\n end", "def file_listing(commit)\n # The only reason this doesn't work 100% of the time is because grit doesn't :/\n # if i find a fix, it'll go upstream :D\n count = 0\n out = commit.diffs.map do |diff|\n count = count + 1\n if diff.deleted_file\n %(<li class='file_rm'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n else\n cla = diff.new_file ? \"add\" : \"diff\"\n %(<li class='file_#{cla}'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n end\n end\n \"<ul id='files'>#{out.join}</ul>\"\n end", "def target_files\n @target_files ||= (git.modified_files - git.deleted_files) + git.added_files\n end", "def filter_git_diff_issues(issues)\n modified_files_info = git_modified_files_info\n return [] if modified_files_info.empty?\n\n filtered_issues = []\n issues.each do |issue|\n file = issue[\"file\"].to_s\n next if modified_files_info[file].nil? || modified_files_info[file].empty?\n\n filtered_errors = issue[\"errors\"].select { |error| modified_files_info[file].include?(error[\"line\"].to_i) }\n filtered_issues << { \"file\" => file, \"errors\" => filtered_errors } unless filtered_errors.empty?\n end\n filtered_issues\n end", "def files\n @files ||= Dir.glob(File.join(@root, '**/*'), GLOB_FLAGS).select do |path|\n File.file?(path) && path !~ IGNORE_REGEX\n end\n end", "def check_clean_status_task\n raise \"The current working copy contains modifications\" if `#{git} ls-files -m`.split(\"\\n\").any?\n end", "def find_all_ignored\n skipped = []\n\n rubocop = YAML.load_file('./.rubocop.yml')\n rubocop['AllCops']['Exclude'].each do |ignored|\n skipped << ignored.split('/')[0]\n end\n\n skipped\nend", "def ignored\n [\n '.agignore',\n '.cvsignore',\n '.gitignore',\n '.hgignore',\n ].map do |file_with_ignore_patterns|\n if File.exist? file_with_ignore_patterns\n patterns = File.read(file_with_ignore_patterns).split(\"\\n\")\n patterns.map do |pattern|\n next if pattern =~ /^#/\n next if pattern =~ /^\\s*$/\n \"-not \\\\( -path \\\"*#{pattern}*\\\" -prune \\\\)\"\n end.compact.join(' ')\n else\n ''\n end\n end.join(' ') + [\n \"-not \\\\( -path \\\"*\\\\.git*\\\" -prune \\\\)\"\n ].join(' ')\nend", "def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACMR --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end", "def gitignore_list(dir)\n @gitignore_list ||= {}\n @gitignore_list[dir] ||= []\n\n ilist = []\n if File.exists?(dir + '/.gitignore')\n File.read(dir + '/.gitignore').split(\"\\n\").each do |line|\n Dir[dir + '/' + line].each do |f|\n fn = f.sub(/^#{dir}\\//, '')\n ilist << fn unless ilist.include?(fn)\n end\n end\n end\n @gitignore_list[dir] = ilist\n end", "def excluded_files\n # TODO: also append files marked as %{exclude} (or handle elsewhere?)\n missing_files_for(upstream_gem)\n end", "def changed_files\n # FIXME: Implement properly once changed detection is available.\n files\n end", "def ignored\n ignores.map {|ignore| ignore.ignoreable}\n end", "def filter_nonexistent(modified_files); end", "def files\n @@files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n end", "def tracked?(path)\n Overcommit::Utils.execute(%W[git ls-files #{path} --error-unmatch]).success?\n end", "def dependent_files\n processed.map(&:abs_path).compact.select { |fn| File.exist?(fn) }\n end", "def tracked_files; end", "def dirty?(exclude_spec=false)\n repo_status = false\n\n return repo_status unless File.directory?(path)\n\n Dir.chdir(path) do\n %x(git update-index -q --ignore-submodules --refresh)\n repo_status = \"Could not update git index for '#{path}'\" unless $?.success?\n\n unless repo_status\n %x(git diff-files --quiet --ignore-submodules --)\n repo_status = \"'#{path}' has unstaged changes\" unless $?.success?\n end\n\n unless repo_status\n %x(git diff-index --cached --quiet HEAD --ignore-submodules --)\n repo_status = \"'#{path}' has uncommitted changes\" unless $?.success?\n end\n\n unless repo_status\n # Things that may be out of date but which should stop the updating\n # of the git repo\n our_exclusions=[\n 'build/rpm_metadata',\n 'dist/'\n ]\n\n untracked_files = %x(git ls-files -o -d --exclude-standard --exclude=#{our_exclusions.join(' --exclude=')})\n\n if $?.success?\n unless untracked_files.empty?\n untracked_files.strip!\n\n if untracked_files.lines.count > 0\n repo_status = \"'#{path}' has untracked files\"\n end\n end\n else\n # We should never get here\n raise Error, \"Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'\"\n end\n end\n end\n\n repo_status\n end", "def releases_including_skipped()\n files = []\n\n cmd.ssh(\"ls -m #{releases_dir}\") do |stdout|\n files.concat(stdout.read.split(/[,\\s]+/))\n end\n\n return files\n end", "def all_incomplete_todos\n (global_incomplete_todos + local_incomplete_todos).uniq\n end", "def committed_files sha\n array_output_of \"git diff-tree --no-commit-id --name-only -r #{sha}\"\nend", "def repository_status(repo)\n untracked_files = 0\n modified_files = 0\n deleted_files = 0\n\n #- +:index_new+: the file is new in the index\n #- +:index_modified+: the file has been modified in the index\n #- +:index_deleted+: the file has been deleted from the index\n #- +:worktree_new+: the file is new in the working directory\n #- +:worktree_modified+: the file has been modified in the working directory\n #- +:worktree_deleted+: the file has been deleted from the working directory\n repo.status do |status|\n if status[1].include?(:worktree_new) || status[1].include?(:index_new)\n untracked_files += 1\n elsif status[1].include?(:worktree_modified) || status[1].include?(:index_modified)\n modified_files += 1\n elsif status[1].include?(:worktree_deleted) || status[1].include?(:index_deleted)\n deleted_files += 1\n end\n end\n\n return {\n untracked_files: untracked_files,\n modified_files: modified_files,\n deleted_files: deleted_files,\n clean: modified_files == 0 && deleted_files == 0\n }\nend", "def unmanifested_files\n mfs = manifested_files.map { |f| File.join bag_dir, f }\n bag_files.reject { |f| mfs.member? f }\n end", "def unmanifested_files\n mfs = manifested_files.map { |f| File.join bag_dir, f }\n bag_files.reject { |f| mfs.member? f }\n end", "def check_results\n bin = prettier_path\n raise \"prettier is not installed\" unless bin\n return run_check(bin, \".\") unless filtering\n ((git.modified_files - git.deleted_files) + git.added_files)\n .select { |f| f[matching_file_regex] }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", \"\") }\n .map { |f| run_check(bin, f) }\n end", "def files\n %x{\n find . -type f ! -path \"./.git/*\" ! -path \"./node_modules/*\"\n }.\n split(\"\\n\").\n map { |p| Pathname.new(p) }\n end", "def ignored_tracked_fields\n @ignored_tracked_fields ||= HistoryTracker.ignored_tracked_fields\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_changed_as_set(files)\n changed_files = files.select { |file| git.modified_files.include? file }\n not_changed_files = files.select { |file| !changed_files.include? file }\n all_files_changed = not_changed_files.empty?\n no_files_changed = changed_files.empty?\n return all_files_changed || no_files_changed\nend", "def files(dir)\n Dir[dir + '/**/*'].reject do |filename|\n File.directory?(filename) ||\n filename =~ /(~|\\.orig|\\.rej|\\.bak)$/\n end\n end", "def modified_files\n file_stats.count { |file| file.status == :modified }\n end", "def ignore\n @ignore ||= []\n end", "def ls\n table Dir.entries( Dir.pwd ).reject { |f| f.match /^\\..*$/ }\n end", "def report_files_that_dont_have_st_sync_active(options)\n inactive_files = []\n active_files = []\n total_file_count = 0\n\n Repositext::Cli::Utils.read_files(\n config.compute_glob_pattern(\n options['base-dir'] || :content_dir,\n options['file-selector'] || :all_files,\n options['file-extension'] || :at_extension\n ),\n options['file_filter'],\n nil,\n \"Reading content AT files\",\n options\n ) do |content_at_file|\n data_json_file = content_at_file.corresponding_data_json_file\n total_file_count += 1\n lang_and_date_code = [\n content_at_file.language_code_3_chars,\n content_at_file.extract_date_code\n ].join\n if data_json_file.contents.index('\"st_sync_active\":false')\n inactive_files << lang_and_date_code\n $stderr.puts \" - doesn't have st_sync_active\".color(:blue)\n else\n active_files << lang_and_date_code\n end\n end\n inactive_files_count = inactive_files.length\n active_files_count = active_files.length\n if inactive_files_count > 0\n $stderr.puts \"\\n\\n#{ inactive_files_count } files that DON'T HAVE st_sync_active:\"\n $stderr.puts '-' * 80\n inactive_files.each { |e| $stderr.puts e }\n $stderr.puts\n end\n if active_files_count > 0\n $stderr.puts \"\\n\\n#{ active_files_count } files that HAVE st_sync_active:\"\n $stderr.puts '-' * 80\n active_files.each { |e| $stderr.puts e }\n $stderr.puts\n end\n summary_line = \"Found #{ inactive_files_count } of #{ total_file_count } files that don't have st_sync_active at #{ Time.now.to_s }.\"\n $stderr.puts summary_line\n end", "def affected_files\n Dir[@result_dir + '/*.{ttf,eot,woff,svg}'].reject { |f| f[@file] }\n end", "def files\n if !@files\n files = Dir.glob(\"#{working_dir}/*\").map {|f| f.split(working_dir)[1][1..-1]}\n files.delete config_file\n @files = files\n end\n return @files\n end", "def get_file_names path\n Dir.entries(path).select { |file| !File.directory? File.join(path, file) }\n end", "def target_files\n @target_files ||= git.modified_files + git.added_files\n end", "def show_changed_files(status)\n status.each_line do |line|\n if line =~ /^#\\t/ # only print out the changed files (I think)\n if line =~ /new file:|modified:|deleted:/\n puts \" #{line}\" \n else\n puts \" #{line.chop}\\t\\t(may need to be 'git add'ed)\" \n end\n end\n end\nend", "def modified_files\n @modified_files ||= begin\n @modified_files = []\n\n rewritten_commits.each do |rewritten_commit|\n refs = \"#{rewritten_commit.old_hash} #{rewritten_commit.new_hash}\"\n @modified_files |= Overcommit::GitRepo.modified_files(refs: refs)\n end\n\n filter_modified_files(@modified_files)\n end\n end", "def all_commits\n `git --git-dir=#{git_dir} log --all --pretty='%H'`.split(/\\n/).uniq\n end", "def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end", "def get_svn_filelist( dir='.' )\n\tlist = IO.read( '|-' ) or exec 'svn', 'st', '-v', '--ignore-externals', dir\n\n\t# Split into lines, filter out the unknowns, and grab the filenames as Pathnames\n\t# :FIXME: This will break if we ever put in a file with spaces in its name. This\n\t# will likely be the least of our worries if we do so, however, so it's not worth\n\t# the additional complexity to make it handle that case. If we do need that, there's\n\t# always the --xml output for 'svn st'...\n\treturn list.split( $/ ).\n\t\treject {|line| line =~ /^(\\?|(\\s*|--- .*)$)/ }.\n\t\tcollect {|fn| Pathname(fn[/\\S+$/]) }\nend", "def files\n result = []\n @my_files.each do |f|\n result << f.fname if FileTest.file?(f.fname)\n end\n result\n end", "def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end", "def removed_infections\n return [] unless prev_scan\n current_infections = scan.infections.collect{|infection| infection.file}\n prev_scan.infections.select{|infection| !current_infections.include?(infection.file)}\nend", "def files_in branch:\n array_output_of(\"git ls-tree -r --name-only #{branch}\")\nend", "def deleted_files\n file_stats.count { |file| file.status == :deleted }\n end", "def blacklisted_dir_entries\n %w[. ..]\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 lint_results\n bin = eslint_path\n raise 'eslint is not installed' unless bin\n return run_lint(bin, '.') unless filtering\n ((git.modified_files - git.deleted_files - git.renamed_files.map { |r| r[:before] }) + git.added_files + git.renamed_files.map { |r| r[:after] })\n .select { |f| target_extensions.include?(File.extname(f)) }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", '') }\n .map { |f| run_lint(bin, f).first }\n end", "def getFilesFromDiff(diff)\n files = []\n diff.lines.map(&:chomp).each do |line|\n if line.start_with? '+++ b/'\n line[\"+++ b/\"] = \"\"\n # try to remove anything after a tab character\n # this is needed by --check 0\n begin\n line[/\\t.*$/] = \"\"\n # IndexError is raised if no tab characters are found\n rescue IndexError\n end\n files << line\n end\n end\n return files\n end", "def removed; status[:removed] || []; end", "def all_commit_times\n `git --git-dir=#{git_dir} log --all --pretty='%at'`.split(/\\n/).uniq\n end", "def prompt_git_status\n if !is_git?\n return \"\"\n end\n stat = `git status`\n res = \"\"\n res += ( stat.include?(\"ahead\") ? \"^\" : \"\" )\n res += ( stat.include?(\"modified\") ? \"*\" : \"\" )\n res += ( stat.include?(\"untracked\") ? \"+\" : \"\" )\n res += ( stat.include?(\"deleted\") ? \"-\" : \"\" )\n res!=\"\" ? \"[#{res}]\".magenta : \"\"\nend", "def diff_gitignore\n system(\"diff .gitignore ~/code/tmpl/gitignore-gem\")\n end", "def diff_gitignore\n system(\"diff .gitignore ~/code/tmpl/gitignore-gem\")\n end", "def all_modified_files_coverage\n unless @project.nil?\n @all_modified_files_coverage ||= begin\n modified_files = git.modified_files.nil? ? [] : git.modified_files\n added_files = git.added_files.nil? ? [] : git.added_files\n all_changed_files = modified_files | added_files\n @project.coverage_files.select do |file|\n all_changed_files.include? file.source_file_pathname_relative_to_repo_root.to_s\n end\n end\n\n @all_modified_files_coverage\n end\n end", "def get_repo_status\n args = {:clone => CONFIG[\"local\"][\"clone\"]}\n st = `#{Templates.status(args)}`\n current_branch = st.split(\"\\n\")[0][3..-1].split(\"...\")[0]\n modified_files = st.split(\"\\n\")[1..-1].join(\"\\n\")\n [current_branch, modified_files]\n end", "def get_files_in_commit(commit)\n\tfiles = {}\n\tcommit.diffs.each do | diff |\n\t\tfiles[diff.a_path] = nil unless files.has_key? diff.a_path\n\t\tfiles[diff.b_path] = nil unless files.has_key? diff.b_path\n\t\t# what about diff.deleted_file and diff.new_file?\n\tend\n\treturn files.keys\nend", "def files\n @files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n # This returns:\n # [\"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Thundercat - For Love I Come - dance.mp3\"]\n end", "def test_clean_checkout_should_not_remove_tracked_files\n with_sandboxed_git do |proj_dir, git|\n tracked_file = File.join(proj_dir, 'tracked.txt')\n FileUtils.touch tracked_file\n sandbox_git_add_and_commit(proj_dir, File.basename(tracked_file))\n untracked_file = File.join(proj_dir, 'untracked.txt')\n git.clean_checkout\n assert File.exist? tracked_file\n assert_false File.exist? untracked_file\n end\n end" ]
[ "0.8367702", "0.8367702", "0.7949428", "0.7858047", "0.759202", "0.697779", "0.6929143", "0.6869004", "0.6848623", "0.67857504", "0.6598226", "0.64837974", "0.63715374", "0.63712436", "0.63645965", "0.6248532", "0.6237173", "0.6237173", "0.60338616", "0.59826505", "0.5969127", "0.5961163", "0.5938676", "0.5914217", "0.5903339", "0.5881684", "0.5877982", "0.5850552", "0.5845726", "0.5784137", "0.5763335", "0.5754837", "0.56904006", "0.56669945", "0.5642885", "0.5631095", "0.56185555", "0.5610356", "0.5583028", "0.55567616", "0.5519064", "0.5517472", "0.5517162", "0.5507081", "0.5500668", "0.5498635", "0.54862064", "0.54848385", "0.54807997", "0.54769164", "0.5451894", "0.5431574", "0.5431249", "0.54209733", "0.5420328", "0.5394139", "0.53716874", "0.53544825", "0.5352516", "0.5348655", "0.53438115", "0.53438115", "0.53422284", "0.5336614", "0.5313219", "0.53083175", "0.52987075", "0.5296679", "0.5276698", "0.52699333", "0.5254102", "0.52361995", "0.52285284", "0.52273935", "0.52273226", "0.52270854", "0.52253675", "0.522432", "0.52114236", "0.52098596", "0.52076894", "0.5206285", "0.52057266", "0.5197313", "0.5196025", "0.5195689", "0.5189985", "0.5186909", "0.51791847", "0.5177584", "0.516342", "0.5159081", "0.51574093", "0.51488423", "0.51488423", "0.51470417", "0.51415807", "0.5137996", "0.5137064", "0.5123803" ]
0.76043624
4
Commit the given file with a message. The file has to be known to Git meaning that it has either to have been already committed in the past or freshly added to the index. Otherwise it will fail.
def commit(message) p4 'submit', '-d', message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit(file, message)\n git 'commit', '-m', message, file\n end", "def commit(file, message)\n git 'commit', '-m', message, file\n end", "def commit(file, message)\n hg 'commit', '-m', message, file\n end", "def commit(message = nil)\n # Write current index back to the repository\n index = @repo.index\n commit_tree = index.write_tree @repo\n\n # Commit message\n message = \"Affected files: #{@affected_files.uniq.join(', ')}\" if message.nil?\n\n # User handling\n user = ENV['USER']\n user = \"cir-out-commit\" if user.nil?\n\n # Commit author structure for git\n commit_author = {\n email: 'cir-auto-commit@nowhere.cz',\n name: user,\n time: Time.now\n }\n\n # And finally commit itself\n Rugged::Commit.create @repo,\n author: commit_author,\n committer: commit_author,\n message: message,\n parents: @repo.empty? ? [] : [ @repo.head.target ].compact,\n tree: commit_tree,\n update_ref: 'HEAD'\n\n # Reset list of files that were changed since last commit\n @affected_files = []\n end", "def commit(repopath, file, contents, message)\n # set up repo and index\n repo = Grit::Repo.new repopath\n index = Grit::Index.new repo\n # write file to repo\n fullpath = File.join repopath, file\n File.open(fullpath, 'wb') {|f| f.write contents}\n # commit file\n index.add file, contents\n parent = repo.commits.count > 0 ? [repo.commits.first] : nil\n index.commit message, parent\n end", "def update_commit_message(message)\n ::File.open(commit_message_file, 'w') do |file|\n file.write(message)\n end\n end", "def commit(msg=status)\n setup unless head\n \n sha = git.commit(msg)\n index.write(sha)\n sha\n end", "def save message\n raise NothingToCommitError if nothing_to_commit?\n @git.index.add_all\n @git.index.write\n usr = {name: @git.config['user.name'],\n email: @git.config['user.email'],\n time: Time.now}\n opt = {}\n opt[:tree] = @git.index.write_tree\n opt[:author] = usr\n opt[:committer] = usr\n opt[:message] = message\n opt[:parents] = unless @git.empty?\n begin\n [@git.head.target].compact\n rescue Rugged::ReferenceError\n []\n end\n else [] end\n opt[:update_ref] = 'HEAD'\n Rugged::Commit.create(@git, opt)\n end", "def commit!(message)\n git \"commit -m \\\"#{message}\\\"\"\n end", "def commit!(msg=status)\n setup unless head\n \n sha = git.commit!(msg)\n index.write(sha)\n sha\n end", "def commit(message)\n Dubya.logger.info \"Updating Git repository...\"\n system %(cd #{path} && git commit -am \"#{message}\" && git push)\n end", "def commit(message)\n @repo.commit_index(\"Cron Job: #{message}\") # Commit.\nend", "def commit(message, opts = {})\n self.lib.commit(message, opts)\n end", "def save message\n Dir.chdir @root do\n cmd = \"git add --all && git commit -m \\\"#{message}\\\"\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n if /nothing to commit/.match stdout\n raise NothingToCommitError\n elsif /Not a git repository/.match stderr\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n end\n end", "def commit(message, options={})\n raise \"no changes to commit\" if status.empty?\n commit!(message, options)\n end", "def git_commit(message)\n yield\n git add: '.'\n git commit: %{ -m #{message.inspect} }\n end", "def commit(author, message)\n GIT.add relative_path\n GIT.commit message, :author => \"#{ author.name } <#{ author.email }>\"\n end", "def commit(message = nil, oneline = nil)\n commit_message = oneline || \"Committing changeset #{repository.commits.size + 1}\"\n commit_message << \"\\n\\n\" << message unless message.nil?\n self.repository.commit_all commit_message\n end", "def stage_and_commit_file(repo_base_path, relpath_to_file, commit_message = nil)\n commit_message = \"Updated #{relpath_to_file} via website\" unless !commit_message.blank?\n gitRepo = Repo.new(repo_base_path)\n olddir = Dir.pwd\n Dir.chdir(repo_base_path)\n gitRepo.add(relpath_to_file)\n gitRepo.commit_index(commit_message)\n Dir.chdir(olddir)\n end", "def commit( commit_msg )\n\n log.info(x) { \"[git] commit msg => #{commit_msg}\" }\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_commit_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} commit -m \\\"#{commit_msg}\\\";\"\n log.info(x) { \"[git] commit command => #{git_commit_cmd}\" }\n %x[#{git_commit_cmd}];\n log.info(x) { \"[git] has committed resources into the local repository.\" }\n\n end", "def commit\n self.index.commit(@commit_msg, @commit_author)\n end", "def commit(branch, message)\n zombie_check\n on_worktree(branch) { |repo| repo.commit(message) }\n end", "def commit!(message, options={})\n now = Time.now\n \n sha = options.delete(:tree) || tree.write_to(self).at(1)\n parents = options.delete(:parents) || (head ? [head] : [])\n author = options[:author] || self.author\n authored_date = options[:authored_date] || now\n committer = options[:committer] || author\n committed_date = options[:committed_date] || now\n\n # commit format:\n #---------------------------------------------------\n # tree sha\n # parent sha\n # author name <email> time_as_int zone_offset\n # committer name <email> time_as_int zone_offset\n # \n # messsage\n # \n #---------------------------------------------------\n # Note there is a trailing newline after the message.\n #\n lines = []\n lines << \"tree #{sha}\"\n parents.each do |parent|\n lines << \"parent #{parent}\"\n end\n lines << \"author #{author.name} <#{author.email}> #{authored_date.strftime(\"%s %z\")}\"\n lines << \"committer #{committer.name} <#{committer.email}> #{committed_date.strftime(\"%s %z\")}\"\n lines << \"\"\n lines << message\n lines << \"\"\n \n @head = set('commit', lines.join(\"\\n\"))\n grit.update_ref(branch, head)\n \n head\n end", "def commit(message, opts = {})\n arr_opts = ['-m', message]\n arr_opts << '-a' if opts[:add_all]\n arr_opts << '--amend' if opts[:amend]\n arr_opts << '--allow-empty' if opts[:allow_empty]\n arr_opts << \"--author\" << opts[:author] if opts[:author]\n command('commit', arr_opts)\n end", "def commit(msg = nil)\n require_dep! 'awesome_spawn'\n require_cmd! git_cmd\n\n in_repo { AwesomeSpawn.run \"#{git_cmd} add #{pkg_files.join(' ')}\" }\n super(msg.nil? ? \"updated to #{version}\" : msg)\n self\n end", "def commit\n system(\"cd #{repo_path};git commit -m 'to the cloud'\")\n end", "def git_commit(message=\"\")\n %x( git commit -m=#{message} )\n end", "def commit(message = '', author = User.from_config, committer = author)\n root.write\n\n commit = Commit.new(self)\n commit.tree = root\n commit.parent << head.id if head\n commit.author = author\n commit.committer = committer\n commit.message = message\n commit.write\n\n open(head_path, \"wb\") do |file|\n file.write(commit.id)\n end\n\n @head = commit\n end", "def commit!\n git add: \".\"\n git commit: \"-m '#{config.dig('commit_msg')}'\"\n end", "def commit(files, no_edit: false, amend: false, message: nil, author: nil)\n run_git ['add', *Array(files)] if files\n\n cmd = %w[commit]\n cmd << '--no-edit' if no_edit\n cmd << '--amend' if amend\n cmd << %[--author=\"#{author}\"] if author\n cmd += ['--message', %[\"#{message}\"]] if message\n\n output, status = run_git(cmd)\n\n status.success? || raise(CannotCommitError.new(output))\n end", "def git_commit_push(message)\n\t\t \t\tshell_command(\"git commit -a -m #{message}\")\n\t\t \t\tshell_command(\"git commit\")\n\t\t \tend", "def commit(message = '', author = nil, committer = nil)\n return if !root.modified?\n\n author ||= default_user\n committer ||= author\n root.save\n\n commit = Commit.new(:repository => self,\n :tree => root,\n :parents => head,\n :author => author,\n :committer => committer,\n :message => message)\n commit.save\n\n write_head_id(commit.id)\n load\n\n commit\n end", "def commit(name, message)\n git = git(name)\n\n git.config('user.name', GIT_AUTHOR[:name])\n git.config('user.email', GIT_AUTHOR[:email])\n\n git.add(all: true)\n git.commit(message)\n end", "def repo_commit(msg)\n git :add => '-u'\n git :add => '.'\n git :commit => \"-m \\\"#{msg}\\\"\" \n end", "def cmd_commit(msg)\n comment = msg[2].tr('\"', '')\n run_cmd(\"cd /etc;git add . && git commit -a -m \\\"#{comment}\\\"\")\n end", "def commit_files(author: nil, message: nil, parent: nil, files: {})\n # check parameters\n raise \"no author given\" if author.nil?\n raise \"no message given\" if message.nil?\n\n # get parent commit\n if not parent.nil?\n parent = @wiki.commit_for(parent)\n elsif parent.nil? and not @wiki.repo.head.commit.nil?\n parent = @wiki.commit_for(@wiki.repo.head.commit.id)\n end\n\n unless parent.nil?\n log_debug \" checkpoint (parent #{parent})\"\n if parent.id != @wiki.repo.head.commit.id\n log_debug \" (parent #{parent} is not head)\"\n\n # now check version of each file individually, if it has been\n # changed in one of the changes since parent.\n #\n # if so, raise error, else proceed\n\n files.each do |path,contents|\n next if @wiki.repo.log(nil, path, {:since => parent.authored_date}).empty?\n log_debug \" file has changed\"\n raise \"repo has changed\"\n end\n end\n end\n\n options = {\n :message => message,\n :author => author,\n }\n unless parent.nil?\n options[:parent] = parent\n end\n\n committer = Gollum::Committer.new(@wiki, options)\n\n files.each do |path,contents|\n path = path.dup.gsub(/^\\.\\//, '')\n if contents.nil?\n committer.index.delete(path)\n else\n committer.index.add(path, normalize(contents))\n end\n # if wikifile_exists? path, parent\n # log_debug \" U path: #{path}, contents: #{normalize(contents)}\"\n # committer.index.add(path.dup, normalize(contents))\n # else\n # log_debug \" A path: #{path}, contents: #{normalize(contents)}\"\n # dir, name, format = split_path path\n # committer.add_to_index(dir, name, format, contents)\n # end\n end\n\n committer.after_commit do |index, sha|\n log_debug \" after_commit: #{index}, #{sha}\"\n @wiki.clear_cache\n\n files.each do |path,contents|\n path = path.gsub(/^\\.\\//, '')\n #dir, name, format = split_path path\n unless @wiki.repo.bare\n Dir.chdir(::File.join(@wiki.repo.path, \"..\")) do\n if contents.nil?\n @wiki.repo.git.rm(path, :force => true)\n else\n @wiki.repo.git.checkout(path, 'HEAD')\n end\n end\n end\n end\n\n @wiki_manager.add_to_index(@wiki, index, sha, files)\n end\n\n sha = committer.commit\n log_debug \"sha #{sha}\"\n end", "def update(content, message=nil)\n # normalise content\n content = Page.normalise_body(content)\n \n # create subdirectory if needed\n dirname = File.dirname(@filename)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n \n # Write changes to file\n File.open(@filename, 'w') { |f| f << content }\n \n # Create commit message\n commit_message = tracked? ? \"edited #{@basename.wikify}\" : \"created #{@basename.wikify}\"\n commit_message += ' : ' + message unless message.blank?\n \n # Commit changes\n begin\n $repo.add(@name)\n $repo.commit(commit_message)\n rescue\n nil\n end\n end", "def save(message)\n to_be_added = pending_changes.select{|f|\n f.untracked && f.type.nil?\n }\n git.add(git_opts, *to_be_added.map{|f| f.path})\n git.commit(git_opts(), '-a', '-m', message)\n self\n end", "def save(commit_msg = nil)\n # Add all changes to index (staging area)\n index = repo.index\n\n # Process config file (if loaded, i.e. may be modified)\n save_config_file(index) if @config\n\n # Process ssh keys (if loaded, i.e. may be modified)\n save_ssh_keys(index) if @ssh_keys\n\n # Write index to git and resync fs\n commit_tree = index.write_tree(repo)\n index.write\n\n author = commit_author.merge(time: Time.now)\n\n opts = {\n parents: [repo.head.target],\n tree: commit_tree,\n update_ref: 'HEAD',\n message: (commit_msg || @settings[:commit_msg]),\n author: author,\n committer: author\n }\n Rugged::Commit.create(repo, opts)\n end", "def git_commit_push(host, branch, message, git_repo_path)\n git_on(host, \"commit -m \\\"#{message}\\\"\", git_repo_path)\n git_push(host, branch, git_repo_path)\nend", "def git_commit(message, fail_on_error = true)\n begin\n mysystem(\"git commit -m \\\"#{message}\\\" 2> /dev/null > /dev/null\")\n return true\n rescue Exception => e\n raise e if fail_on_error\n return false\n end\n end", "def commit_all(_message)\n puts 'TODO: Implement Git.commit_all'\n end", "def save_changes!(files_to_commit: [], custom_message: nil)\n not_implemented(__method__)\n end", "def satellite_commit(repo, message, author, branch)\n options = rugged_commit_options(author, repo, message)\n commit_id = Rugged::Commit.create repo, options\n repo.index.write\n pushtobare branch\n touch # use current updated_at time\n commit_id\n end", "def add_file(file)\n index = @repo.index\n index.add path: file, oid: (Rugged::Blob.from_workdir @repo, file), mode: 0100644\n index.write\n\n @affected_files << file\n end", "def commit\n @git = YMDP::GitHelper.new\n @git.do_commit(@message)\n @git_hash = git.get_hash(options[:branch]) \n end", "def commit_changes\n @message = \"commiting changes for #{@issue_key}\"\n begin\n ui.info \"Commiting changes...\"\n @git.commit_all(@user_message.empty? ? @message : @user_message)\n rescue Git::GitExecuteError => e\n error_message = e.message.split(':').last\n ui.info error_message\n unless error_message =~ /nothing to commit/\n exit 1\n end\n end\n push_changes\n end", "def satellite_commit(repo, message, author, branch)\n options = rugged_commit_options(author, repo, message)\n commit_id = Rugged::Commit.create repo, options\n repo.index.write\n pushtobare branch\n commit_id\n end", "def commit\n @repo.commit\n end", "def commit!\n rsp = post(\"<commit/>\")\n success?(rsp.body) or log_error(rsp.body)\n end", "def git_commit(message, &block)\n yield if block_given?\n git :add => '.'\n git :commit => \"--quiet --message '#{message}'\"\nend", "def commit_message\n @commit.sub '%.%.%', @after_version\n end", "def commit args = {}\n action = :deleted if self.deleted?\n action ||= self.is_new? ? :added : (self.is_changed? ? :updated : :nothing_to_commit) \n args[:skip_part_data] ||= false\n \n unless action.eql?(:nothing_to_commit)\n message = \"#{action} #{name}\"\n message = args[:m] if args[:m] \n if action.eql?(:deleted)\n repo.remove(self.file_name)\n self.history_count += 1\n else\n repo.add(self.file_name)\n end\n\n active_message = self.commit_messages[:most_recent]\n message = \"#{active_message.gsub(message,\"\")}\" unless self.deleted? || active_message.blank? || active_message.eql?(message)\n self.remove_message_from_temp_store(:most_recent) unless active_message.blank?\n \n repo.commit(message)\n self.last_commit = repo.log(self.local_path, :limit => 1).first.to_s\n end\n unless action.eql?(:deleted) \n self.part_count = parts.count\n self.part_count ||= 0 \n update_part_data unless args[:skip_part_data]\n\n self.history_count = self.history.size\n self.history_count = 1 if self.history_count.eql?(0) \n end\n self.save if self.changed?\n \n synchronize unless args[:dont_sync] || self.attributes[\"sync\"].blank? #rather than calling sync.blank? to skip the JSON parsing step.\n return action\n end", "def commit!(message)\n date = Time.now\n @status_add.each{|name, body|\n json = Article.new(name, body, date).to_json\n zcard = @redis.zcard name\n @redis.zadd name, zcard+1, json\n @redis.sadd KEY_SET, name\n @summary_redis.update MarkdownBody.new(name, body, date).summary\n }\n @remove_add.each{|name, latest_rank|\n @redis.zremrange(name, 0, latest_rank)\n }\n @redis.set MODIFIED_DATE, date.to_s\n end", "def quick_commit(repo, msg='WARNING: This commit was made automatically by a script, and should be reviewed!')\n log = File.open \"#{LOG_DIR}/git.txt\", 'a'\n Dir.chdir Pathname(repo).expand_path do |p|\n print \"Performing quick commit for '#{File.basename repo}'...\\n\" unless $cli_opts[:quiet]\n log.puts `git add -A`\n log.puts `git commit -m \"#{msg}\"`\n log.puts\n result = `git push origin`\n log.puts result\n puts result.empty? ? 'Done.' : 'Failed!'\n end\n end", "def commit( *files, **options )\n\t\tself.server.run( :commit, *files, **options )\n\t\treturn true\n\tend", "def add_file(*args)\n context = args.pop\n file_path_hash_or_string, content, commit_msg = args\n file_path_hash = file_path_hash_form(file_path_hash_or_string)\n get_adapter_repo(context).add_file(file_path_hash, content, commit_msg)\n end", "def commit_and_push_to_repo(oauth_token, commit_message, \n tree_sha, head_sha, ref_name)\n client = Octokit::Client.new(access_token: oauth_token)\n sha_new_commit = client.create_commit(full_repo_name, commit_message, tree_sha, head_sha)[:sha]\n client.update_ref(full_repo_name, ref_name, sha_new_commit)\n end", "def git_add(file, msg)\r\n `git add #{file} && git commit -m \\\"#{msg}\\\"`\r\nend", "def add(file)\n # add file to object db\n return false if !File.exists?(file)\n return false if !File.file?(file)\n \n sha = get_raw_repo.put_raw_object(File.read(file), 'blob')\n \n # add it to the index\n @git_index.add(file, sha)\n end", "def commit_file\n\t\tlogger.info(\"[File Attribute #{sprintf('0x%08x', self.object_id)}] Committing file for #{@obj.class}(#{@obj.id}).#{attribute_name} ...\")\n\t\tif @file\n\t\t\tlogger.info(\"[File Attribute] Saving file #{local_file_name} ...\")\n\t\t\t@file.rewind if @file.respond_to?(:rewind)\n\t\t\tFile.makedirs(File.dirname(local_file_name))\n\t\t\tFile.open(local_file_name, \"w\") do |f|\n\t\t\t\tf.write(@file.read)\n\t\t\tend\n\t\t\tlogger.info(\"[File Attribute] Done.\")\n\t\telse\n\t\t\tlogger.info(\"[File Attribute] Skipping file save of #{@file.inspect}.\")\n\t\tend\n\t\ttrue\n\tend", "def create_local_commit author: nil, branch:, file_name:, file_content:, message:, push: false\n on_branch(branch) do\n if (folder_name = File.dirname file_name) != '.'\n Dir.mkdir folder_name\n end\n File.write file_name, file_content\n run \"git add '#{file_name}'\"\n run \"git commit -m '#{message}' #{\"--author='#{author}'\" if author}\"\n run 'git push' if push\n end\nend", "def git_commit_all message\n system \"git add --all .\"\n return false unless $?\n system \"git commit -q -m '#{message.gsub(/'/, \"\\'\")}'\"\n return $?\nend", "def vcs_commit(evt)\n sel = @tblChanges.selection_model.selected_items\n msg = @cmbCommitMsg.value\n if sel.length == 0\n fx_alert_error \"Cannot commit on empty changes selection. Please select at least a file from the table above.\", \"No Files Selected\", main_stage\n elsif (msg.nil? or msg.empty?)\n fx_alert_error \"Commit message must be present.\", \"Empty Commit Message\", main_stage\n else\n commit_changes(sel, msg)\n if not @msgHistory.include?(msg)\n @cmbCommitMsg.items.add(msg)\n @msgHistory << msg\n end\n refresh_tab_state\n end\n end", "def create_commit_msg(commit_msg_path, for_commit)\n File.open(commit_msg_path, 'w') do |file|\n file.puts(\"Automatic documentation update\\n\")\n file.puts(\"- Generated for #{for_commit}.\")\n end\n end", "def write(filename, message, client)\n afile = File.new(filename, \"r+\")\n if afile\n afile.syswrite(message)\n client.puts(\"Changes made to \"+ filename)\n else\n client.puts \"Unable to write to file!\"\n end\nend", "def upload!(file_path)\n raise GitCloud::FileException.new(\"NotFound\") unless File.exists? file_path\n file = File.new(File.expand_path(file_path))\n add(file)\n commit\n push\n end", "def add(file)\n @file = file\n FileUtils.cp_r(file.path,folder_path)\n unless system(\"cd #{repo_path};git add .\")\n raise GitCloud::GitException.new(\"Add\")\n end\n end", "def commit(m)\n git(:add => '.')\n git(:commit => \"-a -m 'Rails Template Commit: #{m}'\")\nend", "def commit_all(message, opts = {})\n opts = {:add_all => true}.merge(opts)\n self.lib.commit(message, opts)\n end", "def commit_message\n user_name = user ? user.login : \"anonymous\"\n \n if revisions.empty?\n \"initial #{user_name}\"\n elsif @rollback\n \"rollback #{self.log.first} #{user_name}\"\n else\n \"edit #{self.log.first} #{user_name}\"\n end\n end", "def write(content, message, author = nil)\n if !content.respond_to? :read\n content.gsub!(\"\\r\\n\", \"\\n\")\n\treturn if @object && @object.data == content\n end\n\n Wiki.check do |errors|\n errors << :already_exists.t(:path => @path) if new? && Resource.find(@repository, @path)\n errors << :empty_commit_message.t if message.blank?\n end\n\n repository.transaction(message, author && author.to_git_user) do\n content = content.read if content.respond_to? :read # FIXME\n repository.root[@path] = Gitrb::Blob.new(:data => content)\n end\n\n reload\n @commit = repository.log(1, nil).first\n @object = @commit.tree[@path] || raise(NotFound, path)\n @current = true\n end", "def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end", "def commit\n sanity_check\n @handle.commit\n end", "def commit_to_git\n puts `git add .`\n puts `git commit -a -m \"New poshts for the syhtt\"`\n puts `git push blahg master`\n end", "def commit(repo)\n # First, ensure everything up-to-date\n # The fourth argument as true tells update to ignore externals.\n repo.ctx.update(repo.wc_path, \"HEAD\", nil, true)\n \n root = Directory.new(repo.ctx, repo.wc_path)\n root.instance_eval(&@block) if @block\n ci = repo.ctx.ci(repo.wc_path)\n unless ci.revision == Svn::Core::INVALID_REVNUM\n rev = ci.revision\n repo.repos.fs.set_prop('svn:log', @message, rev) if @message\n repo.repos.fs.set_prop('svn:author', @author, rev) if @author\n repo.repos.fs.set_prop('svn:date', @date, rev) if @date\n @revprops.each do | key, val |\n val = SvnFixture.svn_time(val) if val.respond_to?(:strftime)\n repo.repos.fs.set_prop(key.to_s, val.to_s, rev)\n end\n else\n puts \"Warning: No change in revision #{name} (SvnFixture::Revision#commit)\"\n end\n return true\n end", "def send_file(message, file)\n response = self.class.post(@api.send_file_config[:url],\n :query => { :auth_token => @token },\n :body => file_body({ :message => message }.send(@api.send_config[:body_format]), file),\n :headers => file_body_headers(@api.headers)\n )\n\n ErrorHandler.response_code_to_exception_for :user, user_id, response\n true\n end", "def git_add_commit_push(host, branch, message, git_repo_path)\n git_add_everything(host, git_repo_path)\n git_commit_push(host, branch, message, git_repo_path)\nend", "def commit(newrevision, content_io=nil)\n if not get_indexfile_with_revision(newrevision).nil?\n raise \"Committing already-existing revision: #{newrevision} for #{@fname}\"\n end\n if content_io.nil?\n compress_file_lines = Deflate.deflate(File.read(@fname))\n else\n cont = content_io.read\n compress_file_lines = Deflate.deflate(cont)\n end\n\n # append current file fname to datafile\n length = IO.readlines(@datafile).size\n\n File.open(@datafile, \"a\") do |append|\n append.puts compress_file_lines\n end\n length = IO.readlines(@datafile).size - length\n\n # new version is the old version plus 1\n # new offset is the last length + last offset\n parse_last_line = parse_indexfile_line get_indexfile_with_line(-1)\n new_offset = parse_last_line[1] + parse_last_line[2]\n\n File.open(@indexfile, \"a\") do |f|\n index_write_row(f, newrevision.to_s,\n new_offset.to_s, length.to_s)\n end\n end", "def add sha:, message:, branch_name:, author:\n local_branch_name = local_branch_name branch_name\n @commits[local_branch_name] ||= {}\n if @commits[local_branch_name].key? sha\n # We already have this commit in a different location --> just append the location to the existing commit\n @commits[local_branch_name][sha]['LOCATION'] << branch_location(branch_name)\n else\n # We don't have this commit in another location --> create an entry for this commit\n @commits[local_branch_name][sha] = commit_data local_branch_name: local_branch_name,\n branch_name: branch_name,\n message: message,\n sha: sha,\n author: author\n end\n end", "def test_add_existing_file\n @gitit.add('hello.txt', 'Hello, dsyph3r')\n @gitit.commit('modifying hello world')\n\n file = @gitit.get_file('hello.txt')\n\n assert_not_nil(file)\n\n assert_equal('Hello, dsyph3r', file['data'], 'File data is incorrect')\n end", "def msg(message)\n FileUtils.cd(@git_dir_path)\n\t# via http://ozmm.org/posts/git_msg.html\n # --allow-empty means git won't require a changed file; it will just store a\n # commit message.\n `git commit --allow-empty -m \"#{message}\" &>/dev/null`\n # Use sed to extract SHA1 hash from most recent log message\n hash = `git log master~1..master | sed -n '/commit/s/commit //p'`.chomp\n # Push to Github\n `git push origin master &>/dev/null`\n return hash\n end", "def image_commit(project, imagefile)\n if logged_in?\n commit project.path, imagefile.original_filename, imagefile.read, \"Add new file #{imagefile.original_filename}.\" \n end\n end", "def commit_modified_files_task\n really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split(\"\\n\")\n if really_modified.any?\n really_modified.each { |file| sh git, 'add', file }\n sh git, 'commit', '-m', \"Released #{gemspec.name} gem version #{gemspec.version}.\"\n end\n end", "def commit_file\n if @upload.public? && @upload.file_type.public? && @upload.address.blank? && (@upload.creating? || @upload.failed?)\n BlockchainCommitJob.perform_later(@upload.id)\n end\n end", "def add_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_add_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} add #{file_path}\"\n log.info(x) { \"[git] single file add command => #{git_add_cmd}\" }\n %x[#{git_add_cmd}];\n log.info(x) { \"[git] has added #{file_path} into the git repository.\" }\n\n end", "def commit_all(message)\n yield if block_given?\n\n git add: '.'\n git commit: %(-aqm \"#{message}\")\nend", "def test_version_message\n Repository.create()\n FileUtils.touch('.test_file1')\n a = ['.test_file1']\n Repository.add(a) \n Repository.commit()\n #Repository.version()\n end", "def write(message)\n f = open(@filename, 'a')\n f.puts(message)\n f.close()\n end", "def save_file(file, name = '')\n if name.size > 0\n filename = name + File.extname(file[:filename])\n else\n filename = file[:filename]\n end\n FileUtils.mkdir_p(attach_dir) unless File.exists?(attach_dir)\n new_file = File.join(attach_dir, filename)\n\n f = File.new(new_file, 'w')\n f.write(file[:tempfile].read)\n f.close\n\n commit_message = \"uploaded #{filename} for #{@name}\"\n begin\n $repo.add(new_file)\n $repo.commit(commit_message)\n rescue\n # FIXME why!??\n nil\n end\n end", "def commit\n rError = nil\n rCommitID = nil\n\n lStrPassword = ''\n if (@CommitPassword != nil)\n lStrPassword = \"--password #{@CommitPassword}\"\n end\n change_dir(@LocalRepository) do\n lOutput = `svn ci --message \"#{@Comment}\" --username #{@CommitUser} #{lStrPassword} #{@StrFiles}`.split(\"\\n\")\n lReturnCode = $?.exitstatus\n if (lReturnCode == 0)\n # Get back the revision number from the output\n lOutput.each do |iLine|\n lMatch = iLine.match(/^Committed revision (.*)\\.$/)\n if (lMatch != nil)\n rCommitID = lMatch[1].to_i\n end\n end\n if ((rCommitID == nil) or\n (rCommitID == 0))\n rError = CommitInvalidError.new(\"Failed to retrieve SVN commit revision. Here is the output: #{lOutput}\")\n end\n else\n rError = CommitConflictError.new(\"SVN returned error #{lReturnCode} upon commit.\")\n end\n end\n\n return rError, rCommitID\n end", "def in_branch(message = nil)\n old_ref = @repo.head\n checkout\n yield @repo\n\n if message\n @repo.commit_index message\n @repo.head.commit\n end\n ensure\n old_ref.checkout\n end", "def commit_all(index, last_commit, last_tree)\n callback = self.git_settings.commit_message\n # $stderr.puts self.git_settings.inspect\n message = case callback\n when Symbol\n self.send(callback)\n when Proc\n callback.call(self)\n else\n \"new version of #{self.class}, id: #{self.id.to_s}\" \n end\n lc = (last_commit ? [last_commit.id] : nil)\n index.commit(message, lc, @model_user)\n end", "def commit(id)\n @commit = @repo.commit(id)\n raise(Ginatra::InvalidCommit.new(id)) if @commit.nil?\n add_refs(@commit,{})\n @commit\n end", "def patch_gemfile(commit_message, options = {}, &block)\n filename = \"#{Dir.pwd}/Gemfile\"\n if File.exist?(filename)\n contents = IO.read(filename)\n new_contents = block.call(contents.dup)\n if contents != new_contents || options[:force]\n File.open(filename, 'wb') {|f| f.write new_contents}\n mysystem('rm -f Gemfile.lock')\n rbenv_exec('bundle install')\n mysystem('git add Gemfile')\n begin\n # Not all repos have lock files checked in\n mysystem('git ls-files Gemfile.lock --error-unmatch > /dev/null 2> /dev/null && git add Gemfile.lock')\n rescue\n end\n begin\n mysystem(\"git commit -m \\\"#{commit_message}\\\"\") unless options[:no_commit]\n rescue\n # The assumption is that we are here because there was no changes but :force was specified\n return false\n end\n return true\n end\n end\n false\n end", "def commit_message\n msg = (params[:message].nil? or params[:message].empty?) ? \"[no message]\" : params[:message]\n commit_message = { :message => msg }\n author_parameters = session['gollum.author']\n commit_message.merge! author_parameters unless author_parameters.nil?\n commit_message\n end", "def patch_file(file, &block)\n filename = \"#{Dir.pwd}/#{file}\"\n if File.exist?(filename)\n contents = IO.read(filename)\n new_contents = block.call(contents.dup)\n if contents != new_contents\n File.open(filename, 'wb') {|f| f.write new_contents}\n mysystem(\"git add #{file}\")\n return true\n end\n end\n false\n end", "def commit_message\n commit_message_lines.join\n end", "def commit\n File.open(file_path, \"w\") do |f|\n f.write(to_json)\n end\n end", "def commit_file(revision)\n c = @gerrit.commit(@id, revision)\n file = []\n file += c['parents'].map do |parent|\n \"Parent: #{parent['commit'][0..6]} (#{parent['subject']})\"\n end\n file += %w(committer author).map do |t|\n [\n \"#{t.capitalize}: #{c[t]['name']} <#{c[t]['email']}>\",\n \"#{t.capitalize}Date: #{c[t]['date']}\"\n ]\n end.flatten\n file << ''\n file << c['message']\n file.join(\"\\n\")\n end" ]
[ "0.8353085", "0.8353085", "0.78761", "0.758509", "0.7333082", "0.72248983", "0.7030328", "0.7003578", "0.6978619", "0.6968783", "0.6930752", "0.687088", "0.676969", "0.6609509", "0.64741194", "0.6428782", "0.6428287", "0.6417623", "0.64120424", "0.636832", "0.63641596", "0.6359647", "0.6359414", "0.6334588", "0.630783", "0.6296475", "0.62917674", "0.6288509", "0.62276816", "0.6223438", "0.6172448", "0.61693615", "0.61584514", "0.61560065", "0.6140987", "0.60825384", "0.6073413", "0.60559124", "0.60325825", "0.6008081", "0.60063946", "0.59832454", "0.59669596", "0.5936051", "0.58883786", "0.5848805", "0.5845637", "0.5790958", "0.57776445", "0.576948", "0.57631457", "0.57603765", "0.5744221", "0.5725794", "0.57123715", "0.56978154", "0.5683827", "0.56450886", "0.56294715", "0.5616794", "0.5602492", "0.5582545", "0.5580157", "0.55758315", "0.5565892", "0.5542929", "0.5540846", "0.5529712", "0.5522574", "0.5515517", "0.55066454", "0.5501487", "0.5482012", "0.54670703", "0.54537874", "0.5446061", "0.5440411", "0.5403271", "0.5399679", "0.53947693", "0.5387127", "0.5369761", "0.53630334", "0.5324524", "0.53156304", "0.531062", "0.53101367", "0.53091294", "0.5301557", "0.5282141", "0.52805656", "0.5272918", "0.5268784", "0.5263182", "0.52571154", "0.5249723", "0.5245253", "0.5222533", "0.5219905", "0.52174026" ]
0.6356128
23
Fails if one of these 2 conditions are not met: 1. the repository is clean: no content staged or unstaged 2. some remote repositories are defined but the current branch does not track any
def check super uncommitted = Perforce.uncommitted_files fail "Uncommitted files violate the First Principle Of Release!\n#{uncommitted.join("\n")}" unless uncommitted.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_repo_clean\n @gitrepo = Grit::Repo.new(@repo_root)\n status = @gitrepo.status\n if !status.changed.nil? || status.changed.size != 0 # This has to be a convoluted way to determine a non-empty...\n # Test each for the magic sha_index. Ref: https://github.com/mojombo/grit/issues/142\n status.changed.each do |file|\n case file[1].sha_index\n when '0' * 40\n ui.error 'There seem to be unstaged changes in your repo. Either stash or add them.'\n exit 4\n else\n ui.msg 'There are modified files that have been staged, and will be included in the push.'\n end\n end\n elsif status.untracked.size > 0\n ui.warn 'There are untracked files in your repo. You might want to look into that.'\n end\n end", "def check\n super\n info \"Working in branch '#{Hg.current_branch}'\"\n uncommitted = Hg.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n fail \"You are releasing from a local branch that does not track a remote!\" if Hg.remote.empty?\n end", "def check\n super\n uncommitted = Git.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n fail \"You are releasing from a local branch that does not track a remote!\" unless Git.remote\n end", "def check\n super\n uncommitted = Git.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n # fail \"You are releasing from a local branch that does not track a remote!\" unless Git.remote\n end", "def check_repo_status\n porcelain_status, = Executable.capture_command('git', %w(status --porcelain), :capture => :merge, :chdir => repo_dir)\n clean = porcelain_status == ''\n raise Informative, \"The repo `#{@repo}` at #{UI.path repo_dir} is not clean\" unless clean\n end", "def check_clean_status_task\n raise \"The current working copy contains modifications\" if `#{git} ls-files -m`.split(\"\\n\").any?\n end", "def clean_working_directory_check\n commit_count_check = `git status`\n if (!(commit_count_check.include? \"Your branch is up-to-date with 'origin/master'.\") &&\n !(commit_count_check.include? \"nothing to commit, working directory clean\")) ||\n (commit_count_check.include? \"Changes not staged for commit:\")\n abort(\"ABORTING... please commit and push any local changes before atte\"\\\n \"mpting to create a new tag\")\n end\n end", "def check_for_clean\n # can't believe there's not a simple yes/no here..\n out = `git status --porcelain`\n\n unless out.empty? then\n puts colorRed(\"you have uncommitted changes -- please commit and try again:\\r\\t#{out}\")\n exit\n end\n\n end", "def verify_non_destructive\n # Obviously non-destructive because we have a linear path.\n return if ancestor == @local_parent || ancestor == remote\n \n # At this point, they obviously are crossing a branch.\n \n if @local_parent.branch == remote.branch\n # Here's how this work: if you want to cross a *revision history branch* (not\n # a named branch), you have to do a branch merge. So that's not allowed.\n #\n # If dirty, print a special message about your changes\n if working_changeset.changed_files.any? || working_changeset.deleted.any?\n raise abort(\"crosses branches (use 'hg merge' or \"+\n \"'hg update -C' to discard changes)\")\n end\n # Otherwise, just let them know they can't cross branches.\n raise abort(\"crosses branches (use 'hg merge' or 'hg update -C')\")\n elsif working_changeset.changed_files.any? || working_changeset.deleted.any?\n # They're crossing to a named branch, but have a dirty working dir. not allowed.\n raise abort(\"crosses named branches (use 'hg update -C'\"+\n \" to discard changes)\")\n else\n # They just want to switch to a named branch. That's ok, as long as they\n # have no uncommitted changes.\n @overwrite = true\n end\n end", "def check_if_push_allowed\n if @source.is_a?(CDNSource)\n raise Informative, 'Cannot push to a CDN source, as it is read-only.'\n end\n\n remotes, = Executable.capture_command('git', %w(remote --verbose), :capture => :merge, :chdir => repo_dir)\n master_repo_urls = [\n 'git@github.com:CocoaPods/Specs.git',\n 'https://github.com/CocoaPods/Specs.git',\n ]\n is_master_repo = master_repo_urls.any? do |url|\n remotes.include?(url)\n end\n\n if is_master_repo\n raise Informative, 'To push to the CocoaPods master repo use ' \\\n \"the `pod trunk push` command.\\n\\nIf you are using a fork of \" \\\n 'the master repo for private purposes we recommend to migrate ' \\\n 'to a clean private repo. To disable this check remove the ' \\\n 'remote pointing to the CocoaPods master repo.'\n end\n end", "def has_remote_tracking_branch(repo)\n return false if $branch_name.empty?\n\n begin\n return !repo.branches[$remote_branch].nil?\n rescue\n return false\n end\nend", "def find_invalid_repos\n repos_with_issues = RepositorySet.new(\n Repositext::PARENT_DIR\n ).git_ensure_repos_are_ready(\n :all_content_repos\n ) { |repo_path| puts \" - #{ repo_path.split('/').last }\" }\n # TODO: Use #all_synced_foreign_repos instead of the RepositorySet method. Requires a refactoring.\n repos_with_issues += ensure_st_ops_filenames_are_valid\n if repos_with_issues.any?\n puts\n puts \"Could not proceed because the following git repositories are not ready:\".color(:red)\n puts\n repos_with_issues.each { |repo_path, issues|\n puts repo_path\n puts '-' * 40\n issues.each { |e| puts \" - #{ e }\".color(:red) }\n }\n puts\n raise ReposNotReadyError.new(\n \"\\n\\nCannot proceed with synching subtitles until all content repos are clean!\".color(:red)\n )\n end\n true\n end", "def clean_local_branch\n run_and_success?(\"#{git} show-branch #{ref} > /dev/null 2>&1 && #{git} branch -D #{ref} > /dev/null 2>&1\")\n end", "def check_not_diverged_task\n raise \"The current branch is diverged from the remote branch!\" if `#{git} rev-list HEAD..#{remote}/#{remote_branch}`.split(\"\\n\").any?\n end", "def check_branch\n same_branch = `git branch -a` =~ /\\* #{@branch}/\n\n if current_remote = `git remote -v`.match(/\\s\\S+/)\n same_remote = current_remote[0].match(/#{@repo}/)\n end\n\n if same_remote && same_branch\n puts \"Deploy to #{@branch} canceled:\".red\n puts \"You cannot deploy to the same branch you are working in. This will overwrite the source for your site.\\n\"\n puts \"First, back up your site's source to a branch:\"\n puts \"\\n git checkout -b source\".yellow\n puts \" git push origin source\".yellow\n puts \"\\nWith that, you'll work in the #{\"source\".bold} branch and deploy to the #{@branch.bold} branch.\"\n abort\n end\n end", "def check_that_current_branch_is_up_to_date_with_origin_master\n return true if options['skip-git-up-to-date-check']\n git_repo = Repositext::Repository.new\n latest_commit_sha_remote = git_repo.latest_commit_sha_remote\n begin\n latest_local_commit = git_repo.lookup(latest_commit_sha_remote)\n rescue Rugged::OdbError => e\n # Couldn't find remote's latest commit in local repo, raise error\n raise GitRepoNotUpToDateError.new([\n '',\n \"Your local '#{ git_repo.current_branch_name }' branch is not up-to-date with origin/master.\",\n 'Please get the updates from origin/master first before running a repositext command.',\n 'You can bypass this check by appending \"--skip-git-up-to-date-check=true\" to the repositext command'\n ].join(\"\\n\"))\n end\n end", "def needs_pushing?(dir = Dir.pwd)\n rval = false\n branch = get_branch\n if is_origin_branch? branch\n Dir.chdir(dir) do\n rval = (%x{git diff \"#{branch}\"..origin/\"#{branch}\"}.size > 0)\n end\n end\n rval\nend", "def validate_target_remote_branch\n remote_path = File.join(config[:remote], config[:branch])\n\n remotes = []\n @gitrepo.remotes.each { |remote| remotes << remote.name }\n unless remotes.include?(remote_path)\n ui.error 'The remote/branch specified does not seem to exist.'\n exit 7\n end\n end", "def nothing_to_commit?\n Dir.chdir @root do\n cmd = \"git status\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n # Check if status indicates nothing to commit\n return /nothing to commit/.match stdout\n end\n end", "def check_git_repo\n # check local dir\n\n # use Open3 in order to get stderr output from child process\n # `` syntax only returns stdout output which is not enough\n\n # since command are all executed in newly spawned child processes so there's no need to record old dir path\n stdout, stderr = Open3.popen3(\"cd #{@local_path} && git status\")[1..2]\n\n local_branch_name = stdout.gets.to_s.match(/^On branch ([^\\s]+)/)[1]\n unless local_branch_name\n raise GitRepoException, \"local path #{@local_path} is not a git repository\"\n end\n\n # check remote dir\n valid = true\n remote_branch_name = ''\n @ssh.exec!(\"cd #{@remote_path} && git status\") do |ch, stream, data|\n case stream\n when :stdout\n valid = false unless (remote_branch_name = data.match(/^On branch ([^\\s]+)/)[1])\n when :stderr\n valid = false unless (data.nil? or data == '')\n end\n end\n unless valid\n raise GitRepoException, \"remote path #{@remote_path} is not a git repository\"\n end\n\n # check match\n if local_branch_name != remote_branch_name\n raise GitRepoException, \"local branch(#{local_branch_name}) and remote branch(#{remote_branch_name}) don't match\"\n end\n end", "def git_reset_if_unchanged(branch = \"origin/#{git_current_branch}\")\n if git_has_remote_branch?(branch) && Zim.cwd_has_unpushed_changes? && `git diff #{branch} 2>&1`.split(\"\\n\").size == 0\n git_reset_branch(branch)\n end\n end", "def nothing_to_commit?\n @git.status do |file, status|\n return false unless status.empty?\n end\n return true\n end", "def unmerged_commits?(branch_name, verbose = true)\n locations = []\n locations << ['', ''] if branch_exists?(:local, branch_name)\n locations << ['origin/', 'origin/'] if branch_exists?(:remote, branch_name)\n locations = locations + [['', 'origin/'], ['origin/', '']] if locations.size == 2\n if locations.empty?\n puts 'Nothing to do. All cleaned up already.' if verbose\n return false\n end\n # Compare remote and local branch with remote and local master.\n responses = locations.collect do |location|\n git_call \"cherry #{location.first}#{target_branch} #{location.last}#{branch_name}\"\n end\n # Select commits (= non empty, not just an error message and not only duplicate commits staring with '-').\n unmerged_commits = responses.reject do |response|\n response.empty? or response.include?('fatal: Unknown commit') or response.split(\"\\n\").reject { |x| x.index('-') == 0 }.empty?\n end\n # If the array ain't empty, we got unmerged commits.\n if unmerged_commits.empty?\n false\n else\n puts \"Unmerged commits on branch '#{branch_name}'.\"\n true\n end\n end", "def should_handle?\n build.repo_source? && build.master_branch? && build.success?\n end", "def verify_valid_branch_merge\n # trying to merge backwards with a direct ancestor of the current directory.\n # that's crazy.\n if ancestor == remote\n raise abort(\"can't merge with ancestor\")\n elsif ancestor == @local_parent\n # If we're at the branch point, without a difference in branch names, just do an update.\n # Kind of the opposite of the last case, only isntead of trying to merge directly backward,\n # we're trying to merge directly forward. That's wrong.\n if @local_parent.branch == remote.branch\n raise abort(\"nothing to merge (use 'amp update' or check\"+\n \" 'amp heads')\")\n end\n end\n # Can't merge when you have a dirty working directory. We don't want to lose\n # those changes!\n if !force && (working_changeset.changed_files.any? || working_changeset.deleted.any?)\n raise abort(\"oustanding uncommitted changes\")\n end\n end", "def git_check\n # May throw InvalidRepositoryException\n # - because of invalid path\n # - or broken git repository\n @repo = GitLib::Repo.new(path)\n end", "def anything_changed?\n @any_changes ||=\n ! @status.match(/nothing to commit.*working directory clean/)\n end", "def has_untracked_changes? \n not [repo.changed, repo.untracked].flatten.select do |k| \n k.include?(\".craft\") || k.eql?(\"persistent.sfs\") || k.eql?(\"quicksave.sfs\") \n end.empty?\n end", "def backported_from_master?\n branch != 'origin/master' && self.class.exists?(:branch => 'origin/master', :message => message, :author => author)\n end", "def handle_repo_push_request\n return unless @repository\n\n branch_name = payload[\"ref\"].sub(%r{\\Arefs/heads/}, '')\n branch = @repository.branches.where(name: branch_name).first\n if branch.present? && branch.convergence? && @repository.run_ci?\n sha = payload[\"after\"]\n branch.kickoff_new_build_unless_currently_busy(sha)\n end\n end", "def ensure_all_content_repos_are_ready\n find_invalid_repos\n find_invalid_primary_st_ops_filenames\n end", "def test_repo_valid\n post '/repos', {:name => GIT_REPO}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"rune@runemadsen.com\", :message => \"My First Commit\"}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There Again\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"rune@runemadsen.com\", :message => \"My First Commit\"}\n `git clone #{path} /tmp/test`\n status = $?.to_i\n assert_equal(0, status)\n FileUtils.rm_rf \"/tmp/test\"\n end", "def test_no_gitgo_no_remote_gitgo\n assert !sh(b, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"shasum\") {|io| io << \"content\" }\n sh(b, 'git add shasum')\n sh(b, 'git commit -m \"added document\"')\n \n sh(b, 'git checkout master')\n sh(b, 'git push origin gitgo')\n \n assert sh(b, 'git branch').include?('gitgo') \n assert sh(a, 'git branch').include?('gitgo')\n \n sh(a, 'git checkout gitgo')\n assert_equal \"content\", File.read(method_root.path(a, \"shasum\"))\n end", "def shouldnt_count_as_a_contribution?\n merge? || backported_from_master?\n end", "def git_repo?\n !repository_root.to_s.empty?\n end", "def check_repo(url)\n output = `git ls-remote #{url} 2>&1`\n if ($? != 0)\n raise BadRepo.new(url + \"<<<\" + output.to_s + \">>>\")\n end\n end", "def validate_in_repo\n unless File.exist?('.git')\n raise NotInAGitRepository, \"We don't appear to be inside a Git repository!\"\n end\n end", "def needs_checkout?\n expected = ref.sha1\n actual = rev_parse('HEAD')\n\n ! (expected == actual)\n end", "def git_has_remote_branch?(branch)\n `git config branch.#{branch}.merge`.strip == ''\n end", "def anything_to_commit?(directory)\n directory && false\n end", "def verify_no_uncommitted_merge\n if !overwrite? && @working_changeset.parents.size > 1\n raise abort(\"outstanding uncommitted merges\")\n end\n end", "def check!\n # does not inherit any dependencies (super.check will inherit)\n Dependencies.new(configuration) do |d|\n d.remote.directory(configuration[:deploy_to]).or(\"`#{configuration[:deploy_to]}' does not exist.\")\n d.remote.writable(configuration[:deploy_to], :via => :sudo).or(\"You do not have permissions to write to `#{configuration[:deploy_to]}'.\")\n d.remote.command(\"svn\")\n d.remote.match(\"cd #{repository_dir}; svn info|grep URL\", configuration[:repository])\n end\n end", "def ensure_cloned(repository_url)\n repository_url && :not_implemented\n end", "def fetch_update\n remote_branch = ErrorEmittingExecutor.execute(\"git branch -r --list origin/#{BRANCH_NAME}\")\n if remote_branch == 'origin/cocina-level2-updates'\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS} #{GIT_BRANCH_FETCH_REFS}\")\n else\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS}\", exit_on_error: true)\n end\nend", "def needs_commit?(dir = Dir.pwd, file = nil)\n rval = false\n Dir.chdir(dir) do\n status = %x{git status}\n if file.nil?\n rval = true unless status =~ /nothing to commit \\(working directory clean\\)|nothing added to commit but untracked files present/\n if status =~ /nothing added to commit but untracked files present/\n puts \"WARNING: untracked files present in #{dir}\"\n show_changed_files(status)\n end\n else\n rval = true if status =~ /^#\\t.*modified: #{file}/\n end\n end\n rval\nend", "def dirty?(exclude_spec=false)\n repo_status = false\n\n return repo_status unless File.directory?(path)\n\n Dir.chdir(path) do\n %x(git update-index -q --ignore-submodules --refresh)\n repo_status = \"Could not update git index for '#{path}'\" unless $?.success?\n\n unless repo_status\n %x(git diff-files --quiet --ignore-submodules --)\n repo_status = \"'#{path}' has unstaged changes\" unless $?.success?\n end\n\n unless repo_status\n %x(git diff-index --cached --quiet HEAD --ignore-submodules --)\n repo_status = \"'#{path}' has uncommitted changes\" unless $?.success?\n end\n\n unless repo_status\n # Things that may be out of date but which should stop the updating\n # of the git repo\n our_exclusions=[\n 'build/rpm_metadata',\n 'dist/'\n ]\n\n untracked_files = %x(git ls-files -o -d --exclude-standard --exclude=#{our_exclusions.join(' --exclude=')})\n\n if $?.success?\n unless untracked_files.empty?\n untracked_files.strip!\n\n if untracked_files.lines.count > 0\n repo_status = \"'#{path}' has untracked files\"\n end\n end\n else\n # We should never get here\n raise Error, \"Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'\"\n end\n end\n end\n\n repo_status\n end", "def enabled?\n (super ||\n !@remote_path.nil? && @remote_path.directory? ||\n local_valid_repo?)\n end", "def validate_repo(repo)\n repo_valid = true\n if /review\\.fuel-infra\\.org/.match(repo).nil? and /github\\.com\\/fuel-infra/.match(repo).nil?\n repo_valid = false\n end\n repo_valid\n end", "def git_rescue\n @logger.error \"Branch or ref does not exist\"\n end", "def usable_repository?\n repository_cache.directory? &&\n run_and_output(\"#{git} remote -v | grep origin\").include?(uri)\n end", "def validate_ref(repo, ref)\n ref_valid = true\n cmd = \"git ls-remote --tags --exit-code #{repo} #{ref} >/dev/null\"\n system(cmd)\n if $?.exitstatus != 0\n ref_valid = false\n end\n ref_valid\n end", "def empty?\n @hg_client.repository_empty?\n end", "def push_repo_changes_aux(repo, opts={})\n diffs = DiffSummary.new()\n\n # adding untracked files (newly added files)\n repo.stage_changes()\n\n # commit if there has been changes\n if repo.changed?\n repo.commit(opts[:commit_msg]||\"Pushing changes from client\") #TODO: make more descriptive\n end\n\n if opts[:remote_repo] and opts[:remote_repo_url]\n repo.add_remote(opts[:remote_repo],opts[:remote_repo_url])\n end\n\n unless opts[:no_fetch]\n repo.fetch(remote(opts[:remote_repo]))\n end\n\n local_branch = repo.local_branch_name\n\n remote_branch_ref = remote_branch_ref(local_branch, opts)\n\n #check if merge needed\n commit_shas = Hash.new\n merge_rel = repo.merge_relationship(:remote_branch,remote_branch_ref, :ret_commit_shas => commit_shas)\n commit_sha = nil\n diffs = DiffSummary.new_version(repo)\n\n if merge_rel == :equal\n commit_sha = commit_shas[:other_sha]\n elsif [:branchpoint,:local_behind].include?(merge_rel)\n if opts[:force]\n diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)\n if diffs.any_diffs?()\n repo.push(remote_branch_ref, {:force => opts[:force]})\n end\n commit_sha = repo.find_remote_sha(remote_branch_ref)\n else\n where = opts[:where] || 'server'\n msg = \"Merge needed before module (#{pp_module(repo)}) can be pushed to #{where}. \"\n if where.to_sym == :catalog\n msg << \" Either a merge into the local module can be done with pull-dtkn command, followed by push-dtkn or force\"\n else\n msg << \"Force\"\n end\n msg << \" push can be used with the '--force' option, but this will overwrite remote contents\"\n raise ErrorUsage.new(msg)\n end\n elsif merge_rel == :no_remote_ref\n repo.push(remote_branch_ref)\n commit_sha = commit_shas[:local_sha]\n elsif merge_rel == :local_ahead\n # see if any diffs between fetched remote and local branch\n # this has be done after commit\n diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)\n\n if diffs.any_diffs?()\n repo.push(remote_branch_ref, {:force => opts[:force]})\n end\n\n commit_sha = repo.find_remote_sha(remote_branch_ref)\n else\n raise Error.new(\"Unexpected merge_rel (#{merge_rel})\")\n end\n\n {\"diffs\" => diffs, \"commit_sha\" => commit_sha, \"repo_obj\" => repo}\n end", "def has_repo?(local_param)\n !list.find { |r| r.param == local_param }.nil?\n end", "def check_duplicata_pr_branch(pr)\n puts `git branch --list #{pr}`\n `git branch -D #{pr} 2>/dev/null` if $CHILD_STATUS.exitstatus.zero?\n end", "def alert_reserved_and_exit\n cli.say \"The current branch #{config.github_repo}/#{git.current_branch} is a reserved branch and can not have pull requests.\"\n exit 1\n end", "def uncommitted_changes?\n inform \"Checking for any uncommitted changes...\"\n if nothing_to_commit?\n inform \"All changes committed :)\"\n false\n else\n inform \"You have uncommitted changes. Please commit them first, then run `rake release` again.\"\n true\n end\n end", "def validate_repo\n @repo_root = shellout('git rev-parse --show-toplevel').stdout.chomp\n rescue Exception => e\n ui.error \"There doesn't seem to be a git repo at #{@cb_path}\\n#{e}\"\n exit 3\n end", "def pristine?; changes.empty?; end", "def check\n puts \"#{name}...\"\n unreleased = 0\n Dir.chdir(CONFIG_DIR) do\n `git clone #{envs.first['git']} --bare #{name} > /dev/null 2>&1`\n Dir.chdir(name) do\n envs.each do |env|\n `git remote add #{env['name']} #{env['git']} > /dev/null 2>&1`\n `git fetch #{env['name']} > /dev/null 2>&1`\n end\n envs.each_cons(2) do |ahead, behind|\n log = `git log #{behind['name']}/#{behind['branch'] || 'master'}..#{ahead['name']}/#{ahead['branch'] || 'master'} --pretty=format:\"%h %ad %s (%an)\" --date=short --no-merges`\n if log == ''\n puts \" #{behind['name']} is up-to-date with #{ahead['name']}\\n\"\n else\n puts \" #{behind['name']} is behind #{ahead['name']} by:\"\n log.lines.each { |l| puts \" #{l}\" }\n unreleased += 1\n end\n end\n end\n end\n unreleased\n end", "def track_missing\n lbranches = local_branches\n dbg \"track_missing: local branches = #{lbranches.join(', ')}\"\n remote = remote_name\n added = []\n remote_branches.reject { |b| /HEAD/.match(b) }.each do |branch|\n dbg \" considering remote branch #{branch}\"\n lbranch = branch.sub(/^#{remote}\\//, '')\n dbg \" local branch name would be #{lbranch}\"\n unless lbranches.include? lbranch\n dbg \" not already tracking #{lbranch}\"\n added << lbranch\n track lbranch\n end\n end\n added\n end", "def test_clean_checkout_should_not_remove_tracked_files\n with_sandboxed_git do |proj_dir, git|\n tracked_file = File.join(proj_dir, 'tracked.txt')\n FileUtils.touch tracked_file\n sandbox_git_add_and_commit(proj_dir, File.basename(tracked_file))\n untracked_file = File.join(proj_dir, 'untracked.txt')\n git.clean_checkout\n assert File.exist? tracked_file\n assert_false File.exist? untracked_file\n end\n end", "def is_valid_for_execution\n (@metadata[\"short_dest_repo_name\"] == \"osrf/gazebo\" and @pr_status == :update) ? false : true\n end", "def recent_branches_strict\n\t\tbranches = `git branch -a`.gsub!(/^\\*?\\s+|\\(no branch\\)\\s*/, \"\").split(/\\n/).map {|i|\n\t\t\ti.split(/ -> /)[0]\n\t\t}\n\t\tretrieve_branch_details(branches)\n\tend", "def reset_remote_repo\n @ssh.exec! \"cd #{@remote_path} && git reset --hard\" do |ch, stream, data|\n if stream == :stderr and data.to_s != '' # check for nil or ''\n raise GitResetException, \"Reset failed: #{data}\"\n end\n end\n end", "def check_current_branch_task\n raise \"Currently not on #{local_branch} branch!\" unless `#{git} branch`.split(\"\\n\").detect { |b| /^\\* / =~ b } == \"* #{local_branch}\"\n end", "def clone_repos repos\n $logger.info \"Detecting if clones repos #{repos}\"\n failed_repos = []\n repos.each do |repo|\n repo_path = \"#{GIT_DIR}/#{repo}\"\n # TODO: Use ssh instead of http\n clone_url = \"http://#{GIT_USER}:#{GIT_PASSWORD}@#{BASE_GIT_URL}:#{BASE_GIT_PORT}/scm/#{PROJECT_ID}/#{repo}.git\"\n unless `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' config --get remote.origin.url`.to_s.strip == clone_url\n $logger.info \"No git repo found or invalid git repo detected at #{repo_path}. Deleting and recloning project #{repo}\"\n # If for some reason we didn't detect that it's a git repo, just clear the whole directory\n # And reclone (note that we only need to clone the latest commit on the master branch)\n successfully_cloned = system \"git clone #{clone_url} --branch master --single-branch --depth 1 #{repo_path}\"\n unless successfully_cloned\n $logger.warn \"Could not git clone repo #{clone_url} to #{repo_path}\"\n failed_repos.push repo\n FileUtils.rm_rf repo_path\n end\n end\n # Make sure the git repos are unmodified before we do anything\n `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' reset --hard HEAD`\n end\n $logger.info \"Removing failed repos #{failed_repos}\"\n repos -= failed_repos\n return repos\nend", "def git_pull\n if `git branch -a` =~ /remotes\\/#{@remote}\\/#{@branch}/ ||\n `git ls-remote #{@remote}` =~ /refs\\/heads\\/#{@branch}/\n `git pull #{@remote} #{@branch}`\n end\n end", "def local_valid_repo?\n @local_dir_path.directory?\n end", "def update\n unless ENV.has_key? 'MWV_NO_UPDATE' or File.exist?($VP + 'no-update')\n system('git fetch origin') if Time.now - File.mtime($VP + '.git/FETCH_HEAD') > 604800 rescue nil\n end\nend", "def skip_sync?\n if R8::Config[:node_agent_git_clone][:mode] == 'skip'\n return true\n end\n skip_sync = nil\n @head_git_commit_id = nil #nil means dont skip\n installed_agent_git_commit_id = @node.get_field?(:agent_git_commit_id)\n begin\n # TODO: ran into obscure problem when github is down; below does not work\n @head_git_commit_id = AgentGritAdapter.get_head_git_commit_id()\n if R8::Config[:node_agent_git_clone][:mode] == 'debug'\n installed_agent_git_commit_id = @node[:agent_git_commit_id] = nil\n end\n rescue => e\n Log.error(\"Error trying to get most recent sync agent code (#{e}); skipping the sync\")\n skip_sync = { error: true }\n end\n skip_sync || ((@head_git_commit_id == installed_agent_git_commit_id) && { error: false })\n end", "def test_gitgo_different_from_remote_gitgo\n assert !sh(a, 'git branch -a').include?('gitgo')\n assert !sh(b, 'git branch -a').include?('gitgo')\n assert !sh(c, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"bshasum\") {|io| io << \"b content\" }\n sh(b, 'git add bshasum')\n sh(b, 'git commit -m \"added document\"')\n \n # setup remote from c\n sh(c, 'git branch gitgo')\n sh(c, 'git checkout gitgo')\n method_root.prepare(c, \"cshasum\") {|io| io << \"c content\" }\n sh(c, 'git add cshasum')\n sh(c, 'git commit -m \"added document\"')\n sh(c, 'git push origin gitgo')\n \n # now try to push back, fails\n assert sh(b, 'git push origin gitgo').include?(\"! [rejected] gitgo -> gitgo (non-fast forward)\")\n \n sh(a, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # merge\n sh(b, 'git fetch')\n assert sh(b, 'git branch').include?('gitgo')\n assert sh(b, 'git branch -a').include?('origin/gitgo')\n sh(b, 'git merge origin/gitgo')\n \n # now push works\n sh(b, 'git push origin gitgo')\n sh(a, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # fetch for c leaves changes unmerged\n sh(c, 'git fetch')\n sh(c, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n \n # manual merge fixes\n sh(c, 'git merge gitgo origin/gitgo')\n sh(c, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n end", "def ci_errors?(pr)\n not travis.find_all{|b| b[:pull_req] == pr[:github_id] and b[:status] == 'errored'}.empty?\n end", "def test_read_files_wrong_repo\n get \"/repos/#{GIT_REPO}.git/branches/master/files/myfile.txt\"\n assert_equal 404, last_response.status\n end", "def fetch_latest_revision(m)\n Open3.popen3(\"cd #{FANCY_DIR} && git pull origin master\") do |stdin, stdout, stderr|\n err_lines = stderr.readlines\n if err_lines.size > 0\n # only print error lines if we're not dealing with an\n # already-up-to-date-message.\n unless err_lines.all?{|l| l !~ /Already up-to-date./}\n m.reply \"Got error while trying to update from repository:\"\n err_lines.each do |l|\n m.reply l.chomp\n end\n m.reply \"Won't/Can't build or run tests.\"\n return false # done since error\n end\n end\n end\n return true\n end", "def file_in_repo?(js_name)\n # Start-Open3\n Open3.popen3(\"git ls-files #{js_name} --error-unmatch\") do |stdin, stdout, stderr|\n # Start-If: Check if job script is committed in git repo \n if stderr.read.empty?\n return true\n else\n puts \"Please commit #{js_name} to the repository before qsub-ing it!\"\n return false\n end\n # End-If Check if job script is committed in git repo\n end\nend", "def verify_valid_update\n if branch_merge\n verify_valid_branch_merge\n elsif !overwrite?\n verify_non_destructive\n end\n end", "def merge?(treeish=upstream_branch)\n sandbox do |git, work_tree, index_file|\n des, src = safe_rev_parse(branch, treeish)\n \n case\n when src.nil? then false\n when des.nil? then true\n else des != src && git.merge_base({}, des, src).chomp(\"\\n\") != src\n end\n end\n end", "def test_git_log_can_have_no_changes\n assert_equal(0, extract_change_count_from_git_log(\"\"))\n end", "def branches?\n ! branch_targets.empty?\n end", "def test_remove_the_same_file_in_both_repos\n a.rm(\"one\").commit(\"a removed one\")\n b.rm(\"one\").commit(\"b removed one\")\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\",\n \"b removed one\",\n \"gitgo merge of origin/gitgo into gitgo\"\n ], b\n end", "def removed?\n branch == BASE\n end", "def test_branches_all\n branches = @lib.branches_all\n assert(branches.size > 0)\n assert(branches.select { |b| b[1] }.size > 0) # has a current branch\n assert(branches.select { |b| /\\//.match(b[0]) }.size > 0) # has a remote branch\n assert(branches.select { |b| !/\\//.match(b[0]) }.size > 0) # has a local branch\n assert(branches.select { |b| /master/.match(b[0]) }.size > 0) # has a master branch\n end", "def same_repo_pull_request?\n # When we're starting to archive payloads after N months we'll also disallow\n # restarting builds older than N months. Once we do so we can also return\n # false if Scheduler.config.enterprise is not true.\n\n # It's not the same repo PR if repo names don't match\n return false if head_repo_vcs_id != repository.vcs_id\n # It may not be the same repo if head_ref or head_sha are missing\n return false if head_ref.nil? or head_sha.nil?\n # It may not be same repo PR if ref is a commit\n return false if head_sha =~ /^#{Regexp.escape(head_ref)}/\n true\n rescue => e\n Travis::Scheduler.logger.error \"[request:#{id}] Couldn't determine whether pull request is from the same repository: #{e.message}\"\n false\n end", "def clean_working_tree?\n rugged.status do |_file, status|\n next if status.include?(:ignored)\n return false\n end\n true\n end", "def initial_commit?\n !Overcommit::Utils.execute(%w[git rev-parse HEAD]).success?\n end", "def initial_commit?\n !Overcommit::Utils.execute(%w[git rev-parse HEAD]).success?\n end", "def status\n @status ||= @repo.status(:unknown => true)\n end", "def test_integration_branch_is_optional\n modified_payload = modify_payload(payload)\n svc = service({'server_url' => 'nowhere', 'username' => 'someone', 'password' => '12345', 'central_repository' => '1'}, modified_payload)\n svc.xmlrpc_client = @server\n svc.receive_push\n\n assert @server.closed_bugs.include?(1)\n assert @server.bug_posts.include?(4)\n end", "def correct_setup?\n return required_keys_and_proper_remote_configuration_repo? &&\n local_configuration_repo_exists?\n end", "def git_clone_main\n raise \"oops, not done\"\nend", "def pr_is_intra_branch(req)\n return false unless pr_has_head_repo(req)\n\n if req['head']['repo']['owner']['login'] ==\n req['base']['repo']['owner']['login'] and\n req['head']['repo']['full_name'] == req['base']['repo']['full_name']\n true\n else\n false\n end\n end", "def repo_exists?(repo_id)\n return false if repo_id == nil || repo_id == false # It actually returns true without this conditon.\n app_client.repository?(repo_id)\nend", "def perform\n git.if_clean do\n check_out_branch\n merge_pull_request\n comment_about_merge\n end\n rescue => e\n case e\n when GitHub::PullRequest::NotFound\n cli.say \"Unable to find pull request #{pull_request_id}. Please retry with a valid ID.\"\n when Git::MergeFailed\n cli.say \"Merge failed. Please identify the source of this merge conflict resolve this conflict in your pull request's branch. NOTE: Merge conflicts resolved in the #{branch_type} branch are NOT used when deploying.\"\n when Git::CheckoutFailed\n cli.say \"Checkout of #{branch_to_merge_into} failed. Please contact Infrastructure to determine the cause.\"\n when GitHub::PullRequest::CommentFailed\n cli.say \"Unable to write comment. Please navigate to #{pull_request.url} and add the comment, '#{comment_body}'\"\n else\n cli.say \"An unknown error occurred: #{e.inspect}\"\n end\n raise\n end", "def merged_with_git?(pr)\n\n #1. Commits from the pull request appear in the master branch\n q = <<-QUERY\n\t select c.sha\n from pull_request_commits prc, commits c\n\t where prc.commit_id = c.id\n\t\t and prc.pull_request_id = ?\n QUERY\n db.fetch(q, pr[:id]).each do |x|\n unless @all_commits.select { |y| x[:sha].start_with? y }.empty?\n return [true, :commits_in_master]\n end\n end\n\n #2. The PR was closed by a commit (using the Fixes: convention).\n # Check whether the commit that closes the PR is in the project's\n # master branch\n unless @closed_by_commit[pr[:github_id]].nil?\n sha = @closed_by_commit[pr[:github_id]]\n unless @all_commits.select { |x| sha.start_with? x }.empty?\n return [true, :fixes_in_commit]\n end\n end\n\n comments = issue_comments(pr[:login], pr[:project_name], pr[:github_id])\n\n comments.reverse.take(3).map { |x| x['body'] }.uniq.each do |last|\n # 3. Last comment contains a commit number\n last.scan(/([0-9a-f]{6,40})/m).each do |x|\n # Commit is identified as merged\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ied)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :commit_sha_in_comments]\n else\n # Commit appears in master branch\n unless @all_commits.select { |y| x[0].start_with? y }.empty?\n return [true, :commit_sha_in_comments]\n end\n end\n end\n\n # 4. Merg[ing|ed] or appl[ing|ed] as last comment of pull request\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ed)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :merged_in_comments]\n end\n end\n\n [false, :unknown]\n end", "def merged_with_git?(pr)\n\n #1. Commits from the pull request appear in the master branch\n q = <<-QUERY\n\t select c.sha\n from pull_request_commits prc, commits c\n\t where prc.commit_id = c.id\n\t\t and prc.pull_request_id = ?\n QUERY\n db.fetch(q, pr[:id]).each do |x|\n unless @all_commits.select { |y| x[:sha].start_with? y }.empty?\n return [true, :commits_in_master]\n end\n end\n\n #2. The PR was closed by a commit (using the Fixes: convention).\n # Check whether the commit that closes the PR is in the project's\n # master branch\n unless @closed_by_commit[pr[:github_id]].nil?\n sha = @closed_by_commit[pr[:github_id]]\n if not @all_commits.select { |x| sha.start_with? x }.empty?\n return [true, :fixes_in_commit]\n end\n end\n\n comments = issue_comments(pr[:login], pr[:project_name], pr[:github_id])\n\n comments.reverse.take(3).map { |x| x['body'] }.uniq.each do |last|\n # 3. Last comment contains a commit number\n last.scan(/([0-9a-f]{6,40})/m).each do |x|\n # Commit is identified as merged\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ied)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :commit_sha_in_comments]\n else\n # Commit appears in master branch\n unless @all_commits.select { |y| x[0].start_with? y }.empty?\n return [true, :commit_sha_in_comments]\n end\n end\n end\n\n # 4. Merg[ing|ed] or appl[ing|ed] as last comment of pull request\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ed)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :merged_in_comments]\n end\n end\n\n [false, :unknown]\n end", "def pr_has_head_repo(req)\n not req['head']['repo'].nil?\n end", "def is_git?\n `git status 2> /dev/null` != \"\"\nend", "def process_pr(pr, cmd)\n head = pr[:head]\n repo = head[:repo]\n\n pending_status(pr, 'Merge in progress.')\n\n return true if skip_pr?(pr)\n\n begin\n cmd.run 'git fetch', repo[:ssh_url], head[:ref] if repo\n\n merge_status = cmd.run! 'git merge --no-ff --no-edit', head[:sha]\n\n if merge_status.success?\n success_status(pr, \"Merge with '#{@base_branch}' was successful.\")\n else\n cmd.run 'git merge --abort'\n\n message = \"Failed to merge '#{head[:ref]} with #{@base_branch}.\"\n failure_status(pr, message)\n end\n rescue => e\n failure_status(pr, \"Merge encountered an error: #{e.message}.\")\n\n return false\n end\n\n true\n end", "def sync_addon_branch_to_blessed_repo(repoName, remoteBranch, localBranch, pushForce = false)\n self.log(INFO,repoName,\"Checkout #{remoteBranch} branch (it is perhaps not the default) for #{repoName}...\")\n s = system(\"git checkout #{localBranch}\")\n if !s\n print(\"[ERROR] No #{remoteBranch} branch in repository #{repoName}, Skip this repo!!!\\n\")\n self.log(INFO,repoName,\"Done.\")\n # Let's process the next one\n else\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Reset #{localBranch} to #{remoteBranch} for #{repoName} ...\")\n s = system(\"git reset --hard #{remoteBranch}\")\n if !s\n abort(\"[ERROR] Reset #{localBranch} to #{remoteBranch} for #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Push #{localBranch} branch content from exo-addons repository to blessed repository ...\")\n\n forceParam = \"\"\n if pushForce\n forceParam = \"--force\"\n end\n\n s = system(\"git push #{forceParam} blessed #{localBranch}\")\n if !s\n abort(\"[ERROR] Push of #{localBranch} branch updates to repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n end\n end" ]
[ "0.7559468", "0.727234", "0.7259476", "0.72218883", "0.7090443", "0.70489347", "0.69626975", "0.6953265", "0.6695067", "0.66317797", "0.6629588", "0.66195047", "0.65545267", "0.6515617", "0.6476684", "0.6381038", "0.63756263", "0.63606435", "0.6317604", "0.62510467", "0.62278086", "0.6217012", "0.6206398", "0.61965114", "0.6163267", "0.6161858", "0.6119553", "0.6106236", "0.60702693", "0.604189", "0.60306466", "0.6020509", "0.5988366", "0.59756124", "0.59468013", "0.5946297", "0.5927791", "0.5915279", "0.5914954", "0.5906029", "0.5904693", "0.5884659", "0.5863698", "0.586043", "0.5847464", "0.58372897", "0.5811816", "0.5811753", "0.5803741", "0.5794705", "0.5767549", "0.57427853", "0.5740598", "0.57391614", "0.5732616", "0.5715631", "0.5682712", "0.5680536", "0.5673134", "0.56723547", "0.5663747", "0.5662645", "0.5645015", "0.5633604", "0.5633193", "0.5618131", "0.560434", "0.5594661", "0.55891806", "0.5587807", "0.55858964", "0.5573927", "0.55709994", "0.55641025", "0.5558194", "0.5552511", "0.5546312", "0.55457395", "0.55438507", "0.55263525", "0.55246997", "0.5511576", "0.5504328", "0.5488053", "0.54805565", "0.5478899", "0.5478899", "0.54748577", "0.5471419", "0.54702955", "0.54655254", "0.54600865", "0.54410285", "0.54393643", "0.5439344", "0.543258", "0.5430518", "0.5424406", "0.5409432", "0.5406107" ]
0.64117765
15
Add a tag reference in .git/refs/tags and push it to the remote if any. If a tag with the same name already exists it will get deleted (in both local and remote repositories).
def tag_release(tag) unless this_version == extract_version puts "Committing buildfile with version number #{extract_version}" Perforce.p4 'edit', Rake.application.rakefile.to_s Perforce.commit message end puts "Tagging release #{tag}" Perforce.p4 'tag', '-l', tag, "//#{ENV['P4CLIENT']}/..." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push\n if @tags.empty?\n gash.send(:git, 'push', @push_to, @refspec)\n else\n gash.send(:git, 'push', '--tags', @push_to, @refspec)\n end\n end", "def create_remote_tag tag_name\n in_secondary_repository do\n create_local_tag tag_name\n run 'git push --tags'\n end\nend", "def push_tags(remote_name, id = nil)\n remote = find_or_create_remote(remote_name)\n raise RemoteNotFound, \"Remote named: #{remote_name} was not found\" unless remote\n all_refs = repo.tags.map(&:canonical_name)\n refs = if id\n tag = find_tag(id)\n tag.canonical_name if tag\n else\n all_refs\n end\n raise NoTagsExists, \"No tags were pushed\" if refs.empty?\n logger.debug(\"Pushing refs #{refs}\")\n logger.info(\"Pushing tags to remote #{remote.url}\")\n remote.push(refs, credentials: credentials)\n end", "def gitPushTag(pushTag)\n puts \"Pushing tag\"\n @gop.push(@remote, \"refs/tags/#{pushTag}\")\n end", "def tag(tag_name)\n git.tag(git_opts, tag_name)\n push(\"origin\", tag_name)\n self\n end", "def git_tag(versionString) \n\t\t\t\tshell_command(\"git tag #{versionString}\")\n\t\t\t\tshell_command(\"git push origin --tags\")\n\t\t\tend", "def create_tag(project, tag_name, ref)\n post(\"/projects/#{project}/repository/tags\", body: {tag_name: tag_name, ref: ref})\n end", "def create_standalone_remote_tag tag_name\n in_secondary_repository do\n run 'git checkout -b temp'\n run 'touch a.txt'\n run 'git add -A'\n run 'git commit -m \"temp\"'\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\n run 'git push --tags'\n end\nend", "def tag(tag, tag_msg=\"\", commit=nil)\n @tags << tag\n if commit\n gash.send(:git, 'tag', '-f', '-a', '-m', tag_msg, tag, commit)\n else\n gash.send(:git, 'tag', '-f', '-a', '-m', tag_msg, tag)\n end\n end", "def github_release_task\n sh git, 'push', '--tags', remote, remote_branch\n end", "def create_local_tag tag_name\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\nend", "def create_git_tag\n assignment_repository.write do |git|\n git.add_tag git_tag\n end\n end", "def push(remote_repo = remote, remote_branch = current_branch)\n git 'push', remote, current_branch\n end", "def push(remote_repo = remote, remote_branch = current_branch)\n git 'push', remote, current_branch\n end", "def update_repo_tag\n unless tag_name.nil? || tag_name.empty?\n callback(:update_repo_tag) do\n notify(:update_repo_tag)\n system_call \"git tag #{tag_name} #{match_tag_name} -f\"\n system_call \"git push -f origin #{tag_name}\"\n end\n end\n end", "def push(repo)\n before_push(repo)\n\n repo.cmd \"git remote add #{name} #{clone_url(repo)}\"\n repo.cmd \"git push --all #{name}\"\n after_push(repo)\n end", "def push(name, internal_repository)\n ensure_remote(name, internal_repository)\n\n git = git(name)\n branch = git.current_branch\n\n git.config \\\n \"remote.#{REMOTE}.push\",\n \"refs/heads/#{branch}:refs/heads/#{branch}\"\n\n git.push(REMOTE, branch)\n end", "def push(remote_repo, opts={:force => false, :revs => nil})\n if remote_repo.capable? \"unbundle\"\n push_unbundle remote_repo, opts\n else\n push_add_changegroup remote_repo, opts\n end\n end", "def tag_release(version)\n system \"git tag v#{version}\"\n system \"git push origin v#{version}\"\n end", "def git_push(host, branch, git_repo_path)\n git_on(host, \"push origin #{branch}\", git_repo_path)\nend", "def git_push(remote = 'origin')\n mysystem(\"git push --set-upstream #{remote} #{git_current_branch}\")\n end", "def add_tag(tag)\n @api.post(\"#{@api.path}/List/#{@id}/Tag\", body: tag)\n end", "def push_repo\n reference_point = git_branch_name || git_tag_name || 'master'\n callback(:push_repo) do\n notify(:push_repo, reference_point: reference_point, app_name: app_name, force: force)\n force_flag = force ? \"-f \" : \"\"\n system_call \"git push #{force_flag}#{deployment_remote} #{reference_point}:refs/heads/master\"\n end\n end", "def update_remote_tags!(new_file=nil)\n Cloudinary::Api.update(my_public_id, tags: tags)\n end", "def push(remote)\n namehost, folder, _barefolder = split_url(remote.name)\n puts 'simple_push'\n simple_push(remote('origin'))\n puts 'bare_repo.push'\n bare_repo.push(remote)\n try_system %[ssh #{namehost} \"cd #{folder} && git pull origin\"]\n end", "def tag_add(id, tag)\n wf_event_id?(id)\n wf_string?(tag)\n api.put([id, 'tag', tag].uri_concat)\n end", "def pushToGitRemotes(branch = 'develop', force = 0)\n if force\n force = \"-f\"\n else\n force = \"\"\n end\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pushing #{branch} to remote: #{branch}\\\"\")\n sh(\"git push #{force} #{remote} #{branch}\")\n end\nend", "def add_tag(tags: nil, track_id: nil)\n tag_names ||= [params[:tags]].flatten\n track_id ||= params[:track_id]\n\n track = current_user.tracks.find(track_id)\n\n added_tags = []\n\n tag_names.reject { |tag_name| tag_name == \"\" || tag_name == \" \" }.each do |tag_name|\n if !(tag = Tag.find_by(name: normalize(tag_name)))\n tag = Tag.create(name: normalize(tag_name))\n end\n unless track.tags.map{ |tag| tag.name.downcase }.include? tag.name.downcase\n track.tags << tag\n added_tags << tag\n end\n end\n end", "def push\n if options.origin.nil?\n logger.error \"No origin URI has been defined for this room\"\n exit 1\n end\n \n if tags.empty?\n logger.error \"Room has no tags. You must create at least one tag before pushing.\"\n exit 1\n end\n\n connect if exp.nil?\n \n # DEADWOOD - Bad idea, lets just force fully qualified paths\n # if uri =~ /\\/~\\//\n # logger.debug \"converting ~ into a real path; uri=#{uri}\"\n # remote_home = ssh.exec!('echo $HOME').chomp\n # uri.sub!(/\\/~\\//, remote_home + '/')\n # logger.debug \"remote home is #{remote_home}, new URI is #{uri}\"\n # end\n \n uri = URI(options.origin)\n\n raise \"unsupported scheme; uri=#{uri}\" unless %w(sftp file).include? uri.scheme\n puts \"pushing room #{name} to #{uri.to_s}\"\n\n basedir = uri.path\n safe_basedir = Shellwords.escape(basedir)\n\n begin\n exp.mkdir basedir\n rescue\n # WORKAROUND: not idempotent\n end\n\n unless exp.ls('').include? 'tags'\n exp.mkdir('tags')\n end\n @platform.mkdir(exp, 'tags')\n\n logger.debug \"uploading options.json\"\n exp.upload(mountpoint + '/etc/options.json', \"options.json\")\n\n @tag_index.construct(self) # KLUDGE\n @tag_index.push\n end", "def add_tag(tag)\n if not tag.kind_of?(String)\n raise \"tag '#{tag.inspect}' is not a String\"\n end\n\n if not @tags.include?(tag)\n @tags.push(tag)\n end\n \n end", "def push(options={})\n raise MissingRemote unless has_remotes?\n options.merge! :remote => DEFAULT_REMOTE, :ref => DEFAULT_LOCAL_REF\n remotes[options[:remote]].push([options[:ref]], {:credentials => credentials})\n end", "def add_tag!(tag)\r\n tag = add_tag(tag)\r\n tag.save\r\n end", "def add_tag(tag_name)\n return false if tag_name.strip == \"\"\n return false if tags.find_by_name(tag_name)\n\n tags << (Tag.where(name: tag_name)[0] || Tag.create(name: tag_name))\n save\n return true\n end", "def push\n unless system(\"cd #{repo_path};git push origin #{branch}\")\n raise GitCloud::GitException.new(\"Push\")\n end\n end", "def tag_object(tag, sha)\n git.fs_write(\"refs/tags/#{clean_tag(tag)}\", sha)\n end", "def add_tag\n url = Url.find_by(id: params[:id])\n tag = Tag.find_by(name: params[:tag])\n if tag\n ## TODO: handle tag with url in backend\n # if not url.tags.where(:tag_id => tag.id).any?\n # url.tags << tag\n # end\n url.tags << tag\n else\n tag = Tag.new(name: params[:tag])\n url.tags << tag\n end\n render json: {code: 200, tags: url.tags}\n end", "def create_tag(dir, branch, tag, message)\n\tDir.chdir(dir) do |path|\n\t\tcmds = [\"git checkout #{branch}\", \n\t\t\t\t\"git pull\",\n\t\t\t\t\"git tag -a #{tag} -m '#{message}'\"\n\t\t\t\t]\n\t\tcmds.delete_at(1) unless remote_branch_exists?(path, branch)\n\t\tapprove_and_execute(cmds, \"in #{path}\")\n\tend\nend", "def git_tag tag\n system \"git tag #{tag}\"\n raise \"tag failed\" unless $?\nend", "def add_tag(tag)\r\n self.tags.new(:name => tag.name)\r\n end", "def unpushed_tags\n output_of \"git push --tags --dry-run 2>&1 | grep 'new tag' | awk '{print $4}'\"\nend", "def tagged?(url, ref)\n reference = Pkg::Util::Git_tag.new(url, ref)\n reference.tag?\n end", "def add(user_id, tag)\n @_client.post(\"/users/#{user_id}/tags\", value: tag)\n end", "def push(_branch)\n puts 'TODO: Implement Git.push'\n end", "def add_tag(tag)\n\n (h.fields['__tags__'] ||= []) << tag\n end", "def git_add_commit_push(host, branch, message, git_repo_path)\n git_add_everything(host, git_repo_path)\n git_commit_push(host, branch, message, git_repo_path)\nend", "def update_tags(tags = nil)\n set_tags(tags)\n write_tags_to_repo\n read_tags_from_repo\n save!\n end", "def add_tag(*tags)\n tags.each_with_index do |tag, i|\n case tag\n when Tags::Tag\n @tags << tag\n when Tags::RefTag\n @ref_tags << tag\n else\n raise ArgumentError, \"expected Tag or RefTag, got #{tag.class} (at index #{i})\"\n end\n end\n end", "def git_push(*remotes)\n remotes.each do |remote|\n git(:push => \"#{remote} master\")\n end\n end", "def add_tags(tags)\n rsp = @flickr.send_request('flickr.photos.addTags', {:photo_id => self.id, :tags => tags}, :post)\n true\n end", "def add_tag(tag_id)\n tag = Tag.find_by_id(tag_id)\n return false if tags.include?(tag)\n tags << tag\n return true\n end", "def push_to_remote(local_branch, remote_branch, remote_name, opts)\n remote_name ||= 'origin'\n\n args = [remote_name]\n\n local_branch ||= branches.current\n remote_branch ||= local_branch\n args << '-f' if opts[:force]\n\n logger.info do\n if local_branch == remote_branch\n \"Pushing to '#{remote_branch}' on '#{remote_name}'.\"\n else\n \"Pushing #{local_branch} to '#{remote_branch}' on '#{remote_name}'.\"\n end\n end\n\n args << \"#{local_branch}:#{remote_branch}\"\n return command(:push, args)\n end", "def push_image_to_remote(image)\n\n if !image.tagged_for_remote\n raise \"Image not yet tagged (use tag_for_remote function)\"\n end\n\n if image.local_image_id.nil?\n raise \"No local id set in image\"\n end\n\n if image.remote_repository.nil?\n raise \"Image has not remote repository specified\"\n end\n\n # api push command oddly fails silently - not sure what's up\n # also, api appears to give no feedback as image is uploaded - which can take some time\n\n # raw_image = self.get_raw_image_by_id(image.local_image_id)\n # https://github.com/bkeepers/dotenv\n # result = raw_image.push(nil,repo_tag: image.remote_repository.get_remote_repository_name + \":\" + image.primary_image_tag)\n # puts result.inspect\n\n\n # drop to command line and issue push via docker-cli for now\n push_command = \"docker push #{image.remote_repository.get_remote_repository_name}:#{image.primary_image_tag}\"\n system push_command\n\n if $?.exitstatus == 0\n return true\n else\n return false\n end\n\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 add_tag (tag)\n `rs_tag --add \"#{tag}\"`\n end", "def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def add_tag(tag)\n @added_tags ||= Set.new\n @added_tags << tag\n end", "def add_tag(tag: required(\"tag\"), options: {}, **data)\n with_params = data.merge(tag: tag).reject { |_,v| v.nil? || Array(v).empty? }\n client.post(\"/tasks/#{gid}/addTag\", body: with_params, options: options) && true\n end", "def push()\n\t\tbegin\n\t\t\t@git.push('origin','master')\n\t\trescue Git::GitExecuteError => e\n\t\t\tif (e.to_s.include?(\"refspec master does not match any\"))\n\t\t\t\tLogger::log(@carpeta,Logger::INFO,\"No hay cambios para subir al servidor\")\n\t\t\telse\n\t\t\t\traise UploadException, \"Error al subir los cambios al servidor\" , caller\n\t\t\tend\n\t\tend\n\tend", "def push_notes(notes)\n run(\"git notes --ref #{refname} add -f -F -\", {:stdin_str => notes, :raise => true})\n ret = run(\"git push origin refs/notes/#{refname}\")\n raise(ConcurrentUpdateError, \"trouble pushing notes\") unless ret[:val] == 0\n end", "def git_remote_add(remote_name, remote_url)\n cmd = \"#{discover_git_executable} remote add upstream \\\"#{remote_url}\\\"\"\n debug \"Running #{cmd} 2>&1\"\n output = %x[#{cmd} 2>&1]\n raise RHC::GitException, \"Error while adding upstream remote - #{output}\" unless output.empty?\n end", "def add_tag_to_server server_uuid, tags\n tag = (tags.respond_to? :join && tags.join(\",\") || tags)\n\n post \"server/#{server_uuid}/tag/#{tag}\"\n end", "def add_remote(uri, name)\n @repository.add_remote(name,uri)\n \n self.remotes\n end", "def git_tag_delete(versionString) \n\t\t\t\tshell_command(\"git push --delete origin #{versionString}\")\n\t\t\t\tshell_command(\"git tag --delete #{versionString}\")\n\t\t\tend", "def push(uuid, repo, from_repo_uuid = nil, to_repo_uuid = nil)\n from_repo_uuid ||= @uuid\n to_repo_uuid ||= repo.uuid\n remote_head = repo.head(uuid, to_repo_uuid)\n # TODO: receiver must store received versions somewhere, \n # then try fast-forward merge or report an error.\n # Find out what this \"somewhere\" is. Maybe, a temporary\n # repo/branch.\n end", "def push_repo\n UI.puts \"\\nPushing the `#{@repo}' repo\\n\".yellow\n repo_git('push', 'origin', 'HEAD')\n end", "def git_commit_and_push(cookbook_path, github_url)\n if File.exists?(File.join(cookbook_path, \".git\"))\n shell_out(\"git remote rm origin\", :cwd => cookbook_path)\n else\n shell_out!(\"git init\", :cwd => cookbook_path)\n end\n shell_out!(\"echo - $(date): Uploaded with knife github plugin. >> CHANGELOG.md \", :cwd => cookbook_path)\n shell_out!(\"git add .\", :cwd => cookbook_path)\n shell_out!(\"git commit -m 'creating initial cookbook structure from the knife-github plugin' \", :cwd => cookbook_path)\n shell_out!(\"git remote add origin #{github_url} \", :cwd => cookbook_path)\n shell_out!(\"git push -u origin master\", :cwd => cookbook_path)\n end", "def git_commit_push(host, branch, message, git_repo_path)\n git_on(host, \"commit -m \\\"#{message}\\\"\", git_repo_path)\n git_push(host, branch, git_repo_path)\nend", "def add_remote(name, url, opts = {})\n url = url.repo.path if url.is_a?(Git::Base)\n self.lib.remote_add(name, url, opts)\n Git::Remote.new(self, name)\n end", "def commit_and_tag(new_version)\n git = Git.init\n git.add([VERSION_FILE, \"Gemfile.lock\"])\n git.commit(\"Update to #{new_version}\")\n git.add_tag(new_version.to_s)\n end", "def push_add_changegroup(remote, opts={})\n # no locking cuz we rockz\n ret = pre_push remote, opts\n \n if ret[0]\n cg, remote_heads = *ret\n remote.add_changegroup cg, :push, url\n else\n ret[1]\n end\n end", "def push_tags *tags\n # Check for nil tags\n Thread.current[:semantic_logger_tags] = self.tags.concat(tags)\n end", "def push(tracking_branch=upstream_branch)\n sandbox do |git, work_tree, index_file|\n remote, remote_branch = parse_tracking_branch(tracking_branch)\n git.push({}, remote, \"#{branch}:#{remote_branch}\") unless head.nil?\n end\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 add_tags(artist, track, tags)\n post(:session, {:method => \"track.addTags\", :artist => artist, :track => track, :tags => tags})\n end", "def tag_exists?(tag_name, options = {})\n options = {\n :repo => nil\n }.merge(options)\n repo = options[:repo] || default_repository\n\n # note that remote tags cannot be queried directly; use git fetch --tags to\n # import them first.\n repo.tags.any? { |tag| tag.name == tag_name }\n end", "def commit_and_push_to_repo(oauth_token, commit_message, \n tree_sha, head_sha, ref_name)\n client = Octokit::Client.new(access_token: oauth_token)\n sha_new_commit = client.create_commit(full_repo_name, commit_message, tree_sha, head_sha)[:sha]\n client.update_ref(full_repo_name, ref_name, sha_new_commit)\n end", "def push(repository)\n # add all files to the repository\n repository.add(all: true)\n\n # commit, but be aware: current version could be identical to previous version resulting in an error\n begin\n repository.commit('Application deployment via Nucleus')\n rescue Git::GitExecuteError => e\n # usually indicates that no files could be committed, repository is up to date\n log.debug(\"Git commit failed: #{e}\")\n end\n\n # repack to enhance compression\n repository.repack\n\n # force push, so that the push is executed even when all files remain unchanged\n repository.push('origin', @repo_branch, force: true)\n end", "def tag_commit(tag_name)\n link = url_helpers.project_tag_path(project, id: tag_name)\n body = \"tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})\"\n\n create_note(NoteSummary.new(noteable, project, author, body, action: 'tag'))\n end", "def add(tag)\n return nil if tag.nil?\n get_list(tag) << tag\n end", "def pushtobare(branch = 'master')\n remote = satelliterepo.remotes['bare']\n remote = satelliterepo.remotes.create 'bare', barerepo.path unless remote\n satelliterepo.push remote, [\"refs/heads/#{branch}\"]\n end", "def pushtobare(branch = 'master')\n remote = satelliterepo.remotes['bare']\n remote = satelliterepo.remotes.create 'bare', barerepo.path unless remote\n satelliterepo.push remote, [\"refs/heads/#{branch}\"]\n end", "def tag_with_name(tag_name, message=\"automated tagging\")\r\n tag_url = build_tag_url_for_base(tag_name)\r\n tag(@repository_trunk, tag_url, message)\r\n end", "def apply\n repo.push('origin', ['refs/heads/master'], credentials: credentials)\n end", "def add_tag(new_tag)\n db = connect_to_database()\n db.execute(\"INSERT INTO tags (Tag) VALUES (?)\", new_tag.downcase)\n end", "def tag_release(tag)\n unless this_version == extract_version\n info \"Committing buildfile with version number #{extract_version}\"\n Git.commit File.basename(version_file), message\n Git.push if Git.remote\n end\n info \"Tagging release #{tag}\"\n Git.git 'tag', '-d', tag rescue nil\n Git.git 'push', Git.remote, \":refs/tags/#{tag}\" rescue nil if Git.remote\n Git.git 'tag', '-a', tag, '-m', \"[buildr] Cutting release #{tag}\"\n Git.git 'push', Git.remote, 'tag', tag if Git.remote\n end", "def tag_release(tag)\n unless this_version == extract_version\n puts \"Committing buildfile with version number #{extract_version}\"\n Git.commit File.basename(Rake.application.rakefile.to_s), message\n Git.push if Git.remote\n end\n puts \"Tagging release #{tag}\"\n # Git.git 'tag', '-d', tag rescue nil\n Git.git 'push', Git.remote, \":refs/tags/#{tag}\" rescue nil if Git.remote\n Git.git 'tag', '-f', '-a', tag, '-m', \"[rake_release] Cutting release #{tag}\"\n Git.git 'push', Git.remote, 'tag', tag if Git.remote\n end", "def tag(arg='')\n `git tag #{arg} 2>&1`\n end", "def add_remote(name, url)\n remotes.create name, url\n end", "def upload!(file_path)\n raise GitCloud::FileException.new(\"NotFound\") unless File.exists? file_path\n file = File.new(File.expand_path(file_path))\n add(file)\n commit\n push\n end", "def add_tag_associations(tags)\n tags.each do |tag|\n t = Tag.find_by_tag(tag)\n if t\n self.tags << t\n else\n t = Tag.new(:tag => tag)\n self.tags << t if t.save\n end\n end \n end", "def register tag, name\n @tags[name] = tag\n end", "def register tag, name\n @tags[name] = tag\n end", "def tag(tag_name)\n Git::Object.new(self, tag_name, 'tag', true)\n end", "def create_tag(project_name, repository_name, reference, tag, opts = {})\n create_tag_with_http_info(project_name, repository_name, reference, tag, opts)\n nil\n end", "def push(args, create_upstream: nil)\n args = args.dup + ['--set-upstream', create_upstream, branch] if create_upstream\n execute_git_output('push', args)\n $?.exitstatus == 0 || (create_upstream && $?.exitstatus == 128)\n end", "def git_push_commits\n shellout(\"git push #{config[:remote]} #{config[:branch]}\")\n end", "def tag(tag_name, *args)\n tag_names = tag_name.split(args.first)\n\n tag_names.each do |tag_name|\n if !(self.tag_ids.include?(tag_name))\n tags << Tag.find_or_create_by(name: tag_name)\n end\n end\n self\n end", "def commit_and_tag(bump_info)\n @logger.log '===> executing commands'\n @command.exec 'git add .'\n @command.exec \"git commit -m '#{bump_info.commit_message}'\"\n @command.exec \"git tag v#{bump_info.after_version}\"\n end", "def git_add_everything(host, git_repo_path)\n git_on(host, \"add #{git_repo_path}/*\", git_repo_path)\nend", "def tag!(params = {})\n self.post params, edge: :tags\n end" ]
[ "0.7778907", "0.7551029", "0.748117", "0.7453234", "0.7365221", "0.6966967", "0.68797684", "0.6761167", "0.66993517", "0.66701823", "0.66433847", "0.65453184", "0.650499", "0.650499", "0.64788896", "0.64710593", "0.64458066", "0.6379185", "0.63728774", "0.63488644", "0.6324828", "0.63194746", "0.6210264", "0.6191315", "0.6168594", "0.61474913", "0.6083689", "0.60688317", "0.60641044", "0.60629183", "0.6060281", "0.6041027", "0.60406595", "0.6030825", "0.59930605", "0.59883964", "0.59872967", "0.5930852", "0.591054", "0.59006214", "0.5879781", "0.5852825", "0.58456737", "0.58411324", "0.58213663", "0.5813884", "0.58066845", "0.58013105", "0.57923913", "0.57865125", "0.576458", "0.5759714", "0.5742829", "0.57405317", "0.5713729", "0.57069343", "0.57050735", "0.5702884", "0.56716895", "0.566693", "0.5662719", "0.56625026", "0.5653897", "0.56516594", "0.56386966", "0.56285095", "0.56261194", "0.56243545", "0.5623306", "0.5622398", "0.5603137", "0.5600579", "0.5583593", "0.5583593", "0.5570822", "0.55705017", "0.5568183", "0.55487514", "0.5532439", "0.55280465", "0.55221486", "0.55221486", "0.5510703", "0.5507233", "0.5503069", "0.5494949", "0.5472967", "0.5472205", "0.5467094", "0.54654974", "0.54519916", "0.54505765", "0.54505765", "0.5450055", "0.54464155", "0.544536", "0.5439459", "0.54391026", "0.54114425", "0.54112834", "0.54073006" ]
0.0
-1
Fails if one of these 2 conditions are not met: 1. the repository is clean: no content staged or unstaged 2. some remote repositories are defined but the current branch does not track any
def check super uncommitted = Git.uncommitted_files fail "Uncommitted files violate the First Principle Of Release!\n#{uncommitted.join("\n")}" unless uncommitted.empty? # fail "You are releasing from a local branch that does not track a remote!" unless Git.remote end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_repo_clean\n @gitrepo = Grit::Repo.new(@repo_root)\n status = @gitrepo.status\n if !status.changed.nil? || status.changed.size != 0 # This has to be a convoluted way to determine a non-empty...\n # Test each for the magic sha_index. Ref: https://github.com/mojombo/grit/issues/142\n status.changed.each do |file|\n case file[1].sha_index\n when '0' * 40\n ui.error 'There seem to be unstaged changes in your repo. Either stash or add them.'\n exit 4\n else\n ui.msg 'There are modified files that have been staged, and will be included in the push.'\n end\n end\n elsif status.untracked.size > 0\n ui.warn 'There are untracked files in your repo. You might want to look into that.'\n end\n end", "def check\n super\n info \"Working in branch '#{Hg.current_branch}'\"\n uncommitted = Hg.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n fail \"You are releasing from a local branch that does not track a remote!\" if Hg.remote.empty?\n end", "def check\n super\n uncommitted = Git.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n fail \"You are releasing from a local branch that does not track a remote!\" unless Git.remote\n end", "def check_repo_status\n porcelain_status, = Executable.capture_command('git', %w(status --porcelain), :capture => :merge, :chdir => repo_dir)\n clean = porcelain_status == ''\n raise Informative, \"The repo `#{@repo}` at #{UI.path repo_dir} is not clean\" unless clean\n end", "def check_clean_status_task\n raise \"The current working copy contains modifications\" if `#{git} ls-files -m`.split(\"\\n\").any?\n end", "def clean_working_directory_check\n commit_count_check = `git status`\n if (!(commit_count_check.include? \"Your branch is up-to-date with 'origin/master'.\") &&\n !(commit_count_check.include? \"nothing to commit, working directory clean\")) ||\n (commit_count_check.include? \"Changes not staged for commit:\")\n abort(\"ABORTING... please commit and push any local changes before atte\"\\\n \"mpting to create a new tag\")\n end\n end", "def check_for_clean\n # can't believe there's not a simple yes/no here..\n out = `git status --porcelain`\n\n unless out.empty? then\n puts colorRed(\"you have uncommitted changes -- please commit and try again:\\r\\t#{out}\")\n exit\n end\n\n end", "def verify_non_destructive\n # Obviously non-destructive because we have a linear path.\n return if ancestor == @local_parent || ancestor == remote\n \n # At this point, they obviously are crossing a branch.\n \n if @local_parent.branch == remote.branch\n # Here's how this work: if you want to cross a *revision history branch* (not\n # a named branch), you have to do a branch merge. So that's not allowed.\n #\n # If dirty, print a special message about your changes\n if working_changeset.changed_files.any? || working_changeset.deleted.any?\n raise abort(\"crosses branches (use 'hg merge' or \"+\n \"'hg update -C' to discard changes)\")\n end\n # Otherwise, just let them know they can't cross branches.\n raise abort(\"crosses branches (use 'hg merge' or 'hg update -C')\")\n elsif working_changeset.changed_files.any? || working_changeset.deleted.any?\n # They're crossing to a named branch, but have a dirty working dir. not allowed.\n raise abort(\"crosses named branches (use 'hg update -C'\"+\n \" to discard changes)\")\n else\n # They just want to switch to a named branch. That's ok, as long as they\n # have no uncommitted changes.\n @overwrite = true\n end\n end", "def check_if_push_allowed\n if @source.is_a?(CDNSource)\n raise Informative, 'Cannot push to a CDN source, as it is read-only.'\n end\n\n remotes, = Executable.capture_command('git', %w(remote --verbose), :capture => :merge, :chdir => repo_dir)\n master_repo_urls = [\n 'git@github.com:CocoaPods/Specs.git',\n 'https://github.com/CocoaPods/Specs.git',\n ]\n is_master_repo = master_repo_urls.any? do |url|\n remotes.include?(url)\n end\n\n if is_master_repo\n raise Informative, 'To push to the CocoaPods master repo use ' \\\n \"the `pod trunk push` command.\\n\\nIf you are using a fork of \" \\\n 'the master repo for private purposes we recommend to migrate ' \\\n 'to a clean private repo. To disable this check remove the ' \\\n 'remote pointing to the CocoaPods master repo.'\n end\n end", "def has_remote_tracking_branch(repo)\n return false if $branch_name.empty?\n\n begin\n return !repo.branches[$remote_branch].nil?\n rescue\n return false\n end\nend", "def find_invalid_repos\n repos_with_issues = RepositorySet.new(\n Repositext::PARENT_DIR\n ).git_ensure_repos_are_ready(\n :all_content_repos\n ) { |repo_path| puts \" - #{ repo_path.split('/').last }\" }\n # TODO: Use #all_synced_foreign_repos instead of the RepositorySet method. Requires a refactoring.\n repos_with_issues += ensure_st_ops_filenames_are_valid\n if repos_with_issues.any?\n puts\n puts \"Could not proceed because the following git repositories are not ready:\".color(:red)\n puts\n repos_with_issues.each { |repo_path, issues|\n puts repo_path\n puts '-' * 40\n issues.each { |e| puts \" - #{ e }\".color(:red) }\n }\n puts\n raise ReposNotReadyError.new(\n \"\\n\\nCannot proceed with synching subtitles until all content repos are clean!\".color(:red)\n )\n end\n true\n end", "def clean_local_branch\n run_and_success?(\"#{git} show-branch #{ref} > /dev/null 2>&1 && #{git} branch -D #{ref} > /dev/null 2>&1\")\n end", "def check_not_diverged_task\n raise \"The current branch is diverged from the remote branch!\" if `#{git} rev-list HEAD..#{remote}/#{remote_branch}`.split(\"\\n\").any?\n end", "def check_branch\n same_branch = `git branch -a` =~ /\\* #{@branch}/\n\n if current_remote = `git remote -v`.match(/\\s\\S+/)\n same_remote = current_remote[0].match(/#{@repo}/)\n end\n\n if same_remote && same_branch\n puts \"Deploy to #{@branch} canceled:\".red\n puts \"You cannot deploy to the same branch you are working in. This will overwrite the source for your site.\\n\"\n puts \"First, back up your site's source to a branch:\"\n puts \"\\n git checkout -b source\".yellow\n puts \" git push origin source\".yellow\n puts \"\\nWith that, you'll work in the #{\"source\".bold} branch and deploy to the #{@branch.bold} branch.\"\n abort\n end\n end", "def check\n super\n uncommitted = Perforce.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n end", "def check_that_current_branch_is_up_to_date_with_origin_master\n return true if options['skip-git-up-to-date-check']\n git_repo = Repositext::Repository.new\n latest_commit_sha_remote = git_repo.latest_commit_sha_remote\n begin\n latest_local_commit = git_repo.lookup(latest_commit_sha_remote)\n rescue Rugged::OdbError => e\n # Couldn't find remote's latest commit in local repo, raise error\n raise GitRepoNotUpToDateError.new([\n '',\n \"Your local '#{ git_repo.current_branch_name }' branch is not up-to-date with origin/master.\",\n 'Please get the updates from origin/master first before running a repositext command.',\n 'You can bypass this check by appending \"--skip-git-up-to-date-check=true\" to the repositext command'\n ].join(\"\\n\"))\n end\n end", "def needs_pushing?(dir = Dir.pwd)\n rval = false\n branch = get_branch\n if is_origin_branch? branch\n Dir.chdir(dir) do\n rval = (%x{git diff \"#{branch}\"..origin/\"#{branch}\"}.size > 0)\n end\n end\n rval\nend", "def validate_target_remote_branch\n remote_path = File.join(config[:remote], config[:branch])\n\n remotes = []\n @gitrepo.remotes.each { |remote| remotes << remote.name }\n unless remotes.include?(remote_path)\n ui.error 'The remote/branch specified does not seem to exist.'\n exit 7\n end\n end", "def nothing_to_commit?\n Dir.chdir @root do\n cmd = \"git status\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n # Check if status indicates nothing to commit\n return /nothing to commit/.match stdout\n end\n end", "def check_git_repo\n # check local dir\n\n # use Open3 in order to get stderr output from child process\n # `` syntax only returns stdout output which is not enough\n\n # since command are all executed in newly spawned child processes so there's no need to record old dir path\n stdout, stderr = Open3.popen3(\"cd #{@local_path} && git status\")[1..2]\n\n local_branch_name = stdout.gets.to_s.match(/^On branch ([^\\s]+)/)[1]\n unless local_branch_name\n raise GitRepoException, \"local path #{@local_path} is not a git repository\"\n end\n\n # check remote dir\n valid = true\n remote_branch_name = ''\n @ssh.exec!(\"cd #{@remote_path} && git status\") do |ch, stream, data|\n case stream\n when :stdout\n valid = false unless (remote_branch_name = data.match(/^On branch ([^\\s]+)/)[1])\n when :stderr\n valid = false unless (data.nil? or data == '')\n end\n end\n unless valid\n raise GitRepoException, \"remote path #{@remote_path} is not a git repository\"\n end\n\n # check match\n if local_branch_name != remote_branch_name\n raise GitRepoException, \"local branch(#{local_branch_name}) and remote branch(#{remote_branch_name}) don't match\"\n end\n end", "def git_reset_if_unchanged(branch = \"origin/#{git_current_branch}\")\n if git_has_remote_branch?(branch) && Zim.cwd_has_unpushed_changes? && `git diff #{branch} 2>&1`.split(\"\\n\").size == 0\n git_reset_branch(branch)\n end\n end", "def nothing_to_commit?\n @git.status do |file, status|\n return false unless status.empty?\n end\n return true\n end", "def unmerged_commits?(branch_name, verbose = true)\n locations = []\n locations << ['', ''] if branch_exists?(:local, branch_name)\n locations << ['origin/', 'origin/'] if branch_exists?(:remote, branch_name)\n locations = locations + [['', 'origin/'], ['origin/', '']] if locations.size == 2\n if locations.empty?\n puts 'Nothing to do. All cleaned up already.' if verbose\n return false\n end\n # Compare remote and local branch with remote and local master.\n responses = locations.collect do |location|\n git_call \"cherry #{location.first}#{target_branch} #{location.last}#{branch_name}\"\n end\n # Select commits (= non empty, not just an error message and not only duplicate commits staring with '-').\n unmerged_commits = responses.reject do |response|\n response.empty? or response.include?('fatal: Unknown commit') or response.split(\"\\n\").reject { |x| x.index('-') == 0 }.empty?\n end\n # If the array ain't empty, we got unmerged commits.\n if unmerged_commits.empty?\n false\n else\n puts \"Unmerged commits on branch '#{branch_name}'.\"\n true\n end\n end", "def should_handle?\n build.repo_source? && build.master_branch? && build.success?\n end", "def verify_valid_branch_merge\n # trying to merge backwards with a direct ancestor of the current directory.\n # that's crazy.\n if ancestor == remote\n raise abort(\"can't merge with ancestor\")\n elsif ancestor == @local_parent\n # If we're at the branch point, without a difference in branch names, just do an update.\n # Kind of the opposite of the last case, only isntead of trying to merge directly backward,\n # we're trying to merge directly forward. That's wrong.\n if @local_parent.branch == remote.branch\n raise abort(\"nothing to merge (use 'amp update' or check\"+\n \" 'amp heads')\")\n end\n end\n # Can't merge when you have a dirty working directory. We don't want to lose\n # those changes!\n if !force && (working_changeset.changed_files.any? || working_changeset.deleted.any?)\n raise abort(\"oustanding uncommitted changes\")\n end\n end", "def git_check\n # May throw InvalidRepositoryException\n # - because of invalid path\n # - or broken git repository\n @repo = GitLib::Repo.new(path)\n end", "def anything_changed?\n @any_changes ||=\n ! @status.match(/nothing to commit.*working directory clean/)\n end", "def has_untracked_changes? \n not [repo.changed, repo.untracked].flatten.select do |k| \n k.include?(\".craft\") || k.eql?(\"persistent.sfs\") || k.eql?(\"quicksave.sfs\") \n end.empty?\n end", "def backported_from_master?\n branch != 'origin/master' && self.class.exists?(:branch => 'origin/master', :message => message, :author => author)\n end", "def handle_repo_push_request\n return unless @repository\n\n branch_name = payload[\"ref\"].sub(%r{\\Arefs/heads/}, '')\n branch = @repository.branches.where(name: branch_name).first\n if branch.present? && branch.convergence? && @repository.run_ci?\n sha = payload[\"after\"]\n branch.kickoff_new_build_unless_currently_busy(sha)\n end\n end", "def ensure_all_content_repos_are_ready\n find_invalid_repos\n find_invalid_primary_st_ops_filenames\n end", "def test_repo_valid\n post '/repos', {:name => GIT_REPO}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"rune@runemadsen.com\", :message => \"My First Commit\"}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There Again\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"rune@runemadsen.com\", :message => \"My First Commit\"}\n `git clone #{path} /tmp/test`\n status = $?.to_i\n assert_equal(0, status)\n FileUtils.rm_rf \"/tmp/test\"\n end", "def test_no_gitgo_no_remote_gitgo\n assert !sh(b, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"shasum\") {|io| io << \"content\" }\n sh(b, 'git add shasum')\n sh(b, 'git commit -m \"added document\"')\n \n sh(b, 'git checkout master')\n sh(b, 'git push origin gitgo')\n \n assert sh(b, 'git branch').include?('gitgo') \n assert sh(a, 'git branch').include?('gitgo')\n \n sh(a, 'git checkout gitgo')\n assert_equal \"content\", File.read(method_root.path(a, \"shasum\"))\n end", "def shouldnt_count_as_a_contribution?\n merge? || backported_from_master?\n end", "def git_repo?\n !repository_root.to_s.empty?\n end", "def check_repo(url)\n output = `git ls-remote #{url} 2>&1`\n if ($? != 0)\n raise BadRepo.new(url + \"<<<\" + output.to_s + \">>>\")\n end\n end", "def validate_in_repo\n unless File.exist?('.git')\n raise NotInAGitRepository, \"We don't appear to be inside a Git repository!\"\n end\n end", "def git_has_remote_branch?(branch)\n `git config branch.#{branch}.merge`.strip == ''\n end", "def needs_checkout?\n expected = ref.sha1\n actual = rev_parse('HEAD')\n\n ! (expected == actual)\n end", "def anything_to_commit?(directory)\n directory && false\n end", "def verify_no_uncommitted_merge\n if !overwrite? && @working_changeset.parents.size > 1\n raise abort(\"outstanding uncommitted merges\")\n end\n end", "def check!\n # does not inherit any dependencies (super.check will inherit)\n Dependencies.new(configuration) do |d|\n d.remote.directory(configuration[:deploy_to]).or(\"`#{configuration[:deploy_to]}' does not exist.\")\n d.remote.writable(configuration[:deploy_to], :via => :sudo).or(\"You do not have permissions to write to `#{configuration[:deploy_to]}'.\")\n d.remote.command(\"svn\")\n d.remote.match(\"cd #{repository_dir}; svn info|grep URL\", configuration[:repository])\n end\n end", "def ensure_cloned(repository_url)\n repository_url && :not_implemented\n end", "def fetch_update\n remote_branch = ErrorEmittingExecutor.execute(\"git branch -r --list origin/#{BRANCH_NAME}\")\n if remote_branch == 'origin/cocina-level2-updates'\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS} #{GIT_BRANCH_FETCH_REFS}\")\n else\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS}\", exit_on_error: true)\n end\nend", "def needs_commit?(dir = Dir.pwd, file = nil)\n rval = false\n Dir.chdir(dir) do\n status = %x{git status}\n if file.nil?\n rval = true unless status =~ /nothing to commit \\(working directory clean\\)|nothing added to commit but untracked files present/\n if status =~ /nothing added to commit but untracked files present/\n puts \"WARNING: untracked files present in #{dir}\"\n show_changed_files(status)\n end\n else\n rval = true if status =~ /^#\\t.*modified: #{file}/\n end\n end\n rval\nend", "def dirty?(exclude_spec=false)\n repo_status = false\n\n return repo_status unless File.directory?(path)\n\n Dir.chdir(path) do\n %x(git update-index -q --ignore-submodules --refresh)\n repo_status = \"Could not update git index for '#{path}'\" unless $?.success?\n\n unless repo_status\n %x(git diff-files --quiet --ignore-submodules --)\n repo_status = \"'#{path}' has unstaged changes\" unless $?.success?\n end\n\n unless repo_status\n %x(git diff-index --cached --quiet HEAD --ignore-submodules --)\n repo_status = \"'#{path}' has uncommitted changes\" unless $?.success?\n end\n\n unless repo_status\n # Things that may be out of date but which should stop the updating\n # of the git repo\n our_exclusions=[\n 'build/rpm_metadata',\n 'dist/'\n ]\n\n untracked_files = %x(git ls-files -o -d --exclude-standard --exclude=#{our_exclusions.join(' --exclude=')})\n\n if $?.success?\n unless untracked_files.empty?\n untracked_files.strip!\n\n if untracked_files.lines.count > 0\n repo_status = \"'#{path}' has untracked files\"\n end\n end\n else\n # We should never get here\n raise Error, \"Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'\"\n end\n end\n end\n\n repo_status\n end", "def validate_repo(repo)\n repo_valid = true\n if /review\\.fuel-infra\\.org/.match(repo).nil? and /github\\.com\\/fuel-infra/.match(repo).nil?\n repo_valid = false\n end\n repo_valid\n end", "def enabled?\n (super ||\n !@remote_path.nil? && @remote_path.directory? ||\n local_valid_repo?)\n end", "def git_rescue\n @logger.error \"Branch or ref does not exist\"\n end", "def usable_repository?\n repository_cache.directory? &&\n run_and_output(\"#{git} remote -v | grep origin\").include?(uri)\n end", "def validate_ref(repo, ref)\n ref_valid = true\n cmd = \"git ls-remote --tags --exit-code #{repo} #{ref} >/dev/null\"\n system(cmd)\n if $?.exitstatus != 0\n ref_valid = false\n end\n ref_valid\n end", "def empty?\n @hg_client.repository_empty?\n end", "def push_repo_changes_aux(repo, opts={})\n diffs = DiffSummary.new()\n\n # adding untracked files (newly added files)\n repo.stage_changes()\n\n # commit if there has been changes\n if repo.changed?\n repo.commit(opts[:commit_msg]||\"Pushing changes from client\") #TODO: make more descriptive\n end\n\n if opts[:remote_repo] and opts[:remote_repo_url]\n repo.add_remote(opts[:remote_repo],opts[:remote_repo_url])\n end\n\n unless opts[:no_fetch]\n repo.fetch(remote(opts[:remote_repo]))\n end\n\n local_branch = repo.local_branch_name\n\n remote_branch_ref = remote_branch_ref(local_branch, opts)\n\n #check if merge needed\n commit_shas = Hash.new\n merge_rel = repo.merge_relationship(:remote_branch,remote_branch_ref, :ret_commit_shas => commit_shas)\n commit_sha = nil\n diffs = DiffSummary.new_version(repo)\n\n if merge_rel == :equal\n commit_sha = commit_shas[:other_sha]\n elsif [:branchpoint,:local_behind].include?(merge_rel)\n if opts[:force]\n diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)\n if diffs.any_diffs?()\n repo.push(remote_branch_ref, {:force => opts[:force]})\n end\n commit_sha = repo.find_remote_sha(remote_branch_ref)\n else\n where = opts[:where] || 'server'\n msg = \"Merge needed before module (#{pp_module(repo)}) can be pushed to #{where}. \"\n if where.to_sym == :catalog\n msg << \" Either a merge into the local module can be done with pull-dtkn command, followed by push-dtkn or force\"\n else\n msg << \"Force\"\n end\n msg << \" push can be used with the '--force' option, but this will overwrite remote contents\"\n raise ErrorUsage.new(msg)\n end\n elsif merge_rel == :no_remote_ref\n repo.push(remote_branch_ref)\n commit_sha = commit_shas[:local_sha]\n elsif merge_rel == :local_ahead\n # see if any diffs between fetched remote and local branch\n # this has be done after commit\n diffs = DiffSummary.diff(repo,local_branch, remote_branch_ref)\n\n if diffs.any_diffs?()\n repo.push(remote_branch_ref, {:force => opts[:force]})\n end\n\n commit_sha = repo.find_remote_sha(remote_branch_ref)\n else\n raise Error.new(\"Unexpected merge_rel (#{merge_rel})\")\n end\n\n {\"diffs\" => diffs, \"commit_sha\" => commit_sha, \"repo_obj\" => repo}\n end", "def has_repo?(local_param)\n !list.find { |r| r.param == local_param }.nil?\n end", "def check_duplicata_pr_branch(pr)\n puts `git branch --list #{pr}`\n `git branch -D #{pr} 2>/dev/null` if $CHILD_STATUS.exitstatus.zero?\n end", "def alert_reserved_and_exit\n cli.say \"The current branch #{config.github_repo}/#{git.current_branch} is a reserved branch and can not have pull requests.\"\n exit 1\n end", "def uncommitted_changes?\n inform \"Checking for any uncommitted changes...\"\n if nothing_to_commit?\n inform \"All changes committed :)\"\n false\n else\n inform \"You have uncommitted changes. Please commit them first, then run `rake release` again.\"\n true\n end\n end", "def validate_repo\n @repo_root = shellout('git rev-parse --show-toplevel').stdout.chomp\n rescue Exception => e\n ui.error \"There doesn't seem to be a git repo at #{@cb_path}\\n#{e}\"\n exit 3\n end", "def check\n puts \"#{name}...\"\n unreleased = 0\n Dir.chdir(CONFIG_DIR) do\n `git clone #{envs.first['git']} --bare #{name} > /dev/null 2>&1`\n Dir.chdir(name) do\n envs.each do |env|\n `git remote add #{env['name']} #{env['git']} > /dev/null 2>&1`\n `git fetch #{env['name']} > /dev/null 2>&1`\n end\n envs.each_cons(2) do |ahead, behind|\n log = `git log #{behind['name']}/#{behind['branch'] || 'master'}..#{ahead['name']}/#{ahead['branch'] || 'master'} --pretty=format:\"%h %ad %s (%an)\" --date=short --no-merges`\n if log == ''\n puts \" #{behind['name']} is up-to-date with #{ahead['name']}\\n\"\n else\n puts \" #{behind['name']} is behind #{ahead['name']} by:\"\n log.lines.each { |l| puts \" #{l}\" }\n unreleased += 1\n end\n end\n end\n end\n unreleased\n end", "def pristine?; changes.empty?; end", "def track_missing\n lbranches = local_branches\n dbg \"track_missing: local branches = #{lbranches.join(', ')}\"\n remote = remote_name\n added = []\n remote_branches.reject { |b| /HEAD/.match(b) }.each do |branch|\n dbg \" considering remote branch #{branch}\"\n lbranch = branch.sub(/^#{remote}\\//, '')\n dbg \" local branch name would be #{lbranch}\"\n unless lbranches.include? lbranch\n dbg \" not already tracking #{lbranch}\"\n added << lbranch\n track lbranch\n end\n end\n added\n end", "def test_clean_checkout_should_not_remove_tracked_files\n with_sandboxed_git do |proj_dir, git|\n tracked_file = File.join(proj_dir, 'tracked.txt')\n FileUtils.touch tracked_file\n sandbox_git_add_and_commit(proj_dir, File.basename(tracked_file))\n untracked_file = File.join(proj_dir, 'untracked.txt')\n git.clean_checkout\n assert File.exist? tracked_file\n assert_false File.exist? untracked_file\n end\n end", "def is_valid_for_execution\n (@metadata[\"short_dest_repo_name\"] == \"osrf/gazebo\" and @pr_status == :update) ? false : true\n end", "def reset_remote_repo\n @ssh.exec! \"cd #{@remote_path} && git reset --hard\" do |ch, stream, data|\n if stream == :stderr and data.to_s != '' # check for nil or ''\n raise GitResetException, \"Reset failed: #{data}\"\n end\n end\n end", "def recent_branches_strict\n\t\tbranches = `git branch -a`.gsub!(/^\\*?\\s+|\\(no branch\\)\\s*/, \"\").split(/\\n/).map {|i|\n\t\t\ti.split(/ -> /)[0]\n\t\t}\n\t\tretrieve_branch_details(branches)\n\tend", "def check_current_branch_task\n raise \"Currently not on #{local_branch} branch!\" unless `#{git} branch`.split(\"\\n\").detect { |b| /^\\* / =~ b } == \"* #{local_branch}\"\n end", "def clone_repos repos\n $logger.info \"Detecting if clones repos #{repos}\"\n failed_repos = []\n repos.each do |repo|\n repo_path = \"#{GIT_DIR}/#{repo}\"\n # TODO: Use ssh instead of http\n clone_url = \"http://#{GIT_USER}:#{GIT_PASSWORD}@#{BASE_GIT_URL}:#{BASE_GIT_PORT}/scm/#{PROJECT_ID}/#{repo}.git\"\n unless `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' config --get remote.origin.url`.to_s.strip == clone_url\n $logger.info \"No git repo found or invalid git repo detected at #{repo_path}. Deleting and recloning project #{repo}\"\n # If for some reason we didn't detect that it's a git repo, just clear the whole directory\n # And reclone (note that we only need to clone the latest commit on the master branch)\n successfully_cloned = system \"git clone #{clone_url} --branch master --single-branch --depth 1 #{repo_path}\"\n unless successfully_cloned\n $logger.warn \"Could not git clone repo #{clone_url} to #{repo_path}\"\n failed_repos.push repo\n FileUtils.rm_rf repo_path\n end\n end\n # Make sure the git repos are unmodified before we do anything\n `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' reset --hard HEAD`\n end\n $logger.info \"Removing failed repos #{failed_repos}\"\n repos -= failed_repos\n return repos\nend", "def git_pull\n if `git branch -a` =~ /remotes\\/#{@remote}\\/#{@branch}/ ||\n `git ls-remote #{@remote}` =~ /refs\\/heads\\/#{@branch}/\n `git pull #{@remote} #{@branch}`\n end\n end", "def local_valid_repo?\n @local_dir_path.directory?\n end", "def skip_sync?\n if R8::Config[:node_agent_git_clone][:mode] == 'skip'\n return true\n end\n skip_sync = nil\n @head_git_commit_id = nil #nil means dont skip\n installed_agent_git_commit_id = @node.get_field?(:agent_git_commit_id)\n begin\n # TODO: ran into obscure problem when github is down; below does not work\n @head_git_commit_id = AgentGritAdapter.get_head_git_commit_id()\n if R8::Config[:node_agent_git_clone][:mode] == 'debug'\n installed_agent_git_commit_id = @node[:agent_git_commit_id] = nil\n end\n rescue => e\n Log.error(\"Error trying to get most recent sync agent code (#{e}); skipping the sync\")\n skip_sync = { error: true }\n end\n skip_sync || ((@head_git_commit_id == installed_agent_git_commit_id) && { error: false })\n end", "def update\n unless ENV.has_key? 'MWV_NO_UPDATE' or File.exist?($VP + 'no-update')\n system('git fetch origin') if Time.now - File.mtime($VP + '.git/FETCH_HEAD') > 604800 rescue nil\n end\nend", "def test_gitgo_different_from_remote_gitgo\n assert !sh(a, 'git branch -a').include?('gitgo')\n assert !sh(b, 'git branch -a').include?('gitgo')\n assert !sh(c, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"bshasum\") {|io| io << \"b content\" }\n sh(b, 'git add bshasum')\n sh(b, 'git commit -m \"added document\"')\n \n # setup remote from c\n sh(c, 'git branch gitgo')\n sh(c, 'git checkout gitgo')\n method_root.prepare(c, \"cshasum\") {|io| io << \"c content\" }\n sh(c, 'git add cshasum')\n sh(c, 'git commit -m \"added document\"')\n sh(c, 'git push origin gitgo')\n \n # now try to push back, fails\n assert sh(b, 'git push origin gitgo').include?(\"! [rejected] gitgo -> gitgo (non-fast forward)\")\n \n sh(a, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # merge\n sh(b, 'git fetch')\n assert sh(b, 'git branch').include?('gitgo')\n assert sh(b, 'git branch -a').include?('origin/gitgo')\n sh(b, 'git merge origin/gitgo')\n \n # now push works\n sh(b, 'git push origin gitgo')\n sh(a, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(a, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(a, \"cshasum\"))\n \n # fetch for c leaves changes unmerged\n sh(c, 'git fetch')\n sh(c, 'git checkout -f gitgo')\n assert_equal false, File.exists?(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n \n # manual merge fixes\n sh(c, 'git merge gitgo origin/gitgo')\n sh(c, 'git checkout -f gitgo')\n assert_equal \"b content\", File.read(method_root.path(c, \"bshasum\"))\n assert_equal \"c content\", File.read(method_root.path(c, \"cshasum\"))\n end", "def ci_errors?(pr)\n not travis.find_all{|b| b[:pull_req] == pr[:github_id] and b[:status] == 'errored'}.empty?\n end", "def test_read_files_wrong_repo\n get \"/repos/#{GIT_REPO}.git/branches/master/files/myfile.txt\"\n assert_equal 404, last_response.status\n end", "def fetch_latest_revision(m)\n Open3.popen3(\"cd #{FANCY_DIR} && git pull origin master\") do |stdin, stdout, stderr|\n err_lines = stderr.readlines\n if err_lines.size > 0\n # only print error lines if we're not dealing with an\n # already-up-to-date-message.\n unless err_lines.all?{|l| l !~ /Already up-to-date./}\n m.reply \"Got error while trying to update from repository:\"\n err_lines.each do |l|\n m.reply l.chomp\n end\n m.reply \"Won't/Can't build or run tests.\"\n return false # done since error\n end\n end\n end\n return true\n end", "def file_in_repo?(js_name)\n # Start-Open3\n Open3.popen3(\"git ls-files #{js_name} --error-unmatch\") do |stdin, stdout, stderr|\n # Start-If: Check if job script is committed in git repo \n if stderr.read.empty?\n return true\n else\n puts \"Please commit #{js_name} to the repository before qsub-ing it!\"\n return false\n end\n # End-If Check if job script is committed in git repo\n end\nend", "def verify_valid_update\n if branch_merge\n verify_valid_branch_merge\n elsif !overwrite?\n verify_non_destructive\n end\n end", "def merge?(treeish=upstream_branch)\n sandbox do |git, work_tree, index_file|\n des, src = safe_rev_parse(branch, treeish)\n \n case\n when src.nil? then false\n when des.nil? then true\n else des != src && git.merge_base({}, des, src).chomp(\"\\n\") != src\n end\n end\n end", "def test_git_log_can_have_no_changes\n assert_equal(0, extract_change_count_from_git_log(\"\"))\n end", "def branches?\n ! branch_targets.empty?\n end", "def test_remove_the_same_file_in_both_repos\n a.rm(\"one\").commit(\"a removed one\")\n b.rm(\"one\").commit(\"b removed one\")\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\",\n \"b removed one\",\n \"gitgo merge of origin/gitgo into gitgo\"\n ], b\n end", "def removed?\n branch == BASE\n end", "def test_branches_all\n branches = @lib.branches_all\n assert(branches.size > 0)\n assert(branches.select { |b| b[1] }.size > 0) # has a current branch\n assert(branches.select { |b| /\\//.match(b[0]) }.size > 0) # has a remote branch\n assert(branches.select { |b| !/\\//.match(b[0]) }.size > 0) # has a local branch\n assert(branches.select { |b| /master/.match(b[0]) }.size > 0) # has a master branch\n end", "def same_repo_pull_request?\n # When we're starting to archive payloads after N months we'll also disallow\n # restarting builds older than N months. Once we do so we can also return\n # false if Scheduler.config.enterprise is not true.\n\n # It's not the same repo PR if repo names don't match\n return false if head_repo_vcs_id != repository.vcs_id\n # It may not be the same repo if head_ref or head_sha are missing\n return false if head_ref.nil? or head_sha.nil?\n # It may not be same repo PR if ref is a commit\n return false if head_sha =~ /^#{Regexp.escape(head_ref)}/\n true\n rescue => e\n Travis::Scheduler.logger.error \"[request:#{id}] Couldn't determine whether pull request is from the same repository: #{e.message}\"\n false\n end", "def clean_working_tree?\n rugged.status do |_file, status|\n next if status.include?(:ignored)\n return false\n end\n true\n end", "def initial_commit?\n !Overcommit::Utils.execute(%w[git rev-parse HEAD]).success?\n end", "def initial_commit?\n !Overcommit::Utils.execute(%w[git rev-parse HEAD]).success?\n end", "def status\n @status ||= @repo.status(:unknown => true)\n end", "def test_integration_branch_is_optional\n modified_payload = modify_payload(payload)\n svc = service({'server_url' => 'nowhere', 'username' => 'someone', 'password' => '12345', 'central_repository' => '1'}, modified_payload)\n svc.xmlrpc_client = @server\n svc.receive_push\n\n assert @server.closed_bugs.include?(1)\n assert @server.bug_posts.include?(4)\n end", "def correct_setup?\n return required_keys_and_proper_remote_configuration_repo? &&\n local_configuration_repo_exists?\n end", "def git_clone_main\n raise \"oops, not done\"\nend", "def pr_is_intra_branch(req)\n return false unless pr_has_head_repo(req)\n\n if req['head']['repo']['owner']['login'] ==\n req['base']['repo']['owner']['login'] and\n req['head']['repo']['full_name'] == req['base']['repo']['full_name']\n true\n else\n false\n end\n end", "def repo_exists?(repo_id)\n return false if repo_id == nil || repo_id == false # It actually returns true without this conditon.\n app_client.repository?(repo_id)\nend", "def merged_with_git?(pr)\n\n #1. Commits from the pull request appear in the master branch\n q = <<-QUERY\n\t select c.sha\n from pull_request_commits prc, commits c\n\t where prc.commit_id = c.id\n\t\t and prc.pull_request_id = ?\n QUERY\n db.fetch(q, pr[:id]).each do |x|\n unless @all_commits.select { |y| x[:sha].start_with? y }.empty?\n return [true, :commits_in_master]\n end\n end\n\n #2. The PR was closed by a commit (using the Fixes: convention).\n # Check whether the commit that closes the PR is in the project's\n # master branch\n unless @closed_by_commit[pr[:github_id]].nil?\n sha = @closed_by_commit[pr[:github_id]]\n unless @all_commits.select { |x| sha.start_with? x }.empty?\n return [true, :fixes_in_commit]\n end\n end\n\n comments = issue_comments(pr[:login], pr[:project_name], pr[:github_id])\n\n comments.reverse.take(3).map { |x| x['body'] }.uniq.each do |last|\n # 3. Last comment contains a commit number\n last.scan(/([0-9a-f]{6,40})/m).each do |x|\n # Commit is identified as merged\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ied)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :commit_sha_in_comments]\n else\n # Commit appears in master branch\n unless @all_commits.select { |y| x[0].start_with? y }.empty?\n return [true, :commit_sha_in_comments]\n end\n end\n end\n\n # 4. Merg[ing|ed] or appl[ing|ed] as last comment of pull request\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ed)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :merged_in_comments]\n end\n end\n\n [false, :unknown]\n end", "def perform\n git.if_clean do\n check_out_branch\n merge_pull_request\n comment_about_merge\n end\n rescue => e\n case e\n when GitHub::PullRequest::NotFound\n cli.say \"Unable to find pull request #{pull_request_id}. Please retry with a valid ID.\"\n when Git::MergeFailed\n cli.say \"Merge failed. Please identify the source of this merge conflict resolve this conflict in your pull request's branch. NOTE: Merge conflicts resolved in the #{branch_type} branch are NOT used when deploying.\"\n when Git::CheckoutFailed\n cli.say \"Checkout of #{branch_to_merge_into} failed. Please contact Infrastructure to determine the cause.\"\n when GitHub::PullRequest::CommentFailed\n cli.say \"Unable to write comment. Please navigate to #{pull_request.url} and add the comment, '#{comment_body}'\"\n else\n cli.say \"An unknown error occurred: #{e.inspect}\"\n end\n raise\n end", "def merged_with_git?(pr)\n\n #1. Commits from the pull request appear in the master branch\n q = <<-QUERY\n\t select c.sha\n from pull_request_commits prc, commits c\n\t where prc.commit_id = c.id\n\t\t and prc.pull_request_id = ?\n QUERY\n db.fetch(q, pr[:id]).each do |x|\n unless @all_commits.select { |y| x[:sha].start_with? y }.empty?\n return [true, :commits_in_master]\n end\n end\n\n #2. The PR was closed by a commit (using the Fixes: convention).\n # Check whether the commit that closes the PR is in the project's\n # master branch\n unless @closed_by_commit[pr[:github_id]].nil?\n sha = @closed_by_commit[pr[:github_id]]\n if not @all_commits.select { |x| sha.start_with? x }.empty?\n return [true, :fixes_in_commit]\n end\n end\n\n comments = issue_comments(pr[:login], pr[:project_name], pr[:github_id])\n\n comments.reverse.take(3).map { |x| x['body'] }.uniq.each do |last|\n # 3. Last comment contains a commit number\n last.scan(/([0-9a-f]{6,40})/m).each do |x|\n # Commit is identified as merged\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ied)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :commit_sha_in_comments]\n else\n # Commit appears in master branch\n unless @all_commits.select { |y| x[0].start_with? y }.empty?\n return [true, :commit_sha_in_comments]\n end\n end\n end\n\n # 4. Merg[ing|ed] or appl[ing|ed] as last comment of pull request\n if last.match(/merg(?:ing|ed)/i) or \n last.match(/appl(?:ying|ed)/i) or\n last.match(/pull[?:ing|ed]/i) or\n last.match(/push[?:ing|ed]/i) or\n last.match(/integrat[?:ing|ed]/i) \n return [true, :merged_in_comments]\n end\n end\n\n [false, :unknown]\n end", "def pr_has_head_repo(req)\n not req['head']['repo'].nil?\n end", "def is_git?\n `git status 2> /dev/null` != \"\"\nend", "def process_pr(pr, cmd)\n head = pr[:head]\n repo = head[:repo]\n\n pending_status(pr, 'Merge in progress.')\n\n return true if skip_pr?(pr)\n\n begin\n cmd.run 'git fetch', repo[:ssh_url], head[:ref] if repo\n\n merge_status = cmd.run! 'git merge --no-ff --no-edit', head[:sha]\n\n if merge_status.success?\n success_status(pr, \"Merge with '#{@base_branch}' was successful.\")\n else\n cmd.run 'git merge --abort'\n\n message = \"Failed to merge '#{head[:ref]} with #{@base_branch}.\"\n failure_status(pr, message)\n end\n rescue => e\n failure_status(pr, \"Merge encountered an error: #{e.message}.\")\n\n return false\n end\n\n true\n end", "def sync_addon_branch_to_blessed_repo(repoName, remoteBranch, localBranch, pushForce = false)\n self.log(INFO,repoName,\"Checkout #{remoteBranch} branch (it is perhaps not the default) for #{repoName}...\")\n s = system(\"git checkout #{localBranch}\")\n if !s\n print(\"[ERROR] No #{remoteBranch} branch in repository #{repoName}, Skip this repo!!!\\n\")\n self.log(INFO,repoName,\"Done.\")\n # Let's process the next one\n else\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Reset #{localBranch} to #{remoteBranch} for #{repoName} ...\")\n s = system(\"git reset --hard #{remoteBranch}\")\n if !s\n abort(\"[ERROR] Reset #{localBranch} to #{remoteBranch} for #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Push #{localBranch} branch content from exo-addons repository to blessed repository ...\")\n\n forceParam = \"\"\n if pushForce\n forceParam = \"--force\"\n end\n\n s = system(\"git push #{forceParam} blessed #{localBranch}\")\n if !s\n abort(\"[ERROR] Push of #{localBranch} branch updates to repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n end\n end" ]
[ "0.75594795", "0.7272357", "0.7259582", "0.7091303", "0.704813", "0.6962056", "0.6953005", "0.66941285", "0.663144", "0.66307986", "0.6620442", "0.655548", "0.65153396", "0.64772177", "0.64114606", "0.6380712", "0.6375067", "0.6360829", "0.6318231", "0.625163", "0.622914", "0.6217764", "0.62064594", "0.61968976", "0.61630654", "0.6161799", "0.6119244", "0.61071295", "0.607028", "0.60423243", "0.60305804", "0.6020462", "0.5988784", "0.59760267", "0.5947763", "0.594643", "0.5927983", "0.5915977", "0.5915288", "0.59049237", "0.59045964", "0.5883665", "0.58631396", "0.5859423", "0.5847158", "0.5836375", "0.5812221", "0.5811875", "0.5804701", "0.57951206", "0.5767317", "0.5743217", "0.5740607", "0.5740337", "0.57331157", "0.57163405", "0.5683186", "0.56806034", "0.56726235", "0.5672291", "0.5665921", "0.56632996", "0.5645688", "0.5634135", "0.5633923", "0.56188357", "0.56053394", "0.55951", "0.5589389", "0.5586793", "0.558657", "0.55740154", "0.5571778", "0.5564287", "0.5557084", "0.55527806", "0.5545178", "0.55448157", "0.5543734", "0.5527209", "0.5525123", "0.5512275", "0.5504642", "0.5488433", "0.54802763", "0.5479476", "0.5479476", "0.5475642", "0.54708564", "0.5470539", "0.5465707", "0.54605377", "0.54416084", "0.5439776", "0.5438908", "0.5433017", "0.54305375", "0.5424816", "0.54099274", "0.54061633" ]
0.72219425
3
Add a tag reference in .git/refs/tags and push it to the remote if any. If a tag with the same name already exists it will get deleted (in both local and remote repositories).
def tag_release(tag) unless this_version == extract_version puts "Committing buildfile with version number #{extract_version}" Git.commit File.basename(Rake.application.rakefile.to_s), message Git.push if Git.remote end puts "Tagging release #{tag}" # Git.git 'tag', '-d', tag rescue nil Git.git 'push', Git.remote, ":refs/tags/#{tag}" rescue nil if Git.remote Git.git 'tag', '-f', '-a', tag, '-m', "[rake_release] Cutting release #{tag}" Git.git 'push', Git.remote, 'tag', tag if Git.remote end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push\n if @tags.empty?\n gash.send(:git, 'push', @push_to, @refspec)\n else\n gash.send(:git, 'push', '--tags', @push_to, @refspec)\n end\n end", "def create_remote_tag tag_name\n in_secondary_repository do\n create_local_tag tag_name\n run 'git push --tags'\n end\nend", "def push_tags(remote_name, id = nil)\n remote = find_or_create_remote(remote_name)\n raise RemoteNotFound, \"Remote named: #{remote_name} was not found\" unless remote\n all_refs = repo.tags.map(&:canonical_name)\n refs = if id\n tag = find_tag(id)\n tag.canonical_name if tag\n else\n all_refs\n end\n raise NoTagsExists, \"No tags were pushed\" if refs.empty?\n logger.debug(\"Pushing refs #{refs}\")\n logger.info(\"Pushing tags to remote #{remote.url}\")\n remote.push(refs, credentials: credentials)\n end", "def gitPushTag(pushTag)\n puts \"Pushing tag\"\n @gop.push(@remote, \"refs/tags/#{pushTag}\")\n end", "def tag(tag_name)\n git.tag(git_opts, tag_name)\n push(\"origin\", tag_name)\n self\n end", "def git_tag(versionString) \n\t\t\t\tshell_command(\"git tag #{versionString}\")\n\t\t\t\tshell_command(\"git push origin --tags\")\n\t\t\tend", "def create_tag(project, tag_name, ref)\n post(\"/projects/#{project}/repository/tags\", body: {tag_name: tag_name, ref: ref})\n end", "def create_standalone_remote_tag tag_name\n in_secondary_repository do\n run 'git checkout -b temp'\n run 'touch a.txt'\n run 'git add -A'\n run 'git commit -m \"temp\"'\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\n run 'git push --tags'\n end\nend", "def tag(tag, tag_msg=\"\", commit=nil)\n @tags << tag\n if commit\n gash.send(:git, 'tag', '-f', '-a', '-m', tag_msg, tag, commit)\n else\n gash.send(:git, 'tag', '-f', '-a', '-m', tag_msg, tag)\n end\n end", "def github_release_task\n sh git, 'push', '--tags', remote, remote_branch\n end", "def create_local_tag tag_name\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\nend", "def create_git_tag\n assignment_repository.write do |git|\n git.add_tag git_tag\n end\n end", "def push(remote_repo = remote, remote_branch = current_branch)\n git 'push', remote, current_branch\n end", "def push(remote_repo = remote, remote_branch = current_branch)\n git 'push', remote, current_branch\n end", "def update_repo_tag\n unless tag_name.nil? || tag_name.empty?\n callback(:update_repo_tag) do\n notify(:update_repo_tag)\n system_call \"git tag #{tag_name} #{match_tag_name} -f\"\n system_call \"git push -f origin #{tag_name}\"\n end\n end\n end", "def push(repo)\n before_push(repo)\n\n repo.cmd \"git remote add #{name} #{clone_url(repo)}\"\n repo.cmd \"git push --all #{name}\"\n after_push(repo)\n end", "def push(name, internal_repository)\n ensure_remote(name, internal_repository)\n\n git = git(name)\n branch = git.current_branch\n\n git.config \\\n \"remote.#{REMOTE}.push\",\n \"refs/heads/#{branch}:refs/heads/#{branch}\"\n\n git.push(REMOTE, branch)\n end", "def push(remote_repo, opts={:force => false, :revs => nil})\n if remote_repo.capable? \"unbundle\"\n push_unbundle remote_repo, opts\n else\n push_add_changegroup remote_repo, opts\n end\n end", "def tag_release(version)\n system \"git tag v#{version}\"\n system \"git push origin v#{version}\"\n end", "def git_push(host, branch, git_repo_path)\n git_on(host, \"push origin #{branch}\", git_repo_path)\nend", "def git_push(remote = 'origin')\n mysystem(\"git push --set-upstream #{remote} #{git_current_branch}\")\n end", "def add_tag(tag)\n @api.post(\"#{@api.path}/List/#{@id}/Tag\", body: tag)\n end", "def push_repo\n reference_point = git_branch_name || git_tag_name || 'master'\n callback(:push_repo) do\n notify(:push_repo, reference_point: reference_point, app_name: app_name, force: force)\n force_flag = force ? \"-f \" : \"\"\n system_call \"git push #{force_flag}#{deployment_remote} #{reference_point}:refs/heads/master\"\n end\n end", "def update_remote_tags!(new_file=nil)\n Cloudinary::Api.update(my_public_id, tags: tags)\n end", "def push(remote)\n namehost, folder, _barefolder = split_url(remote.name)\n puts 'simple_push'\n simple_push(remote('origin'))\n puts 'bare_repo.push'\n bare_repo.push(remote)\n try_system %[ssh #{namehost} \"cd #{folder} && git pull origin\"]\n end", "def tag_add(id, tag)\n wf_event_id?(id)\n wf_string?(tag)\n api.put([id, 'tag', tag].uri_concat)\n end", "def pushToGitRemotes(branch = 'develop', force = 0)\n if force\n force = \"-f\"\n else\n force = \"\"\n end\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pushing #{branch} to remote: #{branch}\\\"\")\n sh(\"git push #{force} #{remote} #{branch}\")\n end\nend", "def add_tag(tags: nil, track_id: nil)\n tag_names ||= [params[:tags]].flatten\n track_id ||= params[:track_id]\n\n track = current_user.tracks.find(track_id)\n\n added_tags = []\n\n tag_names.reject { |tag_name| tag_name == \"\" || tag_name == \" \" }.each do |tag_name|\n if !(tag = Tag.find_by(name: normalize(tag_name)))\n tag = Tag.create(name: normalize(tag_name))\n end\n unless track.tags.map{ |tag| tag.name.downcase }.include? tag.name.downcase\n track.tags << tag\n added_tags << tag\n end\n end\n end", "def push\n if options.origin.nil?\n logger.error \"No origin URI has been defined for this room\"\n exit 1\n end\n \n if tags.empty?\n logger.error \"Room has no tags. You must create at least one tag before pushing.\"\n exit 1\n end\n\n connect if exp.nil?\n \n # DEADWOOD - Bad idea, lets just force fully qualified paths\n # if uri =~ /\\/~\\//\n # logger.debug \"converting ~ into a real path; uri=#{uri}\"\n # remote_home = ssh.exec!('echo $HOME').chomp\n # uri.sub!(/\\/~\\//, remote_home + '/')\n # logger.debug \"remote home is #{remote_home}, new URI is #{uri}\"\n # end\n \n uri = URI(options.origin)\n\n raise \"unsupported scheme; uri=#{uri}\" unless %w(sftp file).include? uri.scheme\n puts \"pushing room #{name} to #{uri.to_s}\"\n\n basedir = uri.path\n safe_basedir = Shellwords.escape(basedir)\n\n begin\n exp.mkdir basedir\n rescue\n # WORKAROUND: not idempotent\n end\n\n unless exp.ls('').include? 'tags'\n exp.mkdir('tags')\n end\n @platform.mkdir(exp, 'tags')\n\n logger.debug \"uploading options.json\"\n exp.upload(mountpoint + '/etc/options.json', \"options.json\")\n\n @tag_index.construct(self) # KLUDGE\n @tag_index.push\n end", "def add_tag(tag)\n if not tag.kind_of?(String)\n raise \"tag '#{tag.inspect}' is not a String\"\n end\n\n if not @tags.include?(tag)\n @tags.push(tag)\n end\n \n end", "def push(options={})\n raise MissingRemote unless has_remotes?\n options.merge! :remote => DEFAULT_REMOTE, :ref => DEFAULT_LOCAL_REF\n remotes[options[:remote]].push([options[:ref]], {:credentials => credentials})\n end", "def add_tag!(tag)\r\n tag = add_tag(tag)\r\n tag.save\r\n end", "def add_tag(tag_name)\n return false if tag_name.strip == \"\"\n return false if tags.find_by_name(tag_name)\n\n tags << (Tag.where(name: tag_name)[0] || Tag.create(name: tag_name))\n save\n return true\n end", "def push\n unless system(\"cd #{repo_path};git push origin #{branch}\")\n raise GitCloud::GitException.new(\"Push\")\n end\n end", "def tag_object(tag, sha)\n git.fs_write(\"refs/tags/#{clean_tag(tag)}\", sha)\n end", "def create_tag(dir, branch, tag, message)\n\tDir.chdir(dir) do |path|\n\t\tcmds = [\"git checkout #{branch}\", \n\t\t\t\t\"git pull\",\n\t\t\t\t\"git tag -a #{tag} -m '#{message}'\"\n\t\t\t\t]\n\t\tcmds.delete_at(1) unless remote_branch_exists?(path, branch)\n\t\tapprove_and_execute(cmds, \"in #{path}\")\n\tend\nend", "def add_tag\n url = Url.find_by(id: params[:id])\n tag = Tag.find_by(name: params[:tag])\n if tag\n ## TODO: handle tag with url in backend\n # if not url.tags.where(:tag_id => tag.id).any?\n # url.tags << tag\n # end\n url.tags << tag\n else\n tag = Tag.new(name: params[:tag])\n url.tags << tag\n end\n render json: {code: 200, tags: url.tags}\n end", "def git_tag tag\n system \"git tag #{tag}\"\n raise \"tag failed\" unless $?\nend", "def add_tag(tag)\r\n self.tags.new(:name => tag.name)\r\n end", "def unpushed_tags\n output_of \"git push --tags --dry-run 2>&1 | grep 'new tag' | awk '{print $4}'\"\nend", "def tagged?(url, ref)\n reference = Pkg::Util::Git_tag.new(url, ref)\n reference.tag?\n end", "def add(user_id, tag)\n @_client.post(\"/users/#{user_id}/tags\", value: tag)\n end", "def push(_branch)\n puts 'TODO: Implement Git.push'\n end", "def add_tag(tag)\n\n (h.fields['__tags__'] ||= []) << tag\n end", "def git_add_commit_push(host, branch, message, git_repo_path)\n git_add_everything(host, git_repo_path)\n git_commit_push(host, branch, message, git_repo_path)\nend", "def update_tags(tags = nil)\n set_tags(tags)\n write_tags_to_repo\n read_tags_from_repo\n save!\n end", "def add_tag(*tags)\n tags.each_with_index do |tag, i|\n case tag\n when Tags::Tag\n @tags << tag\n when Tags::RefTag\n @ref_tags << tag\n else\n raise ArgumentError, \"expected Tag or RefTag, got #{tag.class} (at index #{i})\"\n end\n end\n end", "def git_push(*remotes)\n remotes.each do |remote|\n git(:push => \"#{remote} master\")\n end\n end", "def add_tags(tags)\n rsp = @flickr.send_request('flickr.photos.addTags', {:photo_id => self.id, :tags => tags}, :post)\n true\n end", "def add_tag(tag_id)\n tag = Tag.find_by_id(tag_id)\n return false if tags.include?(tag)\n tags << tag\n return true\n end", "def push_to_remote(local_branch, remote_branch, remote_name, opts)\n remote_name ||= 'origin'\n\n args = [remote_name]\n\n local_branch ||= branches.current\n remote_branch ||= local_branch\n args << '-f' if opts[:force]\n\n logger.info do\n if local_branch == remote_branch\n \"Pushing to '#{remote_branch}' on '#{remote_name}'.\"\n else\n \"Pushing #{local_branch} to '#{remote_branch}' on '#{remote_name}'.\"\n end\n end\n\n args << \"#{local_branch}:#{remote_branch}\"\n return command(:push, args)\n end", "def push_image_to_remote(image)\n\n if !image.tagged_for_remote\n raise \"Image not yet tagged (use tag_for_remote function)\"\n end\n\n if image.local_image_id.nil?\n raise \"No local id set in image\"\n end\n\n if image.remote_repository.nil?\n raise \"Image has not remote repository specified\"\n end\n\n # api push command oddly fails silently - not sure what's up\n # also, api appears to give no feedback as image is uploaded - which can take some time\n\n # raw_image = self.get_raw_image_by_id(image.local_image_id)\n # https://github.com/bkeepers/dotenv\n # result = raw_image.push(nil,repo_tag: image.remote_repository.get_remote_repository_name + \":\" + image.primary_image_tag)\n # puts result.inspect\n\n\n # drop to command line and issue push via docker-cli for now\n push_command = \"docker push #{image.remote_repository.get_remote_repository_name}:#{image.primary_image_tag}\"\n system push_command\n\n if $?.exitstatus == 0\n return true\n else\n return false\n end\n\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 add_tag (tag)\n `rs_tag --add \"#{tag}\"`\n end", "def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def add_tag(tag)\n @added_tags ||= Set.new\n @added_tags << tag\n end", "def add_tag(tag: required(\"tag\"), options: {}, **data)\n with_params = data.merge(tag: tag).reject { |_,v| v.nil? || Array(v).empty? }\n client.post(\"/tasks/#{gid}/addTag\", body: with_params, options: options) && true\n end", "def push()\n\t\tbegin\n\t\t\t@git.push('origin','master')\n\t\trescue Git::GitExecuteError => e\n\t\t\tif (e.to_s.include?(\"refspec master does not match any\"))\n\t\t\t\tLogger::log(@carpeta,Logger::INFO,\"No hay cambios para subir al servidor\")\n\t\t\telse\n\t\t\t\traise UploadException, \"Error al subir los cambios al servidor\" , caller\n\t\t\tend\n\t\tend\n\tend", "def push_notes(notes)\n run(\"git notes --ref #{refname} add -f -F -\", {:stdin_str => notes, :raise => true})\n ret = run(\"git push origin refs/notes/#{refname}\")\n raise(ConcurrentUpdateError, \"trouble pushing notes\") unless ret[:val] == 0\n end", "def git_remote_add(remote_name, remote_url)\n cmd = \"#{discover_git_executable} remote add upstream \\\"#{remote_url}\\\"\"\n debug \"Running #{cmd} 2>&1\"\n output = %x[#{cmd} 2>&1]\n raise RHC::GitException, \"Error while adding upstream remote - #{output}\" unless output.empty?\n end", "def add_remote(uri, name)\n @repository.add_remote(name,uri)\n \n self.remotes\n end", "def add_tag_to_server server_uuid, tags\n tag = (tags.respond_to? :join && tags.join(\",\") || tags)\n\n post \"server/#{server_uuid}/tag/#{tag}\"\n end", "def git_tag_delete(versionString) \n\t\t\t\tshell_command(\"git push --delete origin #{versionString}\")\n\t\t\t\tshell_command(\"git tag --delete #{versionString}\")\n\t\t\tend", "def push(uuid, repo, from_repo_uuid = nil, to_repo_uuid = nil)\n from_repo_uuid ||= @uuid\n to_repo_uuid ||= repo.uuid\n remote_head = repo.head(uuid, to_repo_uuid)\n # TODO: receiver must store received versions somewhere, \n # then try fast-forward merge or report an error.\n # Find out what this \"somewhere\" is. Maybe, a temporary\n # repo/branch.\n end", "def push_repo\n UI.puts \"\\nPushing the `#{@repo}' repo\\n\".yellow\n repo_git('push', 'origin', 'HEAD')\n end", "def git_commit_and_push(cookbook_path, github_url)\n if File.exists?(File.join(cookbook_path, \".git\"))\n shell_out(\"git remote rm origin\", :cwd => cookbook_path)\n else\n shell_out!(\"git init\", :cwd => cookbook_path)\n end\n shell_out!(\"echo - $(date): Uploaded with knife github plugin. >> CHANGELOG.md \", :cwd => cookbook_path)\n shell_out!(\"git add .\", :cwd => cookbook_path)\n shell_out!(\"git commit -m 'creating initial cookbook structure from the knife-github plugin' \", :cwd => cookbook_path)\n shell_out!(\"git remote add origin #{github_url} \", :cwd => cookbook_path)\n shell_out!(\"git push -u origin master\", :cwd => cookbook_path)\n end", "def git_commit_push(host, branch, message, git_repo_path)\n git_on(host, \"commit -m \\\"#{message}\\\"\", git_repo_path)\n git_push(host, branch, git_repo_path)\nend", "def add_remote(name, url, opts = {})\n url = url.repo.path if url.is_a?(Git::Base)\n self.lib.remote_add(name, url, opts)\n Git::Remote.new(self, name)\n end", "def commit_and_tag(new_version)\n git = Git.init\n git.add([VERSION_FILE, \"Gemfile.lock\"])\n git.commit(\"Update to #{new_version}\")\n git.add_tag(new_version.to_s)\n end", "def push_add_changegroup(remote, opts={})\n # no locking cuz we rockz\n ret = pre_push remote, opts\n \n if ret[0]\n cg, remote_heads = *ret\n remote.add_changegroup cg, :push, url\n else\n ret[1]\n end\n end", "def push_tags *tags\n # Check for nil tags\n Thread.current[:semantic_logger_tags] = self.tags.concat(tags)\n end", "def push(tracking_branch=upstream_branch)\n sandbox do |git, work_tree, index_file|\n remote, remote_branch = parse_tracking_branch(tracking_branch)\n git.push({}, remote, \"#{branch}:#{remote_branch}\") unless head.nil?\n end\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 tag_exists?(tag_name, options = {})\n options = {\n :repo => nil\n }.merge(options)\n repo = options[:repo] || default_repository\n\n # note that remote tags cannot be queried directly; use git fetch --tags to\n # import them first.\n repo.tags.any? { |tag| tag.name == tag_name }\n end", "def add_tags(artist, track, tags)\n post(:session, {:method => \"track.addTags\", :artist => artist, :track => track, :tags => tags})\n end", "def commit_and_push_to_repo(oauth_token, commit_message, \n tree_sha, head_sha, ref_name)\n client = Octokit::Client.new(access_token: oauth_token)\n sha_new_commit = client.create_commit(full_repo_name, commit_message, tree_sha, head_sha)[:sha]\n client.update_ref(full_repo_name, ref_name, sha_new_commit)\n end", "def push(repository)\n # add all files to the repository\n repository.add(all: true)\n\n # commit, but be aware: current version could be identical to previous version resulting in an error\n begin\n repository.commit('Application deployment via Nucleus')\n rescue Git::GitExecuteError => e\n # usually indicates that no files could be committed, repository is up to date\n log.debug(\"Git commit failed: #{e}\")\n end\n\n # repack to enhance compression\n repository.repack\n\n # force push, so that the push is executed even when all files remain unchanged\n repository.push('origin', @repo_branch, force: true)\n end", "def tag_commit(tag_name)\n link = url_helpers.project_tag_path(project, id: tag_name)\n body = \"tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})\"\n\n create_note(NoteSummary.new(noteable, project, author, body, action: 'tag'))\n end", "def add(tag)\n return nil if tag.nil?\n get_list(tag) << tag\n end", "def pushtobare(branch = 'master')\n remote = satelliterepo.remotes['bare']\n remote = satelliterepo.remotes.create 'bare', barerepo.path unless remote\n satelliterepo.push remote, [\"refs/heads/#{branch}\"]\n end", "def pushtobare(branch = 'master')\n remote = satelliterepo.remotes['bare']\n remote = satelliterepo.remotes.create 'bare', barerepo.path unless remote\n satelliterepo.push remote, [\"refs/heads/#{branch}\"]\n end", "def tag_with_name(tag_name, message=\"automated tagging\")\r\n tag_url = build_tag_url_for_base(tag_name)\r\n tag(@repository_trunk, tag_url, message)\r\n end", "def apply\n repo.push('origin', ['refs/heads/master'], credentials: credentials)\n end", "def add_tag(new_tag)\n db = connect_to_database()\n db.execute(\"INSERT INTO tags (Tag) VALUES (?)\", new_tag.downcase)\n end", "def tag_release(tag)\n unless this_version == extract_version\n info \"Committing buildfile with version number #{extract_version}\"\n Git.commit File.basename(version_file), message\n Git.push if Git.remote\n end\n info \"Tagging release #{tag}\"\n Git.git 'tag', '-d', tag rescue nil\n Git.git 'push', Git.remote, \":refs/tags/#{tag}\" rescue nil if Git.remote\n Git.git 'tag', '-a', tag, '-m', \"[buildr] Cutting release #{tag}\"\n Git.git 'push', Git.remote, 'tag', tag if Git.remote\n end", "def tag(arg='')\n `git tag #{arg} 2>&1`\n end", "def add_remote(name, url)\n remotes.create name, url\n end", "def upload!(file_path)\n raise GitCloud::FileException.new(\"NotFound\") unless File.exists? file_path\n file = File.new(File.expand_path(file_path))\n add(file)\n commit\n push\n end", "def add_tag_associations(tags)\n tags.each do |tag|\n t = Tag.find_by_tag(tag)\n if t\n self.tags << t\n else\n t = Tag.new(:tag => tag)\n self.tags << t if t.save\n end\n end \n end", "def tag(tag_name)\n Git::Object.new(self, tag_name, 'tag', true)\n end", "def register tag, name\n @tags[name] = tag\n end", "def register tag, name\n @tags[name] = tag\n end", "def create_tag(project_name, repository_name, reference, tag, opts = {})\n create_tag_with_http_info(project_name, repository_name, reference, tag, opts)\n nil\n end", "def push(args, create_upstream: nil)\n args = args.dup + ['--set-upstream', create_upstream, branch] if create_upstream\n execute_git_output('push', args)\n $?.exitstatus == 0 || (create_upstream && $?.exitstatus == 128)\n end", "def git_push_commits\n shellout(\"git push #{config[:remote]} #{config[:branch]}\")\n end", "def tag(tag_name, *args)\n tag_names = tag_name.split(args.first)\n\n tag_names.each do |tag_name|\n if !(self.tag_ids.include?(tag_name))\n tags << Tag.find_or_create_by(name: tag_name)\n end\n end\n self\n end", "def git_add_everything(host, git_repo_path)\n git_on(host, \"add #{git_repo_path}/*\", git_repo_path)\nend", "def commit_and_tag(bump_info)\n @logger.log '===> executing commands'\n @command.exec 'git add .'\n @command.exec \"git commit -m '#{bump_info.commit_message}'\"\n @command.exec \"git tag v#{bump_info.after_version}\"\n end", "def tag!(params = {})\n self.post params, edge: :tags\n end" ]
[ "0.7777915", "0.7551755", "0.7480573", "0.7452982", "0.7365588", "0.6967257", "0.68803537", "0.6762316", "0.6700378", "0.66698194", "0.6644311", "0.654587", "0.65042657", "0.65042657", "0.64787716", "0.64714426", "0.6445232", "0.6379065", "0.63734734", "0.63487726", "0.6323766", "0.6319961", "0.62100315", "0.6191764", "0.61681914", "0.6147587", "0.60835093", "0.6069341", "0.60637087", "0.6062618", "0.60594875", "0.6040909", "0.60405654", "0.6031092", "0.5992918", "0.59888047", "0.5988559", "0.59315544", "0.5910931", "0.59014827", "0.58809745", "0.5853356", "0.5845159", "0.5840939", "0.5821613", "0.5814043", "0.58067137", "0.5801177", "0.57924294", "0.57870775", "0.57636803", "0.57594347", "0.5742961", "0.5740745", "0.57143754", "0.57073915", "0.5704582", "0.57033485", "0.5671412", "0.5666999", "0.5663687", "0.566278", "0.5654875", "0.5651471", "0.5638606", "0.5629025", "0.56261885", "0.5625126", "0.56238484", "0.56218076", "0.56024456", "0.5600156", "0.5583639", "0.5583639", "0.55716205", "0.55714315", "0.5568598", "0.5548853", "0.553312", "0.5528031", "0.55234474", "0.55234474", "0.5511689", "0.55074334", "0.5503209", "0.549507", "0.5472896", "0.54682547", "0.54660666", "0.5451635", "0.5451125", "0.5450189", "0.5450189", "0.54466534", "0.54448295", "0.5439693", "0.5439378", "0.5412145", "0.5410818", "0.54075676" ]
0.54731333
86
AYUDAME: Refactoriza buscando elegancia
def squared_primes(array) primos = array.find_all{|x| (2...x).select(){|i| x % i == 0 }.count == 0 } primos.map{|p| p*p} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def private; end", "def schubert; end", "def zuruecksetzen()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def mi_carrera\n\n\tend", "def romeo_and_juliet; end", "def probers; end", "def formation; end", "def operations; end", "def operations; end", "def schumann; end", "def common\n \n end", "def unusual_sport; end", "def transformations; end", "def terpene; end", "def relatorios\n end", "def custom; end", "def custom; end", "def lookups; end", "def intensifier; end", "def verdi; end", "def upc_e; end", "def berlioz; end", "def bellini; end", "def methods() end", "def manufacture; end", "def helpers; end", "def helpers; end", "def helpers; end", "def code_of_conduct; end", "def anchored; end", "def upc_e_with_composite_symbology; end", "def who_we_are\r\n end", "def basic_clasificator origen,dpworld_data,stwd_data,hit_data\n origen.each do |params|\n\tputs \"FILA: #{params.to_s}\"\n $LOG.debug \" LIBERACION: #{params.to_s}\"\n case [ params['ptocreacion'] , params['solvenciaNotifId'] ]\n when ['DOCAU',1]\n dpworld_data << ReleaseCaucedo.new( params )\n when ['DOCAU',4]\n stwd_data << ReleaseSTWD.new( params )\n when ['DOHAI',2]\n\t hit_data << ReleaseHIT.new( params )\n end\n end\n [dpworld_data,stwd_data,hit_data]\nend", "def jack_handey; end", "def villian; end", "def refutal()\n end", "def guct\n end", "def eplore\n end", "def rossini; end", "def monica\n end", "def especies_filtros\n return unless tiene_filtros?\n self.taxones = Especie.select(:id).select(\"#{Scat.attribute_alias(:catalogo_id)} AS catalogo_id\").joins(:scat).distinct\n por_especie_id\n por_nombre\n #estatus\n #solo_publicos\n estado_conservacion\n tipo_distribucion\n uso\n formas_crecimiento\n ambiente\n\n #return unless por_id_o_nombre\n #categoria_por_nivel\n end", "def feruchemist; end", "def upc_a_with_composite_symbology; end", "def extra; end", "def apis; end", "def analyze_component_breakdown\n\n end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def compilereturn\n\n end", "def inject(obj)\n obj.instance_eval do\n\n def cedente\n self.contribuicao.instituicao.nome.to_s.remover_acentos\n end\n\n def dados_sacado\n dados = \"\"\n cidade_uf = self.contribuicao.pessoa.cidade ? self.contribuicao.pessoa.cidade.nome.as_campo(15) : \"\".as_campo(15)\n cidade_uf += self.contribuicao.pessoa.cidade ? self.contribuicao.pessoa.cidade.estado.sigla.as_campo(2) : \"\".as_campo(2)\n # NOME - 35\n dados += self.contribuicao.pessoa.nome ? self.contribuicao.pessoa.nome.as_campo(35) : \"\".as_campo(35)\n # ENDERECO - 40\n dados += self.contribuicao.pessoa.endereco_minimo.as_campo(40)\n if self.contribuicao.pessoa.endereco.blank?\n # BAIRRO - 12\n dados += self.contribuicao.pessoa.endereco_cobranca_bairro ? self.contribuicao.pessoa.endereco_cobranca_bairro.as_campo(12) : \"\".as_campo(12)\n # CIDADE - 15 e UF - 2\n dados += cidade_uf\n # CEP - 8\n dados += self.contribuicao.pessoa.endereco_cobranca_cep ? self.contribuicao.pessoa.endereco_cobranca_cep.as_campo(8) : \"\".as_campo(8)\n else\n # BAIRRO - 12\n dados += self.contribuicao.pessoa.bairro ? self.contribuicao.pessoa.bairro.as_campo(12) : \"\".as_campo(12)\n # CIDADE - 15 e UF - 2\n dados += cidade_uf\n # CEP - 8\n dados += self.contribuicao.pessoa.cep ? self.contribuicao.pessoa.cep.as_campo(8) : \"\".as_campo(8)\n end\n # REGISTRO - 6 + CAMPO LIVRE - 20\n dados += 0.as_campo(6,0) + CAMPO_LIVRE_20 + \" \".as_campo(5)\n dados += self.contribuicao.pessoa.cpf ? self.contribuicao.pessoa.cpf.to_i.as_campo(15,0) : 0.as_campo(15,0)\n dados += \" \"\n dados.remover_acentos\n end\n\n def vencimento\n self.data_referencia\n end\n\n # Formacao do nosso numero\n # {XXXXXXXXXX}-{D}\n # {XXXXXXXXXX} -> ID DA CONTRIBUICAO\n # {D} -> Digito verificador mod11(Codigo da agencia cedente + ID DA CONTRIBUICAO)\n def nosso_numero\n self.id.as_campo(10,0).to_s\n end\n\n def digito_nosso_numero\n (agencia.as_campo(4).to_s + nosso_numero).modulo11_mercantil { |valor| [0,1].include?(valor) ? 0 : (11 - valor) }\n end\n\n def valor_documento\n self.valor\n end\n\n def numero_carteira\n \"06\"\n end\n\n def quantidade_moeda\n \"000000000000000\"\n end\n\n def especie_documento\n \"OU\"\n end\n\n def aceite\n \"N\"\n end\n\n def instrucoes_bancarias\n instrucoes = \"\"\n if self.contribuicao.contrato_cobranca.conta.instrucoes_bancarias\n (0..5).each do |ix|\n instrucoes += (self.contribuicao.contrato_cobranca.conta.instrucoes_bancarias.split(Conta::QUEBRA_INSTRUCAO_BANCARIA)[ix]).to_s.as_campo(70)\n end\n end\n instrucoes.remover_acentos\n end\n\n def instrucoes_sacado\n instrucoes = \"\"\n if self.contribuicao.contrato_cobranca.conta.instrucoes_bancarias\n (0..2).each do |ix|\n instrucoes += (self.contribuicao.contrato_cobranca.conta.instrucoes_sacado.split(Conta::QUEBRA_INSTRUCAO_SACADO)[ix]).to_s.as_campo(40)\n end\n end\n instrucoes.remover_acentos\n end\n\n def mensagem_sacado\n # mensagem = \"Pagamento referente a manutencao de menores carentes assistidas pela Cidade dos Meninos Sao Vicente de Paulo.\".as_campo(130)\n mensagem = \"\".as_campo(130)\n # mensagem += \"visite nosso site:www.redesolidariedade.org.br ou (31)3228-9236\".as_campo(130)\n mensagem += \"\".as_campo(130)\n # mensagem += \"Ser anjo e voce ser capaz de iluminar no momento em que o outro e trevas!\".as_campo(130)\n mensagem += \"\".as_campo(130)\n mensagem += \"\".as_campo(1560)\n end\n\n def agencia\n self.contribuicao.contrato_cobranca ? self.contribuicao.contrato_cobranca.conta.agencia.to_f.as_campo(4,0) : 0.as_campo(4,0)\n end\n\n def codigo_cedente\n self.contribuicao.contrato_cobranca ? self.contribuicao.contrato_cobranca.numero_contrato.to_f.as_campo(9,0) : 0.as_campo(9,0)\n end\n\n def cnpj_cedente\n self.contribuicao.contrato_cobranca.conta.cnpj.gsub(/\\.|\\/|\\-|\\s/,'').as_campo(14)\n end\n\n def indicador_ano\n \"S\"\n end\n\n def instrucao_codificada\n \"0000\"\n end\n\n end\n end", "def ibu; end", "def method_731(base); end", "def transforms; end", "def transform; end", "def mambo_no_5; end", "def invention; end", "def registers; end", "def winter_paralympics_sport; end", "def mapping; end", "def mapping; end", "def aplicar_a_jugador(actual,todos)\r\n case @tipo\r\n when Tipo_sorpresa::IR_CARCEL\r\n aplicar_a_jugador_ir_carcel(actual,todos)\r\n when Tipo_sorpresa::IR_CASILLA\r\n aplicar_a_jugador_ir_a_casilla(actual,todos)\r\n\r\n when Tipo_sorpresa::PAGAR_COBRAR\r\n aplicar_a_jugador_pagar_cobrar(actual,todos)\r\n\r\n when Tipo_sorpresa::SALIR_CARCEL\r\n aplicar_a_jugador_salir_carcel(actual,todos)\r\n\r\n when Tipo_sorpresa::POR_CASA_HOTEL\r\n aplicar_a_jugador_por_casa_hotel(actual,todos)\r\n\r\n when Tipo_sorpresa::POR_JUGADOR\r\n aplicar_a_jugador_por_jugador(actual,todos)\r\n\r\n end\r\n end", "def pessoavaidois(lugar)\n \"indo para \" + lugar\nend", "def transformation\n end", "def weber; end", "def processor; end", "def buzzword; end", "def buzzword; end", "def malts; end", "def solicitudes_atrasadas\n end", "def winter_olympics_sport; end", "def offences_by; end", "def letzte_komponente\n \n end", "def silly_adjective; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def controlQxxt(jugadalot)\n \n @modelo = Aliasmodelosiglasorteot.where(:siglasorteo => jugadalot.sorteot.sigla).first.modelocontrolq \n @modelo = @modelo.capitalize.classify.constantize # Esto para convertir string en constante y poder acceder al modelos de Active Record. Scado de este link: https://stackoverflow.com/questions/34757582/using-variables-for-model-names-in-active-record \n c = @modelo.where(:numero => jugadalot.n1.to_i).first\n (c.limite - c.vendida) - jugadalot.monto # retorna la diferencia. # Disponible = (c.limite - c.vendida) \n\n end", "def appraisals; end", "def appraisals; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def celebration; end", "def heroine; end", "def summer_paralympics_sport; end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def find_all\n \n end", "def trd; end", "def implementation; end", "def implementation; end", "def usar_metodo\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n\n return_value = UsarMetodoReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __LPAR157__ = nil\n __RPAR159__ = nil\n qualified_name156 = nil\n parametros158 = nil\n\n\n tree_for_LPAR157 = nil\n tree_for_RPAR159 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 160:4: qualified_name LPAR ( parametros )? RPAR\n @state.following.push( TOKENS_FOLLOWING_qualified_name_IN_usar_metodo_723 )\n qualified_name156 = qualified_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, qualified_name156.tree )\n end\n\n __LPAR157__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_usar_metodo_725 )\n if @state.backtracking == 0\n tree_for_LPAR157 = @adaptor.create_with_payload( __LPAR157__ )\n @adaptor.add_child( root_0, tree_for_LPAR157 )\n\n end\n\n # at line 160:24: ( parametros )?\n alt_21 = 2\n look_21_0 = @input.peek( 1 )\n\n if ( look_21_0 == COMILLA || look_21_0.between?( DOUBLEDOT, DecimalLiteral ) || look_21_0 == Identificador || look_21_0.between?( T__81, T__82 ) )\n alt_21 = 1\n end\n case alt_21\n when 1\n # at line 160:24: parametros\n @state.following.push( TOKENS_FOLLOWING_parametros_IN_usar_metodo_727 )\n parametros158 = parametros\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, parametros158.tree )\n end\n\n\n end\n __RPAR159__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_usar_metodo_730 )\n if @state.backtracking == 0\n tree_for_RPAR159 = @adaptor.create_with_payload( __RPAR159__ )\n @adaptor.add_child( root_0, tree_for_RPAR159 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n\n end\n\n return return_value\n end", "def filter(event)\n\n #Category\n category = event.get(\"category\")\n if category.nil?\n category = \"\"\n end\n\n new_category = fn_make_cate_all(category, 0) \n event.set(\"category\", new_category)\n\n service_gubun = event.get(\"service_gubun\")\n\n new_cat1 = fn_make_cate_all(category, 2) \n event.set(\"cat1\", new_cat1)\n \n new_cat2 = fn_make_cate_all(category, 4) \n event.set(\"cat2\", new_cat2)\n \n new_cat3 = fn_make_cate_all(category, 6) \n event.set(\"cat3\", new_cat3)\n \n new_cat4 = fn_make_cate_all(category, 8) \n event.set(\"cat4\", new_cat4)\n\n new_cg = \"\"\n if service_gubun == \"1\"\n new_cg = new_cat2 \n else\n new_cg = new_cat1 \n end \n event.set(\"cg\", new_cg)\n\n #Model Factory\n #deplecated : ES에서 Model-Factory 전용 Tokenizer 사용\n=begin\n if service_gubun == \"1\"\n modelnm = event.get(\"modelnm\")\n factory = event.get(\"factory\")\n if modelnm.nil?\n modelnm = \"\"\n end\n if factory.nil?\n factory = \"\"\n end\n\n model_factory = factory_all(modelnm+\" \"+factory)\n event.set(\"model_factory\", model_factory)\n end\n=end\n \n return [event]\n\nend", "def king_richard_iii; end", "def summer_olympics_sport; end" ]
[ "0.65795237", "0.64750725", "0.60494614", "0.6011357", "0.59995115", "0.59995115", "0.59995115", "0.59995115", "0.5991556", "0.5959397", "0.5831461", "0.5824543", "0.5770559", "0.5770559", "0.5756773", "0.5740751", "0.57021457", "0.56953394", "0.56877494", "0.566284", "0.5636099", "0.5636099", "0.56278026", "0.5592862", "0.5589028", "0.5582924", "0.5582074", "0.55660903", "0.5561861", "0.55329776", "0.5518922", "0.5518922", "0.5518922", "0.55096006", "0.5502437", "0.54980844", "0.5494164", "0.5480407", "0.54804057", "0.54677695", "0.54605144", "0.5428477", "0.54154307", "0.53990257", "0.5393093", "0.5393022", "0.5391188", "0.5390299", "0.5354355", "0.535392", "0.5353016", "0.5351965", "0.5351965", "0.5351965", "0.5351965", "0.5344416", "0.530644", "0.5303757", "0.5299129", "0.52973306", "0.5292199", "0.5280386", "0.52755183", "0.5270578", "0.52672684", "0.5265987", "0.5265987", "0.5260361", "0.5259175", "0.52573526", "0.5245855", "0.5243282", "0.524031", "0.524031", "0.52311695", "0.52218425", "0.52189237", "0.5213485", "0.521077", "0.52051", "0.5200774", "0.5200774", "0.5200774", "0.5200774", "0.5198885", "0.51985216", "0.51985216", "0.5196166", "0.5196166", "0.5195374", "0.5184546", "0.5184327", "0.5183677", "0.5170143", "0.51619726", "0.5160998", "0.5160998", "0.5155217", "0.51531917", "0.5149802", "0.5147559" ]
0.0
-1
Override with value object
def number HookNumber.new(number_record) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_value(old_value)\n raise 'to be implemented in subclass'\n end", "def set_additional_values(object, override)\n override.class.attributes.each do |o|\n object.instance_variable_set(\"@#{o}\", override[o])\n object.define_singleton_method(o.to_sym) { instance_variable_get(\"@#{o}\") }\n end\n end", "def override(identifier, value)\n @value_overrides[identifier] = value\n end", "def old_value=(_arg0); end", "def override_value(param, value)\n self.instance_variable_set(\"@#{param}\", value)\n end", "def set(object, value); end", "def old_value; end", "def overriding_user_value\n clone(:override=>:user)\n end", "def initialize(value)\n @value = value\n super()\n end", "def initialize(value)\n @value = value\n super()\n end", "def value=(obj)\n @value = to_value(obj)\n end", "def value=(val); end", "def value=(_); end", "def __initialize_with(value)\n if value.is_a?(Hash)\n value.each do |key, val|\n if respond_to?(:__overwrite_content) && __content_methods.include?(key.to_s)\n next __overwrite_content(val)\n end\n\n h = key?(key)\n case h\n when Handlers::Attribute then __attribute_object_initialize(h, val)\n when Handlers::Root then __root_object_initialize(h, val)\n when Handlers::Element then __element_object_initialize(h, val)\n else raise h.inspect\n end\n end\n else\n case __handler\n when Handlers::Attribute then __overwrite_value(value)\n when Handlers::Element then __overwrite_content(value)\n else raise h.inspect\n end\n end\n end", "def override\n attributes.override\n end", "def proxy=(new_value); end", "def override(name, val = NULL_ARG)\n @overrides[name] = val unless val.equal?(NULL_ARG)\n @overrides[name]\n end", "def method_missing(method, *args, &block)\n @value = @value.send method, *args, &block\n self\n end", "def value!\n raise NotImplementedError\n end", "def method_missing(meth, *args, &block)\n @value.send meth, *args, &block\n end", "def overrides=(_arg0); end", "def override(name, val = NULL)\n if null?(val)\n overrides[name]\n else\n overrides[name] = val\n end\n end", "def replace(value)\n raise_invalid(value) unless self.class.valid?(value)\n super\n end", "def actual=(value)\n throw \"must be provided by subclass\"\n end", "def handle_value(value)\n super(@transform.call(value))\n end", "def method_missing(method, *args, &block)\n @value.send(method, *args, &block)\n end", "def set(value)\n raise NotImplementedError\n end", "def _refresh_set_values(values)\n ret = super\n load_typecast\n ret\n end", "def method_missing(meth, *args)\n @value.__send__(meth, *args)\n end", "def __value(v); end", "def set_object_origin(obj, value)\n obj.ox = value\n end", "def overrides; end", "def override(name, val = NULL)\n if null?(val)\n overrides[name.to_sym]\n else\n overrides[name.to_sym] = val\n end\n end", "def set_override_on(klass, operator, value )\n overrides_for(klass)[operator] = value\n end", "def set_prototype(value)\n value = JS::Value.from_ruby(context,value)\n res = super(context,self,value)\n return res\n end", "def method_missing(key, value = nil)\n if respond_to?(key)\n super\n else\n @data[key] = value\n end\n end", "def set_value(opts)\n opts = check_params(opts,[:create_instances_if_needed,:class_instance_key,:field_instance_name,:value])\n super(opts)\n end", "def proxy\n super\n end", "def transform(value, instance); end", "def value=(value); self.data.value = value; end", "def new_value(value)\n AwesomeObject.new(self, value)\n end", "def munge(value)\n self.shadow.munge(value) if self.shadow\n\n super\n end", "def call(value)\n raise NotImplementedError\n end", "def value=(value)\n @object.instance_variable_set(:\"@#{@name}\",coerce(value))\n end", "def normalize(v = nil)\n super(v || value)\n end", "def method_missing(*args, &block)\n __value.public_send(*args, &block)\n end", "def set_object_origin(obj, value)\n obj.oy = value\n end", "def modify\n super\n end", "def set_override( method_binding, value )\n overrides_for(method_binding.klass)[method_binding.operator] = value\n end", "def []=(key, value)\n super(convert_key(key), convert_value(value))\n end", "def store(key, value)\r\n obj = for_context(self) { |c| c.store(key, value); c }\r\n return if obj != self \r\n super(key, value)\r\n end", "def override_property(property, value)\n # @overriden_properties.override_value(property, value)\n @file_properties.override_value(property, value)\n end", "def overrides(val = NULL_ARG)\n @overrides = val unless val.equal?(NULL_ARG)\n @overrides\n end", "def assign(obj)\n @value = obj\n end", "def extend_object(obj) end", "def set_value(object, value)\n value = cast_value(value)\n\n case value_type\n when 'integer' then object.value_integer = value\n when 'float' then object.value_float = value\n when 'string' then object.value_string = value\n else raise_invalid_type\n end\n end", "def __overwrite_value(val)\n @__node.content = __export_to_xml(val)\n self.__value = val\n end", "def override_with_form_value(value)\n return value unless @page_config.form_values\n\n temp = if @field_config[:parent_field]\n parent_form_values_hash[@field_name.to_s] || parent_form_values_hash[@field_name]\n else\n @page_config.form_values[@field_name]\n end\n temp.nil? ? value : temp\n end", "def value_object\n vo = self.class.value_object.new\n vo._update(props)\n vo\n end", "def value_object\n vo = self.class.value_object.new\n vo._update(props)\n vo\n end", "def has_value?(value)\n super(convert_value(value))\n end", "def initialize(object,name,type=nil,description=nil,value=nil)\n super(name,type,description)\n\n @object = object\n\n if (self.value.nil? && !value.nil?)\n self.value = case value\n when Proc\n if value.arity > 0\n value.call(@object)\n else\n value.call()\n end\n else\n begin\n value.clone\n rescue TypeError\n value\n end\n end\n end\n end", "def on_value(&blk)\n opts[:on_value] = blk\n end", "def set!(resource, value)\n hook_value(resource, value) unless value.kind_of? Hooker\n super\n end", "def update!(value:, **)\n @value = value\n self\n end", "def value=(value)\n if @value.class == value.class\n @value = value\n @updater = nil\n else\n raise \"Class of new value (#{value.class}) does not match class of current value (#{@value.class})\"\n end\n end", "def value(value)\n\t\t@value=value\n\tend", "def type=(v)\n case v\n when :get then super('get')\n when :set then super('set')\n when :result then super('result')\n when :error then super('error')\n else super(nil)\n end\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def with(new_value)\r\n @new_value = new_value\r\n self\r\n end", "def initialize(value = self.class.default)\n self.value = value\n end", "def variant=(variant); end", "def override_setter_on(model)\n model.class_eval %(\n def #{attribute}=(raw_value)\n definition = self.class.bitmask_definitions[:#{attribute}]\n if raw_value_index = definition.values.find_index(raw_value)\n @#{attribute} = raw_value\n self[:#{attribute}] = raw_value_index\n end\n @#{attribute}\n end\n )\n\n if default_raw.present? then\n model.class_eval %(\n before_save do |m|\n self[:#{attribute}] ||= #{default_raw}\n end\n )\n end\n\n end", "def call(_value)\n raise NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end", "def set!(value_obj)\n\t\t\tinsist!()\n\t\t\t@lookup[0...-1].inject(@obj_with_keys) { |deep_obj, this_key|\n\t\t\t\tdeep_obj[this_key]\n\t\t\t}[@lookup[-1]] = value_obj\n\t\tend", "def coercer\n ValueObjectCoercer.new(self)\n end", "def process_attribute(key, value)\n return super unless key == :value\n\n @built[:value] = value\n nil\n end", "def fire\n @variable.set_value @value, @name\n super\n end", "def tag=(value)\n # Normalize\n super(Tag.normalize(value))\n end", "def call(value)\n coerced = value.map { |item| super(item) }\n\n @set ? Set.new(coerced) : coerced\n end", "def value\n typecast.present? ? typecasted_value : super\n end", "def populate_object(object, name, value)\n setter = :\"#{name}=\"\n\n if object.respond_to?(setter)\n object.send(setter, value)\n end\n end", "def initialize(value = nil)\n @caller_backtrace = caller\n @value = value\n super\n end", "def value=(new_value)\n\t\t@value = new_value\n\t\tinform_obeservers\n\tend", "def []=(key, value)\n super(convert(key), value)\n end", "def []=(a,b)\n\nputs \"trying to store #{a} and #{b}\"\n if a && self.respond_to?(a)\n super(a,b)\n else\n self.extended = {} if !self.extended || !self.extended.is_a?(Hash)\n self.extended[a.to_s] = b\n end\n end", "def _save_set_values(values)\n ret = super\n load_typecast\n ret\n end", "def set_value( value )\n @value = value \n end", "def overriding_system_value\n clone(:override=>:system)\n end", "def replace_by(object)\n raise NotImplementedError, \"#{self.class} did not reimplement #replace_by\"\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end", "def initialize(value, unknown = nil)\n super(self.class.binding_type, value, unknown)\n end" ]
[ "0.7061474", "0.67341113", "0.670489", "0.6695306", "0.6600072", "0.65814215", "0.65393674", "0.65245336", "0.64697385", "0.64697385", "0.6439522", "0.643331", "0.6427863", "0.64169306", "0.6416056", "0.6413187", "0.6413028", "0.6375861", "0.63615185", "0.63596934", "0.6356588", "0.6351368", "0.6349792", "0.6323131", "0.6285473", "0.62682325", "0.62249386", "0.6220558", "0.6198217", "0.61845267", "0.6183597", "0.6183257", "0.616779", "0.6155339", "0.6150563", "0.6137781", "0.61264324", "0.6102378", "0.6077786", "0.6057533", "0.6057397", "0.6056815", "0.60497487", "0.60495794", "0.6043293", "0.6034683", "0.6030356", "0.6028051", "0.6025947", "0.5976861", "0.5956092", "0.5952155", "0.5948187", "0.5942327", "0.5940295", "0.5934929", "0.5928577", "0.5915649", "0.59117657", "0.59117657", "0.5911106", "0.5909646", "0.590609", "0.59010875", "0.58999777", "0.5896194", "0.58783203", "0.58725107", "0.5864362", "0.5862046", "0.5854151", "0.58474416", "0.58440626", "0.5829516", "0.582205", "0.5804565", "0.5796805", "0.5795454", "0.5790552", "0.57880884", "0.57780343", "0.57752377", "0.57749045", "0.57716936", "0.57678014", "0.57647943", "0.57568157", "0.5756049", "0.5756048", "0.57547575", "0.57545656", "0.57545656", "0.57545656", "0.57545656", "0.57545656", "0.57545656", "0.57545656", "0.57545656", "0.57545656", "0.57545656", "0.57545656" ]
0.0
-1
def start(inode) logger.info("machine.start") begin vm.PowerOnVM_Task.wait_for_completion
def nics=(_nics) @nics = _nics.map {|nic| MachineNic.new(nic)} if @nics.nil?.eql?(false) @nics.each do |nic| nic.stats = stats end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start(inode)\n logger.info(\"machine.start\")\n raise Exceptions::NotImplemented\n end", "def start\n\t\t# puts \"Starting #{@ip} ...\"\n\t\tsystem ipmi_command + \" chassis power on\"\n\tend", "def start()\n\t\t_start\n\t\tpossibly_self_provision()\n\tend", "def start_vm\n unless File.exists?(@image_file) and File.owned?(@image_file)\n @log.error \"Image file #{@image_file} doesn't exist or is not owned by you!\"\n exit 255\n end\n @log.info \"VM Will use SSH Port #{@vm_ssh_port} and VNC Port #{@vm_vnc_port}\"\n @log.info \"Starting vmm now...\"\n @log.debug \"vmm command line is: \" + vmm_command_line()\n @vmm_r, @vmm_w, @vmm_pid = PTY.spawn vmm_command_line()\n @vmm_r.expect(@vmm_prompt,@vmm_timeout) do |line|\n true\n end\n @vm_running = true\n @log.debug \"vmm instance pid is #{@vmm_pid}\"\n end", "def start\n execute_prlctl('start', @uuid)\n end", "def start\n register unless registered?\n \n VirtualBox.run_command! ['VBoxManage', '--nologo', 'startvm', uid,\n '--type', gui ? 'gui' : 'headless']\n self\n end", "def start(options={})\n Fission::Action::VM::Starter.new(self).start(options)\n end", "def boot_vm\n start_vm()\n @log.debug \"Loading initial vm...\"\n vmm_command(eb(@config['vmm']['loadinit']))\n end", "def start\n log_debug \"[ #{@node}/#{@environment} ] - Start Proxmox LXC Container ...\"\n with_proxmox do |proxmox|\n run_proxmox_task(proxmox, :post, @lxc_details[:pve_node], \"lxc/#{@lxc_details[:vm_id]}/status/start\")\n end\n end", "def start(obj_vm)\n\t\trun_hyperv_cmd(\"{#@BASE_CMD} -T ws start \\'#{obj_vm.location}\\' nogui\")\n\tend", "def start_vm(vmname)\r\n current = {:errormsg => \"\", :status => \"\", :time => \"\", :vmstatus => \"\"}\r\n\r\n conn_opts=get_cli_connection\r\n Chef::Log.debug(\"#{conn_opts[:host]}...show vm name=#{vmname}\")\r\n Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|\r\n output = ssh.exec!(\"start vm name=#{vmname}\")\r\n output.each_line do |line|\r\n if line.match(/Status:/)\r\n current[:status]=line.split[1].strip\r\n elsif line.match(/Time:/)\r\n line[\"Time: \"]=\"\"\r\n current[:time]=line.strip\r\n elsif line.match(/Error Msg:/)\r\n line[\"Error Msg: \"]=\"\"\r\n current[:errormsg]=line.strip\r\n end\r\n end\r\n end\r\n return current\r\n end", "def start(quiet=false)\n if powered_off?\n log_stdout \"starting ...\", quiet\n\n if(@headless)\n type = 'headless'\n else\n type = 'gui'\n end\n `VBoxManage startvm \"#{@vbox_name}\" --type #{type}`\n wait_for_guestcontrol\n else\n log_stdout \"Already started ...\", quiet\n end\n end", "def new_machine\n self.start\n end", "def start(mode)\n execute(\"startvm\", @uuid, \"--type\", mode.to_s)\n end", "def start\n # Generate Device Description XML file\n generate_xml_device_description\n\n # Start server for M-SEARCH request\n start_ssdp_server\n\n # Start server for HTTP request\n start_http_server\n\n # Send initial notification\n notify :alive\n\n # increase BOOTID\n @boot_id = (@boot_id + 1) % 2**31\n\n # and then set a periodic timer for future notifications\n @notify_timer = EM.add_periodic_timer(@notify_interval) { notify :alive }\n end", "def start_kvm(name)\n unless(system(\"virsh start #{name}\"))\n raise \"Failed to start node: #{name}\"\n end\nend", "def start\n ucommand(:start)\n end", "def start!\n start\n wait_until_terminated(nil)\n end", "def start\n @state_machine.startup\n end", "def start\n create_machine :config_id => self.setting, :cluster_number => 1\n end", "def boot\n # Raise an exception if the limit of vms is reachable\n raise Exceptions::NextDeployException.new(\"Vms limit is reachable\") if Vm.count > Rails.application.config.limit_vm\n\n osapi = Apiexternal::Osapi.new\n\n begin\n self.name = vm_name\n self.technos = project.technos if technos.size == 0\n self.status = 0\n generate_hiera\n user_data = generate_userdata\n sshname = user.sshkeys.first ? user.sshkeys.first.shortname : ''\n self.nova_id = osapi.boot_vm(name, systemimage.glance_id, sshname, vmsize.title, user_data)\n save\n generate_authorizedkeys\n rescue Exceptions::NextDeployException => me\n self.status = 1\n save\n me.log_e\n end\n\n # Wait that vm is well running\n sleep(15)\n init_extra_attr\n # if foatingip is not yet setted by openstack, sleep 15s more\n if @floating_ip.nil?\n sleep(15)\n init_extra_attr\n end\n\n generate_host_all\n end", "def start_virtual_machine(vm_name, cloud_service_name)\n vm = get_virtual_machine(vm_name, cloud_service_name)\n if vm\n if vm.status == 'ReadyRole'\n Loggerx.error \"Cannot perform the start operation on started virtual machine.\"\n else\n path = \"/services/hostedservices/#{vm.cloud_service_name}/deployments/#{vm.deployment_name}/roleinstances/#{vm.vm_name}/Operations\"\n body = Serialization.start_virtual_machine_to_xml\n Loggerx.info \"Starting virtual machine \\\"#{vm.vm_name}\\\" ...\"\n request = ManagementHttpRequest.new(:post, path, body)\n request.call\n end\n else\n Loggerx.error \"Cannot find virtual machine \\\"#{vm_name}\\\" under cloud service \\\"#{cloud_service_name}\\\".\"\n end\n end", "def start\n end", "def start\n end", "def start\n end", "def start\n end", "def start(options={})\n unless @vm.exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n running_response = @vm.running?\n return running_response unless running_response.successful?\n\n if running_response.data\n return Response.new :code => 1, :message => 'VM is already running'\n end\n\n conf_file_response = @vm.conf_file\n return conf_file_response unless conf_file_response.successful?\n\n unless options[:headless].blank?\n if Fusion.running?\n message = 'It looks like the Fusion GUI is currently running. '\n message << 'A VM cannot be started in headless mode when the Fusion GUI is running. '\n message << 'Exit the Fusion GUI and try again.'\n return Response.new :code => 1, :message => message\n end\n end\n\n command = \"#{vmrun_cmd} start \"\n command << \"'#{conf_file_response.data}' \"\n\n command << (options[:headless].blank? ? 'gui ' : 'nogui ')\n command << '2>&1'\n\n command_exec = Fission::Action::ShellExecutor.new command\n Response.from_shell_executor command_exec.execute\n end", "def start\n end", "def start\n end", "def start\n end", "def start\n end", "def start\n end", "def start\n end", "def start\n end", "def start\n end", "def start()\n if @testing \n return test\n end\n\n # Loop until the user interrupts us\n cmd = \"/usr/bin/ovs-ofctl show br-int | grep addr:\"\n while true\n output = `cmd`\n process_output(output)\n sleep @interval\n end\n end", "def start_command\n can_start_instance? or return nil\n\n kvm = SysConf.value_for('kvm_bin')\n basedir = SysConf.value_for(:pid_dir)\n\n inst_num = maint_mode? ? 0 : laboratory.next_instance_to_start\n inst_name = laboratory.instance_name(inst_num)\n mac = laboratory.mac_for_instance(inst_num)\n disks = disk_devs.map {|d| d.dev_string }.join(' ')\n\n pidfile = File.join(basedir,\"#{inst_name}.pid\")\n socket = File.join(basedir, \"#{inst_name}.socket\")\n\n [ \"#{kvm} -name #{inst_name} -m #{ram} -localtime -pidfile #{pidfile}\",\n \"-usb -usbdevice tablet\",\n \"-net nic,macaddr=#{mac},model=#{net_iface.name}\",\n \"-net tap,ifname=tap_#{inst_name},script=/etc/kvm/kvm-ifup\",\n \"-boot c #{disks}\",\n \"-daemonize -vnc none\",\n \"-monitor unix:#{socket},server,nowait\"\n ].join(' ')\n end", "def ensure_start\n start\n sv_command('start') if supervised?\n end", "def start!\n message \"Launching minimum_instances\"\n launch_minimum_instances\n message \"Waiting for master to boot up\" \n \n wait_for_all_instances_to_boot\n \n setup_cloud\n end", "def start_vm\n respond_to do |format|\n logger.debug \"\\n start? \\n \"\n result = @vm.start_vm\n \n is_notice= (result[:notice] && result[:notice]!='')\n is_alert = (result[:alert] && result[:alert]!='')\n\n flash[:notice] = result[:notice].html_safe if is_notice\n flash[:alert] = result[:alert].html_safe if is_alert\n \n format.html {\n redirect_back fallback_location: my_labs_path+(@vm.lab_vmt.lab ? \"/#{@vm.lab_vmt.lab.id}\" : '')+(@vm.lab_vmt.lab && params[:username] ? \"/#{params[:username]}\" : '')\n }\n format.json { render :json => {:success=>is_notice, :message=> is_notice ? 'Machine started' : 'Machine start failed'} }\n end\n end", "def start\n raise \"NotImplemented\"\n end", "def run_start(version)\n puts \"Starting Chef Client, version #{version}\"\n @initial_time = Time.now.to_f\n end", "def start_virtual_machine(vm_name, cloud_service_name)\n vm = get_virtual_machine(vm_name, cloud_service_name)\n if vm\n if vm.status == 'ReadyRole'\n Azure::Loggerx.error 'Cannot perform the start operation on started virtual machine.'\n else\n path = \"/services/hostedservices/#{vm.cloud_service_name}/deployments/#{vm.deployment_name}/roleinstances/#{vm.vm_name}/Operations\"\n body = Serialization.start_virtual_machine_to_xml\n Azure::Loggerx.info \"Starting virtual machine \\\"#{vm.vm_name}\\\" ...\"\n request = client.management_request(:post, path, body: body)\n request.call\n end\n else\n Azure::Loggerx.error \"Cannot find virtual machine \\\"#{vm_name}\\\" under cloud service \\\"#{cloud_service_name}\\\".\"\n end\n end", "def start\n Result.new(call(CMD_START))\n end", "def start_run; end", "def initialize_vm\n\n begin\n #connect to TCPServer to execute the programm\n puts \"Connecting to vm on #{VM_HOST}:#{VM_PORT}.\"\n vm = TCPSocket.open(VM_HOST, VM_PORT)\n rescue\n $stderr.puts 'Could not connect to TCPSocket. Start ruby vm/vm/vm.rb development'\n exit_simulation!('Ein interner Fehler ist aufgetreten.')\n @packet.send_packet\n else\n command = @preprocessor.commands_for_vm\n\n vm.puts proof_commands(command)\n\n vm\n end\nend", "def start\n Command::Installer::Start.new(\n *command_params\n ).execute\n rescue => e\n catch_errors(e)\n end", "def boot_fusion_vm(options)\n exists = check_fusion_vm_exists(options)\n if exists == true\n if options['host-os-name'].to_s.match(/Linux/)\n fusion_vm_dir = options['fusiondir']+\"/\"+options['name']\n else\n fusion_vm_dir = options['fusiondir']+\"/\"+options['name']+\".vmwarevm\"\n end\n fusion_vmx_file = fusion_vm_dir+\"/\"+options['name']+\".vmx\"\n message = \"Starting:\\tVM \"+options['name']\n if options['text'] == true or options['headless'] == true or options['serial'] == true\n command = \"\\\"#{options['vmrun']}\\\" -T fusion start \\\"#{fusion_vmx_file}\\\" nogui &\"\n else\n command = \"\\\"#{options['vmrun']}\\\" -T fusion start \\\"#{fusion_vmx_file}\\\" &\"\n end\n execute_command(options,message,command)\n if options['serial'] == true\n if options['verbose'] == true\n handle_output(options,\"Information:\\tConnecting to serial port of #{options['name']}\")\n end\n begin\n socket = UNIXSocket.open(\"/tmp/#{options['name']}\")\n socket.each_line do |line|\n handle_output(line)\n end\n rescue\n handle_output(options,\"Warning:\\tCannot open socket\")\n quit(options)\n end\n end\n else\n handle_output(options,\"Warning:\\t#{options['vmapp']} VM #{options['name']} does not exist\")\n end\n return\nend", "def leader_start(cloud_type, vm_ips, vm_ip_roles, vm_img_roles, pm_up,\n monitor_function)\n \n # We are the leader\n puts \"#{MY_IP} is the leader\"\n \n # Check wether virtual machines are alive or not\n puts \"Checking whether virtual machines are alive...\"\n alive = {}\n vm_ips.each do |vm|\n if alive?(vm)\n alive[vm] = true\n else\n alive[vm] = false\n puts \"#{vm} is down\"\n end\n end\n \n # Monitor the alive machines. Start and configure the dead ones.\n deads = false\n vm_ips.each do |vm|\n if alive[vm]\n # If they are alive, monitor them\n puts \"Monitoring #{vm}...\"\n @vm_manager.monitor_vm(vm, vm_ip_roles, monitor_function)\n puts \"...Monitored\"\n else\n # If they are not alive, start and configure them\n puts \"Starting #{vm}...\"\n @vm_manager.start_vm(vm, vm_ip_roles, vm_img_roles, pm_up)\n puts \"...Started\"\n deads = true\n end\n end\n \n # Wait for all machines to be started\n unless deads\n \n # If not already started, start the cloud\n unless File.exists?(\"/tmp/cloud-#{@resource[:name]}\")\n \n # Copy important files to all machines\n puts \"Copying important files to all virtual machines\"\n copy_cloud_files(vm_ips, cloud_type)\n \n # Start the cloud\n if start_cloud(@resource, vm_ips, vm_ip_roles)\n \n # Make cloud nodes manage themselves\n auto_manage(cloud_type) # Only if cloud was started properly\n \n # Create file\n cloud_file = File.open(\"/tmp/cloud-#{@resource[:name]}\", 'w')\n cloud_file.puts(@resource[:name])\n cloud_file.close\n \n puts \"===================\"\n puts \"== Cloud started ==\"\n puts \"===================\"\n else\n puts \"Impossible to start cloud\"\n end\n end # unless File\n \n end # unless deads\n\n end", "def do_start\n start_time = Time.new\n @compose.start\n do_wait((Time.new - start_time).to_i)\n end", "def start()\n\n\t\tend", "def command_start; end", "def command_start; end", "def command_start; end", "def perform_start\n raise NotImplementedError\n end", "def start\n \n\tend", "def start\n register_signal_handlers\n startup\n spawn_processes\n watch_for_output\n sleep 0.1\n wait_for_shutdown_or_child_termination\n shutdown\n exit(@exitstatus) if @exitstatus\n end", "def start\n @virtual_machine_state = 'NOSTATE'\n Profitbricks.request :start_server, server_id: self.id\n return true\n end", "def start\n end", "def start\n end", "def connect_vm_to_thread\r\n #Check for duplicates.\r\n current = Thread.current\r\n error \"F91: Only one virtual machine allowed per thread\" if current[:vm]\r\n\r\n #This virtual machine is associated with this thread.\r\n current[:vm] = self\r\n @start_time = Time.now\r\n\r\n self\r\n end", "def start\n\t\tend", "def start\n start_message\n setup_options\n validate!\n setup_jobs\n boot_manager\n end", "def start\n\t\traise NotImplementedError, \"%p does not implement required method #start\" % [ self.class ]\n\tend", "def start\n start_thread\n wait(20) # This so that you wait until either the step is done or 20 seconds is up.\n # It doesn't have to wait the whole 20 seconds if the step finishes quickly.\n end", "def start\n\n end", "def not_cloud_start(cloud_type, vm_ips, vm_ip_roles, vm_img_roles, pm_up)\n \n # Try to find one virtual machine that is already running\n vm_ips.each do |vm|\n if alive?(vm)\n # This machine is running\n puts \"#{vm} is up\"\n vm_leader = vm\n\n # Inform the user of this machine\n puts \"#{vm_leader} is already running\"\n puts \"Do 'puppet apply manifest.pp' on #{vm_leader}\"\n return\n end\n end\n \n # No machines are running\n puts \"All virtual machines are stopped\"\n puts \"Starting one of them...\"\n \n # Start one of the virtual machines\n vm = vm_ips[rand(vm_ips.count)] # Choose one randomly\n puts \"Starting #{vm} ...\"\n \n @vm_manager.start_vm(vm, vm_ip_roles, vm_img_roles, pm_up)\n \n # That virtual machine will be the \"leader\" (actually the chosen one)\n vm_leader = vm\n \n # Copy important files to it\n #copy_cloud_files(vm_leader, cloud_type)\n \n puts \"#{vm_leader} is being started\"\n puts \"Once started, do 'puppet apply manifest.pp' on #{vm_leader}\"\n\n end", "def start\r\n @proc.call\r\n end", "def start\n end", "def start\n raise NotImplementedError\n end", "def start\n\t\tinit\n\t end", "def start(options={})\n unless exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n running_response = running?\n return running_response unless running_response.successful?\n\n if running_response.data\n return Response.new :code => 1, :message => 'VM is already running'\n end\n\n conf_file_response = conf_file\n return conf_file_response unless conf_file_response.successful?\n\n unless options[:headless].blank?\n if Fusion.running?\n message = 'It looks like the Fusion GUI is currently running. '\n message << 'A VM cannot be started in headless mode when the Fusion GUI is running. '\n message << 'Exit the Fusion GUI and try again.'\n return Response.new :code => 1, :message => message\n end\n end\n\n command = \"#{vmrun_cmd} start \"\n command << \"#{conf_file_response.data} \"\n\n command << (options[:headless].blank? ? 'gui ' : 'nogui ')\n command << '2>&1'\n\n Response.from_command(`#{command}`)\n end", "def execute(&each_mach)\n routine_separator(:startup)\n unless @routine\n STDERR.puts \"[this is a generic startup routine]\"\n @routine = {}\n end\n machines = generic_machine_runner(:create) \n machines\n end", "def start()\n data = JSON.generate(:resume => nil)\n response = @compute.connection.csreq(\"POST\",@svrmgmthost,\"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action\",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)\n OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)\n true\n end", "def raw_start\n with_provider_object do |instance|\n instance.actions.start\n instance.wait_for! do\n sdk_update_status(instance)\n instance.started?\n end\n end\n rescue => e\n $ibm_cloud_log.error(e.to_s)\n $ibm_cloud_log.log_backtrace(e)\n raise\n end", "def raw_start\n with_provider_object do |instance|\n instance.actions.start\n instance.wait_for! do\n sdk_update_status(instance)\n instance.started?\n end\n end\n rescue => e\n $ibm_cloud_log.error(e.to_s)\n $ibm_cloud_log.log_backtrace(e)\n raise\n end", "def start!\n process.start\n end", "def attempt_ip(machine_options, action_handler, vm, machine_spec)\n vm_ip = ip_to_bootstrap(machine_options[:bootstrap_options], vm)\n machine_spec.location['ipaddress'] = vm_ip\n\n wait_for_ip(vm, machine_options, machine_spec, action_handler)\n\n unless has_ip?(vm_ip, vm)\n action_handler.report_progress 'rebooting...'\n if vm.guest.toolsRunningStatus != 'guestToolsRunning'\n msg = 'tools have stopped. current power state is '\n msg << vm.runtime.powerState\n msg << ' and tools state is '\n msg << vm.guest.toolsRunningStatus\n msg << '. powering up server...'\n action_handler.report_progress(msg)\n vsphere_helper.start_vm(vm)\n else\n restart_server(action_handler, machine_spec, machine_options)\n end\n wait_for_ip(vm, machine_options, machine_spec, action_handler)\n end\n end", "def start\n begin\n setup\n run\n shutdown\n rescue\n exception($!)\n rescue Interrupt\n interrupt($!)\n ensure\n cleanup\n end\n end", "def start_run\n # Abstract\n end", "def start_run\n # Abstract\n end", "def start\n $stdout.puts \"Starting the pow server...\"\n %x{sudo launchctl load -Fw /Library/LaunchDaemons/cx.pow.firewall.plist 2>/dev/null}\n %x{launchctl load -Fw \"$HOME/Library/LaunchAgents/cx.pow.powd.plist\" 2>/dev/null}\n $stdout.puts \"Done!\"\n end", "def start\n put :start\n end", "def boot_openstack_inception_vm\n say \"\" # glowing whitespace\n\n unless settings[\"inception\"] && settings[\"inception\"][\"server_id\"]\n username = \"ubuntu\"\n say \"Provisioning server for inception VM...\"\n settings[\"inception\"] ||= {}\n\n # Select OpenStack flavor\n if settings[\"inception\"][\"flavor_id\"]\n inception_flavor = fog_compute.flavors.find { |f| f.id == settings[\"inception\"][\"flavor_id\"] }\n settings[\"inception\"][\"flavor_id\"] = nil if inception_flavor.nil?\n end\n unless settings[\"inception\"][\"flavor_id\"]\n say \"\"\n hl.choose do |menu|\n menu.prompt = \"Choose OpenStack flavor: \"\n fog_compute.flavors.each do |flavor|\n menu.choice(flavor.name) do\n inception_flavor = flavor\n settings[\"inception\"][\"flavor_id\"] = inception_flavor.id\n save_settings!\n end\n end\n end\n end\n say \"\"\n confirm \"Using flavor #{inception_flavor.name} for Inception VM\"\n\n # Select OpenStack image\n if settings[\"inception\"][\"image_id\"]\n inception_image = fog_compute.images.find { |i| i.id == settings[\"inception\"][\"image_id\"] }\n settings[\"inception\"][\"image_id\"] = nil if inception_image.nil?\n end\n unless settings[\"inception\"][\"image_id\"]\n say \"\"\n hl.choose do |menu|\n menu.prompt = \"Choose OpenStack image (Ubuntu): \"\n fog_compute.images.each do |image|\n menu.choice(image.name) do\n inception_image = image\n settings[\"inception\"][\"image_id\"] = inception_image.id\n save_settings!\n end\n end\n end\n end\n say \"\"\n confirm \"Using image #{inception_image.name} for Inception VM\"\n\n key_name = settings[\"inception\"][\"key_pair\"][\"name\"]\n\n # Boot OpenStack server\n server = fog_compute.servers.create(\n :name => \"Inception VM\",\n :key_name => key_name,\n :private_key_path => inception_vm_private_key_path,\n :flavor_ref => inception_flavor.id,\n :image_ref => inception_image.id,\n :security_groups => [settings[\"inception\"][\"security_group\"]],\n :username => username\n )\n server.wait_for { ready? }\n unless server\n error \"Something mysteriously cloudy happened and fog could not provision a VM. Please check your limits.\"\n end\n\n settings[\"inception\"].delete(\"create_new\")\n settings[\"inception\"][\"server_id\"] = server.id\n settings[\"inception\"][\"username\"] = username\n save_settings!\n end\n\n server ||= fog_compute.servers.get(settings[\"inception\"][\"server_id\"])\n\n unless settings[\"inception\"][\"ip_address\"]\n say \"Provisioning IP address for inception VM...\"\n ip_address = acquire_ip_address\n associate_ip_address_with_server(ip_address, server)\n\n settings[\"inception\"][\"ip_address\"] = ip_address\n save_settings!\n end\n\n # TODO: Hack\n unless server.public_ip_address\n server.addresses[\"public\"] = [settings[\"inception\"][\"ip_address\"]]\n end\n unless server.private_key_path\n server.private_key_path = inception_vm_private_key_path\n end\n server.username = settings[\"inception\"][\"username\"]\n Fog.wait_for(60) { server.sshable? }\n\n unless settings[\"inception\"][\"disk_size\"]\n disk_size = prompt_for_disk_space(\"Inception VM\", DEFAULT_INCEPTION_VOLUME_SIZE)\n device = \"/dev/vdc\"\n provision_and_mount_volume(server, disk_size, device)\n\n settings[\"inception\"][\"disk_size\"] = disk_size\n settings[\"inception\"][\"disk_device\"] = device\n save_settings!\n end\n\n # settings[\"inception\"][\"host\"] is used externally to determine\n # if an inception VM has been assigned already; so we leave it\n # until last in this method to set this setting.\n # This way we can always rerun the CLI and rerun this method\n # and idempotently get an inception VM\n unless settings[\"inception\"][\"host\"]\n settings[\"inception\"][\"host\"] = settings[\"inception\"][\"ip_address\"]\n save_settings!\n end\n\n confirm \"Inception VM has been created\"\n display_inception_ssh_access\n end", "def autostart; end", "def start\n if options.master?\n start_master(options)\n elsif options.slave?\n start_slave(options)\n else\n invoke :help, [:start]\n end\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 start\n @actions << :start\n end", "def begin!\n start_server\n end", "def console\n create_private_disk\n @results['test_start'] = Time.now()\n passed = []\n boot_vm() if @options[:vmm_enabled]\n prep\n freeze_vm() if @options[:vmm_enabled]\n # Print out ssh & vnc port, and freeze name.\n @log.info \"Handing off VM to you.. Type #{@config['vmm']['quitvmm']} to end session.\"\n @log.info \"Ports - SSH: #{@vm_ssh_port} VNC: #{@vm_vnc_port}\"\n\n # hand off console.\n print @config['vmm']['prompt']\n begin\n system('stty raw -echo')\n Thread.new{ loop { @vmm_w.print $stdin.getc.chr } }\n loop { $stdout.print @vmm_r.readpartial(512); STDOUT.flush }\n rescue\n nil # User probably caused the VMM to exit.\n ensure\n system \"stty -raw echo\"\n end\n # Done via the user?\n # stop_vm()\n cleanup_private_disk\n return\n end", "def start\n return if @closed\n error = check_result ::Libuv::Ext.idle_start(handle, callback(:on_idle))\n reject(error) if error\n end", "def start(name, &block)\n\t\t\t\tThread.fork(name: name, &block)\n\t\t\tend", "def start\n activate\n @process_should_stop_mutex.synchronize do\n @process_should_stop = false\n end\n process_worker_thread\n process_monitor_thread\n end", "def start()\n @state = RUNNING\n @loop.wakeup() unless @loop.nil?\n end", "def start\n puts \"Starting #{@resource[:name]}\"\n return if running?\n cmd = [command(:instance_manager)]\n cmd += [\"start\"]\n cmd += [@resource[:name]]\n run(cmd)\n end", "def start\n true\n end", "def start_pvm_instance(instance_id)\n post(\n \"cloud-instances/#{guid}/pvm-instances/#{instance_id}/action\",\n {\"action\" => \"start\"}.to_json\n )\n end", "def start\n create('start')\n end", "def start(name, &block)\n\t\t\t\tProcess.fork(name: name, &block)\n\t\t\tend", "def resume_vm(vmname)\r\n current = {:errormsg => \"\", :status => \"\", :time => \"\", :vmstatus => \"\"}\r\n\r\n conn_opts=get_cli_connection\r\n Chef::Log.debug(\"#{conn_opts[:host]}...show vm name=#{vmname}\")\r\n Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|\r\n output = ssh.exec!(\"resume vm name=#{vmname}\")\r\n output.each_line do |line|\r\n if line.match(/Status:/)\r\n current[:status]=line.split[1].strip\r\n elsif line.match(/Time:/)\r\n line[\"Time: \"]=\"\"\r\n current[:time]=line.strip\r\n elsif line.match(/Error Msg:/)\r\n line[\"Error Msg: \"]=\"\"\r\n current[:errormsg]=line.strip\r\n end\r\n end\r\n end\r\n return current\r\n end", "def start\n migration_task.update!(:state => 'migrate')\n handover_to_automate\n queue_signal(:poll_automate_state_machine)\n end" ]
[ "0.7645129", "0.7043179", "0.6978433", "0.69695646", "0.67998564", "0.66819066", "0.663508", "0.6635071", "0.6571847", "0.6555738", "0.6545403", "0.6529706", "0.64496946", "0.6444058", "0.6372515", "0.63362724", "0.628545", "0.628453", "0.6270069", "0.62529606", "0.62460876", "0.62112117", "0.6195163", "0.6195163", "0.6195163", "0.6195163", "0.6185665", "0.614633", "0.614633", "0.614633", "0.614633", "0.614633", "0.614633", "0.614633", "0.614633", "0.6120802", "0.6101058", "0.6095168", "0.6090197", "0.6084307", "0.60659254", "0.60651606", "0.60479605", "0.6047001", "0.603195", "0.6017992", "0.60071236", "0.5987922", "0.598573", "0.5978963", "0.59717774", "0.5958007", "0.5958007", "0.5958007", "0.5949323", "0.5949137", "0.5947723", "0.59443307", "0.59322774", "0.59322774", "0.592402", "0.59173656", "0.5906228", "0.58977777", "0.58934987", "0.5874605", "0.58730894", "0.58668876", "0.5860704", "0.5856054", "0.58532304", "0.583275", "0.5832263", "0.58222985", "0.58131784", "0.58131784", "0.58087015", "0.5801996", "0.5801545", "0.5792554", "0.5792554", "0.5778186", "0.5771323", "0.5767154", "0.57646716", "0.57370764", "0.5736646", "0.57090074", "0.57032394", "0.56933373", "0.56927776", "0.56926537", "0.5691", "0.568969", "0.5687512", "0.56762016", "0.5672099", "0.56690717", "0.5667158", "0.56652725", "0.5665271" ]
0.0
-1
lockable locks the obj with user
def lock(obj, time = RedisMutexer.config.time) logger locked = RedisMutexer.config.redis.setnx(key(obj), self.id) if locked return RedisMutexer.config.redis.expire(key(obj), time) end locked end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock _obj, _args\n \"_obj lock _args;\" \n end", "def lockDriver _obj, _args\n \"_obj lockDriver _args;\" \n end", "def set_wo_lock(obj)\n @obj = obj\n end", "def toggle_locking(current_user)\n if can_toggle_locking?(current_user)\n is_locked? ? unlock : lock(current_user.id) # TODO: raise exception or report error here?\n end\n end", "def lock\n self.is_locked = true\n self\n end", "def lock_to!(user)\n update_columns(locked_at: Time.current, locked_by: user.id)\n end", "def work\n stat :attempting_lock_on, item_id: object_id\n if @mutex.try_lock\n stat :has_lock_on, item_id: object_id\n chore\n stat :releasing_lock_on, item_id: object_id\n @mutex.unlock\n else\n stat :bailed_on, item_id: object_id\n end\n end", "def lockedCargo _obj, _args\n \"_obj lockedCargo _args;\" \n end", "def locked; end", "def locked\n end", "def lock\n shaz_nolock_lock if !@nolock\n end", "def lockTurret _obj, _args\n \"_obj lockTurret _args;\" \n end", "def lock(worker)\n return true if locked? && locked_by == worker.name\n #all this to make sure the check and the lock are simultanious:\n cnt = repository.update({properties[:lock_name]=>worker.name},self.class.all(:id=>self.id,:lock_name=>nil))\n if 0 != cnt\n @lock_name = worker.name\n true\n else\n worker.say( \"Worker #{worker.name} Failed to aquire lock on job #{id}\" )\n false\n end\n end", "def can_lock?\n SpaceRequestPolicy.can_lock?(current_user, object)\n end", "def lock!\n @locked = true\n end", "def lockWp _obj, _args\n \"_obj lockWp _args;\" \n end", "def lock!\n freeze!\n @locked = true\n self\n end", "def lock!\n @locked = true\n end", "def lock\n post :lock\n end", "def lock!; end", "def lockable?\n @lockable\n end", "def lock\n end", "def lock(opts={})\n super\n end", "def lock(opts={})\n super\n end", "def lock(opts={})\n super\n end", "def lock!(user = User.current)\n self.comment = \"Agenda closed\"\n self.author = user\n self.locked = true\n self.save\n end", "def access_locked?; end", "def try_lock\n end", "def acquire!(locker)\n self.locked_by = locker\n self.locked_at = Time.now\n save!\n end", "def lock_list\n super\n end", "def lock(name, mode)\n yield\n end", "def lock_exclusively!(max_run_time, worker)\n now = self.class.db_time_now\n if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n self.locked_at = now\n self.locked_by = worker\n end\n\n true\n end", "def lock!\n self.for_update!\n end", "def lockedTurret _obj, _args\n \"_obj lockedTurret _args;\" \n end", "def lock\n @privkey = nil\n @locked = true\n end", "def lock( actor, silent = false )\n\t\tif not @closed\n\t\t\tactor.output \"You can't lock it while it's open!\" unless silent\n\t\t\treturn false\n\t\telsif @locked\n\t\t\tactor.output \"It is already locked.\" unless silent\n\t\t\treturn false\n\t\telsif actor.items.map(&:id).include?(@key_id)\n @reset.activate if @reset\n\t\t\tunless silent\n\t\t\t\tactor.output \"Click.\"\n if @direction\n\t (actor.room.occupants - [actor]).each_output \"0<N> locks the #{self.name} to the #{@direction.name}.\", [actor]\n else\n (actor.room.occupants - [actor]).each_output \"0<N> locks #{self.name}.\", [actor]\n end\n\t\t\tend\n\n\t\t\t@locked = true\n\t\t\t@pair.lock( actor, silent: true ) if @pair\n\t\t\treturn true\n\t\telse\n\t\t\tactor.output \"You lack the key.\" unless silent\n\t\t\treturn false\n\t\tend\n\tend", "def is_locked=(value)\n @is_locked = value\n end", "def locked_by\n @lock_name\n end", "def with_lock(name, opts={}, &b)\n mode = opts[:mode] || :exclusive\n\n raise ArgumentError, \":mode option must be either :shared or :exclusive, not #{mode.inspect}\" unless [:shared, :exclusive].include?(mode)\n\n if mode == :shared\n shared_locker(name).with_lock(&b)\n else\n locker(name).with_lock(&b)\n end\n end", "def if_access_locked; end", "def admin_lock\n data = params[:user_id]\n role = params[:role_id]\n\n #start query\n query = Admin.where(id: data, role_id: role)\n\n #on change le statut de l'utilisateur\n query.lock = true\n\n if query.save\n redirect_to parametre_admins_admin_show_path, flash[:notice] = \"User locked\"\n end\n\n end", "def do_LOCK(req, res)\n end", "def lock(key, admin = false)\n if @lockable and not @locked and (@keys.include? key or admin)\n @locked = true\n\n if self.can? :connected_to\n other = $manager.find self.connected_to\n other.lock(key, admin) if other.can? :lock\n end\n\n true\n else\n false\n end\n end", "def locked?\n end", "def lock\n if unlocked_status == false\n raise ArgumentError.new(\"You cannot lock this door - it is already locked\")\n else\n door_hash[:unlocked_status] = false\n end\n end", "def lock\n @unlocked = false\n \"Diary is now locked\"\n end", "def to_lock\n raise AbstractFunction,\n \"#to_lock must be implemented on #{self.class.name}!\"\n end", "def to_lock\n raise AbstractFunction,\n \"#to_lock must be implemented on #{self.class.name}!\"\n end", "def can_lock?(current_user)\n return false if current_user.anonymous?\n\n not is_locked?\n end", "def lock(&block)\n # TODO: only use replace strategy when server is executing the lock\n return call_strategy unless (locked_token = locksmith.lock(&block))\n\n locked_token\n end", "def lock\n if @unlocked == false\n raise Exception.new(\"a locked door needith not to be locked\")\n else\n return @unlocked = false\n end\n end", "def supports_locking?\n false #true\n end", "def visit_Arel_Nodes_Lock(o, a = nil)\n # SQL Layer does not support row locks\n end", "def lock!(resource, uuid, *lock_names)\n build_locks(resource, lock_names, uuid).each(&:save!)\n end", "def lock\n # locking will automatically trigger reload\n # locker older than 1 hour is considered stale\n if !is_locked || (is_locked && locked_at < Time.now - 3600)\n self.is_locked = true\n self.locked_at = Time.now\n save!\n else\n false\n end\n end", "def lock(secret)\n secret.value = security.encrypt(secret.unlocked_value.to_yaml, secret.user.public_key)\n secret.locked = true\n secret\n end", "def run_action_lock(item)\n item = validate_item(item)\n ui.print \" Locking #{ui.color(item, :bold)}... \"\n content = load_json(File.read(item)).to_smash\n if content[:sfn_parameters_lock]\n ui.puts ui.color(\"no-op\", :yellow)\n ui.warn \"Item is already locked! (#{item})\"\n else\n thing = lock_content(content)\n val = format_json(thing)\n File.write(item, val)\n ui.puts ui.color(\"locked\", :blue)\n end\n end", "def lock; end", "def lock; end", "def lock; end", "def acquire_lock\n\t\t@@logger.info { \"Acquiring a lock in the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => false).update(:locked => true) != 0\n\tend", "def lock?\n record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)\n end", "def account_locked\n @user = User.find(params[:id])\n end", "def is_locked?\n locked\n end", "def lock\n @locked = true\n self\n end", "def lock(key)\n raise NotImplementedError\n end", "def can_lock?(user, space)\n user.review_space_admin? && space.shared? && space.active?\n end", "def is_locked_by_other?(current_user)\n is_locked? and user_locked != current_user.id\n end", "def lock=(value)\n doc['lock'] = value\n end", "def update\n return if params_missing([ :id, :lock_serial ], params, true)\n\n lock = Lock.get_active_else_not(params)\n return render_error_modelname(404, :MISSING_RECORD, Lock) if !lock\n\n # Only the owner can update the lock record\n return render_error(403, :NOT_BELONGING, Lock) if lock.user_id != @current_user_device.user_id\n return render_error(404, :LOCK_DECOMMISSIONED) if lock.decommissioned?\n\n lock.assign_attributes(params_app_allowed)\n\n new_lock = false\n if !lock.commissioned?\n # New lock, set it all up\n new_lock = true\n lock.commission_date = DateTime.now\n end\n\n return check_save_failure(lock) if !lock.save\n\n # Owner's key not created until commissioning is completed (saved) successfully.\n # TODO Transaction around this and the commissioning?\n if new_lock\n key = create_user_key(lock.id, lock.user, lock.user)\n # Validation errors may fail in interesting ways here.\n end\n\n render_lock_reply(lock)\n end", "def enable_lock\n add option: \"-lock=true\"\n end", "def locked_to_user?(headers = nil)\n if locked?\n !can_unlock? headers\n else\n locking_ancestor? @ancestor_path, @ancestors.dup, headers\n end\n end", "def lock(*args, &block)\n args = web_dav_args args\n map_method :lock, args, &block\n end", "def with_lock(key)\n raise NotImplementedError\n end", "def locked?(obj)\n RedisMutexer.config.redis.exists(key(obj))\n end", "def lock\n doc['lock']\n end", "def setVehicleLock _obj, _args\n \"_obj setVehicleLock _args;\" \n end", "def lock_exclusively!(max_run_time, worker = worker_name)\n now = Time.now\n affected_rows = if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n # self.class.update_all([\"locked_at = ?, locked_by = ?\", now, worker], [\"id = ? and (locked_at is null or locked_at < ?)\", id, (now - max_run_time.to_i)])\n klass = self.class\n (klass.all(:id => id) & (klass.all(:locked_at => nil) | klass.all(:locked_at => now))).update(:locked_at => now, :locked_by => worker)\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n # self.class.update_all([\"locked_at = ?\", now], [\"id = ? and locked_by = ?\", id, worker])\n self.class.all(:id => id, :locked_by => worker).update(:locked_at => now)\n end\n if affected_rows == true\n self.locked_at = now\n self.locked_by = worker\n return true\n else\n return false\n end\n end", "def allow_lock\n if params[:checked] == \"1\"\n if !params[:current_user_id].blank?\n locks = Communication.find(params[:note_id]).update_attributes(:lock_by_user_id => \"#{params[:current_user_id]}\")\n end\n else\n locks = Communication.find(params[:note_id]).update_attributes(:lock_by_user_id => \"\")\n end\n render :update do |page|\n if params[:checked] == \"1\"\n flash[:notice] = \"Succesfuly locked\"\n page.redirect_to wfm_notes_path\n else\n flash[:notice] = \"Succesfuly Unlocked\"\n page.redirect_to wfm_notes_path\n end\n end\n end", "def with_lock(&blk)\n create_lock_file!\n queue = Queue.new\n\n first_lock_blk = lambda do\n if have_first_lock?(true)\n queue << :locked\n end\n end\n\n @zk.watcher.register(root_lock_path, &first_lock_blk)\n first_lock_blk.call\n\n if queue.pop\n begin\n @locked = true\n return blk.call\n ensure\n unlock!\n end\n end\n\n end", "def locked?\n self.is_locked\n end", "def lock_exclusively!(max_run_time, worker = worker_name)\n now = self.class.db_time_now\n affected_rows = if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n self.class.update_all([\"locked_at = ?, locked_by = ?\", now, worker], [\"id = ? and (locked_at is null or locked_at < ?)\", id, (now - max_run_time.to_i)])\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n self.class.update_all([\"locked_at = ?\", now], [\"id = ? and locked_by = ?\", id, worker])\n end\n if affected_rows == 1\n self.locked_at = now\n self.locked_by = worker\n return true\n else\n return false\n end\n end", "def lock(worker)\n NotImplementedError\n end", "def unlock!\n self.locked_by = nil\n self.locked_at = nil\n save!\n end", "def non_blocking_lock!( *args, &block )\n unless non_blocking_lock( *args, &block )\n raise ::LockFailed.new( \"Failed to obtain a lock.\" )\n end\n end", "def lock_exclusively!(max_run_time, worker)\n now = self.class.db_time_now\n \n #whether this job has run before in the past\n first_time=self.first_started_at.nil?\n\n #attributes to modify in the job table\n conditions=\"locked_at = ?, last_started_at = ?\"\n attrs=[now,now]\n\n #if it hasn't been run, then we want to also update first_started_at\n if first_time\n conditions+=\", first_started_at = ?\"\n attrs << now\n end\n\n if locked_by != worker\n # We don't own this job so we will also update the locked_by name\n conditions+=\", locked_by = ?\"\n attrs.unshift(conditions)\n attrs << worker\n affected_rows = self.class.update_all(attrs,\n [\"id = ? and (locked_at is null or locked_at < ?) and (run_at <= ?)\", id, (now - max_run_time.to_i), now])\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n attrs.unshift(conditions)\n affected_rows = self.class.update_all(attrs, [\"id = ? and locked_by = ?\", id, worker])\n end\n\n if affected_rows == 1\n #update the attributes to the same values that were set in the database\n self.locked_at = now\n self.last_started_at = now\n self.first_started_at ||= now\n self.locked_by = worker\n return true\n else\n return false\n end\n end", "def synchronized(o)\no.mutex.synchronize { yield }\nend", "def try_lock\n lock_expire = (Time.now + expire_timeout).to_f\n lock_full_ident = owner_ident\n !!if 1 == eval_safe(@eval_try_lock, @ns_names, [lock_full_ident, (lock_expire*1000.0).to_i])\n @lock_expire = lock_expire\n @locked_owner_id = lock_full_ident\n end\n end", "def locked?\n !!@owner\n end", "def lock(args)\n unless(@lock_class)\n NotImplemented\n else\n unless(parent_exists?)\n Conflict\n else\n lock_check(args[:scope])\n lock = @lock_class.explicit_locks(@path).find{|l| l.scope == args[:scope] && l.kind == args[:type] && l.user == @user}\n unless(lock)\n token = UUIDTools::UUID.random_create.to_s\n lock = @lock_class.generate(@path, @user, token)\n lock.scope = args[:scope]\n lock.kind = args[:type]\n lock.owner = args[:owner]\n lock.depth = args[:depth].is_a?(Symbol) ? args[:depth] : args[:depth].to_i\n if(args[:timeout])\n lock.timeout = args[:timeout] <= @max_timeout && args[:timeout] > 0 ? args[:timeout] : @max_timeout\n else\n lock.timeout = @default_timeout\n end\n lock.save if lock.respond_to? :save\n end\n begin\n lock_check(args[:type])\n rescue DAV4Rack::LockFailure => lock_failure\n lock.destroy\n raise lock_failure\n rescue HTTPStatus::Status => status\n status\n end\n [lock.remaining_timeout, lock.token]\n end\n end\n end", "def lock(args)\n raise NotImplemented unless @lock_class\n raise Conflict unless parent_exists?\n\n lock_check(args[:scope])\n lock = @lock_class.explicit_locks(@path).find{|l| l.scope == args[:scope] && l.kind == args[:type] && l.user == @user}\n unless(lock)\n token = UUIDTools::UUID.random_create.to_s\n lock = @lock_class.generate(@path, @user, token)\n lock.scope = args[:scope]\n lock.kind = args[:type]\n lock.owner = args[:owner]\n lock.depth = args[:depth].is_a?(Symbol) ? args[:depth] : args[:depth].to_i\n if(args[:timeout])\n lock.timeout = args[:timeout] <= @max_timeout && args[:timeout] > 0 ? args[:timeout] : @max_timeout\n else\n lock.timeout = @default_timeout\n end\n lock.save if lock.respond_to? :save\n end\n begin\n lock_check(args[:type])\n rescue DAV4Rack::LockFailure => lock_failure\n lock.destroy\n raise lock_failure\n rescue HTTPStatus::Status => status\n status\n end\n [lock.remaining_timeout, lock.token]\n end", "def lock!\n create_lock_file!\n if have_first_lock?(false)\n @locked = true\n else\n cleanup_lock_file!\n false\n end\n end", "def try_lock\n if locked_out?\n false\n else\n lock\n true\n end\n end", "def with_lock(key)\n with_multilock(Array.wrap(key)) do |lock_objects|\n yield lock_objects[key]\n end\n end", "def return_lock\n\t\t@@logger.info { \"Returning the lock to the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => true).update(:locked => false) != 0\n\tend", "def lock_expired?; end", "def locked?\n @locked\n end", "def isLocked\n room = Room.find_by_id params[:id]\n\n if room.nil?\n respond_with locked: true\n else\n if room.lock_owner_user_id.nil? || room.room_lock_start.nil? || room.lock_owner_user_id == session[:uid]\n respond_with locked: false\n else\n respond_with locked: true\n end\n end\n end", "def unlock\n self.is_locked = false\n self\n end", "def lock(mode, &block)\n sql = LOCK % [@opts[:from], mode]\n @db.synchronize do\n if block # perform locking inside a transaction and yield to block\n @db.transaction {@db.execute(sql); yield}\n else\n @db.execute(sql) # lock without a transaction\n self\n end\n end\n end" ]
[ "0.7552429", "0.71941376", "0.7080969", "0.7075627", "0.7049906", "0.70121384", "0.7002947", "0.6996355", "0.69748634", "0.6931699", "0.6913005", "0.6884086", "0.68341905", "0.68155366", "0.67948484", "0.6751871", "0.6747776", "0.67460716", "0.67281514", "0.6693664", "0.6682709", "0.6664223", "0.66490704", "0.66490704", "0.66490704", "0.6644381", "0.66274935", "0.6620165", "0.65793985", "0.6533419", "0.6527352", "0.6522953", "0.65124375", "0.64823514", "0.6480754", "0.64727", "0.6470221", "0.64602554", "0.6455889", "0.6455413", "0.6439756", "0.64141387", "0.6399533", "0.6399433", "0.63936466", "0.6377358", "0.6377169", "0.6377169", "0.63757825", "0.6369093", "0.6351915", "0.63506037", "0.6334943", "0.6323875", "0.6319512", "0.6309117", "0.629054", "0.6279952", "0.6279952", "0.6279952", "0.6272683", "0.62642443", "0.62623936", "0.62614405", "0.6253654", "0.6251244", "0.6243418", "0.6242036", "0.623052", "0.6225523", "0.62140983", "0.6190941", "0.6187775", "0.6181946", "0.6170282", "0.6147442", "0.61402935", "0.6136382", "0.6131265", "0.61186665", "0.6096819", "0.60908455", "0.6067461", "0.6067121", "0.6055763", "0.6045963", "0.60338545", "0.60298914", "0.6029729", "0.6000859", "0.59862274", "0.59844667", "0.5982794", "0.5978406", "0.597142", "0.5970252", "0.59691644", "0.5964651", "0.59562933", "0.5954899" ]
0.6937128
9
this will check if the obj is locked with any user.
def locked?(obj) RedisMutexer.config.redis.exists(key(obj)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locked?\n !!@owner\n end", "def locked?\n fetch_lock_info\n\n obj_exists_and_is_not_type? obj: @lock_info, type: []\n end", "def can_lock?(current_user)\n return false if current_user.anonymous?\n\n not is_locked?\n end", "def can_lock?\n SpaceRequestPolicy.can_lock?(current_user, object)\n end", "def is_locked_by_other?(current_user)\n is_locked? and user_locked != current_user.id\n end", "def is_locked?\n locked\n end", "def i_dont_own?(object)\n if(current_user.present? and object.user.present? and object.user.id.present? and (current_user.id == object.user.id))\n false\n else\n true\n end\n end", "def locked?\n end", "def isLocked\n room = Room.find_by_id params[:id]\n\n if room.nil?\n respond_with locked: true\n else\n if room.lock_owner_user_id.nil? || room.room_lock_start.nil? || room.lock_owner_user_id == session[:uid]\n respond_with locked: false\n else\n respond_with locked: true\n end\n end\n end", "def locked?\n @object.reload!\n @object.exists?\n rescue Google::Cloud::NotFoundError\n false\n end", "def locked?\n\t\t\t@locked\n\t\tend", "def locked?\n @locked\n end", "def locked?\n self.is_locked\n end", "def owner?(obj)\n (self.id == RedisMutexer.config.redis.get(key(obj)).to_i)\n end", "def locked?\n locked_by.present? && locked_at.present? && locked_at > 10.minutes.ago\n end", "def locked?\n @locked\n end", "def locked?\n @locked\n end", "def locked?\n @locked\n end", "def locked?\n @locked\n end", "def locked?\n @locked\n end", "def locked?\n not @lock_name.nil?\n end", "def lockable?\n @lockable\n end", "def locked_out?\n # don't need a mutex because we know #owned? can't change during the call \n locked? && !owned?\n end", "def locked_to_user?(headers = nil)\n if locked?\n !can_unlock? headers\n else\n locking_ancestor? @ancestor_path, @ancestors.dup, headers\n end\n end", "def locked?\n !locked_at.nil?\n end", "def lock?\n record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)\n end", "def unlocked?\n not locked?\n end", "def locked?\n locksmith.locked?\n end", "def is_locked\n return @is_locked\n end", "def locked?\n @mutex.locked?\n end", "def locked?\n return @locked\n end", "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def lock_status?\n return @unlocked == true\n end", "def access_locked?\n !!locked_at && !lock_expired?\n end", "def object_owner?\n User.find(params[:user_id]) == current_user\n end", "def can_unlock?\n SpaceRequestPolicy.can_unlock?(current_user, object)\n end", "def is_owner\n object == current_user\n end", "def if_access_locked; end", "def locked?(user)\n false unless user.present?\n answer_session = self.answer_sessions.where( user_id: user.id ).order( updated_at: :desc ).first\n answer_session.present? and answer_session.locked?\n end", "def locked?\n raise NotImplementedError\n end", "def unlocked?\n !locked?\n end", "def prevent_locked_user_login\n config = sorcery_config\n should_unlock =\n !login_unlocked? &&\n config.login_lock_time_period != 0 &&\n send(config.lock_expires_at_attr_name) <= Time.current\n\n login_unlock! if should_unlock\n\n return false, :locked unless login_unlocked?\n\n true\n end", "def locked?\n\t\t\t!lockoutTime.nil? && lockoutTime.to_i != 0\n\t\tend", "def check_current_user_owns\n head :not_found unless @user == current_user\n end", "def access_locked?\n\n super && date_restricted?\n\n end", "def owned?\n !!if owner_ident == (lock_full_ident = @locked_owner_id)\n redis_pool.mget(*@ns_names).all? {|v| v == lock_full_ident}\n end\n end", "def isAuth\n # Redirect the browser to the homepage, unless the user is logged in\n redirect_to root_path unless signed_in?\n # Execute the 'locked' method unless the user does not have a lock associated with their account\n locked unless current_user.lock == nil\n end", "def has_lock?\n @has_lock || false\n end", "def unlocked?\n @unlocked\n end", "def locked?\n !!locked_by && !!locked_at && (locked_at + Delayed::Worker.max_run_time) >= Delayed::Job.db_time_now\n end", "def is_owner?(user)\n !user.nil? && (self.user_id == user.id)\n end", "def is_owner?(this_user)\n user == this_user\n end", "def can_lock?(user, space)\n user.review_space_admin? && space.shared? && space.active?\n end", "def is_owner?(user)\n user.id == self.user_id\n end", "def access_locked?; end", "def is_owner?(object, no_admin = false)\n if current_user && current_user.id === object.user.id && (object.user.is_admin? || !no_admin)\n return true\n elsif is_admin? && !no_admin\n return true\n else\n return false\n end\n rescue\n return false\n end", "def locked?\n if defined?(@locked)\n @locked\n else\n false\n end\n end", "def active_for_authentication?\n super and self.locked != 1\n end", "def owned?\n locked? && @object.size == @uuid.size && @object.download.read == @uuid\n end", "def owned_by?(user)\n if (access_restricted?)\n return self.acl.owner?(user)\n end\n return false\n end", "def locked?\n approved? or rejected?\n end", "def check_auth\n @slot.user == (current_user ) or raise AccessDenied\n end", "def is_owner_of?(thing)\n return false unless thing.user == self\n true\n end", "def have_lock?\n !!@handle\n end", "def can_unlock?(current_user)\n return false if current_user.anonymous?\n\n is_locked? and not is_locked_by_other?(current_user)\n end", "def owner_user_in_db?\n Woodlock::User.find_by(github_username: @project.github_owner) ? true : false\n end", "def lockout?\n @lockout\n end", "def editable_by?(user)\n \tuser && user == owner\n\tend", "def owner? usr\n user_id == usr.id\n end", "def our_lock?(current_lock)\n return nil unless current_lock\n return false unless current_lock[\"client_name\"] == client_name\n return false unless current_lock[\"process_id\"] == Process.pid\n true\n end", "def is_owner?\n Account.current ? Account.current.has_owner?(self) : false\n end", "def locked?\n\t\t\t\t\treturn payment_in_progress? || paid?\n\t\t\t\tend", "def is_owned_by_user?(user)\n self.user == user\n end", "def has_user_permission?(object)\n object and object.user and current_user and object.user == current_user\n end", "def locked?\n self.released?\n end", "def allow_access\n !@current_user.nil?\n end", "def has_owner(user)\n return self.user.id==user.id\n end", "def locked?\n (status & (1 << 0)).zero?\n end", "def allow_access\n !current_cas_user.nil?\n end", "def editable_by?(user)\n\t \t# user && user == owner\n\t user == user\n \tend", "def locked?\n self.invoiced? && self.invoice.issued?\n end", "def unlocked?\n ! File.exist?(lock_file)\n end", "def try_lock\n if locked_out?\n false\n else\n lock\n true\n end\n end", "def locked\n # Get the current user\n user = current_user\n # If the lock has passed its expiry date, and the lock is not permanent\n if user.lock.expires_at <= Time.now && !user.lock.permanent?\n # Destroy the lock record\n user.lock.destroy!\n end\n # If the account is still locked\n if user.lock != nil\n # Notify the user that their account has been locked\n flash[:error] = \"Your account has been locked. Please contact Player Support for more information\"\n # Log the user out\n logout\n # Take the user to the homepage\n redirect_to root_path\n end\n end", "def has_owner? user\n self.account_users.where(user: user, is_owner: true).count > 0\n end", "def closable_by? (by_user)\n !by_user.nil? && by_user.username==self.username && self.opened?\n end", "def locked?\n File.exist?(lock_file)\n end", "def locked?\n !status_flag?(:kSecUnlockStateStatus)\n end", "def object_owner_for_resource?(object)\n object.user == current_user\n end", "def locked?\n File.exist?(lock_file)\n end", "def require_object_owner\n if User.find(params[:user_id]) != current_user\n flash[:error] = \"Sorry! Viewing not authorized.\"\n redirect_to :back\n end\n end", "def owned?\n user.present?\n end", "def locked?\n submitted?\n end", "def owner?(current_user)\n user == current_user\n end", "def owned_by?(u)\n self.user == u\n end", "def active_for_authentication?\n super && !access_locked?\n end", "def is_owned_by?(user_id)\n self.user_id == user_id\n end", "def check_owner_user\n @guild = Guild.find(@invite[:guild_id])\n if self.admin?\n return 1\n end\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end", "def is_potential_user?\n\t\ttrue\n\tend", "def unlocked?(user)\n\t\treturn user.totalStars >= @starsRequired\n\tend" ]
[ "0.7684398", "0.7403483", "0.7345187", "0.72594255", "0.71440417", "0.7131871", "0.7095968", "0.708216", "0.7010908", "0.6980229", "0.6971062", "0.69588786", "0.6956333", "0.69508123", "0.694917", "0.69092435", "0.69092435", "0.69092435", "0.69092435", "0.6883724", "0.6838925", "0.6793597", "0.6783681", "0.6756347", "0.67260575", "0.6726047", "0.6703308", "0.669267", "0.6691143", "0.6682731", "0.66670364", "0.66588604", "0.66391516", "0.6635035", "0.6628946", "0.66256386", "0.6601278", "0.6575443", "0.65644896", "0.65627587", "0.65477246", "0.65436953", "0.65295017", "0.65288824", "0.65143543", "0.6506885", "0.6504562", "0.6481908", "0.64747894", "0.64692765", "0.6469116", "0.64646965", "0.64590037", "0.64393824", "0.6434998", "0.64309716", "0.64287287", "0.64216715", "0.64035726", "0.6402452", "0.6399922", "0.63812774", "0.6362783", "0.63509184", "0.6349346", "0.6344614", "0.63341856", "0.63227737", "0.6315065", "0.62962806", "0.62938064", "0.6292549", "0.6291096", "0.62843406", "0.62731177", "0.6267409", "0.6257742", "0.6256434", "0.62551284", "0.62433314", "0.6238878", "0.62266225", "0.6223331", "0.62197995", "0.6201591", "0.6197925", "0.6196033", "0.6195915", "0.6192018", "0.61900926", "0.61869466", "0.617433", "0.61700237", "0.6165545", "0.61648417", "0.615417", "0.6153557", "0.61474013", "0.6135376", "0.61299217" ]
0.74661
1
to check if the user is the owner of the lock.
def owner?(obj) (self.id == RedisMutexer.config.redis.get(key(obj)).to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_owner?(this_user)\n user == this_user\n end", "def is_owner?(user)\n !user.nil? && (self.user_id == user.id)\n end", "def is_owner?(user)\n user.id == self.user_id\n end", "def owner? (user)\n user == owner\n end", "def owner? usr\n user_id == usr.id\n end", "def is_owner?\n Account.current ? Account.current.has_owner?(self) : false\n end", "def locked?\n !!@owner\n end", "def owner?(user)\n\t\tuser.id == self.user.id\n\tend", "def check_owner_user\n @guild = Guild.find(@invite[:guild_id])\n if self.admin?\n return 1\n end\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end", "def is_owner_of?(thing)\n return false unless thing.user == self\n true\n end", "def owner?(user)\n user == owner || owners.include?(user)\n end", "def has_owner(user)\n return self.user.id==user.id\n end", "def user_owner_entry?\n user_entry? && principle == \"OWNER\"\n end", "def has_owner? user\n self.account_users.where(user: user, is_owner: true).count > 0\n end", "def owner?(current_user)\n user == current_user\n end", "def owner_user_in_db?\n Woodlock::User.find_by(github_username: @project.github_owner) ? true : false\n end", "def is_owner\n object == current_user\n end", "def is_owner?(username)\n User.get_user(username).eql?(self.owner)\n end", "def owned_by?(u)\n self.user == u\n end", "def owned_by?(user)\n if (access_restricted?)\n return self.acl.owner?(user)\n end\n return false\n end", "def is_owner?(pid, oid)\n oid.owner == get_object(pid).owner\n end", "def owner?(key = :user_id)\n # Lookup the original user_id\n owner_id = was(key) || send(:\"_#{key}\")\n !owner_id.nil? && owner_id == Volt.current_user_id\n end", "def owned?\n !!if owner_ident == (lock_full_ident = @locked_owner_id)\n redis_pool.mget(*@ns_names).all? {|v| v == lock_full_ident}\n end\n end", "def is_owned_by_user?(user)\n self.user == user\n end", "def owner?\n resource.user_id == current_user.id\n end", "def owner?(id)\n if current_user.id == id\n return true\n else\n return false\n end\n end", "def owned?\n user.present?\n end", "def object_owner?\n User.find(params[:user_id]) == current_user\n end", "def is_owner?(item)\n current_user_id == item.user_id\n end", "def user_is_guild_owner?\n @guild = Guild.find(User.find(session[:user_id])[:guild_id])\n return (@guild[:owner_id] == session[:user_id]) ? true : false\n end", "def check_is_guild_owner\n @guild = Guild.find(User.find(session[:user_id])[:guild_id])\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end", "def owned_by?(user)\n return false unless user.is_a? User\n \n # allow admins and project owners to edit\n user.admin? or self.owner == user\n end", "def owned_by?(user)\n return false unless user.is_a? User\n \n # allow admins and project owners to edit\n user.admin? or self.owner == user\n end", "def is_owner? (opportunity)\n \topportunity.user_id == self.id\n end", "def owner?\n record.id == user.id\n end", "def owner?(resource:)\n current_user.present? && resource&.user_id == current_user.id\n end", "def owned_by? a_user\n a_user == user\n end", "def is_owner?(object, no_admin = false)\n if current_user && current_user.id === object.user.id && (object.user.is_admin? || !no_admin)\n return true\n elsif is_admin? && !no_admin\n return true\n else\n return false\n end\n rescue\n return false\n end", "def hasOwner? \n\t\tunless self.author_id.nil? || self.author_id == 0\n\t\t\tUser.find(self.author_id)\n\t\tend\n\n\tend", "def owner?(photo)\n !photo.nil? && photo.owner == current_user\n end", "def routine_owner\n record.user == user\n end", "def is_owned_by?(user_id)\n self.user_id == user_id\n end", "def owner?(project)\n if id == project.user.id\n true\n else\n false\n end\n end", "def owned?(user_to_check = current_user)\n user_to_check ? self.creator == user_to_check : false\n end", "def owner?(current_user)\n current_user && (self.user == current_user || current_user.has_role?(:refinery))\n end", "def editable_by?(user)\n\t \t# user && user == owner\n\t user == user\n \tend", "def editable_by?(user)\n \tuser && user == owner\n\tend", "def owner_of(resource)\n id == resource.user_id ? true : false\n end", "def owner?\n self.role_level == 0 ? true : false\n end", "def article_owner?(obj)\n\t\t\tcurrent_user.id == obj.user_id\n\t\tend", "def user_is_owner?\n current_cookbook.is_owner?(current_user)\n end", "def user_is_owner_or_admin?\n record.user == user || user.try(:admin?)\n end", "def owned_by?(current_user)\n current_user && user_id == current_user.id\n end", "def object_owner_for_resource?(object)\n object.user == current_user\n end", "def is_resource_owner?(resource)\n current_user && current_user.id == resource.user_id\n end", "def user_is_owner_or_admin?\n record.reading.user == user || user.try(:admin?)\n end", "def check_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Workflow.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_WORKFLOW) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "def is_owned_by?(member = nil)\n return false if member.blank?\n if self.designer == member or self.client == member\n true\n else\n member.is_super_user? ? true : false\n end\n rescue\n false\n end", "def owner?(post_owner) # <= User object\n current_user == post_owner\n end", "def i_am_owner_or_admin(user_id)\n \tuser_to_check = User.find(user_id)\n \tif user_to_check\n \t\tif user_to_check.is_admin\n \t\t\treturn true\n \t\telse\n\t \t\tif self.from_user_id == user_to_check.id\n\t \t\t\treturn true\n\t \t\telse\n\t \t\t\treturn false\n\t \t\tend\n \t\tend\n\n \tend\n\n end", "def i_am_owner_or_admin(user_id)\n\t\tuser_to_check = User.find(user_id)\n\t\tif user_to_check\n\t\t\tif user_to_check.is_admin\n\t\t\t\treturn true\n\t\t\telse\n\t \t\tif self.user_id == user_to_check.id\n\t \t\t\treturn true\n\t \t\telse\n\t \t\t\treturn false\n\t \t\tend\n\t\t\tend\n\t\tend\n\tend", "def owner_set?\n return false if current_owner_name.nil?\n\n !current_owner_name.empty?\n end", "def owner?(c_utor)\n contribution.owner?(c_utor)\n end", "def owned_by? a_user\n a_user == program.moderator\n end", "def user_is_track_owner?(track)\n return false if current_user.nil?\n return true if current_user.has_role?('admin')\n current_user.is_track_owner?(track)\n end", "def owned_by?(user_id)\n user_id = user_id.id if user_id.is_a?(User)\n has_role(user_id, :creator)\n end", "def check_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Location.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_LOCATION) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "def owner?\n name == 'owner'\n end", "def is_locked_by_other?(current_user)\n is_locked? and user_locked != current_user.id\n end", "def owner_of(group)\n current_user.is_owner?(group)\n end", "def i_dont_own?(object)\n if(current_user.present? and object.user.present? and object.user.id.present? and (current_user.id == object.user.id))\n false\n else\n true\n end\n end", "def owned?\n !owner.nil?\n end", "def managed_by? a_user\n owned_by? a_user || program.moderator == a_user\n end", "def update?\n user_is_owner_or_admin?\n end", "def allow(owner)\n u = User.find(session[:user_id])\n if u.role == :admin\n return true\n else\n if u.id == owner.id\n return true\n else\n return false\n end\n end\n end", "def locked_to_user?(headers = nil)\n if locked?\n !can_unlock? headers\n else\n locking_ancestor? @ancestor_path, @ancestors.dup, headers\n end\n end", "def managed_by? a_user\n program.owned_by? a_user\n end", "def owned_by?(actor)\n # defaults to false. Override if resource has owner\n false\n end", "def our_lock?(current_lock)\n return nil unless current_lock\n return false unless current_lock[\"client_name\"] == client_name\n return false unless current_lock[\"process_id\"] == Process.pid\n true\n end", "def can_lock?(current_user)\n return false if current_user.anonymous?\n\n not is_locked?\n end", "def is_owner?(account)\n attachable == account.profile\n end", "def owner?(user_asking)\n user_asking.in? company.owners\n end", "def is_owner?(xaccount:)\n # DRAFT and creator means owner\n return true if publication.is_draft? && publication.current_version.is_creator?(xaccount: xaccount)\n\n # Author means owner\n return true if publication.current_version.is_author?(xaccount: xaccount)\n\n # All others are not owners\n false\n end", "def is_owner?(person)\n return person !=nil && person.team_id == self.id && person.role == \"captain\"\n end", "def is_not_global_and_is_owned_by?(user)\n !self.is_global? && self.user_id == user.id\n end", "def update?\n owner? || user.is?(:admin)\n end", "def check_owner\n\n return if params[:id].blank? \\\n or (params[:id] == TreeElement::ROOT_ID.to_s) \\\n or @login_user.nil?\n\n begin\n owner_id = MailFolder.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_MAIL) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "def owned?\n locked? && @object.size == @uuid.size && @object.download.read == @uuid\n end", "def owned?\n @owner == caller\n end", "def check_owner\n\n return if params[:id].nil? or params[:id].empty? or @login_user.nil?\n\n mail_account = MailAccount.find(params[:id])\n\n if !@login_user.admin?(User::AUTH_MAIL) and mail_account.user_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "def game_owner?\n self == game.owner if game.winner.nil?\n end", "def is_global_or_owned_by?(user)\n self.is_global? || self.user_id == user.id\n end", "def update?\n user_is_owner_or_admin?\n end", "def update?\n user_is_owner_or_admin?\n end", "def update?\n user_is_owner_or_admin?\n end", "def owner?\n # exists? ? `ls -al #{path} | grep '[0-9] \\.$'`.split[2] : false\n proprieties[:owner]\n end", "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def update?\n user_is_owner? || user_is_admin?\n end", "def check_owner\n\n return if params[:id].blank? or @login_user.nil?\n\n mail_account = MailAccount.find(params[:id])\n\n if !@login_user.admin?(User::AUTH_MAIL) and mail_account.user_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end", "def updatable_by?(actor)\n actor.is_a?(User) && self.owned_by?(actor)\n end" ]
[ "0.82136476", "0.8160013", "0.81559306", "0.80702865", "0.8044053", "0.8028054", "0.79976916", "0.79792124", "0.7958204", "0.7933038", "0.792701", "0.79254127", "0.7866226", "0.7864399", "0.7846951", "0.7809227", "0.77896965", "0.7754226", "0.7717571", "0.7684922", "0.76810783", "0.76604605", "0.7629031", "0.7626723", "0.7617278", "0.76151377", "0.76144683", "0.7609465", "0.7569274", "0.7564145", "0.75114334", "0.74993145", "0.74993145", "0.74621636", "0.74167395", "0.74130905", "0.7397327", "0.7388623", "0.73489976", "0.73431146", "0.73416126", "0.7334293", "0.73228186", "0.73186034", "0.7278813", "0.72740394", "0.72503656", "0.72476393", "0.7243327", "0.72311115", "0.7225259", "0.72250855", "0.72190833", "0.72179943", "0.7199962", "0.717891", "0.713857", "0.7101591", "0.7100569", "0.70974386", "0.70903176", "0.70573", "0.70489216", "0.7017441", "0.701102", "0.7001941", "0.69991124", "0.69904727", "0.69878346", "0.69846034", "0.6982283", "0.69529927", "0.69412816", "0.69286513", "0.692607", "0.69252837", "0.69239646", "0.6913856", "0.6895636", "0.68758947", "0.6869698", "0.6869268", "0.6865381", "0.6861837", "0.6849446", "0.6847037", "0.6843353", "0.683223", "0.68214136", "0.6811997", "0.6797941", "0.6794118", "0.6784372", "0.6784372", "0.6784372", "0.67832416", "0.6779384", "0.6773718", "0.6766237", "0.67655843" ]
0.7455256
34
find time remaining to expire a lock in seconds.
def unlocking_in(obj) RedisMutexer.config.redis.ttl(key(obj)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_until_unlock\n return 0 unless access_locked?\n return ((User.unlock_in - (Time.current - locked_at)) / 60).round\n end", "def expires_in\n @lock_expire.to_f - Time.now.to_f if @lock_expire && owner_ident == @locked_owner_id\n end", "def calculate_remaining_time\n expiry_time = expires_at.to_i\n current_time = DateTime.now.to_i\n if current_time < expiry_time\n message = ActiveSupport::Duration.build(expiry_time - current_time).parts\n duration = ''\n duration += \"#{message[:days]} day/s \" if message[:days] > 0\n duration += \"#{message[:hours]} hour/s \" if message[:hours] > 0\n duration += \"#{message[:minutes]} minute/s\" if message[:minutes] > 0\n duration\n end\n end", "def seconds_until_expiration(now=Time.now)\n ((@ends_at - now).abs).round\n end", "def lock_duration\n Core::Utils::Interval.try_convert(@lock_duration)\n end", "def get_time_remaining\n\n end", "def time_remaining(options = {})\n options[:private] ||= false\n\n if options[:private]\n [duration - seconds_since_started, 0].max\n else\n [PUBLIC_TIME_LIMIT - seconds_since_started, 0].max\n end\n end", "def time_remaining\n end", "def days_remaining_until_password_expire\n @attributes[:days_remaining_until_password_expire]\n end", "def time_remaining\n member.last_backup_job.time_remaining rescue 0\n end", "def lock_duration\n to_interval description['LockDuration']\n end", "def seconds_to_expire(options = {})\n if options.has_key?(:until)\n case options[:until]\n when 'midnight', :midnight\n secs = ((Time.now + 1.day).midnight - Time.now).to_i \n else\n secs = (options[:until] - Time.now).to_i\n end\n raise \":until(#{options[:until].inspect}) is less than Time.now by #{secs}\" if secs <= 0\n return secs\n elsif options.has_key?(:for)\n return options[:for]\n else\n 0\n end\n end", "def cooldown_remaining\n return 0 unless @cooldown_reset_event\n return (@cooldown_reset_event.time - @sim.runner.current_time) / 1000\n end", "def time_remaining\n\n end", "def get_otp_remaining_time\n (Time.now.utc.to_i / 30 + 1) * 30 - Time.now.utc.to_i\n end", "def edit_time_left(item)\n diff = Time.now - item.updated_at\n expire_rate = APP_CONFIG[:edit_expiration_in_minutes].to_i\n return expire_rate > 0 ? expire_rate - (diff.to_i / 60) : nil\n end", "def time_left_in_seconds\n seconds = time_left[:seconds]\n seconds += time_left[:minutes] * 60\n seconds += time_left[:hours] * 60 * 60\n seconds += time_left[:days] * 60 * 60 * 24\n seconds\n end", "def remaining\n [0, @duration - elapsed].max\n end", "def seconds_remaining\n ends_at ? (ends_at - started_at).round : 0\n end", "def time_left\n return 0.0 if free?\n return end_time - Time.now.to_f\n end", "def remaining_time()\n return @total_time_units - @done_time_units\n end", "def expiration_timestamp\n @lock_expire if @lock_expire && owner_ident == @locked_owner_id\n end", "def remaining_minutes()\n current_time = Time.now\n start_time = Delay.find_newest_travel_time(stop_position.bus.id, current_time)\n predicted_time = start_time + minutes_delayed * 60\n return predicted_time - current_time\n end", "def remain_time\n rem_time = $time - Time.new\n rem_time.to_i\nend", "def remaining\n (Time.now - @last_scrape).to_i \n end", "def minutes_remaining\n time_elapsed = (Time.new - @start_time) / 60\n (@total_paid * 60 - time_elapsed).floor\n end", "def time_left\n @lifetime - @elapsed_time\n end", "def lockout_expires\n @attributes[:lockout_expires]\n end", "def remaining_days_of_grace\n self.expire_on - Date.today - 1\n end", "def extend_lock_if_expires_in_less_than(duration)\n extend_lock if duration > remaining_lock_time\n end", "def time_remaining(interval = 1.second, now = Time.zone.now)\n (next_due_at(now) - now) / interval\n end", "def lock_timeout\n @lock_timeout ||= self.class.lock_timeout || 0\n end", "def remaining_time\n # calculate how old is the feedback\n created_at = self.created_at.to_time\n diff_seconds = (Time.now - created_at).round\n remaining = TEN_MINUTES - diff_seconds\n\n remaining.to_s\n end", "def calc_locked_out_till\n ends_on.since locked_out_duration\n end", "def password_minutes_of_inactivity_before_lock\n return @password_minutes_of_inactivity_before_lock\n end", "def password_minutes_of_inactivity_before_lock\n return @password_minutes_of_inactivity_before_lock\n end", "def lock_expired?; end", "def time_remaining\n return 0 if finished_at\n backup_source_jobs.map(&:time_remaining).sum\n end", "def remaining_str()\n return \"expired\" if isover?\n\n diff = (@end_time - Time.now).floor\n diff, seconds = diff.divmod 60\n diff, minutes = diff.divmod 60\n diff, hours = diff.divmod 24\n days = diff\n\n str = ''\n str += \"#{days}d\" if days != 0\n str += \"#{hours}h\" if hours != 0\n str += \"#{minutes}m\" if minutes != 0\n str += \"#{seconds}s\" if seconds != 0\n \"#{str} remaining\"\n end", "def trial_days_remaining\n days_elapsed = (Time.now.to_i - self.trial_started_at.to_i) / 60 / 60 / 24\n remaining = APP_CONFIG['trial_length'] - days_elapsed\n remaining = 0 if remaining < 0\n remaining\n end", "def get_session_time_left\n expire_time = if session[:expires_at].blank? then (DateTime.now + 30.minutes) else session[:expires_at] end\n @session_time_left = (expire_time.to_datetime - DateTime.now).to_f\n end", "def days_remaining\n target_time = self.next_release[\"release_date\"].to_time\n current_time = Time.now\n \n difference_seconds = target_time - current_time\n difference_seconds.div(86400) # seconds in a day\n end", "def expired?\n remaining.zero?\n end", "def timed_event_remaining_time(event_id = @event_id, map_id = @map_id)\n return ($user_data.dig(:tjn_events, map_id, event_id)&.first || current_time) - current_time\n end", "def unseen_renewals_remaining\n return Float::INFINITY if unlimited_renewals?\n\n unseen_renewals_allowed - renewal_count\n end", "def end_time\n return @start_time + @seconds_to_expiry\n end", "def queue_lock_timeout\n 3600\n end", "def remaining\n max - used\n end", "def hours_left\n remaining = WorkingTime::Interval.new(self, close_of_business)\n return remaining.duration\n end", "def days_to_password_expiry\n no_of_days_remaining = (password_expiry_date.to_date - Time.zone.today).to_i\n no_of_days_remaining.to_i unless no_of_days_remaining >= Rails.configuration.x.authentication.password_due_period\n end", "def untilTimeout()\n return Timer.timeRemaining(@name)\n end", "def time_remaining( address )\n address = encode( address )\n get(\"/timeremaining/#{address}\")\n end", "def timeRemaining(t1)\n\t\treturn subtract(t1,getCurrentTime)\n\tend", "def key_validity_seconds(rnp_key)\n rnp_key.json[\"expiration\"]\n end", "def days_remaining\n if self.days_passed == nil\n puts \"Petition cannot calculate days remaining until it has been filed.\"\n elsif self.days_passed != nil\n days_remaining = 180 - days_passed\n return days_remaining.round(3)\n else \n puts \"Something may be wrong with this petition.\"\n end\n end", "def lock_timeout\n result = Mimi::DB.execute('select setting from pg_settings where name = ?', :lock_timeout)\n value = result.first['setting'].to_i\n value = value.to_f / 1000 unless value == 0\n value\n end", "def wait_time\n if rate_limit_remaining < 50\n [rate_limit_reset - Time.zone.now, 0.001].sort.last\n else\n 3600.0 / rate_limiting\n end\n end", "def paid_days_remaining\n days_elapsed = (Time.now.to_i - self.trial_started_at.to_i) / 60 / 60 / 24\n remaining = 365 - days_elapsed\n remaining = 0 if remaining < 0\n remaining\n end", "def cache_age_tolerance_in_seconds\n 0\n end", "def hours_until_expiration(now=Time.now)\n distance_in_hours = seconds_until_expiration(now)/SECONDS_IN_A_HOUR\n distance_in_hours.floor\n end", "def timeout_in\n\t if self.role=='admin'\n\t 7.days\n\t else\n\t 2.days\n\t end\n\tend", "def passcode_minutes_of_inactivity_before_lock\n return @passcode_minutes_of_inactivity_before_lock\n end", "def expire_time\n updated_at.advance(:days => 30)\n end", "def duration_block_in_minutes\n 180\n end", "def lock_interval\n get_settings[:lock_interval]\n end", "def while_time_remaining; end", "def lock_timeout\n self.class.lock_timeout || default_lock_timeout\n end", "def expires_in_seconds\n '%.0f' % ( expires_at - Time.now )\n end", "def cache_expiry_time\n Rails.configuration.x.accounts.cache_expiry || 10.minutes\n end", "def lease_time\n return (0.667 * @ttl).to_i\n end", "def seen_renewals_remaining\n Float::INFINITY\n end", "def duration_of_stay\n duration_of_stay = (@check_out - @check_in).to_i\n return duration_of_stay\n end", "def expired?\n Time.now.to_f > @lock_expire if @lock_expire && owner_ident == @locked_owner_id\n end", "def time_left\n end_time = created_at + test.time_for_test\n time_left_seconds = end_time - Time.now\n \n return 0 if time_left_seconds < 0\n\n time_left_seconds.round\n end", "def shortest_time_remaining\n return 0 if finished_at\n backup_source_jobs.map(&:time_remaining).reject! {|t| t == 0}.min rescue 0\n end", "def expire_time\n e_time = @token_manager.token_info[\"expiration\"]\n raise 'CloudTools::IAMAuth Unable to extract the retrieved expiration time.' if e_time.nil?\n raise \"CloudTools::IAMAuth Extracted expiry time #{e_time} is not an expected integer.\" unless e_time.kind_of?(Integer)\n\n e_time\n end", "def wait_time(attempts)\n 2 ** (attempts.to_i + 2)\n end", "def wait_interval\n timer = @timers.first\n return 0 unless timer\n\n delay = timer.fire_time - Timers.now\n delay < 0 ? -1 : delay\n end", "def expiry_time\n ((Time.now.tv_sec + 31556926) * 1000).to_i\n end", "def timeout_in_minutes\n data[:timeout_in_minutes]\n end", "def lock_timeout=(_arg0); end", "def seconds_left\n if @last_run\n [(@last_run + interval / 1000.0) - Time.now, 0].max\n else\n interval / 1000.0\n end\n end", "def lock_timeout; end", "def get_days_remaining_with\n remaining = self.user.days_remaining(from_date)\n if !is_actually_deduced? && !is_non_deduce_leave\n remaining -= actual_leave_days\n end\n return remaining\n end", "def lock_expired?\n if unlock_strategy_enabled?(:time)\n locked_at && locked_at < self.class.unlock_in.ago\n else\n false\n end\n end", "def expires_in\n @value.expires_at.to_i - Time.now.utc.to_i\n end", "def expires_in_seconds\n return nil if expires_in.nil?\n\n expires = expires_at - Time.now.utc\n expires_sec = expires.seconds.round(0)\n expires_sec > 0 ? expires_sec : 0\n end", "def update_timeout_status(timeout, start_time, time_left)\n if timeout\n current_time = Time.new.to_i\n p \"current time = #{current_time}\"\n diff = current_time - start_time\n p \"curr - start = #{diff}\"\n time_out_length = 300\n if diff >= time_out_length\n timeout = false\n return timeout\n else\n time_left = time_out_length - diff\n return time_left\n end\n end\nend", "def countdown\n time_left = self.time_remaining\n m = (time_left / 60).to_s\n s = (time_left % 60)\n s = s >= 10 ? s.to_s : \"0#{s}\"\n \"0#{m}:#{s}\"\n end", "def revoke_time\n\t\t((created_at + Donation.revoke_time - Time.now) / 86400).ceil\n\tend", "def timeout_in\n 30.days\n end", "def used\n return 0 if max.zero?\n\n obj = redis.hgetall(key)\n timestamp = obj['timestamp']\n amount = obj['amount']\n if timestamp && amount\n time_passed = Time.now.to_f - timestamp.to_i / 1000.0\n drift = max * time_passed / period\n last_amount = [amount.to_f, max].min\n [(last_amount - drift).ceil, 0].max\n else\n 0\n end\n end", "def lifetime_in_minutes\n return @lifetime_in_minutes\n end", "def lock_timeout_retry_delay; end", "def new_expiration_score\n now + 3600\n end", "def get_time_required\n 0 # number of minutes\n end", "def timeout_in\n if admin?\n 1.hour\n else\n 3.days\n end\n end", "def timeout_in\n if admin?\n 1.hour\n else\n 3.days\n end\n end", "def timeout_in\n if admin?\n 1.hour\n else\n 3.days\n end\n end", "def time_remaining(end_time)\n remaining = (end_time - Time.now).ceil\n format_countdown(remaining)\n end", "def seconds_until\n (start_time - Time.now).to_i\n end" ]
[ "0.7399344", "0.73928326", "0.7186327", "0.70761275", "0.70751756", "0.6949728", "0.6881007", "0.67768145", "0.67613465", "0.6754436", "0.67071015", "0.6692524", "0.665605", "0.6642701", "0.6632026", "0.6586644", "0.6583359", "0.6578869", "0.65775007", "0.65617335", "0.65062755", "0.64970016", "0.6471336", "0.6444583", "0.6426861", "0.64216995", "0.6394687", "0.63843924", "0.63404495", "0.63273644", "0.62938607", "0.6249615", "0.6248483", "0.62095827", "0.6197081", "0.6197081", "0.6184745", "0.617756", "0.61768425", "0.6161237", "0.614801", "0.6146077", "0.61404526", "0.6120298", "0.6111469", "0.6091583", "0.6084036", "0.6071919", "0.6056644", "0.60534406", "0.60476714", "0.60292417", "0.6027666", "0.601492", "0.6001417", "0.5999548", "0.5983127", "0.598292", "0.5968858", "0.59532535", "0.59451413", "0.5927793", "0.59257525", "0.59174716", "0.5914288", "0.5910519", "0.5907093", "0.590269", "0.5900646", "0.5894282", "0.5891717", "0.5886843", "0.58712184", "0.58537054", "0.5840094", "0.58374834", "0.58323824", "0.5821932", "0.5821747", "0.5818572", "0.5813792", "0.5813124", "0.58117086", "0.58093077", "0.580206", "0.5799542", "0.57991534", "0.57926726", "0.5791715", "0.57736903", "0.57728946", "0.576536", "0.5753303", "0.5750154", "0.5749616", "0.57422984", "0.57389456", "0.57389456", "0.57389456", "0.5717418", "0.57157797" ]
0.0
-1
unlock obj if required
def unlock(obj) logger if locked?(obj) RedisMutexer.config.redis.del(key(obj)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lockedCargo _obj, _args\n \"_obj lockedCargo _args;\" \n end", "def unlock_access!; end", "def unlock; end", "def unlock\n @locking = false\n end", "def unlock\n end", "def unlock\n self.is_locked = false\n self\n end", "def lock _obj, _args\n \"_obj lock _args;\" \n end", "def unlock!\n self.locked_by = nil\n self.locked_at = nil\n save!\n end", "def lock\n @privkey = nil\n @locked = true\n end", "def unlock\n self.locked_at = nil\n self.locked_by = nil\n end", "def set_wo_lock(obj)\n @obj = obj\n end", "def locked; end", "def unlock\n self.locked_at = nil\n self.locked_by = nil\n end", "def unlock\n self.is_locked = false\n self.locked_at = nil\n save!\n end", "def lockDriver _obj, _args\n \"_obj lockDriver _args;\" \n end", "def unlock\n self.locked_at = nil\n self.locked_by = nil\n end", "def unlock\n if (!@owner.nil?)\n if (@owner[:locks].last == self)\n @owner[:locks].pop\n else\n if @owner[:locks].delete(self)\n @out_of_order_locks += 1\n raise EMutexOrder.new(self, \"Expected #{@owner[:locks].last}\")\n end\n # if called again let it pass\n end\n @owner = nil\n end\n super\n end", "def unlock\n locksmith.unlock # Only signal to release the lock\n end", "def lockWp _obj, _args\n \"_obj lockWp _args;\" \n end", "def test_locknull_on_unlock\n # ensure that locknull file doesn't exist\n response = @request.delete('locknull')\n\n # create a exclusive write locked null resource\n lock = lock 'locknull', :depth => 0\n\n response = @request.propfind '', 1, :\"current-user-privilege-set\"\n assert_not_nil response[\"#{@uri.path}locknull\"]\n\n unlock('locknull', lock.token)\n \n response = @request.propfind '', 1, :\"current-user-privilege-set\"\n assert_nil response[\"#{@uri.path}locknull\"]\n end", "def result_unlock\n\n end", "def lock!; end", "def release_lock( my_owner = oval )\n # Use my_owner = oval to make testing easier.\n with_watch( okey, xkey ) do\n owner = redis.get( okey )\n if owner == my_owner then\n redis.multi do |multi|\n multi.del( okey )\n multi.del( xkey )\n end\n end\n end\n end", "def release\n locked? && release!\n end", "def access_locked?; end", "def locked\n end", "def lockTurret _obj, _args\n \"_obj lockTurret _args;\" \n end", "def lock\n shaz_nolock_lock if !@nolock\n end", "def unlock\n @mutex.unlock\n end", "def unlock_access!\n self.locked_at = nil\n self.failed_attempts = 0 if respond_to?(:failed_attempts=)\n self.unlock_token = nil if respond_to?(:unlock_token=)\n save(validate: false)\n end", "def unlock\n if @mutex\n if @owner == Thread.current.object_id\n @count -= 1\n if @count == 0\n @owner = nil\n @mutex.unlock\n end\n end\n end\n end", "def if_access_locked; end", "def unlock\n unlock!\n self\n end", "def unlock(*args, &block)\n map_method(:unlock, args, &block)\n end", "def unlock!\n FileUtils.rm_f @path\n end", "def unfreeze(&block); end", "def unlocking_in(obj)\n RedisMutexer.config.redis.ttl(key(obj))\n end", "def lockedTurret _obj, _args\n \"_obj lockedTurret _args;\" \n end", "def resend_unlock_instructions; end", "def lock!\n freeze!\n @locked = true\n self\n end", "def acquire!(locker)\n self.locked_by = locker\n self.locked_at = Time.now\n save!\n end", "def unlock(*args, &block)\n args = web_dav_args args\n map_method :unlock, args, &block\n end", "def without_locking\n old_value = Parts::WithLocking.locking?\n begin\n Parts::WithLocking.locking = false\n ret_value = yield\n ensure\n Parts::WithLocking.locking = old_value\n end\n ret_value\nend", "def release_lock\n super\n end", "def lock; end", "def lock; end", "def lock; end", "def lock(obj, time = RedisMutexer.config.time)\n logger\n locked = RedisMutexer.config.redis.setnx(key(obj), self.id)\n if locked\n return RedisMutexer.config.redis.expire(key(obj), time)\n end\n locked\n end", "def unlock\n FileUtils.rm(lock_file) if File.exist?(lock_file)\n reset!\n end", "def unlock!\n if @locked\n cleanup_lock_file!\n @locked = false\n true\n end\n end", "def without_locking(&block)\n self.class.without_locking(&block)\n end", "def lock!\n @locked = true\n end", "def lock\n self.is_locked = true\n self\n end", "def lock\n @unlocked = false\n \"Diary is now locked\"\n end", "def unlocked?\n not locked?\n end", "def unlock\n if unlocked_status == true\n raise ArgumentError.new(\"The door is already unlocked!\")\n else\n door_hash[:unlocked_status] = true\n end\n end", "def lock\n end", "def unlock\n if @unlocked == true\n raise ExceptionError.new(\"An unlocked door needith not be unlocked\")\n else\n return @unlocked = true\n end\n end", "def unlock\n FileUtils.rm(lock_file) if File.exist?(lock_file)\n reset!\n end", "def resend_unlock_instructions\n if_access_locked { send_unlock_instructions }\n end", "def unlock(token)\n unless(@lock_class)\n NotImplemented\n else\n token = token.slice(1, token.length - 2)\n if(token.nil? || token.empty?)\n BadRequest\n else\n lock = @lock_class.find_by_token(token)\n if(lock.nil? || lock.user != @user)\n Forbidden\n elsif(lock.path !~ /^#{Regexp.escape(@path)}.*$/)\n Conflict\n else\n lock.destroy\n NoContent\n end\n end\n end\n end", "def unlock_access_by_token(unlock_token); end", "def test_shared_locknull\n # ensure that locknull file doesn't exist\n response = @request.delete('locknull')\n\n # create a shared write locked null resource\n lock1 = lock 'locknull', :scope => :shared, :depth => 0\n\n # get another shared lock\n lock2 = lock 'locknull', :scope => :shared, :depth => 0\n\n unlock('locknull', lock2.token)\n\n response = @request.propfind '', 1, :\"current-user-privilege-set\"\n assert_not_nil response[\"#{@uri.path}locknull\"]\n\n # assert that old locktoken doesn't work anymore\n response = @request.unlock('locknull', lock2.token)\n assert_equal '409', response.status # Sec 9.11.1 of draft 18\n\n unlock('locknull', lock1.token)\n\n response = @request.propfind '', 1, :\"current-user-privilege-set\"\n assert_nil response[\"#{@uri.path}locknull\"]\n end", "def lock!\n self.for_update!\n end", "def work\n stat :attempting_lock_on, item_id: object_id\n if @mutex.try_lock\n stat :has_lock_on, item_id: object_id\n chore\n stat :releasing_lock_on, item_id: object_id\n @mutex.unlock\n else\n stat :bailed_on, item_id: object_id\n end\n end", "def lock!\n @locked = true\n end", "def unlock\n if @locking\n @locking_file.close\n end\n end", "def unlock\n if @locking\n @locking_file.close\n end\n end", "def unlock\n if @locking\n @locking_file.close\n end\n end", "def lock\n if @unlocked == false\n raise Exception.new(\"a locked door needith not to be locked\")\n else\n return @unlocked = false\n end\n end", "def lock(opts={})\n super\n end", "def lock(opts={})\n super\n end", "def lock(opts={})\n super\n end", "def unfreeze; end", "def unlocked?\n !locked?\n end", "def unassign(ticket)\n send(ticket.bag_size)[ticket.locker_number] = false\n end", "def locked?(obj)\n RedisMutexer.config.redis.exists(key(obj))\n end", "def without_locking(&block)\n current = ActiveRecord::Base.lock_optimistically\n ActiveRecord::Base.lock_optimistically = false if current\n begin\n block.call\n ensure\n ActiveRecord::Base.lock_optimistically = true if current\n end\n end", "def unlock(secret)\n secret.locked = false\n secret.unlocked_value = YAML.load(security.decrypt(secret.value))\n secret\n end", "def use\n raise \"No block was given.\" if !block_given?\n \n obj = self.get_and_lock\n \n begin\n yield(obj)\n ensure\n self.free(obj)\n end\n end", "def setVehicleLock _obj, _args\n \"_obj setVehicleLock _args;\" \n end", "def unlocked?\n @unlocked\n end", "def unlock!(certifier)\n return false unless self.locked? # gotta be locked\n# return false unless self.certified_at.nil? # can't already be certified\n return false unless self.certifier_id == certifier.id # gotta be the currently active user\n\n return self.update_attributes!(:locked => false, :certifier_id => nil)\n end", "def send_unlock_instructions; end", "def unlock(options = {})\n\n Rails.logger.debug \"---- UNLOCK #{self.class} #{self.try(:id)} #{options.inspect}\"\n \n if options.length == 0 || options[:only] == :parent\n self.locked = false\n self.save\n end\n if (options.length == 0 || options[:only] == :children) && respond_to?(:lockable_children)\n lockable_children.map(&:unlock)\n end\n nil\n end", "def send_unlock_instructions(attributes = {})\n lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)\n lockable.resend_unlock_instructions if lockable.persisted?\n lockable\n end", "def can_unlock?\n SpaceRequestPolicy.can_unlock?(current_user, object)\n end", "def unlock(token)\n return NotImplemented unless @lock_class\n\n token = token.slice(1, token.length - 2)\n if(token.nil? || token.empty?)\n BadRequest\n else\n lock = @lock_class.find_by_token(token)\n if(lock.nil? || lock.user != @user)\n Forbidden\n elsif(lock.path !~ /^#{Regexp.escape(@path)}.*$/)\n Conflict\n else\n lock.destroy\n NoContent\n end\n end\n end", "def use(&block)\n @mutex.synchronize { yield @obj, @mutex }\n end", "def lock\n @can_get_cards = false\n end", "def unlock_all!\n locks.active.each(&:unlock!)\n end", "def run_action_unlock(item)\n item = validate_item(item)\n ui.print \" Unlocking #{ui.color(item, :bold)}... \"\n content = load_json(File.read(item)).to_smash\n if content[:sfn_parameters_lock]\n content = unlock_content(content)\n content.delete(:sfn_lock_enabled)\n File.write(item, format_json(content))\n ui.puts ui.color(\"unlocked\", :green)\n else\n ui.puts ui.color(\"no-op\", :yellow)\n ui.warn \"Item is already unlocked! (#{item})\"\n end\n end", "def unlocked_release(id)\n lock_file = @machine_locks[id]\n if lock_file\n lock_file.close\n begin\n File.delete(lock_file.path)\n rescue Errno::EACCES\n # Another process is probably opened it, no problem.\n end\n\n @machine_locks.delete(id)\n end\n end", "def lock\n if unlocked_status == false\n raise ArgumentError.new(\"You cannot lock this door - it is already locked\")\n else\n door_hash[:unlocked_status] = false\n end\n end", "def unlock\n return unless @locking\n\n @locking_file.close\n\n return unless File.exist?('/var/tmp/vcenter-importer-lock')\n\n File.delete('/var/tmp/vcenter-importer-lock')\n end", "def release\n # @invObj.releaseObj(self)\n end", "def unload_extra\n log \"Unloading extra baggage\" , Logger::Ultimate\n @mutex.synchronize do\n @ghash.delete_if do |goid, obj|\n if obj.busy?\n log \"#{obj} busy\" , Logger::Ultimate\n false\n elsif obj.is_a? Player or obj.is_a? Mobile\n false\n elsif obj.container.nil? or not self.loaded? obj.container\n puts \"Checking #{obj}\" , Logger::Ultimate\n if obj.can? :inventory\n if obj.inventory.has_any? Player or obj.inventory.has_any? Mobile\n log \"It contains a player or mobile:\" , Logger::Ultimate\n log obj.inventory.find_all('class', Player) , Logger::Ultimate\n log obj.inventory.find_all('class', Mobile) , Logger::Ultimate\n false\n else\n @storage.store_object(obj)\n true\n end\n else\n log \"Saving #{obj}\" , Logger::Ultimate\n @storage.store_object(obj)\n log \"Dropping #{obj}\\nContainer is #{obj.container}\\nNo Inventory\" , Logger::Ultimate\n log \"Saving #{obj}\" , Logger::Ultimate\n true\n end\n else\n puts \"#{obj} isn't a player or a mobile or busy and it has a container\" , Logger::Ultimate\n false\n end\n end\n end\n log \"Baggage unloaded\", Logger::Ultimate\n end", "def unlock(token)\n if lock_tokens.include? token\n remove_lock token\n @lock_info = nil\n\n :no_content\n else\n :forbidden\n end\n end", "def send_unlock_instructions(attributes = T.unsafe(nil)); end", "def force_unlock(parameters = {}, invocation_options = {})\n exec(RubyTerraform::Commands::ForceUnlock,\n parameters, invocation_options)\n end" ]
[ "0.72209734", "0.7140033", "0.7085236", "0.70580643", "0.6900973", "0.68980694", "0.687733", "0.68606055", "0.67848706", "0.6768044", "0.6700292", "0.65396726", "0.6535347", "0.65267664", "0.65067124", "0.6462361", "0.6410759", "0.6383346", "0.63611275", "0.6324751", "0.622184", "0.61977607", "0.61573404", "0.61531377", "0.6148051", "0.6142961", "0.61140645", "0.6099465", "0.6083528", "0.607316", "0.60696435", "0.6067031", "0.60612136", "0.60608625", "0.60296863", "0.601855", "0.60089195", "0.59901065", "0.59880453", "0.5985064", "0.5975498", "0.5964126", "0.5962243", "0.59522617", "0.59403217", "0.59403217", "0.59403217", "0.5931158", "0.5923058", "0.5916172", "0.5913692", "0.59014803", "0.5901051", "0.58995384", "0.58949196", "0.5885907", "0.5880753", "0.58780295", "0.58727145", "0.5865855", "0.58581346", "0.5832849", "0.5828402", "0.5803175", "0.5797027", "0.578463", "0.5779536", "0.5779536", "0.5773085", "0.5762025", "0.5758764", "0.5758764", "0.5758764", "0.57540196", "0.57412505", "0.57303226", "0.5724755", "0.57157576", "0.5711288", "0.5704805", "0.57035595", "0.56946796", "0.5678927", "0.5676204", "0.5671262", "0.56628925", "0.5661246", "0.5659613", "0.56572187", "0.5642778", "0.5636344", "0.5631535", "0.561914", "0.5614498", "0.5607677", "0.5602004", "0.5597317", "0.5597001", "0.5593027", "0.5592217" ]
0.7081866
3
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
def rate_limit!(namespace, limit: 5, minutes: 5) request_time = DateTime.now log_path = Rails.root.join("tmp/rate_limits/#{namespace}.log") unless File.exist?(log_path) FileUtils.mkdir_p(File.dirname(log_path)) FileUtils.touch(log_path) timestamp = request_time.strftime('%Y-%m-%dT%H:%M:%S%Z') count = 0 File.write(log_path, "#{timestamp} #{count}") end # Check if log is in limit state log = File.open(log_path, 'r') timestamp, count = log.read.chomp.split time = DateTime.parse(timestamp, '%Y-%m-%dT%H:%M:%S%Z') count = count.to_i if time < (request_time - minutes.minutes) # Time window expired - reset timestamp = request_time.strftime('%Y-%m-%dT%H:%M:%S%Z') count = 1 else # Current time window count += 1 if count > limit flash[:alert] = 'Too many recent requests. Please try again later.' render(status: :too_many_requests) timestamp = DateTime.now.strftime('%Y-%m-%dT%H:%M:%S%Z') # Refresh timestamp File.write(log_path, "#{timestamp} #{count}") return false end end # Update log and allow request to proceed File.write(log_path, "#{timestamp} #{count}") 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 strategy; end", "def used?; end", "def offences_by; end", "def custom; end", "def custom; end", "def suivre; end", "def isolated; end", "def isolated; end", "def private_method\n end", "def intensifier; end", "def spec; end", "def spec; end", "def internal; end", "def initialize\n\n end", "def initialize\n\n end", "def operations; end", "def operations; end", "def initialize\n \n end", "def initialize\n \n end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def missing; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def celebration; 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 initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n\t\t\n\tend", "def extra; end", "def initialize() end", "def villian; end", "def weber; end", "def apply\n end", "def executor; end", "def executor; end", "def executor; end", "def overrides; end", "def internship_passed; end", "def initialize\r\n\r\n end", "def initialize\n # nothing here for now\n 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 anchored; end", "def identify; end", "def ignore; end", "def who_we_are\r\n end", "def wrapper; end", "def missing?; end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def init; end", "def init; end", "def init; end", "def init; end", "def processor; end", "def formation; end", "def same; end", "def operation; end", "def common\n \n end", "def sitemaps; end" ]
[ "0.7687934", "0.6349491", "0.6315199", "0.6315199", "0.6275309", "0.6207741", "0.6207741", "0.6207741", "0.6207741", "0.6172574", "0.6029909", "0.5963366", "0.5911472", "0.5881053", "0.5881053", "0.5860235", "0.58521295", "0.58521295", "0.5839214", "0.57903016", "0.5770094", "0.5770094", "0.57510096", "0.5743143", "0.5743143", "0.57395566", "0.57395566", "0.5732469", "0.57255524", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.5716744", "0.56961566", "0.5670494", "0.5670494", "0.5667982", "0.56623006", "0.565477", "0.5654238", "0.5654238", "0.5654238", "0.56338537", "0.56338537", "0.56338537", "0.56338537", "0.56338537", "0.56338537", "0.56338537", "0.56338537", "0.56338537", "0.56338537", "0.56271416", "0.5619644", "0.5617635", "0.5613513", "0.5598341", "0.55940586", "0.5590739", "0.5590739", "0.5590739", "0.55863976", "0.5574602", "0.556937", "0.55685776", "0.55629104", "0.55629104", "0.55629104", "0.55629104", "0.55629104", "0.55629104", "0.55629104", "0.55629104", "0.55629104", "0.5561062", "0.5555771", "0.55553716", "0.5551977", "0.55505216", "0.55497825", "0.5547578", "0.5547578", "0.5547578", "0.5547578", "0.5545404", "0.5545404", "0.5545404", "0.5545404", "0.5543111", "0.55398977", "0.5524219", "0.5523672", "0.5514821", "0.5513974" ]
0.0
-1
Array output original array algo each takes an array and a block given the array iterate over array invoke the block passing in element as arg return passed in array
def each(arr) counter = 0 while counter < arr.length yield(arr[counter]) counter += 1 end arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(array)\n for elem in array do\n yield(elem)\n end\n\n array\nend", "def each(&block)\n array.each(&block)\n end", "def each(&block)\n @array.each(&block)\n end", "def custom_each(array)\n i = 0\n while i < array.length\n #yield will pass this element to the block\n yield array[i] #each and single element of array iterate\n i += 1 #to stop infinite loop\n end\nend", "def each(&block)\r\n @arr.each &block\r\n end", "def each(&block)\r\n @arr.each &block\r\n end", "def each(&block)\n @array.each(&block)\n end", "def each(&block)\n @array.each(&block)\n end", "def custom_each(array)\r\n i = 0 \r\n while i < array.length \r\n yield array[i]\r\n i += 1\r\n end\r\nend", "def my_each(array)\n i = 0\n while i < array.length\n yield(array[i])\n array[i]\n i += 1\n end\n array\nend", "def custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend", "def my_array(array,&block)\n ret = []\n array.each do |n|\n ret << block.call(n) # ret << n * 10\n end\n ret\nend", "def nc_my_each(array, &block)\n array.length.times do |i|\n block.call(array[i])\n end\n array\nend", "def my_collect(input_array)\n if block_given?\n counter = 0\n output = []\n while counter < input_array.size\n output << yield(input_array[counter])\n counter +=1\n end\n output\n end\n\n\n\n\nend", "def my_each(array)\n\t\t#array = []\n\t\tindex = 0\n\t\twhile index < array.length\n\t\t\tyield(array[index])\n\t\t\tindex += 1\n\t\tend\n\t\treturn array\n\tend", "def my_collect(array) # put argument(s) here\n # code here\n i = 0\n result = []\n\n while i < array.size\n\n result << yield(array[i])\n i += 1\n end\nresult\nend", "def each(array)\n idx = 0\n while idx < array.size\n yield(array[idx]) if block_given?\n idx += 1\n end\n\n array\nend", "def map(array)\n new = []\n i = 0\n \n while i < array.length do\n \n # yield passes each element to the block\n new.push(yield(array[i]))\n # push the element into the new array\n \n i += 1\n \n # Each method call with a block will do the actual calculations\n \n end\n new\nend", "def my_each(array) \n n = 0\n while n < array.length \n yield(array[n])\n n = n + 1 \n end\n array\nend", "def my_each(array) # put argument(s) here\n i = 0\n\n while i < array.length\n yield array[i]\n i += 1\n end\n array\nend", "def my_each(array)\n if block_given?\n i = 0\n while i < array.length\n yield array[i]\n i = i + 1\n end\n array\n end\nend", "def map(arr) # creating our own map method\n\tnewArr = [] # declaring an empty array to push our results inside\n\tarr.each do |i| # run the block of code to iterate inside each elements in an array\n\t\tnewArr << yield(i) # push the modified elements inside our newArr []\n\tend\n\tnewArr\nend", "def yield_with_each(array, &block)\n array.each do |x|\n yield x\n end\n\nend", "def map &block\n new_array = [] # create a new array where elements will go into\n self.each {|el| new_array << (yield el)} # for each true element in the block, shovel that element into new array\n new_array # return the new array\n end", "def my_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\n array\nend", "def each(*args, &block)\n array.each(*args, &block)\n end", "def each(array)\n counter = 0\n while counter < array.size do\n yield(array[counter])\n counter += 1\n end\n array\nend", "def map2(arr)\n result = []\n each arr do |x|\n results << yield(x)\n end\n results\nend", "def each(array)\n index = 0\n\n while index < array.size\n element = array[index]\n yield element\n index += 1\n end\n \n array\nend", "def my_each(array)\n if block_given?\n counter = 0\n while counter < array.length\n yield (array[counter])\n counter += 1\n end\n array\n else\n puts \"No block given\"\n end\nend", "def yield_with_each(array, &block)\n array.each { |i| yield i }\nend", "def my_each(arr)\n array = []\n n = 0\n while n < arr.length\n yield(arr[n])\n array << arr[n]\n n += 1\n end\n array\nend", "def each(&blk)\n (0..@size-1).each { |i| blk.call(self.[](i)) }\n end", "def each &b\n\t\t@array.each(&b)\n\tend", "def my_each(array)\n if block_given?\n i = 0\n \n while i < array.length \n yield array[i] \n i = i + 1 \n end\n \n array\n else\n return \"Hey! No block was given!\"\n end\nend", "def pass_block(arr)\n yield arr\nend", "def mapa(array)\n i = 0\n oarray = []\n while i < array.size\n oarray << yield(array[i])\n i += 1\n end\n oarray\nend", "def map(array)\n new = []\n i = 0 \n while i < array.length\n # yield pass element of the array to the block. map{ block }\n new.push(yield(array[i]))\n i += 1 \n end\n new \nend", "def map(arr)\n # create empty array to populate with results of called block\n arr2 = []\n # for each element in the array, run the block of code, held in yield, on it then add that element to the new array\n arr.each { |x| arr2 << yield(x) }\n # return the new array, setting the original array to these new values\n arr2\nend", "def each (arr)\n # arr = [2, 3, 4] #val will be 2 in the first iteration and so on.\n for val in arr \n # we are calling block ({ |x| x * 10 }) with \n result = yield(val)\n puts \"result: #{result}\"\n end\nend", "def each a\n\ti = 0\n\tuntil i == a.size\n\t\tyield a[i]\n\t\ti += 1\n\tend\n\ta\nend", "def my_collect(array)\ni = 0\n\nnewArray = []\nwhile i < array.length\n\n newArray.push(yield array[i])\n i = i + 1\nend\nnewArray\nend", "def cada2(array, &myproc)\n i = 0\n while i < array.size\n myproc.call(array[i])\n i += 1\n end\n array\nend", "def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def each(&block)\n to_a.each(&block)\n end", "def map(arr)\n result = []\n arr.each {|element| result << yield(element)}\n result\nend", "def map(arr)\n result = []\n arr.each {|element| result << yield(element)}\n result\nend", "def each\n @arr.each do |n|\n yield(n)\n end\n end", "def each(&block)\n to_a.each(&block)\n end", "def each(arr)\n ndx = 0\n while ndx < arr.size do\n yield(arr[ndx])\n ndx += 1\n end\n arr\nend", "def each_method(array)\n i = 0\n while i< array.length\n yield array[i]\n i +=1\n end\nend", "def my_collect(array)\n i = 0\n collection = []\n while i < array.size\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&blk)\r\n to_a.each(&blk)\r\n end", "def my_collect(array)\n collection = []\n index = 0\n while index < array.size\n collection << yield(array[index])\n index += 1\n end\n collection\nend", "def each (arr)\n # arr = [2, 3, 4, 5]\n # val will be 2 in the first iteration and so on...\n for val in arr \n # we are calling block ({ |x| x * 10 }) with val\n result = yield(val)\n puts \"result: #{result}\"\n end\nend", "def each(&blk)\n to_a.each(&blk)\n end", "def map(arr)\n new_arr = []\n for el in arr\n new_arr << yield(el)\n end\n new_arr\nend", "def my_collect(array)\n i = 0\n collect = []\n while i < array.length\n collect << yield(array[i])\n i+=1\n end\n collect\nend", "def each\n if block_given?\n @array.each do |e|\n yield e\n end\n end\n end", "def each(&block)\n i = @elements.length - 1\n while i >= 0\n yield @elements[i]\n i -= 1\n end\n end", "def my_collect(array)\n i = 0\n collect = []\n while i < array.length\n collect << yield(array[i])\n i += 1\n end\n collect\nend", "def my_collect(array)\n \n i = 0 \n collect = []\n \n while i < array.length \n collect << yield(array[i])\n i += 1\n end\n \n collect \nend", "def map(array)\n new_array = []\n for element in array\n new_array << yield(element)\n end\n new_array\nend", "def simp_mt(arr1)\n arr1.map {|el| el ** 3} #passing BLOCK to map method, method on Arr\nend", "def for_each_in(array, &instructions)\n for i in 0...array.length\n instructions.call(array[i])\n end\nend", "def map(array)\n array.each_with_object([]) { |element, results| results << yield(element) }\n# results\nend", "def array(ary, &block)\n ary.map { |v| _recurse_(v, &block) }\n end", "def work_input(input_arr)\n yield(input_arr)\nend", "def map(array)\n result = []\n array.each { |element| result << yield(element) }\n result\n\n# using Enumerable #reduce\n array.reduce([]) { |result, element| result << yield(element)}\nend", "def yield_with_each(array, &block)\n if array == []\n nil\n else\n array.each {|i| block.call(i)}\n end\nend", "def map(array)\n new = []\n i = 0\n while i < array.length\n new.push(yield(array[i]))\n i += 1\n end\n new\nend", "def each(&block)\n to_a.each(&block)\n end", "def each(&block)\n to_a.each(&block)\n end", "def for_each_element(arr)\n index = 0\n total = arr.size\n\n while index < total\n yield(arr[index])\n index += 1\n end\nend", "def our_reduce(array, result = array.shift)\n array << \"test\" # => [\"moose\", \"bear\", \"cat\", \"dog\", \"test\"]\n array.each do |el| # => [\"moose\", \"bear\", \"cat\", \"dog\", \"test\"]\n result = yield(result, el) # => 5, 9, 12, 15, 19\n end # => [\"moose\", \"bear\", \"cat\", \"dog\", \"test\"]\n result # => 19\nend", "def each_cons(arr, &block)\n arr.size < 2 ? return : block.call(arr[0, 2])\n each_cons(arr.drop(1), &block)\nend", "def each\n for each element\n yield(element)\n end\nend", "def each_pair(&block); end", "def sum_using_each(array)\n end", "def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend", "def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend", "def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend", "def each\n unless @array.empty?\n @array.size.times do |i|\n yield @array[i]\n end\n end\n end", "def each\n yield self[0]\n yield self[1]\n end", "def hello_t(array)\n i = 0\n\n while i < array.length\n yield(array[i])\n i = i + 1\n end\n\n array\nend", "def map(list, &block)\n array = []\n list.each do |ele|\n array << block.call(ele)\n end\n\n array\nend", "def my_map(&block)\n array = Array.new\n self.my_each do |x|\n array << block.call(x)\n end\n array\n end", "def my_collect(array)\n new_array = []\n # if array.size == 0\n # return 0\n # else\n counter = 0\n while counter < array.length\n new_array << yield(array[counter])\n counter += 1\n end\n \n new_array\nend", "def map(source_array)\n new_array = []\n index = 0\n while index < source_array.size do \n new_array[index] = yield(source_array[index])\n index += 1\n end\n \n new_array\nend", "def each(&a_proc); end", "def yield_with_while_loop(array, &block)\n i = 0\n while i < array.length\n block.call(array[i])\n#yield array[i]\ni+=1\nend\nend", "def map\n return dup unless block_given?\n out = Array.new @total\n i = 0\n while i < @total\n out[i] = yield(at(i))\n i += 1\n end\n out\n end" ]
[ "0.75485575", "0.74348205", "0.74239683", "0.736643", "0.728209", "0.728209", "0.7272646", "0.7272646", "0.7236823", "0.72240263", "0.7173359", "0.7173057", "0.7145331", "0.71402687", "0.7139408", "0.71120423", "0.71055305", "0.7104836", "0.70990276", "0.709017", "0.7079499", "0.70515776", "0.70456076", "0.7030746", "0.70213884", "0.7010031", "0.700564", "0.69990283", "0.6992045", "0.6989055", "0.69809693", "0.6974423", "0.6954499", "0.69517654", "0.6950467", "0.69244224", "0.691751", "0.6917226", "0.689766", "0.68799984", "0.6878154", "0.6870535", "0.6837553", "0.68363476", "0.68363476", "0.68363476", "0.6826383", "0.6825253", "0.6825253", "0.6824223", "0.67955816", "0.67944014", "0.6793812", "0.6782824", "0.67657363", "0.67657363", "0.67657363", "0.67657363", "0.67657363", "0.67657363", "0.6752821", "0.67333716", "0.6733264", "0.6726472", "0.6715566", "0.67025244", "0.6698422", "0.66968924", "0.6693368", "0.6692399", "0.66844237", "0.66832834", "0.666406", "0.6660045", "0.6646893", "0.66439253", "0.66279095", "0.66182536", "0.66073257", "0.6601878", "0.6601878", "0.65968853", "0.65868497", "0.6582587", "0.65720534", "0.65695804", "0.6567034", "0.6565143", "0.6565143", "0.6565143", "0.6561229", "0.6541898", "0.65387", "0.6531733", "0.6513555", "0.6507889", "0.650036", "0.64972293", "0.6496221", "0.6487495" ]
0.68069834
50
Calculate the sub_total as the SUM(line_item.line_amount).
def sub_total total_cache(:sub_total) || sum_line_items(line_items, :line_amount) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subtotal\n line_items.reduce(BigDecimal(\"0\")) { |result, item| result += item.amount }\n end", "def sub_total\n sum = 0\n line_items.each do |line_item|\n sum += line_item.total_price\n end\n sum\n end", "def sub_total\n return ApplicationHelper.round_currency(self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price })\n end", "def sub_total_price\n line_items.inject(0) {|sum, item| sum += item.price * item.qty }\n end", "def line_total\n (@quantity * @price + line_item_sales_tax_total).round(2)\n end", "def get_total_price\n self.line_items.sum { |item| item.get_subtotal }\n end", "def subtotal\r\n\t\t@items.inject(0.0) { |sum, i| sum + i.total_unit_price * i.quantity }\r\n\tend", "def total\n @total = items.inject(0.0) { |sum, order_line_item| sum + order_line_item.subtotal }\n end", "def subtotal\n order_items.collect{|order_item| order_item.valid? ? order_item.price.to_d * order_item.quantity.to_i : 0}.sum\n end", "def calculate_invoice_total\n res = [ ]\n self.line_items.each do |item|\n res.push(item.qty * item.price)\n end\n # Return the sum of the items\n self.total = res.inject(:+) \n end", "def total\n total = 0\n line_items.each do |line_item|\n total += line_item.item.price * line_item.quantity\n end\n total\n end", "def items_sub_total\n order_items.inject(BigDecimal(0)) { |t, i| t + i.sub_total }\n end", "def items_sub_total\n order_items.inject(BigDecimal(0)) { |t, i| t + i.sub_total }\n end", "def subtotal\n return items.inject(0) {|total, item| total + item.subtotal}\n end", "def subtotal\n @items.sum { |item| item.subtotal }\n end", "def total\n sum = self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price } +\n self.price_modifiers.inject(BigDecimal('0.0')) { |sum, pm| sum + pm.amount }\n return ApplicationHelper.round_currency(sum)\n end", "def item_total\n line_items.map(&:total).reduce(:+)\n end", "def total_price\n line_items.map { |line_item| line_item.item.price * line_item.quantity }.sum\n end", "def subtotal\n order_items.collect { |oi| oi.valid? ? (oi.quantity * oi.unit_price) : 0 }.sum\n end", "def subtotal_sub\n itemis.collect{|itemi| itemi.valid? ? itemi.unit_price*itemi.quantity_quantity : 0}.sum\n end", "def total_price\n self.line_items.each.sum {|li| li.total_price}\n end", "def subtotal\n items.map(&:price).reduce(&:+)\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price}\n end", "def total_price\n line_items.to_a.sum {|item| item.total_price}\n end", "def item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total\n end\n self.item_total = tot\n end", "def total_price\n\t\tline_items.to_a.sum { |item| item.total_price }\n\tend", "def line_items_total\n\t\ttotal = 0\n\t\tfor item in self.order_line_items\n\t\t\ttotal += item.total\n\t\tend\n\t\treturn total\n\tend", "def total_price\n\t\tline_items.to_a.sum{|item| item.total_price}\n\tend", "def total\n cart_value = 0\n self.line_items.each do |line_item|\n cart_value += line_item.value\n end\n cart_value\n end", "def sub_total\n (self.subtotal + self.taxes + self.shipping_cost)\n end", "def total_amount\n line_items.reduce(Money.zero) { |a, e| a + e.total_amount_inc_tax }\n end", "def subtotal\n #SQL version of summing which is much faster than Ruby\n line_items.select(\"SUM(quantity * price) AS sum\")[0].sum\n # Ruby version of sum\n # line_items.to_a.sum {|item| item.total}\nend", "def subtotal\n self.cost_per_pound * self.order_quantity\n end", "def subtotal\n subtotal = (self.quantity) * (self.product.price)\n return subtotal.round(2)\n end", "def total\n @items_total = []\n self.line_items.each do |item|\n @item = Item.find_by_id(item.item_id)\n @items_total << @item.price.to_f\n end\n cart_total = @items_total.inject(0){|sum, x| sum + x }\n @cart_total = cart_total.round(2)\n @cart_total\n end", "def total_price\n # convert to array so it doesn't try to do sum on database directly\n @total = 0\n line_items.each do |item|\n @total = item.price\n end\n line_items.to_a.sum {|item| (item.quantity * item.price) }\n end", "def test_credit_note_sub_total_calculation\n credit_note = create_test_credit_note\n line_item = credit_note.line_items.first\n\n # Make sure that everything adds up to begin with.\n expected_sub_total = credit_note.line_items.inject(BigDecimal('0')) { | sum, l | l.line_amount }\n assert_equal(expected_sub_total, credit_note.sub_total)\n\n # Change the amount of the first line item and make sure that\n # everything still continues to add up.\n line_item.unit_amount = line_item.unit_amount + 10\n assert_not_equal(expected_sub_total, credit_note.sub_total)\n expected_sub_total = credit_note.line_items.inject(BigDecimal('0')) { | sum, l | l.line_amount }\n assert_equal(expected_sub_total, credit_note.sub_total)\n end", "def grand_total\n order_lines.inject(Money.new(0)) { |grand_total, line| grand_total + line.total_price }\n end", "def total\n total_price = 0.0\n cart.line_items.each do |line_item|\n if !line_item.unit_price.blank?\n total_price += line_item.unit_price.to_f\n if line_item.line_item_options\n line_item.line_item_options.each do |line_item_option|\n total_price += line_item_option.price.to_f\n end\n end\n elsif line_item.menu_section_item\n total_price += line_item.menu_section_item.price.to_f\n if line_item.menu_item_options\n line_item.menu_item_options.each do |menu_item_option|\n total_price += menu_item_option.price.to_f\n end\n end\n else\n total_price += 0\n end\n end\n tax = total_price.to_f * 0.0825\n total_price = total_price + tax\n if tip\n total_price = total_price.to_f + tip.to_f\n end\n return total_price\n end", "def total_amount\n sum = ::Money.new(1, self.currency)\n @line_items.each {|li| sum += li.total_amount}\n sum -= ::Money.new(1, self.currency)\n sum\n end", "def total_items\n line_items.sum(:quantity)\n end", "def total_items\n line_items.sum(:quantity)\n end", "def total\n\t\tprices = line_items.map {|li| li.price}\n\t\tprices.reduce(0) {|it0, it1| it0+it1}\n\tend", "def total_quantity\n line_items.sum(:quantity)\n end", "def unadjusted_total\n total = Money.new( 0, 'USD' )\n \n for line_item in line_items\n total += ( line_item.price * line_item.quantity )\n end\n \n total\n end", "def total\n total_invoice_items_price(invoice_items)\n end", "def total_price\n sum = 0\n line_items.to_a.sum do |check|\n check.total_price.to_i\n end\n\t\nend", "def subtotal\n subtotal = purse.price * quantity\n end", "def total_price\n puts \"O PRECO TOTAL DE ORDER FOI CHAMADO\"\n self.line_items.to_a.sum{ |item| item.total_price}\n end", "def total\n apply_rules(subtotal).round\n end", "def sub_total\n # quantity * unit_price\n unit_price\n end", "def line_items_price_calculations(line_items)\n total_price = 0.0\n line_items.each do |li|\n total_price += (li.quantity * li.price.to_f)\n end\n return total_price\n end", "def update_total\n self.total = self.line_items.reload.map(&:total).inject(:+).to_f\n end", "def calculated_total\n variant_ids = self.standing_line_items.pluck(:variant_id)\n avvs = self.account.account_viewable_variants.where(variant_id: variant_ids).to_a\n\n self.standing_line_items.includes(:variant).inject(0.to_d) do |sum, i|\n avv = avvs.select{|avv| avv.variant_id == i.variant_id}.first\n if avv\n sum + (avv.price * i.quantity)\n else\n sum + (i.variant.price * i.quantity)\n end\n end\n end", "def running_total\n self.line_items( \n :include => {:variation => :product} \n ).inject(0) { |total, line_item| \n total + (line_item.variation.product.price * line_item.quantity)\n }\n end", "def total\n \torder_items.collect { |order_item| order_item.subtotal }.sum\n end", "def total\r\n sum = 0\r\n sales_lines.each do |line|\r\n sum += line.line_amount unless line.line_amount.blank?\r\n end\r\n return sum\r\n end", "def total_items\n\t\tline_items.sum(:quantity)\n\tend", "def total_cost_items\n line_items.sum(&:total_cost_line_item)\n end", "def total\n self.line_items_total + self.shipping_cost\n end", "def test_credit_note_sub_total_calculation2\n credit_note = create_test_credit_note\n line_item = credit_note.line_items.first\n\n # Make sure that everything adds up to begin with.\n expected_total_tax = credit_note.line_items.inject(BigDecimal('0')) { | sum, l | l.tax_amount }\n assert_equal(expected_total_tax, credit_note.total_tax)\n\n # Change the tax_amount of the first line item and make sure that\n # everything still continues to add up.\n line_item.tax_amount = line_item.tax_amount + 10\n assert_not_equal(expected_total_tax, credit_note.total_tax)\n expected_total_tax = credit_note.line_items.inject(BigDecimal('0')) { | sum, l | l.tax_amount }\n assert_equal(expected_total_tax, credit_note.total_tax)\n end", "def subtotal\n self.product.price * self.quantity\n end", "def total_cost\n line_items.to_a.sum {|item| item.total_cost}\n end", "def update_line_item_totals(line_item)\n line_item.total_price = line_item.price * line_item.quantity\n line_item.save\n end", "def item_total\n @promotion_attributed_line_items.map(&:amount).sum\n end", "def total\n sub_total\n end", "def get_line_item_total(id)\n\t\tself.order_line_items.each do |item|\n\t\t\treturn item.total if item.product_id == id\n\t\tend\n\t\treturn 0\n\tend", "def line_vat_total\n order_lines.inject(0) { |sum, l| sum + l.vat_amount }\n end", "def additional_shipping_total\n self.line_items.inject(0) { |total,line_item| total + line_item.variation.product.additional_shipping_cost }\n end", "def total\n subtotal\n # + tax\n end", "def get_total\n counts = convert_to_hash(@item_list)\n uniq_items = @item_list.uniq\n\n final = (@total - @sale.apply(uniq_items, counts)).round(2) # Used round for precision\n puts get_invoice + final.to_s\n final\n end", "def total\n total = 0.00\n #accesses the subtotal of each of the order items\n order_items.each do |item|\n total += item.subtotal\n end\n return total.round(2)\n end", "def total_full_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_full_price)\n end", "def calculate_total\n order_items.sum(:total)\n end", "def total\n total = order_items.inject(0) { |sum, p| sum + p.subtotal }\n end", "def get_subtotal\n if is_a_review?\n user_visibility = :peer_visible\n else\n user_visibility = :ta_visible\n end\n Result.get_subtotals([self.id], user_visibility: user_visibility)[self.id]\n end", "def update_line_item_totals(line_item)\n\t\tline_item.total_price = line_item.price * line_item.quantity\n\t\tline_item.save\n\tend", "def subtotal\n fees = [ticket_fees_in_cents].sum\n\n discounted_total + fees\n end", "def line_total_net\n order_lines.inject(BigDecimal(\"0\")) { |sum, l| sum + l.line_total_net }\n end", "def discount_on_line_item_total\n total_discount = 0\n\n line_item_promotions.each do |promotion|\n total_discount += discount_for_line_item_promotion(promotion)\n end\n\n total_discount\n end", "def set_total\r\n self.total = self.order_items.collect{ |order_item| order_item.valid? ? (order_item.sub_total) : 0 }.sum.to_d\r\n end", "def recalculate_totals\n # Line's total prices (qty * amount)\n single_untaxed_price_after_rebate = BigDecimal.new( (self.single_untaxed_price - self.single_rebate).to_s )\n self.gross_price = BigDecimal.new( (self.quantity * single_untaxed_price_after_rebate).to_s )\n self.gross_price = self.gross_price\n self.taxes = (self.gross_price / BigDecimal.new(\"100.0\")) * self.tax_percentage\n self.taxed_price = (BigDecimal.new( (self.gross_price + self.taxes).to_s )).rounded # Rounded like in document_line.rb\n\n # Line's single prices (for qty 1 * amount)\n single_taxes = ((single_untaxed_price_after_rebate / BigDecimal.new(\"100.0\")) * self.tax_percentage) # like in product.rb\n self.single_price = (single_untaxed_price_after_rebate + single_taxes).rounded # Like in document_line.rb\n\n end", "def amount\n estimate_total = self.estimate_line_items.sum(:amount)\n if self.tax_inclusive? \n tax_total = 0 \n else\n tax_total = 0 \n tax_line_items.each do |line_item|\n tax_account = line_item.account\n next if (tax_account.accountable_type=='DutiesAndTaxesAccounts' && tax_account.accountable.calculation_method==4 && tax_account.accountable.split_tax == 0) \n tax_total += line_item.amount\n end\n end\n ship_charge = self.shipping_line_items.sum(:amount)\n estimate_total + tax_total + ship_charge\n end", "def total_discounted_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_discounted_price)\n end", "def total_item\n @items.reject {|item| item.quantity == 0}\n invoice_total = @items.sum {|item| item.sale_price * item.quantity}\n\n end", "def subtotal_amount\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(\"/_lblSubTotalAmount$/\"), format_method(__method__))\n end", "def update_subtotal_items!\n subtotal = @customer_order.order_items.collect do |order_item|\n order_item.cache_provider_item_precio!\n order_item.subtotal\n end.sum\n @customer_order.assign_attributes(\n subtotal_items: subtotal\n )\n end", "def subtotal_amount\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(\"/_SubtotalLabel$/\"), format_method(__method__))\n end", "def value_for_line_item(line_item)\n return 0 unless line_item_eligible?(line_item)\n line_item.total\n end", "def get_total_qnty(line_items)\n line_items.map(&:quantity).sum\n end", "def get_total_qnty(line_items)\n line_items.map(&:quantity).sum\n end", "def line_total_gross\n zr = zero_rated?\n order_lines.inject(BigDecimal(\"0\")) do |sum, l|\n sum + l.line_total_net + (zr ? 0 : l.vat_amount)\n end\n end", "def total_unit_price\r\n\t\ttotal = self.unit_price\r\n\r\n\t\tliovs = self.line_item_option_values\r\n\t\tliovs.each do |cur_liov|\r\n\t\t\ttotal += cur_liov.extra_cost\r\n\t\tend\r\n\r\n\t\ttotal\r\n\tend", "def total\n subtotal + tax + shipping\n end", "def calculate_total\n sub_total = 0\n\n if size\n sub_total += Config.booths[size][:price]\n end\n\n self.add_ons.each do |add_on|\n sub_total += add_on.total\n end\n sub_total += industries.length * 35000\n sub_total += fees.pluck(:amount).reduce(0, &:+)\n\n self.total = sub_total\n self.balance = total - payments.paid.map(&:amount_paid).reduce(0, &:+)\n self\n end", "def compute_amount(line_item)\n raise \"Adjustable does not match line item\" unless line_item == inventory_unit.line_item\n -(line_item.total.to_d / line_item.inventory_units.not_canceled.reject(&:original_return_item ).size)\n end" ]
[ "0.8941642", "0.87423617", "0.8526777", "0.8475841", "0.81044716", "0.7917328", "0.7806597", "0.77830803", "0.77776575", "0.7768823", "0.77299535", "0.77105564", "0.77105564", "0.7653539", "0.76464564", "0.76460207", "0.76066554", "0.7598901", "0.7590735", "0.75285095", "0.7493799", "0.7486226", "0.748171", "0.748171", "0.748171", "0.748171", "0.7481574", "0.74508667", "0.7416513", "0.7415254", "0.7409145", "0.73872596", "0.7378442", "0.7371814", "0.734797", "0.73449564", "0.7341029", "0.7337419", "0.7328991", "0.73173517", "0.7315696", "0.7299858", "0.72947615", "0.7294334", "0.72735184", "0.72735184", "0.7230228", "0.7209477", "0.71954465", "0.7149792", "0.71491164", "0.7137125", "0.7134448", "0.7128771", "0.71200734", "0.71163404", "0.7107549", "0.7094752", "0.7081097", "0.70732296", "0.70620036", "0.70617175", "0.70531595", "0.7052981", "0.70505536", "0.7038378", "0.7010261", "0.70011723", "0.69998944", "0.69967365", "0.69802016", "0.6970231", "0.69677347", "0.69246835", "0.6920672", "0.69138026", "0.6909998", "0.69069934", "0.69063145", "0.6904621", "0.689338", "0.6893219", "0.6888997", "0.68143433", "0.68105084", "0.67939174", "0.6789536", "0.67750704", "0.6771436", "0.6761516", "0.6759331", "0.675348", "0.67476565", "0.67420864", "0.67420864", "0.67287636", "0.67196715", "0.67161524", "0.67016953", "0.67014176" ]
0.87697595
1
Calculate the total_tax as the SUM(line_item.tax_amount).
def total_tax total_cache(:total_tax) || sum_line_items(line_items, :tax_amount) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_tax\n line_items.reduce(Money.zero) { |a, e| a + e.total_tax }\n end", "def tax_total\n self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }\n self.tax_amount\n end", "def tax_total\n self.tax_amount = line_items.inject(::Money.new(0, self.currency || ::Money.default_currency.iso_code)) {|sum,line| sum + line.tax_amount}\n self.tax_amount\n end", "def tax_total\n self.tax_amount = line_items.inject(Money.new(0, self.currency || Money.default_currency)) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end", "def tax_total\n self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end", "def total_amount\n line_items.reduce(Money.zero) { |a, e| a + e.total_amount_inc_tax }\n end", "def total_tax\n unit_tax * quantity\n end", "def total_with_tax\n total = 0\n @cart_items.each do |item|\n total += item.total_price\n end\n return total\n end", "def total_amount_inc_tax\n unit_amount_inc_tax * quantity\n end", "def line_item_sales_tax_total\n\n ((pre_tax_total * 20).ceil.to_f / 20.0).round(2)\n end", "def amount\n estimate_total = self.estimate_line_items.sum(:amount)\n if self.tax_inclusive? \n tax_total = 0 \n else\n tax_total = 0 \n tax_line_items.each do |line_item|\n tax_account = line_item.account\n next if (tax_account.accountable_type=='DutiesAndTaxesAccounts' && tax_account.accountable.calculation_method==4 && tax_account.accountable.split_tax == 0) \n tax_total += line_item.amount\n end\n end\n ship_charge = self.shipping_line_items.sum(:amount)\n estimate_total + tax_total + ship_charge\n end", "def tax\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.tax_amount }\n end", "def line_total\n (@quantity * @price + line_item_sales_tax_total).round(2)\n end", "def tax\n order.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.tax_amount }\n end", "def pre_tax_amount_from_line_item line_item\n amount = (line_item.discounted_amount - line_item.included_tax_total) / line_item.quantity\n\n Spree::Money.new(\n BigDecimal.new(amount.to_s).round(2, BigDecimal::ROUND_HALF_DOWN),\n currency: line_item.currency\n ).cents\n end", "def tax_amount\n self.quantity * single_item_tax\n end", "def total_before_tax\n self.delivery_price + self.items_sub_total\n end", "def sum_of_tax_rates line_item\n line_item.adjustments.tax.\n joins(\"INNER JOIN spree_tax_rates ON spree_tax_rates.id = spree_adjustments.source_id\").\n where(spree_tax_rates: { included_in_price: true }).\n map(&:source).\n sum(&:amount)\n end", "def total_before_tax\n order.delivery_price + items_sub_total\n end", "def calculate_total_for_tax(invoice, tax_rate)\n total_amount = total_tax_amount = 0\n\n components = invoice.\n all_items.\n flatten.\n select { |component| component.tax_rate == tax_rate }\n\n components.each do |component|\n total_amount += component.price\n total_tax_amount += component.calculate_tax\n end\n\n [total_amount, total_tax_amount]\n end", "def total_before_tax\n total = 0\n @cart_items.each do |item|\n total += item.price\n end\n return total\n end", "def tax_rate\n self[:tax_rate] ||= Float(line_items.inject(0) {|sum, l| sum + l.tax_rate}) / line_items.size\n end", "def total\n total_price = 0.0\n cart.line_items.each do |line_item|\n if !line_item.unit_price.blank?\n total_price += line_item.unit_price.to_f\n if line_item.line_item_options\n line_item.line_item_options.each do |line_item_option|\n total_price += line_item_option.price.to_f\n end\n end\n elsif line_item.menu_section_item\n total_price += line_item.menu_section_item.price.to_f\n if line_item.menu_item_options\n line_item.menu_item_options.each do |menu_item_option|\n total_price += menu_item_option.price.to_f\n end\n end\n else\n total_price += 0\n end\n end\n tax = total_price.to_f * 0.0825\n total_price = total_price + tax\n if tip\n total_price = total_price.to_f + tip.to_f\n end\n return total_price\n end", "def total\n cost_without_tax = get_cost_without_tax\n return cost_without_tax + get_sales_tax(cost_without_tax)\n end", "def add_tax_as_line_item\n raise unless @fields['x_tax']\n add_line_item :name => 'Total Tax', :quantity => 1, :unit_price => @fields['x_tax'], :tax => 0, :line_title => 'Tax'\n end", "def calculate_total_price_and_taxes\n # find the tax rate\n tax_rate_percent = 0\n\n unless is_exempt_from_regular_tax?\n tax_rate_percent += REGULAR_TAX_PERCENT\n end\n\n unless self.is_exempt_from_import_tax?\n tax_rate_percent += IMPORT_TAX_PERCENT\n end\n\n # np/100\n # total tax needs to be a float rounded to nearest .05\n @total_tax = SalesTaxes::Item.round_properly((self.price * tax_rate_percent)/100)\n\n @total_price = (@price + @total_tax)\n end", "def tax_rate\n write_attribute( :tax_rate, Float(line_items.inject(0) {|sum, l| sum + l.tax_rate}) / line_items.size)\n end", "def sales_tax\n return (@listOfItem.inject(0){|sum,e| sum += \n e.product != nil ? e.product.sales_tax + e.product.import_tax : 0 }).round_to(2)\n end", "def calc_total\n (@total_after_tax * @gratuity) + @total_after_tax\n end", "def tax_total\n send(:tax_amount) if respond_to?(:tax_amount)\n end", "def calculate_tax\n if self.vendor.net_prices\n # this is for the US tax system. At this point, total is still net.\n self.tax_amount = self.total * self.tax / 100.0\n # here, total becomes gross\n self.total += tax_amount\n else\n # this is for the Europe tax system. self.total is already gross, so we don't have to modify it here.\n self.tax_amount = self.total * ( 1 - 1 / ( 1 + self.tax / 100.0 ) )\n end\n end", "def unit_amount_inc_tax\n unit_amount + unit_tax\n end", "def vat_amount_from_line_item line_item\n amount = line_item.included_tax_total / line_item.quantity\n\n Spree::Money.new(\n BigDecimal.new(amount.to_s).round(2, BigDecimal::ROUND_HALF_UP),\n currency: line_item.currency\n ).cents\n end", "def tax_sum(tax, tax_percent)\n (tax - (tax / (1 + tax_percent))).round(2)\n end", "def total\n subtotal\n # + tax\n end", "def get_total(item_name)\n return (@item_hash[item_name].to_f + @tax_hash[item_name].to_f).round(2)\n end", "def total\n total_cache(:total) || (sub_total + total_tax)\n end", "def total_price(tax_rate)\n ((1 + tax_percentage(tax_rate)) * price)\n end", "def calculate_tax_for(total)\n if self.vat_rate.present? && self.vat_rate != 0.0\n ((self.vat_rate / 100) * total)\n else\n 0\n end\n end", "def calculate\n @item_list.each { |item|\n tax_rate = (item.exempt? ? 0.00 : Constants::NON_IMPORT_TAX_RATE) + (item.imported? ? Constants::IMPORT_TAX_RATE : 0.00)\n total_before_tax = item.qty * item.price\n tax = (total_before_tax * tax_rate).round_to_05\n\n @receipt_tax += tax\n @receipt_total += item.total = total_before_tax + tax\n }\n\n # do final rounding - needed due to Float quirks\n @receipt_tax = @receipt_tax.round(2)\n @receipt_total = @receipt_total.round(2)\n return self\n end", "def sales_tax\n total_tax_percent = 0\n if Tax.sales_tax_applicable?(@item)\n total_tax_percent += Tax.sales_tax_amount\n end\n if Tax.import_duty_applicable?(@item)\n total_tax_percent += Tax.import_tax_amount\n end\n total_tax_percent.round(2)\n end", "def total\n total_cost = 0\n \n # Summing up the product cost\n @products.each do |item, cost|\n total_cost += cost\n end\n \n # Calculate a 7.5% tax\n total_order_cost = total_cost * 1.075\n \n # Rounding the result to two decimal places\n return total_order_cost.round(2)\n end", "def tax_total\n adjustments.where(:originator_type => \"TaxRate\").map(&:amount).sum\n end", "def total_amount\n sum = ::Money.new(1, self.currency)\n @line_items.each {|li| sum += li.total_amount}\n sum -= ::Money.new(1, self.currency)\n sum\n end", "def tax_amount\n rounded(tax.percent_of(price))\n end", "def total\n order_total + delivery_price + (prices_include_tax ? 0 : tax_amount)\n end", "def cumulative_total_after_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.total\n end#each\n return amount\nend", "def tax_calc\n tax = @quantity * @price * @taxe\n end", "def calculate\n product.taxes&.map { |tax| tax_portion(tax) }.sum.to_f || 0\n end", "def discountable_item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total if li.product.taxons.any? {|t| t.name == \"Discountable\"}\n end\n self.item_total = tot\n end", "def total\n @total = items.inject(0.0) { |sum, order_line_item| sum + order_line_item.subtotal }\n end", "def calc_tax_rate(item)\n tax_rate = 0\n tax_rate += @@import_duty if item.imported\n tax_rate += @@sales_tax unless (item.is_a? Book) || (item.is_a? Food) || (item.is_a? Medicine)\n \n return tax_rate\n end", "def total_price\n (@base_price * @tax_rate + @base_price) * @quantity\n end", "def calc_all_tax(items)\n items_tax = items.collect { |item| calc_tax(item) }\n end", "def total_taxes\n @total_taxes = 0\n @list.each do |item, quantity|\n @total_taxes += quantity * item.taxes\n end\n puts \"Sales Taxes: #{MONEY_FORMAT % @total_taxes}\"\n end", "def tax_amount\n self[:tax_amount] || (application_fee * tax_rate / 100)\n end", "def item_total\n @promotion_attributed_line_items.map(&:amount).sum\n end", "def total\n sum = self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price } +\n self.price_modifiers.inject(BigDecimal('0.0')) { |sum, pm| sum + pm.amount }\n return ApplicationHelper.round_currency(sum)\n end", "def calculate_taxes\n\t\ttax = 0\n\t\t\n\t\tif self.sku.contains_merch?\n\t\t\t# because paypal orders will not have billing addresses, just set \n\t\t\t# billing == to shipping if billing_address is nil\n\t\t\tself.billing_address ||= self.shipping_address \n\t\t\t\n\t\t\ttax = (self.sku.price * self.tax_rate * self.sku_quantity).round if self.billing_address.state == self.nexus\n\t\tend\n\t\t\n\t\tself.tax_amount = tax\n\t\t\n\tend", "def total\n subtotal + tax + shipping\n end", "def get_total_price\n self.line_items.sum { |item| item.get_subtotal }\n end", "def tax25_sum\n tax_sum(tax25, 0.25)\n end", "def total\n self.delivery_price +\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end", "def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end", "def line_items_pre_tax_price\n @pre_tax ||= LineItem.total_price(unpaid_line_items)\n end", "def calculate(items)\n\n\t\titems.each do |item|\n\t\t\ttax_rate = get_tax_rate(item)\n\t\t\ttax = get_tax(item[:price], item[:quantity], tax_rate)\n\t\t\t@total_tax += tax\n\n\t\t\titem[:sales_price] = (item[:price] * item[:quantity] + tax).round(2)\n\t\t\t@total_price += item[:sales_price]\n\t\tend\n\n\t\treturn @total_tax, @total_price\n\tend", "def calculate_price\n result = 0.0\n @items.each do |item|\n name = item.name\n price = item.price\n final_taxed_price = price # Begin with price and add tax as necessary\n tax = 0.0\n\n # Is the item subject to sales tax (ie. not exempt)?\n if !is_exempt(name)\n # Not exempt, apply sales tax\n tax += price * @@sales_tax\n else\n # Exempt, don't apply sales tax\n end\n\n # Is the item subject to import tax (ie. is it imported)?\n if is_imported(name)\n # Is imported, apply import sales tax\n tax += price * @@imported_goods_sales_tax\n else\n # Is not imported, don't apply import sales tax\n end\n\n final_taxed_price += round_point05(tax)\n\n puts final_taxed_price\n\n result += final_taxed_price # Add the final price to the running total\n end\n result\n end", "def total\n order.delivery_price +\n order.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end", "def calcuate_tax\n @price * 0.12\n end", "def grand_total_sans_tax\n (subtotal_sans_tax || 0.to_money) + adjustments_sans_tax\n end", "def total\n total_invoice_items_price(invoice_items)\n end", "def add_taxes(amt, good_tax, import_tax)\n amt += good_tax + import_tax\n amt.round(2)\n end", "def total_without_tax\n sub_total - tax_amount\n end", "def cumulative_total_before_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.price\n end#each\n return amount\nend", "def total_price\n line_items.to_a.sum { |item| item.total_price}\n end", "def total\n product_total = 0\n tax = 1.075\n @products.each do |product, price|\n product_total += price\n end\n order_total = (product_total * tax).round(2)\n return order_total\n end", "def delivery_tax_amount\n read_attribute(:delivery_tax_amount) ||\n delivery_price / BigDecimal(100) * delivery_tax_rate\n end", "def get_tax_rate(item)\n\t\ttax_rate = 0.0\n\t\ttax_rate = @goods_tax_rate unless item[:exempt]\n\t\ttax_rate = tax_rate + @imported_tax_rate if item[:import]\n\t\treturn tax_rate\n\tend", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n\t\tline_items.to_a.sum { |item| item.total_price }\n\tend", "def calculate_tax(item, price)\n tax = 0.0\n \n # if no words in the item match the exempt list\n if (Exempt - item.split(\" \")).length == Exempt.length\n tax += 0.10\n end\n\n # if imported, add 5% tax\n if item.split(\" \").include? 'imported'\n tax += 0.05\n end\n\n # round up to nearest .05 calculation\n item_tax = price.to_f * tax\n @tax_hash[item] = (item_tax * 20).ceil / 20.0\n end", "def total_price\n line_items.to_a.sum {|item| item.total_price}\n end", "def subtotal\n line_items.reduce(BigDecimal(\"0\")) { |result, item| result += item.amount }\n end", "def total\n total = 0\n line_items.each do |line_item|\n total += line_item.item.price * line_item.quantity\n end\n total\n end", "def total_price\n\t\tline_items.to_a.sum{|item| item.total_price}\n\tend", "def total_price\n line_items.map { |line_item| line_item.item.price * line_item.quantity }.sum\n end", "def compute_tax(item_price, tax_rate)\n item_price * tax_rate\n end", "def sub_total\n sum = 0\n line_items.each do |line_item|\n sum += line_item.total_price\n end\n sum\n end", "def apply_taxes(taxman)\n @taxes = BigDecimal.new(0)\n if @is_imported\n @taxes += taxman.apply_tax(@price, taxman.import_duty)\n end\n unless taxman.exempt_basic.include?(@type)\n @taxes += taxman.apply_tax(@price, taxman.sales_tax)\n end\n @price += @taxes\n end", "def gross_total_base\n net_total_base + tax_total_base\n end", "def calculate_invoice_total\n res = [ ]\n self.line_items.each do |item|\n res.push(item.qty * item.price)\n end\n # Return the sum of the items\n self.total = res.inject(:+) \n end", "def total_price\n self.line_items.each.sum {|li| li.total_price}\n end", "def calculate_totals\n subtotal = 0\n\n carted_products.each do |carted_product|\n subtotal += carted_product.subtotal\n end\n\n tax = subtotal * 0.09\n total = subtotal + tax\n update(subtotal: subtotal, tax: tax, total: total)\n end", "def total\n apply_rules(subtotal).round\n end", "def tax\n rate = 0.09\n tax_amount = (price.to_f * rate)\n return tax_amount\n end", "def cart_price_total_wtax\n price = 0\n tax = 2.99\n CartProduct.all.each do |cart_product|\n if cart_product.user_id == logged_in\n if product = get_product_by_id(cart_product.product_id)\n price += (product.price * cart_product.quantity) \n end\n end\n end\n return price + tax\n end", "def item_total\n line_items.map(&:total).reduce(:+)\n end" ]
[ "0.91519034", "0.90613794", "0.903708", "0.89413226", "0.89005405", "0.8607375", "0.81528765", "0.8117022", "0.80188704", "0.7996691", "0.79483753", "0.7921185", "0.7885601", "0.78657436", "0.7857986", "0.7809498", "0.78011584", "0.7796635", "0.7780616", "0.77156", "0.76952803", "0.7651033", "0.763869", "0.7622238", "0.75697684", "0.7549459", "0.7511414", "0.7509934", "0.74987155", "0.7476334", "0.7447949", "0.74385434", "0.74123394", "0.7395151", "0.7365953", "0.7346783", "0.72891724", "0.72395533", "0.72344923", "0.72273344", "0.71917397", "0.7183613", "0.71769655", "0.71765774", "0.71705025", "0.71589357", "0.71379036", "0.7119547", "0.71144074", "0.71015733", "0.70977056", "0.70874816", "0.7086891", "0.70745784", "0.7046684", "0.7041498", "0.7030492", "0.70276445", "0.70269346", "0.7013268", "0.7010622", "0.70039356", "0.69966614", "0.6992476", "0.69747907", "0.6968804", "0.69563854", "0.6950342", "0.6947941", "0.69446003", "0.69348365", "0.6922108", "0.69149476", "0.6902725", "0.6894821", "0.6891786", "0.6874192", "0.68621814", "0.6858867", "0.6858867", "0.6858867", "0.6858867", "0.68400794", "0.6836727", "0.680041", "0.6797192", "0.67956376", "0.6786632", "0.67646474", "0.67278075", "0.6703765", "0.6678794", "0.66756964", "0.6662229", "0.66485554", "0.6639447", "0.6636485", "0.66362906", "0.66345304", "0.6633748" ]
0.90230715
3
Calculate the toal as sub_total + total_tax.
def total total_cache(:total) || (sub_total + total_tax) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total\n subtotal\n # + tax\n end", "def calc_total\n (@total_after_tax * @gratuity) + @total_after_tax\n end", "def total_before_tax\n self.delivery_price + self.items_sub_total\n end", "def sub_total\n (self.subtotal + self.taxes + self.shipping_cost)\n end", "def total_without_tax\n sub_total - tax_amount\n end", "def total_before_tax\n order.delivery_price + items_sub_total\n end", "def total\n subtotal + tax + shipping\n end", "def calculate_total_price_and_taxes\n # find the tax rate\n tax_rate_percent = 0\n\n unless is_exempt_from_regular_tax?\n tax_rate_percent += REGULAR_TAX_PERCENT\n end\n\n unless self.is_exempt_from_import_tax?\n tax_rate_percent += IMPORT_TAX_PERCENT\n end\n\n # np/100\n # total tax needs to be a float rounded to nearest .05\n @total_tax = SalesTaxes::Item.round_properly((self.price * tax_rate_percent)/100)\n\n @total_price = (@price + @total_tax)\n end", "def total_tax\n unit_tax * quantity\n end", "def total\n cost_without_tax = get_cost_without_tax\n return cost_without_tax + get_sales_tax(cost_without_tax)\n end", "def tax_total\n self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }\n self.tax_amount\n end", "def tax_total\n self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end", "def grand_total_sans_tax\n (subtotal_sans_tax || 0.to_money) + adjustments_sans_tax\n end", "def calculate_tax_for(total)\n if self.vat_rate.present? && self.vat_rate != 0.0\n ((self.vat_rate / 100) * total)\n else\n 0\n end\n end", "def total_tax\n total_cache(:total_tax) || sum_line_items(line_items, :tax_amount)\n end", "def total_tax\n line_items.reduce(Money.zero) { |a, e| a + e.total_tax }\n end", "def tax\n if defined?(tax_rate)\n calculated = subtotal * tax_rate\n return 0 if calculated < 0\n calculated\n else\n 0\n end\n end", "def tax_total\n self.tax_amount = line_items.inject(Money.new(0, self.currency || Money.default_currency)) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end", "def total\n apply_rules(subtotal).round\n end", "def total_with_tax\n total = 0\n @cart_items.each do |item|\n total += item.total_price\n end\n return total\n end", "def calculate_totals\n subtotal_collector = 0\n active_contracts.each do |active_contract|\n subtotal_collector += active_contract.subtotal\n end\n\n self.subtotal = subtotal_collector\n self.tax = subtotal * 0.09\n self.total = subtotal + tax\n save\n end", "def tax_total\n self.tax_amount = line_items.inject(::Money.new(0, self.currency || ::Money.default_currency.iso_code)) {|sum,line| sum + line.tax_amount}\n self.tax_amount\n end", "def total\n @total ||= ((shipping_amount * subtotal).to_f/100) + subtotal + promotion_amount.to_i\n end", "def total\n sub_total\n end", "def total_amount_inc_tax\n unit_amount_inc_tax * quantity\n end", "def calcuate_tax\n @price * 0.12\n end", "def line_item_sales_tax_total\n\n ((pre_tax_total * 20).ceil.to_f / 20.0).round(2)\n end", "def calculate_tax\n if self.vendor.net_prices\n # this is for the US tax system. At this point, total is still net.\n self.tax_amount = self.total * self.tax / 100.0\n # here, total becomes gross\n self.total += tax_amount\n else\n # this is for the Europe tax system. self.total is already gross, so we don't have to modify it here.\n self.tax_amount = self.total * ( 1 - 1 / ( 1 + self.tax / 100.0 ) )\n end\n end", "def tax\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.tax_amount }\n end", "def total_price\n (@base_price * @tax_rate + @base_price) * @quantity\n end", "def total\n order_total + delivery_price + (prices_include_tax ? 0 : tax_amount)\n end", "def sub_total\n total_cache(:sub_total) || sum_line_items(line_items, :line_amount)\n end", "def total\n regular_total = sub_total\n if used_promo\n regular_total -= discount_from_promo\n end\n regular_total >= 0 ? (\"%.2f\" % regular_total).to_f : 0.0 \n end", "def tax\n order.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.tax_amount }\n end", "def gross_total_base\n net_total_base + tax_total_base\n end", "def total_price(tax_rate)\n ((1 + tax_percentage(tax_rate)) * price)\n end", "def total\n total_cost = 0\n \n # Summing up the product cost\n @products.each do |item, cost|\n total_cost += cost\n end\n \n # Calculate a 7.5% tax\n total_order_cost = total_cost * 1.075\n \n # Rounding the result to two decimal places\n return total_order_cost.round(2)\n end", "def sub_total\n # quantity * unit_price\n unit_price\n end", "def final_bill\n total + tax + @tip_amount\n end", "def calculate_taxes\n\t\ttax = 0\n\t\t\n\t\tif self.sku.contains_merch?\n\t\t\t# because paypal orders will not have billing addresses, just set \n\t\t\t# billing == to shipping if billing_address is nil\n\t\t\tself.billing_address ||= self.shipping_address \n\t\t\t\n\t\t\ttax = (self.sku.price * self.tax_rate * self.sku_quantity).round if self.billing_address.state == self.nexus\n\t\tend\n\t\t\n\t\tself.tax_amount = tax\n\t\t\n\tend", "def tax_calc\n tax = @quantity * @price * @taxe\n end", "def calculate_total\n sub_total = 0\n\n if size\n sub_total += Config.booths[size][:price]\n end\n\n self.add_ons.each do |add_on|\n sub_total += add_on.total\n end\n sub_total += industries.length * 35000\n sub_total += fees.pluck(:amount).reduce(0, &:+)\n\n self.total = sub_total\n self.balance = total - payments.paid.map(&:amount_paid).reduce(0, &:+)\n self\n end", "def invoice_tax(taxable_sub_total)\n ZipCodeTax.invoice_tax(zip_code_5_digit, taxable_sub_total)\n end", "def subtotal\n subtotal = purse.price * quantity\n end", "def subtotal\n self.cost_per_pound * self.order_quantity\n end", "def subtotal1\n @subtotal1 = @uomd + @clean\n end", "def subtotal\n fees = [ticket_fees_in_cents].sum\n\n discounted_total + fees\n end", "def calculate_total_for_tax(invoice, tax_rate)\n total_amount = total_tax_amount = 0\n\n components = invoice.\n all_items.\n flatten.\n select { |component| component.tax_rate == tax_rate }\n\n components.each do |component|\n total_amount += component.price\n total_tax_amount += component.calculate_tax\n end\n\n [total_amount, total_tax_amount]\n end", "def obvious_total(subtotal:, tax:, discount:)\r\n subtotal + tax - discount\r\nend", "def calculate_totals\n subtotal = 0\n\n carted_products.each do |carted_product|\n subtotal += carted_product.subtotal\n end\n\n tax = subtotal * 0.09\n total = subtotal + tax\n update(subtotal: subtotal, tax: tax, total: total)\n end", "def subtotal\r\n\t\t@items.inject(0.0) { |sum, i| sum + i.total_unit_price * i.quantity }\r\n\tend", "def total_before_tax\n total = 0\n @cart_items.each do |item|\n total += item.price\n end\n return total\n end", "def unit_amount_inc_tax\n unit_amount + unit_tax\n end", "def subtotal\n subtotal = (self.quantity) * (self.product.price)\n return subtotal.round(2)\n end", "def calculate current_tax_rate, delivery_price=nil\n delivery = delivery_price.nil? ? (delivery.try(:price) || 0) : delivery_price\n subtotal = (total_price + delivery)\n tax = subtotal * current_tax_rate\n return {\n subtotal: subtotal,\n tax: tax,\n delivery: delivery,\n total: subtotal + tax\n }\n end", "def sub_total\n return ApplicationHelper.round_currency(self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price })\n end", "def taxes\n calculation = BigDecimal.new(\"0\")\n absolutely_priced? ? base_price = sales_price : base_price = gross_price\n calculation = ( (base_price - rebate) / BigDecimal.new(\"100.0\")) * tax_class.percentage\n end", "def total\n \tsubtotal\n end", "def subtotal_sub\n itemis.collect{|itemi| itemi.valid? ? itemi.unit_price*itemi.quantity_quantity : 0}.sum\n end", "def tax_amount\n self.quantity * single_item_tax\n end", "def get_subtotal\n if is_a_review?\n user_visibility = :peer_visible\n else\n user_visibility = :ta_visible\n end\n Result.get_subtotals([self.id], user_visibility: user_visibility)[self.id]\n end", "def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end", "def gross_total\n self.gross_amount = self.net_total + self.tax_total\n end", "def items_sub_total\n order_items.inject(BigDecimal(0)) { |t, i| t + i.sub_total }\n end", "def items_sub_total\n order_items.inject(BigDecimal(0)) { |t, i| t + i.sub_total }\n end", "def sub_total\n sum = 0\n line_items.each do |line_item|\n sum += line_item.total_price\n end\n sum\n end", "def total\n self.delivery_price +\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end", "def subtotal\n return items.inject(0) {|total, item| total + item.subtotal}\n end", "def sales_tax\n total_tax_percent = 0\n if Tax.sales_tax_applicable?(@item)\n total_tax_percent += Tax.sales_tax_amount\n end\n if Tax.import_duty_applicable?(@item)\n total_tax_percent += Tax.import_tax_amount\n end\n total_tax_percent.round(2)\n end", "def total_amount\n t = amount\n t += sub_transactions.sum(:amount) if recurring_period\n t\n end", "def add_taxes(amt, good_tax, import_tax)\n amt += good_tax + import_tax\n amt.round(2)\n end", "def tax_reduction\n if has_rebate?\n previous_taxes = taxes\n previous_gross_price = gross_price + rebate\n rebate_in_percent_of_gross = (BigDecimal.new(\"100.0\") / previous_gross_price) * rebate\n tax_reduction = (previous_taxes / BigDecimal.new(\"100.0\")) * rebate_in_percent_of_gross\n else\n tax_reduction = BigDecimal.new(\"0.0\")\n end\n return tax_reduction\n end", "def gross_total\n self.gross_amount = self.net_total + self.tax_total\n end", "def sales_tax\n return (@listOfItem.inject(0){|sum,e| sum += \n e.product != nil ? e.product.sales_tax + e.product.import_tax : 0 }).round_to(2)\n end", "def total\n product_total = 0\n tax = 1.075\n @products.each do |product, price|\n product_total += price\n end\n order_total = (product_total * tax).round(2)\n return order_total\n end", "def subtotal\n order_items.collect{|order_item| order_item.valid? ? order_item.price.to_d * order_item.quantity.to_i : 0}.sum\n end", "def total\n total = 0.00\n #accesses the subtotal of each of the order items\n order_items.each do |item|\n total += item.subtotal\n end\n return total.round(2)\n end", "def line_total\n (@quantity * @price + line_item_sales_tax_total).round(2)\n end", "def total\n order.delivery_price +\n order.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end", "def calculate_price\n result = 0.0\n @items.each do |item|\n name = item.name\n price = item.price\n final_taxed_price = price # Begin with price and add tax as necessary\n tax = 0.0\n\n # Is the item subject to sales tax (ie. not exempt)?\n if !is_exempt(name)\n # Not exempt, apply sales tax\n tax += price * @@sales_tax\n else\n # Exempt, don't apply sales tax\n end\n\n # Is the item subject to import tax (ie. is it imported)?\n if is_imported(name)\n # Is imported, apply import sales tax\n tax += price * @@imported_goods_sales_tax\n else\n # Is not imported, don't apply import sales tax\n end\n\n final_taxed_price += round_point05(tax)\n\n puts final_taxed_price\n\n result += final_taxed_price # Add the final price to the running total\n end\n result\n end", "def subtotal\n @items.sum { |item| item.subtotal }\n end", "def tax_total\n send(:tax_amount) if respond_to?(:tax_amount)\n end", "def subtotal\n order_items.collect { |oi| oi.valid? ? (oi.quantity * oi.unit_price) : 0 }.sum\n end", "def total\n total_price = 0.0\n cart.line_items.each do |line_item|\n if !line_item.unit_price.blank?\n total_price += line_item.unit_price.to_f\n if line_item.line_item_options\n line_item.line_item_options.each do |line_item_option|\n total_price += line_item_option.price.to_f\n end\n end\n elsif line_item.menu_section_item\n total_price += line_item.menu_section_item.price.to_f\n if line_item.menu_item_options\n line_item.menu_item_options.each do |menu_item_option|\n total_price += menu_item_option.price.to_f\n end\n end\n else\n total_price += 0\n end\n end\n tax = total_price.to_f * 0.0825\n total_price = total_price + tax\n if tip\n total_price = total_price.to_f + tip.to_f\n end\n return total_price\n end", "def subtotal3\n @subtotal3 = @subtotal2 + @cafm + @helpdesk\n end", "def calculate\n product.taxes&.map { |tax| tax_portion(tax) }.sum.to_f || 0\n end", "def tax_amount\n self[:tax_amount] || (application_fee * tax_rate / 100)\n end", "def test_credit_note_sub_total_calculation2\n credit_note = create_test_credit_note\n line_item = credit_note.line_items.first\n\n # Make sure that everything adds up to begin with.\n expected_total_tax = credit_note.line_items.inject(BigDecimal('0')) { | sum, l | l.tax_amount }\n assert_equal(expected_total_tax, credit_note.total_tax)\n\n # Change the tax_amount of the first line item and make sure that\n # everything still continues to add up.\n line_item.tax_amount = line_item.tax_amount + 10\n assert_not_equal(expected_total_tax, credit_note.total_tax)\n expected_total_tax = credit_note.line_items.inject(BigDecimal('0')) { | sum, l | l.tax_amount }\n assert_equal(expected_total_tax, credit_note.total_tax)\n end", "def subtotal\n line_items.reduce(BigDecimal(\"0\")) { |result, item| result += item.amount }\n end", "def sub_total_price\n line_items.inject(0) {|sum, item| sum += item.price * item.qty }\n end", "def full_price\n\t\t\t\t@aftertax = @baseprice * @taxrate\n\t\tend", "def cumulative_total_after_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.total\n end#each\n return amount\nend", "def calculate_total_2(info)\n tip_amt = info[:price] * info[:tip]\n tax_amt = info[:price] * info[:tax]\n info[:price] + tip_amt + tax_amt\nend", "def subtotal2\n @subtotal2 = @subtotal1 + @variance\n end", "def billing_amount\n self.net_amount + self.taxes_amount\n end", "def billing_amount\n self.net_amount + self.taxes_amount\n end", "def amount\n estimate_total = self.estimate_line_items.sum(:amount)\n if self.tax_inclusive? \n tax_total = 0 \n else\n tax_total = 0 \n tax_line_items.each do |line_item|\n tax_account = line_item.account\n next if (tax_account.accountable_type=='DutiesAndTaxesAccounts' && tax_account.accountable.calculation_method==4 && tax_account.accountable.split_tax == 0) \n tax_total += line_item.amount\n end\n end\n ship_charge = self.shipping_line_items.sum(:amount)\n estimate_total + tax_total + ship_charge\n end", "def subtotal\n precio * cantidad\n end", "def calculate\n=begin\n self.net_amount = nil\n self.tax_amount = nil\n self.gross_amount = nil\n=end\n self.total\n end", "def total_taxes\n @total_taxes = 0\n @list.each do |item, quantity|\n @total_taxes += quantity * item.taxes\n end\n puts \"Sales Taxes: #{MONEY_FORMAT % @total_taxes}\"\n end" ]
[ "0.8092417", "0.79347134", "0.78405243", "0.78202415", "0.77440614", "0.7682706", "0.762453", "0.74780154", "0.74429786", "0.7405017", "0.73900545", "0.7373795", "0.7368895", "0.73362714", "0.73166233", "0.7277744", "0.7270196", "0.7263673", "0.7220909", "0.71075124", "0.7106332", "0.7101156", "0.70932966", "0.7084329", "0.7074252", "0.70584095", "0.7040136", "0.70272946", "0.7018946", "0.7012237", "0.6994107", "0.6993931", "0.6991735", "0.69893193", "0.695498", "0.693045", "0.69129455", "0.69075054", "0.6896956", "0.6893342", "0.6892652", "0.6889483", "0.68798524", "0.6862295", "0.68547356", "0.6849063", "0.6831335", "0.6829353", "0.68269867", "0.68033457", "0.6799121", "0.6776021", "0.677197", "0.67532814", "0.6730339", "0.6723529", "0.6710363", "0.67059857", "0.6693997", "0.6687459", "0.6671069", "0.66697496", "0.66629523", "0.66567737", "0.66567737", "0.6654486", "0.664309", "0.66257596", "0.6625415", "0.6614694", "0.6611131", "0.6591506", "0.6590684", "0.65883905", "0.6583916", "0.658137", "0.6561064", "0.6557211", "0.65367377", "0.65307534", "0.65292686", "0.65287787", "0.65236896", "0.65234274", "0.65207934", "0.65151656", "0.6505003", "0.649309", "0.6485736", "0.6482003", "0.6480728", "0.647704", "0.647619", "0.64657986", "0.64616615", "0.64616615", "0.6460321", "0.6442337", "0.64394426", "0.6433516" ]
0.7670291
6
If a templating language other than ERB is specified, add the relevant gem to the Gemfile.
def add_view_language_gem return if view_language == "erb" add_gems %(gem "#{view_language}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_linter_gems(engine)\n return '' if engine.blank?\n\n case engine.to_s\n when 'haml'\n \"gem 'haml_lint'#{gemfile_requirement('haml_lint')}, require: false\"\n when 'slim'\n \"gem 'slim_lint'#{gemfile_requirement('slim_lint')}, require: false\"\n else\n \"gem 'erb_lint', github: 'Shopify/erb-lint', require: false\"\n end\n end", "def gems_for_template_engine(template_engine)\n gems = ''\n if template_engine != :erb\n if template_engine.in?(:haml, :builder)\n template_engine_plugin = \"merb-#{template_engine}\"\n else\n template_engine_plugin = \"merb_#{template_engine}\"\n end\n gems = %Q{gem \"#{template_engine_plugin}\"}\n end\n gems\n end", "def replace_gemfile\n # Gemfile template needs to be 'Gemfile.erb' otherwise it attempts to fetch Gemfile template from the Rails gem\n # https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/Gemfile.tt#L9\n template 'Gemfile.erb', 'Gemfile', force: true\n end", "def gems_for_template_engine(template_engine)\n gems = ''\n if template_engine != :erb\n if [:haml, :builder].include? template_engine\n template_engine_plugin = \"merb-#{template_engine}\"\n else\n template_engine_plugin = \"merb_#{template_engine}\"\n end\n gems = %Q{gem \"#{template_engine_plugin}\"}\n end\n gems\n end", "def gem(gem_name, *version_requirements)\n if gem_name =='i18n'\n puts \"skipping loading the i18n gem ...\"\n return\n end\n super(gem_name, *version_requirements)\nend", "def template_engine_gem_str(css_framework = '')\n case css_framework.to_s\n when 'semantic'\n 'semantic_ui'\n else\n 'bootstrap'\n end\nend", "def add_gemfile\n copy_file 'static/dry/Gemfile.default', \"#{name}/Gemfile\"\n say 'Add Gemfile', :green\n end", "def enhance_gemfile\n gem_lines = File.readlines('Gemfile').select{ |line| line =~ /^gem/ }\n @original_gems = gem_lines.reject do |line|\n line =~ /'(#{ SKIP_GEMS.join '|' })'/\n end\n\n template 'Gemfile', force: true\n end", "def require_engine\n return if defined? ::RagTag\n require_library 'ragtag'\n end", "def template_engine\n @template_engine ||= :erb\n end", "def apply_rails_new_template\n assert_generator_use_postgresql\n skip_libraries_installation\n\n apply_template 'LICENSE'\n apply_template 'README.md'\n apply_template 'gitignore', '.gitignore'\n\n apply_template 'ruby-version', '.ruby-version'\n apply_template 'Gemfile'\n\n apply_template 'env.example'\n apply_template 'env.example', '.env'\n\n run_with_clean_bundler_env 'bundle install'\n run_with_clean_bundler_env 'bin/rails webpacker:install:typescript'\n\n apply_template 'docker-compose.yml'\n run_with_clean_bundler_env 'docker-compose up -d'\n\n apply_file 'config/database.yml'\n run_with_clean_bundler_env 'bin/rails db:create'\n\n run_with_clean_bundler_env 'bin/rails generate rspec:install'\n\n setup_git\n\n setup_heroku\nend", "def require_engine\n return if defined?(::RDoc::Markup)\n require 'rubygems' # hack\n gem 'rdoc', '> 3'\n require_library 'rdoc'\n #require_library 'rdoc/markup'\n #require_library 'rdoc/markup/to_html'\n end", "def platform_gems\n array = package_config[:gemfile]\n return [] if array.blank?\n path = vendor? ? \"./#{vendor_path}/vendor\" : source_vendor_path\n new_erb.erb_array(array, vendor_path: path)\n end", "def template_engine\n te = options[:template_engine].try(:to_s).try(:downcase) || 'erb'\n if te == \"haml\"\n return \"haml\"\n else\n return \"erb\"\n end\n end", "def initialize_engine\n require_template_library 'haml_coffee'\n end", "def load_eruby(name)\n if name.nil? || !['erb', 'erubis'].include?(name)\n name = 'erb'\n end\n\n if name == 'erb'\n Helpers.require_library 'erb'\n ::ERB\n elsif name == 'erubis'\n Helpers.require_library 'erubis', true\n ::Erubis::FastEruby\n end\n end", "def initialize_engine\n require_template_library 'haml_coffee_assets/compiler'\n end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def gemspec?; end", "def after_configuration\n markdown_exts = %w(markdown mdown md mkd mkdn)\n\n begin\n # Look for the user's preferred engine\n if app.config[:markdown_engine] == :redcarpet\n require 'middleman-core/renderers/redcarpet'\n ::Tilt.prefer(::Middleman::Renderers::RedcarpetTemplate, *markdown_exts)\n elsif app.config[:markdown_engine] == :kramdown\n require 'middleman-core/renderers/kramdown'\n ::Tilt.prefer(::Middleman::Renderers::KramdownTemplate, *markdown_exts)\n elsif app.config[:markdown_engine]\n # Map symbols to classes\n markdown_engine_klass = if app.config[:markdown_engine].is_a? Symbol\n engine = app.config[:markdown_engine].to_s\n engine = engine == 'rdiscount' ? 'RDiscount' : engine.camelize\n app.config[:markdown_engine_prefix].const_get(\"#{engine}Template\")\n else\n app.config[:markdown_engine_prefix]\n end\n\n # Tell tilt to use that engine\n ::Tilt.prefer(markdown_engine_klass, *markdown_exts)\n end\n rescue LoadError\n # If they just left it at the default engine and don't happen to have it,\n # then they're using middleman-core bare and we shouldn't bother them.\n if app.config.setting(:markdown_engine).value_set?\n logger.warn \"Requested Markdown engine (#{app.config[:markdown_engine]}) not found. Maybe the gem needs to be installed and required?\"\n end\n end\n end", "def load_template\n\t\traw = IO.read( __FILE__ ).split( /^__END__$/m, 2 ).last\n\t\treturn ERB.new( raw, nil, '<%>' )\n\tend", "def load_erb(erb)\n # @tmpl = ERB.new(erb)\n @tmpl = ERB.new(erb,0,\"<>\")\n end", "def verify_haml_existence\n begin\n require 'haml'\n rescue LoadError\n say \"HAML is not installed, or it is not specified in your Gemfile.\"\n exit\n end\n end", "def add_gems\n gem 'sorbet-rails', path: '../../../.'\n\n sorbet_version = ENV[\"SORBET_VERSION\"]\n if sorbet_version\n # mostly used to test against a stable version of Sorbet in Travis.\n gem 'sorbet', sorbet_version\n gem 'sorbet-runtime', sorbet_version\n else\n # prefer to test against latest version because sorbet is updated frequently\n gem 'sorbet'\n gem 'sorbet-runtime'\n end\nend", "def add_template(filepath)\n # templates must be strings for ERB\n @template = File.read(filepath)\n end", "def create_plugin_gemspec\n template(\"extension.gemspec\",\n \"#{extension_name}/#{extension_name}.gemspec\")\n end", "def initialize_engine\n require_template_library 'ejs'\n end", "def gemspec_helper; end", "def gemspec_helper; end", "def gemspec_helper; end", "def gemspec_helper; end", "def gemspec_helper; end", "def gemspec_helper; end", "def gem(name, requirement = nil)\n gems << Gem.new(name, requirement)\n end", "def text_helper\n gem 'actionpack'\n require 'action_controller' # bringing this in for autolinks\n helper = Object.new\n helper.extend ActionView::Helpers::TextHelper\n helper.extend ActionView::Helpers::TagHelper\n helper\nend", "def default_template_file\n File.join(__dir__, '..', '..', '..', '..', '..', 'vendor', 'AdditionalConfiguration.php.erb')\n end", "def find_template(views, name, engine, &block)\n I18n.fallbacks[I18n.locale].each { |locale|\n super(views, \"#{name}.#{locale}\", engine, &block) }\n super(views, name, engine, &block)\n end", "def templated_build(name, opts={})\n short = name.downcase\n source = File.join(\"wrappers\", short)\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\n\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\n\n desc \"Package for #{name}\"\n task short.to_sym => dependencies do\n puts \"Packaging for #{name}\"\n\n mkdir_p opts[:location] if opts[:location]\n\n files = [\n \"#{source}/mustache.js.pre\",\n 'mustache.js',\n \"#{source}/mustache.js.post\"\n ]\n\n open(\"#{opts[:location] || '.'}/#{target_js}\", 'w') do |f|\n files.each {|file| f << File.read(file) }\n end\n\n puts \"Done, see #{opts[:location] || '.'}/#{target_js}\"\n end\nend", "def custom_gem(name, options = Hash.new)\n local_path = File.expand_path(\"../../#{name}\", __FILE__)\n if ENV[\"USE_JSUS_CUSTOM_GEMS\"] && File.directory?(local_path)\n gem name, options.merge(:path => local_path).delete_if { |key, _| [:git, :branch].include?(key) }\n else\n gem name, options\n end\nend", "def templated_build(name, opts={})\r\n short = name.downcase\r\n source = File.join(\"wrappers\", short)\r\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\r\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\r\n\r\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\r\n\r\n desc \"Package for #{name}\"\r\n task short.to_sym => dependencies do\r\n puts \"Packaging for #{name}\"\r\n\r\n mkdir_p opts[:location] if opts[:location]\r\n\r\n files = [\r\n \"#{source}/mustache.js.pre\",\r\n 'mustache.js',\r\n \"#{source}/mustache.js.post\"\r\n ]\r\n\r\n open(\"#{opts[:location] || '.'}/#{target_js}\", 'w') do |f|\r\n files.each {|file| f << File.read(file) }\r\n end\r\n\r\n puts \"Done, see #{opts[:location] || '.'}/#{target_js}\"\r\n end\r\nend", "def resolve_template_engine(template_path)\n resolved_template_path = File.join(self.options.views, template_path.to_s + \".*\")\n template_file = Dir[resolved_template_path].first\n raise \"Template path '#{template_path}' could not be located in views!\" unless template_file\n template_engine = File.extname(template_file)[1..-1].to_sym\n end", "def add_javascript_dependencies\n gem 'bootstrap', options[:'bootstrap-version'].presence # in rails 7, only for stylesheets\n gem 'jquery-rails' if bootstrap_4? # Bootstrap 4 has a dependency on jquery\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 integration_gemfile(integration)\n \"BUNDLE_GEMFILE=#{integration_path(integration)}/Gemfile\"\nend", "def ruby?\n exist? 'Gemfile'\n end", "def custom_gem(name, options = Hash.new)\n local_path = File.expand_path \"../vendor/#{name}\", __FILE__\n\n if File.exist? local_path\n options = options.merge :path => local_path\n options.delete_if do |key, _|\n [:github, :branch].include? key\n end\n end\n\n gem name, options\nend", "def resolve_template_engine(template_path)\n resolved_template_path = File.join(self.options.views, template_path.to_s + \".*\")\n template_file = Dir[resolved_template_path].first\n raise \"Template path '#{template_path}' could not be located in views!\" unless template_file\n template_engine = File.extname(template_file)[1..-1].to_sym\n end", "def mailer_gems(mailer = 'sparkpost')\n if mailer.to_s == 'postmark'\n \"gem 'postmark-rails'\"\n else\n \"gem 'sparkpost_rails'\"\n end\n end", "def erb(file_name, template_name)\n template = ERB.new(File.open(template_name, \"r:UTF-8\", &:read), nil, \"-\")\n File.open(file_name, \"w:UTF-8\") { |file| file.write(template.result(binding)) }\nend", "def prep_template(language,frame_binding)\n\n template=@localized_templates[language]\n @language=language\n eval(\"@language='#{language}'\",frame_binding)\n \n unless template\n local_template_text=@raw_template.result(frame_binding)\n local_template_text=local_template_text.gsub(@ltag,\"<%\")\n local_template_text=local_template_text.gsub(@rtag,\"%>\")\n\n template=compile(local_template_text)\n @localized_templates[language]=template unless is_development?\n end\n template\n \n end", "def add_gem_paths; end", "def add_standard_bundler_tasks\n desc 'Install all dependencies for application if Gemfile present'\n command(:bundle_install) do\n rbenv_exec('bundle install') if File.exist?('Gemfile')\n end\n end", "def install_sample_files\n super\n inject_line_before root.join('apps/web/templates/application.html.erb'), '</head>', <<-HTML\n <%= vite_client %>\n <%= vite_javascript 'application' %>\n HTML\n end", "def gemfile_requirement(name)\n @original_gemfile ||= IO.read('Gemfile')\n req = @original_gemfile[/gem\\s+['\"]#{name}['\"]\\s*(,[><~= \\t\\d\\.\\w'\"]*)?.*$/, 1]\n req && req.tr(\"'\", %(\")).strip.sub(/^,\\s*\"/, ', \"')\nend", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemfile_requirement(name)\n @original_gemfile ||= IO.read('Gemfile')\n req = @original_gemfile[/gem\\s+['\"]#{name}['\"]\\s*(,[><~= \\t\\d\\.\\w'\"]*)?.*$/, 1]\n req && req.gsub(\"'\", %(\")).strip.sub(/^,\\s*\"/, ', \"')\nend", "def view_language\n options[:haml] ? 'haml' : 'erb'\n end", "def template_files path\n exts = template_engines.keys.map{|e| \".\" << e if e }.join(\",\")\n Dir[\"#{path}{#{exts}}\"]\n end", "def prefer(template_class, *extensions); end", "def find(name_or_path=nil)\n name_or_path ||= MB::Application.config.bootstrap.default_template\n return unless name_or_path\n installed = MB::FileSystem.templates.join(\"#{name_or_path}.erb\").to_s\n if File.exists?(installed)\n return installed\n end\n if File.exists?(name_or_path)\n return name_or_path\n else\n raise MB::BootstrapTemplateNotFound\n end\n end", "def initialize_engine\n require_template_library 'eco'\n end", "def setup_override\n spec = Gem::Specification.find_by_name 'yard'\n erb = File.join(spec.gem_dir,\"templates\",\"default\",\"fulldoc\",\"html\",ERB)\n # Create the subdirectory structure\n subdir = File.join(tmpdir,\"default\",\"fulldoc\",\"html\")\n FileUtils.mkdir_p subdir\n # Copy the erb\n target_file = File.join(subdir,ERB)\n FileUtils.cp(erb,target_file)\n # Open the file and add the anchors\n open(target_file,'a') do |file|\n file.write \"<% do_dash %>\\n\"\n end\n end", "def lockfile_contents\n @lockfile_contents || <<-EOF\nGEM\n remote: http://rubygems.org/\n specs:\n pg (0.11.0)\n rake (0.9.2.2)\n ey_config (0.0.1)\n\nPLATFORMS\n ruby\n\nDEPENDENCIES\n pg\n rake\n ey_config\n EOF\n end", "def my_render_erb erb, opts = {}\n if (path = erb_path_for(erb)).nil?\n log_error \"If you use #my_render_erb within a dynamically defined dep, you have to give the full path to the erb template.\"\n elsif !File.exists?(path) && !opts[:optional]\n log_error \"Couldn't find erb to render at #{path}.\"\n elsif File.exists?(path)\n # require 'erb'\n debug ERB.new(IO.read(path)).result(binding)\n shell(\"cat > #{opts[:to]}\",\n :input => ERB.new(IO.read(path)).result(binding),\n :sudo => opts[:sudo]\n ) do |result|\n if result\n log \"Rendered #{opts[:to]}.\"\n sudo \"chmod #{opts[:perms]} '#{opts[:to]}'\" unless opts[:perms].nil?\n else\n log_error \"Couldn't render #{opts[:to]}.\"\n end\n end\n end\nend", "def add_template_helper(mod)\n _helpers.module_eval { include mod }\n end", "def add_files_to_project\n # add/overwrite some files\n mkdir('config/init')\n mkdir_p('lib/tasks')\n cp_r(Dir.glob('../files/*'), '.')\n # gem changed the api in version 1.3.2, I think, at least it is changed\n # in version 1.3.4, so the following merb hack is necessary for merb\n # 1.0.11\n # TODO: this should be generically performed outside of the spec2merb script\n if Versionomy.parse(`gem --version`) < Versionomy.parse('1.3.4')\n raise Exception.new 'Please upgrade rubygems to at least 1.3.4 (sudo gem update --system)'\n end\n if File.exist?('tasks/merb.thor/gem_ext_4.rb')\n rm('tasks/merb.thor/gem_ext.rb') if File.exist?('tasks/merb.thor/gem_ext.rb')\n mv('tasks/merb.thor/gem_ext_4.rb', 'tasks/merb.thor/gem_ext.rb')\n end\n end", "def require_gems\n Jekyll::External.require_with_graceful_fail(\n site.gems.select { |plugin| plugin_allowed?(plugin) }\n )\n end", "def template_for_options(opts = {})\n type = opts[:template_type] || 'log'\n if opts[:\"template-raw\"]\n Support::RawERbTemplate.new(opts[:\"template-raw\"])\n elsif opts[:template].is_a?(Support::Template)\n opts[:template]\n else\n template = opts[:template]\n template = \"default-#{type}\" if template.nil? || template.to_s == \"default\"\n Support::Template['mercurial', template]\n end\n end", "def require_theme_deps; end", "def install_additional_packages\n <<~APT\n # Install app-specific Ubuntu packages\n RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y #{NL_TAB}#{@app.packages.join(\" #{NL_TAB}\")}\n APT\n end", "def template_extensions\n %w(mod dat)\n end", "def add_handlers\n template 'templates/dry/app.tt', \"#{name}/app.rb\"\n end", "def is_erb?(file)\n /\\.erb\\z/.match?(file)\n end", "def integrated\n File.exist?(gemfile)\n end", "def to_gemfile\n if @engine == :ruby\n \"ruby '#{ruby_version}'\"\n else\n \"ruby '#{ruby_version}', :engine => '#{engine}', :engine_version => '#{engine_version}'\"\n end\n end", "def require!\n super do\n gem @gem_name, @version if @version\n end\n end", "def load_html_template\n template = @options.template\n\n unless template =~ %r{/|\\\\} then\n template = File.join('rdoc', 'generator', @options.generator.key,\n template)\n end\n\n require template\n\n @template = self.class.const_get @options.template.upcase\n @options.template_class = @template\n\n rescue LoadError\n $stderr.puts \"Could not find HTML template '#{template}'\"\n exit 99\n end", "def resolve_ext(file_name)\n SUPPORTED_TEMPLATE_FORMATS.find { |ext| File.exists?(\"#{file_name}.#{ext}\") }\n end", "def gemfile(install = false, options = {}, &gemfile)\n require \"lic\"\n\n opts = options.dup\n ui = opts.delete(:ui) { Lic::UI::Shell.new }\n ui.level = \"silent\" if opts.delete(:quiet)\n raise ArgumentError, \"Unknown options: #{opts.keys.join(\", \")}\" unless opts.empty?\n\n old_root = Lic.method(:root)\n def Lic.root\n Lic::SharedHelpers.pwd.expand_path\n end\n Lic::SharedHelpers.set_env \"LIC_GEMFILE\", \"Gemfile\"\n\n Lic::Plugin.gemfile_install(&gemfile) if Lic.feature_flag.plugins?\n builder = Lic::Dsl.new\n builder.instance_eval(&gemfile)\n\n definition = builder.to_definition(nil, true)\n def definition.lock(*); end\n definition.validate_runtime!\n\n missing_specs = proc do\n definition.missing_specs?\n end\n\n Lic.ui = ui if install\n if install || missing_specs.call\n Lic.settings.temporary(:inline => true) do\n installer = Lic::Installer.install(Lic.root, definition, :system => true)\n installer.post_install_messages.each do |name, message|\n Lic.ui.info \"Post-install message from #{name}:\\n#{message}\"\n end\n end\n end\n\n runtime = Lic::Runtime.new(nil, definition)\n runtime.setup.require\nensure\n lic_module = class << Lic; self; end\n lic_module.send(:define_method, :root, old_root) if old_root\nend", "def compile_rails_template(template_file_name)\n template_content = read_template_content(template_file_name)\n if template_file_name[/\\.hbs\\.erb\\z/]\n compiled_rails_template = ERB.new(template_content).result\n elsif template_file_name[/\\.hamlbars\\z/]\n stub = ''\n compiled_rails_template = Haml::Engine.new(template_content).render(stub)\n end\n compiled_rails_template\n end", "def gemset_use!(name, options = {})\n gemset_use name, {:replace_env => true}.merge(options)\n end", "def setup_docker_compose\n template 'docker-compose.yml.tt', 'docker-compose.yml'\n end", "def python_packages\n PRE_INSTALLED_PYTHON_PACKAGES.join(\" #{NL_TAB}\")\n end", "def render_template(template, env)\n templates_dir = \"lib/search_engine/views\"\n template = \"#{template}.slim\" unless template.end_with? \".slim\"\n template_path = \"#{templates_dir}/#{template}\"\n content = File.read(template_path)\n Slim::Template.new { content }.render(env)\nend", "def load_module(m)\n load_template(\"http://github.com/meskyanichi/rails-templates/raw/master/modules/#{m}.rb\")\nend", "def add_vendor_files\n say_quietly \"Copying files...\"\n\n %w[auth backend frontend].each do |section|\n template \"vendor/assets/javascripts/archangel/#{section}.js\"\n template \"vendor/assets/stylesheets/archangel/#{section}.css\"\n end\n end", "def install\n ensure_development_dependency\n template('lib/versioned/version.rb.tt', \"lib/#{namespaced_path}/version.rb\")\n install_bundle\n template('CHANGELOG.md.tt', 'CHANGELOG.md')\n template('CONTRIBUTING.md.tt', 'CONTRIBUTING.md')\n template('RELEASING.md.tt', 'RELEASING.md')\n template('UPGRADING.md.tt', 'UPGRADING.md')\n setup_rspec\n end", "def erb(template, options = {}, locals = {})\n template = template.to_sym\n options[:layout] = options[:layout].present? ? options[:layout] : !request.xhr?\n \n super\n end" ]
[ "0.6434705", "0.62683153", "0.6247927", "0.62002105", "0.61389774", "0.57077384", "0.56590736", "0.5601729", "0.557176", "0.5535659", "0.5502187", "0.5473761", "0.54413515", "0.5350218", "0.52036774", "0.52022403", "0.5175113", "0.51533234", "0.51533234", "0.51533234", "0.51533234", "0.51533234", "0.51533234", "0.5085426", "0.50634235", "0.5001926", "0.49969846", "0.4981164", "0.49324962", "0.4909102", "0.49068004", "0.48890612", "0.48878834", "0.48878834", "0.48878834", "0.48878834", "0.48878834", "0.48878834", "0.4884674", "0.48823294", "0.48483682", "0.48335233", "0.4813891", "0.48074338", "0.48063996", "0.47878125", "0.47701293", "0.47679928", "0.47568136", "0.47500205", "0.47480866", "0.47466344", "0.47404695", "0.4739823", "0.47325465", "0.47185782", "0.47136182", "0.4711557", "0.47071624", "0.47008526", "0.47008526", "0.47008526", "0.47008526", "0.47008526", "0.47008526", "0.47008526", "0.47008526", "0.46936598", "0.46895015", "0.46812806", "0.46781084", "0.46675983", "0.46565768", "0.46495837", "0.46494696", "0.4647034", "0.46462795", "0.46444532", "0.46230987", "0.46215212", "0.46207446", "0.46197182", "0.4616995", "0.46166095", "0.46131477", "0.46102917", "0.4603614", "0.45863992", "0.45814475", "0.45796037", "0.45698717", "0.45684063", "0.45629364", "0.45621687", "0.4557776", "0.4555886", "0.45542866", "0.45490265", "0.45452783", "0.45411065" ]
0.7270648
0
Run the Views generator to produce views
def generate_views Views.new(cli: cli, app_path: app_path).generate end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_view \n \n return if skip_method(__method__)\n \n # build edit _form index new show\n \n ['_form','edit','new','index','show'].each do |file|\n \n \n template = File.read(template(\"rails/views/#{file}.html.erb\"))\n \n # need to use ERB for these templates\n text = ERB.new(template, nil, '-').result(binding)\n\n filename = \"#{file}.html.erb\"\n # #puts \"build Rails view\"\n \n path = namespaced_path(\"app/views\",\"#{plural_table_name}/\"+filename)\n puts \"build Rails #{file} view for #{model_name} in #{path}\"\n write_artifact(path,text)\n \n end\n \n # build the json views\n ['index','show'].each do |file|\n \n template = File.read(template(\"rails/views/#{file}.json.jbuilder\"))\n text = ERB.new(template, nil, '-').result(binding)\n \n filename = \"#{file}.json.jbuilder\"\n # #puts \"build Rails JSON view \"\n \n path = namespaced_path(\"app/views\",\"#{plural_table_name}/\"+filename)\n puts \"build Rails #{file} JSON view for #{model_name} in #{path}\"\n write_artifact(path,text)\n \n end\n \n end", "def create_analysis_views\n puts \"====================\"\n puts \"creating analysis views for #{self.name}\"\n puts \"====================\"\n\n run_analysis_views\n\n puts \"> done\"\n puts \"====================\"\n end", "def run()\n\t\tif Core::DEBUG\n\t\t\traise \"View #{self.class.name} can't be build because run method is not redefined.\"\t\t\n\t\tend\n\tend", "def generate_views\n target_views = VIEWS\n file_prefix = prefix.blank? ? '' : prefix.singularize.underscore + '_'\n target_views.each do |name|\n directory name, \"app/views/#{file_prefix}#{name}\"\n end\n end", "def generate_view_models\n file_name = class_name.underscore\n \n create_model class_name, file_name\n \n create_views file_name if options.views.present?\n end", "def run\n\t\tself.print_hosts # generate all the host_*.html files\n\t\tself.print_index # generate the index.html file\n\t\tself.print_vulns # generate all the vuln_*.html files\n\t\tself.print_vuln_overview # generate the vuln_overview.html file\n\tend", "def view\n\t `ruby #{File.dirname(__FILE__) + \"/viewer/viewer.rb\"}`\n end", "def process_pages\n bindings = {\n :name => @definition.get_name,\n :version => @definition.get_version\n }\n\n page = Calamum::DocGenerator.new(:view)\n @definition.resources.each do |methods|\n methods[1].each do |resource|\n bindings.merge!(:resource => resource)\n filename = \"#{resource.slug}.html\"\n page.save_template(filename, bindings)\n end\n end\n end", "def view; end", "def call\n load_view_class\n return <<-RUBY\n instance_vars = assigns.merge(local_assigns).inject({}) do |result, (name, value)|\n result.update(\"@\\#{name}\" => value)\n end\n view = #{view_class_name}.new(self, instance_vars) { |*names| yield(*names) }\n view.#{render_method}(#{template_source.inspect})\n RUBY\n end", "def assert_generated_views_for(name, *actions)\n actions.each do |action|\n assert_generated_file(\"app/views/#{name.to_s.underscore}/#{action}\") do |body|\n yield body if block_given?\n end\n end\n end", "def _view; end", "def create_analysis_tables_and_views\n puts \"====================\"\n puts \"creating analysis tables and views for #{self.name}\"\n puts \"====================\"\n\n run_analysis_tables\n run_analysis_views\n\n puts \"> done\"\n puts \"====================\"\n end", "def create_views file_name\n %W(list_item main_item).each do |view|\n create_file \"app/views/#{file_name.pluralize}/_#{view}.html.#{options.views.downcase}\", File.read(File.join(File.expand_path('../templates', __FILE__), \"/views/_empty.html.#{options.views.downcase}\"))\n end\n \n # Copy collection views.\n #\n %W(collection list pagination table).each do |view|\n create_file \"app/views/#{file_name.pluralize}/_#{view}.html.#{options.views.downcase}\", File.read(File.join(File.expand_path('../templates', __FILE__), \"/views/_#{view}.html.#{options.views.downcase}\"))\n end\n end", "def view\n end", "def generate\n # Ensure site is a directory\n FileUtils.mkdir_p site_path\n\n # If there is more than one language, then we need to create\n # multiple files, one for each language.\n if languages.size >= 1\n\n # Enter the most dastardly loop. \n # Create a View::Document with sections only containing the \n # specified language. \n languages.map do |language|\n document_views = documents.map do |document|\n document.sections = document.sections.map do |section|\n section.examples = section.examples.select {|ex| ex.language.blank? || ex.language == language }\n section\n end\n\n Views::Document.new document\n end\n\n # Use Mustache to create the file\n page = Page.new\n page.title = title\n page.logo = File.basename logo if logo\n page.documents = document_views\n\n File.open(\"#{site_path}/#{language.underscore}.html\", \"w\") do |file|\n file.puts page.render\n end\n end\n\n # copy the default language to the index and were done!\n FileUtils.cp \"#{site_path}/#{default.underscore}.html\", \"#{site_path}/index.html\"\n\n # There are no languages specified, so we can just create one page\n # using a collection of Document::View.\n else \n document_views = documents.map do |document|\n Views::Document.new document\n end\n\n page = Page.new\n page.title = title\n page.logo = File.basename logo if logo\n page.documents = document_views\n\n File.open(\"#{site_path}/index.html\", \"w\") do |file|\n file.puts page.render\n end\n end\n\n # Copy the logo if specified\n FileUtils.cp \"#{logo}\", \"#{site_path}/#{File.basename(logo)}\" if logo\n\n # Copy all the stylesheets into the static directory and that's it!\n resources_path = File.expand_path \"../resources\", __FILE__\n\n FileUtils.cp \"#{resources_path}/style.css\", \"#{site_path}/style.css\"\n FileUtils.cp \"#{resources_path}/syntax.css\", \"#{site_path}/syntax.css\"\n end", "def execute(view)\n self.view = view\n\n valid_translation? @translation_file\n prevent_overwrite! (@options)\n\n unless File.directory?(output_folder)\n FileUtils.mkdir_p(output_folder)\n end\n\n @generator = Mongify::Mongoid::Generator.new(@translation_file, output_folder)\n @generator.process\n\n output_success_message\n\n view.report_success\n end", "def render\n view = @view\n for command in @commands\n view.send( *command )\n end\n view\n end", "def add_views\n output \"I'm copying the default views into app/views/gem_displays for you.\", :magenta\n template \"index.html.haml\", \"app/views/gem_displays/index.html.haml\"\n template \"show.html.haml\", \"app/views/gem_displays/show.html.haml\"\n template \"_widget.html.haml\", \"app/views/gem_displays/_widget.html.haml\"\n end", "def render\r\n view = @view\r\n for command in @commands\r\n view.send(*command)\r\n end\r\n view\r\n end", "def rendered_views=(_arg0); end", "def generate_view(ignore_missing: false)\n return generated_content if generated_content.present?\n\n generate(ignore_missing: ignore_missing)\n rescue FphsException => e\n \"EXCEPTION: #{e}\"\n end", "def views(name = nil)\n raise NotImplementedError, \"views is an abstract method\"\n end", "def generate\n gen_app\n handle_public_index\n gen_file(\"config/routes.rb\", \"routes\")\n @app.goals.values.each_with_index { |goal, i| gen_goal(goal, i) }\n gen_misc\n self\n end", "def view()\n @view\n end", "def views(opts=OPTS, &block)\n tables_or_views('VIEW', opts, &block)\n end", "def construct_view()\n design_docs = [\"couchdb_views/content_views.json\"]\n design_docs.each { |design_doc|\n #Read the file\n content = File.read(Pathname.new(File.dirname(__FILE__) + \"/../../\" + design_doc).cleanpath)\n check_sum = generateCheckSum(content)\n \n #create the JSON\n design_doc_as_json = JSON.parse(content)\n design_doc_as_json[:content_hash] = check_sum\n \n #upload the JSON as a design document\n upsert_doc(@db, design_doc_as_json, design_doc_as_json, :content_hash, @log)\n }\n end", "def view_step(*view_name, &block)\n \n # Instantiate a ViewStep object if symbol or string received\n view_name.each do |name|\n \n step = WebFlow::ViewStep.new(name.to_s)\n \n # Register this step in the flow repository\n register name.to_s, step\n \n # Execute the config block\n step.instance_eval(&block) if block_given?\n \n end\n \n end", "def create_view(db)\n begin\n db.get('_design/todos')\n rescue RestClient::ResourceNotFound => nfe\n db.save_doc({\n \"_id\" => \"_design/todos\",\n :views => {\n :allTodos => {\n :reduce => \"_count\",\n :map => \"function(doc){if(doc.name != null){emit(doc.order,{name: doc.name})}}\"\n }\n }\n })\n end\n end", "def refresh_views\n database.views.each do |name, view|\n materialize(view)\n end\n end", "def run_scaffolds\n @file.each_pair do |class_name, spec|\n args = []\n args << class_name \n args += spec[\"fields\"].map do |field|\n \"#{field[\"name\"]}:#{field[\"type\"]}\"\n end\n args << '--timestamps'\n Rails::Generators.invoke \"rails:scaffold\", args\n end\n end", "def define\n desc \"setup couchdb views\"\n task :setup do\n unless ENV['COUCH']\n abort \"You must set COUCH environment variable!\"\n end\n\n @db = CouchRest.database!(ENV['COUCH'])\n\n begin\n @db.get(\"_design/tools\")\n rescue RestClient::ResourceNotFound\n @db.save_doc({\n \"_id\" => \"_design/tools\",\n :views => {\n :by_id => {\n :map => <<-JS.split.map(&:strip).join,\n function(doc) { if (doc.id) emit(doc.id, null); }\n JS\n :reduce => <<-JS.split.map(&:strip).join\n _count\n JS\n }\n }\n })\n end\n end\n end", "def generate_html_views\n selective_copy 'app/views/kublog/posts/*.html.erb'\n end", "def method_missing(sym, *args, &block)\n if matches = sym.to_s.match(/^.*(?=_view$)|view$/)\n return Tanuki::Loader.run_template(\n {},\n self,\n matches[0].to_sym,\n *args,\n &block\n )\n end\n super\n end", "def create_view(view, cspec)\n\tKernel.system(\"perl #{$scripts}/ct-mkview.pl -raw -name #{view} -dynamic -spec #{cspec}\")\n\treturn $? == 0\nend", "def app_generators; end", "def generate_html\n # the individual descriptions for files and classes\n gen_into(@files)\n gen_into(@classes)\n # and the index files\n gen_file_index\n gen_class_index\n gen_method_index\n gen_main_index\n\n # this method is defined in the template file\n write_extra_pages if defined? write_extra_pages\n end", "def copy_views\n case options[:template_engine].to_s\n when \"haml\"\n verify_haml_existence\n verify_haml_version\n create_and_copy_haml_views\n else\n directory \"app/views/regulate\", \"app/views/regulate\"\n end\n end", "def copy_view_files #do NOT change the name of this method \n # it must be overriding an existing one in a parent class\n base_path = File.join(\"app/views\", class_path, file_name)\n #binding.pry\n empty_directory base_path\n @actions = actions.nil? || actions.empty? ? %w(index new create edit update destroy) : actions\n @attr_cols = GeneratorUtils::attr_cols(table_name)\n @col_count = @attr_cols.count\n @col_count += 1 if @actions.include?(\"edit\")\n @col_count += 1 if @actions.include?(\"destroy\")\n @search_sort = options.search_sort?\n (@actions - %w(create update destroy)).each do |action|\n @action = action\n formats.each do |format|\n @path = File.join(base_path, filename_with_extensions(action, format))\n set_template(@action, @path)\n end\n end\n end", "def get_views()\n gen_config.views.map(&:name)\n end", "def views\n Views.new(connection).all\n end", "def update_views\n gauges_config = YAML.load_file(\"#{CACHE_DIR_PATH}/config\")\n views = load_views\n last_run = gauges_config[:last_run] || gauges_config[:signup_date]\n yesterday = Date.today - 1\n\n if last_run.nil?\n views = fetch_views(views, yesterday, gauges_config[:token])\n elsif last_run && last_run != Date.today\n for date in last_run..yesterday do\n views = fetch_views(views, date, gauges_config[:token])\n end\n end\n\n cache_views(views)\n update_last_run(gauges_config)\n end", "def index\n @views = View.all\n end", "def index\n @views = @project.views.all\n end", "def view\n @_view\n end", "def run\n parse_options\n Calamum::Config.apply(config)\n @definition = Calamum::DocParser.new(load_source)\n @definition.load_resources\n Calamum::DocGenerator.init_base_dir\n process_index\n\n if config[:template] == 'twitter'\n process_pages\n process_section(\"overview\", @definition.get_description)\n process_section(\"authentication\", @definition.get_authentication)\n process_errors\n end\n rescue => ex\n puts_error ex.message\n end", "def compile!(view); end", "def start_view(view)\n\treturn true if File.directory?(view_dir(view))\n\tKernel.system(\"cleartool startview #{view} > nul 2>&1\")\n\treturn $? == 0\nend", "def make_render_in_view exp\n make_render exp, true\n end", "def load_views!\n new = YAML.load ERB.new(\n Pathname.new(__FILE__).dirname.join('..', 'config', 'views.yml').read\n ).result\n\n id = new['_id']\n old = database.get id\n\n if old['version'].to_i < new['version'].to_i\n log \"Upgrading Design Document #{id} to v#{new['version']}\"\n database.delete_doc old\n database.save_doc new\n end\n\n rescue RestClient::ResourceNotFound\n log \"Creating Design Document #{id} v#{new['version']}\"\n database.save_doc new\n end", "def erb_app(view, options = {})\n options = {:layout => '<%= yield %>', :url => '/tests' }.merge(options)\n get options[:url], :view => view, :layout => options[:layout], :engine => :erb \n end", "def define_view\n \t#puts \"#{controller_name}.define_view:begin view=#{@myparams[:view_id]}\"\n \t# views: liste des vues possibles est utilisee dans la view ruby show\n\t\t@views = View.all\n\t\t# view_id: id de la vue selectionnee est utilisee dans la view ruby show\n\t\t#@myparams[:view_id] = @views.first.id if @myparams[:view_id].nil?\n\t\tif @myparams[:view_id].nil?\n\t\t\tif logged_in?\n\t\t\t@myparams[:view_id] = current_user.get_default_view.id\n\t\t\tend\n\t\tend\n\t\t#puts \"#{controller_name}.define_view:end view=#{@myparams[:view_id]}\"\n\tend", "def init(context={})\n\n app = context[:app]\n \n # View models\n ::Model::ViewModel.new(:content, 'content', ContentManagerSystem::Content, :view_template_contents,\n [::Model::ViewModelField.new(:_id, 'id', :string),\n ::Model::ViewModelField.new(:title, 'title', :string),\n ::Model::ViewModelField.new(:path, 'path', :string),\n ::Model::ViewModelField.new(:alias, 'alias', :string),\n ::Model::ViewModelField.new(:summary, 'summary', :string),\n ::Model::ViewModelField.new(:type, 'type', :string),\n ::Model::ViewModelField.new(:creation_date, 'creation_date', :date),\n ::Model::ViewModelField.new(:creation_user, 'creation_user', :string)])\n \n ::Model::ViewModel.new(:term, 'term', ContentManagerSystem::Term, :view_template_terms,\n [::Model::ViewModelField.new(:id, 'id', :serial),\n ::Model::ViewModelField.new(:description, 'description', :string)])\n\n ::Model::ViewModel.new(:profile, 'profile', Users::Profile, :view_template_profiles,[]) \n\n # View renders \n teaser_preprocessor = Proc.new do |data, context, render_options|\n data.map { |element| CMSRenders::Factory.get_render(element, context, 'teaser').render({}, [:ignore_complements, :ignore_blocks]) }\n end\n\n slider_preprocessor = Proc.new do |data, context, render_options|\n data.map { |element| CMSRenders::Factory.get_render(element, context, 'justphoto').render({}, [:ignore_complements, :ignore_blocks]) }\n end\n\n term_hierarchy_preprocessor = Proc.new do |data, context, render_options|\n separator = render_options['separator'] || \"&nbsp;&middot;&nbsp;\"\n data.map do |element| \n terms = []\n terms << \"<a href=\\\"#{render_options['prefix']}/#{element.id}\\\">\"\n terms << \"#{element.description}</a>\"\n while not element.parent.nil?\n element = element.parent\n terms << separator\n terms << \"<a href=\\\"#{render_options['prefix']}/#{element.id}\\\">#{element.description}</a>\"\n end\n render_result = \"<div class=\\\"term-hierarchy-container #{render_options['container_class']}\\\">\" << terms.reverse.join << \"</div>\"\n end\n \n end\n\n ::Model::ViewRender.new(:teaser, 'teaser', ::Model::ViewStyle::VIEW_STYLE_TEASER, teaser_preprocessor)\n ::Model::ViewRender.new(:thumbnail, 'thumbnail', Model::ViewStyle::VIEW_STYLE_THUMBNAIL)\n\n end", "def create_view(db) \n begin\n db.get('_design/todos')\n rescue RestClient::ResourceNotFound => nfe\n db.save_doc({\n \"_id\" => \"_design/todos\",\n :views => {\n :allTodos => {\n :reduce => \"_count\",\n :map => \"function(doc){if(doc.title && doc.completed != null){emit(doc.order,{title: doc.title,completed: doc.completed})}}\"\n }\n }\n })\n end\nend", "def views\n @views\n end", "def index\n @views = @ministry.views.find(:all, :order => _(:title, :view))\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @views.to_xml }\n end\n end", "def upload_default_views(logger = Logger.new(STDOUT))\n each_model(:raise_exceptions => true) do |model|\n design_document = WingedCouch::Design::Document.from(model.database)\n\n model.attribute_names.each do |attribute_name|\n WingedCouch::Design::View.create(design_document, *view_attributes(attribute_name))\n end\n\n logger.info %Q{Uploaded default views for model \"#{model.name}\"}\n end\n end", "def viewize(functions)\n {:views => functions}\n end", "def index\n @lake_views = LakeView.all\n end", "def start\n # Set a cleaner process title\n Process.setproctitle(\"generate #{ARGV.join(\" \")}\")\n\n # Parse CLI arguments\n parser.parse!\n\n # Render Apache portal config\n view = View.new(context)\n rendered_template = view.render(template.read)\n output.write(rendered_template)\n rescue\n $stderr.puts \"#{$!.to_s}\"\n $stderr.puts \"Run 'generate --help' to see a full list of available options.\"\n exit(false)\n end", "def initialize(options={})\n @debug = !!options[:debug]\n\n @views = {}\n @compact = options[:compact]\n @cache = nil\n\n backend = options[:backend]\n case backend\n when 'html5', 'docbook45', 'docbook5'\n eruby = load_eruby options[:eruby]\n #Helpers.require_library 'asciidoctor/backends/' + backend\n require 'asciidoctor/backends/' + backend\n # Load up all the template classes that we know how to render for this backend\n BaseTemplate.template_classes.each do |tc|\n if tc.to_s.downcase.include?('::' + backend + '::') # optimization\n view_name, view_backend = self.class.extract_view_mapping(tc)\n if view_backend == backend\n @views[view_name] = tc.new(view_name, backend, eruby)\n end\n end\n end\n else\n Debug.debug { \"No built-in templates for backend: #{backend}\" }\n end\n\n # If user passed in a template dir, let them override our base templates\n if (template_dirs = options.delete(:template_dirs))\n Helpers.require_library 'tilt', true\n\n if (template_cache = options[:template_cache]) === true\n # FIXME probably want to use our own cache object for more control\n @cache = (@@global_cache ||= TemplateCache.new)\n elsif template_cache\n @cache = template_cache\n end\n\n view_opts = {\n :erb => { :trim => '<>' },\n :haml => { :format => :xhtml, :attr_wrapper => '\"', :ugly => true, :escape_attrs => false },\n :slim => { :disable_escape => true, :sort_attrs => false, :pretty => false }\n }\n\n # workaround until we have a proper way to configure\n if {'html5' => true, 'dzslides' => true, 'deckjs' => true, 'revealjs' => true}.has_key? backend\n view_opts[:haml][:format] = view_opts[:slim][:format] = :html5\n end\n\n slim_loaded = false\n path_resolver = PathResolver.new\n engine = options[:template_engine]\n\n template_dirs.each do |template_dir|\n # TODO need to think about safe mode restrictions here\n template_dir = path_resolver.system_path template_dir, nil\n template_glob = '*'\n if engine\n template_glob = \"*.#{engine}\"\n # example: templates/haml\n if File.directory? File.join(template_dir, engine)\n template_dir = File.join template_dir, engine\n end\n end\n\n # example: templates/html5 or templates/haml/html5\n if File.directory? File.join(template_dir, backend)\n template_dir = File.join template_dir, backend\n end\n\n # skip scanning folder if we've already done it for same backend/engine\n if @cache && @cache.cached?(:scan, template_dir, template_glob)\n @views.update(@cache.fetch :scan, template_dir, template_glob)\n next\n end\n\n helpers = nil\n scan_result = {}\n # Grab the files in the top level of the directory (we're not traversing)\n Dir.glob(File.join(template_dir, template_glob)).\n select{|f| File.file? f }.each do |template|\n basename = File.basename(template)\n if basename == 'helpers.rb'\n helpers = template\n next\n end\n name_parts = basename.split('.')\n next if name_parts.size < 2\n view_name = name_parts.first \n ext_name = name_parts.last\n if ext_name == 'slim' && !slim_loaded\n # slim doesn't get loaded by Tilt\n Helpers.require_library 'slim', true\n end\n next unless Tilt.registered? ext_name\n opts = view_opts[ext_name.to_sym]\n if @cache\n @views[view_name] = scan_result[view_name] = @cache.fetch(:view, template) {\n Tilt.new(template, nil, opts)\n }\n else\n @views[view_name] = Tilt.new template, nil, opts\n end\n end\n\n require helpers unless helpers.nil?\n @cache.store(scan_result, :scan, template_dir, template_glob) if @cache\n end\n end\n end", "def render(name, **args)\n\t\t\n\t\tif Core::DEBUG\n\t\t\tputs \"Loading view...\"\n\t\tend\n\n\t\tname = Core::VIEW + name\n\n\t\tfilePath = Core::viewPath(name)\n\n\t\tself.loadFile(filePath, \"View\")\n\n\t\t## Will retrieve class constant name for dynamic instanciation\n\t\tviewName = Object.const_get(name)\n\n\t\tview = viewName.new()\n\n\t\t## Force children controller and view\n\t\t## to run parent initialize if overriden.\n\t\tCore::forceParentInit(self)\t\n\t\tCore::forceParentInit(view)\n\n\t\t## Set values sent from previous view in\n\t\t## content of current view.\n\t\targs.each{\n\t\t\t|key, value|\n\t\t\t@content[key.to_s] = value\n\t\t}\n\n\t\tself.setProperties(view)\n\n\t\t## Collect content from controller and send it to view\n\t\tview.controller = self\n\t\tview.controller.run()\n\t\tview.content = @content.clone()\n\n\t\t## Refer controller methods in view for easier\n\t\t## call.\n\t\tself.class.instance_methods(false).each() do |method|\n\t\t\tif !view.class.method_defined?(method)\n\t\t\t\tview.define_singleton_method(method) do |*arguments|\n\t\t\t\t\tself.controller.send(method, *arguments)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t## Will render view with content retrieved in controller\n\t\tview.setInstanceVars()\n\t\tview.run()\n\n\t\tFenetre::css(:priorite => \"PRIORITY_APPLICATION\")\n\n\t\t## Display content builded in view with Gtk\n\t\tview.window.show_all\n\tend", "def compile()\n begin\n\n @config = FILE_IMPORTER.load(@config, true)\n\n Wavy::Parsers::Import.load(@config, @config_root)\n Wavy::Parsers::Import.extract\n\n if @view == false\n exports = Wavy::Models::Exports.get\n exports.each do |key, export|\n rendered = self.class.render(export.path)\n output(rendered['template'], rendered['full_path'], rendered['file_path'])\n end\n else\n rendered = self.class.render(@view)\n output(rendered['template'], rendered['full_path'], rendered['file_path'])\n end\n\n rescue Exception => e\n puts e.message\n end\n end", "def run\n each_test do |liquid, layout, assigns, page_template, template_name|\n compile_and_render(liquid, layout, assigns, page_template, template_name)\n end\n end", "def generate_html\n @main_url = main_url\n @sorted_files = @files.sort\n @sorted_classes = @classes.sort\n @sorted_methods = RDoc::Generator::Method.all_methods.sort\n\n # the individual descriptions for files and classes\n gen_into(@files)\n gen_into(@classes)\n\n # and the index files\n gen_file_index\n gen_class_index\n gen_method_index\n gen_main_index\n\n # this method is defined in the template file\n values = {\n :title_suffix => CGI.escapeHTML(\"[#{@options.title}]\"),\n :charset => @options.charset,\n :style_url => style_url('', @options.css),\n }\n\n @template.write_extra_pages(values) if\n @template.respond_to?(:write_extra_pages)\n end", "def views\n []\n end", "def views\n []\n end", "def views\n []\n end", "def views\n []\n end", "def views(stream)\n # Don't create \"system\" views.\n view_names = PgSaurus::Tools.views\n view_names.each do |options|\n write_view_definition(stream,\n options[\"table_schema\"],\n options[\"table_name\"],\n options[\"view_definition\"])\n end\n stream << \"\\n\"\n end", "def templates; end", "def define\n desc \"Generate rokko documentation\"\n task @name do\n # Find README file for `index.html` and delete it from `sources`\n if @options[:generate_index]\n readme_source = @sources.detect { |f| File.basename(f) =~ /README(\\.(md|text|markdown|mdown|mkd|mkdn)$)?/i }\n readme = readme_source ? File.read(@sources.delete(readme_source)) : ''\n end\n\n # Run each file through Rokko and write output\n @sources.each do |filename|\n rokko = Rokko.new(filename, @sources, @options)\n out_dest = File.join(@dest, filename.sub(Regexp.new(\"#{File.extname(filename)}$\"), \".html\"))\n puts \"rokko: #{filename} -> #{out_dest}\"\n FileUtils.mkdir_p File.dirname(out_dest)\n File.open(out_dest, 'wb') { |fd| fd.write(rokko.to_html) }\n end\n\n # Generate index.html if needed\n if @options[:generate_index]\n require 'rokko/index_layout'\n out_dest = File.join(@dest, 'index.html')\n puts \"rokko: #{out_dest}\"\n File.open(out_dest, 'wb') { |fd| fd.write(IndexLayout.new(@sources, readme, @options).render) }\n end\n\n # Run specified file through rokko and use it as index\n if @options[:index] && source_index = @sources.find{|s| s == @options[:index]}\n rokko = Rokko.new(source_index, @sources, @options.merge(preserve_urls: true))\n out_dest = File.join(@dest, 'index.html')\n puts \"rokko: #{source_index} -> index.html\"\n File.open(out_dest, 'wb') { |fd| fd.write(rokko.to_html) }\n end\n\n end\n end", "def index\n @views = @workspace.views.all\n end", "def execute(*args)\n \n # Verify if the controller answers to the @view_name value\n if args[0].respond_to? lookup_method_to_call(@view_name)\n \n # The controller defines a method with the same name as @view_name.\n # Kewl! A 'someone else problem' !!!\n \n # Launch execution\n result = args[0].send( lookup_method_to_call(@view_name) )\n \n else\n \n # Do we have to do everything here? lazy user...\n \n # Render something but only if the user hasn't\n # defined a custom render block.\n args[0].send :render, :action => lookup_method_to_call(@view_name) unless renders.has_key?('render')\n \n # Return the :render event\n result = WebFlow::Event.new(:render)\n \n end\n \n # Verify if we have to override the render result.\n # Execute if necessary.\n # Also validate that the return type is an event, or let go and it will\n # crash as soon as execution completes anyways...\n if result.kind_of?(WebFlow::Event) && renders.has_key?(result.name)\n \n # Execute the render block\n args[0].instance_eval( &renders.fetch( result.name ) )\n \n end\n \n result\n \n end", "def build_view_paths(paths); end", "def render()\n # WARNING! NO NEED TO UNDERSTAND THIS\n self.action = calling_method = caller[0].split(\"`\").pop.gsub(\"'\", \"\")\n template = File.read(view_filename)\n eruby = Erubis::Eruby.new(template)\n eruby.result(binding())\n end", "def generate_email_views\n directory \"app/views/kublog/post_mailer\"\n end", "def generate_main_page_with(specs)\n main_page = Amy::Model::Main.new\n specs['resources'].each_pair { |resource, options|\n main_page.add_resource( { 'resource' => resource, 'title' => options['title'] } )\n }\n main_page.links = specs['links'] || []\n main_page.version = specs['api_version']\n main_page.base_url = specs['base_url']\n @generator.do(\"#{Amy::BASE_DIR}/views/main.erb.html\", main_page)\n end", "def preview_index(urls, path: request.path)\n render(path: __dir__ + \"/index.erb\", locals: { urls: Array(urls), path: path })\n end", "def copy_view_files\n available_views.each do |view|\n filename = view_filename_with_extensions(view)\n template filename, File.join(\"app/views\", controller_file_path, File.basename(filename))\n end\n end", "def _render filename\n\t\t\tFile.read(\"./views/_/#{filename}.html\")\n\t\tend", "def copy_views\n #theoretical support in the future for haml\n extension = \".\" + template_engine\n file_names = %w{index show _pagination _search_form }\n file_names.each do |file_name|\n source = \"views/email_manager/managed_emails/\" + file_name + \".html\" + extension\n destination = \"app/views/email_manager/managed_emails/\" + file_name + \".html\" + extension\n copy_file source, destination\n end\n end", "def call(env)\n DocumentGenerator.call(\n app: @app,\n env: env,\n html: @html,\n markdown: @markdown,\n path: path,\n )\n end", "def view_paths; end", "def view_paths; end", "def view_paths; end", "def copy_views\n target_views = options[:views] || VIEWS\n target_views.each do |directory|\n view_directory directory.to_sym\n end\n end", "def view(opts)\n opts = check_params(opts,[:view_names])\n super(opts)\n end", "def generator\n @app.generator\nend", "def execute!\n make_web_directory\n generate_universe\n generate_html\n print_success_message\n end", "def generate_Genre_Pages\n template_doc = File.open(\"lib/templates/genre.html.erb\")\n template = ERB.new(template_doc.read)\n Genre.all.each do |genre|\n File.write(\"_site/genre/#{genre.url}\", template.result(binding))\n end\n end", "def generate!\n info \"GENERATE\"\n\n f = Generator.new @dbi, @settings, @logger\n xslt = XML::XSLT.new\n xslt.xml = f.generate_root.to_s\n\n default_template_dir = File.dirname(__FILE__) + '/../../data/templates'\n template_dir = @settings['templates'] || default_template_dir\n output_dir = @settings['output']\n\n task \"copy static files\" do\n FileUtils.mkdir_p output_dir\n FileUtils.cp_r Dir[File.join( template_dir, 'static', '*' )], output_dir\n end\n\n begin\n Dir.foreach(template_dir) { |template_file|\n next if template_file =~ /^\\./ || template_file == 'static'\n\n task \"process #{template_file}\" do\n xslt.xsl = File.join( template_dir, template_file )\n File::open( File.join( output_dir, template_file ), 'w') { |f| f.write(xslt.serve) }\n end\n }\n rescue Errno::ENOENT\n warn \"Couldn't find templates directory, fallback to default templates!\"\n template_dir = default_template_dir\n retry\n end\n end", "def grvpc\n render layout: 'views/index'\n end", "def index\n @yourviews = Yourview.all\n end", "def view_thing thing\n\t@thing = thing\n\trender :template => 'things/view'\n\t#render :text => '<pre>'+YAML::dump(@thing)\n end", "def view(check = nil, &block)\n raise ArgumentError, \"block required\" unless block_given?\n @views.insert(0, ViewHandler.new(check, block))\n end", "def view(name, opts = {})\n design_doc.create_view(name, opts)\n end", "def process_index\n bindings = {\n :url => @definition.get_url,\n :name => @definition.get_name,\n :resources => @definition.resources,\n :description => @definition.get_description,\n :version => @definition.get_version\n }\n\n page = Calamum::DocGenerator.new(:index)\n page.save_template('index.html', bindings)\n end", "def create_view_templates\n unless @check_migration\n template 'views/images.html.erb', File.join(file_path, \"_images.html.erb\")\n template 'views/image.html.erb', File.join(file_path, \"_image.html.erb\")\n template 'views/images_field.html.erb', File.join(file_path, \"_images_field_#{@chunk}.html.erb\")\n else\n unless File.exists?(\"#{file_path}/_images_field_#{@chunk}.html.erb\")\n template 'views/images_field.html.erb', File.join(file_path, \"_images_field_#{@chunk}.html.erb\")\n end\n end\n end", "def configure_views\n helpers do\n def find_template(views, name, engine, &block)\n _, dir = views.detect { |k,v| engine == Tilt[k] }\n dir ||= views[:default]\n super(dir, name, engine, &block)\n end\n end\n end" ]
[ "0.72299117", "0.7178173", "0.69774723", "0.6902254", "0.67007166", "0.66692483", "0.6498586", "0.6430707", "0.6332138", "0.62775815", "0.6263002", "0.62627524", "0.6200726", "0.6200673", "0.6165071", "0.6149146", "0.61454237", "0.6119936", "0.60735446", "0.6062002", "0.6046769", "0.60307884", "0.6008146", "0.59968024", "0.59752727", "0.59735084", "0.59729654", "0.5935003", "0.59208184", "0.59151804", "0.5911565", "0.5900686", "0.5898668", "0.5853221", "0.58490646", "0.58479524", "0.5844983", "0.5836769", "0.5828554", "0.58157104", "0.5806101", "0.58040047", "0.5791573", "0.57834274", "0.5736614", "0.57241064", "0.57163066", "0.57097673", "0.5705858", "0.5705303", "0.57039994", "0.5703012", "0.56916267", "0.5676346", "0.56754756", "0.567511", "0.56697136", "0.5663803", "0.566359", "0.5656115", "0.56482524", "0.56398493", "0.56376195", "0.5637411", "0.5634498", "0.5632794", "0.5632794", "0.5632794", "0.5632794", "0.56303084", "0.56202054", "0.56119955", "0.5599827", "0.55959", "0.5587431", "0.55769193", "0.55733323", "0.55430603", "0.5534052", "0.553237", "0.55320436", "0.55298555", "0.55219823", "0.5516352", "0.5516352", "0.5516352", "0.551342", "0.5508038", "0.55071765", "0.550647", "0.55002654", "0.54985315", "0.54966956", "0.5495823", "0.5495769", "0.5495158", "0.54915017", "0.5491376", "0.54865724", "0.5477571" ]
0.79429555
0
generates a fetch statistic image
def stats! info "STATS" task "generate chart" do c = Chart::StatsPerCollection.new @dbi.execute( File.read( sql_query(:chart) ) ).each{ |date,collection| c.add_one(collection, Date.parse(date).day) } Chart.new(c).write File.join( @config['settings']['output'], '/chart.jpg' ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @samples = ImageReaderService.new(@image).analyze.generate_samples 4\n end", "def show\n unless (request.path.scan(/^\\/(.{1,})\\/.{1,}$/)[0].nil? || request.path.scan(/^\\/(.{1,})\\/.{1,}$/)[0][0] == \"imgnewsletters\")\n @newsletter = Newsletter.find(params[:id])\n respond_with(@newsletter)\n else\n\t Newsletter.updatetat(params[:id])\n\t pixel = Magick::Image.new(1,1)\n\t Magick::Draw.new.fill('white').point(1,1).draw(pixel)\n\t pixel.write(\"#{Rails.root}/app/assets/images/statistic_pixel/pixel.png\")\n\t \n\t pixel_read = Magick::Image.read(\"#{Rails.root}/app/assets/images/statistic_pixel/pixel.png\").first\n\t \n\t send_data pixel_read.to_blob, :filename => \"pixel.png\",\n\t \t \t\t :dsposition => 'inline',\n\t \t\t\t :type => 'image/png'\n end\n end", "def create_statistics_output(result)\n size_improvement = result['originalSize'] - result['compressedSize']\n size_gzip_improvement = result['originalGzipSize'] - result['compressedGzipSize']\n rate_improvement = (size_improvement * 100)/result['originalSize']\n rate_gzip_improvement = (size_gzip_improvement * 100)/result['originalGzipSize']\n out = \"Original Size: #{result['originalSize']} bytes (#{result['originalGzipSize']} bytes gzipped) \\n\"\n out << \"Compiled Size: #{result['compressedSize']} bytes (#{result['compressedGzipSize']} bytes gzipped) \\n\"\n out << \"\\t Saved #{rate_improvement}% off the original size (#{rate_gzip_improvement}% off the gzipped size)\"\n end", "def do_generate_tile(image)\n i = image\n puts \"GENERATE #{name}: #{i}\"\n @operations.each do |operation|\n puts \" ! do_#{operation[:operation]}, #{operation}.\"\n i = send(\"do_#{operation[:operation]}\", i, operation)\n end\n return i\n end", "def extract_graphic\n if !Cache.screenshot(@save_number, header).nil?\n bitmap_screenshot = Cache.screenshot(@save_number, header)\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n else @virtualb = DataManager.load_screenshot(@save_number)\n if @virtualb.nil?\n bitmap_screenshot = black_bitmap\n else\n bitmap_screenshot = @virtualb.get_bitmap\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n Cache.add_screenshot(@save_number, bitmap_screenshot, header[:key])\n end\n end\n @screenshot.bitmap = bitmap_screenshot\n @screenshot_loaded = false\n @loading_bar.disappear\n end", "def get_haplotype_img(map_id)\n\n map = Map.find(map_id)\n @markers = []\n chromosome = params['chromosome'] || 1\n start = params['start'] || 20000000\n stop = params['end'] || 25000000\n\n # do the processing to get the data and create the image\n get_region_marker_data(chromosome, start, stop)\n # redirect output to the image file itself, thereby rendering the file\n redirect_to draw_haplotype_image(@markers, @strains, @genotypes, false, 'high', 'gif')\n\n end", "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 graphics_file(type=:stress)\n job.configure_concern\n results_dir = job.result_path\n results_file = lambda { |f| f.exist? ? f : \"\" }\n if type == :stress\n results_file.call(results_dir + \"#{prefix}_stress.html\").to_s\n elsif type == :displ\n results_file.call(results_dir + \"#{prefix}_displ.html\").to_s\n else\n return \"\"\n end\n end", "def show\n @bench_test_photo_gen = BenchTest::PhotoGen.find(params[:id])\n if @bench_test_photo_gen.start.nil?\n # no start time recorded yet, see if we can find info about first photo\n photo = Photo.find_by_user_id_and_album_id_and_caption(@bench_test_photo_gen.user_id,\n @bench_test_photo_gen.album_id,\n '1')\n if photo\n utime = photo.image_updated_at\n @bench_test_photo_gen.start = utime unless utime.nil?\n end\n end\n if @bench_test_photo_gen.stop.nil?\n last = @bench_test_photo_gen.iterations.to_s\n # no start time recorded yet, see if we can find info about first photo\n photo = Photo.find_by_user_id_and_album_id_and_caption(@bench_test_photo_gen.user_id,\n @bench_test_photo_gen.album_id,\n last)\n if photo\n utime = photo.updated_at # yes we really do want updated_at not image_update_at for the end time\n if utime && (photo.ready? || photo.error?)\n @bench_test_photo_gen.stop = utime\n\n # since this is last photo gather good/bad stats\n photos = Photo.find_all_by_user_id_and_album_id(@bench_test_photo_gen.user_id,\n @bench_test_photo_gen.album_id)\n good_count = 0\n error_count = 0\n photos.each do |photo|\n if photo.ready?\n good_count += 1\n else\n error_count += 1\n end\n end\n @bench_test_photo_gen.good_count = good_count\n @bench_test_photo_gen.error_count = error_count\n @bench_test_photo_gen.result_message = \"Test Complete.\"\n end\n end\n end\n if @bench_test_photo_gen.changed?\n # persist the changes\n @bench_test_photo_gen.save!\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bench_test_photo_gen }\n end\n end", "def output_image\r\n\t\tif !(@data.empty?)\r\n\t\t\t@data.each do |row| \r\n\t\t\t\tputs row.join(' ')\r\n\t\t\tend\r\n \r\n\t\telse\r\n\t\t\tputs \"No values supplied.\"\r\n\t\tend\r\n\tend", "def download_image\n Net::HTTP.start(\"yuml.me\", 80) do |http|\n http.get(URI.escape(@diagram.get_uri))\n end\n end", "def output_image\r\n @icon.each do |data|\r\n puts data.join\r\n end\r\n end", "def generate(key, filename, seqid, range, style_obj, width, add_introns, \n style_override, return_image_info)\n \n log \"generating img/info #{key}\"\n log filename, 2\n log \"#{seqid}, #{range.inspect}\", 2\n \n info = \"\"\n \n time = Benchmark.measure do\n style_copy = style_obj.clone\n style_override.each do |gt_ruby_type, section, attribute, value|\n if value.nil?\n style_copy.unset(section, attribute)\n else\n style_copy.send(\"set_#{gt_ruby_type}\", section, attribute, value)\n end\n end\n mode = add_introns ? :on : :off\n fix = feature_index(filename, mode)\n gtrange = fix.get_range_for_seqid(seqid)\n gtrange.start = range.first\n gtrange.end = range.last\n diagram = GT::Diagram.from_index(fix, seqid, gtrange, style_copy)\n info = GT::ImageInfo.new\n layout = GT::Layout.new(diagram, width, style_copy)\n canvas = GT::CanvasCairoFile.new(style_copy, width, layout.get_height, info)\n layout.sketch(canvas)\n lock(:img) do\n @cache[:img][key] = canvas.to_stream\n end\n end\n log \"done (%.4fs)\" % time.real, 3\n return info if return_image_info\n end", "def to_erb\n url = @img['src']\n url.sub!(\"/images/\", \"\")\n data_pixel = ''\n\n # resolve special data-pixel-density-2 case\n if @img.to_s.include? 'data-pixel-density-2'\n data_value = @img['data-pixel-density-2']\n data_value.sub!(\"/images/\", \"\")\n data_pixel = \", 'data-pixel-density-2': image_path('#{data_value}')\"\n end\n\n options_str = process_options\n\n if url.include?(\"<%= \") && url.include?(\" %>\")\n url.sub!(\"<%= \", '#{')\n url.sub!(\" %>\", \"}\")\n url_string = \"\\\"#{url.to_s}\\\"\"\n\n \"<%= image_tag(#{url_string}#{options_str}#{data_pixel})%>\"\n else\n \"<%= image_tag('#{url}'#{options_str}#{data_pixel})%>\"\n end\n end", "def generate_site_stats\n H.ul {\n H.li {\"#{$r.get(\"users.count\")} users\"} +\n H.li {\"#{$r.zcard(\"news.cron\")} news posted\"} +\n H.li {\"#{$r.info['used_memory_human']} of used memory\"}\n }\nend", "def run\n ::SimpleHttp.get(@url).tap do |response|\n status, headers, blob = *response\n response[2] = Magick::Image.from_blob(blob).first if status == 200\n end\n end", "def render\n # image size\n x = @data.length*@field_size # columns x field_size\n y = @data.dataset_length*@field_size # buckets x field_size\n\n # start drawing the damn thing\n image = Magick::Image.new(x, y) { self.background_color = \"white\" }\n\n i = 0\n @data.each do |point|\n j = 0\n point.reverse.each do |part|\n # draw a red rectangle on the white background\n core = Magick::Draw.new\n\n intensity = 127.5 * part\n # Fix for float stupidity\n intensity = 127.5 if intensity > 127.5\n\n # Get the correct value\n l = (255-intensity).round\n\n # Draw\n core.fill(Magick::Pixel.from_hsla(0, 255, l, 1).to_color)\n core.rectangle((i*@field_size), (j*@field_size), ((i+1)*@field_size), ((j+1)*@field_size))\n core.draw image\n j = j + 1\n end\n i = i + 1\n end\n\n image\n end", "def generate_image\n matrix_values = compute_values\n max, min = matrix_values.max.to_f, matrix_values.min.to_f\n \n hue_range = HeatPalette::HSL_HUE_MAX - HeatPalette::HSL_HUE_MIN\n matrix_scaled = ((matrix_values - min)*(hue_range-1)/(max-min)).round\n \n contours_values = explicit_range(min..max, @contours).drop(1)\n contours_scaled = contours_values.map{|e| ((e - min)*(hue_range-1)/(max-min)).round}\n rainbow = colorines(contours_scaled)\n \n @metadata[\"max_value\"] = max\n @metadata[\"min_value\"] = min\n @metadata[\"contours_values\"] = contours_values\n \n legend_stream = rainbow.map{|e| ChunkyPNG::Color.from_hex(e)}\n \n @legend = ChunkyPNG::Image.new(hue_range, LEGEND_HEIGHT, legend_stream*LEGEND_HEIGHT)\n \n stream = matrix_scaled.flatten.to_a\n stream.map!{|e| ChunkyPNG::Color.from_hex(\"#{rainbow[e]}\")}\n @img = ChunkyPNG::Image.new(@width, @height, stream).rotate_counter_clockwise\n end", "def main()\n img = ImageList.new($input)\n convert = ImageList.new\n page = Magick::Rectangle.new(0,0,0,0)\n $total_ops = (img.rows * img.columns).to_f\n\n for i in 0..img.rows\n for j in 0..img.columns\n pixel = generate_hex_pixel(rgb_to_hex(img.pixel_color(j,i)))\n convert << pixel\n page.x = j * pixel.columns\n page.y = i * pixel.rows\n pixel.page = page\n progress()\n end\n end\n\n puts 'Writing image, this could take a while...'\n convert.mosaic.write($output)\nend", "def create_basic\n ImageGeneratingService.new(self, 'Basic.jpg', 'image/jpeg', 100).generate_resized(600)\n end", "def to_html\n \"<img src='#{@url}' height='#{@height}' width='#{width}' />\"\n end", "def show\n\n matches = params[:size].match(\"([0-9]+)x([0-9]+).*\") if params[:size]\n\n default_size = 200\n min_size = 16\n max_size = 200\n\n if matches\n\n width = matches[1].to_i\n height = matches[2].to_i\n\n if ((width < min_size) || (width > max_size) || (height < min_size) || (height > max_size))\n width = default_size\n height = default_size\n end\n\n else\n width = 200\n height = 200\n end\n \n send_cached_data(\"public/pictures/show/#{width.to_i}x#{height.to_i}/#{params[:id].to_i}.jpg\",\n :type => 'image/jpeg', :disposition => 'inline') {\n\n img = Magick::Image.from_blob(@picture.data).first\n img = img.change_geometry(\"#{width}x#{height}>\") do |c, r, i| i.resize(c, r) end\n\n img.format = \"jpg\"\n img.to_blob\n }\n\n end", "def display_tile_image\n generate_tile unless @i.nil?\n display_image = @i.scale(8.0)\n display_image.display\n end", "def generate_tile_image(output_path, type = :png)\n generate_tile unless @i.nil?\n @i.write(File.join(output_path, \"#{name}.#{type}\"))\n end", "def perform\n logger.info \">>>>>>>>>>>>>>>>>>>>>>>>>>>>> Acquiring Thumbnail data on url '#{url}' >>>>>>>>>>>>>>>>>>>>>>>>>\"\n # A url which is a date string denotes an ImageReference which came in as data, and is therefore good\n if fake_url?\n attrib_needed! :thumbdata, false\n return\n end\n self.errcode = 0 if errcode == -2\n if response_body = fetch # Attempt to get data at the other end of the URL\n begin\n img = Magick::Image::from_blob(response_body).first\n if img.columns > 200\n scalefactor = 200.0 / img.columns\n thumb = img.scale(scalefactor)\n else\n thumb = img\n end\n thumb.format = 'PNG'\n quality = 80\n accept_attribute :thumbdata, 'data:image/png;base64,' + Base64.encode64(thumb.to_blob { self.quality = quality })\n rescue Exception => e\n self.errcode = -2 # Bad data\n err_msg = \"couldn't parse to image data: ImageReference #{id}: #{url} (#{e})\"\n errors.add :url, err_msg\n raise err_msg\n end\n else\n attrib_needed! :thumbdata, false\n errors.add :url, \"couldn't be read (errcode = #{errcode})\" if errcode != 0\n end\n end", "def show\n graph = GraphViz.new(:G, type: :digraph)\n competency = Competency.find(params[:id])\n graphviz(graph, competency)\n @file = Tempfile.new(['foo', '.png'], \"#{Rails.root}/public/images\")\n graph.output(png: @file.path)\n end", "def show\n\n # Get random gif from Giphy (http://giphy.com)\n response = HTTParty.get('http://api.giphy.com/v1/gifs/search?' +\n 'q=' + @boolio.val.to_s +\n '&api_key=dc6zaTOxFJmzC' + # provided for public beta testing via (https://github.com/Giphy/GiphyAPI#public-beta-key)\n '&limit=1' + # only want 1\n '&offset=' + rand(30).to_s + # pull from the top 10 most relevant images\n '&rating=pg' + # afraid if this is any higher\n '&fmt=json' # seems to return JSON anyway, but just in case\n )\n\n if response.code == 200\n\n # conver to JSON\n json = JSON.parse response.body, object_class: OpenStruct\n\n # set image from returned results\n @image = json.data[0].images if json.data.count > 0\n end\n\n end", "def generate_png\n img = IMGKit.new(url).to_png\n file = File.new(\"#{id}-full.png\", \"w\", :encoding => 'ascii-8bit')\n file.write(img)\n return file.path\n end", "def scanned_prof_image\n scanned_prof\n end", "def status\n image_name = if params[:sha]\n @project.sha_status_image(params[:sha])\n elsif params[:ref]\n @project.status_image(params[:ref])\n else\n 'unknown.png'\n end\n\n send_file Rails.root.join('public', image_name), filename: image_name, disposition: 'inline'\n end", "def sample\n img :src => $imgHostURL + \"/\" + $sampleImg\n end", "def statistics; end", "def test_hist_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"h\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n\n if @parameter[1].to_i == 1\n assert_equal [64, 112, 48, 96, 96, 32, 32, 80, 16, 128, 64, 16, 48, 80, 112],\n img.ancillary_chunks[:hIST][0].get_data\n else\n assert_equal [4]*256, img.ancillary_chunks[:hIST][0].get_data\n end\n end\n end\n\n\n\n img = Imgrb::Image.new(10, 10, [255,155,10])\n hist_dat = [10*10]\n hist = Imgrb::Chunks::ChunkhIST.assemble(*hist_dat)\n img.add_chunk(hist)\n\n png_str = save_png_to_string(img, 1)\n img_saved = Imgrb::Image.new(png_str, :from_string, :only_metadata)\n hist_dat_saved = img_saved.ancillary_chunks[:hIST][0].get_data\n\n assert_equal hist_dat, hist_dat_saved\n end", "def print_hitnumdist(io, run)\n\n io.puts \"<h3>hit number distributions</h3>\"\n io.puts \"<div style=\\\"text-align: center;\\\">\"\n\n io.puts \"<table>\"\n (1..4).each { |row|\n io.puts \" <tr>\"\n (1..6).each { |col|\n ch = 48 + 6*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/lehit#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/lehit#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n\n io.puts \"<table>\"\n (1..$mod).each { |row|\n io.puts \" <tr>\"\n (1..$pad).each { |col|\n ch = $off + $pad*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/tehit#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/tehit#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n\n io.puts \"</div>\"\n\nend", "def create_and_send_stats_files\n if params[:type] == \"stata\"\n download_stata_files\n else\n download_spss_files\n end\n end", "def render_info\n account, ref, app_key = params[:user], params[:ref], params[:a]\n if (account.nil? || ref.nil?)\n json_error(\"missing parameters\")\n return\n elsif (@screen_res.nil?)\n json_error(\"unable to find current screen resolution\");\n return\n end\n\n # look up the image\n begin\n @image = Image.find_user_image_by_ref(account, ref)\n #@image = Image.find_lifesize_image(account, ref)\n rescue ActiveRecord::RecordNotFound\n json_error(\"image not found: \" + ref)\n return\n else\n if @image.nil?\n json_error(\"image not found: \" + ref)\n return\n end\n\n # calculate how big the image should be rendered now, and return that to the server\n lifesize = LifeSize.new(@screen_config)\n sz = lifesize.image_size(@image)\n response = { :width => sz[:width], :height => sz[:height], :confidence => @screen_config[:confidence]}\n puts \"image response will be #{response.to_json}\"\n respond_to do |format|\n format.json { render :json => response }\n end\n end\n end", "def output_image\r\n # loop continues through each Row and outputs content\r\n @array.each do |row|\r\n puts row.join\r\n end\r\n end", "def build_HTML_response(response)\n return \"<img src=\\\"#{response}\\\" alt=\\\"#{options[:title].nil? ? 'Screenshot' : options[:title]}\\\">\" if options[:size].nil?\n\n \"<img src=\\\"#{response}\\\" alt=\\\"#{options[:title].nil? ? 'Screenshot' : options[:title]}\\\" width=\\\"#{options[:size]}%\\\">\"\n end", "def create_info_bitmap\n @info = Bitmap.new(Graphics.width-10, HEIGHT)\n #draw_party_members(80, 2)\n draw_save_number(85,60)\n draw_bars\n #draw_playTime(0, 98)\n #draw_story(0,122)\n #draw_gold(0,98)\n #draw_location(0, 122)\n end", "def image\n image = Weatherman::Image.new(attribute('image'))\n do_convertions(image, [:width, :to_i], [:height, :to_i], :title, :link, :url)\n end", "def extract_histogram\n Riiif::File.new(\"#{Settings.IMAGE_PATH}/#{file_name}\")\n .extract(\n Riiif::Transformation.new(\n nil, nil, nil, nil,\n # Only provide :format for this Struct\n '-define histogram:unique-colors=true -format %c'\\\n ' histogram:info'\n )\n )\n end", "def image_element(url, name)\n abs_url = @base_url + url\n size = content_size(abs_url)\n\n ret = \"<image url=#{abs_url.encode(xml: :attr)} name=#{name.encode(xml: :attr)} size=\\\"#{size}\\\">\\n\"\n ret += \"<checksum type=\\\"sha256\\\" disposition=#{(abs_url + '.sha256').encode(xml: :attr)}/>\\n\"\n ret += \"</image>\"\n ret.html_safe\n end", "def render\n labels = []\n values = []\n @data.each do |label, value|\n labels << CGI::escape(label)\n values << (value > 0 ? value * 100 / @max : value).round.to_s\n end\n params = {:cht => 'p', :chs => \"#{width}x#{height}\", :chd => \"t:#{values.join(',')}\", :chl => labels.join('|') }\n params['chco'] = color if color\n\n url = \"http://chart.apis.google.com/chart?#{to_query(params)}\"\n\n alt_msg = \"This pie chart is generated by Google Charts. You must be connected to the Internet to view this chart.\"\n html = \"<img id=\\\"pie_chart_image\\\" src=\\\"#{url}\\\" alt=\\\"#{alt_msg}\\\"/>\"\n return html\n end", "def get_data_mms\n process\n puts \" Feed #{self.tag} generated #{self.pictures.size} pictures\"\n self.pictures.size \n end", "def print\n Catpix::print_image self.img_url,\n :limit_x => 1.0,\n :limit_y => 0,\n :center_x => true,\n :center_y => true,\n :bg => \"white\",\n :bg_fill => true,\n :resolution => \"low\"\n end", "def output_image\r\n @image.each do |cell|\r\n puts cell.join\r\n end\r\n end", "def get_a_heat_image_given_its_floorplan_id_and_filter_parameters(args = {}) \n get(\"/resource.json/heat/#{args[:floorplanId]}/#{args[:filename]}\", args)\nend", "def generate_image(url)\n # Capture the screenshot\n kit = IMGKit.new(url, quality: 90, width: 1280, height: 720)\n\n # Resize the screengrab using rmagick\n Image.from_blob(kit.to_img(:jpg)).first.\n resize_to_fill!(params['width'].to_i, params['height'].to_i).to_blob\nend", "def capture\n for i in 0..49\n\t open(\"tempImages/image#{i}.png\", 'wb') do |file|\n\t file << open('http://hq.cirrusmio.com:82/media/?action=snapshot', http_basic_authentication: [\"admin\", \"admin\"]).read\n\t sleep(0.2)\n\tend\n end\n end", "def generate\n data = { 'conflicts' => [], 'failing' => [], 'pending' => [], 'passing' => [] }\n\n pulls = client.pulls(repository)\n pulls.each do |pull|\n pull = Hubtrics::PullRequest.fetch(repository, pull.number)\n\n # pull.mergeable contains a nil when the check has not been performed yet, so we need to compare against false\n data['conflicts'] << pull.to_h if pull.mergeable == false\n data[pull.status] << pull.to_h\n end\n\n @report = template.render('data' => data, 'total_pulls' => pulls.count).strip\n end", "def show\n scan_procedure_array = (current_user.view_low_scan_procedure_array).split(' ').map(&:to_i)\n @image_dataset = ImageDataset.where(\"image_datasets.visit_id in (select visit_id from scan_procedures_visits where scan_procedure_id in (?))\", scan_procedure_array).find(params[:id])\n @visit = @image_dataset.visit\n @image_datasets = @visit.image_datasets\n \n @image_comment = ImageComment.new\n @image_comments = @image_dataset.image_comments\n @next_image_dataset = @image_datasets[@image_datasets.index(@image_dataset) + 1 ]\n @previous_image_dataset = @image_datasets[@image_datasets.index(@image_dataset) - 1 ]\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image_dataset }\n end\n end", "def image; end", "def view_stats\n @company = Company.find(params[:id])\n data = {\n :name => \"Student Views\",\n :pointInterval => 1.day * 1000,\n :pointStart => 1.weeks.ago.at_midnight.to_i * 1000,\n :data => (1.weeks.ago.to_date..Date.today).map{ |date|\n @company.impressions.where(\n \"created_at > ? AND created_at < ?\",\n date.at_beginning_of_day,\n date.tomorrow.at_beginning_of_day\n ).select{ |impression| impression.action_name == \"stat_show\"}.count\n }\n }\n respond_with data\n end", "def tw_image_url(type)\n \"http://api.twitter.com/1/users/profile_image?user_id=#{tw_user_id}&size=#{type}\"\n end", "def render_image\n render_image_iterm2\n end", "def get_stats_file(classification, transformation, preprocess)\n format = \"#{classification}_#{transformation}_#{preprocess}\"\n filename = File.join(@res, 'stats', format + '.json')\n\n filename\n end", "def add_result_stats(base, _opts)\n MiGA::Result.new(\"#{base}.json\")\n end", "def add_result_stats(base, _opts)\n MiGA::Result.new(\"#{base}.json\")\n end", "def show_image_version\n if @options[\"mode\"] == \"himage\"\n tpl = @himage_tpl\n elsif @options[\"mode\"] == \"vimage\"\n tpl = @vimage_tpl\n else \n raise \"invalid template name\" + @options[\"mode\"]\n end\n calc_weather_icon\n calc_wind_icon\n parse_radar unless @options[\"radar_location\"].empty?\n erb = ERB.new(File.read(tpl), 0, '>')\n @conky_output = erb.result(binding)\n puts @conky_output\n end", "def render\n canvas = Vips::Image.grey(@width, @height)\n\n @tiles.each do |tile|\n canvas = canvas.insert(tile.image, tile.offset.x, tile.offset.y) # rubocop:disable Style/RedundantSelfAssignment\n end\n\n # add attribution image to bottom corner if available & attribution fits into image\n if add_attribution?\n options = { x: canvas.width - attribution.width, y: canvas.height - attribution.height }\n canvas = canvas.composite2(attribution, :over, **options)\n end\n\n canvas\n end", "def heatmap\n \n if not validate_params(params)\n respond_with msg: \"Invalid params\", type: \"error\"\n end\n\n metric_attr = params[:attr]\n timeobj = JSON.parse(params[:time])\n start = long_to_date(timeobj[\"from\"][\"time\"])\n stop = long_to_date(timeobj[\"to\"][\"time\"])\n region = params[:region]\n site = params[:site]\n apn = params[:apn]\n stack = params[:stack]\n sgsn = params[:sgsn]\n\n avg_rtt_succ_rate = \"avg_rtt_succ_rate\"\n youtube_succ_rate = \"youtube_succ_rate\"\n speedtest_dl_2m_rate = \"speedtest_dl_2m_rate\"\n\n\n results = []\n # Completely hack on this logic\n # TODO\n if (stack == 'GGSN')\n MetricHttp.facebook\n .select(\"date_time, apn as group, avg(#{metric_attr}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time, :apn)\n .asc_date_time\n .each do | d|\n t = d.attributes\n t[\"service\"] = \"facebook\"\n results << d\n end\n\n MetricPing\n .select(\"date_time, apn as group, avg(#{avg_rtt_succ_rate}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time, :apn)\n .asc_date_time\n .each do | d|\n results << d\n end\n\n MetricYoutube\n .select(\"date_time, apn as group, avg(#{youtube_succ_rate}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time, :apn)\n .asc_date_time\n .each do | d|\n results << d\n end\n\n MetricSpeedtest\n .select(\"date_time, apn as group, avg(#{speedtest_dl_2m_rate}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time, :apn)\n .asc_date_time\n .each do | d|\n results << d\n end\n\n\n\n elsif (stack == 'RNC')\n MetricHttp\n .select(\"date_time, rncname as group, avg(#{metric_attr}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time, :rncname)\n .asc_date_time\n .each do | d|\n results << d\n end\n\n\n\n else \n MetricHttp\n .select(\"date_time, avg(#{metric_attr}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time)\n .asc_date_time\n .each do | d|\n t = d.attributes\n t[\"service\"] = \"HTTP\"\n results << t\n end\n\n # MetricHttp.twitter\n # .select(\"date_time, avg(#{metric_attr}) as value\")\n # .region(region)\n # .site(site)\n # .apn(apn)\n # .sgsn(sgsn)\n # .start(start)\n # .stop(stop)\n # .group(:date_time)\n # .asc_date_time\n # .each do | d|\n # t = d.attributes\n # t[\"service\"] = \"twitter\"\n # results << t\n # end\n\n # MetricHttp.instagram\n # .select(\"date_time, avg(#{metric_attr}) as value\")\n # .region(region)\n # .site(site)\n # .apn(apn)\n # .sgsn(sgsn)\n # .start(start)\n # .stop(stop)\n # .group(:date_time)\n # .asc_date_time\n # .each do | d|\n # t = d.attributes\n # t[\"service\"] = \"instagram\"\n # results << t\n # end\n\n MetricPing\n .select(\"date_time, avg(#{avg_rtt_succ_rate}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time)\n .asc_date_time\n .each do | d|\n t = d.attributes\n t[\"service\"] = \"Ping\"\n results << t\n end\n\n MetricYoutube\n .select(\"date_time, avg(#{youtube_succ_rate}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time)\n .asc_date_time\n .each do | d|\n t = d.attributes\n t[\"service\"] = \"Youtube\"\n results << t\n end\n\n MetricSpeedtest\n .select(\"date_time, avg(#{speedtest_dl_2m_rate}) as value\")\n .region(region)\n .site(site)\n .apn(apn)\n .sgsn(sgsn)\n .start(start)\n .stop(stop)\n .group(:date_time)\n .asc_date_time\n .each do | d|\n t = d.attributes\n t[\"service\"] = \"Speedtest\"\n results << t\n end\n\n end\n\n respond_with results\n\n end", "def histogram(params = {})\n params[:name] ||= File.join(@pictureName.gsub(\".png\", \"Histogram.html\"))\n bins = Hash.new(0)\n \n (0...@picture.height).each do |j|\n (0...@picture.width).each do |i|\n r = ChunkyPNG::Color.r(@picture[i,j])\n g = ChunkyPNG::Color.g(@picture[i,j])\n b = ChunkyPNG::Color.b(@picture[i,j])\n \n op = 0.241 * r**2 + 0.691 * g**2 + 0.68 * b**2\n val = Math.sqrt(op).round\n val /= 13\n \n bins[val] += 1\n end\n end\n \n bins = Hash[ bins.map { |k,v| [k * 13, v] }.sort ]\n graph(bins, params[:name])\n end", "def get_random_image( )\n\n print \"getting image... \"\n\n dest_file = \"#{File::SEPARATOR}tmp#{File::SEPARATOR}#{SecureRandom.hex( 5 )}.jpg\"\n Net::HTTP.start( \"lorempixel.com\" ) do |http|\n resp = http.get(\"/640/480/cats/\")\n open( dest_file, \"wb\" ) do |file|\n file.write( resp.body )\n end\n end\n puts \"done\"\n return dest_file\n\n end", "def robot_image_generator\n img_base_url = 'https://robohash.org/'\n @robot.img_sm = img_base_url + @robot.robot_name + '?size=80x80'\n @robot.img_lg = img_base_url + @robot.robot_name + '?size=300x300'\n end", "def fetch\n http_request(url) do |body|\n incidents = JSON.parse body\n\n counts = {}\n total = incidents[\"resourceSets\"].first[\"estimatedTotal\"]\n resources = incidents[\"resourceSets\"].first[\"resources\"]\n resources.each do |resource|\n severity = resource[\"severity\"]\n counts[severity] = (counts.fetch severity, 0) + 1\n end\n\n @data = {}\n counts.each do |severity, count|\n @data[severity_label(severity)] = count\n end\n end\n end", "def make_pie_chart\n\t\trequire 'gruff'\n \t\ta = Sha.group(\"filetype\").count\n\n \t\tg = Gruff::Pie.new\n \t\tg.title = 'Filetypes'\n \n \t\ta.each do |key, value|\n \t\t puts g.data(key, a[key])\n \t\tend\n\n\t\t g.write('app/assets/images/pie.png')\n\tend", "def index\n if params[:visit_id]\n @visit = Visit.find(params[:visit_id])\n @search = @visit.image_datasets.search(params[:search])\n @image_datasets = @search.relation.page(params[:page]).per(50).all\n @total_count = @image_datasets.count\n @page_title = \"All Image Datasets for Visit #{@visit.rmr}\"\n else\n # @image_datasets = ImageDataset.find_all_by_visit_id(params[:visit_id])# .paginate(:page => params[:page], :per_page => PER_PAGE)\n # @visit = Visit.find(params[:visit_id])\n # @total_count = @image_datasets.count\n # @page_title = \"All Image Datasets for Visit #{@visit.rmr}\"\n # else\n @search = ImageDataset.search(params[:search])\n \n # Set pagination and reporting options depending on the requested format\n # (ie Don't paginate datasets on CSV download.)\n if params[:format]\n @image_datasets = @search.relation\n \n # Eventually, we'll be able to set exactly what we want included in the \n # report from the web interface. For now, we'll do it programatically \n # here in the controller.\n light_include_options = :image_dataset_quality_checks\n heavy_include_options = {\n :image_dataset_quality_checks => {:except => [:id]},\n :visit => {:methods => :age_at_visit, :only => [:scanner_source, :date], :include => {\n :enrollments => {:only => [:enumber], :include => { \n :participant => { :methods => :genetic_status, :only => [:gender, :wrapnum, :ed_years] }\n }}\n }}\n }\n else\n @image_datasets = @search.relation.page(params[:page])\n end\n \n # @total_count = all_images.size # I'm not sure where this method is coming from, but it's breaking in ActiveResource\n @total_count = ImageDataset.count\n @page_title = \"All Image Datasets\"\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :text => @image_datasets.to_xml(:except => [:dicom_taghash])}\n format.csv { render :csv => ImageDataset.csv_download(@image_datasets, heavy_include_options) }\n end\n end", "def show_image # :nologin: :prefetch:\n store_location\n if @image = find_or_goto_index(Image, params[:id].to_s, :include => [\n :copyright_changes,\n :image_votes,\n :license,\n {:observations => [:comments, :name]},\n :projects,\n :user,\n ])\n @is_reviewer = is_reviewer\n pass_query_params\n\n # Decide which size to display.\n @default_size = @user ? @user.image_size : :medium\n @size = params[:size].blank? ? @default_size : params[:size].to_sym\n\n # Make this size the default image size for this user.\n if @user and (@default_size != @size) and\n (params[:make_default] == '1')\n @user.image_size = @size\n @user.save_without_our_callbacks\n @default_size = @size\n end\n\n # Wait until here to create this search query to save server resources.\n # Otherwise we'd be creating a new search query for images for every single\n # show_observation request. We know we came from an observation-type page\n # because that's the only time the 'obs' param will be set (with obs id).\n obs = params[:obs]\n if !obs.blank? &&\n # The outer search on observation won't be saved for robots, so no sense\n # in bothering with any of this.\n !is_robot?\n obs_query = find_or_create_query(:Observation)\n obs_query.current = obs\n img_query = create_query(:Image, :inside_observation,\n :observation => obs, :outer => obs_query)\n set_query_params(img_query)\n end\n\n # Cast user's vote if passed in 'vote' parameter.\n if @user and\n (val = params[:vote]) and\n (val == '0' or (val = Image.validate_vote(val)))\n val = nil if val == '0'\n cur = @image.users_vote\n if cur != val\n anon = @user.votes_anonymous == :yes\n @image.change_vote(@user, val, anon)\n Transaction.put_images(:id => @image, :set_vote => val, :set_anonymous => anon)\n end\n\n # Advance to next image automatically if 'next' parameter set.\n if params[:next]\n query = find_or_create_query(Image)\n query.current = @image\n if query.index(@image) and\n (query = query.next)\n @image = query.current\n end\n end\n end\n\n # Grab list of votes.\n @votes = @image.image_votes(:include => :user).sort_by do |v|\n (v.anonymous ? :anonymous.l : v.user.unique_text_name).downcase\n end\n\n # Update view stats on image we're actually showing.\n update_view_stats(@image)\n end\n end", "def stats\n \n end", "def fetch_content( collage )\n\n app_config = Rails.application.config_for( :customization )\n path = collage.path\n query = collage.query\n if json?( query )\n query = JSON.parse( query )\n query_type = query[ 'instagram' ][ 'type' ]\n query_string = query[ 'instagram' ][ 'query_string' ]\n end\n max_items = app_config[ 'collages_max_items_to_retrieve' ]\n index = 0\n\n # the following code goes to instagram and scrapes image data from\n # the page.\n # create a headless browser\n b = Watir::Browser.new :phantomjs\n uri = 'https://www.instagram.com/explore/tags/' + query_string.to_s\n uri = 'https://www.instagram.com/' + query_string.to_s if query_type == 'user'\n b.goto uri\n\n # all data are stored on this page-level object.\n o = b.execute_script( 'return window._sharedData;')\n o = extract_insta_data( o, query_type )\n\n data = o[ 'data' ]\n has_next_page = o[ 'has_next_page' ]\n max_id = o[ 'max_id' ]\n\n data.each { |item|\n break if index >= max_items\n url = item[ 'thumbnail_src' ]\n image = MiniMagick::Image.open( url )\n index += 1 if crop_and_save_collage_image( image, index, path, collage )\n }\n\n while( has_next_page && (index < max_items) )\n uri = 'https://www.instagram.com/explore/tags/' + query_string.to_s\\\n + '?&max_id=' + max_id.to_s\n uri = 'https://www.instagram.com/' + query_string.to_s + '?&max_id='\\\n + max_id.to_s if query_type === 'user'\n b.goto uri\n o = b.execute_script( 'return window._sharedData;')\n o = extract_insta_data( o, query_type )\n data = o[ 'data' ]\n has_next_page = o[ 'has_next_page' ]\n max_id = o[ 'max_id' ]\n\n data.each { |item|\n break if index >= max_items\n url = item[ 'thumbnail_src' ]\n image = MiniMagick::Image.open( url )\n index += 1 if crop_and_save_collage_image( image, index, path, collage )\n }\n end\n b.close # IMPORTANT!\n rescue\n Rails.logger.info 'collages_helper - fetch_content() - Error scraping Instagram.'\n b.close\n end", "def get_all_tracking_pixels_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TrackingControllerApi.get_all_tracking_pixels ...'\n end\n allowable_values = [\"ASC\", \"DESC\"]\n if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])\n fail ArgumentError, \"invalid value for \\\"sort\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/tracking/pixels'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?\n query_params[:'searchFilter'] = opts[:'search_filter'] if !opts[:'search_filter'].nil?\n query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?\n query_params[:'before'] = opts[:'before'] if !opts[:'before'].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(['*/*'])\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] || 'PageTrackingPixelProjection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['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: TrackingControllerApi#get_all_tracking_pixels\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def output_image\n @image.each do |image|\n puts image.join(' ')\n end\n end", "def classify_image\n\n\t\trequire 'rubygems'\n\t\trequire 'RMagick'\n\t\trequire \"open-uri\"\n\n\t\timagelist = Magick::ImageList.new # not sure why using ImageList and not an Image, but thats the example. can try rewrite \n\t\turlimage = open(params[:url]) # Image URL \n\t\timagelist.from_blob(urlimage.read)\n\t\timage = imagelist.cur_image\n\n\tputs \"image opened, color coding\"\n\n\t\tcolorcodes = {\n\t\t\t:red => [255,0,0],\n\t\t\t:green => [0,255,0],\n\t\t\t:blue => [0,0,255],\n\t\t\t:yellow => [255,255,0],\n\t\t}\n\t\t@colors = {}\n\t\t@classmodel = ClassModel.find params[:classmodel]\n\t\tclassnames = @classmodel.classnames.split(',') # user-supplied classes; \n\t\tclassnames.each_with_index do |classname,index|\n\t\t\t@colors[classname] = colorcodes.to_a[index]\n\t\tend\n\n\tputs \"assembling classes\"\n\n\t\tclasses = ClassModel.find(params[:classmodel]).to_hash\n\n\tputs \"parsing pixels and writing new pixels\"\n\n\t\t@percentages = {}\n\t\tclasses.each do |classname,classbands|\n\t\t\t@percentages[classname] = 0\n\t\tend\n\n\t\t# this can also surely be more efficient, look at: http://www.simplesystems.org/RMagick/doc/image2.html#import_pixels\n\t\t(0..image.columns-1).each do |x|\n\t\t\t(0..image.rows-1).each do |y|\n\t\t\t\t# classify the pixel\n\t\t\t\t# first, extract a JSON string of the colors... inefficient but a start:\n\t\t\t\ta = image.export_pixels(x, y, 1, 1, \"RGB\");\n\t\t\t\tpixel_string = {\"red\" => a[0]/255,\"green\" => a[1]/255,\"blue\" => a[2]/255} # MaxRGB is 255^2\n\t\t\t\t\t#puts pixel_string\n\t\t\t\tclosest = CartesianClassifier.closest_hash(pixel_string,classes)\n\t\t\t\t\t#puts closest\n\t\t\t\t@percentages[closest] += 1\n\t\t\t\t# match the resulting class to a color and write to a pixel\n\t\t\t\ta = colorcodes[@colors[closest][0]].map { |c| c*255 } #MaxRGB is 255^2\n\t\t\t\timage.import_pixels(x, y, 1, 1, \"RGB\", a);\n\t\t\tend\n\t\tend\n\n\t\t@percentages.each do |key,value|\n\t\t\t@percentages[key] = (100*((1.00 * value) / (image.rows*image.columns))).to_i\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.html { \n\t\t\t\t@b64 = Base64.encode64(image.to_blob)\n\t\t\t}\n\t\t\tformat.png { \n\t\t\t\theaders['Content-Type'] = 'image/png'\n\t\t\t\theaders['Cache-Control'] = 'public'\n\t\t\t\theaders['Expires'] = 'Mon, 28 Jul 2020 23:30:00 GMT'\n\t\t\t\trender :text => image.to_blob\n\t\t\t}\n\t\tend\n\tend", "def add_result_stats(base, _opts)\n MiGA::Result.new(\"#{base}.json\")\n end", "def find_normal_image\n return \"Pictures/pcn%04d.png\" % (80 + id)\n end", "def thumbnail\n\n image = Rails.cache.fetch(\"/image_thumbnail/#{params[:id]}\", :expires_in => 10.minutes) do\n puts \"miss!\"\n user_client.thumbnail(params[:id], min_height: 256, min_width: 256)\n end\n\n send_data image, :type => 'image/png', :disposition => 'inline'\n end", "def profile_img(uid, type=\"normal\")\n \"http://graph.facebook.com/#{uid}/picture?type=#{type}\"\n end", "def show\n @image_dataset = ImageDataset.find(params[:id])\n @visit = @image_dataset.visit\n @image_datasets = @visit.image_datasets\n \n @image_comment = ImageComment.new\n @image_comments = @image_dataset.image_comments\n @next_image_dataset = @image_datasets[@image_datasets.index(@image_dataset) + 1 ]\n @previous_image_dataset = @image_datasets[@image_datasets.index(@image_dataset) - 1 ]\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image_dataset }\n end\n end", "def describe_image(image)\n puts \"#{image[:name]} is #{image[:width]}px * #{image[:height]}px\"\nend", "def create_advanced\n image_service = ImageGeneratingService.new(self, 'Advanced.jpg', 'image/jpeg', 69)\n output_path = image_service.generate\n original_size_mb = File.size(output_path).to_f / 2**20\n if original_size_mb > 1.0\n image_service.generate_resized(1200)\n end\n end", "def print\n Catpix::print_image self.url,\n :limit_x => 0.2,\n :limit_y => 0,\n :center_x => false,\n :center_y => false,\n :bg => \"white\",\n :bg_fill => false \n end", "def perform(druid)\n druid_obj = Dor.find(druid)\n original_uri = get_original_uri(druid_obj.datastreams['descMetadata'].ng_xml)\n druid_id = druid_obj.id.split(':').last\n send_to_thumbnail_generator(druid_id, original_uri)\n end", "def test_06b\r\n db = build\r\n db.fetch('image-1.jpg',:width => 102)\r\n db.fetch('image-1.jpg',:width => 103)\r\n db.fetch('image-1.jpg',:width => 104)\r\n db.fetch('image-1.jpg',:height => 105)\r\n r = db.image('image-1.jpg')\r\n assert_equal 'image-1.jpg',r[:original]\r\n end", "def generate_images\n Docsplit.extract_images(@files.to_s)\n end", "def print_totdist(io, run)\n\n io.puts \"<h3>ToT distributions</h3>\"\n io.puts \"<div style=\\\"text-align: center;\\\">\"\n io.puts \"<table>\"\n (1..$mod).each { |row|\n io.puts \" <tr>\"\n (1..$pad).each { |col|\n ch = $off + $pad*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/tot#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/tot#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n io.puts \"</div>\"\n\nend", "def cached_stats\n generate 'sufia:cached_stats'\n end", "def info( options =nil )\n json = request 'images.getInfo', options, :ImageID => image_id, :ImageKey => key\n \n image = upper_hash_to_lower_hash( json['Image'] )\n image.merge!( :image_id => image[\"id\"] )\n \n OpenStruct.new( image ) \n end", "def show\n if @food.counter == nil\n @food.update_attribute(:counter, 1)\n else\n @food.update_attribute(:counter, @food.counter+1)\n end\n #send_data(Base64.decode64(@food.image.data), :type => @food.image.mime_type, :filename => @food.image.filename, :disposition => 'inline')\n end", "def get_image_info(img_uid)\n @client.post \"/service_json_ssl.svc/GetImageInfo\", {img_uid:img_uid}\n end", "def create_image_object(obj)\n return content_tag(:div, tag(:img, :src => obj.link), :style => \"position:absolute; top: #{obj.y}px; left: #{obj.x}px;\")\n end", "def create image_url, page_url, x, y, h, w\n #@img = Img.create(image_url: image_url, page_url: page_url, x: x, y: y, h: h, w: w)\n end", "def display id\n get_image(id).display\n end", "def get_softwarerepository_cached_image_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SoftwarerepositoryApi.get_softwarerepository_cached_image_by_moid ...'\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 SoftwarerepositoryApi.get_softwarerepository_cached_image_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/softwarerepository/CachedImages/{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', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\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] || 'SoftwarerepositoryCachedImage'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"SoftwarerepositoryApi.get_softwarerepository_cached_image_by_moid\",\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: SoftwarerepositoryApi#get_softwarerepository_cached_image_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_img\n images = @driver.find_elements(tag_name: 'img')\n progress_length = (images.length) -2\n progress_bar = ProgressBar.create(:title => \"Progress\", :total => progress_length, :length => 80)\n dir_path = \".\"\n dir_path = \"#{@current_title}\" if @mkdir\n if not Dir.exists? dir_path\n Dir.mkdir dir_path\n end\n index = 0\n images.each do |img|\n if index > 0 and index < images.length - 1\n scrn_dir = \"#{@global_count}_#{index}.png\"\n scrn_dir = \"#{dir_path}/#{index}.png\" if @mkdir\n img.save_screenshot scrn_dir\n @img_list << scrn_dir\n progress_bar.increment\n end\n index += 1\n end\n end", "def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end", "def generate_statistics_from_nif(entity_types, count = 10, demand_reload = false)\n unless @nif_file_path\n raise RuntimeError.new('Instance has no defined return nif_dataset_path. Can not start generate from nif datset. Please create new instance.')\n end\n\n resources = get_best_ranked_resources(entity_types, count)\n resources = keep_unloaded(resources) unless demand_reload\n\n actual_resource_data = []\n lines_group = []\n\n begin\n time_start = Time.now\n nif_file = File.open(@nif_file_path, 'r')\n line = nif_file.readline\n\n until nif_file.eof?\n line = nif_file.readline\n\n if lines_group.size == 7\n # evaulate group (7 lines)\n this_resource_uri = NIFLineParser.parse_resource_uri(lines_group[0])\n\n if resources.keys.include?(this_resource_uri)\n # process group, is requested\n resource_uri = this_resource_uri\n actual_resource_data << NIFLineParser.parse_line_group(lines_group)\n\n elsif !actual_resource_data.empty?\n # resource changed, process actual_resource_data\n resource_hash = resources.delete(resource_uri)\n type = resource_hash[:type]\n\n this_time = (Time.now - time_start).round(2)\n puts \"\\n#{resource_uri}\\n- nif found in #{this_time}\\n- resources to find #{resources.size}\" if @console_output\n\n result_relations = find_relations(resource_uri, actual_resource_data, type)\n generate_result_file(resource_uri, type, result_relations, this_time)\n\n actual_resource_data = []\n time_start = Time.now\n end\n\n # start new group\n lines_group = [line]\n else\n\n # join line to group\n lines_group << line\n end\n\n break if resources.empty?\n end\n\n ensure\n nif_file.close if nif_file && !nif_file.closed?\n end\n end", "def fetch\n end", "def pull_image(value)\n user_hash = pull_records(value)\n id = user_hash[0][\"id\"]\n image_name = user_hash[0][\"image\"]\n image = \"images/uploads/#{id}/#{image_name}\"\nend", "def output_image\n @image_array.each do |e|\n puts e.join\n end\n end", "def output_image\r\n # loop continues through each Row and outputs content\r\n puts \"Original Image\"\r\n @array.each do |row|\r\n puts row.join\r\n end\r\n end" ]
[ "0.5667243", "0.5641356", "0.55593824", "0.5435218", "0.53880805", "0.53696626", "0.53649914", "0.536338", "0.5345917", "0.53441507", "0.5323299", "0.532244", "0.53213435", "0.5309056", "0.53035444", "0.5246989", "0.5244687", "0.523554", "0.523322", "0.52300507", "0.52249205", "0.5206865", "0.5195091", "0.5184307", "0.51616055", "0.51610374", "0.5150026", "0.5149744", "0.51459795", "0.5122149", "0.51205474", "0.5103988", "0.5103023", "0.51022863", "0.5096558", "0.50906366", "0.5089513", "0.5085807", "0.5083541", "0.5082763", "0.50825065", "0.5078057", "0.5070635", "0.5050952", "0.50450957", "0.50436276", "0.5038242", "0.5036099", "0.5024322", "0.5023601", "0.50178087", "0.5003764", "0.49954483", "0.49935415", "0.4990881", "0.49886516", "0.4986981", "0.4986981", "0.4984293", "0.49814", "0.4981215", "0.49789166", "0.4978263", "0.4970363", "0.4968176", "0.49646387", "0.49594578", "0.49584714", "0.4955482", "0.4950796", "0.49446175", "0.49396944", "0.49368316", "0.49293333", "0.49287024", "0.49261093", "0.492267", "0.49173447", "0.49125814", "0.49095106", "0.49047306", "0.49039224", "0.4902741", "0.48995942", "0.4898806", "0.4882277", "0.48780555", "0.48752752", "0.48747355", "0.48730177", "0.48729327", "0.486853", "0.48664767", "0.4864722", "0.4861407", "0.48587337", "0.48544767", "0.48518488", "0.48427194", "0.48419282" ]
0.5662734
1
Excerpted from "Everyday Scripting in Ruby" We make no guarantees that this code is fit for any purpose. Visit for more book information.
def convert_to_integer(string) unless /^-?\d+$/ =~ string raise "'#{string}' is not an integer." #(1) end string.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def herald; end", "def program; end", "def main; end", "def probers; end", "def jack_handey; end", "def schubert; end", "def hiss; end", "def code_like_crazy\r\n puts \"I'm crushing some code!\"\r\n end", "def p15\n\t\nend", "def p003rubystrings\n\tputs \"Hello World\"\n\t\n\t# CAn use \" or '. But, ' is more effective\n\tputs 'Hello WOrld'\n\n\t#String concatenate\n\tputs \"I like\" + \" Ruby\"\n\n\t#Escape Sequence\n\tputs 'It\\'s my Ruby'\n\n\t#New here displays the string 3 times\n\tputs 'Hello' * 3\n\n\tputs PI\n\n\t#USe of back-tick\n\tputs \"LIsting of files\"\n\tputs `ls`\n\n\tsystem (\"ls\")\n\nend", "def stderrs; end", "def gounod; end", "def villian; end", "def terpene; end", "def bellini; end", "def weird_stuff\n puts \"Mussolini apparently liked to eat raw garlic, although he suffered\n from severe stomach ulcers. He also had many Jewish friends, and didn't like\n Hitler very much. Yeah right!\"\n #sleep(20)\n puts \"Idi Amin gave himself the title His Excellency, President for Life Field\n Marshall Al Hadj Doctor Idi Amin Dada, VC, DSO, MC, Lord of all the Beasts\n of the Earth and Fishes of the Sea and Conqueror of the British Empire in\n Africa in General and Uganda in particular.\"\n #sleep(20)\n puts \"Adolf Hitler thought of himself as a pacifist. He was a vegetarian.\n It is said that he injured his groin during World War I, and his left\n testicle was removed. Hitler enjoyed watching Charley Chaplin, who made fun\n of Hitler.\"\n #sleep(20)\n puts \"Stalin was also the man behind the most wicked practical joke ever\n played. Being a very private man he gave the order that no person should\n enter his bed chambers on pain of death. Later, while in his chambers he\n decided to test whether his guards had listened to this instruction.\n Pretending to scream in pain, he called for the guards stationed outside\n the door. Fearing that their leader was in trouble the guards burst into\n the room. Stalin had them executed for failing to follow his standing orders.\n This little prank soon backfired, however, when Stalin suffered a seizure\n while alone in his bedroom. The guards were too afraid to enter, finding\n him hours later laid in a puddle of stale urine. He died three days later.\"\n #sleep(30)\n puts \"Niyazov loved to rename things. For example, he renamed the month of\n January Turkmenbashi, which means Father of the Turkmen, a name he gave\n himself. He also 'legislated' the renaming of the days of the week to ones\n that translate to 'Young Day', 'Spirituality Day', etc. He even renamed the\n word 'bread', Gurbansoltan, after his own mother. Niyazov outlawed beards on\n men and cosmetics on TV anchors, and prohibited both chewing tobacco and lip-\n syncing on Turkmenistan soil. In a society of smokers, Niyazov recommended\n that people chew on bones, which he argued would strengthen their teeth. He\n authored a book, the Book of the Soul, and ordered students in schools and\n mosques to read and study it, and in the case of mosques, to give it equal\n respect to the Quran (and if not, the mosque would be demolished). To get a\n driver's license, people had to memorize the contents of the book. Finally,\n Niyazov told everyone that he had made a pact with G-d that anyone who read\n his book three times would go to heaven. In 2005, he ordered a copy of his\n book to be sent to outer space.\"\n #sleep(60)\n puts \"Mussolini apparently liked to eat raw garlic, although he suffered\n from severe stomach ulcers. He also had many Jewish friends, and didn't like\n Hitler very much. Yeah right!\"\n #sleep(10)\n puts \"He gave himself the title His Excellency, President for Life Field\n Marshall Al Hadj Doctor Idi Amin Dada, VC, DSO, MC, Lord of all the Beasts\n of the Earth and Fishes of the Sea and Conqueror of the British Empire in\n Africa in General and Uganda in particular.\"\n end", "def how_it_works\r\n end", "def hello_world # \"def\" is short for \"defining a method\" and we are\n # defining a method called \"hello_world\"\n\n puts \"Hello World!\" # \"puts\" is used to print a value, which in our\n # our case is \"Hello World!\"\n\nend", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def anchored; end", "def berlioz; end", "def king_richard_iii; end", "def main\n\n end", "def hello(name, age)\n\tputs \"Welcome #{name}, #{age} is definitely not too old to learn how to code\" \nend", "def main\n\n #\n # In Ruby, everything is an expression, even the control structures.\n #\n\n #\n # if, else, elsif\n #\n # The value that results from evaluating an if expression is the\n # value of the last expression in the code that was executed, or\n # nil if no block of code is executed.\n #\n \n x = 3\n\n if x == 1\n name = \"one\"\n elsif x == 2\n name = \"two\"\n elsif x == 3\n name = \"three\"\n elsif x == 4\n name = \"four\"\n else\n name = \"many\"\n end\n\n puts name\n\n # here is another way to write the above if expression\n\n if x == 1\n name = \"one\"\n elsif x == 2\n name = \"two\"\n elsif x == 3 then name = \"three\"\n elsif x == 4 ; name = \"four\"\n else\n name = \"many\"\n end\n\n puts name\n\n # here is another way to write the above if expression\n\n name = if x == 1 then \"one\"\n elsif x == 2 then \"two\"\n elsif x == 3 then \"three\"\n elsif x == 4 then \"four\"\n else \"many\"\n end\n\n puts name\n\n # for single-line conditionals: use \"if\" as a modifier\n y = x.odd? if x.respond_to?(:odd?)\n puts y\n \n #\n # unless is the opposite of if. unless executes code only if associated\n # expression evaluates to false or nil. elsif clauses are not allowed.\n #\n x = 10\n unless x == 0\n puts \"x is not 0\"\n else\n puts \"x is 0\"\n end\n \n # for single-line conditionals: use \"unless\" as a modifier\n s = x.to_s unless x.nil?\n puts s\n \n #\n # case statement is a multiway conditional. Like if, case returns a value\n #\n x = 5\n case x\n when 1\n name = \"one\"\n when 2\n name = \"two\"\n when 3\n name = \"three\"\n when 4\n name = \"four\"\n else # optional\n name = \"many\"\n end\n puts name\n \n # since case returns a value, here is another way to write the above case\n name = case x\n when 1\n \"one\"\n when 2\n \"two\"\n when 3\n \"three\"\n when 4\n \"four\"\n else \"many\"\n end\n puts name\n \n #\n # Ruby has three looping statements: while, until, and for/in.\n #\n x = 10\n while x >= 0 do\n puts x\n x -= 1\n end\n puts\n \n # above code using until\n x = 10\n until x < 0 do\n puts x\n x -= 1\n end\n puts\n \n # while as a modifier\n x = 0\n puts x = x + 1 while x < 10\n puts\n \n # until as a modifier\n x = 0\n puts x = x + 1 until x == 10\n puts\n \n #\n # for/in loop is used to iterate through the elements of an enumerable object\n #\n for i in 1..10 do\n print i, \" \"\n end\n print \"\\n\\n\"\n \n # print elements in an array\n a = [5, 10, 15, 20, 25]\n for e in a do\n print e, \" \"\n end\n print \"\\n\\n\"\n \n # print keys and values in a hash\n h = {:a => 1, :b => 2, :c => 3}\n for key,value in h\n puts \"#{key} => #{value}\"\n end\n puts\n \nend", "def private; end", "def sld; end", "def returns; end", "def slop!; end", "def slop!; end", "def main\n end", "def who_we_are\r\n end", "def r; end", "def r; end", "def main()\n puts(\"Hello, Ruby.\")\n\nend", "def y; end", "def y; end", "def y; end", "def rossini; end", "def scientist; end", "def suivre; end", "def program() @program end", "def statement; end", "def buzzword; end", "def buzzword; end", "def strain; end", "def schumann; end", "def code_point; end", "def spice; end", "def pass; end", "def pass; end", "def code_point=(_); end", "def does\n puts \"ALL THE THINGESSSS!!!eleventy\"\nend", "def verdi; end", "def introduction # def opens a function/ method\n\tputs \"This is an introduction program to ruby.\" # puts includes \\n newline before displaying a string\n\tputs \"If you entered this from the command line it would have looked something like this...\"\n\tputs \"\\n\\t$\\t#{$0}\" # \"#{$0}\"\" displays the script ran from the command line. \nend", "def compliment_machine(name)\nputs \"Hey there, #{name}! Lookin' good today!\"\nputs \"Is that a new face? It looks nice!\"\nend", "def sharp; accidental; end", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def issn; end", "def boring_parrot(statement)\n statement\nend", "def shout(word)\n# irb(main):012:1> \nreturn \"HOLA\"\n# irb(main):013:1> \nend", "def faint; end", "def faint; end", "def script; end", "def script; end", "def ibu; 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 most_interesting_man_in_the_world; end", "def runtime; end", "def demon; end", "def bizet; end", "def lines_of_code; end", "def lines_of_code; end", "def s(x); 1; end", "def g; end", "def g; end", "def greet\n hello + \" \" + world # this format allows us to use puts on line 31\nend", "def main\n\n # Print the heading. Note the highly advanced lower-case letters.\n puts ' '*33 + \"Bunny\"\n puts ' '*15 + \"Creative Computing Morristown, New Jersey\"\n\n # Print blank lines.\n print \"\\n\\n\\n\"\n\n # The positions to write; this is ripped from the BASIC program's\n # DATA statements.\n positions = [\n 1,2,-1,0,2,45,50,-1,0,5,43,52,-1,0,7,41,52,-1, \n 1,9,37,50,-1,2,11,36,50,-1,3,13,34,49,-1,4,14,32,48,-1,\n 5,15,31,47,-1,6,16,30,45,-1,7,17,29,44,-1,8,19,28,43,-1,\n 9,20,27,41,-1,10,21,26,40,-1,11,22,25,38,-1,12,22,24,36,-1,\n 13,34,-1,14,33,-1,15,31,-1,17,29,-1,18,27,-1,\n 19,26,-1,16,28,-1,13,30,-1,11,31,-1,10,32,-1,\n 8,33,-1,7,34,-1,6,13,16,34,-1,5,12,16,35,-1,\n 4,12,16,35,-1,3,12,15,35,-1,2,35,-1,1,35,-1,\n 2,34,-1,3,34,-1,4,33,-1,6,33,-1,10,32,34,34,-1,\n 14,17,19,25,28,31,35,35,-1,15,19,23,30,36,36,-1,\n 14,18,21,21,24,30,37,37,-1,13,18,23,29,33,38,-1,\n 12,29,31,33,-1,11,13,17,17,19,19,22,22,24,31,-1,\n 10,11,17,18,22,22,24,24,29,29,-1,\n 22,23,26,29,-1,27,29,-1,28,29,-1,\n ]\n\n # The text we're writing.\n text = \"BUNNY\"\n\n # Draw the bunny.\n last_pos = 0\n while positions.size > 0\n first = positions.shift\n\n # If we've found -1, start a new line\n if first == -1\n puts\n last_pos = 0\n next\n end \n\n # Advance to start of the range\n print ' '*(first - last_pos)\n last_pos = first\n\n # Now, draw pixels:\n second = positions.shift\n for i in first .. second\n print text[i % text.size] # choose the letter according to the column\n last_pos += 1\n end\n end\n\n # Print the final blank line\n puts\nend", "def bye; end", "def my_first_interpreter code\n # Implement your interpreter here\n text = ''\n count = 0\n x = 0\n while x < code.length do \n if code[x] == '+'\n count += 1\n elsif code[x] == '.'\n text << count.chr\n end\n if count >= 256\n count = 0\n end\n x += 1\n end\n text\nend", "def p(string);end", "def basic_feature(str)\n\tputs str + \" \" + str\n\tputs str * 3\n\tputs \"1\" + \"2\"\n\tputs \"1\" * 2\n\tputs str.size\n\tputs str.length\n\tputs str.capitalize\n\tputs str.reverse\n\tputs str.upcase\n\tputs str.downcase\n\tputs str.swapcase\nend", "def algorithm=(_); end", "def algorithm=(_); end", "def algorithm=(_); end" ]
[ "0.62879074", "0.61298084", "0.5957766", "0.59353083", "0.59229153", "0.5814389", "0.57971877", "0.5789178", "0.5785706", "0.5734955", "0.57174236", "0.5608481", "0.5593764", "0.559197", "0.55728775", "0.5568986", "0.5566202", "0.55647683", "0.55463326", "0.55463326", "0.55463326", "0.55463326", "0.55463326", "0.55463326", "0.55463326", "0.55219537", "0.5506204", "0.55057293", "0.5499022", "0.548787", "0.5479629", "0.54767597", "0.54765815", "0.54655814", "0.54488754", "0.54488754", "0.54445195", "0.5442347", "0.54369044", "0.54369044", "0.5432306", "0.54292953", "0.54292953", "0.54292953", "0.5426835", "0.5425382", "0.54165053", "0.5408449", "0.54074436", "0.5406731", "0.5406731", "0.5399562", "0.538976", "0.53651035", "0.53628284", "0.53476095", "0.53476095", "0.5325018", "0.5320923", "0.5310941", "0.5309956", "0.52993405", "0.5297712", "0.5285065", "0.5285065", "0.5285065", "0.52805173", "0.5279543", "0.5268657", "0.52651143", "0.52651143", "0.5244846", "0.5244846", "0.52444947", "0.5244125", "0.5244125", "0.5244125", "0.5244125", "0.5244125", "0.5244125", "0.5244125", "0.5244125", "0.5244125", "0.52372503", "0.52310026", "0.52298075", "0.5225836", "0.5221322", "0.5221322", "0.521921", "0.5217071", "0.5217071", "0.52144104", "0.5213007", "0.5208195", "0.5204524", "0.5201789", "0.5198876", "0.519426", "0.519426", "0.519426" ]
0.0
-1
> compress [1, 1, 2, 3, 3, 3] => [1, 2, 3]
def compress(array) array.uniq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compress(list)\n list.zip(list[1..-1] + [nil]). # Zip with shifted list\n select {|a,b| a != b}. # Filter dups\n map {|a,b| a} # Unzip\nend", "def compress(array)\n prev = nil\n array.select {|v| v == prev ? false : prev = v}\nend", "def compress(data); end", "def compress!; end", "def compress_string(string)\n input_array = string.split(\"\")\n prev = input_array[0]\n count = 1\n output_array = []\n for i in 1..input_array.length-1\n if input_array[i] == prev \n count += 1\n else\n if count != 1 \n output_array << count\n end\n output_array << prev\n prev = input_array[i]\n count = 1\n end \n end\n if count != 1 \n output_array << count\n end \n output_array << prev\n return output_array.join\nend", "def destutter2(seq)\n result = [] #result will be a new array\n last = nil #keep track of last thing\n\n seq.each do |item|\n if item != last\n result.push(item)\n #result << item\n end\n last = item\n end\n result\nend", "def compress(wrd)\n new_wrd = \"\"\n char = wrd[0]\n count = 1\n (1..wrd.length).each do |i|\n if char != wrd[i]\n new_wrd += char\n new_wrd += count.to_s if count > 1\n count = 1\n else\n count += 1\n end \n char = wrd[i] \n end\n\n new_wrd\nend", "def compress(string) \n result = \"\"\n count = 0\n\n (0..(string.length - 2)).each do |i|\n count += 1\n if(string[i] != string[i + 1])\n result << \"#{string[i]}#{count}\"\n count = 0\n end\n end\n\n (result.length < string.length) ? result : string\n end", "def compress_str(str)\n\n new = []\n count = 1\n\n (0..str.length-1).each do |i|\n if str[i] == str[i+1]\n count += 1\n elsif str[i] != str[i+1]\n if count > 1\n new << count.to_s + str[i]\n count = 1\n else \n new << str[i]\n end\n end\n end\n new.join(\"\")\nend", "def pack_consecutive_duplicates\n self.inject([[]]) do |array, current|\n if array[-1][-1] == current or array[-1][-1].nil?\n array[-1] << current\n else\n array << [current]\n end\n array\n end\n \n end", "def compress(string)\n return string if string.length < 2\n compressed = \"\"\n\n i = 0\n while i < string.length\n\n counter = 1 # counter counts the number of repeated characters string[i]\n until string[i] != string[i+counter]\n counter += 1 # increments it as long as the current and next characters are identical\n end\n\n # we append to 'compressed' the current character + the counts of its repetition\n compressed << string[i] + counter.to_s\n i += counter # the looping goes to the next non repeated character\n end\n\n compressed\nend", "def compress(string)\n compressed_string = []\n count_consecutive = 0\n\n ##\n # Here is a simple counter: count_consecutiv will add 1 each time\n # next string letter is the same. If next array element is not the the same\n # will write letter and counter after the letter. Once it happened will set\n # counter back to 0.\n #\n for i in 0..string.length - 1\n count_consecutive +=1\n\n if string.chars[i] != string.chars[i+1]\n if count_consecutive == 1\n compressed_string << string.chars[i].to_s\n count_consecutive = 0\n else\n compressed_string << string.chars[i].to_s + count_consecutive.to_s\n count_consecutive = 0\n end\n end\n end\n compressed_string.join\nend", "def stringCompress(fullString)\n\n result = []\n\n fullString.each_char do |c|\n\n if result[-2] != c\n result << c << 1\n else\n result[-1] += 1\n end\n end\n\n if result.length < fullString.length\n result.join(\"\")\n else\n fullString\n end\n\nend", "def compress_string(string)\n array = string.chars\n array.each do |el|\n return el.times\n if el.time == 1\n one = el\n end\n return el.time + el\n end\nend", "def compress_str(str)\n compressed = \"\"\n count = 1\n (0..str.length-1).each do |idx|\n if str[idx] == str[idx+1]\n count += 1\n else\n if count == 1\n compressed += str[idx]\n else\n compressed += count.to_s + str[idx]\n count = 1\n end\n end\n end\n return compressed\nend", "def string_compress(string)\n original=string\n i=0\n while(i<string.length)\n j=i\n while (string[i]==string[j])\n j+=1\n end\n string[i..j-1]=\"#{string[i]}#{(j-i)}\"\n i+=2\n end\n return original if string.length>original.length \n return string\n \nend", "def compress(string)\n new_string = string.downcase\n compressed_string_length = count_compressed_length(new_string)\n return string if compressed_string_length > new_string.length\n\n compressed_string = \"\"\n count_consecutive = 0\n new_string.length.times do |i|\n count_consecutive += 1\n if(i+1 > new_string.length-1 || new_string[i] != new_string[i+1])\n compressed_string << new_string[i] << count_consecutive.to_s\n count_consecutive = 0\n end\n end\n return compressed_string\nend", "def compress(data)\n result = []\n data = data.slice!(0..80).downcase!\n carry = -1\n result_idx = 0\n\n data.length.times do |itr|\n char = data[itr]\n index = TRANSLATION_MAP.index(char) || 0\n index += 195 if index > 12\n\n if carry == -1\n if index < 13\n carry = index\n else\n result[result_idx += 1] = index\n end\n elsif index < 13\n result[result_idx += 1] = ((carry << 4) + index)\n carry = -1\n else\n result[result_idx += 1] = ((carry << 4) + (index >> 4))\n carry = index & 0xF\n end\n end\n\n result[result_idx += 1] = (carry << 4) if carry != -1\n result\n end", "def pack(a)\n\treps = Hash.new(1)\n prev = nil\n \n # filter out repeats\n a.select! {|v| prev == v ? (reps[v] += 1; false) : prev = v}\n \n # replace with nested arrays\n reps.each {|k, v| a[a.index k] = Array.new(v, k)}\n \n a\nend", "def recompress( unprocessed )\n emitted, residue=recompress_with_remainder( unprocessed )\n # There are a few cases where the buffer in the recompress method\n # still holds data that can be compressed, so we have to recurse \n # on the residue.\n until residue.empty?\n extra, residue=recompress_with_remainder( residue )\n emitted.push *extra\n emitted.push residue.shift unless residue.empty?\n end\n emitted\n end", "def compress_str(str)\n curr = str[0]\n new_str = \"\"\n len = 1\n (1..(str.length - 1)).each do |i|\n if str[i] == str[i - 1]\n len += 1\n else\n new_str += compressed(str[i - 1], len)\n len = 1\n end\n end\n new_str += compressed(str[-1], len)\nend", "def compress_str(str)\n compressed_str = \"\"\n c = 0\n (0...str.length).each do |i|\n c += 1\n if str[i] == str[i+1]\n next\n end\n compressed_str += c.to_s if c > 1 \n compressed_str += str[i]\n c = 0\n end\n compressed_str\nend", "def encode_modified(list)\n pack(list).map { |i| i.length > 1 ? [i.length,i.first] : i.first }\nend", "def compression; end", "def \t\tstringCompression(args)\n\ti = 1;\n\tarr = \"\";\n\tcount = 1;\n\tlen = args.length\n\twhile i < len + 1\n\t\tif args[i - 1] == args[i]\n\t\t\tcount += 1\n\t\telse\n\t\t\tarr << args[i - 1] << count.to_s\n\t\t\tcount = 1\n\t\tend\n\t\ti += 1\n\tend\n\tarr.size > len ? args : arr\nend", "def eliminate_consecutive_duplicates\n self.inject([]) do |array, current| \n array << current unless array[-1] == current\n array\n end\n end", "def compression; @store.compression; end", "def compress_string(string)\n str = ''\n start = 0\n (0..string.length).each do |i|\n next if string[start] == string[i]\n\n str << string[start] << (i - start).to_s\n start = i\n end\nend", "def compress(chars)\n return 1 if chars.size == 1\n hash = {}\n\n chars.each do |char|\n if hash[char]\n hash[char] += 1\n else\n hash[char] = 1\n end\n end\n\n answer = []\n hash.each do |key, value|\n if value == 1\n answer << key\n else\n if value > 9\n answer << key\n value.to_s.each_char do |char|\n answer << char\n end\n else\n answer << key\n answer << value.to_s\n end\n end\n end\n\n answer.size\nend", "def compress_str(str)\n\n new = \"\"\n count = 1\n\n (0..str.length-1).each do |i|\n if str[i] == str[i+1]\n count += 1\n elsif str[i] != str[i+1]\n if count > 1\n new += count.to_s + str[i]\n count = 1\n else \n new += str[i]\n end\n end\n end\n new\nend", "def consolidate_by_frequency(array)\n array.group_by{|x| x}.values.sort_by{|group| group.count}.reverse.flatten(1).uniq\nend", "def compressed\n require 'jsmin'\n @compressed ||= self.class.compress(combined)\n end", "def compress_str(str)\n compress = str.gsub(/(.)\\1*/).to_a\n hash = Hash.new(0)\n arr = []\n compress.each do |len|\n if len.length < 2\n arr << len\n else\n arr << len.length\n arr << len\n end\n end\n\n new_arr = arr.map {|a| a.to_s}\n\n new_arr.each_with_index do |compact, i|\n if compact.length > 1\n compact.each_char do |char|\n new_arr[i] = char\n end\n end\n end\n\nreturn new_arr.join(\"\")\n\nend", "def compress_str(str)\n new_str = ''\n count = 1\n (0..str.length - 1).each do |i|\n if str[i + 1] == str[i]\n count += 1\n else\n new_str << count.to_s if count > 1\n new_str << str[i]\n count = 1\n end\n end\n new_str\nend", "def compress_str(str)\n res = \"\"\n count = 0\n (0...str.length - 1).each do |idx|\n if str[idx] != str[idx + 1]\n if count > 0\n sub_res = (count + 1).to_s + str[idx]\n res += sub_res\n else\n res += str[idx]\n end\n count = 0\n else\n count += 1\n end\n end\n if count > 0\n sub_res = (count + 1).to_s + str[-1]\n res += sub_res\n else\n res += str[-1]\n end\n return res\nend", "def compress_str(str)\n res = \"\"\n count = 0\n (0...str.length - 1).each do |idx|\n if str[idx] != str[idx + 1]\n if count > 0\n sub_res = (count + 1).to_s + str[idx]\n res += sub_res\n else\n res += str[idx]\n end\n count = 0\n else\n count += 1\n end\n end\n if count > 0\n sub_res = (count + 1).to_s + str[-1]\n res += sub_res\n else\n res += str[-1]\n end\n return res\nend", "def run_length_encode\n self.pack_consecutive_duplicates.inject([]) do |array, current|\n array << [current.size, current[0]]\n array \n end\n end", "def custom_uniq(array)\n final = []\n array.each do |element|\n final << element if !final.include?(element)\n end \n final\nend", "def compress(input)\n unused_chars = []\n subst_characters = (' ' .. '~').to_a.reverse\n subst_characters.each do |char|\n # substitution characters must be safe from RegExp point of view\n next if ['|', '\\\\', '[', ']', '?', '+', '*', '(', ')', '.', '^', '\\'', '$', '{', '}'].include?(char)\n unused_chars.push(char) if !input.include?(char)\n end\n subst_map = {}\n compressed = input\n prev_compressed = ''\n while (unused_chars.size > 0) do\n prev_compressed = compressed\n compressed = substitute_chars(compressed, unused_chars, subst_map)\n break if prev_compressed == compressed\n end\n subst_map.keys.reverse.each do |char|\n compressed << \"|#{char}#{subst_map[char]}\"\n end\n return compressed\nend", "def compress_str(str)\n group = []\n str.each_char do |c|\n if group.empty?\n group.push([c])\n elsif c == group.last[0]\n group.last.push(c)\n else\n group.push([c])\n end\n end\n compressed = ''\n group.each do |el|\n if el.length > 1\n compressed = compressed + el.length.to_s + el[0]\n else\n compressed += el[0]\n end\n end\n compressed\nend", "def remove_duplicates(array)\nend", "def unique_in_order(x)\r\n a = (x.class == String ? x.chars : x ).chunk { |i| i }\r\n a.map{|a| a.first}\r\nend", "def magic_array(array)\narray.flatten.reverse.map! {|i| i = i*2}.delete_if {|i| i.modulo(3) == 0}.uniq.sort\nend", "def compress(conditions = nil, base_row_count = 3)\n dup.compress!(conditions, base_row_count)\n end", "def string_compression(str)\n compressed = string[0]\n\n count = 1\n (1...string.length).each do |idx|\n if string[idx] == compressed[-1]\n count += 1\n else\n compressed += count.to_s\n compressed += string[idx]\n count = 1\n end\n end\n\n compressed += count.to_s\n\n compressed.length >= string.length ? string : compressed\nend", "def compress\n @current_index = 0\n while !buckets_empty?\n @sep = \"\"\n @lines[@current_index] = \"\"\n add_words_starting_size(0)\n @current_index += 1\n end\n end", "def strCompress(string)\n str = string.split('')\n result = []\n counter = 1\n current = 0\n str.each do |char|\n if char != str[current+1]\n result << char\n result << counter\n counter = 0\n end\n current +=1\n counter +=1\n end\n result.join('')\n end", "def string_compression(str)\n output = [str[0]]\n count = 0\n str.split('').each do |char|\n if char == output[-1]\n count += 1\n else\n output << count\n output << char\n count = 1\n end\n end\n output << count\n\n output.length < str.length ? output.join : str\nend", "def brute_force_compress(str)\n compressed_str = ''\n count_consecutive = 0\n str.each_char.with_index do |char, index|\n count_consecutive += 1\n next_char_different = ((index + 1) == str.chars.size || (str.chars[index + 1] != char))\n if next_char_different\n compressed_str << (char << count_consecutive.to_s)\n count_consecutive = 0\n end\n end\n compressed_str.length < str.length ? compressed_str : str\nend", "def sluggish_octopus!(array)\n sorted = false\n until sorted\n sorted = true\n array.each_index do |index|\n index_2 = index + 1\n next if index_2 == array.length\n if array[index].length > array[index_2].length\n array[index],array[index_2] = array[index_2],array[index]\n sorted = false\n end\n end\n end\n array[-1]\nend", "def array_copy(source)\n\tdestination = []\n\tfor number in source\n\t\t# add number to destination if number\n\t\t# is less than 4\n\t\tdestination << number if number < 4\n\tend\n\treturn destination\nend", "def duplicate(array)\n array.uniq!\nend", "def compress\n return :input_too_short if buf.size < 2\n return :input_too_large if buf.size > 0xFFFFFF\n\n outstream = ArrayOStream.new\n .u8(0x11).u16(buf.size).u8(buf.size >> 16)\n\n outbuffer = [8 * 4 + 1] * 33\n outbuffer[0] = 0\n bufferlength = 1\n bufferedBlocks = 0\n readBytes = 0\n while readBytes < buf.size\n if bufferedBlocks == 8\n outstream.write(outbuffer[0, bufferlength])\n outbuffer[0] = 0\n bufferlength = 1\n bufferedBlocks = 0\n end\n\n oldLength = [readBytes, 0x1000].min\n disp, length = occurrence_length(readBytes,\n [buf.size - readBytes, 0x10110].min, readBytes - oldLength, oldLength)\n if length < 3\n outbuffer[bufferlength] = buf[readBytes]\n readBytes += 1\n bufferlength += 1\n else\n readBytes += length\n outbuffer[0] |= (1 << (7 - bufferedBlocks)) & 0xFF\n case\n when length > 0x110\n outbuffer[bufferlength] = 0x10\n outbuffer[bufferlength] |= ((length - 0x111) >> 12) & 0x0F\n bufferlength += 1\n outbuffer[bufferlength] = ((length - 0x111) >> 4) & 0xFF\n bufferlength += 1\n outbuffer[bufferlength] = ((length - 0x111) << 4) & 0xF0\n when length > 0x10\n outbuffer[bufferlength] = 0x00\n outbuffer[bufferlength] |= ((length - 0x111) >> 4) & 0x0F\n bufferlength += 1\n outbuffer[bufferlength] = ((length - 0x111) << 4) & 0xF0\n else\n outbuffer[bufferlength] = ((length - 1) << 4) & 0xF0\n end\n outbuffer[bufferlength] |= ((disp - 1) >> 8) & 0x0F\n bufferlength += 1\n outbuffer[bufferlength] = (disp - 1) & 0xFF\n bufferlength += 1\n end\n\n bufferedBlocks += 1\n end\n\n if bufferedBlocks > 0\n outstream.write(outbuffer[0, bufferlength])\n end\n\n outstream.buf\n end", "def compress_str(str)\n res = \"\"\n curChar = str[0]\n curCharCount = 1\n (1...str.length).each do |i|\n if str[i] != curChar \n res += add_to_result(curChar, curCharCount)\n curChar, curCharCount = str[i], 1 \n \n else \n curCharCount += 1\n end \n end \n res += add_to_result(curChar, curCharCount)\n res \nend", "def compressor; end", "def move_duplicates(a)\n\n n = a.length\n\n h = Hash.new\n\n if a.length < 1\n return nil\n end\n\n if a.length < 2\n return a\n end\n\n dup_arr = []\n\n (0..n-1).each do |i|\n if h[a[i]]\n h[a[i]] = h[a[i]] + 1\n else\n h[a[i]] = 1\n end\n end\n\n h.each do |key,val|\n\n if h[key] > 1\n dup_arr.push(key)\n end\n end\n\n return dup_arr\n\n\nend", "def sluggish_oct(arr)\n new_arr = arr.dup\n sorted = true\n\n i = 0\n until sorted && i == new_arr.length - 1\n if new_arr[i].length > new_arr[i + 1].length\n new_arr[i], new_arr[i + 1] = new_arr[i + 1], new_arr[i]\n sorted = false\n end\n\n i += 1\n if i == arr.length - 1 && sorted == false\n i = 0\n sorted = true\n end\n end\n\n new_arr.last\nend", "def array_transform(array)\n\tb = []\n\tarray.each_index do |i|\n\t\tb.push(array[i]+array[i-1])\tif i > 0\n\tend\n\treturn b.unshift(1).push(1)\nend", "def compress(data)\n compressed = \"\\x10\"\n compressed <<\n Bytestream.from_hex(format('%06X', data.length)).to_b.reverse\n\n index = 0\n w = 0xFFF\n window = ''\n lookahead = ''\n\n loop do\n bits = ''\n check = nil\n current_chunk = ''\n\n 8.times do\n window = (index < w ? data[0, index] : data[(index % w)..index])\n lookahead = data[index..-1]\n\n if lookahead.nil? || lookahead.empty?\n unless bits.empty?\n while bits.length < 8\n bits << '0'\n current_chunk << \"\\x00\"\n end\n compressed <<\n Bytestream.from_hex(format('%02x', bits.to_i(2))).to_b <<\n current_chunk\n end\n break\n end\n\n check = window.index(lookahead[0..2])\n if check\n bits << '1'\n length = 2\n store_length = 0\n store_check = 0\n while check && length < 18\n store_length = length\n length += 1\n store_check = check\n check = window.index(lookahead[0, length])\n end\n index += store_length\n store_length -= 3\n position = window.length - 1 - store_check\n store_length = store_length << 12\n current_chunk <<\n Bytestream.from_hex(format('%04X', (store_length | position))).to_b\n else\n index += 1\n bits << '0'\n current_chunk << lookahead[0]\n end\n end # 8.times\n\n if lookahead.nil? || lookahead.empty?\n unless bits.empty?\n while bits.length < 8\n bits << '0'\n current_chunk << \"\\x00\"\n end\n compressed <<\n Bytestream.from_hex(format('%02x', bits.to_i(2))).to_b <<\n current_chunk\n end\n break\n end\n\n compressed <<\n Bytestream.from_hex(format('%02x', bits.to_i(2))).to_b <<\n current_chunk\n end # loop\n\n compressed << \"\\x00\" until compressed.length % 4 == 0\n compressed\n end", "def using_uniq (array)\n return array.uniq!\nend", "def compress_str(string)\n\n result = \"\" #[a]\n i = 0\n \n while i < string.length\n counter = 1\n while string[i] == string[i + 1]\n counter += 1\n i += 1\n end\n \n result += counter.to_s if counter > 1\n result += string[i]\n i += 1\n end\n result\nend", "def stutter(a) \n a.zip(a).flatten(1)\nend", "def zany_zip(*arr)\n max_length = 0\n arr.each do |x|\n if x.length > max_length\n max_length = x.length\n end\n end\n result = []\n i = 0\n while i < max_length\n temp = []\n arr.each do |subarray|\n temp << subarray[i]\n end\n result << temp\n i += 1\n end\n result\nend", "def using_uniq(array)\n\n \nend", "def basic_compression(string)\n string = string.split(\"\")\n out = \"\"\n return out if string.empty?\n\n char = string.shift\n count = 1\n out += char\n\n while string[0] == char\n string.shift\n count += 1\n end\n\n out += count.to_s\n out += basic_compression(string.join(\"\"))\n out\nend", "def uniq(array)\n counts = Hash.new(0)\n result = []\n array.each do |element|\n counts[element] += 1\n result << element unless counts[element] > 1\n end\n result\nend", "def reverse(array)\n result = []\n array.each do |item|\n result.prepend(item)\n end\n result\nend", "def uniq(array)\n finalArray = []\n array.each do |element|\n if !finalArray.include?(element)\n finalArray.push(element)\n end\n end\n return finalArray\nend", "def clever(arr)\n arr.reduce do |big_fish, fish|\n fish.length > big_fish.length ? fish : big_fish\n end\nend", "def remove_duplicates(nums)\n counter = 0\n original_length = nums.length\n\n (1...nums.length).each do |i|\n if nums[i-1] == nums[i]\n counter += 1\n else\n nums[i-counter] = nums[i]\n end\n end\n\n return original_length - counter\nend", "def encode(list)\n pack(list).map { |i| [i.length,i.first] }\nend", "def compress_str(str)\n newstr = \"\"\n lastc = \"\"\n str.each_char.with_index do |c, i|\n next if lastc == c\n lastc = c\n newstr += count_reps(str[i..-1])\n newstr += lastc\n end\n newstr\nend", "def compress_solution_one(str)\n compressed_str = ''\n count_consecutive = 0\n str_chars = str.chars\n str_size = str_chars.size\n str_chars.each.with_index do |char, index|\n count_consecutive += 1\n next_char_different = ((index + 1) == str_size || (str_chars[index + 1] != char))\n if next_char_different\n compressed_str << char\n compressed_str << count_consecutive.to_s\n count_consecutive = 0\n end\n end\n compressed_str.length < str_size ? compressed_str : str\nend", "def compress_solution_two(str)\n str_chars = str.chars\n str_size = str_chars.size\n return str if str_size < compressed_size(str_chars, str_size)\n\n compressed_str = ''\n count_consecutive = 0\n str_chars.each.with_index do |char, index|\n count_consecutive += 1\n next_char_different = ((index + 1) == str_size || (str_chars[index + 1] != char))\n if next_char_different\n compressed_str << char\n compressed_str << count_consecutive.to_s\n count_consecutive = 0\n end\n end\n compressed_str\nend", "def reverser(array)\n new_array = []\n array.each { |e| new_array.unshift(e) }\n new_array\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def reduce key, list\n res = []\n loop do\n min = list.reject(&:empty?).min # find array starting with smallest element\n break if min.nil? # break if none found\n res << min.shift # pull out the first element and append it to result\n end\n res\n end", "def compress(str)\n\tletter_count = {}\n\tfor i in 0..str.length-1\n\t\tif letter_count[str[i]]\n\t\t\tletter_count[str[i]] += 1\n\t\telse\n\t\t\tletter_count[str[i]] = 1\n\t\tend\n\tend\n\tcompressed = \"\"\n\tletter_count.each {|k,v| compressed += \"#{k}#{v}\"}\n\tif compressed.length < str.length\n\t\tcompressed\n\telse\n\t\tstr\n\tend\nend", "def sluggish_octopus(array)\n\n sorted = false\n until sorted\n sorted = true\n\n array.each_index do |i|\n next if i == array.length - 1\n j = i + 1\n\n if array[i].length > array[j].length\n sorted = false\n array[i], array[j] = array[j], array[i]\n end\n end\n end\n array.last\n\nend", "def compress_str(str)\n result = str[0]\n prev = {char: str[0], num: 1}\n (1...str.length).each do |i|\n if str[i] == prev[:char]\n prev[:num] += 1\n if prev[:num] > 2\n result = result[0...-2] + prev[:num].to_s + prev[:char]\n else\n result = result[0...-1] + prev[:num].to_s + prev[:char]\n end \n else\n result += str[i]\n prev[:char], prev[:num] = str[i], 1\n end\n end\n\n result\nend", "def compress_str(str)\n compressed = \"\"\n\n i = 0\n while i < str.length\n char = str[i]\n\n count = 0\n while char == str[i]\n count +=1\n i += 1\n end\n \n if count > 1\n compressed += count.to_s + char \n else\n compressed += char\n end\n end\n \n compressed \nend", "def string_compression(str)\n str_array = str.split(\"\")\n current_letter = str_array.first\n output = [current_letter]\n current_count = 1\n\n indx = 1\n while indx < str_array.length\n if current_letter == str_array[indx]\n current_count += 1\n else\n output << current_count unless current_count == 1\n current_count = 1\n current_letter = str_array[indx]\n output << current_letter\n end\n indx += 1\n end\n output.join(\"\")\nend", "def compress(str)\n compressed = ''\n chars = str.split('')\n idx = 0\n\n while idx <= chars.length-1\n streak = 1\n char = chars[idx]\n while chars[idx] == chars[idx+1]\n streak += 1\n idx+= 1\n end\n idx += 1\n if streak > 1\n compressed += char + streak.to_s\n else\n compressed += char\n end\n end\n compressed\nend", "def compress_str(str)\n compressed = ''\n\n i = 0\n while i < str.length\n char = str[i]\n\n count = 0\n while char == str[i]\n count += 1\n i += 1\n end\n\n if count > 1\n compressed += count.to_s + char\n else\n compressed += char\n end\n end\n\n compressed\nend", "def mirror(list)\n list_copy = list.dup\n index_tracker = list.length - 1\n until index_tracker == 0\n list_copy << list[index_tracker]\n index_tracker -= 1\n end\n return list_copy\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend", "def rotate_array(array)\r\n result = array.select {|x| x}\r\n result << result.shift\r\nend", "def compress_str(str)\n results = []\n counter = 1\n str.each_char.with_index do |char, ind|\n if char = str[ind+1]\n counter += 1\n else \n results << counter\n results << char\n counter = 1\n end\n end\n return results.join(',')\nend", "def rem_dup(list)\n list.uniq!\n return list\nend", "def compress\n Vedeu.timer('Removing duplicate cells...') do\n content.map do |cell|\n character = character_for(cell)\n\n character == @same ? next : @same = character\n end.join.tap do |out|\n Vedeu.log(type: :compress,\n message: \"#{message} -> #{out.size} characters\")\n end\n end\n end", "def string_compressor(string)\n array = string.split(//).sort\n count = 1\n result = \"\"\n\n array.each_with_index do |letter, index|\n if array[index] == array[index + 1]\n count += 1\n elsif array[index] != array[index + 1]\n result << letter + count.to_s\n count = 1\n end\n end\n result\nend", "def reverse(array)\n array.each_with_object([]) do |item, result|\n result.prepend(item)\n end\nend", "def remove_duplicates(array)\n array.uniq!.length\nend", "def compress_str(str)\n \n # Checks each char for the number of duplicates, keeps only chars that\n # are repeated more than once.\n dups = str.chars.group_by{|e| e}.keep_if{|_, e| e.length > 0}\n\n\n # Map the chars from a hash into a new string, key value is the number\n # of times that the char is repeated, value is the char itself. Join the\n # chars back into a string at the end and return it.\n new_str = dups.map{|k, v| v.length.to_s + k}.join(\"\")\n\nend" ]
[ "0.7903527", "0.73421437", "0.6634792", "0.6615078", "0.6261407", "0.61034465", "0.60872287", "0.60740423", "0.6065707", "0.6043544", "0.59632117", "0.5960188", "0.5942582", "0.5940796", "0.5913524", "0.5880538", "0.5861572", "0.5854636", "0.5848758", "0.5837404", "0.5806937", "0.580372", "0.5792841", "0.577365", "0.57476115", "0.57473814", "0.5747302", "0.57184553", "0.57072985", "0.56883895", "0.5686213", "0.5685911", "0.56841004", "0.5667898", "0.56242716", "0.56242716", "0.561492", "0.5610885", "0.55789584", "0.55659986", "0.55503184", "0.55480474", "0.55291027", "0.55215895", "0.551893", "0.5507994", "0.54972875", "0.5495032", "0.5493253", "0.547988", "0.5471731", "0.5465036", "0.54573655", "0.54546684", "0.54453796", "0.5442332", "0.5433697", "0.5433516", "0.543113", "0.5415218", "0.54093814", "0.5401026", "0.5398409", "0.5397559", "0.53961974", "0.5394526", "0.5393289", "0.53839517", "0.53709817", "0.53693604", "0.5368965", "0.5365928", "0.5365618", "0.5349059", "0.53459305", "0.5330505", "0.5330505", "0.5326688", "0.53237075", "0.5319107", "0.53133464", "0.53123367", "0.5309568", "0.5307014", "0.5304274", "0.53015697", "0.5300491", "0.5300491", "0.5300491", "0.5300491", "0.5300491", "0.5300491", "0.5293242", "0.5290523", "0.52884537", "0.5287591", "0.52813125", "0.52790946", "0.52731764", "0.5268508" ]
0.80014986
0
if user has courses and logged in via root, send to courses listing
def redirect_path_for(user) requested_path = session.delete(:requested_path) requested_path_from_cookie = cookies.delete(:requested_path) if requested_path_from_cookie requested_path_from_cookie elsif requested_path requested_path elsif user.courses.any? root_path else root_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if current_user.nil?\n redirect_to user_session_path\n return\n end\n @courses = current_user.courses\n @permission = current_user\n end", "def check_courses\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?) && (not @current_user.courses.include?(@course))\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\tend", "def check_courses\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?) && (not @current_user.courses.include?(@course))\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\tend", "def index\n \n @courses = current_user.courses.active\n \n respond_to do |format|\n if current_user and current_user.login.blank?\n format.html { redirect_to '/account' }\n else\n format.html # index.html.erb\n format.xml { render :xml => @courses }\n end\n end\n end", "def courses\n unless user_signed_in? && current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n \n $selected_course = nil\n\n @courses = current_user.instructor.courses.collect{ |course|\n {\n name: course.name,\n id: course.id\n }\n }\n\n render :template => \"home/index\"\n end", "def list_courses \r\n courses = Subject.find(params[:s]).courses rescue render_return\r\n render_return if courses.empty? or !logged_in_user.see_course?(courses.first)\r\n render_p 'course_display/list_courses',{'courses'=>courses,'caller'=>params[:caller]}\r\n end", "def list_courses\n if current_user.is_admin?\n @user = User.find(params[:id])\n @courses = @user.courses\n respond_to do |format|\n format.xml { render :xml => @courses }\n end\n else\n respond_to do |format|\n format.xml { render :text => \"error\" }\n end\n end\n end", "def index\n if current_user.is_admin\n @courses = Course.all\n else\n @courses = current_user.courses\n end\n end", "def index\n if current_user.has_role? :admin\n @courses = Course.all\n render and return\n elsif current_user.has_role? :instructor\n @user = current_user\n @courses = current_user.courses.select { |course| current_user.has_local_role? :instructor, course }\n render \"courses/taught\" and return\n else\n @courses = current_user.courses\n render \"courses/enrolled\" and return\n end\n end", "def index\n @course=current_user.teaching_courses if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n end", "def index\n @current_user = User.find_by_id(session[:user_id])\n @courses = @current_user.courses.paginate page: params[:page], order: 'created_at asc', per_page: 25\n if @current_user.courses.empty?\n redirect_to new_course_url, notice: \"You Have No Courses Yet\"\n return\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def view_all_courses\n\t\t\t# module_grand_access = permission_control(\"course\",\"show\")\n\t\t\tmodule_grand_access = true\n\t\t\tif module_grand_access\n\t\t\t\tcourses = Course.all\n\t\t\t\tif courses.present?\n\t\t\t\t\trender json: courses ,status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {error: \"No Courses are created\"}, status: :not_found\n\t\t\t\tend\n\t\t\telse\n \t\t\trender json: { error: \"You dont have permission to perform this action,Please contact Site admin\" }, status: :unauthorized\t\t\t\t\n\t\t\tend\n\t\tend", "def index\n \n if can? :update, @course #instructor \n @courses = current_user.subjects #Course.where(:user_id => current_user.id) #courses that person teaches\n else\n @courses = current_user.courses \n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def visible\n if current_user.admin?\n render status: :ok, json: current_user.taught_courses\n else\n render status: :ok, json: current_user.enrolled_courses\n end\n end", "def index\n if logged_in?\n if current_user.type == \"Student\"\n @students_courses = StudentCourse.where(student_id: current_user.id).where.not(grade: '')\n elsif current_user.type == \"Admin\" || current_user.type == \"SuperAdmin\"\n @students_courses = StudentCourse.where.not(grade: '')\n end\n else\n redirect_to static_pages_home_url\n end\n end", "def index\n \tif current_user && current_user.username.eql?(\"admin\")\n @courses = Course.all\n elsif current_user\n\t @lista = Profesor.joins(:course).where(:user_id => session[:user_id])\t\n\t list = Array.new\n\t @lista.each do |l|\n\t \tlist << l.course_id\n end\n\t @courses = Course.find(list)\n\tend\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json=> @courses }\n end\n end", "def instructor_list\n #NEED TO ADD CURRENT USER\n @courses = Course.where(:instructor_id=>current_user.id).paginate(:per_page=>10, :page=>params[:page])\n @course_category_id = \"\"\n @instructor_section = true\n @page_title = 'Courses for <span style=\"font-size:14px\">for ' + current_user.name + '</span>'\n\n render :action=>\"/courses/index\"\n end", "def index\n @courses = Course.all\n @student = User.find(session[:user_id])\n @courses_enrolled = @student.courses\n end", "def index\n @courses = teacher_signed_in? ? current_teacher.courses.all : Course.all\n end", "def index\n \n redirect_to courses_path\n end", "def home\n set_current_course if params[:course_id]\n\n respond_to do |format|\n format.html do\n if current_course.nil? && !current_user.admin?\n course_count = current_user.registered_courses.count +\n current_user.employed_courses.count\n if course_count == 0\n redirect_to connect_courses_url\n return\n end\n if course_count == 1\n redirect_to course_root_url(course_id:\n current_user.registered_courses.first ||\n current_user.employed_courses.first)\n return\n end\n end\n\n # Pull information about the current user.\n @news_flavor = params[:flavor] ? params[:flavor].to_sym : nil\n end\n format.json { }\n end\n end", "def require_authorized_for_current_section\n\t\t if current_user.enrolled_in?(@current_course) #= @current_user \n\t\t\tredirect_to course_path(current_lesson.course)\n\n\t\telse\n\t\t\tredirect_to root_url, alert: 'You Shall Not Pass!'\nend\n\tend", "def select_the_course\r\n course = Course.find(params[:c]) rescue nil\r\n render_return unless logged_in_user and course and logged_in_user.see_course?(course)\r\n render_p 'course_display/list_subjects',{'caller'=>params[:caller],'course'=>course}\r\n end", "def index\n authorize! :read, Course\n\n if is_student?\n @course_sections = Course.find_student_courses(current_user.id)\n else\n @course_sections = Course.find_professor_courses(current_user.id)\n end\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 if current_user.admin?\n @courses = Course.paginate(page: params[:page], per_page: 30).order('created_at DESC')\n elsif current_user.teacher?\n @courses = Course.where(user_id: current_user.id)\n .paginate(page: params[:page], per_page: 30)\n .order('created_at DESC')\n else\n @courses = Course.joins(:course_students)\n .where('course_students.user_id' => current_user.id)\n .paginate(page: params[:page], per_page: 30)\n .order('created_at DESC')\n end\n end", "def index\n redirect_to all_courses_path\n end", "def index\n redirect_to all_courses_path\n end", "def index\n if user_signed_in?\n @courses = current_entity.courses.active\n elsif teacher_signed_in?\n @courses = Course.where(courses: {teacher: current_entity, active: true})\n end\n end", "def index\n @current_user=current_user\n if isAdmin?\n @courses = Course.paginate(page: params[:page])\n elsif isProf?\n @title = \"All Courses Offered\"\n @courses= @current_user.offered_courses.paginate(page: params[:page])\n elsif isStudent?\n @title = \"All Courses Offered\"\n @courses= Course.paginate(page: params[:page])\n\n # @courses= @current_user.registered_courses.paginate(page: params[:page])\n else\n redirect_to root_url\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def goto_courses\n node_object = TreeFolder.find_by_name('Courses')\n session[:root] = FolderNode.find_by_node_object_id(node_object.id).id\n redirect_to controller: 'tree_display', action: 'list'\n end", "def index\n @course=Course.where(teacher_id: current_user) if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n @course = Course.where(status: [$CourseReview,$CourseArrange]) if admin_logged_in?\n end", "def index\n if current_user\n @instructor_query = LeaderboardHelper.user_is_instructor?(current_user.id)\n\n if @instructor_query\n @course_list = LeaderboardHelper.instructor_courses(current_user.id)\n else\n @course_list = LeaderboardHelper.student_in_which_courses(current_user.id)\n end\n @course_info = Leaderboard.getCourseInfo(@course_list)\n end\n end", "def index\n if !current_user.nil?\n @user_courses = current_user.courses.paginate(page: params[:page])\n end\n @course_feed = Course.where(public: true).all.paginate(page: params[:page])\n end", "def course\n unless user_signed_in? && current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n \n $selected_course = Course.where({id: params[:id]}).first\n\n @course_projects = $selected_course.projects.collect{ |project|\n {\n project_name: project.name,\n team_names: project.teams.reduce(''){|names, team| names + team.name + ', '}[0..-3],\n due: project.due.in_time_zone('Eastern Time (US & Canada)').strftime('%Y-%m-%d %I:%M:%S %p')\n }\n }\n\n render :template => \"home/index\"\n end", "def index\n #to see tenant info\n #@tenant = Tenant.current_tenant\n @courses = Course.all\n end", "def courses\n @courses = Course.where(\"teacher_id=?\",session[:user].teacher_id)\n end", "def landing\n \t@user = User.find(params[:id])\n @course = User.joins(:course).select(\"users.*,courses.*\").find(params[:id])\n end", "def assignments_home\n @current_user = User.find_by_session_token(cookies[:session_token])\n if(params[:courseId] != nil)\n if(Course.exists?(params[:courseId]))\n $course = Course.find(params[:courseId])\n else\n $course = nil\n end\n \n end\n if($course != nil && Assignment.exists?(:course_id => $course.id))\n $assignments = Assignment.where(\"course_id = ?\", $course.id)\n else\n $assignments = nil\n end#$course = Course.find(1)\n \n if(!@current_user || @current_user == nil)\n flash[:warning] = \"You need to be logged in to see this page\"\n $course = nil\n $assignments = nil\n elsif(!$course || $course == [])\n flash[:warning] = \"Please select a class to see this page\"\n end\n \n end", "def show\n @courses = Course.all\n unless validate_user_for_survey\n redirect_to(main_app.root_path,\n flash: { notice: 'Sorry, You do not have access to this survey' })\n return\n end\n render 'show'\n end", "def ensure_user_in_course!\n user_from_course_user = CourseUser.find(params[:id]).user\n\n unless current_user && user_from_course_user && current_user.id == user_from_course_user.id\n head 401\n end\n end", "def index\n @course=current_user.teaching_courses if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n @credit_isdegree, @credit_nodegree=cal_degree\n end", "def topics_for_course\n redirect_guest\n @course = Course.find(params[:id])\n @topics = @course.topics\n end", "def show\n #avoid users to see other students courses\n if user_signed_in?\n redirect_to courses_path if !@course.users.include?(current_entity)\n elsif teacher_signed_in?\n redirect_to courses_path if @course.teacher != current_entity\n end\n # redirect_to root_path if current_user.teacher? && !@course.users.include?(current_user)\n # @lessons = Lesson.where(course_id: (params[:id])).order('date DESC')\n end", "def current_course\n\n @user = current_user\n @courses = []\n \n if @user.parent or @user.student\n @student = Student.find(:all,\n #:select => \"\",\n :joins => \"inner join batches b on students.batch_id = b.id \",\n :conditions => \"b.is_active = true and b.is_deleted = false \"+\n \"and students.is_active = true and students.is_deleted = false \"+\n \"and students.user_id = \"+@user.id.to_s+\"\"\n ).first\n\n if !@student.nil?\n @courses = Course.find(:all,\n :conditions => \"is_deleted = false \"+\n \"and id in ( \"+ @student['batch_id'].to_s + \")\"\n )\n end\n end\n @courses\n end", "def show\n @course = Course.find(params[:id])\n enrolled = current_user && current_user.courses.all.include?(@course)\n @enrolment = @course.enrolments.build\n\n if enrolled || current_user == @course.publisher\n redirect_to show_enrolled_course_path(@course)\n else\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course }\n end\n end\n end", "def show\n @user = current_user\n @course = Course.find(params[:id])\n\n # Only give students the available assignments\n if current_user.has_local_role? :student, @course\n @assignments = @course.assignments.select { |assignment| Time.now > assignment.start_date }\n else\n @assignments = @course.assignments\n end\n\n if current_user.has_local_role? :grader, @course or current_user.has_role? :admin\n render \"courses/manage\" \n end\n end", "def index\n @user_courses = UserCourse.all\n end", "def index\n redirect_to course_path @course #Easiest to put things in one place\n end", "def index\n @courses = Course.all\n @current_semester = Semester.find_by_active(1)\n if @courses.present?\n @current_semester_courses = @current_semester.courses\n end\n @check_user = current_user.admin\n @semesters = Semester.all\n end", "def add_course\n if current_user.is_admin?\n @user = User.find(params[:id])\n @course = Course.find_by_official_id(params[:course_official_id])\n if @course.nil?\n respond_to do |format|\n format.xml { render :text => \"course_not_exist\" }\n end\n return\n end\n if !@user.is_admin?\n if @user.courses.find_by_id(@course.id).nil?\n @user.courses << @course\n else\n respond_to do |format|\n format.xml { render :text => \"course_exists\" }\n end\n return\n end\n end\n respond_to do |format|\n format.xml { render :xml => @course.to_xml }\n end\n else\n respond_to do |format|\n format.xml { render :text => \"error\" }\n end\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def require_authorized_for_current_lesson\n if !current_user.enrolled_in?(current_lesson.section.course) && current_lesson.section.course.user != current_user\n# redirect_to courses_path, alert: \"Please enroll in the course to view lessons\" # redirects to courses page\n redirect_to course_path(current_lesson.section.course), alert: \"Please enroll in the course to view lessons\" # redirects to specific course page\n end\n end", "def show\n @course = Course.find(params[:id])\n @tab = params[:tab] || 0\n if @course.user != current_user and !@course.published?\n return redirect_to :root, notice: 'Nothing here' \n end\n @hals = @course.hals.not_private\n @followers = @course.get_course_followers\n # puts @followers.inspect\n end", "def process_courses(user)\n if !user.global_role.can_edit_system_configuration? &&\n !user.global_role.can_manage_all_courses?\n\n # Everyone can manage their own course enrollments\n can :manage, CourseEnrollment, user_id: user.id\n\n can :enroll, CourseOffering, self_enrollment_allowed: true\n\n can :unenroll, CourseOffering\n\n # A user can manage a CourseOffering if they are enrolled in that\n # offering and have a CourseRole where can_manage_course? is true.\n can [:edit, :update], CourseOffering,\n CourseOffering.managed_by_user(user) do |co|\n co.is_manager? user\n end\n\n # A user can grade a CourseOffering if they are enrolled in that\n # offering and have a CourseRole where can_grade_submissions? is true.\n can :generate_gradebook, CourseOffering do |co|\n co.is_staff? user\n end\n\n # Likewise, a user can only manage enrollments in a CourseOffering\n # that they have can_manage_courses? permission in.\n can :manage, CourseEnrollment do |enrollment|\n enrollment.course_offering.is_manager? user\n end\n end\n end", "def show\n @user = current_user\n @course = Course.find(params[:id])\n end", "def get_courses\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_courses'\n\tend", "def index\n #instructor_id =session[:id]\n #@courses = Course.where([\"instructor_id = ?\", instructor_id])\n @courses = Course.all\n end", "def index \n @course_enrollements = current_user.course_enrollements\n end", "def index\n @courses = current_user\n .courses\n .select('courses.*, count(labs.id) AS labs_count')\n .joins('LEFT OUTER JOIN labs ON labs.course_id = courses.id').group('courses.id')\n .page(params[:page])\n end", "def list_subjects\r\n #TODO only list subjects from my own schools \r\n #because then people can still it \r\n school = School.find(params[:nid]) rescue render_return\r\n render_return if !logged_in_user.see_course?(school)\r\n render_p 'course_display/course_selection',{'caller'=>params[:caller],'school'=>school}\r\n end", "def index\n @course_to_users = CourseToUser.all\n end", "def list\n @currCtlr = params[:currCtlr]\n redirect_to controller: :content_pages, action: :view unless user_logged_in?\n\n redirect_to controller: :student_task, action: :list if current_user.try(:student?)\n end", "def index\n add_breadcrumb \"Inicio\", :root_path\n add_breadcrumb \"#{@course_user.course.name} \", student_course_path(@course_user.course)\n end", "def request_path\n \"courses/#{@course_id}/users\"\n end", "def show_courses_instructing\n if is_professor?\n Course.where(user_id: self).order(:course_id)\n end\n end", "def index\n unless current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n\n @students = $selected_course.students.collect{|student| {name: student.first + ' ' + student.last, student_id: student.id }}\n end", "def authorize_user_for_course\n @course = Course.find(params[:course_id] || params[:id])\n unless @course\n flash[:error] = \"Course #{params[:course]} does not exist!\"\n redirect_to controller: :home, action: :error and return\n end\n\n # set course logger\n begin\n COURSE_LOGGER.setCourse(@course)\n rescue Exception => e\n flash[:error] = e.to_s\n redirect_to controller: :home, action: :error and return\n end\n\n uid = current_user.id\n # don't allow sudoing across courses\n if (session[:sudo]) then\n if (@course.id == session[:sudo][\"course_id\"]) then\n uid = session[:sudo][\"user_id\"]\n else\n session[:sudo] = nil\n end\n end\n\n # set @cud\n cud, reason = CourseUserDatum.find_or_create_cud_for_course @course, uid\n case reason\n when :found\n @cud = cud\n\n when :admin_created\n @cud = cud\n flash[:info] = \"Administrator user added to course\"\n\n when :admin_creation_error\n flash[:error] = \"Error adding user: #{current_user.email} to course\"\n redirect_to controller: :home, action: :error and return\n\n when :unauthorized\n flash[:error] = \"User #{current_user.email} is not in this course\"\n redirect_to controller: :home, action: :error and return\n end\n\n # check if course was disabled\n if @course.disabled? and !@cud.has_auth_level?(:instructor) then\n flash[:error] = \"Your course has been disabled by your instructor. Please contact them directly if you have any questions\"\n redirect_to controller: :home, action: :error and return\n end\n\n # should be able to unsudo from an invalid user and\n # an invalid user should be able to make himself valid through edit page\n invalid_cud = !@cud.valid?\n nicknameless_student = @cud.student? && @cud.nickname.blank?\n in_edit_or_unsudo = (params[:controller] == \"course_user_data\") &&\n (params[:action] == \"edit\" or params[:action] == \"update\" or\n params[:action] == \"unsudo\")\n\n if (invalid_cud or nicknameless_student) and !in_edit_or_unsudo then \n flash[:error] = \"Please complete all of your account information before continuing\"\n redirect_to edit_course_course_user_datum_path(id: @cud.id, course_id: @cud.course.id)\n end\n end", "def show\n @tutor_application = TutorApplication.find(params[:id])\n @courses = Course.all.sort_by{|c| @tutor_application.suitability_for_course(c)}.reverse\n @allocation_links = @tutor_application.allocation_links\n if current_user.CC? && !@allocation_links.any? { |al| al.course.course_coordinator_id == current_user.id }\n redirect_to login_path, :notice => 'You are not authorised.' and return\n end\n find_grades\n if @tutor_application.allocation_links.allocated.size > 2\n flash.now[:error] = \"Tutor is allocated to more than 2 courses.\"\n end\n end", "def show\n @user = User.find(session[:user_id])\n @articles = @course.articles\n end", "def process_courses(user)\n # A user can manage a CourseOffering if they are enrolled in that\n # offering and have a CourseRole where can_manage_course? is true.\n\n can :read, CourseOffering do |offering|\n user.course_offerings.include?(offering)\n end\n\n can :manage, CourseOffering do |offering|\n user.managing_course_offerings.include?(offering)\n end\n\n # Likewise, a user can only manage enrollments in a CourseOffering\n # that they have can_manage_courses? permission in.\n can :manage, CourseEnrollment do |enrollment|\n user_enrollment = CourseEnrollment.where(\n user_id: user.id,\n course_offering_id: enrollment.course_offering.id).first\n\n user_enrollment && user_enrollment.course_role.can_manage_course?\n end\n end", "def addcourse\n current_user.courses<<@course unless current_user.courses.exists?(@course.id)\n redirect_to courses_path\n end", "def index\n @course_users = CourseUser.all\n end", "def index\n @course_users = CourseUser.all\n end", "def require_owner\n @course = Course.find_by_id(params[:id])\n if (!@course || @course.user != current_user)\n redirect_to :root, notice: 'Not yours. Pas touche.' \n end\n end", "def index\n redirect_to help_pages_how_it_works_path, notice: t('have_to_login') unless current_user\n @subscriptions = Subscription.where(user_id: current_user.id) if current_user\n end", "def index\n @course=current_user.teaching_courses if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n \n @course_all=Course.all\n @course_all=@course_all-@course\n @course_true = Array.new\n @course_all.each do |single|\n if single.open then\n @course_true.push single\n end\n end\n end", "def show\n \t@courses = Course.all\n \t@admin = Admin.find(params[:id])\n end", "def users\n @course = Course.find(params[:id])\n @users = @course.users.all\n end", "def check_user_permissions\n if user_signed_in?\n if !current_user.is_admin? && !current_user.is_professor?\n redirect_to courses_path, notice: \"You don't have permission to access that page!\"\n end\n end\n end", "def index\n\t\t@courses = Course.all\n\tend", "def list\n redirect_to controller: :content_pages, action: :view if current_user.nil?\n redirect_to controller: :student_task, action: :list if current_user.try(:student?)\n end", "def show\n @user = current_user #User.find(params[:id])\n @taking_courses = @user.takes\n @offering_courses = Array.new\n \n Authour.where(:user_id => @user.id).each do |authour|\n @offering_courses << Course.find(authour.course_id)\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mypage }\n end\n end", "def index\n @path_courses = PathCourse.all\n end", "def goto_courses\n goto_controller('Courses')\n end", "def confirm_own_classes_page\n if (Profile.find(params[:profile].to_i).user_id != session[:user_id])\n flash[:notice] = \"You cannot take courses for other users!\"\n if session[:admin]\n redirect_to admin_path\n else\n redirect_to(user_path( :id => session[:user_id]))\n end\n end\n end", "def index\n if instructor_signed_in? and current_instructor.is_admin\n # Only an admin has access to this information. Ohter instructors will not get the link\n @instructor = Instructor.all\n else \n redirect_to root_path\n return\n end\n end", "def myschedule\n\n # Check if logged-in student before loading page. If not, go to login page.\n if current_student.nil?\n redirect_to new_student_session_path\n else\n\n # Show all selected courses in current semeseter's schedule\n @schedule = current_student.schedules.first\n @temp_courses = []\n if !@schedule.course_schedules.find_by(registered: false).nil?\n @schedule.course_schedules.where(registered: false).each do |course_schedule| \n @temp_courses << Course.find(course_schedule.course_id)\n end\n end\n\n # Show all registered courses in current semeseter's schedule\n @registered_courses = []\n if !@schedule.course_schedules.find_by(registered: true).nil?\n @schedule.course_schedules.where(registered: true).each do |course_schedule|\n @registered_courses << Course.find(course_schedule.course_id)\n end\n end\n end\n end", "def online_chapter\n redirect_to root_path unless (current_user.sk.admin? || @chapter.online)\n end", "def index\n if !current_user\n redirect_to '/'\n end\n\n if current_user.email == 'samir@test.com' || current_user.email == 'priyatham.ven@gmail.com'\n @critiques = Critique.all\n else\n redirect_to '/'\n end\n end", "def validate_course_access(course_id)\n logger.info 'validating ' + course_id.to_s\n validation_success = false\n courses = get_ids(get_all_courses_for_user)\n logger.info 'courses are' + courses.inspect\n validation_success = courses.include?(Integer(course_id))\n if validation_success == false\n redirect_to (GyanV1::Application.config.landing_page.to_s)\n end\n\n end", "def index\n @admin_courses = Course.all\n end", "def show\n @user = User.find(params[:id])\n\n # @user = User.find(params[:id])\n # if isAdmin?\n # @users =User.where('role' => 2)\n # elsif isProf?\n # @courses= @user.offered_courses\n # elsif isStudent?\n # @courses= Course.all\n # end \n end", "def new_user_to_course\n\n if !current_user.nil? && current_user.is_professor?\n @course = Course.find(params[:id])\n @students = User.where('rank = ? ',User::RANK_STUDENT)\n @students -= @course.users\n render 'new_user_to_course'\n else\n redirect_to root_url\n end\n end", "def index\n begin\n case\n when params[:semester_id]\n @courses = Semester.find(params[:semester_id]).courses\n when params[:teacher_id]\n check_token(params[:teacher_id], params[:token], true)\n @courses = User.find(params[:teacher_id]).real_teaching_courses\n when params[:student_id]\n check_token(params[:student_id])\n @courses = Course.none\n User.find(params[:student_id]).participations.each do |participation|\n @courses <<= participation.course if ROLE_STUDENT == participation.role\n end\n when params[:assistant_id]\n check_token(params[:assistant_id])\n @courses = Course.none\n User.find(params[:assistant_id]).participations.each do |participation|\n @courses <<= participation.course if ROLE_ASSISTANT == participation.role\n end\n else\n json_failed\n end\n rescue ActiveRecord::RecordNotFound\n json_failed(REASON_RESOURCE_NOT_FOUND)\n end\n end", "def index\n if isAdmin?\n @title= \"Listing All Professors\"\n @users = User.where('role' => 2).paginate(page: params[:page])\n if(!@users.any?)\n flash[:notice]= \"No professor on CMS. To create a new professor click on Create New Professor\"\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n else\n flash[:notice]= \"You don't have permission to browse all users\"\n redirect_to courses_path\n end\n end", "def authorized_user?\n if params[:controller].eql?(\"subjects\")\n subject = Subject.find(params[:id])\n if params[:action].eql?(\"show\")\n # If a user is trying to access another user's private subject playlist, they will be redirected to /subjects\n redirect_to subjects_path if subject.private? && !is_resource_owner?(subject)\n elsif params[:action].eql?(\"edit\") || params[:action].eql?(\"update\") || params[:action].eql?(\"destroy\")\n # If a user tries to alter their default (non-editable) subject or a subject they do not own, they are redirected back to the subject show page\n redirect_to subject_path(subject) if subject.default_subject || !is_resource_owner?(subject)\n end\n elsif params[:controller].eql?(\"videos\")\n video = Video.find(params[:id])\n if params[:action].eql?(\"show\")\n # If a user tries to view another user's private video, they are redirected back to /videos\n redirect_to videos_path if video.private? && !is_resource_owner?(video)\n elsif params[:action].eql?(\"edit\") || params[:action].eql?(\"update\") || params[:action].eql?(\"destroy\")\n # If a user tries to alter a video they do not own, they are redirected back to the videos show page\n redirect_to video_path(video) unless is_resource_owner?(video)\n end\n end\n end", "def list_courses(courses_collection)\n courses_collection.each do |course|\n\n end\n end", "def check_multiple_courses\n \n end", "def index\n # return all courses associated with the current user\n @teacher = Teacher.find_by_email(session[:email])\n\n # if teacher is an admin redirect to admin home\n if @teacher.admin\n # check if admin intends to view teacher view\n if !session[:admin]\n\n else\n # otherwise redirect them to admin page\n redirect_to '/admin/index'\n return\n end\n end\n\n # return courses related to the courses\n @courses = @teacher.courses.all\n @courses.each {|course|\n course.books.each {|b|\n if b.books_for_classes[0].quantity == nil || b.books_for_classes[0].quantity == 0\n b.quantity = 0\n else\n b.quantity = b.books_for_classes[0].quantity\n end\n }\n }\n render :layout => 'index'\n end", "def index\n @admin_section = true\n #@courses = Course.paginate(:all, :per_page=>10, :page=>params[:page])\n @courses = Course.page(params[:page]).per(10) \n\n @course_category_id = \"\"\n @admin_section = true\n @page_title = \"Courses\"\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @courses }\n end\n end", "def index\n @course=current_user.teaching_courses if teacher_logged_in?\n @course=current_user.courses if student_logged_in?\n\n #----------分页功能的实现---------#\n total = @course.count\n params[:total] = total\n params[:page] ||= 1 #进行初始化\n if total % $PageSize == 0\n params[:pageNum] = total / $PageSize\n else\n params[:pageNum] = total / $PageSize + 1\n end\n\n #计算分页的开始和结束位置\n params[:pageStart] = (params[:page].to_i - 1) * $PageSize\n\n if params[:pageStart].to_i + $PageSize <= params[:total].to_i\n params[:pageEnd] = params[:pageStart].to_i + $PageSize - 1\n else\n params[:pageEnd] = params[:total].to_i - 1 #最后一页\n end\n @credits = get_credits\n end", "def users_courses\n current_user.all_upcoming_courses.limit(5)\n end" ]
[ "0.7592931", "0.75892025", "0.75892025", "0.7547961", "0.75016683", "0.74610686", "0.74197644", "0.7391246", "0.7385164", "0.73444295", "0.7246492", "0.72037655", "0.7148991", "0.7054611", "0.7012976", "0.6893904", "0.6887844", "0.68810856", "0.686988", "0.68076384", "0.6782259", "0.67577755", "0.674624", "0.6726834", "0.67211926", "0.671448", "0.671448", "0.6711735", "0.6709122", "0.6645322", "0.6626878", "0.6623624", "0.6622409", "0.6584166", "0.6578107", "0.65574384", "0.654195", "0.6520094", "0.6514415", "0.64956564", "0.6490158", "0.6485742", "0.6459709", "0.64302653", "0.6423732", "0.64229107", "0.63952917", "0.63837165", "0.6381928", "0.6358624", "0.63197124", "0.6274056", "0.62634265", "0.62484473", "0.6240074", "0.62334454", "0.621568", "0.6214799", "0.6214033", "0.618764", "0.6187293", "0.617285", "0.6169906", "0.615757", "0.61500365", "0.6143617", "0.6140386", "0.61364955", "0.6135801", "0.61285424", "0.61245054", "0.61245054", "0.61203897", "0.6119562", "0.61172205", "0.61051476", "0.6094937", "0.6089054", "0.6080674", "0.60588527", "0.60478556", "0.6046916", "0.60453534", "0.60443497", "0.60439503", "0.60411674", "0.60358936", "0.60249025", "0.6021832", "0.6017936", "0.6004462", "0.60032344", "0.5988927", "0.59854287", "0.59795845", "0.59683937", "0.5968089", "0.59668714", "0.5961398", "0.59595305", "0.5957604" ]
0.0
-1
GET /admin/enrollments/new GET /admin/enrollments/new.xml
def new @enrollment = Enrollment.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @enrollment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @entitlement = Entitlement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entitlement }\n end\n end", "def new\n @assessment = Assessment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assessment }\n end\n end", "def new\n @administration = Administration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administration }\n end\n end", "def new\n @visit = Visit.new\n @visit.enrollments << Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit }\n end\n end", "def new\n @administrator = Administrator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrator }\n end\n end", "def new\n @administrator = Administrator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrator }\n end\n end", "def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lease }\n end\n end", "def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end", "def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end", "def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end", "def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end", "def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end", "def new\n @renewal = Renewal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @renewal }\n end\n end", "def new\n @education = Education.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @education }\n end\n end", "def new\n @entradas = Entrada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entradas }\n end\n end", "def new\n @course_degree = CourseDegree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course_degree }\n end\n end", "def new\n @partyrole = Partyrole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partyrole }\n end\n end", "def new\n @adminnistrador = Adminnistrador.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adminnistrador }\n end\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def new\n @account_department = AccountDepartment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account_department }\n end\n end", "def create\n @enrollment = Enrollment.new(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n flash[:notice] = 'Enrollment was successfully created.'\n format.html { redirect_to(department_lecture_path(@enrollment.lecture.department, @enrollment.lecture)) }\n format.xml { render :xml => @enrollment, :status => :created, :location => @enrollment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @course_registrant = CourseRegistrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course_registrant }\n end\n end", "def new\n @assignment = Assignment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def new\n @assignment = @user.assignments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def new\n @account = Admin::Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end", "def new\n @admin = AdminAccount.find_by_id(session[:admin_id])\n @admin_account = AdminAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_account }\n end\n end", "def new\n @accountadmin_language = AccountadminLanguage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @accountadmin_language }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def new\n @assignmentstatus = Assignmentstatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignmentstatus }\n end\n end", "def new \n @section = 'resume'\n @education = Education.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @education }\n end\n end", "def new\n @department = Department.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @department }\n end\n end", "def new\n @department = Department.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @department }\n end\n end", "def new\n @new_employee_request = NewEmployeeRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @new_employee_request }\n end\n end", "def create\n @enrollment = Enrollment.new(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n @log_entry = LogEntry.last\n format.html { redirect_to admin_scheduled_course_url(@enrollment.scheduled_course), :notice => 'A student was successfully enrolled.' }\n #format.xml { render :xml => @enrollment, :status => :created, :location => @enrollment }\n else\n #format.html { render :action => \"new\" }\n #format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @announcement }\n end\n end", "def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @announcement }\n end\n end", "def new\n @employeer = Employeer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @employeer }\n end\n end", "def new\n @educational_level = EducationalLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @educational_level }\n end\n end", "def new\n @accident_assignee_expense = AccidentAssigneeExpense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @accident_assignee_expense }\n end\n end", "def new\n @course = Course.find(params[:course_id])\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end", "def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @announcement }\n end\n end", "def new\n @add_on = AddOn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_on }\n end\n end", "def new\n @admin_language = Language.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_language }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def new\n @issued = Issued.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @issued }\n end\n end", "def new\n head :status => 405\n return\n \n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.xml { render :xml => @participant }\n end\n end", "def new\n @election = Election.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @election }\n end\n end", "def new\n @lendable = Lendable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lendable }\n end\n end", "def new\n @lead = Lead.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lead }\n end\n end", "def new\n @external_account = ExternalAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @external_account }\n end\n end", "def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end", "def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end", "def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end", "def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end", "def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end", "def new\n @institute = Institute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institute }\n end\n end", "def new\n @course = Course.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end", "def new\n @semester_subject = SemesterSubject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @semester_subject }\n end\n end", "def new\n @college = College.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @college }\n end\n end", "def new\n @entrada = Entrada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entrada }\n end\n end", "def new\n @lookup_eligibilityoutcome = LookupEligibilityoutcome.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_eligibilityoutcome }\n end\n end", "def new\n @administrativo = Administrativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrativo }\n end\n end", "def new\n @adjunto = Adjunto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adjunto }\n end\n end", "def new\n @attendance = Attendance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attendance }\n end\n end", "def new\n @evaluate_course = EvaluateCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluate_course }\n end\n end", "def new\n @test_subject_evaluation = TestSubjectEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_subject_evaluation }\n end\n end", "def new\n @journal = Journal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journal }\n end\n end", "def new\n @encounter_type = EncounterType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @encounter_type }\n end\n end", "def new\n @niveis_ensino = NiveisEnsino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @niveis_ensino }\n end\n end", "def new\n @enemy = EnemyTemplate.new\n @title = \"New enemy\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @enemy }\n end\n end", "def new\n @lookup_eligibility_ineligibility = LookupEligibilityIneligibility.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_eligibility_ineligibility }\n end\n end", "def new\n @lablocational = Lablocational.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lablocational }\n end\n end", "def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lesson }\n end\n end", "def new\n @vgroup = Vgroup.new\n\n @vgroup.enrollments << Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vgroup }\n end\n end", "def new\n @subject = Subject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @subject }\n end\n end", "def new\n @subject = Subject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @subject }\n end\n end", "def new\n @subject = Subject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @subject }\n end\n end", "def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loan }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end", "def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end", "def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end", "def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end", "def new\n @testament = Testament.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testament }\n end\n end", "def new\n @annee = Annee.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @annee }\n end\n end", "def new\n @ptcourse = Ptcourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ptcourse }\n end\n end", "def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def new\n @role = Role.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end", "def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end", "def new\n @lesson_plan = LessonPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lesson_plan }\n end\n end", "def new\n @approval = Approval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @approval }\n end\n end", "def new\n @applicant_status = ApplicantStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @applicant_status }\n end\n end", "def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end", "def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end" ]
[ "0.7059007", "0.7040094", "0.7016466", "0.7011768", "0.7005482", "0.7005482", "0.6924383", "0.6910551", "0.6910551", "0.68755823", "0.68755823", "0.68755823", "0.68608713", "0.6819725", "0.6760885", "0.6758027", "0.67453074", "0.6742924", "0.67345005", "0.67328286", "0.67300105", "0.6711734", "0.67117274", "0.6706979", "0.6698355", "0.66967463", "0.66803414", "0.6673484", "0.6672278", "0.66622007", "0.66583467", "0.66583467", "0.6647655", "0.6643131", "0.6631979", "0.6631979", "0.66285336", "0.6620173", "0.661386", "0.6612472", "0.660798", "0.6594328", "0.6588322", "0.6586653", "0.6585766", "0.6585766", "0.65829235", "0.6579564", "0.6577396", "0.6569612", "0.6568448", "0.65637004", "0.6563454", "0.65585726", "0.65585726", "0.65585726", "0.65585726", "0.65585726", "0.65585697", "0.6556235", "0.6555719", "0.6553071", "0.6552856", "0.6550917", "0.6542847", "0.6540842", "0.6537435", "0.6537111", "0.65302837", "0.6530062", "0.65291274", "0.6526785", "0.65184206", "0.6518201", "0.65173393", "0.6515235", "0.6506014", "0.6501766", "0.6501766", "0.6501766", "0.6499948", "0.64998376", "0.64998376", "0.64998376", "0.649964", "0.649964", "0.649964", "0.649964", "0.6494821", "0.64947265", "0.6494242", "0.6493101", "0.64923847", "0.64908934", "0.6489458", "0.6487543", "0.6487128", "0.64842707", "0.64842707" ]
0.76625216
1
POST /enrollments POST /enrollments.xml
def create @enrollment = Enrollment.new(params[:enrollment]) respond_to do |format| if @enrollment.save @log_entry = LogEntry.last format.html { redirect_to admin_scheduled_course_url(@enrollment.scheduled_course), :notice => 'A student was successfully enrolled.' } #format.xml { render :xml => @enrollment, :status => :created, :location => @enrollment } else #format.html { render :action => "new" } #format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end", "def create\n @enrollment = Enrollment.new(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n flash[:notice] = 'Enrollment was successfully created.'\n format.html { redirect_to(department_lecture_path(@enrollment.lecture.department, @enrollment.lecture)) }\n format.xml { render :xml => @enrollment, :status => :created, :location => @enrollment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @enrollments = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollments.save\n format.html { redirect_to current_user }\n format.json { render :show, status: :created, location: @enrollments }\n else\n format.html { render :new }\n format.json { render json: @enrollments.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @enrollment = current_user.enrollments.build(enrollment_params)\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to user_enrollment_path(current_user, @enrollment), notice: 'We have received your request for enrollment. We\\'ll contact you with further details.' }\n else\n flash[:alert] = @enrollment.errors.full_messages.to_sentence\n format.html { redirect_to request.referrer }\n end\n end\n end", "def create\n @enroll = Enroll.new(enroll_params)\n\n respond_to do |format|\n if @enroll.save\n format.html { redirect_to @enroll, notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: @enroll }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enrollment = Enrollment.new(enrollment_params)\n\t@enrollment.save\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: tr(\"enrollment_created\") }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @enrolment = Enrolment.new(enrolment_params)\n\n respond_to do |format|\n if @enrolment.save\n format.html { redirect_to @enrolment, notice: \"Enrolment was successfully created.\" }\n format.json { render :show, status: :created, location: @enrolment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @enrolment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to [:admin, @enrollment], notice: 'enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @entitlement = Entitlement.new(params[:entitlement])\n\n respond_to do |format|\n if @entitlement.save\n format.html { redirect_to(@entitlement, :notice => 'Entitlement was successfully created.') }\n format.xml { render :xml => @entitlement, :status => :created, :location => @entitlement }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entitlement.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.find(params[:course_id])\n @enrollment = @course.enrollments.create(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n format.html { render :template => 'enrollments/success', notice: 'ya' }\n format.json { render json: @enrollment, status: :created, location: @enrollment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def enrollment_params\n params.require(:enrollment).permit(:date, :method, :remarks, :coordinator_id, :registry_id, :participant_id)\n end", "def create_enrollment\n\n end", "def create_and_invitation_studant(params = {})\n run(:post, \"/invitations\", [201,422], JSON.dump(params))\n end", "def create\n @enrollment = @parent.enrollments.build enrollment_params\n if @enrollment.save\n render :show, status: :created, location: api_v1_mutant_enrollment_url(@enrollment.mutant_id, @enrollment)\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end", "def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Matrícula criada com sucesso.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @enrollments = Enrollment.all\n end", "def index\n @enrollments = Enrollment.all\n end", "def index\n @enrollments = Enrollment.all\n end", "def index\n @enrollments = Enrollment.all\n end", "def enrollment_params\n params.require(:enrollment).permit(:attended, :user_id, :training_session_id)\n end", "def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend", "def enrollment_params\n params.require(:enrollments).permit(:user_id, :lesson_id)\n end", "def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end", "def create\n\n @enrollment = Enrollment.new(properties_data: enrollment_properties_params)\n #debugger\n #@enrollment = Enrollment.new()\n #render json: request.raw_post(), status: :created\n\n if @enrollment.save\n render json: {:reference_number => @enrollment.reference_number}, status: :created\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end", "def enroll_params\n params.require(:enroll).permit(:firstname, :lastname, :phone, :email, :childname, :childage, :question, :consent, :startdate, :enddate, :typeofday)\n end", "def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @enrollment }\n end\n end", "def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @enrollment }\n end\n end", "def enroll\n\n response = {}\n status_code = 200\n\n begin\n\n # Must be POST request to create course\n return unless request.post?\n\n # Retrieves current user\n user = get_logged_user()\n return unless user\n\n if !user\n status_code = 401\n raise 'Not logged in!'\n end\n\n if !user.is? \"supervisor\"\n status_code = 403\n raise 'Student cannot edit course!'\n end\n\n # If a supervisor\n if user.is? \"supervisor\"\n # Get parameters\n student_id = params[:student_id]\n course_id = params[:course_id]\n\n # Only allowed to enroll students in courses he supervises\n return unless user.courses.find(course_id)\n else\n # If unknown class, do nothing\n return\n end\n\n # Create plan\n plan = Plan.new\n\n group = Group.create!(\n :name => \"Pessoal\",\n :min_credits => nil,\n :min_subjects => nil\n )\n\n # Supervisor only enrolls if student exists\n if Student.find(student_id) != nil\n plan.course = Course.find(course_id)\n plan.student = Student.find(student_id)\n plan.group = group\n\n plan.save\n else\n status_code = 404\n raise 'Student does not exist!'\n end\n\n redirect_back fallback_location: \"/\"\n rescue Exception => e\n response[:status] = 'error'\n response[:error] = \"#{e}\"\n else\n status_code 201\n response[:status] = 'success'\n response[:message] = 'Student was enrolled with success!'\n end\n end", "def request_enroll(applicant)\n url = \"#{root_url}/ivs-ippaas-api/IPPRest/resources/rest/optInIPPApplicant\"\n body = {\n sponsorID: sponsor_id,\n uniqueID: applicant.unique_id,\n firstName: applicant.first_name,\n lastName: applicant.last_name,\n streetAddress: applicant.address,\n city: applicant.city,\n state: applicant.state,\n zipCode: applicant.zip_code,\n emailAddress: applicant.email,\n IPPAssuranceLevel: '1.5',\n }\n\n res = faraday.post(url, body, dynamic_headers) do |req|\n req.options.context = { service_name: 'usps_enroll' }\n end\n Response::RequestEnrollResponse.new(res.body)\n end", "def create\n @enrollment = Enrollment.new(enrollment_params)\n @enrollment.student = Student.find(params[:student_for_enrollment])\n @enrollment.subject = Subject.find(params[:subject])\n @enrollment.year = DateTime.now.year\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to '/students', notice: 'La Cursada se creó exitosamente.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @enrollments ||= @committee.enrollments if @committee\n @enrollments ||= @user.enrollments if @user\n @enrollments = @enrollments.ordered\n\n respond_to do |format|\n format.html { render :action => 'index' } # index.html.erb\n format.xml { render :xml => @enrollments }\n end\n end", "def create\n @enrollment_ta = EnrollmentTa.new(enrollment_ta_params)\n\n respond_to do |format|\n if @enrollment_ta.save\n format.html { redirect_to @enrollment_ta, notice: 'Enrollment ta was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment_ta }\n else\n format.html { render :new }\n format.json { render json: @enrollment_ta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enqury = Enqury.new(enqury_params)\n\n respond_to do |format|\n if @enqury.save\n format.html { redirect_to @enqury, notice: 'Enqury was successfully created.' }\n format.json { render :show, status: :created, location: @enqury }\n else\n format.html { render :new }\n format.json { render json: @enqury.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:education][:accomplishment][\"0\"] != \"\"\n @education = Education.new(education_params)\n if @education.save\n params[:education][:accomplishment].each do |i, acc|\n EducationAccomplishment.create(description: acc, education_id: @education.id)\n end\n redirect_to '/'\n else\n redirect_to :back, flash: {alert: @education.errors.full_messages}\n end\n else\n redirect_to :back, flash: {alert: \"Must have at least one accomplishment\"}\n end\n end", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def create\n @required_degree = RequiredDegree.new(params[:required_degree])\n @job_postings = JobPosting.find :all\n @education_concentrations = EducationConcentration.find :all\n @educational_levels = EducationalLevel.find :all\n respond_to do |format|\n if @required_degree.save\n flash[:notice] = 'RequiredDegree was successfully created.'\n format.html { redirect_to(@required_degree) }\n format.xml { render :xml => @required_degree, :status => :created, :location => @required_degree }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @required_degree.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @pre_enrollment = PreEnrollment.new(pre_enrollment_params)\n\n respond_to do |format|\n if @pre_enrollment.save\n format.html { redirect_to @pre_enrollment, notice: 'Pre enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @pre_enrollment }\n else\n format.html { render :new }\n format.json { render json: @pre_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @visit = Visit.new\n @visit.enrollments << Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit }\n end\n end", "def create\n @enrollment = Enrollment.new(instructor: true)\n @course = Course.new(course_params)\n @course.enrollments << @enrollment\n current_user.enrollments << @enrollment\n\n respond_to do |format|\n if @enrollment.save and @course.save and current_user.save\n format.html { redirect_to root_url, notice: 'Course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def enrollment_params\n params.require(:enrollment).permit(:enrollment_date, :year, :active, :paid, :student_id, :course_id)\n end", "def create\n @accident_assignee_expense = AccidentAssigneeExpense.new(params[:accident_assignee_expense])\n\n respond_to do |format|\n if @accident_assignee_expense.save\n format.html { redirect_to(@accident_assignee_expense, :notice => 'Accident assignee expense was successfully created.') }\n format.xml { render :xml => @accident_assignee_expense, :status => :created, :location => @accident_assignee_expense }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @accident_assignee_expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def enrollment_params\n params.require(:enrollment).permit(:student_id, :course_id)\n end", "def enrollment_params\n params.require(:enrollment).permit(:user_id, :course_id, :approve, :deny, :grade)\n\n end", "def create\n admin_only\n @consuming_enrollment = ConsumingEnrollment.new(consuming_enrollment_params)\n\n respond_to do |format|\n if @consuming_enrollment.save\n format.html { redirect_to @consuming_enrollment, notice: 'Consuming enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @consuming_enrollment }\n else\n format.html { render :new }\n format.json { render json: @consuming_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @attendance_record = AttendanceRecord.new(attendance_record_params)\n #\n # respond_to do |format|\n # if @attendance_record.save\n # format.html { redirect_to @attendance_record, notice: 'Attendance record was successfully created.' }\n # format.json { render :show, status: :created, location: @attendance_record }\n # else\n # format.html { render :new }\n # format.json { render json: @attendance_record.errors, status: :unprocessable_entity }\n # end\n # end\n enrollments = Enrollment.where(section_id: params[:section_id])\n enrollments.each do |e|\n if (params[\"ar_p-#{e.student_id}\"])\n primary = params[\"ar_p-#{e.student_id}\"]\n secondary = params[\"ar_s-#{e.student_id}\"] ? params[\"ar_s-#{e.student_id}\"] : nil\n ar_params = {}\n ar_params[:student_id] = e.student_id\n ar_params[:section_id] = params['section_id']\n ar_params[:primary] = primary\n ar_params[:secondary] = secondary\n ar_params[:attendance_date] = Date.today\n AttendanceRecord.create(ar_params)\n end\n end\n end", "def create\n @enrollment = Enrollment.new\n @enrollment.student_id = params[:enrollment][:student]\n @enrollment.course_id = params[:enrollment][:course_id]\n \n if !@enrollment.student_id.nil? and !@enrollment.course_id.nil?\n @enrollment.save\n end\n redirect_to enrollments_index_path(:course_id=>@enrollment.course_id) \n end", "def enrollment_params\n params.require(:enrollment).permit(:client_id, :service_id, :preferences)\n end", "def create\n @enrolled = Enrolled.new(params[:enrolled])\n \n respond_to do |format|\n if @enrolled.save\n format.html { redirect_to @enrolled, :notice => t('selecao_admin.flash_messages.successfully_created.', :model => @enrolled.class.model_name.human) }\n format.json { render :json => @enrolled, :status => :created, :location => @enrolled }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @enrolled.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @enrollment = @membership.build_enrollment(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to business_membership_enrollment_path(@business, @membership, @enrollment), notice: 'Enrollment was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def enroll_params\n params.require(:enroll).permit(:user_id, :course_id)\n end", "def enroll_params\r\n params.require(:enroll).permit(:user_id, :lecture)\r\n end", "def create\n @education_accomplishment = EducationAccomplishment.new(education_accomplishment_params)\n\n respond_to do |format|\n if @education_accomplishment.save\n format.html { redirect_to @education_accomplishment, notice: 'Education accomplishment was successfully created.' }\n format.json { render :show, status: :created, location: @education_accomplishment }\n else\n format.html { render :new }\n format.json { render json: @education_accomplishment.errors, status: :unprocessable_entity }\n end\n end\n end", "def enroll!(course_id)\n self.enrollments.create!(course_id:course_id)\n end", "def enroll_params\n params.require(:enrollment).permit(:course_id, :user_id)\n end", "def create\n @enrollment = Enrollment.new(enrollment_params)\n @registry = @enrollment.registry\n @participants = Participant.all - @registry.participants\n @coordinators = @registry.coordinators\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def create\n @encouragement = Encouragement.new(encouragement_params)\n\n respond_to do |format|\n if @encouragement.save\n format.html { redirect_to admin_encouragements_path, notice: 'Encouragement was successfully created.' }\n format.json { render :show, status: :created, location: @encouragement }\n else\n format.html { render :new }\n format.json { render json: @encouragement.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @encounter_enemy = EncounterEnemy.new(params[:encounter_enemy])\n\n respond_to do |format|\n if @encounter_enemy.save\n format.html { redirect_to(@encounter_enemy.encounter.adventure, :notice => 'Encounter enemy was successfully created.') }\n format.xml { render :xml => @encounter_enemy, :status => :created, :location => @encounter_enemy }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @encounter_enemy.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @enrolls = Enroll.all\n @enroll = Enroll.new\n end", "def eligibility(params = {})\n scope 'default'\n post('eligibility/', params)\n end", "def create\n @degree = Degree.new(params[:degree])\n @users = User.find :all\n @educational_institutions = EducationalInstitution.find :all\n @educational_qualifications = EducationalQualification.find :all\n @education_concentrations = EducationConcentration.find :all\n @educational_levels = EducationalLevel.find :all\n respond_to do |format|\n if @degree.save\n flash[:notice] = 'Degree was successfully created.'\n format.html { redirect_to(@degree) }\n format.xml { render :xml => @degree, :status => :created, :location => @degree }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @degree.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @entrant = Entrant.new(params[:entrant])\n\n respond_to do |format|\n if @entrant.save\n format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }\n format.json { render json: @entrant, status: :created, location: @entrant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entrant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @education = @resume.educations.build(params[:education])\n\n respond_to do |format|\n if @education.save \n flash[:notice] = '教育信息创建成功.'\n format.html { redirect_to edit_resume_path(@resume) }\n format.xml { render :xml => @resume, :status => :created, :location => @resume }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def create\n raise SecurityTransgression unless Enrollment.can_be_created_by? current_user\n @enrollment = Enrollment.new(enrollment_params)\n\n if @enrollment.save\n redirect_to welcome_index_path, notice: 'Enrollment was successfully created.'\n else\n render action: 'new'\n end\n end", "def enroll\n\t\traise \"Invalid role!\" unless current_user.role_student?\n\n\t\t# We *shouldn't* get here if we already have requests, but just in case - DESTROY THEM\n\t\t@seminar.seminar_students.for_student_user(current_user).each{|x| x.destroy} \n\n\t\t@enrollment = @seminar.seminar_students.create!(:student_user => current_user, :student_confirmed => true)\n\t\tflash[:notice] = \"Enrollment requested\"\n\t\tredirect_to @seminar\n\tend", "def do_enroll\n rrid = params[:enrollment][:registration_role_id]\n rr = RegistrationRole.find rrid\n do_creator_action :enroll do\n\tflash_notice(\"Your registration request is successfully sent to #{rr.event}\") if valid?\n\tfalse #force default rendering\n end\n end", "def create\n @entradas = Entrada.new(params[:entrada])\n\n respond_to do |format|\n if @entradas.save\n flash[:notice] = 'LANÇAMENTO ENTRADA EFETUADO'\n format.html { redirect_to(homes_path) }\n format.xml { render :xml => @entradas, :status => :created, :location => @entradas }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entradas.errors, :status => :unprocessable_entity }\n end\n end\n end", "def enrolment_params\n params.require(:enrolment).permit(:course_id, :student_id)\n end", "def enrollment_params\n params.require(:enrollment).permit(:section_id, :student_id)\n end", "def create\n @renewal = Renewal.new(params[:renewal])\n\n respond_to do |format|\n if @renewal.save\n format.html { redirect_to(@renewal, :notice => 'Renewal was successfully created.') }\n format.xml { render :xml => @renewal, :status => :created, :location => @renewal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @renewal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @enrolled = Enrolled.new(:student_id => current_student.student_id, :course_id => params[:course_id])\n\n respond_to do |format|\n if @enrolled.save\n format.html { redirect_to @enrolled, notice: 'Enrolled was successfully created.' }\n format.json { render json: @enrolled, status: :created, location: @enrolled }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled.errors, status: :unprocessable_entity }\n end\n end\n end", "def enrollment_params\n params.permit(:id, :participant_id, :studysite_id, :study_id)\n #params.require(:participantstudysites).permit(:id, :participant_id, :studysite_id )\n end", "def enrollment_params\n params.require(:enrollment).permit(:course_id,:student_id, :grade)\n end", "def create\n @education = Education.new(params[:education])\n @education.resource_id = current_user.id\n @education.resource_type = 'User'\n @education.provider = 0 \n\n respond_to do |format|\n if @education.save\n format.html { redirect_to(educations_url, :notice => 'Education was successfully added.') }\n format.xml { render :xml => @education, :status => :created, :location => @education }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @education = Education.new(education_params)\n\n respond_to do |format|\n if @education.save\n format.html { redirect_to educations_url, notice: 'Education was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def guardian_create_enrollment_ticket(body)\n raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty?\n\n path = \"#{guardian_enrollments_path}/ticket\"\n post(path, body)\n end", "def create\n \n\t# create a new student as well if there is not already a student associated with this user.\n\t#Student.new({:user_id => session[:id], :student_number => params[:enrollment][:student_number]})\n\t\n\t# give correct user id.\n\tparams[:enrollment][:user_number] = session[:user_id]\n @enrollment = Enrollment.new(params[:enrollment])\n\t\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render json: @enrollment, status: :created, location: @enrollment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit!\n @hr_attendence = Hr::Attendence.new(params[:hr_attendence])\n\n respond_to do |format|\n if @hr_attendence.save\n format.html { redirect_to(@hr_attendence, :notice => 'Attendence was successfully created.') }\n format.xml { render :xml => @hr_attendence, :status => :created, :location => @hr_attendence }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hr_attendence.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @account_department = AccountDepartment.new(params[:account_department])\n\n respond_to do |format|\n if @account_department.save\n format.html { redirect_to([:admin, @account_department], :notice => 'AccountDepartment criada com sucesso.') }\n format.xml { render :xml => @account_department, :status => :created, :location => @account_department }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @account_department.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @course_degree = CourseDegree.new(params[:course_degree])\n\n respond_to do |format|\n if @course_degree.save\n format.html { redirect_to(@course_degree, :notice => 'Course degree was successfully created.') }\n format.xml { render :xml => @course_degree, :status => :created, :location => @course_degree }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course_degree.errors, :status => :unprocessable_entity }\n end\n end\n end", "def enroll_params\n params.require(:enroll).permit(:student_id, :course_id, :percentage, :lettergrade)\n end", "def create\n @education = Education.new(education_params)\n\n if @education.save\n render json: @education, status: :created, location: @education\n else\n render json: @education.errors, status: :unprocessable_entity\n end\n end", "def create\n @referral_enrolment = ReferralEnrolment.new(referral_enrolment_params)\n\n respond_to do |format|\n if @referral_enrolment.save\n format.html { redirect_to @referral_enrolment, notice: 'Referral enrolment was successfully created.' }\n format.json { render :show, status: :created, location: @referral_enrolment }\n else\n format.html { render :new }\n format.json { render json: @referral_enrolment.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_outcome_request\n raise IMS::LTI::InvalidLTIConfigError, \"\" unless has_required_attributes?\n\n res = post_service_request(@lis_outcome_service_url,\n 'application/xml',\n generate_request_xml)\n\n @outcome_response = extend_outcome_response(OutcomeResponse.new)\n @outcome_response.process_post_response(res)\n end", "def create\n @advancement = Advancement.new(params[:advancement])\n\n respond_to do |format|\n if @advancement.save\n format.html { redirect_to @advancement, notice: 'Advancement was successfully created.' }\n format.json { render json: @advancement, status: :created, location: @advancement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @advancement.errors, status: :unprocessable_entity }\n end\n end\n end", "def enrollment_params\n params.require(:enrollment).permit(:event_group_id, :user_id, :coupon_id, :opp_status_id, :guest_id)\n end", "def create\n @adjunto = Adjunto.new(params[:adjunto])\n\n respond_to do |format|\n if @adjunto.save\n format.html { redirect_to(@adjunto, :notice => 'Adjunto was successfully created.') }\n format.xml { render :xml => @adjunto, :status => :created, :location => @adjunto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adjunto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n newEssay = params[:essay]\n newEssay[:assignment_id] = params[:assignment_id]\n @essay = Essay.new(newEssay)\n \n respond_to do |format|\n if @essay.save\n format.html { redirect_to assignment_essay_url(@essay.assignment_id, @essay.id), notice: 'Essay was successfully created.' }\n format.json { render json: @essay, status: :created, location: @essay }\n else\n format.html { render action: \"new\" }\n format.json { render json: @essay.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @engagement_attendee = EngagementAttendee.new(engagement_params)\n if @engagement_attendee.save\n render :show, status: :created, location: api_v1_engagement_url(@engagement_attendee)\n else\n render json: @engagement_attendee.errors, status: :unprocessable_entity\n end\n end", "def create\n user_id = @current_user.id\n date = DateTime.strptime(params[:date], '%s')\n schedule_id = params[:id]\n\n e = Enrollment.find_by user_id: user_id, date: date, schedule_id: schedule_id\n\n # avoid duplicating enrollments\n unless e.present?\n\n @enrollment = Enrollment.create(\n user_id: user_id,\n date: date,\n schedule_id: schedule_id\n )\n\n end\n\n redirect_to bookings_path\n\n end", "def create\n @tutor_attendance = TutorAttendance.new(params[:tutor_attendance])\n\n respond_to do |format|\n if @tutor_attendance.save\n flash[:notice] = 'TutorAttendance was successfully created.'\n format.html { redirect_to(@tutor_attendance) }\n format.xml { render :xml => @tutor_attendance, :status => :created, :location => @tutor_attendance }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tutor_attendance.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n # binding.pry\n @student_id = StudentId.new(student_id_params)\n\n respond_to do |format|\n if @student_id.save\n if @enrolment\n format.html { redirect_to enrolment_student_ids_path(@enrolment), notice: 'Student was successfully created.' }\n else\n format.html { redirect_to student_ids_url, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student_id }\n end\n else\n format.html { render :new }\n format.json { render json: @student_id.errors, status: :unprocessable_entity }\n end\n end\n end", "def enrollment_params\n params.require(:enrollment).permit(:user_id, :course_code)\n end", "def create\n @lease = Lease.new(params[:lease])\n\n respond_to do |format|\n if @lease.save\n format.html { redirect_to(@lease, :notice => 'Lease was successfully created.') }\n format.xml { render :xml => @lease, :status => :created, :location => @lease }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lease.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @invest = Invest.new(params[:invest])\n\n respond_to do |format|\n if @invest.save\n format.html { redirect_to(@invest, :notice => 'Invest was successfully created.') }\n format.xml { render :xml => @invest, :status => :created, :location => @invest }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @invest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n course = Course.find(params[:course_id])\n student = Student.find_by(dni: params[:student_id])\n @enroll = Enroll.new( student: student, course: course)\n TestCourse.of(course).each do |tc|\n Score.create( student: student, test_id: tc.test_id, value: -2)\n end\n \n respond_to do |format|\n if @enroll.save\n format.html { redirect_to course_enrolls_path(course), notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: course_enrolls_path(course) }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end", "def enrollment_params\n params.require(:enrollment).permit(:section_id, :user_id)\n end" ]
[ "0.68580055", "0.6438068", "0.63683385", "0.6174988", "0.6160666", "0.5962718", "0.5962718", "0.58450824", "0.58260685", "0.5815332", "0.5739992", "0.57312495", "0.5713923", "0.5619601", "0.56070054", "0.56008565", "0.5591116", "0.55532026", "0.55532026", "0.55532026", "0.55532026", "0.5550947", "0.5540584", "0.553277", "0.55261165", "0.5516661", "0.55023503", "0.5501783", "0.5501783", "0.5461366", "0.544179", "0.54269105", "0.54256856", "0.54035705", "0.53869855", "0.53834796", "0.5378274", "0.53753096", "0.5372152", "0.5362124", "0.53568894", "0.5350638", "0.53458035", "0.5339973", "0.5329486", "0.5325037", "0.53201103", "0.53193897", "0.53020346", "0.52943027", "0.5292646", "0.5288064", "0.52697045", "0.5263158", "0.5262426", "0.5261648", "0.5256816", "0.52512133", "0.5244627", "0.52400607", "0.5235095", "0.5212358", "0.52017707", "0.519577", "0.51889145", "0.5182372", "0.5167332", "0.5162837", "0.5162661", "0.5157491", "0.51523435", "0.51521504", "0.514865", "0.51447856", "0.51365983", "0.51276034", "0.51266", "0.51210856", "0.51164496", "0.5110523", "0.5107281", "0.5103112", "0.50969887", "0.50946355", "0.50925136", "0.50877506", "0.508673", "0.508134", "0.5080923", "0.50802463", "0.5075228", "0.50743455", "0.50691724", "0.5066109", "0.5061336", "0.5055812", "0.50546193", "0.5050891", "0.5048343", "0.5044014" ]
0.58234847
9
PUT /admin/enrollments/1 PUT /admin/enrollments/1.xml
def update @enrollment = Enrollment.find(params[:id]) respond_to do |format| if @enrollment.update_attributes(params[:enrollment]) @log_entry = LogEntry.last format.html { redirect_to @enrollment, :notice => 'The details of this enrollment have changed.' } format.xml { head :ok } format.js else format.html { render :action => "edit" } format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @enrollment = Enrollment.find(params[:id])\n\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n flash[:notice] = 'Enrollment was successfully updated.'\n format.html { redirect_to(@enrollment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_enroll\n @enroll = Enroll.find(params[:id])\n end", "def set_enroll\n @enroll = Enroll.find(params[:id])\n end", "def set_enroll\n @enroll = Enroll.find(params[:id])\n end", "def set_enroll\n @enroll = Enroll.find(params[:id])\n end", "def update\n \n @enrollment = Enrollment.find(params[:id])\n\t# give correct user id.\n\t\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def set_enroll\n @enroll = Enroll.find(params[:id])\n\n end", "def update\n @enroll = Enroll.find(params[:id])\n @enroll.tournament = Tournament.find params[:enroll][:tournament_id]\n respond_to do |format|\n if @enroll.update_attributes(params[:enroll])\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #debugger\n if @enrollment.update(update_params)\n head :no_content\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end", "def update\n @enroll = Enroll.find(params[:id])\n if @enroll.update_attributes(params[:enroll])\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end", "def update\n @enrollment = Enrollment.find(params[:id])\n if @enrollment.update(enrollment_params)\n redirect_to enrollments_index_path(:course_id=>@enrollment.course_id) \n end\n \n end", "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end", "def update\n admin_only\n respond_to do |format|\n if @consuming_enrollment.update(consuming_enrollment_params)\n format.html { redirect_to @consuming_enrollment, notice: 'Consuming enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @consuming_enrollment }\n else\n format.html { render :edit }\n format.json { render json: @consuming_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollement.update(enrollement_params)\n format.html { redirect_to @enrollement, notice: \"Enrollement was successfully updated.\" }\n format.json { render :show, status: :ok, location: @enrollement }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @enrollement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrolment.update(enrolment_params)\n format.html { redirect_to @enrolment, notice: \"Enrolment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @enrolment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @enrolment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @entitlement = Entitlement.find(params[:id])\n\n respond_to do |format|\n if @entitlement.update_attributes(params[:entitlement])\n format.html { redirect_to(@entitlement, :notice => 'Entitlement was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entitlement.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @enrolled = Enrolled.find(params[:id])\n \n respond_to do |format|\n if @enrolled.update_attributes(params[:enrolled])\n format.html { redirect_to @enrolled, :notice => t('selecao_admin.flash_messages.successfully_updated.', :model => @enrolled.class.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @enrolled.errors, :status => :unprocessable_entity }\n end\n end\n end", "def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end", "def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @enterprise = Enterprise.find(params[:id])\n\n respond_to do |format|\n if @enterprise.update_attributes(params[:enterprise])\n format.html { redirect_to \"/enterprises\", notice: 'Enterprise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enterprise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update \n\n if @enrollment && @enrollment.update(enrollment_params)\n render :show\n else\n render json: {error: \"Enrollment not updated.\"}\n end\n end", "def update\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n\n respond_to do |format|\n if @education.update_attributes(params[:education])\n format.html { redirect_to(@education, :notice => 'Education was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n expire_one(params[:id])\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to([:admin, @article], :notice => 'Article was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @enrolled = Enrolled.find(params[:id])\n\n respond_to do |format|\n if @enrolled.update_attributes(params[:enrolled])\n format.html { redirect_to @enrolled, notice: 'Enrolled was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrolled.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @encounter_enemy = EncounterEnemy.find(params[:id])\n\n respond_to do |format|\n if @encounter_enemy.update_attributes(params[:encounter_enemy])\n format.html { redirect_to(@encounter_enemy, :notice => 'Encounter enemy was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @encounter_enemy.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_encouragement\n @encouragement = Encouragement.find_by_id(params[:id])\n unless @encouragement\n redirect_to admin_encouragements_path, notice: \"Encouragement ##{params[:id]} is not existed.\"\n end\n end", "def update\n @emirate = Emirate.find(params[:id])\n\n respond_to do |format|\n if @emirate.update_attributes(params[:emirate])\n flash[:notice] = 'Emirate was successfully updated.'\n format.html { redirect_to(@emirate) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @emirate.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end", "def update\n @envelope = Envelope.find(params[:id])\n\n respond_to do |format|\n if @envelope.update_attributes(params[:envelope])\n flash[:notice] = 'Envelope was successfully updated.'\n format.html { redirect_to(@envelope) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @envelope.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vopportunity_enrolment.save(vopportunity_enrolment_params)\n format.html { redirect_to @vopportunity_enrolment, notice: 'Enrolled! Congratulations!' }\n format.json { render :show, status: :ok, location: @vopportunity_enrolment }\n else\n format.html { render :edit }\n format.json { render json: @vopportunity_enrolment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n\n respond_to do |format|\n if @supervisor_estagio.update_attributes(params[:supervisor_estagio])\n flash[:notice] = 'Supervisor de Estagio atualizado com sucesso.'\n format.html { redirect_to(@supervisor_estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @supervisor_estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pre_enrollment.update(pre_enrollment_params)\n format.html { redirect_to @pre_enrollment, notice: 'Pre enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @pre_enrollment }\n else\n format.html { render :edit }\n format.json { render json: @pre_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @eventual = Eventual.find(params[:id])\n\n respond_to do |format|\n if @eventual.update_attributes(params[:eventual])\n flash[:notice] = 'Eventual was successfully updated.'\n format.html { redirect_to(@eventual) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @eventual.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def update\n @etiquetage = Etiquetage.find(params[:id])\n\n respond_to do |format|\n if @etiquetage.update_attributes(params[:etiquetage])\n flash[:notice] = 'Etiquetage was successfully updated.'\n format.html { redirect_to([:admin, @etiquetage]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @etiquetage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @encouragement.update(encouragement_params)\n format.html { redirect_to admin_encouragements_path, notice: 'Encouragement was successfully updated.' }\n format.json { render :show, status: :ok, location: @encouragement }\n else\n format.html { render :edit }\n format.json { render json: @encouragement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Matrícula editada com sucesso.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_enrollment(subdomain, course_id, enrollment_id, state)\n canvas_url = \"https://#{subdomain}.instructure.com\"\n token = get_token\n\n canvas_delete(\"#{canvas_url}/api/v1/courses/#{course_id}/enrollments/#{enrollment_id}\",\n token,\n {\n task: state\n }\n )\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def update\n @education = Education.find(params[:id])\n\n respond_to do |format|\n if @education.update_attributes(params[:education])\n flash[:notice] = '教育信息更新成功.'\n format.html { redirect_to edit_resume_path(@resume) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n # this action is not provided for partyroles\n end", "def update\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n if @exprience.update_attributes(params[:exprience])\n format.html { redirect_to @exprience, notice: 'Exprience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exprience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params.permit!\n @hr_attendence = Hr::Attendence.find(params[:id])\n\n respond_to do |format|\n if @hr_attendence.update_attributes(params[:hr_attendence])\n format.html { redirect_to(@hr_attendence, :notice => 'Attendence was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @hr_attendence.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n @enrollment = Enrollment.shard_for( params[:enrollment][:classroom_id] ).find(params[:id])\n\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params.permit!\n @employeer = Employeer.find(params[:id])\n\n respond_to do |format|\n if @employeer.update_attributes(params[:employeer])\n format.html { redirect_to(@employeer, :notice => 'Employeer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @employeer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end", "def update\n\t \n\t @enrollment = Enrollment.find(params[:enrollment_id], :include => :contract)\n\t @meeting = Meeting.find(params[:meeting_id])\n\t if @enrollment\n\t privs = @enrollment.contract.privileges(@user)\n\t render :text => \"You don't have privileges to do this.\", :status=>500 and return unless privs[:edit]\n\t \n\t participant = update_attendance_for_enrollment(@meeting, @enrollment, params)\n\t end\n \n render :json => {:id => participant.id}.to_json\n\tend", "def update\n @administrator = Administrator.find(params[:id])\n\n respond_to do |format|\n if @administrator.update_attributes(params[:administrator])\n flash[:notice] = 'Administrator was successfully updated.'\n format.html { redirect_to(@administrator) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @administrator.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @account_department = AccountDepartment.find(params[:id])\n\n respond_to do |format|\n if @account_department.update_attributes(params[:account_department])\n format.html { redirect_to([:admin, @account_department], :notice => 'AccountDepartment atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account_department.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n\n respond_to do |format|\n if @entry_instrument.update_attributes(params[:entry_instrument])\n flash[:notice] = 'EntryInstrument was successfully updated.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n user = demo? ? demo_user : current_user\n @resume = user.resumes.find(params[:id])\n @resume.update_count += 1\n\n respond_to do |format|\n if @resume.update_attributes(params[:resume])\n format.html { \n redirect_to(html_resume_path(@resume), :notice => 'updated') \n }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resume.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @article.update_attributes(params[:article])\n flash[:notice] = 'Article was successfully updated.'\n format.html { redirect_to([:admin, @article]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n format.html { redirect_to(admin_article_path(@article), :notice => 'Article was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_enrollment\n @enrollment = Participantstudysite.find(params[:id])\n end", "def update\n @article = Article.find(params[:id])\n\n respond_to do |format|\n if @article.update_attributes(params[:article])\n flash[:notice] = 'Article was successfully updated.'\n format.html { redirect_to(admin_articles_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n format.html { redirect_to business_membership_enrollment_path(@business, @membership, @enrollment), notice: 'Enrollment was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def update\n @trip_enrollment = TripEnrollment.find(params[:id])\n\n respond_to do |format|\n if @trip_enrollment.update_attributes(params[:trip_enrollment])\n flash[:notice] = 'TripEnrollment was successfully updated.'\n format.html { redirect_to(@trip_enrollment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip_enrollment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @employee = Employee.find(params[:id])\n\n respond_to do |format|\n if @employee.update_attributes(params[:employee])\n format.html { redirect_to(@employee, :notice => 'Employee was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @employee.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @industry = Industry.find(params[:id])\n\n respond_to do |format|\n if @industry.update_attributes(params[:industry])\n flash[:notice] = 'Industry was successfully updated.'\n format.html { redirect_to(@industry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @industry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n @instructor1 = Instructor1.find(params[:id])\n\n respond_to do |format|\n if @instructor1.update_attributes(params[:instructor1])\n format.html { redirect_to @instructor1, notice: 'Instructor1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instructor1.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_enrolment\n @enrolment = Enrolment.find(params[:id])\n end", "def update\n respond_to do |format|\n if @enrollment_ta.update(enrollment_ta_params)\n format.html { redirect_to @enrollment_ta, notice: 'Enrollment ta was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment_ta }\n else\n format.html { render :edit }\n format.json { render json: @enrollment_ta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @enrollment.student = @student_for_enrollment\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to '/students', notice: 'La Cursada se actualizó exitosamente.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n raise SecurityTransgression unless current_user.can_update? @enrollment\n if @enrollment.update(enrollment_params)\n redirect_to course_path(@enrollment.course_id), notice: 'Enrollment was successfully updated.'\n else\n render action: 'edit'\n end\n end", "def update\n @child = @enrollment.child\n\tputs enrollment_params\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: tr(\"enrollment_updated\") }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @accident_assignee_expense = AccidentAssigneeExpense.find(params[:id])\n\n respond_to do |format|\n if @accident_assignee_expense.update_attributes(params[:accident_assignee_expense])\n format.html { redirect_to(@accident_assignee_expense, :notice => 'Accident assignee expense was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @accident_assignee_expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @admin = Admin.find(params[:admin][:id])\n\n respond_to do |format|\n if @admin.update_attributes(params[:admin])\n format.html { redirect_to(:controller => \"admins\", :action => \"index\") }\n format.xml { head :ok }\n else \n format.html { render :action => \"index\" }\n flash.now[:alert] = \"Problem saving admin\"\n format.xml { render :xml => @admin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @emt = Emt.find(params[:id])\n\n respond_to do |format|\n if @emt.update_attributes(params[:emt])\n format.html { redirect_to(incident_timesheet_path, :notice => 'EMT was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @emt.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @course_degree = CourseDegree.find(params[:id])\n\n respond_to do |format|\n if @course_degree.update_attributes(params[:course_degree])\n format.html { redirect_to(@course_degree, :notice => 'Course degree was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course_degree.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n\n respond_to do |format|\n if @empleadosautorizado.update_attributes(params[:empleadosautorizado])\n format.html { redirect_to(@empleadosautorizado, :notice => 'Empleadosautorizado was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @empleadosautorizado.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @niveis_ensino = NiveisEnsino.find(params[:id])\n\n respond_to do |format|\n if @niveis_ensino.update_attributes(params[:niveis_ensino])\n format.html { redirect_to(@niveis_ensino, :notice => 'Niveis ensino atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @niveis_ensino.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @admin = Admin.find(params[:id])\n\n respond_to do |format|\n if @admin.update_attributes(params[:admin])\n format.html { redirect_to([:admin, @admin], :notice => 'Admin was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @admin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @manage_instructor = Instructor.find(params[:id])\n\n respond_to do |format|\n if @manage_instructor.update_attributes(params[:manage_instructor])\n format.html { redirect_to @manage_instructor, notice: 'Instructor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manage_instructor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @employeebankmaster = Employeebankmaster.find(params[:id])\n\n respond_to do |format|\n if @employeebankmaster.update_attributes(params[:employeebankmaster])\n format.html { redirect_to(@employeebankmaster, :notice => 'Employeebankmaster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @employeebankmaster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @asainactiverule = Asainactiverule.find(params[:id])\n\n respond_to do |format|\n if @asainactiverule.update_attributes(params[:asainactiverule])\n format.html { redirect_to @asainactiverule, notice: 'Asainactiverule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asainactiverule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.save!\n\n respond_to do |format|\n if @config_xml.update_attributes(params[:config_xml])\n flash[:notice] = 'ConfigXml was successfully updated.'\n format.html { redirect_to(@config_xml) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @config_xml.errors, :status => :unprocessable_entity }\n end\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def update\n @lineaedesal = Lineaedesal.find(params[:id])\n\n respond_to do |format|\n if @lineaedesal.update_attributes(params[:lineaedesal])\n format.html { redirect_to(@lineaedesal, :notice => 'Lineaedesal was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lineaedesal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @institute = Institute.find(params[:id])\n\n respond_to do |format|\n if @institute.update_attributes(params[:institute])\n format.html { redirect_to(@institute, :notice => 'Institute was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institute.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @renewal = Renewal.find(params[:id])\n\n respond_to do |format|\n if @renewal.update_attributes(params[:renewal])\n format.html { redirect_to(@renewal, :notice => 'Renewal was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @renewal.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6596078", "0.630038", "0.630038", "0.6183862", "0.6183862", "0.6183862", "0.6183862", "0.61791563", "0.6172935", "0.61470383", "0.61290914", "0.61149824", "0.6074484", "0.60686827", "0.6024957", "0.595611", "0.5912802", "0.5909143", "0.59031934", "0.5885574", "0.5864468", "0.5857659", "0.58502984", "0.58502984", "0.58502984", "0.58502984", "0.58502984", "0.5839809", "0.5801552", "0.57868034", "0.57825214", "0.57717085", "0.5768583", "0.5747093", "0.5729976", "0.57252324", "0.5719667", "0.5710716", "0.57019585", "0.5698283", "0.56949794", "0.56936187", "0.56936187", "0.5688678", "0.56865704", "0.5684871", "0.567507", "0.56711024", "0.56652933", "0.56647426", "0.566029", "0.56450963", "0.5644782", "0.5638941", "0.5638819", "0.5638819", "0.5638819", "0.5638819", "0.5638819", "0.5638819", "0.5638819", "0.5638819", "0.5638819", "0.5638819", "0.5625564", "0.5624153", "0.5621572", "0.56128806", "0.56081617", "0.5604934", "0.5573662", "0.5573442", "0.5567939", "0.5567533", "0.556567", "0.556431", "0.5563609", "0.5560922", "0.5559897", "0.5555201", "0.5553589", "0.5550318", "0.55480295", "0.55472887", "0.55471444", "0.55439556", "0.5536015", "0.5529684", "0.55259746", "0.5520227", "0.550845", "0.550691", "0.5503524", "0.5497857", "0.54976285", "0.54952824", "0.5493977", "0.54932237", "0.5487755", "0.54833376" ]
0.5694984
40
DELETE /admin/enrollments/1 DELETE /admin/enrollments/1.xml
def destroy @enrollment = Enrollment.find(params[:id]) @scheduled_course = @enrollment.scheduled_course @enrollment.destroy respond_to do |format| if(current_person.current_crew) format.html { redirect_to admin_scheduled_course_url(@scheduled_course) } else format.html { redirect_to enrollments_url } end format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to(enrollment_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.delete\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @enrollment.destroy\n\n head :no_content\n end", "def destroy\n @education = @resume.educations.find(params[:id])\n @education.destroy\n\n respond_to do |format|\n format.html { redirect_to(edit_resume_path(@resume)) }\n format.xml { head :ok }\n end\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n @education.destory\n\n respond_to do |format|\n format.html { redirect_to(educations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n\n respond_to do |format|\n format.html { redirect_to enrolls_url }\n format.json { head :no_content }\n end\n end", "def delete\n eadid = (params[\"eadid\"] || \"\").strip\n if eadid == \"\"\n log_error(\"Cannot delete EAD. No ID was provided.\")\n flash[:alert] = \"No EAD ID was provided.\"\n redirect_to upload_list_url()\n return\n end\n\n filename = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/\" + eadid + \".xml\"\n if !File.exist?(filename)\n log_error(\"Cannot delete EAD. File was not found: #{filename}\")\n flash[:alert] = \"Source file not found for finding aid: #{eadid}.\"\n redirect_to upload_list_url()\n return\n end\n\n target = ENV[\"EAD_XML_DELETED_FILES_PATH\"] + \"/\" + eadid + \".xml\"\n FileUtils.mv(filename, target)\n\n if !File.exist?(target)\n log_error(\"File delete failed: #{filename}\")\n flash[:alert] = \"Could not delete finding aid #{eadid}.\"\n redirect_to upload_list_url()\n return\n end\n\n Rails.logger.info(\"Findind aid #{eadid} has been deleted\")\n flash[:notice] = \"Findind aid #{eadid} has been deleted\"\n redirect_to upload_list_url()\n rescue => ex\n render_error(\"delete\", ex, current_user)\n end", "def destroy\n @enrollment = Enrollment.find(params[:id])\n student = @enrollment.student\n course_id = @enrollment.course_id\n @enrollment.destroy\n\n respond_to do |format|\n flash[:notice] = student.name_first_last + ' unenrolled'\n format.html { redirect_to course_url(course_id) }\n format.xml { head :ok }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @administrator = Administrator.find(params[:id])\n @administrator.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrators_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @administrator = Administrator.find(params[:id])\n @administrator.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrators_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to admin_enrollments_url, notice: 'enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to enrollments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @etiquetage = Etiquetage.find(params[:id])\n @etiquetage.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_etiquetages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @administration = Administration.find(params[:id])\n @administration.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n admin_only\n @consuming_enrollment.destroy\n respond_to do |format|\n format.html { redirect_to consuming_enrollments_url, notice: 'Consuming enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admins_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admins_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @assessment = Assessment.find(params[:id])\n @assessment.destroy\n \n respond_to do |format|\n format.html { redirect_to(assessments_url) }\n format.xml { head :ok }\n end\n end", "def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend", "def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_admins_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_admins_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entitlement = Entitlement.find(params[:id])\n @entitlement.destroy\n\n respond_to do |format|\n format.html { redirect_to(entitlements_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lease = Lease.find(params[:id])\n @lease.destroy\n\n respond_to do |format|\n format.html { redirect_to(leases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @adminnistrador = Adminnistrador.find(params[:id])\n @adminnistrador.destroy\n\n respond_to do |format|\n format.html { redirect_to(adminnistradors_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @course = Course.where(:id=>params[:id]).first()\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_courses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Matrícula excluída com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @enroll.destroy\n respond_to do |format|\n format.html { redirect_to enrolls_url, notice: 'Enroll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hr_attendence = Hr::Attendence.find(params[:id])\n @hr_attendence.destroy\n\n respond_to do |format|\n format.html { redirect_to(hr_attendences_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @educator = Educator.find(params[:id])\n @educator.destroy\n\n respond_to do |format|\n format.html { redirect_to(educator_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entradas = Entrada.find(params[:id])\n @entradas.destroy\n\n respond_to do |format|\n format.html{ redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @asignacionexa = Asignacionlabexa.find(params[:id])\r\n @asignacionexa.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(asignacionlabexas_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end", "def destroy\n @renewal = Renewal.find(params[:id])\n @renewal.destroy\n\n respond_to do |format|\n format.html { redirect_to(renewals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @article = Article.find_by_sysname(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(articles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @inbound_email_log = InboundEmailLog.find(params[:id])\n @inbound_email_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(inbound_email_logs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @trip_enrollment = TripEnrollment.find(params[:id])\n @trip_enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to(trip_enrollments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n child = @enrollment.child\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to child, notice: tr(\"enrollment_destroyed\") }\n end\n end", "def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to business_membership_url(@business, @membership) }\n end\n end", "def destroy\n @absence_request = AbsenceRequest.find(params[:id])\n @absence_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(absence_requests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @article = Article.find(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_articles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @article = Article.find(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_articles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lineaedesal = Lineaedesal.find(params[:id])\n @lineaedesal.destroy\n\n respond_to do |format|\n format.html { redirect_to(lineaedesals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exalumno = @alumno.exalumno\n @exalumno.destroy\n\n respond_to do |format|\n format.html { redirect_to(alumno_path(@alumno)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @certificado = Certificado.find(params[:id])\n @certificado.destroy\n\n respond_to do |format|\n format.html { redirect_to(certificados_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enroll.destroy\n respond_to do |format|\n format.html { redirect_to enrolls_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_enroll }\n end\n end", "def destroy\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n @supervisor_estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(supervisor_estagios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @exhibition = Exhibition.find_by_urlname(params[:id])\r\n @exhibition.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(:controller=>:admin, :action => :exhibition_list) }\r\n format.xml { head :ok }\r\n end\r\n end", "def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend", "def destroy\n @enrollment=Enrollment.find(params[:id])\n if @enrollment.present?\n @enrollment.destroy\n end\n redirect_to request.referrer\n end", "def destroy\n @tree_node_ac_rights = TreeNodeAcRight.find(params[:id])\n @tree_node_ac_rights.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_tree_node_tree_node_permissions_path }\n format.xml { head :ok }\n end\n end", "def destroy\n @req_breakdown = ReqBreakdown.find(params[:id])\n @req_breakdown.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_req_breakdowns_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_test = Admin::Test.find(params[:id])\n @admin_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_tests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entrada = Entrada.find(params[:id])\n @entrada.destroy\n\n respond_to do |format|\n format.html { redirect_to(mngr_entradas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @invier_acceso = InvierAcceso.find(params[:id])\n @invier_acceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(invier_accesos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @administration_email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(administration_email_templates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exp = Exp.find(params[:id])\n @exp.destroy\n\n respond_to do |format|\n format.html { redirect_to(exps_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @college = College.find(params[:id])\n @college.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_colleges_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @administrativo = Administrativo.find(params[:id])\n @administrativo.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrativos_url) }\n format.xml { head :ok }\n end\n end", "def educations_del\r\n edu_profile_id = params[:edu_profile_id]\r\n edu_profile = EducationProfile.find(edu_profile_id, :select => \"id, account_id\")\r\n \r\n return jump_to(\"/errors/forbidden\") unless edu_profile.account_id == session[:account_id]\r\n \r\n EducationProfile.delete(edu_profile_id)\r\n @edu_profile_entry_id = \"edu_profile_#{edu_profile_id}\"\r\n end", "def destroy\n @envelope = Envelope.find(params[:id])\n @envelope.destroy\n\n respond_to do |format|\n format.html { redirect_to(envelopes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @course_degree = CourseDegree.find(params[:id])\n @course_degree.destroy\n\n respond_to do |format|\n format.html { redirect_to(course_degrees_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ordendetalle = Ordendetalle.find(params[:id])\n @ordendetalle.destroy\n\n respond_to do |format|\n format.html { redirect_to(ordendetalles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @upgrade = Upgrade.find(params[:id])\n @upgrade.destroy\n\n respond_to do |format|\n format.html { redirect_to(upgrades_url) }\n format.xml { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @employeebankmaster = Employeebankmaster.find(params[:id])\n @employeebankmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(employeebankmasters_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @atest = Atest.find(params[:id])\n @atest.destroy\n\n respond_to do |format|\n format.html { redirect_to(atests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @student_attendance = StudentAttendance.find(params[:id])\n @student_attendance.destroy\n\n respond_to do |format|\n format.html { redirect_to(student_attendances_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluate_course = EvaluateCourse.find(params[:id])\n @evaluate_course.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluate_courses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @prd_etc = PrdEtc.find(params[:id])\n @prd_etc.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_etcs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exammaker = Exammaker.find(params[:id])\n @exammaker.destroy\n\n respond_to do |format|\n format.html { redirect_to(exammakers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exammaker = Exammaker.find(params[:id])\n @exammaker.destroy\n\n respond_to do |format|\n format.html { redirect_to(exammakers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @docent = Docent.find(params[:id])\n @docent.destroy\n\n respond_to do |format|\n format.html { redirect_to(docents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @accident_assignee_expense = AccidentAssigneeExpense.find(params[:id])\n @accident_assignee_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(accident_assignee_expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @orc_uni_despesa = OrcUniDespesa.find(params[:id])\n @orc_uni_despesa.destroy\n\n respond_to do |format|\n format.html { redirect_to(orc_uni_despesas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @almacen = Almacen.find(params[:id])\n @almacen.destroy\n \n respond_to do |format|\n format.html { redirect_to(almacenes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluacione = Evaluacione.find(params[:id])\n @evaluacione.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @accordion = Accordion.find(params[:id])\n @accordion.destroy\n\n respond_to do |format|\n format.html { redirect_to(accordions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_courses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @employeer = Employeer.find(params[:id])\n @employeer.destroy\n\n respond_to do |format|\n format.html { redirect_to(employeers_url) }\n format.xml { head :ok }\n end\n end", "def destroy \n @administration_offering.destroy\n\n respond_to do |format|\n format.html { redirect_to(administration_offerings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @agent = Agent.find(params[:id])\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to(agents_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end" ]
[ "0.6982586", "0.66441727", "0.66232467", "0.66232055", "0.6545451", "0.653755", "0.6508032", "0.64824784", "0.6458054", "0.64530575", "0.6424514", "0.64085263", "0.6378808", "0.6378808", "0.6365029", "0.63641405", "0.63586396", "0.6342038", "0.63415694", "0.6340282", "0.63310367", "0.63310367", "0.6326215", "0.6315432", "0.6305946", "0.6305946", "0.62976086", "0.62951094", "0.62923455", "0.62831986", "0.62785035", "0.6257377", "0.6257006", "0.62477237", "0.6241117", "0.6240185", "0.6222678", "0.6221753", "0.6217783", "0.62156427", "0.6213942", "0.62087256", "0.62071985", "0.6205916", "0.62022537", "0.6196762", "0.61945", "0.61880666", "0.61876523", "0.61876523", "0.6185773", "0.6180865", "0.6180865", "0.6180865", "0.6180865", "0.6180865", "0.6178613", "0.61721975", "0.61694354", "0.61685103", "0.6166481", "0.6157716", "0.61545515", "0.6150803", "0.6149291", "0.61484474", "0.61476696", "0.6145395", "0.6144454", "0.6139578", "0.6131625", "0.61299443", "0.6121394", "0.61179256", "0.61176795", "0.611655", "0.61164314", "0.61134565", "0.6113043", "0.61098534", "0.6109609", "0.6108337", "0.61044633", "0.6103743", "0.60955286", "0.60899156", "0.6087196", "0.6080757", "0.60804504", "0.60804504", "0.6079906", "0.60793936", "0.607576", "0.6065873", "0.6063459", "0.60610044", "0.60585046", "0.60565627", "0.6051019", "0.6050916" ]
0.60688674
93
Generate a searchable schema list in the output
def generate_schema_list puts "GENERATE SCHEMA LIST" # load all the features from the Registry @items = Registry.all(:schema).sort { |a,b| a.name.downcase <=> b.name.downcase } @list_title = "Schema List" @list_type = "schema" # optional: the specified stylesheet class # when not specified it will default to the value of @list_type @list_class = "schema" # Generate the full list html file with named feature_list.html # @note this file must be match the name of the type asset('schema_list.html', erb(:full_list)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @schemas = Schema.all\n end", "def schema\n []\n end", "def available_schemas\n load_schemas.transform_values(&:description).to_a\n end", "def user_defined_schemas(stream)\n return if (list = (@connection.user_defined_schemas - ['public'])).empty?\n\n stream.puts \" # Custom schemas defined in this database.\"\n list.each { |name| stream.puts \" create_schema \\\"#{name}\\\", force: :cascade\" }\n stream.puts\n end", "def schema\n @schema ||= []\n end", "def get_schemas\n @schemas\n end", "def schemas(stream)\n # Don't create \"public\" schema since it exists by default.\n schema_names = PgPower::Tools.schemas - [\"public\", \"information_schema\"]\n schema_names.each do |schema_name|\n schema(schema_name, stream)\n end\n stream << \"\\n\"\n end", "def print_schema(schema)\n print_filtered_schema(schema, method(:is_defined_type))\n end", "def search_schemas(opts = {})\n data, _status_code, _headers = search_schemas_with_http_info(opts)\n return data\n end", "def schema\n execute(<<-eosql).collect { |row| row[0] }.collect { |t| table_schema(t) }\nSELECT rdb$relation_name FROM rdb$relations WHERE rdb$system_flag != 1\neosql\n end", "def create_search_schema(name, content)\n @data[:search_schemas][name] = {:name => name, :content => content}\n true\n end", "def chooseSchema\n @metadata.chooseSchema\n end", "def search_schemas(opts = {})\n data, _status_code, _headers = search_schemas_with_http_info(opts)\n data\n end", "def print_introspection_schema\n query_root = ObjectType.define do\n name \"Query\"\n end\n schema = Schema.new(query: query_root)\n print_filtered_schema(schema, method(:is_introspection_type))\n end", "def build_schema(**args)\n if object.respond_to?(:each)\n build_collection_schema(args)\n else\n Surrealist.build_schema(instance: self, **args)\n end\n end", "def index\n @schema_tables = SchemaTable.all\n end", "def filter_shema(schema)\n schema.filter{|obj| include?(obj)}\n end", "def all_schemas\n query('SELECT schema_name FROM information_schema.schemata').flatten\n end", "def list_schemas view, options = {}\n schema_view = Google::Cloud::PubSub::V1::SchemaView.const_get view.to_s.upcase\n paged_enum = schemas.list_schemas parent: project_path(options),\n view: schema_view,\n page_size: options[:max],\n page_token: options[:token]\n\n paged_enum.response\n end", "def compare_schemas\n\t\t\tapi_sort = @api_model.schema.sort\n\t\t\tar_sort = @ar_model.schema.sort\n\t\t\tlongest = find_longest_field + 5\n\t\t\tspaces = \" \"*(longest-10)\n\t\t\tputs \"API Schema#{spaces}| AR Schema\"\n\t\t\tputs '__________________________'\n\t\t\tapi_sort.each_with_index do |field, i|\n\t\t\t\tspaces = \" \"*(longest - field[0].length)\n\t\t\t\tputs \"#{field[0]}#{spaces}| #{ar_sort[i][0]}\"\n\t\t\tend\n\t\tend", "def index\n @schemas = Schema.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schemas }\n end\n end", "def schema_search_path\n @schema_search_path ||= select_value('SHOW search_path', 'SCHEMA')\n end", "def generate_definitions_list\n definitions = YARD::Registry.all(:definition).uniq.sort_by{|define| define.name.to_s}\n generate_full_list(definitions, 'Definition', 'definitions')\nend", "def schema_definition\n of.schema_definition \n end", "def schema_search_path\n @schema_search_path ||= select_value('SHOW search_path', 'SCHEMA')\n end", "def schema\n raise NotImplementedError\n end", "def build_schemas(parent_schema)\n # Build ref schemas if they exist\n if parent_schema.schema[\"$ref\"]\n load_ref_schema(parent_schema, parent_schema.schema[\"$ref\"])\n end\n if parent_schema.schema[\"extends\"]\n if parent_schema.schema[\"extends\"].is_a?(String)\n load_ref_schema(parent_schema, parent_schema.schema[\"extends\"])\n elsif parent_schema.schema[\"extends\"].is_a?(Array)\n parent_schema.schema[\"extends\"].each do |type|\n handle_schema(parent_schema, type)\n end\n end\n end\n\n # handle validations that always contain schemas\n [\"allOf\", \"anyOf\", \"oneOf\", \"not\"].each do |key|\n if parent_schema.schema.has_key?(key)\n validations = parent_schema.schema[key]\n validations = [validations] unless validations.is_a?(Array)\n validations.each {|v| handle_schema(parent_schema, v) }\n end\n end\n\n # Check for schemas in union types\n [\"type\", \"disallow\"].each do |key|\n if parent_schema.schema[key] && parent_schema.schema[key].is_a?(Array)\n parent_schema.schema[key].each_with_index do |type,i|\n if type.is_a?(Hash)\n handle_schema(parent_schema, type)\n end\n end\n end\n end\n\n # \"definitions\" are schemas in V4\n if parent_schema.schema[\"definitions\"]\n parent_schema.schema[\"definitions\"].each do |k,v|\n handle_schema(parent_schema, v)\n end\n end\n\n # All properties are schemas\n if parent_schema.schema[\"properties\"]\n parent_schema.schema[\"properties\"].each do |k,v|\n handle_schema(parent_schema, v)\n end\n end\n if parent_schema.schema[\"patternProperties\"]\n parent_schema.schema[\"patternProperties\"].each do |k,v|\n handle_schema(parent_schema, v)\n end\n end\n\n # Items are always schemas\n if parent_schema.schema[\"items\"]\n items = parent_schema.schema[\"items\"].clone\n single = false\n if !items.is_a?(Array)\n items = [items]\n single = true\n end\n items.each_with_index do |item,i|\n handle_schema(parent_schema, item)\n end\n end\n\n # Convert enum to a ArraySet\n if parent_schema.schema[\"enum\"] && parent_schema.schema[\"enum\"].is_a?(Array)\n parent_schema.schema[\"enum\"] = ArraySet.new(parent_schema.schema[\"enum\"])\n end\n\n # Each of these might be schemas\n [\"additionalProperties\", \"additionalItems\", \"dependencies\", \"extends\"].each do |key|\n if parent_schema.schema[key].is_a?(Hash)\n handle_schema(parent_schema, parent_schema.schema[key])\n end\n end\n\n end", "def schema_meta_data\n schema = []\n # not sure if there needs to be a header element with the number of columns in it\n # would look sort of like this\n # header = SchemaElement.new\n # header.name = @csv.rows.first.first\n # header.num_children = num_rows\n # schema << header\n @csv.headers.each do |header|\n schema << Configurator.schema_element_with_defaults({\n name: header\n })\n end\n\n schema\n end", "def build_schema(**args)\n if Helper.collection?(object)\n build_collection_schema(**args)\n else\n Surrealist.build_schema(instance: self, **args)\n end\n end", "def schema(work_class_name:, context: nil)\n context ||= AllinsonFlex::Context.where(name: 'default')\n AllinsonFlex::DynamicSchema.where(\n allinson_flex_class: work_class_name,\n context: context\n ).order('created_at').last.schema\n rescue StandardError\n {}\n end", "def schemas\n @schema ||= Dir['schemas/*'].reduce({}) do |schemas, file|\n filename = parse_filename(file)\n schemas[filename] = File.read(file).split(\"\\n\").map do |row|\n values = row.split(',')\n {\n name: values[0],\n length: values[1],\n type: values[2]\n }\n end\n\n schemas\n end\n end", "def schema\n jiak.data.schema\n end", "def schemas\n @schemas ||= metadata.xpath('//Schema').map do |schema_xml|\n [\n schema_xml.attributes['Namespace'].value,\n Schema.new(schema_xml, self)\n ]\n end.to_h\n end", "def schemas\n @schemas ||= metadata.xpath('//Schema').map do |schema_xml|\n [\n schema_xml.attributes['Namespace'].value,\n Schema.new(schema_xml, self)\n ]\n end.to_h\n end", "def schema\n hyper_schema_link.schema\n end", "def get_tables\n get_schemas.keys\n end", "def list_schemas 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_list_schemas_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::DiscoveryEngine::V1::ListSchemasResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def schema_generator\n JSON::SchemaGenerator\n end", "def schema_search_path\n 'dbo'\n end", "def scaffold_field_type_list\n list = \"\"\n @fields.each {|field| list << field.scaffold_instruction}\n list\n end", "def get_schema_struct(table_name)\n dbres = do_sql_command(\"DESC #{table_name};\")\n\n dbstruct = []\n\n if(dbres) then\n dbres.each_hash do | row |\n dbstruct_hash = {}\n row.each {|key, val|\n dbstruct_hash[key.downcase.to_sym] = val \n }\n dbstruct << dbstruct_hash\n end \n end\n\n dbstruct\nend", "def search_keys \n return search_field_definitions.keys\n end", "def generate_data\n tokens = []\n # loop over schema files\n Dir.glob('assets/data/schema/*.xsd').map do |schema|\n data = read_file(schema)\n data.scan(/<xs:\\w+|\\w+=\"\\w+\"|\\w+=\"xs:\\w+\"/).uniq do |x|\n tokens << x unless tokens.include? x\n end\n data.scan(/<xs:\\w+ \\w+=\"\\w+\"/).uniq do |x|\n tokens << x unless tokens.include? x\n end\n end\n # create main data array\n structure = []\n tokens.sort.map.with_index do |x, i|\n structure[i] = [x]\n Dir.glob('assets/data/schema/*.xsd').map do |schema|\n filename = schema.split('/').last\n amount = read_file(schema).scan(x).size\n structure[i] << [filename, amount] unless amount.zero?\n end\n end\n structure\nend", "def index\n @price_schemas = PriceSchema.all\n end", "def structure\n {\n domain_name: @name,\n schemas: @schemas.map(&:structure)\n }\n end", "def schema_search_path\n @schema_search_path ||= exec_query('SHOW search_path', 'SCHEMA')[0]['search_path']\n end", "def create_schema\n schema = @index.schema\n unless schema.tables['search']\n @index.execute_batch <<-SQL\n CREATE VIRTUAL TABLE search USING fts5(\n sequence_number,\n kanji,\n kana,\n senses\n );\n SQL\n @index.reload_schema!\n end\n end", "def schema\n adapter.schema\n end", "def schema\n absolutize(@schema)\n end", "def schema\n absolutize(@schema)\n end", "def schema_find(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: SchemaApi#schema_find ...\"\n end\n \n # resource path\n path = \"/schema\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'model'] = opts[:'model'] if opts[:'model']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n result = @api_client.call_api(:GET, 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 => 'inline_response_200')\n if Configuration.debugging\n Configuration.logger.debug \"API called: SchemaApi#schema_find. Result: #{result.inspect}\"\n end\n return result\n end", "def show_schema(api_or_ar)\n\t\t\tif api_or_ar == \"api\"\n\t\t\t\t\"#{@name} Api Model: #{@api_model.schema}\"\n\t\t\telsif api_or_ar == \"ar\"\n\t\t\t\t\"#{@name} AR Model: #{@ar_model.schema}\"\n\t\t\telse\n\t\t\t\tputs \"show_schema arg requires a String with a value of either 'api' or 'ar'\"\n\t\t\tend\n\t\tend", "def schema\n @schema ||= get_parser(options)\n end", "def schema_search_path\n @schema_search_path ||= query('SHOW search_path')[0][0]\n end", "def fill_out\n @build = {}\n descend(@schema, [])\n @build\n end", "def showSkeltonInSchemaFile(schemaFiles)\n schemaFiles.each{|file|\n\tscanSchema(file) ;\n\t@xsd.elementList.each{|e|\n\t e.expandedStructure.describe($stdout) ;\n\t $stdout << '-' * 50 << \"\\n\" ;\n\t}\n }\n end", "def build_collection_schema(**args)\n object.map { |object| self.class.new(object, context).build_schema(args) }\n end", "def load_schemas\n\t\t\tschema_instructions = []\n\t\t\tschema_pi = self.find_all { |i| i.is_a? REXML::Instruction and i.target == 'xml:schema' }\n\t\t\tschema_pi.each do |i|\n\t\t\t\tif i.attributes.has_key?('url')\n i.attributes['source'] = i.attributes['url']\n elsif i.attributes.has_key?('source')\n i.attributes['url'] = i.attributes['source']\n else\n raise \"parse error schema instruction missing required url attribute\"\n end\n if i.attributes.has_key?('uri')\n i.attributes['space'] = i.attributes['uri']\n elsif i.attributes.has_key?('space')\n i.attributes['uri'] = i.attributes['space']\n else\n raise \"parse error schema instruction missing required type attribute\"\n end\n schema_instructions << i\n\t\t\tend\n\t\t\treturn schema_instructions\n\t\tend", "def schema_names\n select_value(<<-SQL, 'SCHEMA')\n SELECT nspname\n FROM pg_namespace\n WHERE nspname !~ '^pg_.*'\n AND nspname NOT IN ('information_schema')\n ORDER by nspname;\n SQL\n end", "def get_schemas(tag, sname, node, attrs)\n begin\n engine = Marty::ScriptSet.new(tag).get_engine(sname+'Schemas')\n result = engine.evaluate_attrs(node, attrs, {})\n attrs.zip(result)\n rescue => e\n use_message = e.message == 'No such script' ?\n 'Schema not defined' : 'Problem with schema'\n raise \"Schema error for #{sname}/#{node} \"\\\n \"attrs=#{attrs.join(',')}: #{use_message}\"\n end\n end", "def show\n respond_with(@schema) do |format|\n format.json { render json: @schema.to_json }\n end\n end", "def get_schema_id_iterator\n\t\tend", "def get_course_templates_schema\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/schema\"\n _get(path)\n # This action returns a JSON array of SchemaElement blocks.\nend", "def schema_meta_structure\n CreateVersionsTableQuery.new.to_cql\n end", "def schema_tables\n @schema_tables ||= %i[\n projects\n amazon_clouds\n data_centers\n jmeter_plans\n load_agents\n target_hosts\n clusters\n execution_cycles\n client_stats\n page_stats\n target_stats\n jtl_files\n ]\n end", "def response_schema(additional_meta_fields = {})\n fields = Array.new \n # Rails.logger.debug(\"before making response schema, data columns are: \" + self.data_columns.size.inspect)\n # Rails.logger.debug(\"before making response schema, data columns are: \" + self.data_columns.class.inspect)\n \n self.data_columns.each do |column_name, opts| \n # Rails.logger.debug(\"data_column: \" + column_name.inspect)\n column_response_schema = {:key => column_name.to_s}\n \n if opts.has_key?(:parser)\n column_response_schema[:parser] = opts[:parser]\n elsif column_opts = self.data_columns[column_name.to_sym]\n if field_def = column_opts[:field_def]\n if yui_parser = field_def.yui_parser\n column_response_schema[:parser] = yui_parser\n end\n end\n end\n \n # Rails.logger.debug(\"adding field: \" + column_response_schema.inspect) \n fields << column_response_schema\n end\n \n\n # Rails.logger.debug(\"returning response schema, fields are: \" + fields.inspect) \n { :resultsList => 'records', \n :fields => fields,\n :metaFields => {\n :totalRecords => \"total_records\",\n :paginationRecordOffset => \"offset\",\n :paginationRowsPerPage => \"page_size\",\n :sortKey => \"order_key\",\n :sortDir => \"order_dir\"\n }.merge(additional_meta_fields)\n }\n end", "def index\n @schema_categories = SchemaCategory.all\n end", "def get_document_schema\n filePath = Rails.root.join(\"lib\", \"base_truevault_doc.json\")\n file = File.read(filePath)\n schema = JSON.parse(file).with_indifferent_access\n end", "def read_all(path=nil)\n schemas = []\n file_path = File.join(path || SchemaTools.schema_path, '*.json')\n Dir.glob( file_path ).each do |file|\n schema_name = File.basename(file, '.json').to_sym\n schemas << read(schema_name, path)\n end\n schemas\n end", "def schema\n self.class.schema\n end", "def resource_schema\n schemated = {}\n resource.columns_hash.each { |key, value| schemated[key] = value.type }\n schemated\n end", "def search_schemas_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DevelopersApi.search_schemas ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'skip'].nil? && opts[:'skip'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"skip\"]\" when calling DevelopersApi.search_schemas, must be greater than or equal to 0.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 50\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling DevelopersApi.search_schemas, must be smaller than or equal to 50.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling DevelopersApi.search_schemas, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = \"/schemas\"\n\n # query parameters\n query_params = {}\n query_params[:'searchString'] = opts[:'search_string'] if !opts[:'search_string'].nil?\n query_params[:'skip'] = opts[:'skip'] if !opts[:'skip'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'Array<Schema>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DevelopersApi#search_schemas\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def solr_schema_xml\n template = File.open( \"#{File.dirname(__FILE__)}/../templates/solr_schema.xml.erb\", \"r\" )\n erb = ERB.new( template.read, nil, \"-\" )\n schema = erb.result( binding )\n return schema\n end", "def get_search_schema(name)\n search_schema = @data[:search_schemas][name]\n raise ProtobuffsErrorResponse.new(BeefcakeProtobuffsBackend::RpbErrorResp.new(:errcode => 0, :errmsg => 'notfound')) unless search_schema\n\n BeefcakeProtobuffsBackend::RpbYokozunaSchema.new(search_schema)\n end", "def build_collection_schema(**args)\n object.map { |object| self.class.new(object, **context).build_schema(**args) }\n end", "def schema_search_path=(schema_csv)\n if schema_csv\n existing_schemas = execute(\"select nspname from pg_catalog.pg_namespace;\").values\n unless existing_schemas.map{|x| x[0]}.include?(schema_csv)\n execute(\"CREATE SCHEMA #{schema_csv}\")\n end\n execute(\"SET search_path TO #{schema_csv}\", 'SCHEMA')\n @schema_search_path = schema_csv\n end\n end", "def index\n @custom_definitions = CustomDefinition.all\n end", "def schema_names\n select_values(\n \"SELECT nspname FROM pg_namespace\" <<\n \" WHERE nspname !~ '^pg_.*' AND nspname NOT IN ('information_schema')\" <<\n \" ORDER by nspname;\",\n 'SCHEMA')\n end", "def schema_version_list\n result = []\n Dir.glob(\"#{File.dirname(__FILE__)}/expands/v*.rb\") do |f|\n result << File.basename(f, '.rb')\n end\n result.sort\n end", "def scaffold_auto_complete_result(entries)\n return unless entries\n content = '<ul>'\n entries.collect{|entry| content << \"<li>#{h(entry.scaffold_name_with_id)}</li>\"}\n content << '</ul>'\n content\n end", "def ls\n show_fields = options[:l] ? %w[name appid stateflags sizeondisk] : %w[name]\n output = @apps.map do |id, app|\n app.select{ |field| show_fields.include?(field) }\n end\n\n puts output.map{ |o| o.values.join(\"\\t\")}.join(\"\\n\")\n end", "def schema\n schema = Schema.new\n\n for name in db.tables\n next if IGNORED_TABLES.include? name\n table = schema.add_table( name )\n import_table( table )\n end\n\n schema\n end", "def findAll\n # returns the definitions as an array of definition hashes inside the hash for the individual words\n MinWords::DB[:words].all.map {|e| e.merge({ definitions: definitions(e)}) }\n end", "def list(regex = '.*')\n @admin.listTableNames(Pattern.compile(regex)).map(&:getNameAsString)\n end", "def schema(schema_name, stream)\n stream << \" create_schema \\\"#{schema_name}\\\"\\n\"\n end", "def format_schema_helper(hsh)\n hsh = map_data_types(hsh)\n hsh.map { |column_name,column_type| [\"#{column_type}\".to_sym,\"#{column_name}\"] }\n end", "def structure\n self.change_schema_to 'information_schema';\n @database_name, @table_name = request[:database_name], request[:name]\n @result = Hash.new success: true\n @result[:columns] = Column.where TABLE_SCHEMA: @database_name, TABLE_NAME: @table_name\n structure = Table.where(TABLE_SCHEMA: @database_name, TABLE_NAME: @table_name).first.attributes\n @result[:desc] = []\n structure.keys.length.times do |i|\n key = structure.keys[i]\n @result[:desc].push COLUMN_NAME: key, COLUMN_TYPE: structure[key]\n end\n \n @result[:type] = 'table'\n @result[:name] = @table_name\n \n render json: @result\n end", "def schema\n self\n end", "def load_physical_schema(conn, builder)\n builder.indexes{\n conn.tables.each{|table|\n conn.indexes(table).each_pair{|name, defn|\n next if defn[:unique]\n builder.index(name, {:relvar => table, :attributes => defn[:columns]})\n }\n }\n }\n end", "def to_s\n\t\tparts = [ \"Schema:\" ]\n\t\tparts << self.ivar_descriptions.collect {|desc| ' ' + desc }\n\t\treturn parts.join( $/ )\n\tend", "def schema\n return @schema\n end", "def schema\n UrlScraper::TYPES.each_pair do |schema, types|\n return schema if types.include?(self.type)\n end\n nil\n end", "def structure\n [\n # scaffold inject marker\n ]\n end", "def load_schemas!\n @schema_store.load_schemas!\n end", "def define_schema\n yield schema if block_given?\n end", "def format_model_schema(klass)\n hsh = klass.columns_hash.map { |column_name,column| [column_name, column.type] }.to_h\n format_schema_helper(hsh)\n end", "def index\n @metadata_schemas = MetadataSchema.arrange(:order => :created_at)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @metadata_schemas }\n end\n authorize! :metadata_schemas, MetadataSchema\n end", "def index\n # @schemas = Schema.where(default: false)\n\n ####CLEANUP FUNCTION - SUPER QUICK###\n orphans = Schema.where(disabled: false).where([ \"id NOT IN (?)\", Account.select(:schema_id).where(banned: false, created: true)])\n orphans.update_all(disabled: true)\n\n @schemas = Schema.ordered_by_use\n\n end", "def schema_for(collection_name)\n params = Params.new.limit(1).filter('name' => collection_name)\n schemas.list(params).first\n end", "def schema(table, opts={})\n hero = execute(\"DESCRIBE #{table}\")\n hero.map do |h|\n [\n h[:col_name].strip.to_sym,\n { :db_type => h[:data_type].strip , :comment => h[:comment].strip }\n ]\n end\n end" ]
[ "0.64337724", "0.6202368", "0.6157455", "0.6154027", "0.614332", "0.61003363", "0.60073525", "0.60014963", "0.59498584", "0.5901143", "0.58913946", "0.58911574", "0.5885941", "0.5870931", "0.58381474", "0.5816694", "0.58004546", "0.5765432", "0.5716042", "0.56836516", "0.56821996", "0.56792533", "0.56685334", "0.5658259", "0.5653051", "0.5649213", "0.5603232", "0.55892354", "0.5581556", "0.55813384", "0.5559015", "0.55398357", "0.55318695", "0.55318695", "0.5517423", "0.549872", "0.54791784", "0.54738253", "0.5472149", "0.5470768", "0.5469967", "0.5468194", "0.5467839", "0.54670215", "0.5445775", "0.54210657", "0.54187685", "0.5413386", "0.54058063", "0.54058063", "0.5365965", "0.53396946", "0.5326912", "0.53242826", "0.5323277", "0.5311148", "0.5307871", "0.5300651", "0.53000706", "0.52922696", "0.52901626", "0.5288619", "0.5266929", "0.52619004", "0.5261169", "0.5255362", "0.52535903", "0.5231733", "0.52313286", "0.5229863", "0.5222878", "0.52206314", "0.52178353", "0.52087194", "0.5207776", "0.52046937", "0.5202111", "0.52012616", "0.52003753", "0.5194882", "0.51910853", "0.5177467", "0.5176164", "0.51759404", "0.51738155", "0.5162677", "0.5150092", "0.5135323", "0.5129137", "0.51273394", "0.5118793", "0.5114685", "0.5111532", "0.5102722", "0.5101936", "0.51010585", "0.509708", "0.5095792", "0.508948", "0.50879985" ]
0.6860441
0
Create a new Website
def initialize(title = "Link List") @links = [] @title = title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\t\t@website = Website.new(params[:website])\n\n\t\trespond_to do |format|\n\t\t\tif @website.save\n\t\t\t\tflash[:notice] = 'Website was successfully created.'\n\t\t\t\tformat.html { redirect_to websites_url }\n\t\t\t\tformat.xml\t{ render :xml => @website, :status => :created, :location => @website }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml\t{ render :xml => @website.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def new_site\n \n end", "def create_web(name, template, options = {}, &blk)\n\t\t\t # create our new web\n\t\t\t new_web = Webs.create_web(@web, name, template, options)\n\t\t\t context_for_new_object(new_web, WebContext, &blk)\n\t\t\tend", "def create\n @website = Website.new(params[:website])\n\n respond_to do |format|\n if @website.save\n flash[:notice] = 'Website was successfully created.'\n format.html { redirect_to(@website) }\n format.xml { render :xml => @website, :status => :created, :location => @website }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @website.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @website = Website.new(params[:website])\n\n respond_to do |format|\n if @website.save\n flash[:notice] = 'Website was successfully created.'\n format.html { redirect_to admin_website_url(@website) }\n format.xml { head :created, :location => admin_websites_url }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @website.errors.to_xml }\n end\n end\n end", "def create\n @website = websites.new(website_params)\n\n respond_to do |format|\n if @website.save\n flash[:notice] = :success\n format.html { redirect_to @website, notice: 'Website was successfully created.' }\n format.json { render :show, status: :created, location: @website }\n else\n format.html { render :new }\n format.json { render json: @website.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_website(website_name=nil)\n set_param(:method, 'SitesManager.addSite')\n if website_name == nil # post path\n set_param(:siteName, get_param(:website_name))\n set_param(:urls, get_param(:website_name))\n else # login path\n set_param(:siteName, website_name)\n set_param(:urls, website_name)\n end\n\n url_string = @metrics_admin_url + @metrics_params.slice(:module, :method, :siteName, :urls, :ecommerce, :timezone,\n :token_auth).to_query\n xstring = api_call(url_string)\n site_id = xstring.xpath('//result/text()').map(&:text)[0]\n set_param(:idSite, site_id)\n site_id.to_i\n end", "def run( args )\n parse args\n create_site\n end", "def create\n flash[:notice] = 'The website was successfully added.' if website.save\n respond_with(website)\n end", "def createSite _obj, _args\n \"_obj createSite _args;\" \n end", "def create_site(params={name:random_string})\n\t\tnew_site = site[:new]\n\t\tparams[:site] = params[:name]\n\t\tnew_site[:params].merge!(params)\n\t\tnew_site[:params][:address] = append_ftp_value(new_site[:params][:address],new_site[:params][:ftp_type])\n\t\tpost(new_site)\n\tend", "def create\n @website = Website.new(website_params)\n\n if @website.save\n render json: @website, status: :created, location: @website\n else\n render json: @website.errors, status: :unprocessable_entity\n end\n end", "def create\n @website = Website.new(website_params) \n @website.user_id = current_user.id\n\n respond_to do |format|\n if @website.save\n\n Website.create_home_page(@website)\n\n format.html { redirect_to @website, notice: 'Website was successfully created.' }\n format.json { render :show, status: :created, location: @website }\n else\n format.html { render :new }\n format.json { render json: @website.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t url = params.require(:site)[:url]\n\t site = Site.create(url: url)\n\t LinksWorker.perform_async(site.id)\n\t redirect_to site_path(site)\n\tend", "def new\n @website = Website.new params[:website]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @website }\n end\n end", "def create_site\n if params[:site]\n @site_url = TabSite.new(params[:site])\n flash[:notice]= @site_url.save ? \"Tab site created successfully.\" : \"Tab site not created.\"\n redirect_to \"/users/profile/#{@login_user.id}\"\n end\n end", "def create\n raise ArgumentError, \"Site already exists in Piwik, call 'update' instead\" unless new?\n raise ArgumentError, \"Name can not be blank\" if name.blank?\n raise ArgumentError, \"Main URL can not be blank\" if main_url.blank?\n xml = call('SitesManager.addSite', :siteName => name, :urls => main_url)\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n @id = result.to_i\n @created_at = Time.current\n id && id > 0 ? true : false\n end", "def create\n require 'open-uri'\n @site = Site.find_or_initialize_by(site_params)\n if @site.save\n #render text: @site\n redirect_to site_path(@site)\n else\n redirect_to :back, :flash => {:error => @site.errors[:url]}\n end\n end", "def create\n set_meta_tags :nofollow => true\n\n @website = Website.new(params[:website])\n\n respond_to do |format|\n if @website.save\n format.html { redirect_to :back, notice: 'Thank you! We will be in touch with you very soon!' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @website.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n\t\t@website = Website.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml\t{ render :xml => @website }\n\t\tend\n\tend", "def create_site\n # create it in the default locale\n Mounter.with_locale(self.default_locale) do\n self.output_locale\n\n self.output_resource_op self.site\n\n if (site = self.post(:sites, self.site.to_hash(false), Mounter.locale)).nil?\n raise Mounter::WriterException.new('Sorry, we are unable to create the site.')\n else\n self.site._id = site['id']\n self.output_resource_op_status self.site\n end\n end\n\n # update it in other locales\n self.update_site(true)\n end", "def generate_blank_for_new_site(options = {})\n @site = Site.new({ \n :short_name => nil, \n :full_name => nil, \n :url => nil, \n :comments_allowed => true,\n :active => true })\n end", "def create\n @pwebsite = Pwebsite.new(params[:pwebsite])\n\n respond_to do |format|\n if @pwebsite.save\n format.html { redirect_to(@pwebsite, :notice => 'Pwebsite was successfully created.') }\n format.xml { render :xml => @pwebsite, :status => :created, :location => @pwebsite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pwebsite.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new_site_create(params={})\n study_study_sites.set params[:site_name]\n site_number.set params[:site_number]\n study_site_number.set params[:study_site_number]\n end", "def create_site(sitecontainer, title = \"Test Site\", sitepath = \"\", sitetemplate=nil )\n\t path = @sling.url_for(sitecontainer)\n res = @sling.execute_post(path+\".createsite.json\", \"sakai:title\" => title, \":sitepath\" => sitepath, \"sakai:site-template\" => sitetemplate )\n if (res.code != \"200\" && res.code != \"201\")\n puts \"Unable to create site: #{res.code} #{res.body}\"\n return nil\n end\n return Site.new(@sling, sitecontainer+sitepath)\n end", "def new\n @web= Web.new\n end", "def create_webform(title, fields, browser = @browser)\n browser.navigate.to($config['sut_url'] + create_webform_url)\n Log.logger.debug(\"Entering new webform title '#{title}'\")\n fields.each{|fieldname|\n self.add_webform_component(fieldname)\n }\n self.add_webform_title(title)\n message = self.save_webform(browser)\n return message\n end", "def new\n @page_title = \"Web Design & Development Price Calculator\"\n @page_description = \"Free onsite SEO with every new website built with Web Design Stories. We specialize in small companies sector, build your brand and become one of the successful companies.\"\n @page_keywords = 'Web Design Calculator, Website calculator, web development price calculator, price calculator website, website, calculator'\n \n @breadcrumb = \"New Website\"\n @website = Website.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @website }\n end\n end", "def create\n @web = Web.new(web_params)\n\n respond_to do |format|\n if @web.save\n format.html { redirect_to @web, notice: 'Web was successfully created.' }\n format.json { render :show, status: :created, location: @web }\n else\n format.html { render :new }\n format.json { render json: @web.errors, status: :unprocessable_entity }\n end\n end\n end", "def finish_site_creation(browser, user, password, site_prefix, template, timeout = 300, template_selected = false)\n Log.logger.info(\"Finishing the site creation for #{site_prefix}.\")\n # If selecting features then template will be selected first and then its features. And finally it comes for finish site creation from testcase.\n if (template_selected == false)\n self.template_selection(template, browser)\n else\n Log.logger.debug(\"Template for #{site_prefix} already selected\")\n end\n # Submit our template choice, start website creation process\n create_site_btn = 'edit-submit'\n Log.logger.info(\"Waiting for the create site button for #{site_prefix}\")\n wait = Selenium::WebDriver::Wait.new(:timeout => 30)\n btn = wait.until { browser.find_element(:xpath => create_site_btn) }\n Log.logger.info(\"Clicking the submit button for #{site_prefix}: #{create_site_btn}\")\n btn.click\n if browser.find_element(:xpath => \"//body\").text.include?(\"We were unable to create the site for #{site_prefix}\")\n browser.quit\n raise(\"Site creation for #{site_prefix} failed, got the 'We were unable to create the site' message :(\")\n end\n\n # Cue Jeopardy music while waiting for loading bar\n Log.logger.info(\"Waiting for progress bar for #{site_prefix} to go away\")\n begin\n self.wait_for_progress_bar(browser, site_prefix, timeout)\n rescue Exception => e\n #This can happen if we immediately run into the \"site creation busy\" screen.\n Log.logger.warn(\"Waiting for progress bar failed: #{e.message}.\")\n end\n \n retries = 0\n #We will loop and either fill this with the URL of the site or it will stay nil and the creation process failed\n return_value = nil\n\n #We will loop and check for a number of things to figure out\n #if we've already been redirected to our shiny new page\n #We could do it in javascript, but this way we get better logs and it won't time out on us that easily\n loop do\n sleep 2.5 #So we leave some time in between checks\n begin\n retries+=1\n if retries > 60\n Log.logger.error(\"We didn't get our site (#{site_prefix}) within our timeout limits :(\")\n #No point in continuing really\n break\n end\n #gather our current environments data\n begin\n current_location = browser.current_url\n rescue Exception => e\n Log.logger.warn(\"Got an exception while checking for current location: #{e.message}\")\n current_location = \"\"\n sleep 5\n end\n \n #when the browser is in the middle of a redirect, this sometimes is a bit wonky\n begin\n current_body = browser.get_body_text()\n rescue Exception => e\n Log.logger.info(\"Problem while getting html body for #{site_prefix}from #{current_location.inspect}: #{e.message.inspect}, ignoring\")\n current_body = \"\"\n end\n\n #start checking\n on_sites_url = current_location.include?(\"http://#{site_prefix}\")\n openid_in_url = current_location.include?(\"openid\")\n #space in front of 'front' because the error page has 'not-front'\n final_site_present = browser.find_elements(:xpath => \"//body[contains(@class, ' front')]\").size > 0\n Log.logger.info(\"Current URL: #{current_location} | on our site's domain -> #{on_sites_url} | openid in url -> #{openid_in_url} | final_site_present -> #{final_site_present}\")\n\n #Error Message:\n #http://gardener.gsteamer.acquia-sites.com/site-not-found?site=derp.gsteamer.acquia-sites.com\n #Check back soon, derp.gsteamer.acquia-sites.com is undergoing maintenance\n #The site you requested derp.gsteamer.acquia-sites.com is undergoing brief maintenance.\n site_not_found_page = current_location.include?(\"/site-not-found\")\n if site_not_found_page\n #We don't get redirected from here, so we have to click the link\n Log.logger.info(\"We are on the 'site not found' page for #{site_prefix}! Clicking on the 'try again' link.\")\n browser.find_element(:xpath => \"//a[text()='try again']\").click\n next\n end\n\n #http://gardener.gsteamer.acquia-sites.com/site-creation-busy\n #Oops, this is taking longer than usual\n site_creation_busy = current_location.include?(\"/site-creation-busy\")\n if site_creation_busy\n Log.logger.info(\"Temporary failure detected for #{site_prefix} (site creation busy, 'oooops'), waiting for site creation using special URL\")\n #finish the loop\n break\n end\n\n errors_present = current_body.include?(\"choose another name\") or current_body.include?(\"encountered error\") or \n\t\t \t (browser.find_elements(:xpath =>\"//div[@class='messages error']\").size > 0)\n\n if errors_present\n if browser.find_elements(:xpath => \"//div[@class='messages error']\").size > 0\n error_text = browser.find_element(:xpath => \"//div[@class='messages error']\").text\n Log.logger.info(\"Exiting for #{site_prefix} because of error message: #{error_text.inspect}\")\n else\n Log.logger.info(\"Exiting for #{site_prefix} because of error message\")\n end\n #and we're out...\n break\n end\n\n\n if (on_sites_url && !openid_in_url && final_site_present && !errors_present)\n Log.logger.info(\"Yay, we seem to be on our site for #{site_prefix}!\")\n #http://xqsqavrk.gsteamer.acquia-sites.com/node\n return_value = current_location.gsub(\"/node\", \"\")\n break\n end\n rescue Exception => e\n Log.logger.info(\"Error while checking for site. Retrying. #{site_prefix}: #{e.message.inspect}\\n#{e.backtrace.inspect}\")\n end\n end #loop\n \n #Check if we failed or not. If we couldn't detect our site or landed somewhere weird, check internally for the site\n if return_value.nil?\n Log.logger.info(\"not on the right site for #{site_prefix} yet -> running wait_for_site_creation()\")\n return self.wait_for_site_creation(browser, user, password, site_prefix, timeout = 600)\n else\n Log.logger.info(\"New site created for #{site_prefix}! Returning #{return_value.inspect}\")\n return return_value\n end\n end", "def create\n @site = Xmt::Press::Site.new(site_params)\n respond_to do |format|\n if @site.save\n format.html { redirect_to xmt_press_sites_url, notice: '站点创建成功.' }\n format.json { render :show, status: :created, location: @site }\n else\n format.html { render :new }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_site\n # see if the site already exists\n abort \"'#{site}' already exists\" if test ?e, site\n\n # copy over files from the data directory\n files = site_files\n\n files.keys.sort.each do |dir|\n mkdir dir\n files[dir].sort.each {|file| cp file}\n end\n nil\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n flash[:notice] = 'Site was successfully created.'\n Changelog.add(@current_user.login, \"Created the site #{@site.name}\")\n format.html { redirect_to(@site) }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @agent_website = AgentWebsite.new(agent_website_params)\n @agent_website.agent_id = current_agent.id\n respond_to do |format|\n if @agent_website.save\n format.html { redirect_to @agent_website, notice: 'Agent website was successfully created.' }\n format.json { render :show, status: :created, location: @agent_website }\n else\n format.html { render :new }\n format.json { render json: @agent_website.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(args)\n # validate arguments\n\n # got arguments\n unless args.empty?\n # TODO: parse_args method\n required_args = ['sitename', 'type']\n # loop given arguments\n used_args = []\n args_hash = Hash.new\n args.each { |argument|\n arg = argument.split('=')\n if arg.length == 2\n # every argument has value, check for required args\n\n # split argument to key value pair\n key = arg[0]\n val = arg[1]\n\n # remove all dashes from beginning of key\n key.sub! /\\A-+/, ''\n # check for duplicate arguments\n if used_args.include?(key)\n puts \"Duplicate arguments\"\n puts CREATE_HELP\n exit\n else\n # keep track of used arguments\n used_args.push(key)\n \n # TODO: validate sitename (only lowercase chars, dashes or numbers)\n\n # set key and value to hash\n args_hash[key]=val\n end\n\n if required_args.include?(key)\n required_args.delete(key)\n end\n\n else\n # argument value missing, exit script and show help\n puts 'Argument '+arg[0]+' needs value'\n puts CREATE_HELP\n exit\n end\n }\n\n if required_args.length == 0\n # all required arguments given, proceed\n else\n # required arguments missing, exit script and show help\n puts \"Arguments required:\"\n puts required_args\n puts CREATE_HELP\n exit\n end\n\n # start creating project\n create_app(args_hash)\n\n else\n # no arguments given, start wizard\n create_wizard()\n\n end\n\n end", "def process\n\t\t\t\tbegin\n\t\t\t\t\t@site_name = self.args.join\n\t\t\t\t\tFileUtils.mkdir @site_name\n\t\t\t\t\tFileUtils.cp_r Dir.glob(File.expand_path('../../../new_site', __FILE__) + '/*'), File.join(self.source, @site_name)\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"pages\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media/images\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media/videos\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media/sounds\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"includes\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"plugins\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"extras\")\n\t\t\t\t\tdefault_page\n\n\t\t\t\t\tp \"#{@site_name} created.\"\n\t\t\t\trescue Exception => e\n\t\t\t\t\tp e\n\t\t\t\tend\n\t\t\tend", "def execute!\n make_web_directory\n generate_universe\n generate_html\n print_success_message\n end", "def create_empty_page(p)\n cli.say 'Creating project page'\n FileUtils.mkdir_p(browse_file(p, '.'))\n %w[favicon-32.png style.css].each do |i|\n FileUtils.cp(template_file(i), browse_file(p, i))\n end\n write_file(p, 'about.html') do\n build_from_template('about.html', citation: MiGA::MiGA.CITATION)\n end\n end", "def create(p)\n puts \"Creating page #{p}\"\n Dir.mkdir p unless File.exists? p\n Content.new(\"#{@dir}\", @extension).page p\n end", "def add_site(params = {})\n site_name.set params['site_name']\n client_division_site_number.set params['client_division_site_number']\n site_number.set params['site_number']\n address_1.set params['address_1']\n address_2.set params['address_2'] if params['address_2']\n zip_code.set params['zip_code']\n city.set params['city']\n country.select(params['country'], match: :first)\n sleep 2 # Wait for the state to be active #TODO: find a way to remove this sleep ~MD\n state.select(params['state']) unless state.disabled?\n study_env.select(params['study_env'])\n pi_email.set params['pi_email']\n pi_first_name.set(params['pi_first_name'])\n pi_last_name.set(params['pi_last_name'])\n pi_role.select(params['pi_role'])\n add_site_submit.click\n sleep 10 # Wait to create a site\n end", "def create\n @website = Website.new(create_params)\n @website.save!\n # create default values\n @website.create_default\n @website.save!\n \n @websites = Website.all\n .order(created_at: :desc)\n respond_to do |format|\n format.js\n end\n end", "def new_site_save\n active_submit.click\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to(@site) }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def build_site_for_user\n #ditinguer nom et url\n create_site(params[:site][:url],params[:user][:site], current_user)\n end", "def create_site(opts = {})\n data, _status_code, _headers = create_site_with_http_info(opts)\n data\n end", "def create\n HTTParty.post(create_url, :options => { :headers => HEADERS })\n end", "def create\n @get_started_page.brand = website.brand\n respond_to do |format|\n if @get_started_page.save\n format.html { redirect_to([:admin, @get_started_page], notice: '\"Get Started\" page was successfully created.') }\n format.xml { render xml: @get_started_page, status: :created, location: @get_started_page }\n website.add_log(user: current_user, action: \"Created get_started_page: #{@get_started_page.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @get_started_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_params\n params.require(:website).permit(:name, :description)\n end", "def create!\n document_roots = ServerTools::Configuration.get(\"apache\",\"documentroots\")\n logs = join_and_expand_path(document_roots, @name, \"logs\")\n available_site = join_and_expand_path(ServerTools::Configuration.get(\"apache\",\"available_sites\"), @name)\n\n put_option(:document_root, join_and_expand_path(document_roots, @name, \"htdocs\"))\n put_option(:error_log, join_and_expand_path(logs, \"error.log\"))\n put_option(:custom_log, \"#{join_and_expand_path(logs,\"access.log\")} combined\")\n \n ServerTools::Logger.message(\"Create VirtualHost \\\"#{@name}\\\"\")\n ServerTools::Logger.message(\"Document root: #{@options[:document_root]}\")\n ServerTools::Logger.message(\"Logs: #{logs}\")\n ServerTools::Logger.message(\"Configuration: #{available_site}\")\n \n if File.exists?(available_site)\n ServerTools::Logger.error(\"Configuration does already exist!\")\n exit\n end\n if Dir.exists?(@options[:document_root])\n ServerTools::Logger.error(\"Document root does already exist!\")\n exit\n end\n \n FileUtils.mkpath(@options[:document_root])\n FileUtils.mkpath(logs)\n \n File.open(available_site, \"w\") do |f|\n f.puts %Q{\\#\n\\# #{@name} (#{available_site})\n\\#\n<VirtualHost *>\n\\tServerName\\t#{@name}\n#{parse_options(@options)}\n#{htaccess_configuration(@options)}\n</VirtualHost>\n }\n end\n \n end", "def create\n @website_detail = WebsiteDetail.new(website_detail_params)\n\n respond_to do |format|\n if @website_detail.save\n format.html { redirect_to @website_detail, notice: 'Website detail was successfully created.' }\n format.json { render :show, status: :created, location: @website_detail }\n else\n format.html { render :new }\n format.json { render json: @website_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @crawled_site = WebCrawlers.new(\"http://wiprodigital.com/\")\n render :show\n end", "def create\n \n @site = Site.new(params[:site])\n \n @project = Project.find(@site.project_id)\n # site_path is the destination path which store all of resource of this site\n # site_path should be the same as the path in capistrano file(cap file)\n # @site.path = \"/home/inice/InstantSOA/deploy_cap/inice/#{current_user.id}_#{params[:site][:name]}\"\n @site.path = \"/home/inice/users/#{current_user.id}/#{current_user.id}_#{params[:site][:name]}\"\n @site.status = \"Promt for Install\"\n @site.user = current_user\n respond_to do |format|\n \n if Site.find_by_name(@site.name) != nil\n flash[:error] = 'Site name is exist.'\n format.html { redirect_to(@site) }\n else\n if @site.validate_site_name(@site.name) \n if @site.save\n\n format.html { redirect_to @site }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n else\n flash[:warning] = 'Site name is incorrect'\n format.html { render :action => \"new\"}\n format.xml { render :xml => @site.errors, :status => :'Site name is incorrect' }\n end\n end\n end\n end", "def create\n @scraping_page = ScrapingPage.new(scraping_page_params)\n\n #--- Set url and new mechanize ---#\n url = @scraping_page.page_url\n uri = URI.parse(url) # ex) https://example.com/ -> set \"example.com\"\n agent = Mechanize.new\n page = agent.get(url)\n\n #--- Set title ---#\n title = page.title if page.respond_to?(:title) # For undefiend page.title method error (ex: RSS or missing title meta tag WebSite).\n title = \"#{title} #{uri.host}\"\n @scraping_page.title = title\n\n #--- Set charset ---#\n @scraping_page.charset = set_charset(page.body)\n\n #--- Obey robots.txt ---#\n robotex = Robotex.new \"Crawler\"\n @scraping_page.is_robots_allowed = robotex.allowed?(url)\n\n #--- Set scraping HTML file name ---#\n @scraping_page.directory_path = create_directory(url) # concerns/file_savable.rb\n\n respond_to do |format|\n if @scraping_page.save\n format.html { redirect_to @scraping_page, notice: 'Scraping page was successfully created.' }\n format.json { render :show, status: :created, location: @scraping_page }\n else\n format.html { render :new }\n format.json { render json: @scraping_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to(root_url, :notice => 'Site was successfully created.') }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n \n # Domain Name\n re='((?:[a-z][a-z\\\\.\\\\d\\\\-]+)\\\\.(?:[a-z][a-z\\\\-]+))(?![\\\\w\\\\.])'\t\n @m=Regexp.new(re,Regexp::IGNORECASE)\n @host = @m.match(@site.linkws)[1] \n @site.host = @host\n \n respond_to do |format|\n if @site.save\n format.html { redirect_to @site, notice: 'Site was successfully created.' }\n format.json { render json: @site, status: :created, location: @site }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to(@site, :notice => 'Site was successfully created.') }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to(@site, :notice => 'Site was successfully created.') }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to(@site, :notice => 'Site was successfully created.') }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n redirect_to pages_path\n end", "def create\n\n Campsite.create(\n name: params[:name],\n location: params[:location],\n campsite_type: params[:campsite_type],\n max_people: params[:max_people],\n per_night: params[:per_night]\n )\n\n # CREATE has no template of its own:\n # redirect to index page\n redirect_to( campsites_path )\n\n end", "def create\n @mysite = Mysite.new(mysite_params)\n\n respond_to do |format|\n if @mysite.save\n format.html { redirect_to @mysite, notice: 'Mysite was successfully created.' }\n format.json { render :show, status: :created, location: @mysite }\n else\n format.html { render :new }\n format.json { render json: @mysite.errors, status: :unprocessable_entity }\n end\n end\n end", "def instantiate_site\n flash[:alert] = \"No site currently exists, please create one\"\n redirect_to(new_admin_sites_path)\n return false\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n flash[:notice] = 'Site was successfully created.'\n format.html { redirect_to(@site) }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @site = Site.new\n @site.url = 'http://'\n @site.creator = current_user.name if user_signed_in?\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end", "def create\n params[:site][:virtualhost] = nil if params[:site][:virtualhost] =~ /^\\s*$/\n @site = current_user.sites.build(params[:site])\n\n respond_to do |format|\n if @site.save\n flash[:notice] = 'Site was successfully created.'\n format.html { redirect_to(@site) }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n user_id = session[:user_id] \n if user_id \n all_params = site_params\n all_params[:date] = Date.strptime(all_params[:date],'%m/%d/%Y') \n site = Site.new(all_params)\n if site.valid?\n site.save\n redirect_to '/sites/' + site.id.to_s + '/upload'\n else\n err = site.errors.messages\n err_str = \"\\n\"\n err.each do |key, value|\n err_str += \"#{key}:#{value}\\n\"\n end\n flash[:danger] = \"Oooops - sorry, something went wrong while saving your new site: \" + err_str\n redirect_to '/'\n end\n else \n open_id = URI.encode(params[:open_id])\n tmp = Sitetmp.new(site_params)\n tmp.nonce = nonce\n tmp.save\n to_url = '/login?n=' + tmp.nonce + '&open_id=' + open_id\n redirect_to to_url \n end\n end", "def create_site\n files = site_files\n\n # in update mode we only want to update the tasks directory\n if options[:update]\n FileUtils.mkdir_p site unless pretend?\n mkdir 'tasks'\n files['tasks'].sort.each {|file| cp file}\n else\n dirs = files.keys.concat %w[content layouts lib tasks templates]\n dirs.sort!\n dirs.uniq!\n\n # create the directories first\n dirs.each do |dir|\n next if dir =~ %r/^output\\/.*$/\n mkdir dir\n end\n\n # and the create the files under each directory\n dirs.each do |dir|\n next if dir =~ %r/^output(\\/.*)?$/\n files[dir].sort.each {|file| cp file}\n end\n end\n end", "def create\n \turl = Url.create(params[:url])\n \t\n \tredirect_to urls_path\n end", "def create\n @site = Site.new(site_params)\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to(root_url, :notice => 'Site was successfully created.') }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @page.brand = website.brand\n respond_to do |format|\n if @page.save\n format.html { redirect_to([:admin, @page], notice: 'Page was successfully created.') }\n format.xml { render xml: @page, status: :created, location: @page }\n website.add_log(user: current_user, action: \"Created page: #{@page.title}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate(site)\n end", "def create\n #@page = Page.new(page_params)\n\n @website = Website.find(params[:website_id])\n @page = Page.new page_params.merge! website_id: @website.id\n\n respond_to do |format|\n if @page.save\n format.html { redirect_to website_page_path(@website.id, @page), notice: 'Page was successfully created.' }\n format.json { render :show, status: :created, location: website_page_path(:website_id, @page) }\n else\n format.html { render :new }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_site(opts = {})\n data, _status_code, _headers = create_site_with_http_info(opts)\n return data\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to @site, notice: 'Site was successfully created.' }\n format.json { render json: @site, status: :created, location: @site }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to @site, notice: 'Site was successfully created.' }\n format.json { render json: @site, status: :created, location: @site }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to @site, notice: 'Site was successfully created.' }\n format.json { render json: @site, status: :created, location: @site }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def load_1\n puts \"created Revs\"\n p = Site.new\n p.name = \"Revs\"\n p.author = \"Jebbit\"\n p.created_at = Date.new 2014, 05, 27 \n p.img_url = \"http://image_somewhere.com/img.jpg\"\n p.landing_url = \"http://jebbit.com\"\n p.save!\nend", "def new_page\n page = Page.new\n page.url = params[:id] if Page.url?(params[:id]) && params[:id] != 'new-page'\n page\n end", "def create\r\n html=params[:page][:html]\r\n @page = Page.new(params[:page])\r\n respond_to do |format|\r\n if @page.save\r\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\r\n format.json { render json: @page, status: :created, location: @page }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n if !File.directory?(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}/images\")\r\n end\r\n File.open(target, \"w+\") do |f|\r\n f.write(html)\r\n end\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n\t\tpre_new\n\t\t@page.save!\n\t\tflash[:notice] = 'New Page was successfully saved.'\n\t\tredirect_to @page.sitepath\n\t#rescue NoMethodError\n\t#\trender :action=>:new\n\trescue ActiveRecord::RecordInvalid\n\t\trender :action=>:new\n\trescue\n\t\tflash.now[:error] = 'An error occurred while trying to save your new Page.'\n\t\trender :action=>:new\n\tend", "def create_project(tx)\n Installer.copy(tx, \"#{@service_dir}/pieces/public\", get_path(:web))\n true\n end", "def new\n @page_title = \"New Blog\"\n @blogpost = Blogpost.new\n end", "def create\n @web_app = WebApp.new(params[:web_app])\n\n respond_to do |format|\n if @web_app.save\n format.html { redirect_to @web_app, notice: 'Web app was successfully created.' }\n format.json { render json: @web_app, status: :created, location: @web_app }\n else\n format.html { render action: \"new\" }\n format.json { render json: @web_app.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @site = current_user.sites.create(params[:site])\n respond_to do |format|\n if @site.save\n format.html { flash_and_redirect(\"successfully saved!\", sites_url) }\n format.json { render json: @site, status: :created, location: @site }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @website = Website.new(website_params)\n\n respond_to do |format|\n if verify_recaptcha(model: @website) && @website.save\n WebsiteMailer.url_info(@website).deliver_later\n format.html { redirect_to websites_path, notice: 'Website was successfully created.' }\n format.json { render :show, status: :created, location: @website }\n else\n format.html { render :new }\n format.json { render json: @website.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @web_info = WebInfo.new(params[:web_info])\n\n respond_to do |format|\n if @web_info.save\n format.html { redirect_to(@web_info, :notice => 'Web info was successfully created.') }\n format.xml { render :xml => @web_info, :status => :created, :location => @web_info }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @web_info.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @site = current_user.sites.build(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to root_url(subdomain: @site.subdomain), notice: 'Site was successfully created.' }\n format.json { render json: @site, status: :created, location: @site }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @url = params[:url]\n token = SecureRandom.hex(4)\n @tiny_token = Url.create(\n url: @url,\n token: token,\n domain: \"#{ENV['HOSTNAME']}/#{token}\" \n )\n redirect_to url_path(token)\n \n end", "def new\n @webpage = Webpage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @webpage }\n end\n end", "def test_create_page\n file = Configuration.TEST_PAGE\n \n # This test depends on a succesfull login\n if test_correct_login\n token = make_login Configuration.USER, Configuration.PASSWORD\n else\n return false\n end\n \n page_key = 'page-test-' + random_string(Configuration.PAGE_KEY_RS_SIZE)\n res = post_page file, token, page_key, 'test-tag', 'This is a Test Page'\n \n # Remove the just created page\n remove_page page_key, token\n \n puts \"\\nTester#test_create_page:\\n#{res}\" if Configuration.VERBOSE\n res == Constants.SUCCESS_MESSAGE\n end", "def new\n @pwebsite = Pwebsite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pwebsite }\n end\n end", "def create\n @site = Site.new(site_params)\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to @site, notice: 'Site was successfully created.' }\n format.json { render :show, status: :created, location: @site }\n else\n format.html { render :new }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @site = Site.new(params[:site])\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to(@site, :notice => 'Site was successfully created.') }\n format.json { render :json => @site, :status => :created, :location => @site }\n format.xml { render :xml => @site, :status => :created, :location => @site }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @site.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @selector_site = SelectorSite.new(params[:selector_site])\n\n respond_to do |format|\n if @selector_site.save\n flash[:notice] = 'SelectorSite was successfully created.'\n format.html { redirect_to(@selector_site) }\n format.xml { render :xml => @selector_site, :status => :created, :location => @selector_site }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @selector_site.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n authorize RegisteredApplication\n @view.app = RegisteredApplication.new(submitted_params_whitelist)\n @view.app.url = fixup_url\n @view.app.user = @view.current_user\n\n if @view.app.save\n # Response: tell browser to show this new registered site.\n redirect_to @view.app, notice: 'Site was saved successfully.'\n else\n # Response: redisplay the edit form with error msgs.\n flash.now[:alert] = 'Error creating registered site. Please try again.'\n render :new\n end\n end", "def create!(bundle_id: nil, name: nil, mac: false)\n new_website_push = client.create_website_push!(name, bundle_id, mac: mac)\n self.new(new_website_push)\n end", "def create\n @institution = @navigation_context.institution\n return unless authorize_resource(@institution, CREATE_INSTITUTION_SITE)\n @site = @institution.sites.new(site_params(true))\n @sites = check_access(@institution.sites, READ_SITE)\n\n respond_to do |format|\n if @site.save\n format.html { redirect_to sites_path, notice: I18n.t('sites.create.success') }\n format.json { render action: 'show', status: :created, location: @site }\n else\n format.html { render action: 'new' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @website_use = WebsiteUse.new(params[:website_use])\n\n respond_to do |format|\n if @website_use.save\n flash[:notice] = 'WebsiteUse was successfully created.'\n format.html { redirect_to(@website_use) }\n format.xml { render :xml => @website_use, :status => :created, :location => @website_use }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @website_use.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @title = \"Creating New Content\"\n @content_node = ContentNode.new\n end", "def new\n @page = Page.find_by_title('Huren bij Xposers')\n end", "def create\n @site_url = SiteUrl.new(site_url_params)\n\n respond_to do |format|\n if @site_url.save\n format.html { redirect_to @site_url, notice: \"Site url was successfully created.\" }\n format.json { render :show, status: :created, location: @site_url }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @site_url.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7090664", "0.7039746", "0.69364256", "0.69164723", "0.68795747", "0.6878071", "0.6863321", "0.67511964", "0.66125214", "0.65740234", "0.6570023", "0.6564045", "0.65628874", "0.64869785", "0.64228046", "0.64178336", "0.6379928", "0.6345181", "0.62986666", "0.62978494", "0.6257674", "0.6211476", "0.61805046", "0.61589366", "0.6155702", "0.61284655", "0.6122185", "0.61212593", "0.6111171", "0.6103248", "0.6103229", "0.60937184", "0.6089212", "0.6058544", "0.6049054", "0.604096", "0.60227525", "0.5998544", "0.59977406", "0.59949243", "0.59815574", "0.59735286", "0.5972498", "0.59636873", "0.59606475", "0.59486604", "0.5929459", "0.5927126", "0.5925608", "0.5924455", "0.5921452", "0.5902614", "0.5890647", "0.58886117", "0.5877151", "0.5857039", "0.5857039", "0.5857039", "0.58534586", "0.58521736", "0.5835593", "0.58351755", "0.5832408", "0.5830106", "0.58282", "0.5825212", "0.5822097", "0.5807489", "0.5787785", "0.57797396", "0.5773457", "0.5766774", "0.57662517", "0.5761403", "0.5761403", "0.5761403", "0.57531095", "0.5746114", "0.57410926", "0.57244986", "0.57108307", "0.5706568", "0.57040894", "0.570257", "0.5701346", "0.5685222", "0.5683299", "0.56645554", "0.56543744", "0.56543094", "0.5645316", "0.5635979", "0.56352913", "0.5628085", "0.5624286", "0.56221527", "0.5620027", "0.56187844", "0.56129056", "0.56082284", "0.56053215" ]
0.0
-1
Add a link to the website
def add_link(link) links << link end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link() url; end", "def link() url; end", "def link(link, title, content)\n\t \"<u><link href='#{link}'>#{content}</link></u>\"\n\t end", "def link(link, title, content)\n \"#{content} (#{link})\"\n end", "def link uri\n self.apply_hyperlink java.net.URI.new(uri)\n end", "def link\n Html::Link.new(:href => url) << display_name\n end", "def link(_content, _url)\n raise NotImplementedError\n end", "def nexia_link # :doc:\n content_box.a(:text => \"nexiahome.com\")\n end", "def add(url)\n @links << url\n end", "def add_this(text, url)\n link_to text, \"http://www.addthis.com/bookmark.php\", :onmouseover => \"return addthis_open(this, '', '#{url}', '');\", :onmouseout => \"addthis_close();\", :onclick => \"return addthis_sendto();\"\n end", "def link(link, title, content)\n link = OodAppkit.files.api(path: @app_path.to_s + '/' + link).to_s if @app_path && relative?(link)\n return \"<a href=\\\"#{link}\\\" rel=\\\"noopener\\\" target=\\\"_blank\\\">#{content}</a>\" unless id_link?(link)\n return \"<a href=\\\"#{link}\\\">#{content}</a>\"\n end", "def link_to(name, url, options = {}); end", "def link(target)\n File.join(site.url, target)\n end", "def link(link, title, content)\n if no_links\n content\n else\n # \"<a href=\\\"#{DashboardRouter.normalize(link)}\\\" target=\\\"_top\\\">#{content}</a>\"\n \"<a href=\\\"#{link}\\\">#{content}</a>\"\n end\n end", "def url(href)\n a href, :href => href\n end", "def link_to(body, url)\n \"[#{body}](#{url})\" if !AIPP.options.check_links || url_exists?(url)\n end", "def add_link(links)\n links = [links] if links.is_a?(String)\n self.class.get(\"/action/add/links/grabber0/start1/\"+links.join(\" \"))\n end", "def web_link=(value)\n @web_link = value\n end", "def link(content,href,options={})\n options.update :href => href\n tag :a, content, options\n end", "def add_url(url)\n @ole.AddURL(url)\n end", "def add_url(url)\n @ole.AddURL(url)\n end", "def add_link(el, href, title, alt_text = T.unsafe(nil), ial = T.unsafe(nil)); end", "def html_link(item)\n tag :a, yield, :href => item.url\n end", "def link(opts)\n \"#{opts[:name]} !LINK_OPEN_TAG!#{opts[:href]}!LINK_CLOSE_TAG!\"\n end", "def linkify(options = {})\n url = options[:value].first\n link_to url, url\n end", "def add_href\n return if attributes.key?(\"href\")\n return unless attributes.key?(\"id\")\n attributes[\"href\"] = client.connection.api_path(\"#{collection.name}/#{attributes['id']}\")\n end", "def href; end", "def to_link(text)\n URI::encode(@base_url + text.strip.gsub(/\\s+/, @space_replacement))\n end", "def link(url, title) # :nodoc:\n warn \"link called from #{self.inspect}\"\n \"[#{title}](#{url})\"\n end", "def link(url, title) # :nodoc:\n \"[#{title}](#{url})\"\n end", "def link *a; app.link *a end", "def linkify(url, text)\n if ENV['BUILDKITE']\n \"\\033]1339;url='#{url}';content='#{text}'\\a\"\n else\n \"#{text}: #{url}\"\n end\n end", "def publication_link\n h.link_to \"Read Now\" , object.publication_url , title: 'Read Now' , class: 'btn waves-effect waves-light btn-primary custom-btn' , target: '_blank'\n end", "def link aUrl, aName = nil, aTitle = nil\n aName ||= aUrl\n %{<a href=\"#{aUrl}\"#{%{ title=\"#{aTitle}\"} if aTitle}>#{aName}</a>}\n end", "def link(text, url = nil)\n url = text if url.nil?\n tag(:a, text, :href => url)\n end", "def make_link(url, text)\n return (\"[#{text}|#{url}]\")\n end", "def link\n h.content_tag :li do\n h.link_to h.content_tag(:i, '' , class: object.icon ) , object.url , target: \"_blank\" , title: object.name\n end\n end", "def extern_link(text, url)\n\n link_to(text, url, target: '_blank', rel: 'no-follow') +\n link_to(content_tag(:sup, icon('fas', 'external-link-alt', class: 'external-link')),\n url, target: '_blank', rel: 'nofollow')\n end", "def add_http_to_url\n if !self.website_url.blank?\n unless self.website_url[/\\Ahttp:\\/\\//] || self.website_url[/\\Ahttps:\\/\\//]\n self.website_url = \"http://#{self.website_url}\"\n end\n end\n end", "def link\n \"<a href='http://www.mailgun.com/'>Mailgun</a>\"\n end", "def click(link); end", "def to_link\n \"<a href=\\\"#{self.url}\\\">#{self.name}</a>\"\n end", "def link_url(url, title = T.unsafe(nil), params = T.unsafe(nil)); end", "def link_url(url, title = T.unsafe(nil), params = T.unsafe(nil)); end", "def add_link\n @bib.link.each do |l|\n case l.type&.downcase\n when \"doi\" then @item.doi = l.content\n when \"file\" then @item.file2 = l.content\n when \"src\" then @item.url = l.content\n end\n end\n end", "def easy\n url = params[:url]\n\n # Well, this would be super slow for mainstream processors, but\n # might be good enough for Mom's & Dad's shop\n link = Link.find_by_url(url)\n\n # Oops, we don't have this Url in tables yet\n if link.nil?\n link = Link.new\n link.url = url\n link.save\n end\n\n render :text => SHORT_URL + \"/\" + Base32::Crockford.encode(link.id)\n end", "def link(_link, _title, content)\n content.to_s\n end", "def link_to_ecoologic\n image = image_tag(Setting.ecoologic_link_image_url,\n {:alt => Setting.ecoologic_alt, :height => '64px'})\n url = Setting.ecoologic_link_url\n link_opts = {:title => Setting.ecoologic_link_title, :target => '_blank'}\n # :id => :ecoologic_link\n \n link_to image, url, link_opts\n end", "def link(relation, href, options={})\n @resource.add_link relation, href, options\n end", "def hyperlink(url, class_name)\n hyper_a = @doc.at_css \"div[@class='row title #{class_name}']//a\"\n hyper_a['href'] = url\n end", "def button_link_to( title, url, options={} )\n\t\tclasses = ['link']\n\t\tclasses << options[:class]\n\t\ts = \"<a href='#{url_for(url)}' style='text-decoration:none;'>\"\n\t\ts << \"<button type='button'>\"\n\t\ts << title\n\t\ts << \"</button></a>\\n\"\n\tend", "def url(href, options = {})\n a href, ({:href => href}.merge(options))\n end", "def make_link(source:, link:)\n @output.item @i18n.t('setup.ln', target: link, source: source)\n FileUtils::rm link if (File::symlink? link and not File::exist? link)\n FileUtils::ln_s source, link unless File::exist? link\n end", "def concat(link)\n Wgit::Url.concat(self, link)\n end", "def append_target!\n @tag.gsub! /\\<a/, '<a target=\"_blank\"'\n end", "def append_link\n url = params[:link]\n @link = Link.new()\n @link.url = url[:url]\n @link.package = Package.find(params[:package_id])\n @link.save()\n # renova a busca para atualizar lista de links.\n @links = Link.find(:all, :conditions => [\"package_id = ?\", params[:package_id]])\n\n flash[:notice] = \"Link was successfully appended.<br/>\" + url[:url]\n redirect_to :action => 'show', :id => params[:package_id]\n end", "def link!\n self.linkbutton = true\n self.save\n self.linkbutton\n end", "def link(link_text)\n element(damballa(link_text+\"_link\")) { |b| b.link(:text=>link_text) }\n action(damballa(link_text)) { |b| b.link(:text=>link_text).click }\n end", "def link(url)\n if @_bucket.nil?\n raise \"Robots.link must be called inside of allow or disallow block\"\n else\n @_bucket.push(url.to_s)\n end\n end", "def url_for_link( project, opts )\n if (opts[:link])\n (opts[:link] =~ /^(https?:\\/\\/|\\/)/i) ? opts[:link] : url_for_page( project, opts.update(:page_name => opts[:link]) )\n end\n end", "def link_to(body, url, html_options = {})\n ActionController::Base.helpers.link_to(body, url, html_options).html_safe\n end", "def url(link)\n '#'\n end", "def handle_special_HYPERLINK(special)\n url = special.text\n gen_url url, url\n end", "def link\n @link ||= uri.to_s\n end", "def link(link, title, content)\n\t\tif (title)\n\t\t\treturn \"title : [#{content}|#{link}]\"\n\t\telse\n\t\t\treturn \"[#{content}|#{link}]\"\n\t\tend\n\tend", "def link_to(title, path, opts={}, base=true)\n unless is_uri?(path) || base == false\n path = url(path)\n end\n \n return \"<a href=\\\"#{path}\\\"#{parse_options(opts)}>#{title}</a>\"\n end", "def link_to (label, url)\n \"<a href='#{url}'>#{label}</a>\"\n end", "def external_link(label, path, **opt, &block)\n opt[:target] = '_blank' unless opt.key?(:target)\n make_link(label, path, **opt, &block)\n end", "def create_link(url, title = nil, description = nil)\n Dropio::Resource.client.create_link(self, url, title, description)\n end", "def link\n\t\tpage_id.present? ? short_page_path(Page.find(page_id)) : href\n\tend", "def _link=( aLink )\n comps = aLink.split(\"://\")\n if comps.size == 1 \n # no protocol decleration, assume it's http\n aLink = \"http://\" + aLink\n end\n \n @link = aLink\n \n end", "def link\n @link ||= \"#{IMAGE_URL}#{id}.#{IMAGE_EXTENSION}\"\n end", "def to_link(options = {})\n options = { :title => self.title,\n :href => self.url }.merge(options)\n\n Nelumba::Link.new(options)\n end", "def link_to_landing_page \n \"/about/#{url_uuid}\"\n end", "def external_link(link_label, url, options={})\n attributes = options[:attributes] || {}\n children = options[:children] || {}\n image = options[:image] || {}\n\n img =\"\"\n unless image.empty?\n img = self.external_image(image[:url], image, true) \n end\n\n child_elements = self.children_list(children) << img\n link_label = self.tag('label', link_label)\n url = self.tag('url', url)\n link = self.tag('externalLink', url << link_label << child_elements, attributes)\n\n cell = options[:cell] || {}\n row = options[:row] || {}\n self.row_cell(link, cell, row)\n end", "def menu_item_link(m)\n options = {}\n if m.new_page\n options = {:target => \"_blank\"}\n end\n link_to m.title, m.url, options\n end", "def link\n '-'\n end", "def href=(value)\n @href = value\n end", "def add_link(el, href, title, alt_text = nil, ial = nil)\n el.options[:ial] = ial\n update_attr_with_ial(el.attr, ial) if ial\n if el.type == :a\n el.attr['href'] = href\n else\n el.attr['src'] = href\n el.attr['alt'] = alt_text\n el.children.clear\n end\n el.attr['title'] = title if title\n @tree.children << el\n end", "def md_url(url, al=nil)\n md_el(:immediate_link, [], { :url => url }, al)\n end", "def link_to_external url ,link_label\n link_to \"#{link_label}\" ,\"#{url}\" , :target=>'_blank'\n end", "def link_to_remote(name, options = {}, html_options = {})\n unless html_options[:href]\n html_options[:href] = url_for(options[:url])\n end\n \n link_to_function(name, remote_function(options), html_options)\n end", "def link_to_remote(name, options = {}, html_options = {})\n unless html_options[:href]\n html_options[:href] = url_for(options[:url])\n end\n \n link_to_function(name, remote_function(options), html_options)\n end", "def link_to_remote_with_href_from_url(name, options = {}, html_options = nil)\n # set the href manually so that its the link not # and non js users will follow link\n # this should maybe be removed from the library and be set in an application specific way?\n # why does rails not use this by default?\n html_options ||= {}\n html_options[:href] ||= options[:url]\n link_to_remote(name, options, html_options)\n end", "def help_link(wiki_entry_name=nil)\n wiki_url = \"https://github.com/indykish/identityprov/wiki\"\n if wiki_entry_name\n wiki_url += \"/#{wiki_entry_name}\"\n link_text = \"Help for #{wiki_entry_name.underscore_humanize}\" \n else\n link_text =\"Help\" \n end\n link_to_ link_text, wiki_url, { :target => '_blank'}\n end", "def link_to text, href\n \"[#{text}](#{href})\"\n end", "def link\n BASE_URL + (private? ? \"/private/#{@key}\" : \"/#{@id}\")\n end", "def autolink(text)\n auto_link(text, :html => { :target => '_blank' })\n end", "def website_link\n return unless website?\n\n @website_link ||= website.split(\"//\")[1].sub(/^www\\./, \"\")\n end", "def sexy(body)\n body.gsub(URL_MATCHER, link_to(\"http://\\\\2\", \"http://\\\\2\", :target => \"_blank\"))\n end", "def add_link_header(query_parameters)\n response.headers['Link'] = construct_link_header(query_parameters)\n end", "def create_links\n end", "def create_links\n end", "def link_to_asset(body,model,url_opts={},html={})\n result = String.new\n result << '<a href=\"' + url_for_asset(model,url_opts) + '\">'\n result << body\n result << '</a>'\n end", "def link(wallet_id, otp)\n\t\t\t\tJuspayCheckout::ExpressCheckout.request(\"/wallets/#{wallet_id}\", 'post', {command: 'link', otp: otp})\n\t\t\tend", "def link(text, target, attributes = {})\n if target.is_a? Fixnum\n attributes[:rel] = rel_value(target)\n target = url(target)\n end\n @template.link_to(text, target, attributes.merge(:remote => true))\n end", "def make_link(name, web, text = nil, options = {})\n mode = (options[:mode] || :show).to_sym\n link_type = (options[:link_type] || :show).to_sym\n\n if (link_type == :show)\n known_page = web.has_page?(name)\n else\n known_page = web.has_file?(name)\n description = web.description(name)\n description = description.unescapeHTML.escapeHTML if description\n end\n if (text == name)\n text = description || text\n else\n text = text || description\n end\n text = (text || WikiWords.separate(name)).unescapeHTML.escapeHTML\n \n case link_type\n when :show\n page_link(mode, name, text, web.address, known_page)\n when :file\n file_link(mode, name, text, web.address, known_page, description)\n when :pic\n pic_link(mode, name, text, web.address, known_page)\n when :audio\n media_link(mode, name, text, web.address, known_page, 'audio')\n when :video\n media_link(mode, name, text, web.address, known_page, 'video')\n when :delete\n delete_link(mode, name, web.address, known_page)\n else\n raise \"Unknown link type: #{link_type}\"\n end\n end", "def alink(*args)\n\n args << {} unless args.last.is_a?(Hash)\n args.last[:title] = true\n\n opts = args.last\n\n hl = hlink(*args)\n\n attributes = %w[ href rel title ].inject([]) { |a, att|\n if val = hl[att]\n a << \"#{att}=\\\"#{val}\\\"\"\n end\n a\n }.join(' ')\n\n \"<a #{attributes}>#{opts[:text] || hl['href']}</a>\"\n end", "def link_in(href, title)\n \"<wiki %p %p>\" % [href, title]\n tag(:a, title || href, :href => \"/#{href}\")\n end", "def jquery_link(name, options = {})\n content_tag :a, name, options.merge({:href => 'javascript:;'})\n end" ]
[ "0.7272793", "0.7272793", "0.71232647", "0.7049978", "0.70148504", "0.7010466", "0.6913935", "0.68870544", "0.68052584", "0.679065", "0.67857206", "0.67855346", "0.6762925", "0.67523545", "0.6732364", "0.6720014", "0.67156154", "0.6708738", "0.6689934", "0.66776645", "0.66776645", "0.66614735", "0.66340005", "0.6603541", "0.65939736", "0.65827876", "0.6578383", "0.6576779", "0.65607214", "0.6555322", "0.65457314", "0.65010184", "0.64826244", "0.64670223", "0.6419402", "0.64159256", "0.6384351", "0.6374406", "0.636036", "0.63451993", "0.6340754", "0.63156563", "0.63130045", "0.63119316", "0.62999356", "0.62960476", "0.6288397", "0.62831885", "0.6283102", "0.6282261", "0.62635547", "0.6252358", "0.6235421", "0.62262917", "0.62099177", "0.6201005", "0.61936116", "0.61932266", "0.6175936", "0.6172066", "0.6158607", "0.6156267", "0.6153003", "0.61422086", "0.613344", "0.61245424", "0.61237365", "0.6122747", "0.61143297", "0.61051524", "0.61034834", "0.60959876", "0.6091243", "0.6089429", "0.6083934", "0.60823655", "0.60809815", "0.607608", "0.6073664", "0.60646784", "0.6064676", "0.60626686", "0.60626686", "0.6061746", "0.60583526", "0.6058", "0.60545224", "0.604823", "0.6047972", "0.6043815", "0.60432667", "0.6032534", "0.6032534", "0.60285145", "0.6027969", "0.60255885", "0.6022459", "0.6018985", "0.6016869", "0.6003462" ]
0.6902849
7
Remove a link from the website
def remove_link(link) links.delete(link) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_links\n gsub(%r{</?a.*?>}, \"\")\n end", "def clear_link\n @link = nil\n @autolink = false\n end", "def strip_links(html); end", "def strip_links(html); end", "def strip_links(html); end", "def remove_hyperlink(hyperlink_to_delete)\n hyperlinks = self.hyperlinks\n hyperlinks.delete(hyperlink_to_delete)\n self.submitted_hyperlinks = YAML.dump(hyperlinks)\n save\n end", "def unlink(text)\n return text.html_safe if text =~ /<a / # They already linked it.\n text.gsub(URI::ABS_URI) { |match|\n if match.size < 20\n \"<a href=\\\"#{match}\\\">#{match}</a>\"\n else\n host = URI::parse(match).host\n \"<a href=\\\"#{match}\\\">#{host}</a>\"\n end\n }.html_safe\n end", "def unlink!\n parse \n @tags.each do |tag|\n @doc.xpath(\"//a[ends_with(@href,'#{tag}')]\", EndsWithFilter.new).each do |element|\n element.swap(element.children)\n end\n end\n output = @doc.xpath(\"/#{@wrap_tag}/body/p\").inner_html\n output = @doc.xpath(\"/#{@wrap_tag}/body\").inner_html if output == \"\"\n output\n end", "def clear_link(skip_requesting = false)\n link.skip_requesting = skip_requesting\n self.link = nil\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def remove_link(resource,tag)\n self.class.remove_link(self,resource,tag)\n end", "def clear_links ()\n\nend", "def delete\n self.class.delete self.href\n end", "def remove_url (url)\n execute(:features_removeurl, url)\n end", "def remove_link(from,to,tag)\n link = JiakLink.new(to.jiak.object.bucket, to.jiak.object.key, tag)\n has_link = from.jiak.object.links.include?(link)\n if has_link\n from.jiak.object.links.delete(link)\n if(from.auto_update? ||\n ((from.auto_update? != false) && from.class.auto_update?))\n put(from)\n end\n end\n has_link\n end", "def remove_url(url_with_file, removal_type = \"PAGE\")\n url = CGI::escape norm_url(url_with_file)\n page = agent.get(REMOVAL % [url, CGI::escape(url_with_file)])\n\n page.form.field_with(:name => 'removalmethod').value = removal_type\n page = agent.submit page.form\n files = page.search(\".wmt-external-url\").map { |n| File.basename(n.text) }\n raise \"could not submit URL\" unless files.include?(File.basename(url_with_file))\n end", "def remove_link\n\t\tfname = \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.info(\"#{self.class.name}.#{__method__}\") { \"params=#{params}\" }\n\t\t@link = Link.find(params[:id])\n\t\t@link.destroy\n\t\trespond_to do |format|\n\t\t LOG.debug(fname) {\"session[:tree_object] =#{session[:tree_object]}\"}\n\t\t\tformat.html { redirect_to(session[:tree_object].nil? ? links_url : session[:tree_object]) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def remove_link(project_link)\n self.project_links.destroy(project_link)\n end", "def invalidate_link link\n @links.delete(link.condition)\n \n end", "def delete_plagarism_html(match_link)\n rm_file = path_to_plagarism_html(match_link)\n if File.exists? rm_file\n FileUtils.rm(rm_file)\n to_dir = student_work_dir(:plagarism, match_link.task)\n\n if Dir[File.join(to_dir, '*.html')].count == 0\n FileUtils.rm_rf(to_dir)\n end\n end\n\n self\n end", "def remove_link(link)\n # If the_link is head, set head to nil\n if self[:head_id] == link.id\n self[:head_id] = link.next_id\n end\n if link.prev\n # If things on both sides, link them\n if link.next\n link.prev.next_id = link.next_id\n link.next.prev_id = link.prev_id \n link.next = nil\n link.prev = nil\n # If no next id, clear prev's next\n else\n link.prev.next_id = nil\n link.prev = nil\n end\n else\n # If no prev id, clear next's prev\n if link.next\n link.next.prev_id = nil\n link.next = nil\n # It none on either side, do nothing\n else\n end\n end\n end", "def unlink_site\n FileUtils.rm_rf(self.absolute_path) if File.exists?(self.absolute_path)\n end", "def remove_image_link_tag\n @caption_node\n .children\n .first\n .content = @caption_node.content.sub(href_regexp, '').strip\n end", "def destroy\n @recommended_link.destroy\n\n head :no_content\n end", "def destroy\n @social_media_link.destroy\n\n head :no_content\n end", "def remove_urls(text)\n text.gsub!(/#{URI::regexp}/, '')\n text\n end", "def remove_links(block)\n inline_block = block.gsub(LINK_PATTERN) do |s|\n url = URL_PATTERN.match(s)[2]\n extension = File.extname(url)\n /\\.js|\\.css/.match(extension) && !URI.parse(url).absolute? ? '' : s\n end\n inline_block\n end", "def remove_url_anchor url\n url.gsub!(/#.*/, '') if url =~ /#/\n url\nend", "def strip_google_tracking_links(doc)\n doc.css(\"a\").each do |node|\n href = node.attr(\"href\").to_s\n next if href.blank?\n\n query_string = URI.parse(href).query\n actual_url = Rack::Utils.parse_nested_query(query_string)[\"q\"]\n\n node[\"href\"] = actual_url\n end\n end", "def invalidate_link link\r\n @links.delete(link.condition)\r\n link.detach_and_revert\r\n end", "def remove_terms_of_use_url(value)\n @children['terms-of-use-url'][:value].delete(value)\n end", "def destroy\n @pending_recommended_link.destroy\n\n head :no_content\n end", "def remove_oneway_links\n @links.delete_if { |k,l|\n l.oneway?\n }\n end", "def remove_links\n for name in get_to_links\n ln = link_name(name)\n\n if File.symlink? ln\n puts \"Removing link #{ln}\"\n File.unlink ln\n end\n end\nend", "def remove_medium_link(opts)\n opts[:text] ||= I18n.t('remove_link', :scope => [:has_media, :form])\n link_to opts[:text], medium_url(opts[:medium]), :remote => true, :method => :delete\n end", "def remove_javascript_links(result)\n #TODO: put this in the logger\n result.linked_resources.delete_if { |linked_resource| linked_resource.downcase.starts_with?(\"javascript:\") }\n end", "def remove_url_anchor(url)\n url.gsub(/\\#.*$/, '')\nend", "def url(link)\n '#'\n end", "def fix_html_link(link)\n return link.gsub(\"documentcloud.org\", \"assets.documentcloud.org\").sub(\"-\", \"/\").gsub(\".html\", \".pdf\").gsub(\"www.\", \"\")\n end", "def remove_url_anchor(url)\n url.split('#').first # url.split('#').shift\nend", "def fixme(link)\n \n link =~ /href=['|\"]([^'|\"]*)/i\n href = $1\n return link if href.nil?\n return link if href =~ /^http:|^https|^mailto:/i\n\n return link if href =~ /\\#/\n segs = href.split(\".\")\n return link if segs.last =~ /\\/|%|\\?/\n \n\n begin\n num = Integer(segs.last)\n return link\n rescue ArgumentError => ex\n rescue TypeError => te # ruby 1.9.2\n end\n \n if segs.length > 1 and segs.last.downcase != \"html\"\n link.gsub!(/<a/, %Q(<a onClick=\"javascript: pageTracker._trackPageview('#{href}'); \"))\n end\n\n link\n \n end", "def clean_destination_url\n if !self.url.blank? and self.url !~ REGEX_LINK_HAS_PROTOCOL\n self.url.insert(0, URL_PROTOCOL_HTTP)\n end\n end", "def remove_url_anchor(url)\n result = ''\n url.each_char do |char|\n break if char == '#'\n result << char\n end\n result\nend", "def clean_url(href)\n # TODO: A better way would be to split by / then take the last section, strip off the anchor then cgi escape\n URI.unescape(href.strip).gsub(\" \", \"%20\")\n end", "def remove_typepad_links\n results = @content.scan(/<a href=.*?<\\/a>/)\n\n results.each do |result|\n # if result contains an image with an image-full class\n if result =~ /image-full/\n temp = result.sub(/<a href=.*?>/, \"\").sub(/<\\/a>/, \"\")\n @content.sub!(result, temp)\n end\n end\n end", "def unmap_url(loc)\n self.locker.synchronize do\n if url = get_url(Sitemapper.urlfy(loc))\n url.remove\n write_file\n end\n end\n end", "def clear(url)\n if code = code_for(url)\n purge(code, url)\n end\n end", "def remove_url_anchor(url)\n url.sub( /#.*/, '' ) # /#.*/ everything after #\nend", "def clean(url)\n url\n end", "def without_anchor\n anchor = to_anchor\n without_anchor = anchor ? gsub(anchor, '') : self\n\n Wgit::Url.new(without_anchor)\n end", "def destroy\n @link.destroy\n respond_to do |format|\n format.html { redirect_to links_url, notice: '투표안건이 성공적으로 삭제되었습니다.' }\n format.json { head :no_content }\n end\n end", "def remove_link(form, link_text = nil)\n id = form.object_id.abs\n text = link_text.blank? ? image_tag(\"/images/nested_edit/remove.png\", :class => \"icon\") : link_text\n if form.object.new_record?\n link_to(text, \"#\", :id => \"#{id}\", :class=>\"remove_link\")\n else\n link_to(text, \"#\", :id => \"#{id}\", :class => \"remove_link\") +\n form.hidden_field(:_destroy, :id => \"hidden_#{id}\")\n end\n end", "def strip_blanks\n self.link = self.link.strip\n end", "def destroy\n @link.destroy\n flash[:success] = \"Link gelöscht!\"\n respond_to do |format|\n format.html { redirect_to pot_path(@link.pot) }\n format.json { head :no_content }\n end\n end", "def remove_target_and_click\n # The expression returns null otherwise we get a \"Cyclic object value\" in\n # Firefox, this is caused by the driver trying to return the objects\n # serialized as JSON, but the raw A elements have cyclic references, causing\n # JSON.stringify to crash.\n page.evaluate_script(\"$('a').removeAttr('target'), null\")\n click\n end", "def remove_link\n return true if (questions = next_questions).length === 0\n\n # Remove the link to any direct questions\n survey.node_maps.select do |i|\n i.node == self\n end.each do |node_map|\n survey.node_maps.select do |j|\n node_map.children.include?(j)\n end.each do |child|\n if child.node.class.ancestors.include?(::ActiveRecordSurvey::Node::Question)\n child.parent = nil\n child.send(child.new_record? ? :destroy : :mark_for_destruction)\n end\n end\n end\n\n # remove link any answeres that have questions\n answers.collect(&:remove_link)\n end", "def remove_domain\n url = args.shift\n remove_url(url)\n end", "def remove_privacy_statement_url(value)\n @children['privacy-statement-url'][:value].delete(value)\n end", "def remove(item)\n self.link(:title=>\"Remove #{item}\").click\n end", "def delete_bad_link(record, link)\n record.send(link.to_s+\"_id=\", nil)\n#@report << \"Delete bad link: #{link.to_s+'_id='}nil, changed? = #{record.changed?}\\n\"\n end", "def destroy\n destroy_and_respond(@link)\n end", "def remove_link(src_policy_element, dst_policy_element)\n assert_different_machines(src_policy_element, dst_policy_element)\n src_policy_element.unlink(dst_policy_element)\n end", "def remove_url_anchor(url)\n url.gsub(/(\\S+)#(\\S+)?/) { $1 }\nend", "def unlink\n if current_user.picasa_identity\n current_user.picasa_identity.destroy\n flash[:notice] = \"We've dissassociated your Picasa account from your #{CONFIG.site_name} account.\"\n redirect_to :action => 'options'\n else\n flash[:notice] = \"Your Picasa account has not been linked before!\"\n redirect_to :action => 'options'\n end\n end", "def pretend_links_do_not_exist\n test_mode && remove_old_links\n end", "def unlinked\n reject(&:linked?)\n end", "def remove_item_link\n $tracer.trace(__method__)\n #unit_test_no_generate: remove_item_link, a.className(create_ats_regex_string(\"ats-remove\"))\n return ToolTag.new(a.className(create_ats_regex_string(\"ats-remove\")), __method__, self)\n end", "def strip_external_links(text)\n link_stripper = Loofah.fragment(text)\n\n link_stripper.scrub!(Loofah::Scrubber.new do |node|\n next unless node.name == 'a'\n\n begin\n uri = URI(node['href'].to_s.strip)\n rescue URI::InvalidURIError\n node.replace(node.inner_text)\n next\n end\n\n next if uri.relative?\n\n domain = ActionDispatch::Http::URL.extract_domain(\n uri.host.to_s, ActionDispatch::Http::URL.tld_length\n )\n\n node.replace(node.inner_text) unless domain == request.domain\n end)\n\n link_stripper.inner_html\n end", "def delete_lti_link(lti_link_id)\n path = \"/d2l/api/le/#{$le_ver}/lti/link/#{lti_link_id}\"\n _delete(path)\nend", "def unlink(link=nil)\n if link.class == String && block_given?\n @j_del.java_method(:unlink, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(link,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling unlink(link)\"\n end", "def removeHtml\r\n @page = Page.find(params[:id])\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n @page.update_attribute(:html , target)\r\n end", "def removal_link\n new_params = toggle_params\n\n h.content_tag(\n :li,\n h.link_to(\n h.html_escape(\"#{Documents::Category.model_name.human}: #{name}\") +\n close_icon,\n h.search_path(new_params)))\n end", "def strip_http(url = '')\n return url.gsub('http://', '')\n end", "def remove\n\t\t\tself.make_request!({uri: self.to_uri, method: :delete})\n\t\tend", "def remove_url_anchor(url)\n suburl = url[/[^#]+/]\n return suburl\nend", "def destroy(code)\n @@urls.delete(code)\n end", "def strip_url(url)\n url.sub!(/https\\:\\/\\//, '') if url.include? \"https://\"\n url.sub!(/http\\:\\/\\//, '') if url.include? \"http://\"\n return url\n end", "def destroy\n @useful_link = UsefulLink.find(params[:id])\n @useful_link.destroy\n\n respond_to do |format|\n format.html { redirect_to useful_links_url }\n format.json { head :no_content }\n end\n end", "def delete_link(link)\n puts \"Removing link: \" + link\n ScraperWiki.sqliteexecute(\"DELETE FROM links WHERE link = '#{link}'\")\n ScraperWiki.commit()\nend", "def delete_link(link)\n puts \"Removing link: \" + link\n ScraperWiki.sqliteexecute(\"DELETE FROM links WHERE link = '#{link}'\")\n ScraperWiki.commit()\nend", "def trim_href(string)\n '#' + string.split('#')[1]\nend", "def remove_archives\n self.web_link.archive_links.each { |l| l.destroy }\n self.web_link.update_attribute(:archived, false)\n end", "def unlink\n if current_user.picasa_identity\n current_user.picasa_identity.destroy\n flash[:notice] = \"We've dissassociated your Picasa account from your NatureWatch NZ account.\"\n redirect_to :action => 'options'\n else\n flash[:notice] = \"Your Picasa account has not been linked before!\"\n redirect_to :action => 'options'\n end\n end", "def destroy\n @parsed_site.destroy\n\n head :no_content\n end", "def clean_destination_url\n if !self.url.blank? and self.url !~ REGEX_LINK_HAS_PROTOCOL\n self.url.insert(0, URL_PROTOCOL_HTTP)\n end\n end", "def destroy\n @link = UserLink.find(params[:id])\n @link.destroy\n\n redirect_to links_url\n end", "def transform(link)\n link = Filters::Util.make_URI(link)\n return link unless (link != nil && link.query != nil)\n link.query = nil\n link\n end", "def delete\n delete_from_server single_url\n end", "def ignore_links\n @link_rules.reject\n end", "def clear_code(url)\n if url = find(code)\n purge(code, url)\n end\n end", "def onRemoved(links)\n @set -= links\n end", "def remove_blob_in_package_ref_url(value)\n @children['blob-in-package-ref-url'][:value].delete(value)\n end", "def unshare\n self.slug = nil\n end", "def remove_url_anchor(url)\n url.split(/#/).first\nend", "def remove_tag_url(tag_id)\n url + '/tag_uses/' + tag_id\n end", "def verify_linkurl(linkurl)\n url = Loofah.scrub_fragment(linkurl, :prune).to_s\n url if valid_url?(url)\n end", "def disable_link\n @disable_link = true\n end", "def clear_backlinks\n @backlinks = []\n end", "def purge_link_update(*titles)\n purge_request({ forcelinkupdate: 1 }, titles)\n end" ]
[ "0.72726053", "0.72398233", "0.713943", "0.713943", "0.713943", "0.70390487", "0.6958023", "0.6928066", "0.68861246", "0.677371", "0.677371", "0.67188716", "0.6716101", "0.67093617", "0.67045206", "0.6691306", "0.6643811", "0.65920997", "0.65794975", "0.6573608", "0.65212876", "0.64470077", "0.6392613", "0.63624007", "0.63422984", "0.63044304", "0.6283798", "0.627634", "0.6261777", "0.62561584", "0.6254189", "0.6238385", "0.62278026", "0.6187695", "0.6185122", "0.6173824", "0.6172496", "0.6166234", "0.616586", "0.613572", "0.6083606", "0.6079339", "0.6070978", "0.60679775", "0.6054416", "0.60540164", "0.6042321", "0.60246265", "0.60155624", "0.60019386", "0.59950614", "0.5992137", "0.597378", "0.5963423", "0.59564096", "0.59508836", "0.59497094", "0.59471196", "0.59390277", "0.59368855", "0.5934709", "0.59324044", "0.59244996", "0.5906091", "0.5899761", "0.5891023", "0.5886512", "0.58543044", "0.58504814", "0.5828562", "0.5825653", "0.5823894", "0.58200425", "0.58197135", "0.58165383", "0.5813425", "0.58120054", "0.5810365", "0.5809051", "0.579594", "0.579594", "0.57929885", "0.5786146", "0.5784034", "0.577915", "0.57735884", "0.57734406", "0.57733566", "0.57684565", "0.5762118", "0.5755184", "0.5747077", "0.57444036", "0.57380027", "0.57376146", "0.5736597", "0.57355773", "0.5733662", "0.5728852", "0.57284886" ]
0.7798636
0
List links that match the attributes
def list_links(args = {}) if args.empty? links else links.select { |link| link.match? args } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_all_links_attributes\n # Interface method\n end", "def link(attribute)\n links.find_all { |l| l.rel == attribute.to_s }\n end", "def links\n each_link.to_set\n end", "def links\n self[\"link\"].map { |l| l.href }\n end", "def links\n self[\"link\"].map { |l| l.href }\n end", "def links; end", "def links; end", "def links\n @links.values\n end", "def links\n\ttmp = []\n @doc.xpath('//field[@id=\"linkedWorkItems\"]/list/struct').each do |struct|\n\t linked_wid = struct.xpath('item[@id=\"workItem\"]').text\n\t role = struct.xpath('item[@id=\"role\"]').text\n\t tmp << \"#{role}:#{linked_wid}\"\n\tend\n\treturn tmp\n end", "def links\n data['links']\n end", "def list\n extract_names_and_urls = lambda do |doc|\n [extact_url(@url, document), extract_titles(document)]\n end\n \n html.css('a').map(&extract_names_and_urls)\n end", "def links\n construct_html(self.items)\n end", "def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end", "def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end", "def display_link_attributes(link)\n # Interface method\n end", "def links()\n return @links\n end", "def links\n @data.links ||= parsed_document.search(\"//a\") \\\n .map {|link| link.attributes[\"href\"] \\\n .to_s.strip}.uniq rescue nil\n end", "def links\n @doc.css('a[href]').map do |a|\n parse_element_attribute_uri(a, 'href')\n end.compact.uniq\n end", "def links\n return unless success? and body\n\n doc = Nokogiri::HTML(@body)\n \n links = []\n\n doc.css('div.list-lbc a').each do |a|\n link = {\n :url => a['href'],\n :title => a.css('div.title').first.content.strip\n }\n\n link[:ad_id] = link[:url][/^http:\\/\\/www.leboncoin.fr\\/locations\\/(\\d+).*/,1]\n links << link\n yield link if block_given?\n end\n\n links\n end", "def matching_links(type)\n link_pattern = config.public_send(\"link_#{type}_pattern\")\n return [] unless link_pattern\n\n metadata\n .select { |key| __send__(\"#{type}?\", key) }\n .map { |key, value| Allure::ResultUtils.public_send(\"#{type}_link\", key.to_s, value, link_pattern) }\n end", "def link_to(links)\n links.map { |link| \"<a href='#{link[:uri]}'>#{link[:name]}</a>\" }.join(\"<br>\")\nend", "def links\n @data[\"_links\"]\n end", "def link_attribute_list(attribute, separator = nil)\n links.map {|link| link.send(attribute).split(separator)}.flatten.uniq.sort\n end", "def links\n return @links\n end", "def links\n return @links\n end", "def links\n return @links\n end", "def links\n\t\t( 0...self.link_count ).collect do |i|\n\t\t\tself.link( i )\n\t\tend\n\tend", "def show_links\r\n links = Document.new(self).get_links\r\n puts \"There are #{links.length} links\"\r\n index = 1\r\n links.each do |l|\r\n puts \"link: name: #{l.name}\"\r\n puts \" id: #{l.id}\"\r\n puts \" href: #{l.href}\"\r\n puts \" index: #{index}\"\r\n index += 1\r\n end\r\n end", "def links\n\t\t@links.keys\n\tend", "def all_links\n Link.all\n end", "def all_links\n Link.all\n end", "def all_links\n Link.all\n end", "def each_hyperlink # :yields: text\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end", "def links\n response = Clever.request :get, url\n response[:links]\n end", "def links\n valid_link_keys = %w(mandate )\n valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }\n\n links_class = Struct.new(\n *{\n\n mandate: ''\n\n }.keys\n ) do\n def initialize(hash)\n hash.each do |key, val|\n send(\"#{key}=\", val)\n end\n end\n end\n links_class.new(valid_links)\n end", "def printcre(criteria, target)\n list = $page.css(\"a[#{criteria} = #{target}]\")\n list.each do |item|\n puts item['href']\n end\nend", "def href\n attributes[:href]\n end", "def links\n linked_to.map{|to|[self,to]}\n end", "def link_attributes\n [:accesskey, :charset, :coords, :hreflang, :id, :lang, :name, :onblur,\n :onclick, :ondblclick, :onfocus, :onkeydown, :onkeypress, :onkeyup,\n :onmousedown, :onmousemove, :onmouseout, :onmouseover, :onmouseup,\n :rel, :rev, :shape, :style, :tabindex, :target, :title, :type]\n end", "def render_link\n values.map { |v| link(link_field, v) }\n end", "def links\n return @links if @links\n return false unless @source\n @links = @source.scan(HREF_CONTENTS_RE).map do |match|\n # filter some malformed URLS that come in\n # meant to be a loose filter to catch all reasonable HREF attributes.\n link = match[0]\n Link.new(@t.scheme, @t.host, link).path\n end.uniq\n end", "def link_attributes(tag)\n Hash[$1.scan(/(\\w+)=\"([^\"]*)\"/)] if tag =~ link_regex\n end", "def links\n @links ||= []\n @links\n end", "def collect_links(html)\n Hash[Nokogiri::HTML(html).css('a').collect {|node| [node.text.strip, node.attributes['href'].to_s]}]\n end", "def extract_link_attributes(hash)\n select_link_attributes(hash).map do |attribute, value|\n \" #{attribute}=\\\"#{value}\\\"\"\n end\n end", "def non_fulltext_links\n links = []\n other_customlinks = @record.fetch('CustomLinks',{})\n if other_customlinks.count > 0\n other_customlinks.each do |other_customlink|\n link_url = other_customlink['Url']\n link_label = other_customlink['Text']\n link_icon = other_customlink['Icon']\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'customlink-other'})\n end\n end\n\n links\n end", "def links\n return @links unless @links.nil?\n @links = []\n return @links if !doc\n\n doc.search(\"//a[@href]\").each do |a|\n next if a['data-method'] && a['data-method'] != 'get'\n u = a['href']\n next if u.nil? or u.empty?\n abs = to_absolute(u) rescue next\n @links << abs if in_domain?(abs)\n end\n @links.uniq!\n @links\n end", "def processLinks\n if params[:plant][:links_attributes]\n for i in 0..2\n @curLink = @plant.links[i]\n\n if !params[:plant][:links_attributes][i.to_s][:name].empty?\n @curLink.name = params[:plant][:links_attributes][i.to_s][:name]\n end\n if !params[:plant][:links_attributes][i.to_s][:link].empty?\n @curLink.link = params[:plant][:links_attributes][i.to_s][:link]\n end\n end\n end\n end", "def links\n metadata[:links] || Set.new\n end", "def links\n links = []\n result = self.perform\n links = result.ft_links\n end", "def lists\n @links = Link.all\n @short_link = ActionMailer::Base.default_url_options[:host]\n end", "def multi_links(custom_attribute_value)\n res = \"\"\n value = custom_attribute_value\n attr = value.custom_attribute\n\n if attr.multiple?\n same_type = (attr == @last_type)\n @last_type = attr\n\n add_style = same_type ? \"display: none\" : \"\"\n remove_style = same_type ? \"\" : \"display: none;\"\n \n res += link_to_function(_(\"Add another\"), \"addAttribute(this)\", \n :class => \"add_attribute\", \n :style => add_style) \n res += link_to_function(_(\"Remove\"), \"removeAttribute(this)\", \n :class => \"remove_attribute\", \n :style => remove_style)\n end\n\n return res\n end", "def links\n @links ||= lambda do \n raw_links.map do |link|\n hash = {}\n link.keys.each do |key|\n hash[key] = link[key]\n end\n hash\n end\n end.call\n end", "def groups_links\n noko.css('div.toc li a').partition { |a| a.attr('href').include? CEASED_MEMBERS_URL }\n end", "def links\n curations = self.curations.select do |curation|\n curation.rating != '0' and curation.status != 'deleted'\n end\n\n links = curations.map do |curation|\n link = Link.find(curation.link_id)\n owner = User.find(link.link_owner)\n link_for_app = {\n curation_id: curation.id,\n link_id: link.id,\n status: curation.status,\n rating: curation.rating,\n date_added: curation.created_at,\n url: link.url,\n url_type: link.url_type,\n title: link.title,\n image: link.image,\n comment: curation.comment,\n shared_with: people_shared_with(link, owner),\n tags: curation.tags,\n owner: {\n name: owner.name,\n phone: owner.phone,\n }\n }\n link_for_app\n end\n links.sort_by { |link| link[:date_added] }.reverse\n end", "def get_raw_links\n @doc.xpath(LINKS_XPATH).map { |link| link['href'] }\n end", "def links\n if params[:links]\n titles = params[:links][:title]\n url = params[:links][:url]\n s = titles.zip(url)\n @external_links = []\n if (params[:label] == \"Classrooms\" || params[:label] == \"Subjects\") \n if params[:label] == \"Subjects\"\n label = \"Subjects\"\n else\n label = \"Classrooms\"\n end\n s.each do |f|\n a = f.flatten\n if ( a[1] != \"\") && (a[3] != \"\")\n @external_links << @current_school.external_links.create({:classroom_id => @classroom.id, :label => label,\n :title => a[1], :url => a[3] })\n end\n end\n else\n s.each do |f|\n a = f.flatten\n if ( a[1] != \"\") && (a[3] != \"\")\n @external_links << @current_school.external_links.create({:title => a[1], :label => params[:label], :url => a[3] })\n end\n end\n end\n end\n end", "def each_hyperlink # :yields: text\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end", "def links\n @source._links\n end", "def links\n valid_link_keys = %w(creditor creditor_bank_account )\n valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }\n\n links_class = Struct.new(\n *{\n\n creditor: '',\n\n creditor_bank_account: ''\n\n }.keys\n ) do\n def initialize(hash)\n hash.each do |key, val|\n send(\"#{key}=\", val)\n end\n end\n end\n links_class.new(valid_links)\n end", "def links\n return nil unless @item and self.type == :query and @item['entry']['link']\n @item['entry']['link']\n end", "def links\n param = {lat: lat.to_f, lng: lng.to_f, latlng: latlng}\n Hashie::Mash.new(EXTERNAL_LINKS.map{|key, pattern| [key, pattern % param]}.to_h)\n end", "def links\n valid_link_keys = %w(mandate new_customer_bank_account organisation parent_event payment payout previous_customer_bank_account refund subscription )\n valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }\n\n links_class = Struct.new(\n *{\n\n mandate: '',\n\n new_customer_bank_account: '',\n\n organisation: '',\n\n parent_event: '',\n\n payment: '',\n\n payout: '',\n\n previous_customer_bank_account: '',\n\n refund: '',\n\n subscription: ''\n\n }.keys\n ) do\n def initialize(hash)\n hash.each do |key, val|\n send(\"#{key}=\", val)\n end\n end\n end\n links_class.new(valid_links)\n end", "def my_links\n end", "def links=(value)\n @links = value\n end", "def links=(value)\n @links = value\n end", "def links=(value)\n @links = value\n end", "def sitemap_links\n each_sitemap_link.to_a\n end", "def links(doc)\n links = []\n doc.search(\"//a[@href]\").each do |a|\n u = a['href']\n next if u.nil? or u.empty?\n links << u\n end\n links.uniq!\n links\n end", "def list_item_simple_list items, attribute\n html = \"<p class=\\\"list_item_attribute\\\"><b>#{(items.size > 1 ? attribute.pluralize : attribute)}:</b> \"\n if items.empty?\n html << \"<span class='none_text'>Not specified</span>\"\n else\n items.each do |i|\n if block_given?\n value = yield(i)\n else\n value = (link_to get_object_title(i), show_resource_path(i))\n end\n html << value + (i == items.last ? \"\" : \", \")\n end\n end\n return html + \"</p>\"\n end", "def select_eo_links(irs_doc)\n irs_doc.xpath('//a/@href').select { |link| link.to_s =~ LINK_REGEX }.map(&:to_s)\n end", "def extract_group_links\n # this one works to extract the group node container:\n #\n # group_list_node = mahara_dashboard_page.css('#groups').each do |node|\n # ...\n # end\n #\n # However, I decided to go the easy way here with some knowledge on how the url must look like\n\n return @mahara_dashboard_page.links_with(:href => /mahara\\/group\\/view/)\n end", "def get_position_links\n # Get all links that have the text: \"View Details\"\n links = @page.links_with(:text => /View Details/)\n href_links = []\n # convert all links into an appropriate html link\n links.each { |link| href_links << 'https://www.jobsatosu.com' + link.href }\n href_links\n end", "def links\n\t self.tweets.collect{|t| t.links}.flatten.compact\n\tend", "def dedouche_links\n [\n { :url => 'http://dvorak.org/na', :name => 'Blankets'},\n { :url => 'http://dvorak.org/na', :name => 'Water'},\n { :url => 'http://dvorak.org/na', :name => 'Just Send Cash'}\n ]\n end", "def get_hrefs\n # this will grab all the html from the url that\n # the user created the scraper with\n url_to_scrape = HTTParty.get(self.url)\n # nokogiri turns everything from HTTParty into nodes.\n nodes = Nokogiri::HTML(url_to_scrape)\n nodes.css('a').each do |a|\n self.hrefs << a['href']\n end\n self.hrefs\n end", "def links_group_by(attribute, linkz = links)\n linkz.map { |link| { key: link.send(attribute), link: link } }\n .group_by { |entry| entry[:key] }\n .each { |key, link| link.map! { |l| l[:link] }}\n end", "def index\n @room_room_attribute_links = RoomRoomAttributeLink.all.page params[:page]\n end", "def method_missing(m)\n if @options[:tags].keys.include?(m)\n links = []\n @options[:tags][m].each do |selector, attribute|\n find_matches(links, selector, attribute)\n end\n links.uniq\n else\n puts \"Warning: There was no configuration on how to find #{m} links\"\n []\n end\n end", "def create_links(key)\n '<br>' + @items.select { |i| i[:category] == key }\n .map { |i| link_to(i[:title], i.identifier) }.join('<br>') + '<br>'*2\nend", "def return_links_array(doc)\n links = doc.css(\".search-content .teaser-item__title a\")\n recipe_links = []\n links.each do |element|\n recipe_links << \"https://www.bbcgoodfood.com\" + element.attribute('href').value\n end\n return recipe_links\n end", "def extract_links(doc)\n (doc/'a').map { |link|\n href = link['href']\n CGI.unescapeHTML(href) if href && href !~ /^#/\n }.compact\n end", "def links_feed\n end", "def links\n json_hyperschema[\"links\"] || []\n end", "def exist_links\n return [] if sumup.blank?\n\n sumup.fetch(\"public_praises\").fetch(\"items\")\n end", "def links\n typed_set(entities, Occi::Core::Link)\n end", "def links(object=nil)\n options[:links] ||= []\n options[:links] << object if object\n options[:links]\n end", "def links\n if @links.blank?\n @links = []\n link_nodes =\n FeedTools::XmlHelper.combine_xpaths_all(self.channel_node, [\n \"atom10:link\",\n \"atom03:link\",\n \"atom:link\",\n \"link\",\n \"channelLink\",\n \"a\",\n \"url\",\n \"href\"\n ])\n for link_node in link_nodes\n link_object = FeedTools::Link.new\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:href\",\n \"@atom03:href\",\n \"@atom:href\",\n \"@href\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.href == \"atom10:\" ||\n link_object.href == \"atom03:\" ||\n link_object.href == \"atom:\"\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@href\"\n ], :select_result_value => true)\n end\n if link_object.href.nil? && link_node.base_uri != nil\n link_object.href = \"\"\n end\n begin\n if !(link_object.href =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(link_object.href)\n link_object.href = FeedTools::UriHelper.resolve_relative_uri(\n link_object.href,\n [link_node.base_uri, self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n link_object.href =\n FeedTools::UriHelper.normalize_url(link_object.href)\n end\n link_object.href.strip! unless link_object.href.nil?\n next if link_object.href.blank?\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:hreflang\",\n \"@atom03:hreflang\",\n \"@atom:hreflang\",\n \"@hreflang\"\n ], :select_result_value => true)\n if link_object.hreflang == \"atom10:\" ||\n link_object.hreflang == \"atom03:\" ||\n link_object.hreflang == \"atom:\"\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@hreflang\"\n ], :select_result_value => true)\n end\n unless link_object.hreflang.nil?\n link_object.hreflang = link_object.hreflang.downcase\n end\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:rel\",\n \"@atom03:rel\",\n \"@atom:rel\",\n \"@rel\"\n ], :select_result_value => true)\n if link_object.rel == \"atom10:\" ||\n link_object.rel == \"atom03:\" ||\n link_object.rel == \"atom:\"\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@rel\"\n ], :select_result_value => true)\n end\n unless link_object.rel.nil?\n link_object.rel = link_object.rel.downcase\n end\n if link_object.rel.nil? && self.feed_type == \"atom\"\n link_object.rel = \"alternate\"\n end\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:type\",\n \"@atom03:type\",\n \"@atom:type\",\n \"@type\"\n ], :select_result_value => true)\n if link_object.type == \"atom10:\" ||\n link_object.type == \"atom03:\" ||\n link_object.type == \"atom:\"\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@type\"\n ], :select_result_value => true)\n end\n unless link_object.type.nil?\n link_object.type = link_object.type.downcase\n end\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:title\",\n \"@atom03:title\",\n \"@atom:title\",\n \"@title\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.title == \"atom10:\" ||\n link_object.title == \"atom03:\" ||\n link_object.title == \"atom:\"\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@title\"\n ], :select_result_value => true)\n end\n # This catches the ambiguities between atom, rss, and cdf\n if link_object.title == link_object.href\n link_object.title = nil\n end\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:length\",\n \"@atom03:length\",\n \"@atom:length\",\n \"@length\"\n ], :select_result_value => true)\n if link_object.length == \"atom10:\" ||\n link_object.length == \"atom03:\" ||\n link_object.length == \"atom:\"\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@length\"\n ], :select_result_value => true)\n end\n if !link_object.length.nil?\n link_object.length = link_object.length.to_i\n else\n if !link_object.type.nil? && link_object.type[0..4] != \"text\" &&\n link_object.type[-3..-1] != \"xml\" &&\n link_object.href =~ /^http:\\/\\//\n # Retrieve the length with an http HEAD request\n else\n link_object.length = nil\n end\n end\n @links = [] if @links.nil?\n @links << link_object\n end\n end\n return @links\n end", "def links(arg = nil)\n set_or_return(:links, arg, kind_of: Array)\n end", "def list_item_attribute attribute, value, url=nil, url_options={}\n unless url.nil?\n value = link_to value, url, url_options\n end\n return \"<p class=\\\"list_item_attribute\\\"><b>#{attribute}</b>: #{value}</p>\"\n end", "def job_links\n links = []\n loop do\n links << listing_page.links_with(class: 'ovalbuttondetails')\n break unless next_link\n @listing_page = next_link.click\n end\n links.flatten\n end", "def sort_links\n resource_service.sortable_fields.collect do |key,value|\n \tlink_to key, params.dup.update(:sort => key), :class => ((params[:sort].to_s==key.to_s) ? 'current' : '')\n end.join(' | ')\n end", "def hyperlinks\n links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) }\n links.map { |a| a.hyperlink }\n end", "def links\n @links ||= begin\n if doc\n # get a list of distinct links on the page, in absolute url form\n links = doc.css('a[href]').inject([]) do |list, link|\n href = link.attributes['href'].content\n href.strip! if href\n \n unless skip_link?(href)\n begin\n url = to_absolute(href)\n rescue URI::InvalidURIError\n $stderr.puts \"ERROR: bad URI #{href.inspect} on page #{self.url.to_s.inspect}\"\n else\n list << url if url.scheme =~ /^https?$/\n end\n end\n list\n end\n \n links.uniq!\n links\n else\n []\n end\n end\n end", "def find_links(url)\n # This should return an array of all links at the given URL\nend", "def relationship_related_link(attribute_name); end", "def test_links\n schema = Heroics::Schema.new(SAMPLE_SCHEMA)\n assert_equal(\n ['list', 'info', 'identify_resource', 'create', 'submit', 'update', 'delete'],\n schema.resource('resource').links.map { |link| link.name })\n end", "def search_links(page,content)\n page.links_with( :text => Regexp.new(content, true))\n end", "def links\n links = Hash.new([])\n order = []\n each_with_rescue(@notes) do |note|\n order << note.row\n links[note.row] += [link_helper(note)]\n end\n\n html = ''\n order.uniq!\n order.each do |row|\n html << \"#{row.is_a?(String) ? row : row.to_s.camelize}: #{links[row].join(\" | \\n\")}<br />\"\n end\n html\n end", "def link_bylines(bylines, links)\n bylines.map do |byline|\n if !!links && byline.user.try(:is_public)\n link_to byline.display_name, byline.user.public_path\n else\n byline.display_name\n end\n end\n end" ]
[ "0.73371696", "0.71691275", "0.7080161", "0.70359284", "0.70359284", "0.6885857", "0.6885857", "0.6767168", "0.67192537", "0.6717245", "0.6700448", "0.66823786", "0.6674021", "0.6674021", "0.66558456", "0.6645124", "0.66331834", "0.6629481", "0.6601029", "0.6598765", "0.6590518", "0.65729827", "0.65634084", "0.65456104", "0.65456104", "0.65456104", "0.64454025", "0.6434556", "0.64210916", "0.64197594", "0.64197594", "0.64197594", "0.6409636", "0.6397617", "0.6394475", "0.63691896", "0.6341951", "0.6305131", "0.63049775", "0.6295831", "0.62911475", "0.628788", "0.6271711", "0.62690544", "0.62481713", "0.6241586", "0.62341815", "0.6225661", "0.6222014", "0.621869", "0.62030375", "0.62011606", "0.6193906", "0.61931634", "0.61919194", "0.6172554", "0.61415887", "0.6138498", "0.6135247", "0.61077327", "0.60892165", "0.6086986", "0.6086259", "0.6080174", "0.60557735", "0.60557735", "0.60557735", "0.6045048", "0.6022287", "0.6012867", "0.6001109", "0.59975976", "0.5978387", "0.5978221", "0.5965221", "0.59611005", "0.59584713", "0.5953946", "0.5944325", "0.59368026", "0.5926573", "0.59196675", "0.591694", "0.59124947", "0.5889817", "0.5887692", "0.5883166", "0.5881402", "0.5879135", "0.58774656", "0.58592767", "0.58378077", "0.58320093", "0.58307135", "0.5827179", "0.5822054", "0.5819466", "0.5818189", "0.5808222", "0.5806171" ]
0.6734793
8
Finds all links that contain the search string
def find_links(search) links.select { |link| link.contains? search } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_links(page,content)\n page.links_with( :text => Regexp.new(content, true))\n end", "def research_sites(search_str)\n search_sites = link_to \"Google\", 'http://www.google.com/search?q=' + search_str, :target => '_blank'\n search_sites += ' | '\n search_sites += link_to \"Yahoo\", 'http://search.yahoo.com/search?p=' + search_str, :target => '_blank'\n search_sites += ' | '\n search_sites += link_to \"Technorati\", 'http://www.technorati.com/search' + search_str, :target => '_blank'\n search_sites += ' | '\n search_sites += link_to \"Wikipedia\", 'http://en.wikipedia.org/w/wiki.phtml?search=' + search_str, :target => '_blank'\n search_sites += ' | '\n search_sites += link_to \"del.icio.us\", 'http://del.icio.us/search/?all=' + search_str, :target => '_blank'\n end", "def search(date_str)\n doc = get_page_results\n rows = get_todays_rows(doc, date_str)\n # to get the relevant links\n regex = /puppy|pup|Pup|dog|Dog/\n results = filter_links(rows, regex)\nend", "def url_search(url)\n\t\tresponse = get_response_with_redirect(URI.parse(url))\n\t\tif (response.code != \"404\")\n\t\t\tresponse.body.each_line{|line|\n\t\t\t\tresults = line.scan(/href=\"([^\"]*)\"/)\n\t\t\t\tresults.each{|href|\n\t\t\t\t\tfound = URI.join(url, href[0]).to_s\n\t\t\t\t\turl_eval(found)\n\t\t\t\t}\n\t\t\t\t#TODO: find urls that are in plain text, not just href\n\t\t\t}\n\t\tend\n\t\treturn true\n\trescue => e\n\t\t$error.save_error_to_file(url, e, $majorErrorTxt)\n\t\treturn false\n\tend", "def search2(doc)\n doc.search('.subtext > a:nth-child(3)').map {|link| link['href'] }\n end", "def search(str)\n return [] if str.to_s.empty?\n \n words = str.downcase.split(' ')\n pattern = Regexp.new(words.join('|'))\n matches = []\n\n pages.each do |page|\n if page.title.downcase =~ pattern\n matches << [page, []]\n \n elsif page.body.downcase =~ pattern\n matches << [page, highlight(page.html, words)]\n end\n end\n\n matches\n end", "def find_links(url)\n # This should return an array of all links at the given URL\nend", "def searchLink(array,link)\n\t\tarrayLength = array.length\n\t\tlocAnchor = Array.new\n\t\tcountLoc = 0\n\t\t\t\n\t\tfor k in 0..arrayLength-1\n\t\t\tif ((array[k].include? \"#{link}\") && (array[k].include? \"<a href=\"))\n\t\t\t\t#puts \"FOUND #{link} at #{k}!\"\n\t\t\t\tlocAnchor[countLoc] = k\n\t\t\t\tcountLoc = countLoc + 1\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn locAnchor\n\tend", "def find_links_to(url, &block)\n url, selector = if url.kind_of? Array\n [url[1], url[0]]\n else\n [url, 'a']\n end\n \n links = (@data/selector).find_all do |link|\n link[:href].match(strip_url_params(url)) if link and link[:href]\n end\n \n links = links.compact.collect { |link| [link[:href], link.inner_text] }.uniq[0..@_hits - 1]\n \n links.collect do |link|\n yield link[0]\n end\n end", "def test_contains\n source = <<-EOF\n <foo>\n <a href=\"mailto:a@b.c\">a@b.c</a>\n <a href=\"http://www.foo.com\">http://www.foo.com</a>\n </foo>\n EOF\n doc = Document.new source\n\n [\n #['o', 2],\n ['foo', 1], ['bar', 0]].each { |search, expected|\n set = doc.elements.to_a(\"//a[contains(@href, '#{search}')]\")\n assert_equal expected, set.size\n }\n end", "def list_links(args = {})\n if args.empty?\n links\n else\n links.select { |link| link.match? args }\n end\n end", "def find_links(url)\n # This should return an array of all links at the given URL\n # Can be done using Nokogiri's css OR xpath methods\n #links = page.xpath('//a[@href]').map\n #links = page.xpath('//@href').map(&:value)\n links = []\n doc = Nokogiri::HTML(open(url))\n doc.css('a').each do |a_tag| #doc.css('a') is Nokogiri::XML::NodeSet\n href_str = String(a_tag['href']) # converting to String in case if it is NilClass type\n if href_str.include? \"http\"\n links.push(a_tag['href'])\n end \n end\n links\nend", "def get_movelist_urls_sf(search_url)\n results = Nokogiri::HTML(open(MOVELIST_SEARCH_URL_SF))\n result_links = results.css('li.result > article > h1 > a')\n movelist_urls = result_links.select{ |el|\n el.text.downcase.include? \"list of moves\"\n }.map{ |el|\n el.attribute('href').value\n }\nend", "def search3(doc)\n doc.search('.title > a:first-child').map { |link| link.inner_text}\n end", "def lookup_text\n\t\t$app.data_controller.search_matching_links_to @search_text\n\tend", "def search_on_filename\n needle = query.downcase.as_wiki_link\n all_pages.select { |name| name.downcase.include? needle }.map do |name|\n # unfreeze the String name by creating a \"new\" one\n SearchResult.new(name, 2 * @score, [0, name.tr('_', ' ')])\n end\n end", "def find_all( search_text = '.*', with_passwords: false )\n show( search_text, with_passwords: with_passwords, regex: true ) || []\n end", "def get_links(page_url)\n ndoc = Nokogiri::HTML(open(page_url))\n links = ndoc.css('a')\n tmp = []\n found = nil\n links.each do |ln|\n if ln.text == \"next 5,000\"\n tmp = get_links(\"http://en.wikipedia.org\" + ln[\"href\"])\n tmp << \"http://en.wikipedia.org\" + ln[\"href\"]\n found = true\n break\n end\n end\n if found == nil\n tmp << page_url\n end\n tmp\nend", "def search\n \n\t# Verifica se os parametros nao estao nulos\n if not params[:description].nil? and not params[:link][:category_id].nil? then\n\t\n\t\t# Formata a variavel descricao para fazer a consulta com LIKE corretamente\n\t\tdescription = \"%\" + params[:description] + \"%\"\n\t\t\n\t\t# Define as condicoes de busca\n\t\tconditions = \"category_id = :category AND description LIKE :description\"\n\t\t\n\t\t# Realiza a busca no banco de dados\n\t\t@links = Link.where(conditions, {:category => params[:link][:category_id], :description => description})\n\t\t\n\tend\n end", "def search_page_use_hpricot(url)\n sync_puts \"searching the link in #{url}\"\n # do something and put the new urls into the queue\n doc = Hpricot(open(url,{\n 'User-Agent' => 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.0)'\n }))\n converter = Iconv.new('utf-8', 'GBK')\n doc.search('a').each do |a|\n # a.inner_html.force_encoding('utf-8') is useless\n begin\n #sync_puts \"#{converter.iconv(a.inner_html)} => #{a.attributes['href']}\"\n @queue.push(a.attributes['href'])\n rescue ArgumentError\n sync_puts \"ArgumentError!!!\"\n end\n end\n end", "def find_links(page)\n links = []\n for link in page.links\n canonical = \"\"\n if /\\Ahttps?/.match(link.href.to_s)\n canonical = canonical + link.href.to_s\n else\n base = page.uri.scheme + \"://\" + page.uri.host\n base.chomp!\n begin\n if !link.uri\n next\n end\n canonical = URI.join(base, link.uri.path.to_s).to_s\n rescue URI::InvalidURIError, URI::InvalidComponentError\n next\n end\n end\n canonical.gsub!(/\\/\\z/, \"\")\n links.push(canonical)\n end\n return links\nend", "def links(doc)\n links = []\n doc.search(\"//a[@href]\").each do |a|\n u = a['href']\n next if u.nil? or u.empty?\n links << u\n end\n links.uniq!\n links\n end", "def select_eo_links(irs_doc)\n irs_doc.xpath('//a/@href').select { |link| link.to_s =~ LINK_REGEX }.map(&:to_s)\n end", "def links\n return @links if @links\n return false unless @source\n @links = @source.scan(HREF_CONTENTS_RE).map do |match|\n # filter some malformed URLS that come in\n # meant to be a loose filter to catch all reasonable HREF attributes.\n link = match[0]\n Link.new(@t.scheme, @t.host, link).path\n end.uniq\n end", "def search_page_use_hpricot(url)\n # do something and put the new urls into the queue\n doc = Hpricot(open(url,{\n 'User-Agent' => 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.0)'\n }))\n converter = Iconv.new('utf-8', 'GBK')\n doc.search('a').each do |a|\n # a.inner_html.force_encoding('utf-8') is useless\n begin\n if a.attributes['href'] != nil && !filtered?(a.attributes['href'])\n #sync_puts \"#{converter.iconv(a.inner_html)} => #{a.attributes['href']}\"\n @queue.push(a.attributes['href'])\n end\n rescue ArgumentError\n sync_puts \"ArgumentError!!!\"\n end\n end\n end", "def filter_links(links, filter_method, paths)\n links.send(filter_method) do |link|\n # Turn http://example.com into / meaning index.\n link = link.to_endpoint == '/' ? '/' : link.omit_base\n\n match = false\n paths.each do |pattern|\n match = File.fnmatch?(pattern, link, File::FNM_EXTGLOB)\n break if match\n end\n\n match\n end\n end", "def printcre(criteria, target)\n list = $page.css(\"a[#{criteria} = #{target}]\")\n list.each do |item|\n puts item['href']\n end\nend", "def search(pattern)\n entries.inject(Rush::SearchResults.new(pattern)) do |results, entry|\n if !entry.dir? and matches = entry.search(pattern)\n results.add(entry, matches)\n end\n results\n end\n end", "def search_words\n begin\n regex = Regexp.new(@pattern)\n rescue RegexpError => msg\n error_msg(msg)\n rescue NameError => msg\n error_msg(msg)\n end\n @results = DICT.select do |word|\n regex =~ word\n end\n @num_results = @results.length\n format_results\n display_results\n end", "def find_urls_on_page(doc, current_url)\t\n #puts \"Search and return URLs within the doc: #{doc}\" if @verbose\n\t\tbegin \n\t\t\turls_list = []\n\t\t\t# case 1 - search embedded HTML tag <a href='url'> for the url elements\n\t\t\tlinks=doc.css('a')\n\t\t\tlinks.map do |x|\n\t\t\t\t#puts \"x: #{x}\"\n\t\t\t\tnew_url = x.attribute('href').to_s\n\t\t\t\tunless new_url == nil\n\t\t\t\t\tif new_url.match(\"http\")\n\t\t\t\t\t\t#if urls_on_same_domain?(new_url,current_url)\n\t\t\t\t\t\t\turls_list.push(new_url)\n\t\t\t\t\t\t#end\n\t\t\t\t\telse\n\t\t\t\t\t\tnew_url = make_absolute(current_url, new_url)\n\t\t\t\t\t\turls_list.push(new_url)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\t# case 2 - search client side redirect - <meta http-equiv=\"refresh\" content=\"5;URL='http://example.com/'\">\n\t\t\telements=doc.css(\"meta[http-equiv]\")\n\t\t\tunless elements.size == 0\n\t\t\t\tlink=elements.attr(\"content\").value.split(/url\\=/i)[1]\n\t\t\t\tunless link.nil?\n\t\t\t\t\tnew_url = make_absolute(current_url, link)\n\t\t\t\t\turls_list.push(new_url) unless new_url.nil?\n\t\t\t\tend\t\t\t\t\n\t\t\tend\n\t\t\t#puts \"Found URLs under page #{current_url}:\\n#{urls_list}\" if @verbose\n\t\t\treturn urls_list.uniq-[\"\",nil]\n rescue => ee\n puts \"Exception on method #{__method__}: #{ee}\" if @verbose\n return nil\n\t\tend\n end", "def get_job_links(search_results)\n\t\tjob_links = search_results.links.find_all do |l| \n\t\t\t!l.href.nil? && l.href.match(/(\\/jobs\\/detail\\/)/)\n\t\tend\n\t\tjob_links\n\tend", "def search(search_string)\n\n # Convert to a get-paramenter\n search_string = CGI.escapeHTML search_string\n search_string.gsub!(\" \", \"&nbsp;\")\n\n results = []\n \n return results\n end", "def get_urls(search_results)\n # A Google search_result looks like:\n # <a href=\"/url?q=https://www.scienceexchange.com/\">Science Exchange<b>...</b></a>\n # To get the actual page URL, use the 'href' and get the query param 'q' term.\n urls = []\n search_results.each do |result|\n url = result['href']\n query = URI.parse(url).query\n result_url = CGI.parse(query)['q'].first\n result_url = url if result_url.nil?\n urls << result_url\n end\n return urls\n end", "def xpath_search\n return unless grafana_url.present?\n\n %(descendant-or-self::a[starts-with(@href, '#{grafana_url}')])\n end", "def to_links(per_page = 100)\n htag_set = Set.new\n\n search = Twitter::Search.new\n @search.per_page(100).fetch.each do |msg|\n links = msg.text.split(\" \").select { |f| f.strip =~ /^https?:/ }\n links.each { |link| htag_set.add(link.strip) }\n end\n\n htag_set\n end", "def search(term)\n all.select do |unit|\n unit.aliases.any? { |str| Regexp.new(term).match(str) }\n end\n end", "def urls(text)\n scan(text, URL, :url)\n end", "def get_mag_index_pages(mag_url)\n links = []\n doc = Nokogiri::HTML(open(mag_url, :allow_redirections => :safe)) \n doc.css(\"a[href]\").each do |p|\n if p.attribute('href').to_s.include? \"#issues\"\n links.push(p.attribute('href').to_s)\n end\n end\n # the link of the actual url is not in the array. it needs to be,\n # since this is the first page that index issues.\n links.push(mag_url)\n return links.uniq\nend", "def searches\n Boundary.get(@url)\n end", "def searchABatch(directory, extension, searchString)\n return Dir.entries(directory).select{|file| File.open(file, \"r\").include?(searchString)}\nend", "def external_search_urls\n {\n Google_Maps: \"https://maps.google.com/maps?q=\",\n Google_Search: \"https://www.google.com/search?q=\",\n Wikipedia: \"https://en.wikipedia.org/w/index.php?search=\"\n }.freeze\n end", "def matching_links(type)\n link_pattern = config.public_send(\"link_#{type}_pattern\")\n return [] unless link_pattern\n\n metadata\n .select { |key| __send__(\"#{type}?\", key) }\n .map { |key, value| Allure::ResultUtils.public_send(\"#{type}_link\", key.to_s, value, link_pattern) }\n end", "def relevant_fulltext_link?(link)\n relevant_links.map { |x| link[:url].include?(x) }.any?\n end", "def get_listing_URLs_from_search_html(search_html)\r\n raise NotImplementedError\r\n end", "def search(pattern)\n entries.grep(Regexp.new(pattern))\n end", "def source_search(url, html)\n\n hits = []\n\n html.css('script,embed,object').each do |source|\n\n # attributes\n data = source.attr('data')\n src = source.attr('src')\n\n if src.nil?\n # load script and parse?\n else\n # check src lib name\n hits << url if src =~ /swfobject.js|player.swf/i\n hits << url if data =~ /player.swf/i\n end\n end\n\n hits.uniq!\n\n end", "def search\n if Config[\"ISEARCH\"]\n incremental_search\n else\n str = getstr('/')\n do_search NEXT, str\n end\n end", "def auto_search\n\t\tif (@curURL_Sr != nil)\n\t\t\turl_search(@curURL_Sr)\n\t\t\tHashOfArray_smart_add($searched, @curURL_Sr)\n\t\t\t$toSearch.shift\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend", "def search_list\n if params[:keyword].nil? or params[:keyword].empty?\n redirect_back :fallback_location => root_path, :alert => \"Unrecognized user input. \"\n else\n keyword = \"%\" + params[:keyword].strip + \"%\"\n end\n @domains = Domain.where('name like ?', keyword).limit(10)\n end", "def search\n http, request = frame_request @keyword\n\n # Getting response from YouTube\n response = http.request(request)\n\n # Parsing for serialization of the response\n json_response = JSON.parse(response.body)\n\n # Any mishaps inside the code-block will return an empty array.\n begin\n json_response['feed']['entry'].map{ |rsp| \n rsp['media$group']['media$content'].first.send(:[],'url')\n }\n rescue\n []\n end\n end", "def search_page(url, agent, keywords, depth, log_level=1)\n begin\n page = agent.get(url.to_s.downcase) # agent acquires the page.\n rescue => e\n puts \"Get page: #{e}\"\n return \"page not found\"\n end\n if !((sf = find_software(keywords, page, agent)) || depth == 0)\n if !page.nil?\n link_array = []\n puts \"... iterate over #{page.links.count} links\" if log_level>1\n page.links.each do |link| # Loops through each link and appends it to the link array to be searched.\n if link.href.to_s != '' && !link.href.index(' ')\n puts \"... ... adding #{link.href}\" if log_level>1 # Optional logging\n begin\n if link.href.to_s.index(\"http\") == 0\n link_array << link.href\n else\n puts page.uri.to_s + \" : \" + link.href.to_s if log_level>1\n link_array << URI.join(page.uri, link.href).to_s\n end\n rescue => e\n puts \"link loop: #{e}\"\n end\n end\n end\n for page_url in link_array.uniq # Performs search_page on each link in link_array\n if !\"#{page_url}\".match(/(mailto:|javascript|facebook|instagram|twitter|yelp|youtube|plus.google|pinterest|vimeo|buckley.af|tel:1800|tel:1-800)/)\n puts \"... checking #{page_url}\" if log_level > 0\n sf = search_page(page_url, agent, keywords, depth-1, log_level) # depth-1 so the function won't call itself forever\n #if sf == \"none found\" || \"page not found\"\n #doc = Nokogiri::HTML(open(page_url))\n # Input function for searching iFrame\n #end\n break if ![\"none found\",\"page not found\"].index(sf) # Breaks out of loop if sf isn't \"none found\" or \"page not found\"\n sf = nil\n end\n end\n end\n end\n return sf || \"none found\" # Returns software (sf) or \"none found\"\nend", "def search_text(text, max_results)\n begin\n\n return [] if @settings.wikipedia_host.empty?\n\n search = Wikipedia.client.request( {\n action: 'opensearch',\n search: text,\n limit: max_results,\n redirects: 'resolve',\n format: 'json'\n } )\n\n # search => \"[\\\"GnR\\\",[\\\"Guns N' Roses\\\"],[\\\"Guns N' Roses is an American hard blah blah.\\\"],\n # [\\\"https://en.wikipedia.org/wiki/Guns_N%27_Roses\\\"]]\"\n search = JSON.parse(search)\n\n # Format result\n results = []\n names = search[1]\n urls = search[3]\n names.each_with_index do |name, index|\n results << [ name , urls[index] ]\n end\n return results\n\n rescue\n Log.log_last_exception\n return []\n end\n end", "def get_links(url)\n # catch 404 error from host\n\n doc = Nokogiri::HTML(open(url))\n # find internal links on page\n doc.css('#tagCloud a').each do |link|\n link = link.attr('href')\n # If link correspond to a recipe we add it to recipe to scraw\n if link.include?(ALLOWED_URLS[@host]) && !@crawled_urls.include?(url)\n @to_crawl_urls << link\n end\n end\n @to_crawl_urls.delete url\n @crawled_urls << url\n @to_crawl_urls.uniq!\n rescue OpenURI::HTTPError\n @to_crawl_urls.delete url\n warn \"#{url} cannot be reached\"\n end", "def count_all_links(dir)\n perform_global_search('//a', [], dir)\n end", "def retrieve_links(search_service, site, page)\n term = search_service.and_query(\"site:#{site}\", name, page)\n result = extract_first_result(search_service, query_bing(search_service, term))\n unless (result.nil? || result.url.nil?)\n enhance_with_bing(page, result)\n end\n end", "def object_link_filter(text, pattern, link_text: nil)\n references_in(text, pattern) do |match, id, project_ref, matches|\n project = project_from_ref(project_ref)\n\n if project && object = find_object(project, id)\n title = object_link_title(object)\n klass = reference_class(object_sym)\n\n data = data_attribute(\n original: link_text || match,\n project: project.id,\n object_sym => object.id\n )\n\n url = matches[:url] if matches.names.include?(\"url\")\n url ||= url_for_object(object, project)\n\n text = link_text || object_link_text(object, matches)\n\n %(<a href=\"#{url}\" #{data}\n title=\"#{escape_once(title)}\"\n class=\"#{klass}\">#{escape_once(text)}</a>)\n else\n match\n end\n end\n end", "def return_links_array(doc)\n links = doc.css(\".search-content .teaser-item__title a\")\n recipe_links = []\n links.each do |element|\n recipe_links << \"https://www.bbcgoodfood.com\" + element.attribute('href').value\n end\n return recipe_links\n end", "def get_links(url)\n @driver.get(url)\n data = @driver.execute_script(\"return document.getElementsByTagName('html')[0].innerHTML\")\n\n Nokogiri::HTML(data).css(\"a\").map do |link|\n if (href = link.attr(\"href\"))\n res = Link.new\n\n begin\n res.href = self.build_careers_page_url(url, href.strip).to_s\n rescue\n res.href = nil\n end\n res.text = link.text\n res\n end\n end.compact.reject do |link|\n link.href.nil?\n end.uniq\n end", "def get_links(post)\n post_links = post.content.content.scan(/youtube.*?\\\"/)\nend", "def _resolve_links(text)\n text.gsub(/L\\((\\w+)\\)/) { _link($1) }\nend", "def search\n @links = Link.search do\n keywords params[:query]\n end.results\n\n respond_to do |format|\n format.html { render :action => \"index\" }\n format.json { render :json => @links }\n end\n end", "def get_all_the_urls_of_val_doise_townhalls\n\n\n page1 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\")) #ouvre la page ciblée\n $get_llinks = page1.css('a[href*=\"95\"]').map{|link| link[\"href\"]} #definie un array \"get_llinks\" cible la balise avec href 95 et prend toutes les fin d'url\n\n\nend", "def get_all_the_urls_of_val_doise_townhalls\n\n\n page1 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\")) #ouvre la page ciblée\n $get_llinks = page1.css('a[href*=\"95\"]').map{|link| link[\"href\"]} #definie un array \"get_llinks\" cible la balise avec href 95 et prend toutes les fin d'url\n\n\nend", "def search(word)\r\n \r\n end", "def find_videos_linked_in_text(text)\n raise ArgumentError, \"must provide a text string\" unless text.is_a?(String)\n \n raw_urls = text.split.grep(URL_REGEX)\n return videos_from_url_array(raw_urls)\n end", "def extract_all_links(html, base)\n base_url = URI.parse(base)\n doc = Nokogiri::HTML(html)\n links = []\n doc.css(\"a\").each do |node|\n \n begin\n uri = URI(node['href'])\n if uri.absolute? and uri.scheme != \"javascript\" \n links << uri.to_s\n elsif uri.path.start_with?(\"/\")\n uri = base_url + uri\n end\n rescue\n # don't do anything\n end\n end \n links.uniq\n end", "def search(pattern, search_constraints=nil)\n matches = []\n @entries_mutex.synchronize do\n @entries.each do |aid, agent_description|\n matches << agent_description if agent_description.matches? pattern\n end\n end\n matches\n end", "def search_text(query, text)\n text = pattern(text)\n query.where { title.ilike(text) | description.ilike(text) }\n end", "def search_link(attr, value, content)\n string = \"<a href='#{@search_url}#{attr.downcase}=#{value.downcase}'>#{content}</a>\"\nend", "def grep_for(text, where = \"./\", double_quote = false, perl_regex = false)\n # If they're on Windows, they probably don't have grep.\n @probably_has_grep ||= (Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/).nil?\n\n # protect against double root paths in Rails 3\n where.gsub!(Regexp.new(base_path),'')\n\n lines = if @probably_has_grep\n find_with_grep(text, base_path + where, double_quote, perl_regex)\n else\n find_with_rak(text, base_path + where, double_quote)\n end\n\n # ignore comments\n lines.gsub /^(\\/[^:]+:)?\\s*#.+$/m, \"\"\n end", "def parse_search_results(page)\n libraries_available = []\n links = page.css(\"ol[class=result] li[class=clearfix] h3 a\")\n links.each do |link|\n fetch_result = fetch(\"#{LIBRARY_BASE_URL + (link.attr 'href')}\")\n body = Zlib::GzipReader.new(StringIO.new(fetch_result[:response].body)).read\n libraries_available.concat parse_detail(body)\n\n # should we go to the next link? do we already know if it's available at our library?\n if libraries_available.include? LIBRARY_MY_STRING; return [LIBRARY_MY_STRING] end\n end\n\n libraries_available\nend", "def get_urls(target)\n trail_urls = []\n i = 24\n while i < 162\n search_page_hike_url = target[i].to_s\n search_page_hike_url = search_page_hike_url.gsub(\"&amp;\", \"&\")\n search_page_hike_url = search_page_hike_url.gsub(/\\<a href=\"/, \"\")\n search_page_hike_url = search_page_hike_url.gsub(/\" .*/, \"\")\n trail_urls << search_page_hike_url\n i+=1\n end\n trail_urls\nend", "def find_links(html_code)\n all_links = Array.new\n page = Mechanize::Page.new(nil, nil, html_code, nil, Mechanize.new)\n page.links.each do |link|\n all_links.push(link.href)\n end\n # fill in some code here!\n return all_links\nend", "def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end", "def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end", "def search_all_paths(word)\n\n\tsearch_project_paths(word)\n\tsearch_bundle_paths(word)\n\t\n\t$best_paths.uniq!\n\t$package_paths.uniq!\n\t\n\t{ :exact_matches => $best_paths, :partial_matches => $package_paths }\n\t\nend", "def links\n return @links unless @links.nil?\n @links = []\n return @links if !doc\n\n doc.search(\"//a[@href]\").each do |a|\n next if a['data-method'] && a['data-method'] != 'get'\n u = a['href']\n next if u.nil? or u.empty?\n abs = to_absolute(u) rescue next\n @links << abs if in_domain?(abs)\n end\n @links.uniq!\n @links\n end", "def similars\n uri = URI(site.home)\n if match = uri.host.match( /\\b\\w*\\.\\w*$/)\n Site.joins(:reference).\n where(\"type = 'SiteReference' and url ILIKE ?\", \"%#{match[0]}%\").\n uniq.\n keep_if { |other| other.id != site.id }\n else\n []\n end\n end", "def search(search_string)\n GoogleAjax::Search.web(search_string)[:results]\n end", "def list\n extract_names_and_urls = lambda do |doc|\n [extact_url(@url, document), extract_titles(document)]\n end\n \n html.css('a').map(&extract_names_and_urls)\n end", "def search_text(\n query, case_sensitive: false, whole_sentence: true,\n limit: 10, skip: 0, sentence_limit: 80, top_result_only: false\n )\n results = search(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n limit: limit,\n skip: skip\n )\n\n results\n .map do |doc|\n yield(doc) if block_given?\n\n results = doc.search(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n sentence_limit: sentence_limit\n )\n\n # Only return result if its text has a match - compact is called below.\n next nil if results.empty?\n\n [doc.url, (top_result_only ? results.first : results)]\n end\n .compact\n .to_h\n end", "def snippet_link_filter(text)\n self.class.references_in(text) do |match, id, project_ref|\n project = self.project_from_ref(project_ref)\n\n if project && snippet = project.snippets.find_by(id: id)\n push_result(:snippet, snippet)\n\n title = escape_once(\"Snippet: #{snippet.title}\")\n klass = reference_class(:snippet)\n data = data_attribute(project.id)\n\n url = url_for_snippet(snippet, project)\n\n %(<a href=\"#{url}\" #{data}\n title=\"#{title}\"\n class=\"#{klass}\">#{match}</a>)\n else\n match\n end\n end\n end", "def find_links(html)\n i = 0\n while i < html.length\n\n # If we get to an opening carrat, we want to return a Node object for quicker\n # parsing\n # We also want to keep track of the indentation level\n if html[i] == \"<\"\n\n # We will skip ahead to the closing carat, and then analyze that node object\n find_closing_carat\n\n else\n next\n end\n end\n end", "def url_contains_keywords (url, keywords)\n unless keywords.nil?\n arr = keywords.split(',')\n arr.each do |keyword|\n if url.downcase.include? keyword.downcase\n puts \"Found matching keyword: #{keyword}\"\n return true\n end\n end\n \n puts \"Didn't find any keywords in #{url}.\"\n false\n end\nend", "def extractLinks(page)\n\tbase_wiki_url = \"https://en.wikipedia.org\"\n\tlinks = page.search(\"//a\")\n\tlinks = links.map{|item| item[\"href\"]}\n\n\t#Appending with base_wiki_page to make it full fledged page.\n\tlinks = links.map{|link| base_wiki_url+link.to_s}\n\n\treturn stripUnwantedLinksBasedOnCondition(links)\nend", "def get_names_and_urls(page)\n names_and_urls = []\n for _a in page.xpath('.//a[@href]')\n names_and_urls << _a if ((_a['href'] =~ %r{^/\\w+/$}))\n end\n names_and_urls.map{ |_a| [ _a['href'], _a.content.strip ] }\nend", "def filter_links(html_string)\n\thash = {}\n\t# Get links from HTML content\n\tlink_regex = /<a href=\"\\/wiki[^>]*?>/\n\thtml_string.each_line { |line|\n\t\tmatches = line.scan(link_regex)\n\t\tmatches.each { |link|\n\t\t\t# Remove special links\n\t\t\tif link !~ /\\/wiki\\/(Book|Book_talk|Category|File|Forum|Help|Portal|Portal_talk|Special|Talk|Template|Thread|User|User_blog|User_talk|Wikipedia|Wikipedia_talk):/\n\t\t\t\t# Remove ?redirect=no links\n\t\t\t\tif link !~ /\\?redirect=no/\n\t\t\t\t\t# Remove links without title=\"...\"\n\t\t\t\t\tif link =~ /title=\".*?\"/\n\t\t\t\t\t\t# Remove any fragments\n\t\t\t\t\t\tif link =~ /(.*)#.*?(\".*)/\n\t\t\t\t\t\t\tlink = $1 + $2\n\t\t\t\t\t\tend\n\t\t\t\t\t\tlink = link.to_sym\n\t\t\t\t\t\tif !hash.has_key?(link)\n\t\t\t\t\t\t\thash[link] = 0\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\t}\n\treturn hash\nend", "def search\n words = params[:query].split(/\\s+/).reject(&:blank?)\n url = nil\n\n case words.size\n when 1\n if words.first.starts_with?('@')\n user = find_users(words.first[1..-1]).only\n url = user_url(user) if user\n else\n project = find_projects(words[0]).only.try!(:sluggable)\n url = project_url(project) if project\n end\n when 2\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n url = project_environment_bugs_url(project, env) if env\n when 3\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n url = project_environment_bug_url(project, env, bug) if bug\n when 4\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n occurrence = bug.occurrences.find_by_number(words[3].to_i) if bug\n url = project_environment_bug_occurrence_url(project, env, bug, occurrence) if occurrence\n end\n\n url ? render(text: url) : head(:ok)\n end", "def merge_request_link_filter(text)\n self.class.references_in(text) do |match, id, project_ref|\n project = self.project_from_ref(project_ref)\n\n if project && merge_request = project.merge_requests.find_by(iid: id)\n push_result(:merge_request, merge_request)\n\n title = escape_once(\"Merge Request: #{merge_request.title}\")\n klass = reference_class(:merge_request)\n data = data_attribute(project.id)\n\n url = url_for_merge_request(merge_request, project)\n\n %(<a href=\"#{url}\" #{data}\n title=\"#{title}\"\n class=\"#{klass}\">#{match}</a>)\n else\n match\n end\n end\n end", "def search(target)\n end", "def search (pattern)\n\t\tputs \"Search site store based on the regular expression: #{pattern}\" if @verbose\n\t\tpattern=pattern.strip.downcase\n\t\tresults=Array.new\n\t\t@known_sites.keys.map do |key|\n\t\t\tif key =~ /#{pattern}/i\n\t\t\t\tresults.push(key)\n\t\t\tend\n\t\tend\n\t\treturn results\n\trescue Exception => ee\n\t\tputs \"Exception on method search: #{ee}\" if @verbose\n\t\treturn nil\n\tend", "def get_urls(proxy=nil)\n query = SETTINGS.extract_query!\n payloads = SETTINGS.create_payloads(PAYLOAD_TEMPLATE_PATH)\n File.read(\"#{QUERY_BLACKLIST_PATH}\").each_line do |black| # check if the search query is black listed\n if query == black\n FORMAT.warning(\"Query: #{query} is blacklisted, defaulting to random query\")\n query = File.readlines(\"#{PATH}/lib/lists/search_query.txt\").sample # Retry if it is\n end\n end\n\n FORMAT.info(\"I'm searching for possible SQL vulnerable sites, using search query #{query.chomp}\")\n agent = Mechanize.new\n if proxy\n agent.set_proxy(proxy.split(\":\").first, proxy.split(\":\").last) # Set your proxy if used\n end\n correct_agent = SETTINGS.random_agent?\n agent.user_agent = correct_agent\n\n correct_agent == DEFAULT_USER_AGENT ? FORMAT.info(\"Using default user agent\") :\n FORMAT.info(\"Grabbed random agent from #{RAND_AGENT_PATH}\")\n\n google_page = agent.get(\"http://google.com\")\n google_form = google_page.form('f')\n\n FORMAT.info(\"Verifying search query...\")\n unless SETTINGS.test_query(query, correct_agent, proxy)\n query = File.readlines(\"#{PATH}/lib/lists/search_query.txt\").sample\n LOGGER.info(\"Query changed to: #{query}\")\n end\n\n google_form.q = \"#{query}\" # Search Google for the query\n url = agent.submit(google_form, google_form.buttons.first)\n\n url.links.each do |link|\n if link.href.to_s =~ /url.q/ # Pull the links from the search\n str = link.href.to_s\n str_list = str.split(%r{=|&})\n urls = str_list[1]\n if urls.split(\"/\")[2].start_with?(*SKIP) # Skip all the bad URLs\n next\n end\n urls_to_log = URI.decode(urls)\n FORMAT.success(\"Site found: #{urls_to_log}\")\n sleep(0.3)\n payloads.each { |payload|\n File.open(\"#{SITES_TO_CHECK_PATH}\", \"a+\") { |to_check| to_check.puts(\"#{urls_to_log}#{payload}\")}\n }\n end\n end\n FORMAT.info(\"I've dumped possible vulnerable sites into #{SITES_TO_CHECK_PATH}\")\n end", "def object_link_filter(text, pattern, link_content: nil, link_reference: false)\n references_in(text, pattern) do |match, id, project_ref, namespace_ref, matches|\n parent_path = if parent_type == :group\n reference_cache.full_group_path(namespace_ref)\n else\n reference_cache.full_project_path(namespace_ref, project_ref)\n end\n\n parent = from_ref_cached(parent_path)\n\n if parent\n object =\n if link_reference\n find_object_from_link_cached(parent, id)\n else\n find_object_cached(parent, id)\n end\n end\n\n if object\n title = object_link_title(object, matches)\n klass = reference_class(object_sym)\n\n data_attributes = data_attributes_for(link_content || match, parent, object,\n link_content: !!link_content,\n link_reference: link_reference)\n data_attributes[:reference_format] = matches[:format] if matches.names.include?(\"format\")\n\n data = data_attribute(data_attributes)\n\n url =\n if matches.names.include?(\"url\") && matches[:url]\n matches[:url]\n else\n url_for_object_cached(object, parent)\n end\n\n url.chomp!(matches[:format]) if matches.names.include?(\"format\")\n\n content = link_content || object_link_text(object, matches)\n\n link = %(<a href=\"#{url}\" #{data}\n title=\"#{escape_once(title)}\"\n class=\"#{klass}\">#{content}</a>)\n\n wrap_link(link, object)\n else\n match\n end\n end\n end", "def all_links\n self.fulltext_links + self.non_fulltext_links\n end", "def links\n @doc.css('a[href]').map do |a|\n parse_element_attribute_uri(a, 'href')\n end.compact.uniq\n end", "def mention_link_filter(text, base_url='/', issueid_pattern)\n self.class.mentioned_issues_in(text, issueid_pattern) do |match, issueid|\n link = link_to_mentioned_issue(issueid)\n link ? match.sub(\"\\##{issueid}\", link) : match\n end\n end", "def links\n @data.links ||= parsed_document.search(\"//a\") \\\n .map {|link| link.attributes[\"href\"] \\\n .to_s.strip}.uniq rescue nil\n end", "def search_externally(search_term:)\n return [] unless search_term.present? && search_term.length > 2\n\n orgs = externals_search(search_term: search_term)\n prepare(search_term: search_term, records: orgs)\n end", "def search_filenames\n # * => all files\n # r => search from its subdirectories\n # i => ignore cases\n # l => list file name\n # c => show word occurence count\n # w => words\n\n args = set_args\n # grep -ril '#keyword1' --include=\\*.rb *\n `grep -ril '#{args}' #{search_extension} *`\n end", "def search(word)\n \n end" ]
[ "0.7509331", "0.6644939", "0.6555102", "0.6539062", "0.6487399", "0.6372842", "0.6367508", "0.6366524", "0.62081313", "0.61661977", "0.61636686", "0.5996572", "0.597002", "0.5932552", "0.5927549", "0.5926851", "0.5862333", "0.5827129", "0.582345", "0.5766893", "0.5757087", "0.5751092", "0.573244", "0.5726943", "0.57176167", "0.56631327", "0.56630766", "0.56542665", "0.5640144", "0.5638504", "0.56232417", "0.5597439", "0.55885637", "0.55755585", "0.5562473", "0.5549673", "0.55495584", "0.55283654", "0.55253994", "0.55182433", "0.5512704", "0.54894704", "0.5486063", "0.5458352", "0.5453492", "0.5445061", "0.5443069", "0.5426327", "0.54178077", "0.5412347", "0.5391399", "0.53909546", "0.5388496", "0.53868794", "0.5370279", "0.5352703", "0.53492403", "0.53491545", "0.5333774", "0.5330981", "0.5330087", "0.5323095", "0.5323095", "0.5319915", "0.5313179", "0.52888227", "0.5287335", "0.5284125", "0.52804947", "0.52798605", "0.5278047", "0.52760106", "0.5275046", "0.52735084", "0.52735084", "0.52729493", "0.5272392", "0.52701426", "0.5266302", "0.52655464", "0.52654666", "0.5255959", "0.5255405", "0.5255019", "0.5251257", "0.52478105", "0.52395225", "0.52337813", "0.5231713", "0.5231196", "0.52293295", "0.52233404", "0.5222418", "0.521978", "0.5218885", "0.52152723", "0.5211971", "0.52073526", "0.5206321", "0.52027434" ]
0.84877676
0