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
Set the headers for HttpClient
def headers=(headers) @headers = headers.merge({"User-Agent" => user_agent}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_header(auth_headers)\n header 'access-token', auth_headers['access-token']\n header 'token-type', auth_headers['token-type']\n header 'client', auth_headers['client']\n header 'expiry', auth_headers['expiry']\n header 'uid', auth_headers['uid']\nend", "def setHeaders(headers)\n @headers = headers\n end", "def set_headers # :nodoc:\n {\n 'User-Agent' => \"twm-ruby-#{VERSION}\",\n 'Content-Type' => 'application/json; charset=utf-8',\n 'Accept' => 'application/json'\n }\n end", "def set_request_headers!(request); end", "def headers= headers\n @headers = headers\n headers.each do |attr, value|\n `#@native.setRequestHeader(attr, value)`\n end\n end", "def set_headers(items)\n @headers = items.map { |item|\n item.gsub(/ /, '_')\n }\n end", "def headers(headers)\n @headers = headers\n end", "def add_auth_headers\n @client.headers['Auth-Email'] = '...'\n @client.headers['Auth-Token'] = '...'\n end", "def perform\n add_request_if_new do |request|\n request.header_set(*arguments)\n end\n end", "def headers\n super\n @headers['User-Agent'] = \"Recurly Ruby Client v#{VERSION}\"\n @headers\n end", "def make_headers(user_headers); end", "def upd_header(headers)\n hdr={'Content-Type' =>'application/json'}\n if(headers!=nil)\n headers['Content-Type']='application/json'\n hdr=headers\n end\n hdr\n end", "def add_headers; end", "def headers\n @headers ||= {\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer #{@token}\",\n }\n end", "def auth_headers(headers = {})\n h = headers.dup\n h['X-Tableau-Auth'] = @client.auth.token\n h\n end", "def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"User-Agent\"] = \"CloudServers Ruby API #{VERSION}\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers.merge(headers)\n end", "def headers=(headers)\n @headers = headers if headers.kind_of? Hash\n end", "def initialize_http_header(initheader)\n super\n set_headers_for_body\n end", "def headers=(hash)\n if headers\n headers.replace hash\n else\n super\n end\n end", "def set_header key, value\n headers.update(key => value)\n end", "def set_sasc_request_headers(api_version = nil)\n sasc_request_headers(api_version).each { |header, value| request.headers[header] = value }\n end", "def headers=(headers={})\n @headers = headers.merge(\n \"x-amz-date\" => request_timestamp\n )\n end", "def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers[\"Content-Type\"] = \"application/json\"\n default_headers.merge(headers)\n end", "def set_meta_headers(headers)\n @logger.info \"Setting #{headers.keys.join(', ')} for tenant #{@fog_options[:hp_tenant_id]}...\"\n response = @connection.request({\n :method => 'POST',\n :headers => headers\n })\n\n # Confirm meta data changes\n response = @connection.request({\n :method => 'HEAD'\n })\n\n @logger.info \"Done setting account meta key.\"\n end", "def request_headers= request_headers\n @agent.request_headers = request_headers\n end", "def request_headers=(request_headers); end", "def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"User-Agent\"] = \"OpenStack::Compute Ruby API #{VERSION}\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers.merge(headers)\n end", "def headers=(hash); end", "def headers=(hash); end", "def headers(headers = nil)\n @headers.assign(headers) if headers\n @headers\n end", "def headers=(hash)\n @headers.replace hash\n end", "def make_request_headers(opts); end", "def headers(new_headers = {})\n (@headers ||= {}).merge!(new_headers)\n end", "def request_headers\n headers = {'Content-Type' => 'application/json'}\n headers[:user_agent] = @client.user_agent\n headers[:authorization] = auth_header\n headers\n end", "def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers[\"Content-Type\"] = \"application/json\"\n default_headers[\"User-Agent\"] = \"Cloud Databases Ruby API #{CloudDB::VERSION}\"\n default_headers.merge(headers)\n end", "def headers\n headers = {}\n headers[:accept] = '*/*'\n headers[:content_type] = 'Application/json;charset=UTF-8'\n headers[:Authorization] = encode_credentials\n headers\n end", "def add_headers(headers)\n @headers = @headers.merge(headers)\n end", "def set_wiremock_headers(headers)\n @wiremock_headers = headers\n end", "def fill_header(response); end", "def headers\n @headers ||= HeaderHash.new(@http_response.to_hash)\n end", "def headers=(v)\n check_headers(v)\n set_headers(v)\n v\n end", "def set_header_insert(opts)\n opts = check_params(opts,[:headers])\n super(opts)\n end", "def set_header name, value\n response_object.header name, value\n end", "def set_response_headers(headers)\n new(\n response_headers: ConnSupport::Headers.normalize(headers)\n )\n end", "def headers\n {\n 'Host' => host,\n 'Content-Type' => 'application/json',\n api_key => settings.api_key\n }\n end", "def headers=(new_headers)\n @_response ||= ActionDispatch::Response.new\n @_response.headers.replace(new_headers)\n end", "def headers=(v)\n cfg_set(:headers, v)\n end", "def add_http_header(key, value)\n @http_headers[key] = value\n end", "def headers\n {\n 'Authorization' => \"key=#{@server_key}\",\n 'Content-Type' => 'application/json'\n }\n end", "def update_headers(request_headers)\n @request_headers.merge!(request_headers)\n end", "def request_headers=(_arg0); end", "def get_headers\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/headers'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the response\n _response = @http_client.execute_as_string(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n end", "def headers=(v)\n cfg_set(:headers, v)\n end", "def headers(headers); end", "def header=(header = {})\n @header = { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }.merge(header)\n end", "def header=(header = {})\n @header = { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }.merge(header)\n end", "def post_headers(response=nil)\n hdrs = {\"Content-Type\" => 'application/json',\n \"Accept\" => \"application/json, text/javascript, */*; q=0.01\"}\n @headers.merge!(hdrs)\n end", "def add_headers\n @headers.each do |field, value|\n @request_header << \"#{field}: #{value}\"\n end\n end", "def set_header_options(curl)\n summary = summary_for_feed\n \n unless summary.nil?\n curl.headers['If-None-Match'] = summary[:etag] unless summary[:etag].nil?\n curl.headers['If-Modified-Since'] = summary[:last_modified] unless summary[:last_modified].nil?\n end\n \n curl\n end", "def set_header(name, value)\n @headers[name] = value\n \n return self\n end", "def set_headers(v)\n @headers = []\n if v\n v.split('&').each do |x|\n @headers << x.split(/=/, 2)\n end\n end\n end", "def headers_with_auth(token)\n return @headers unless token\n\n headers = @headers\n headers[\"Authorization\"] = \"Bearer #{token}\"\n headers\n end", "def set_headers! session = nil\n response.headers['sid'] = session.id\n response.headers['utoken'] = session.utoken\n end", "def default_headers(arg=nil)\n set_headers\n end", "def headers(hash = {})\n hash.each_pair do |k,v|\n @header[k] = v\n end\n end", "def headers(hash=nil)\n @headers = hash unless hash.nil?\n @headers ||= {}\n end", "def http_headers\n {\n 'Content-Type' => 'application/json',\n 'Accept' => 'application/json',\n 'User-Agent' => \"resque-exceptional/#{Version}\"\n }\n end", "def headers\n hash = {}\n hash['Content-Type'] = 'application/json'\n hash['Authorization'] = \"ShacipKey #{api_key}\" unless api_key.nil?\n hash\n end", "def header_set(name, value)\n return dup_without_response.header_set(name, value) if response\n\n name = name.to_s\n if value.nil?\n @headers.delete name\n return self\n end\n\n @headers[name] = value.to_s\n self\n end", "def set_extra_headers_for(params)\n maor_headers = {\n 'x-tmrk-version' => @version,\n 'Date' => Time.now.utc.strftime(\"%a, %d %b %Y %H:%M:%S GMT\"),\n }\n params[:headers].merge!(maor_headers)\n if params[:method]==\"POST\" || params[:method]==\"PUT\"\n params[:headers].merge!({\"Content-Type\" => 'application/xml'})\n params[:headers].merge!({\"Accept\" => 'application/xml'})\n end\n unless params[:body].empty?\n params[:headers].merge!({\"x-tmrk-contenthash\" => \"Sha256 #{Base64.encode64(Digest::SHA2.digest(params[:body].to_s)).chomp}\"})\n end\n if @authentication_method == :basic_auth\n params[:headers].merge!({'Authorization' => \"Basic #{Base64.encode64(@username+\":\"+@password).delete(\"\\r\\n\")}\"})\n elsif @authentication_method == :cloud_api_auth\n signature = cloud_api_signature(params)\n params[:headers].merge!({\n \"x-tmrk-authorization\" => %{CloudApi AccessKey=\"#{@access_key}\" SignatureType=\"HmacSha256\" Signature=\"#{signature}\"}\n })\n end\n params[:headers]\n end", "def headers\n {\n \"Authorization\" => basic_auth,\n \"Content-Type\" => \"application/json\",\n \"Accept\" => \"application/json\"\n }\n end", "def headers\n @headers.merge({ \"Status\" => @status })\n end", "def add_generic_headers(http_method, uri, request_headers, context = nil)\n request_headers.concat(@session.meta_data_provider.meta_data_headers)\n request_headers.push(RequestHeader.new('Date', get_header_date_string))\n if !context.nil? && !context.idempotence_key.nil?\n request_headers.push(RequestHeader.new('X-GCS-Idempotence-Key', context.idempotence_key))\n end\n authenticator = @session.authenticator\n authentication_signature = authenticator.create_simple_authentication_signature(http_method, uri, request_headers)\n request_headers.push(RequestHeader.new('Authorization', authentication_signature))\n end", "def default_headers(current_time)\n {}.tap do |def_headers|\n def_headers['User-Agent'] = Azure::Core::Default::USER_AGENT\n def_headers['x-ms-date'] = current_time\n def_headers['x-ms-version'] = '2014-02-14'\n def_headers['DataServiceVersion'] = '1.0;NetFx'\n def_headers['MaxDataServiceVersion'] = '3.0;NetFx'\n def_headers['Content-Type'] = 'application/atom+xml; charset=utf-8'\n end\n end", "def headers\n call_once\n @headers\n end", "def headers\r\n # give access to helpers to opts with a different name\r\n @opts\r\n end", "def headers\n @headers ||= self.class.beautify_headers(@net_http_res.to_hash)\n end", "def headers\n {'Authorization' => options[:header_format] % token}\n end", "def set_header(token)\n response.headers['Authorization'] = \"Bearer #{token.to_jwt}\"\n end", "def header(hash)\n self._headers.merge!(hash)\n end", "def add_headers(opts = {})\n unless opts[:headers].nil?\n opts[:headers].each do |opt, value|\n @headers[opt.to_s] = value\n end\n opts.delete(:headers)\n end\n end", "def header(hash = {})\n @headers.merge!(hash)\n end", "def headers\n { 'X-Auth-Token' => self.api_key }\n end", "def headers hash=nil\n @response.headers.merge! hash if hash\n @response.headers\n end", "def initialize\n @headers = {\"User-Agent\" => \"cookies\"}\n end", "def headers\n @headers ||= {}\n end", "def headers=(new_headers)\n if !new_headers.kind_of?(Hash)\n raise ArgumentError, \"Headers must be a hash\"\n end\n\n @headers = new_headers\n end", "def http2_upgraded_headers(headers)\n headers.merge(\n ':scheme' => 'http',\n ':authority' => headers['host']\n )\n end", "def set_headers(soap, args, extra_namespaces)\n @headerhandler.each do |handler|\n handler.prepare_request(@client.http, soap, args)\n end\n soap.namespaces.merge!(extra_namespaces) unless extra_namespaces.nil?\n end", "def headers\n @headers ||= {}\n end", "def headers\n headers = {}\n headers['Content-Type'] = 'application/x-www-form-urlencoded'\n headers['X-SILENCE-LOGGER'] = 'true'\n headers['Dont-Chunk'] = 'true' unless self.class.long_polling\n\n headers\n end", "def add_request_headers(request)\n ChefAPI::Log.info \"Adding request headers...\"\n\n headers = {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Connection\" => \"keep-alive\",\n \"Keep-Alive\" => \"30\",\n \"User-Agent\" => user_agent,\n \"X-Chef-Version\" => \"11.4.0\",\n }\n\n headers.each do |key, value|\n ChefAPI::Log.debug \"#{key}: #{value}\"\n request[key] = value\n end\n end", "def []=(k, v) @headers[translate_header_to_sym(k)] = v end", "def headers\r\nHttp::Headers.new(@env)\r\nend", "def _initialize_headers\n {}\n end", "def request_headers; end", "def request_headers; end", "def dynamic_headers\n {\n 'Authorization' => token,\n 'RequestID' => request_id,\n }\n end", "def headers\n [\n { :key => \"User-Agent\", :value => user_agent},\n { :key => \"Content-Type\", :value => \"application/json; charset=utf-8\" },\n { :key => \"Accept\", :value => \"application/json\"}\n ]\n end", "def headers\n @headers ||={}\n end" ]
[ "0.75865567", "0.7334449", "0.72294927", "0.7218453", "0.7147003", "0.70689005", "0.7018355", "0.6965115", "0.6958192", "0.6953768", "0.69357526", "0.69284195", "0.6884861", "0.686171", "0.68590105", "0.68501484", "0.6840429", "0.6838375", "0.6838244", "0.6821156", "0.681721", "0.67921513", "0.67881817", "0.67677087", "0.6757256", "0.6748302", "0.6737667", "0.6730959", "0.6730959", "0.67138386", "0.66781574", "0.667377", "0.6671107", "0.6660958", "0.6653419", "0.66291696", "0.6608028", "0.66073847", "0.6598842", "0.6568228", "0.6557043", "0.65524495", "0.65519565", "0.6531181", "0.65304136", "0.65271395", "0.65197825", "0.6513469", "0.6511776", "0.65006936", "0.648921", "0.6477574", "0.6464044", "0.64573944", "0.6429643", "0.6429409", "0.6413878", "0.64064914", "0.640491", "0.6387436", "0.6365017", "0.634352", "0.63387513", "0.63219666", "0.6320575", "0.6320413", "0.63194895", "0.6318508", "0.6317391", "0.6310921", "0.6299728", "0.6296256", "0.6294652", "0.6291095", "0.6288231", "0.62871784", "0.62831765", "0.6273149", "0.6271417", "0.62699556", "0.6268942", "0.62624466", "0.6256306", "0.62546104", "0.62471896", "0.62433547", "0.6235702", "0.62344843", "0.6228092", "0.6227019", "0.62259895", "0.62240595", "0.62106174", "0.62092716", "0.6206439", "0.62031376", "0.62031376", "0.62011623", "0.6200262", "0.61729527" ]
0.7058182
6
Set the user agent for HttpClient
def user_agent=(name) @user_agent = USER_AGENT[name] || USER_AGENT['bot'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def useragent=(value)\n Curl.set_option(:useragent, value_for(value, :string), handle)\n end", "def user_agent= user_agent\n @agent.user_agent = user_agent\n end", "def user_agent=(user_agent); end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent(agent)\n headers.update 'User-Agent' => agent\n end", "def user_agent(user_agent)\n @user_agent = user_agent\n end", "def user_agent=(user_agent)\n @request_headers['User-Agent'] = user_agent\n @request = Net::HTTP::Get.new(@uri.request_uri, @request_headers)\n end", "def user_agent= new_ua\n @headers['User-Agent'] =\n new_ua && Kronk.config[:user_agents][new_ua.to_s] ||\n new_ua || Kronk::DEFAULT_USER_AGENT\n end", "def user_agent= new_ua\n @headers['User-Agent'] =\n new_ua && Kronk.config[:user_agents][new_ua.to_s] ||\n new_ua || Kronk::DEFAULT_USER_AGENT\n end", "def user_agent=(user_agent)\n @attributes[\"user_agent\"] = user_agent\n end", "def init_user_agent(options)\n @headers ||= {}\n @headers['User-Agent'] = options[:user_agent] || default_user_agent\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def user_agent\n @user_agent || USER_AGENT\n end", "def user_agent\n @user_agent || USER_AGENT\n end", "def set_user_agent_override(user_agent:, accept_language: nil, platform: nil)\n {\n method: \"Emulation.setUserAgentOverride\",\n params: { userAgent: user_agent, acceptLanguage: accept_language, platform: platform }.compact\n }\n end", "def user_agent_alias= name\n self.user_agent = AGENT_ALIASES[name] ||\n raise(ArgumentError, \"unknown agent alias #{name.inspect}\")\n end", "def headers=(headers)\n @headers = headers.merge({\"User-Agent\" => user_agent})\n end", "def set_client(user_agent_string)\n user_agent = AgentOrange::UserAgent.new(user_agent_string)\n device = user_agent.device\n if device.is_mobile?\n self.client = device.platform\n self.version = device.platform.version\n else device.is_computer?\n self.client = device.engine.browser.name\n self.version = device.engine.browser.version\n end\n end", "def user_agent\n headers[\"HTTP_USER_AGENT\"] || headers[\"USER-AGENT\"]\n end", "def user_agent; end", "def user_agent; end", "def user_agent; end", "def user_agent\n @headers['User-Agent']\n end", "def user_agent\n @headers['User-Agent']\n end", "def user_agent\n @headers['User-Agent']\n end", "def user_agent_alias=(name); end", "def user_agent\n ENV[\"CHEF_API_USER_AGENT\"] || config[\"CHEF_API_USER_AGENT\"] || USER_AGENT\n end", "def default_user_agent\n \"#{NAME}/#{VERSION} (Ruby/#{RUBY_VERSION})\"\n end", "def user_agent(value)\n value || DEFAULT_USER_AGENT\n end", "def agent\n @agent ||= Sawyer::Agent.new('', sawyer_options) do |http|\n http.headers[:user_agent] = user_agent\n end\n end", "def use_agent=(use_agent); end", "def user_agent\n @request['User-Agent']\n end", "def get_user_agent\n user_agent\n end", "def user_agent\n @options[:user_agent] || \"Ruby Twitter Gem\"\n end", "def http_user_agent\n # User agent is required for cookie validation\n request.env['HTTP_USER_AGENT'].to_s\n end", "def user_agent\n @agent.user_agent\n end", "def default_header\n {\n \"User-Agent\" => user_agent\n }\n end", "def agent\n @agent ||= Mechanize.new do |agent|\n agent.user_agent_alias = 'Mac Safari'\n end\n end", "def ua\n @ua ||= begin\n request.env['HTTP_USER_AGENT'].downcase\n rescue\n ''\n end\n end", "def user_agent\n @data[\"user_agent\"]\n end", "def setUseMobileUserAgent(value)\n @fields['use_mobile_user_agent'] = value\n self\n end", "def setUseMobileUserAgent(value)\n @fields['use_mobile_user_agent'] = value\n self\n end", "def initialize\n @agent = Mechanize.new\n @agent.set_defaults if @agent.respond_to?(:set_defaults)\n @agent.user_agent = @@user_agent ||= \"bahn.rb\"\n end", "def user_agent\n self.class.user_agent ||= USER_AGENTS.shuffle.first\n end", "def initialize\n @agent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }\n end", "def user_agent (value = nil)\n\t\tif value\n\t\t\traise_if_error C.glyr_opt_useragent(to_native, value)\n\t\telse\n\t\t\tto_native[:useragent]\n\t\tend\n\tend", "def set_defaults\n default_user_agent = Config.user_agent || Typhoeus::USER_AGENT\n\n options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})\n options[:headers]['Expect'] ||= ''\n options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil?\n options[:maxredirs] ||= 50\n options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil?\n end", "def get_agent\n\t\tagent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }\n\tend", "def user_agent\n [\n \"#{config.application_name}/#{config.application_version}\",\n \"google-api-ruby-client/#{Google::APIClient::VERSION::STRING}\",\n Google::APIClient::ENV::OS_VERSION,\n '(gzip)'\n ].join(' ').delete(\"\\n\")\n end", "def initialize(user_agent_string)\n @user_agent = user_agent_string\n end", "def user_agent(vendor: T.unsafe(nil)); end", "def headers\n super\n @headers['User-Agent'] = \"Recurly Ruby Client v#{VERSION}\"\n @headers\n end", "def getUserAgent()\n\t\t\tUSER_AGENT\n\t\tend", "def user_agent_on_header\n request.headers['HTTP_USER_AGENT']\n end", "def user_agent\n # This particular string is required by the Discord devs.\n required = \"DiscordBot (https://github.com/meew0/discordrb, v#{Discordrb::VERSION})\"\n @bot_name ||= ''\n\n \"rest-client/#{RestClient::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} discordrb/#{Discordrb::VERSION} #{required} #{@bot_name}\"\n end", "def user_agent\n # This particular string is required by the Discord devs.\n required = \"DiscordBot (https://github.com/meew0/discordrb, v#{Discordrb::VERSION})\"\n @bot_name ||= ''\n\n \"rest-client/#{RestClient::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} discordrb/#{Discordrb::VERSION} #{required} #{@bot_name}\"\n end", "def initialize\n @headers = {\"User-Agent\" => \"cookies\"}\n end", "def initialize(opts={})\n name = opts[:user_agent] || DEFAULT_USER_AGENT\n @client = opts[:client] || HTTPClient.new( :agent_name => name )\n @apikey = opts[:apikey] || nil \n @opts = opts\n end", "def user_agent\n \"SocketLabs-ruby/#{VERSION};ruby(#{RUBY_VERSION})\"\n end", "def init_agent\r\n agent = Mechanize.new{|a| a.history.max_size = 10}\r\n agent.user_agent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'\r\n agent.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n agent\r\nend", "def initialize(agent_alias)\n @agent = Mechanize.new\n @agent.user_agent_alias = agent_alias\n\n end", "def bot_user_agent(vendor: T.unsafe(nil)); end", "def initialize\n super\n @user_agent_alias = 'Mac Safari'\n @follow_meta_refresh = true\n @redirect_ok = true\n end", "def headers\n { 'User-Agent' => user_agent }\n end", "def some_user_agent\n \"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090920 Firefox/3.5.3 (Swiftfox)\"\n end", "def user_agent(string)\n string = string.to_s\n return nil if string.empty?\n UserAgent.new(string)\n end", "def initialize(user_agent)\n self.class.headers 'User-Agent' =>\n \"#{user_agent} CWSrb/#{Cwsrb::VERSION} (#{RUBY_ENGINE}/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL})\"\n end", "def agent\n @agent ||= Sawyer::Agent.new(endpoint, sawyer_options) do |http|\n http.headers[:accept] = default_media_type\n http.headers[:content_type] = \"application/json\"\n http.headers[:user_agent] = user_agent\n end\n end", "def agent\n anonymous? ? nil : user.agent\n end", "def generate_user_agent(extra_ids = [])\n agent_app = @config.read('authentication.user_agent')\n extra_ids << ['AwApi-Ruby/%s' % BingAdsApi::ApiConfig::CLIENT_LIB_VERSION]\n super(extra_ids, agent_app)\n end", "def connection_options\n {\n headers: {\n user_agent: user_agent\n }\n }\n end", "def set_headers # :nodoc:\n {\n 'User-Agent' => \"twm-ruby-#{VERSION}\",\n 'Content-Type' => 'application/json; charset=utf-8',\n 'Accept' => 'application/json'\n }\n end", "def default_headers\n {\n \"User-Agent\" => ProxyFetcher.config.user_agent\n }\n end", "def default_headers\n {\n 'User-Agent' => ProxyFetcher.config.user_agent\n }\n end", "def user_agent\n @request[FUA]\n end", "def mech\n @mech ||= Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }\n end", "def headers\n {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}\n end", "def append_user_agent_to_params\n params[:browser_user_agent] = http_user_agent\n end", "def connection_options\n {\n :headers => {\n :user_agent => user_agent\n }\n }\n end", "def connection_options\n {\n :headers => {\n :user_agent => user_agent\n }\n }\n end", "def create_agent\n self.agent = WWW::Mechanize.new\n agent.user_agent = \"Mozilla/4.0 (compatible; Blackbook #{Blackbook::VERSION})\"\n agent.keep_alive = false\n agent\n end", "def user_agent\n kernel = Facter[:kernel] ? Facter[:kernel].value : 'unknown'\n kvers = Facter[:kernelversion] ? Facter[:kernelversion].value : 'unknown'\n values = {\n 'razor' => MK::VERSION,\n 'facter' => Facter.version, # sigh\n 'ruby' => RUBY_VERSION,\n 'kernel' => \"#{kernel}-#{kvers}\"\n }.reject{|k,v| v.nil?}.map{|k,v| k+'/'+v}.join(' ')\n end", "def user_agent\n \"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3\"\n end", "def generate_user_agent(extra_ids = [])\n agent_app = @config.read('authentication.user_agent')\n extra_ids << ['AwApi-Ruby/%s' % YahooAdApi::ApiConfig::CLIENT_LIB_VERSION]\n super(extra_ids, agent_app)\n end", "def browser\n Browser.new(user_agent)\n end" ]
[ "0.79014856", "0.7727958", "0.76766497", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7675428", "0.7675428", "0.7675428", "0.7675428", "0.7675428", "0.7588549", "0.75546414", "0.7493754", "0.71817666", "0.71817666", "0.7096832", "0.7053156", "0.68910795", "0.68910795", "0.68910795", "0.68910795", "0.68910795", "0.6801018", "0.6801018", "0.67736816", "0.67686737", "0.6754116", "0.67008066", "0.6696156", "0.6677107", "0.6677107", "0.6677107", "0.6570355", "0.6570355", "0.6570355", "0.6558965", "0.6553029", "0.65333146", "0.6529893", "0.65135366", "0.6482519", "0.6456743", "0.6456384", "0.6430904", "0.6417535", "0.64034486", "0.6382068", "0.6372054", "0.6337506", "0.63152546", "0.6289618", "0.6289618", "0.62794566", "0.62593126", "0.6220713", "0.62130183", "0.62112904", "0.61861825", "0.6154749", "0.615324", "0.6129404", "0.6114967", "0.61054564", "0.61001474", "0.60941887", "0.60941887", "0.60510415", "0.6037951", "0.603491", "0.59798825", "0.59706026", "0.5939029", "0.59192955", "0.59084475", "0.59009296", "0.58953726", "0.5891547", "0.5863757", "0.5862515", "0.58532035", "0.5846791", "0.5838877", "0.5822036", "0.5816895", "0.57979256", "0.57908845", "0.57684106", "0.57537377", "0.57501477", "0.57501477", "0.57481027", "0.57184684", "0.5710877", "0.570494", "0.5691582" ]
0.7180948
20
The Faraday connection object
def connection @connection ||= begin conn = Faraday.new(url: url) conn.build do |b| conn_build.call(b) end if conn_build conn end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connection\n @connection ||= faraday(config, logger)\n end", "def connection\n @connection ||= Faraday.new(self.api_url, { ssl: { verify: false } })\n end", "def connection\n @connection ||= Faraday.new(endpoint, connection_options)\n end", "def connection\n @connection ||= Faraday.new(ENDPOINT, connection_options)\n end", "def connection\n @connection ||= Faraday.new(ENDPOINT, connection_options)\n end", "def connection\n @connection ||= Faraday.new(request: { timeout: ForecastIO.timeout })\n end", "def connection\n Faraday.new(:url => host) do |faraday|\n #faraday.response :logger # log requests to STDOUT\n faraday.response :xml, :content_type => /\\bxml$/\n faraday.adapter Faraday.default_adapter # make requests with Net::HTTP\n end\n end", "def connection\n @connection ||= Faraday.new(@endpoint, @connection_options, &@middleware)\n end", "def connection\n @connection ||= begin\n conn = Faraday.new(:url => @url) do |b|\n b.use Faraday::Request::UrlEncoded # convert request params as \"www-form-urlencoded\"\n b.use Faraday::Request::JSON # encode request params as json\n b.use Faraday::Response::Logger # log the request to STDOUT\n b.use Faraday::Adapter::NetHttp # make http requests with Net::HTTP \n end\n conn\n end\n end", "def connection\n @connection = begin\n connection_options = {:builder => @middleware}\n connection_options[:ssl] = {:verify => true} if @endpoint[0..4] == 'https'\n connection_options[:proxy] = @proxy if @proxy\n Faraday.new(@endpoint, @connection_options.merge(connection_options))\n end\n end", "def connection\n @connection ||= Faraday.new(url: base_url, headers: default_headers, ssl: {verify: false}) do |builder|\n builder.use Faraday::Request::UrlEncoded\n builder.use Faraday::Response::Mashify\n builder.use Faraday::Response::ParseJson\n builder.adapter Faraday.default_adapter\n end\n end", "def connection\n @connection ||= Faraday.new(@endpoint, @connection_options.merge(:builder => @middleware))\n end", "def connection\n @connection ||= Faraday.new(@endpoint, @connection_options.merge(:builder => @middleware))\n end", "def connection\n @connection ||= Faraday.new(@endpoint, @connection_options.merge(:builder => @middleware))\n end", "def connection\n @connection ||= Faraday.new(@endpoint, @connection_options.merge(:builder => @middleware))\n end", "def connection\n @connection ||= Faraday.new(@server_uri, :ssl => {:verify => false}) do |builder|\n builder.request :url_encoded # Encode request parameters as \"www-form-urlencoded\"\n builder.response :logger # Log request and response to STDOUT\n builder.adapter :net_http # Perform requests with Net::HTTP\n end\n end", "def connection\n Faraday.new(api_url, ssl: { verify: true }) do |conn|\n conn.adapter Faraday.default_adapter\n end\n end", "def connection\n self.faraday_connection ||= Faraday.new(configuration.faraday_options) do |f|\n if configuration.authenticated?\n f.request :authorization, :basic, configuration.username, configuration.password\n end\n f.request :multipart\n f.request :url_encoded\n unless options[:raw]\n f.response :mashify\n f.response :json\n end\n\n f.response :raise_error\n f.adapter configuration.adapter\n end\n end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n\n faraday.request :multipart\n faraday.request :json\n\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def conn\n Faraday.new(:url => @config.url) do |c|\n c.adapter Faraday.default_adapter\n c.headers['User-Agent'] = @config.usr_agent\n c.params = self.options\n end\n end", "def connection\n @connection ||= Faraday.new(url: PriceHubble.configuration.base_url,\n &method(:configure))\n end", "def connection\n @connection ||= Faraday.new(base_url) do |builder|\n build_middleware(builder)\n builder.adapter Faraday.default_adapter\n end\n end", "def connection\n @connection ||= begin\n Faraday.new(:url => \"http://#{configuration.server}:#{configuration.port}\", &connection_block)\n end\n end", "def connection\n # @connection ||= Faraday.new connection_options do |conn|\n @faraday_connection ||= Faraday.new(:url => @url) do |conn|\n # Follow redirects\n # conn.use FaradayMiddleware::FollowRedirects, limit: 5\n conn.response :logger # log requests to STDOUT\n # Convert request params to \"www-form-encoded\"\n conn.request :url_encoded\n # Parse responses as JSON\n # conn.use FaradayMiddleware::ParseJson, content_type: 'application/json'\n # Use Faraday's default HTTP adapter\n conn.adapter Faraday.default_adapter\n #pass api_key and api_username on every request\n # conn.params['api_key'] = api_key\n # conn.params['api_username'] = api_username\n end\n return @faraday_connection\n end", "def conn\n @conn ||= Faraday.new(base_url, headers: @headers, ssl: ssl_options, request: timeout) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n faraday.use EVSS::ErrorMiddleware\n faraday.response :betamocks if @use_mock\n faraday.response :snakecase, symbolize: false\n faraday.response :json_parser\n faraday.use :remove_cookies\n faraday.adapter :httpclient\n end\n end", "def faraday_connection(url=nil)\n url ||= self.root\n key = \"faraday_connection_#{url}\"\n return Thread.current[key] if Thread.current[key]\n\n fc = Faraday.new(:url => url)\n fc.headers.merge!('User-Agent' => \"HyperResource #{HyperResource::VERSION}\")\n fc.headers.merge!(self.headers || {})\n if ba=self.auth[:basic]\n fc.basic_auth(*ba)\n end\n Thread.current[key] = fc\n end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n faraday.request :json\n\n faraday.response :betamocks if use_mocks?\n faraday.response :snakecase, symbolize: false\n faraday.response :json, content_type: /\\bjson/\n\n faraday.adapter Faraday.default_adapter\n end\n end", "def faraday\n @faraday ||= Faraday.new ssl: { verify: ssl_verify } do |faraday|\n authenticate!(faraday)\n\n faraday.request(:retry, max: retries) if retries\n faraday.options.timeout = read_timeout if read_timeout\n faraday.options.open_timeout = open_timeout if open_timeout\n\n faraday.request :url_encoded # Form-encode POST params\n faraday.response :raise_error\n faraday.use :http_cache, store: http_cache, serializer: Marshal\n faraday.use Faraday::CacheHeaders\n faraday.response :json, content_type: /\\bjson$/\n faraday.adapter :excon\n end\n end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n\n faraday.request :multipart\n faraday.request :json\n\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n\n faraday.request :multipart\n faraday.request :json\n\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def connection\n @connection ||= begin\n connection_options = {:builder => @middleware}\n connection_options[:ssl] = {:verify => true} if @endpoint[0..4] == 'https'\n Faraday.new(@endpoint, @connection_options.merge(connection_options))\n end\n end", "def connection\n Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.request :json\n\n faraday.response :raise_error, error_prefix: service_name\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def connection\n Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.request :json\n\n faraday.response :raise_error, error_prefix: service_name\n faraday.response :caseflow_errors\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def connection\n @connection ||= begin\n conn = Faraday.new(site, options[:connection_opts])\n conn.build do |b|\n options[:connection_build].call(b)\n end if options[:connection_build]\n conn\n end\n end", "def connection\n @conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|\n faraday.use :breakers\n faraday.use Faraday::Response::RaiseError\n\n faraday.response :betamocks if mock_enabled?\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end", "def connection\n @connection ||= begin\n connection_options = { builder: @middleware }\n connection_options[:ssl] = { verify: true } if @endpoint[0..4] == 'https'\n Faraday.new(@endpoint, @connection_options.merge(connection_options))\n end\n end", "def connection\n @connection ||= Faraday.new(faraday_options) do |builder|\n builder.use Faraday::Request::UrlEncoded\n # builder.use QuickbooksOnlineRuby::Middleware::Mashify, nil, @options\n builder.response :json\n\n if QuickbooksOnlineRuby.log?\n builder.use QuickbooksOnlineRuby::Middleware::Logger,\n QuickbooksOnlineRuby.configuration.logger,\n @options\n end\n\n builder.adapter @options[:adapter]\n end\n end", "def connection\n @connection ||= Faraday.new @url do |c|\n c.headers[\"X-Api-Token\"] = @token\n c.use FaradayMiddleware::ParseJson, content_type: \"application/json\"\n #c.use Faraday::Response::Logger, Logger.new(\"tmp/faraday.log\")\n c.use FaradayMiddleware::FollowRedirects, limit: 3\n c.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses\n c.use Faraday::Adapter::NetHttp\n end\n end", "def connection\n Faraday.new(url: self.configuration.base_url) do |f|\n f.response :xml, :content_type => /\\bxml$/\n f.adapter :net_http\n f.basic_auth self.configuration.username, self.configuration.password\n end\n end", "def conn\n @conn ||= Faraday.new(:url => uri.to_s) do |builder|\n builder.adapter self.class.adapter\n end\n end", "def connection\n @connection ||= Faraday.new(url: api_endpoint) do |faraday|\n faraday.use Faraday::Request::UrlEncoded\n faraday.use Redd::Response::RaiseError\n faraday.use Redd::Response::ParseJson\n faraday.adapter Faraday.default_adapter\n\n faraday.headers = headers\n end\n end", "def faraday\n mutex.synchronize do\n @faraday ||= create_faraday\n end\n end", "def connection\n @connect ||= Faraday.new do |f|\n f.adapter :net_http\n f.headers = connection_headers\n f.url_prefix = \"#{default_url_prefix}/api/v#{api_version}/\"\n f.response :json, content_type: /\\bjson$/\n end\n end", "def connection\n @connection ||= begin\n connection_options = {:builder => @middleware}\n Faraday.new(@endpoint, @connection_options.merge(connection_options))\n end\n end", "def endpoint_connection\n @endpoint_connection ||= Faraday.new(url: endpoint_url) do |faraday|\n faraday.adapter :net_http\n end\n end", "def connection\n Faraday.new(url:, headers:) do |conn|\n conn.request :json\n conn.use :breakers\n conn.use Faraday::Response::RaiseError\n conn.response :raise_error, error_prefix: service_name\n conn.response :json\n conn.response :betamocks if mock_enabled?\n conn.adapter Faraday.default_adapter\n end\n end", "def connection\n Faraday.new(base_path, headers: base_request_headers, request: request_options, ssl: ssl_options) do |conn|\n conn.use :breakers\n conn.request :soap_headers\n\n conn.response :soap_parser\n conn.response :betamocks if Settings.emis.mock\n conn.adapter Faraday.default_adapter\n end\n end", "def connection\n @connection ||= Faraday.new(url: Leo.route_base) do |faraday|\n faraday.options.timeout = Leo.read_timeout\n faraday.options.open_timeout = Leo.open_timeout\n faraday.use Faraday::Response::RaiseError\n faraday.request :url_encoded\n faraday.adapter Faraday.default_adapter\n end\n end", "def connection\n Faraday.new(url: url) do |conn|\n conn.use :breakers\n conn.response :check_in_errors\n conn.use :check_in_logging\n conn.response :raise_error, error_prefix: service_name\n conn.adapter Faraday.default_adapter\n end\n end", "def connection\n return unless @url\n\n @connection ||= Faraday::Connection.new(@url) do |b|\n middleware.each { |m, opts| b.use(m, opts) }\n b.request :url_encoded\n b.adapter :net_http\n end\n \n @connection.basic_auth(*@basic_auth) if @basic_auth\n @connection.token_auth(*@token_auth) if @token_auth\n @connection.authorization(*@authorization) if @authorization\n @connection\n end", "def build_connection\n connection = Faraday.new(url: base_url)\n connection.adapter *connection_adapter\n end", "def connection\n params = {}\n @connection ||= Faraday::Connection.new(:url => api_url, :ssl => ssl, :params => params, :headers => default_headers) do |builder|\n @connection_middleware.each do |middleware|\n builder.use *middleware\n end\n builder.adapter Faraday.default_adapter\n end\n end", "def conn\n @conn ||= Faraday.new(url: authentication_uri.to_s) do |builder|\n builder.adapter Faraday.default_adapter\n end\n end", "def connection\n @connection ||= Faraday.new do |conn|\n conn.use Signature::Authentication, endpoint.secret\n\n yield conn if block_given?\n\n unless conn.builder.handlers.any? { |h| h.name.include? ':Adapter:' }\n conn.adapter Faraday.default_adapter\n end\n end\n end", "def faraday_connection(url = nil)\n url ||= URI.join(root, href)\n\n Faraday.new(faraday_options.merge(url: url)) do |builder|\n builder.headers.merge!(headers || {})\n builder.headers['User-Agent'] = Aptible::Resource.configuration\n .user_agent\n\n if (ba = auth[:basic])\n builder.basic_auth(*ba)\n end\n\n builder.request :url_encoded\n builder.request :retry\n builder.adapter Faraday.default_adapter\n end\n end", "def connection\n return unless @url\n\n @connection ||= Faraday::Connection.new(@url) do |b|\n b.request :url_encoded\n b.adapter :net_http\n end\n\n @connection.basic_auth(*@basic_auth) if @basic_auth\n @connection\n end", "def connection\n options = { url: api_url, ssl: { verify: false } }\n\n connection = Faraday.new(options) do |conn|\n conn.response :readmill_errors\n conn.response :mashify\n conn.response :json\n\n conn.adapter adapter\n end\n\n connection\n end", "def endpoint_connection\n @endpoint_connection ||= Faraday.new(url: endpoint_url) do |faraday|\n faraday.params = datasource_params\n faraday.adapter :net_http\n end\n end", "def endpoint_connection\n @endpoint_connection ||= Faraday.new(url: endpoint_url) do |faraday|\n faraday.params = datasource_params\n faraday.adapter :net_http\n end\n end", "def connection\n @connection ||= Faraday.new(\"#{URL_PREFIX}\", connection_options) do |conn|\n conn.basic_auth(api_key, nil)\n end\n end", "def endpoint_connection\n @endpoint_connection ||= Faraday.new(url: endpoint_url) do |faraday|\n faraday.request :basic_auth, user, password\n faraday.params = datasource_params\n faraday.adapter :net_http\n end\n end", "def create_connection\n\t\t@connection = Faraday.new(:url => @base_url) do |faraday|\n\t\t\tfaraday.headers['Accept'] = 'application/json'\n\t\t\tfaraday.adapter Faraday.default_adapter\n\t\tend\n\tend", "def endpoint_connection\n @conn ||= Faraday.new(url: ENDPOINT_URL) do |faraday|\n faraday.adapter :net_http\n end\n rsp = @conn.get do |request|\n request.params = data_params\n end\n end", "def __build_connection(host, options={}, block=nil)\n client = ::Faraday::Connection.new(__full_url(host), options, &block)\n Connections::Connection.new :host => host, :connection => client\n end", "def faraday_adapter\n Faraday.default_adapter\n end", "def client\n Faraday.new(url: URL) do |c|\n c.token_auth self.auth_token\n c.request :url_encoded # form-encode POST params\n c.adapter Faraday.default_adapter # Net::HTTP\n end\n end", "def connection(address)\n service_connection = Faraday.new(:url => \"#{address}\") do |faraday|\n faraday.request :url_encoded # form-encode POST params\n #faraday.response :logger # log requests to STDOUT\n faraday.adapter Faraday.default_adapter # make requests with Net::HTTP\n end\n return service_connection\nend", "def connection\n params = {}\n params[:oauth_token] = @access_token if @access_token\n @connection ||= Faraday.new(:url => api_url, :params => params, :headers => default_headers) do |builder|\n builder.use Faraday::Request::UrlEncoded\n builder.use Faraday::Response::Mashify\n builder.use Faraday::Response::ParseJson\n builder.adapter Faraday.default_adapter\n end\n end", "def connection(options = {})\n\n options = self.connection_options(options)\n \n if @connection_options != options\n @connection = nil\n @connection_options = options\n end\n\n @connection ||= Faraday.new(@connection_options.merge(:builder => self.stack))\n end", "def get_conn url\n return Faraday.new(:url => url, :ssl => @@ssl) do |faraday|\n faraday.adapter Faraday.default_adapter\n faraday.response :logger\n end\n end", "def connection\n @connection ||= Faraday.new(api_endpoint) do |http|\n http.headers[:accept] = \"application/json, */*\"\n http.headers[:user_agent] = user_agent\n\n http.request :authorization, :Bearer, -> { token_store.get_token }\n http.request :json\n\n http.use Keap::REST::Response::RaiseError\n\n http.response :dates\n http.response :json, content_type: \"application/json\"\n # http.response :logger do |logger|\n # logger.filter(/(Bearer) (\\w+)/, '\\1 [FILTERED]')\n # end\n\n http.adapter adapter, @stubs\n end\n end", "def connection(force_ssl = false)\n opts = {\n :headers => headers\n }\n domain = @endpoint \n if(force_ssl || self.ssl)\n opts[:ssl] = {:verify => false }\n opts[:url] = @endpoint.sub /^http:/, \"https:\"\n else \n opts[:url] = @endpoint.sub /^https:/, \"http:\"\n end\n conn = Faraday::Connection.new(opts) do |builder|\n builder.adapter Faraday.default_adapter\n builder.use Faraday::Response::ParseJson\n builder.use FlexmlsApi::FaradayExt::FlexmlsMiddleware\n end\n FlexmlsApi.logger.debug(\"Connection: #{conn.inspect}\")\n conn\n end", "def connection\n @connection ||= Faraday.new(@options[:instance_url]) do |builder|\n builder.use Restforce::Middleware::Mashify, self, @options\n builder.use Restforce::Middleware::Multipart\n builder.request :json\n builder.use authentication_middleware, self, @options if authentication_middleware\n builder.use Restforce::Middleware::Authorization, self, @options\n builder.use Restforce::Middleware::InstanceURL, self, @options\n builder.response :json\n builder.use Restforce::Middleware::Caching, cache, @options if cache\n builder.use FaradayMiddleware::FollowRedirects\n builder.use Restforce::Middleware::RaiseError\n builder.use Restforce::Middleware::Logger, Restforce.configuration.logger, @options if Restforce.log?\n builder.use Restforce::Middleware::Gzip, self, @options\n builder.adapter Faraday.default_adapter\n end\n end", "def connection\n Faraday.new(api_url) do |conn|\n conn.use :breakers\n conn.response :snakecase\n conn.response :json, content_type: /\\bjson$/\n conn.adapter Faraday.default_adapter\n end\n end", "def connection\n Faraday.new(api_url) do |conn|\n conn.use :breakers\n conn.response :snakecase\n conn.response :json, content_type: /\\bjson$/\n conn.adapter Faraday.default_adapter\n end\n end", "def build_connection\n Faraday.new(url) do |f|\n f.request :retry, max: 2, interval: 0.1, backoff_factor: 2\n\n f.headers['Content-Type'] = content_type\n f.headers['User-Agent'] = user_agent\n\n f.options.timeout = timeout\n f.options.open_timeout = open_timeout\n\n f.adapter :typhoeus\n end\n end", "def connection\n @connection ||= begin\n conn = Faraday.new(url: Settings.SCIENCEWIRE.BASE_URI) do |faraday|\n faraday.use Faraday::Response::RaiseError\n faraday.request :retry, max: 2,\n interval: 0.5,\n interval_randomness: 0.5,\n backoff_factor: 2\n faraday.adapter :httpclient\n end\n conn.options.timeout = timeout_period\n conn.options.open_timeout = 10\n conn\n end\n end", "def connection(options = {})\n conn_options = default_options(options).keep_if { |k, _| ALLOWED_OPTIONS.include?(k) }\n clear_cache unless options.empty?\n puts \"OPTIONS:#{conn_options.inspect}\" if ENV[\"DEBUG\"]\n\n Faraday.new(conn_options.merge(builder: stack(options)))\n end", "def connection\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"base_url=#{base_url}\",\n \"username=#{username}\",\n # \"password=#{password}\",\n \"\" ], bold_puts: debug_verbose_puts if debug_verbose\n rv = Faraday.new(url: base_url) do |c|\n c.basic_auth(username, password)\n c.adapter(Faraday.default_adapter)\n end\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"rv=#{rv}\",\n \"\" ], bold_puts: debug_verbose_puts if debug_verbose\n return rv\n end", "def connection(options = {})\n default_options = {\n :headers => {\n :accept => 'application/json',\n :user_agent => user_agent,\n :host => EdgeCast::Config::DEFAULT_HOST\n },\n :ssl => { :verify => false },\n :url => endpoint,\n }\n\n @connection ||= Faraday.new(default_options.merge(connection_options)) do |builder|\n builder.request :auth, api_token\n builder.request :json\n builder.request :multipart\n builder.request :url_encoded\n\n builder.response :client_error\n builder.response :json\n builder.response :server_error\n\n builder.adapter(adapter)\n end\n end", "def connection\n @connection ||=\n begin\n conn_opts = {}\n conn_opts[:url] = url\n #conn_opts[:proxy] = proxy if proxy\n conn_opts[:request] = options.slice(:timeout, :open_timeout)\n conn_opts[:request][:params_encoder] = Faraday::FlatParamsEncoder\n\n retry_opt = {\n max: options[:retry_after_limit],\n interval: 0.05,\n interval_randomness: 0.5,\n backoff_factor: 2,\n }\n\n Faraday.new(conn_opts) do |conn|\n conn.use :ils_caching_middleware\n conn.request :retry, retry_opt\n conn.response :raise_error\n conn.adapter options[:adapter] || Faraday.default_adapter\n end\n end\n end", "def connection\n return unless @url\n\n @connection ||= Faraday::Connection.new(@url) do |b|\n b.request :url_encoded\n b.adapter :net_http\n end\n\n proc_or_username = @basic_auth.first\n if proc_or_username.respond_to?(:call)\n username_password = proc_or_username.call\n @connection.basic_auth(*username_password)\n elsif proc_or_username\n @connection.basic_auth(*basic_auth)\n end\n\n @connection\n end", "def connection\n return @connection if defined? @connection\n\n options = {\n request: {\n timeout: Nominatim.config.timeout\n }\n }\n\n @connection = Faraday.new Nominatim.config.endpoint, options do |builder|\n builder.use Nominatim::Response::ParseJson\n builder.adapter Faraday.default_adapter\n end\n\n @connection.params[:format] = 'json'\n @connection.params[:email] = Nominatim.config.email if Nominatim.config.email\n @connection.params[:key] = Nominatim.config.key if Nominatim.config.key\n\n @connection.headers[:user_agent] = Nominatim.config.user_agent\n @connection.headers[:\"accept-language\"] = Nominatim.config.accept_language\n\n @connection\n end", "def connection(force_ssl = false)\n opts = {\n :headers => headers\n }\n if(force_ssl || self.ssl)\n opts[:ssl] = {:verify => false } unless self.ssl_verify\n opts[:url] = @endpoint.sub REG_HTTP, HTTPS_SCHEME\n else \n opts[:url] = @endpoint.sub REG_HTTPS, HTTP_SCHEME\n end\n\n if self.compress\n opts[:headers][ACCEPT_ENCODING] = COMPRESS_ACCEPT_ENCODING\n end\n\n if request_id_chain\n opts[:headers][X_REQUEST_ID_CHAIN] = request_id_chain\n end\n\n conn = Faraday.new(opts) do |conn|\n conn.response self.middleware.to_sym\n conn.options[:timeout] = self.timeout\n conn.adapter Faraday.default_adapter\n end\n SparkApi.logger.debug { \"Connection: #{conn.inspect}\" }\n conn\n end", "def connection(options={})\r\n Faraday.new(:url => 'http://www.femexfut.org.mx/portalv2/webservices/ws_portal_v2.aspx/', :proxy=>\"\") do |builder|\r\n builder.use Faraday::Response::Mashify\r\n builder.use Faraday::Response::ParseXml\r\n builder.use Faraday::Response::Logger \r\n builder.adapter Faraday.default_adapter\r\n end\r\n end", "def connection\n @connection ||= Faraday.new(url: 'http://api.unloq.co', headers: default_headers) do |conn|\n conn.request :json\n conn.adapter Faraday.default_adapter\n conn.response :json, :content_type => /\\bjson$/\n end\n end", "def access_token_connection\n Faraday.new(access_token_url, headers: headers) do |conn|\n conn.use :breakers\n conn.response :json, content_type: /\\bjson$/\n conn.adapter Faraday.default_adapter\n end\n end", "def setup_connection\n Faraday.new(:url => @api_url) do |connection|\n #connection.request :url_encoded\n connection.request :json\n #connection.request :retry\n\n connection.response :logger if debug?\n connection.response :raise_error\n connection.response :json, :content_type => /\\bjson$/\n\n connection.use :instrumentation\n connection.adapter Faraday.default_adapter\n end\n end", "def access_token_connection\n Faraday.new(access_token_url) do |conn|\n conn.use :breakers\n conn.response :json, content_type: /\\bjson$/\n conn.adapter Faraday.default_adapter\n end\n end", "def connection\n options = {\n :headers => {'Accept' => \"application/#{SponsorPay.format}; charset=utf-8\", \n 'User-Agent' => SponsorPay.user_agent, \n 'Connection' => 'Keep-Alive'}, \n #'Accept-Encoding' => 'gzip ...' # => automatically added by net::http\n :ssl => {:verify => false},\n :url => SponsorPay.endpoint,\n }\n Faraday::Connection.new(options) do |connection|\n connection.use FaradayMiddleware::Mashify\n connection.use Faraday::Response::ParseJson if SponsorPay.format.to_s.downcase == 'json'\n connection.adapter SponsorPay.adapter\n end\n end", "def http\n Faraday.new(url: URL) do |c|\n c.token_auth self.auth_token\n c.request http_config[:request_encoding]\n c.response :json, :content_type => /\\bjson$/ # parse responses to JSON\n c.adapter http_config[:http_adapter]\n end\n end", "def base_connection(options = FmRest.default_connection_settings, &block)\n host = options.fetch(:host)\n\n # Default to HTTPS\n scheme = \"https\"\n\n if host.match(/\\Ahttps?:\\/\\//)\n uri = URI(host)\n host = uri.hostname\n host += \":#{uri.port}\" if uri.port != uri.default_port\n scheme = uri.scheme\n end\n\n faraday_options = {}\n faraday_options[:ssl] = options[:ssl] if options.key?(:ssl)\n faraday_options[:proxy] = options[:proxy] if options.key?(:proxy)\n\n Faraday.new(\n \"#{scheme}://#{host}#{BASE_PATH}/#{URI.escape(options.fetch(:database))}/\".freeze,\n faraday_options,\n &block\n )\n end", "def base_connection(settings = FmRest.default_connection_settings, faraday_options = nil, &block)\n settings = ConnectionSettings.wrap(settings)\n\n host = settings.host!\n\n # Default to HTTPS\n scheme = \"https\"\n\n if host.match(/\\Ahttps?:\\/\\//)\n uri = URI(host)\n host = uri.hostname\n host += \":#{uri.port}\" if uri.port != uri.default_port\n scheme = uri.scheme\n end\n\n faraday_options = (faraday_options || {}).dup\n faraday_options[:ssl] = settings.ssl if settings.ssl?\n faraday_options[:proxy] = settings.proxy if settings.proxy?\n\n database = V1.url_encode(settings.database!)\n\n Faraday.new(\n \"#{scheme}://#{host}#{DATABASES_PATH}/#{database}/\".freeze,\n faraday_options,\n &block\n )\n end", "def initialize(faraday_connection)\n @faraday_connection = faraday_connection\n flush_out_buffer\n end", "def connection\n log :debug, '.connection'\n\n @conn ||= Faraday.new(url: options.cas_server, ssl: ssl_hash) do |conn|\n conn.headers = headers\n conn.response :logger # log requests to STDOUT\n format = options.format\n conn.response(:xml, content_type: /\\bxml$/) if format == 'xml'\n conn.response(:json, content_type: /\\bjson$/) if format == 'json'\n conn.adapter :excon\n end\n end", "def connection\n @connection ||= Faraday.new(Features::SegmentDeletionConfig.config.uri) do |faraday|\n faraday.use ResponseMiddleware\n faraday.use Faraday::Adapter::NetHttp\n end\n end", "def connection\n @connection ||= Faraday.new(mws_endpoint, connection_options) do |conn|\n conn.request :multipart\n conn.request :url_encoded\n\n # Ensures the mws endpoint url is set.\n conn.request :mws_endpoint, self, options\n\n # Inserts user agent header as requested in Amazon MWS docs\n conn.request :user_agent\n\n # Inserts request signature\n conn.request :signature, self, options\n\n # Adds header with md5 calculated on body\n conn.request :md5\n\n # Handles throttling events\n conn.response :throttle, self, options\n\n # Raises errors for 40x responses.\n conn.response :raise_error\n\n # Follows 34x redirects.\n conn.response :follow_redirects\n\n conn.response :xml\n\n # Log request/responses\n conn.use Mws::Middleware::Logger, Mws.configuration.logger, options if Mws.log?\n\n conn.adapter adapter\n end\n end", "def initialize\n @use_ssl = false\n @http_adapter = Yummly::FaradayAdapter\n end", "def establish_connection(url, token)\n Faraday.new(url: url) do |faraday|\n faraday.request :json\n faraday.headers[\"Authorization\"] = token\n faraday.headers['Accept'] = 'application/json'\n faraday.response :json\n faraday.response :raise_error\n faraday.options.open_timeout = 2\n faraday.options.timeout = 100\n faraday.adapter Faraday.default_adapter\n end\n end", "def gamebus_connection\n connection = Faraday.new url: Rails.application.secrets.gamebus_url do |faraday|\n faraday.request :url_encoded # form-encode POST params\n faraday.response :logger if Rails.env.development? || ENV['DEBUG_FARADAY'] # log requests to STDOUT\n faraday.adapter Faraday.default_adapter # make requests with Net::HTTP\n end\n connection.headers['Authorization'] = \"Bearer #{gamebus_key}\"\n connection.headers['Content-Type'] = 'application/json'\n return connection\n end" ]
[ "0.8418042", "0.83763164", "0.8350241", "0.83189946", "0.8287058", "0.82806814", "0.8241433", "0.8208422", "0.81615955", "0.8116815", "0.8100564", "0.8051944", "0.8051944", "0.8051944", "0.8051944", "0.8037387", "0.80084753", "0.7988721", "0.79849297", "0.79710174", "0.7964809", "0.79440135", "0.7939257", "0.7934553", "0.7916719", "0.7912003", "0.78976977", "0.7885294", "0.7876596", "0.7876596", "0.7874363", "0.7873821", "0.7871216", "0.78677344", "0.7867681", "0.78516454", "0.78334165", "0.7824273", "0.78085405", "0.7788014", "0.77874094", "0.77734953", "0.77638835", "0.77231354", "0.77114564", "0.77108324", "0.77014726", "0.76964766", "0.7681194", "0.76800364", "0.7659185", "0.7651033", "0.76509774", "0.76255435", "0.7582595", "0.757237", "0.75626314", "0.7550792", "0.7550792", "0.7501931", "0.7482049", "0.7474392", "0.74453217", "0.73919356", "0.7374762", "0.7373379", "0.7332171", "0.7309061", "0.7308269", "0.7279848", "0.7272203", "0.7189359", "0.71823263", "0.71814024", "0.71814024", "0.7168628", "0.71664476", "0.7166303", "0.7142396", "0.71270126", "0.7121161", "0.71189487", "0.7102438", "0.7095594", "0.70879954", "0.7047321", "0.7030949", "0.69926155", "0.69771767", "0.69690394", "0.694208", "0.69090027", "0.69000655", "0.6896725", "0.6844875", "0.68401825", "0.6799493", "0.6794828", "0.6771671", "0.67590237" ]
0.8172128
8
Make request with HttpClient
def request(verb, uri, query={}) verb == :get ? query_get = query : query_post = query uri = connection.build_url(uri, query_get) response = connection.run_request(verb, uri, query_post, headers) do |request| yield request if block_given? end response = Response.new(response) case response.status when 301, 302, 303, 307 request(verb, response.headers['location'], query) when 200..299, 300..399 response end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_request(url,headers,query)\n c = HTTPClient.new\n c.get_content(url,query,headers)\nend", "def make_request\n response = @http.request(@request)\n end", "def request(http_method, path, body = '', headers = {})\n puts \"#{http_method}: #{path} - [#{body}]\" if @http_debug\n @request_client.request(http_method, path, body, headers)\n end", "def request\n self.http_response = http_client.get(url, request_options)\n self\n end", "def request(params)\n\n # Add auth header\n headers = params[:headers] || {}\n headers['x-vcloud-authorization'] = @auth_key if !@auth_key.nil? || !@auth_key.equal?('')\n\n # set connection options\n options = {:url => params[:url],\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers || {},\n :method => params[:method] || 'GET'\n }\n\n # connect\n res = RestClient::Request.execute options\n\n raise res if (res.code!=params[:expects] && res.code!=200)\n\n res\n\n\n end", "def make_request(http, request)\n response = http.request(request)\n Response.new(response)\n end", "def http_send url, form_data, headers, &block\n if form_data['action'] == 'query'\n log.debug(\"GET: #{form_data.inspect}, #{@cookies.inspect}\")\n headers[:params] = form_data\n RestClient.get url, headers, &block\n else\n log.debug(\"POST: #{form_data.inspect}, #{@cookies.inspect}\")\n RestClient.post url, form_data, headers, &block\n end\n end", "def request(http_method, path, params = {})\n response = connection.send(http_method) do |request|\n case http_method\n when :get, :delete\n request.url(path, params)\n when :post, :put\n request.path = path\n request.body = params unless params.empty?\n end\n end\n\n response.body['response']\n end", "def request(method, path, params)\n params ||= {}\n uri = full_url(path)\n\n Trubl.logger.info(\"Trubl::Client #{method}-ing #{uri} with params #{params.merge(headers: headers)}\")\n response = HTTMultiParty.send(method, uri, params.merge(headers: headers))\n\n if !response.code =~ /20[0-9]/\n Trubl.logger.fatal(\"Trubl::Client #{response.code} #{method}-ing #{uri.to_s} #{response.parsed_response}\")\n else\n Trubl.logger.debug(\"Trubl::Client #{uri} response: #{response.body}\")\n end\n response.body.force_encoding(\"utf-8\") if response.body and response.body.respond_to?(:force_encoding)\n response\n end", "def do_request()\n uri = URI.parse(API_BASE_URL + build_request_path())\n response = Net::HTTP.get_response(uri)\n response.body\n end", "def execute_http_request(http_method, path, payload = nil)\n response = RestClient::Request.execute(method: http_method, url: path, payload: payload, headers: DEFAULT_HEADERS)\n # handle response using helper\n handle_response(response)\n end", "def make_request\n query = {'income': @income, 'zipcode': @zipcode, 'age': @age}\n begin\n response = HTTParty.get(BASE_URL, query: query)\n # I know I can do better than this\n rescue Exception => e\n raise RequestException\n else\n response\n end\n end", "def http(url, opts = {})\n method = opts[:method] || :get\n response = HTTParty.send(method, url, opts)\n if (200..299).include?(response.code)\n response.body\n else\n raise HttpError.new(\"Bad response: #{response.code} #{response.body}\", response)\n end\n end", "def request(method, uri, headers, body, opts)\n # Create the client\n client = Net::HTTP.new(uri.host, uri.port)\n\n # Use SSL if requesting a secure connection\n if uri.scheme == 'https'\n client.use_ssl = true\n client.verify_mode = OpenSSL::SSL::VERIFY_PEER\n client.ca_file = opts[:cacert] if opts[:cacert]\n client.cert = OpenSSL::X509::Certificate.new(File.read(opts[:cert])) if opts[:cert]\n client.key = OpenSSL::PKey::RSA.new(File.read(opts[:key])) if opts[:key]\n end\n\n # Build the request\n request = Net::HTTP.const_get(method).new(uri.request_uri, headers)\n\n # Build the query if there's data to send\n request.body = body if body\n\n # Send the request\n client.request(request)\n rescue StandardError => e\n raise TaskHelper::Error.new(\n \"Failed to connect to #{uri}: #{e.message}\",\n 'http_request/connect-error'\n )\n end", "def send_request_for(testcase)\n @http_client.send_request(testcase.request['method'], testcase.request['path'], testcase.request['headers'], testcase.request['body'], testcase.request['parameters'])\n end", "def send_request(uri, params, user, password)\n request = Net::HTTP::Get.new(uri)\n request.basic_auth(user, password)\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n params.each_pair do |key, val|\n request[key] = val\n end\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n return JSON.parse(response.body)\nend", "def request( params={} )\n if Biomart.proxy or ENV['http_proxy']\n proxy_uri = Biomart.proxy\n proxy_uri ||= ENV['http_proxy']\n proxy = URI.parse( proxy_uri )\n @@client = Net::HTTP::Proxy( proxy.host, proxy.port )\n end\n \n params[:url] = URI.escape(params[:url])\n \n if params[:method] === 'post'\n res = @@client.post_form( URI.parse(params[:url]), { \"query\" => params[:query] } )\n else\n res = @@client.get_response( URI.parse(params[:url]) )\n end\n \n # Process the response code/body to catch errors.\n if res.code != \"200\"\n raise HTTPError.new(res.code), \"HTTP error #{res.code}, please check your biomart server and URL settings.\"\n else\n if res.body =~ /ERROR/\n if res.body =~ /Filter (.+) NOT FOUND/\n raise FilterError.new(res.body), \"Biomart error. Filter #{$1} not found.\"\n elsif res.body =~ /Attribute (.+) NOT FOUND/\n raise AttributeError.new(res.body), \"Biomart error. Attribute #{$1} not found.\"\n elsif res.body =~ /Dataset (.+) NOT FOUND/\n raise DatasetError.new(res.body), \"Biomart error. Dataset #{$1} not found.\"\n else\n raise BiomartError.new(res.body), \"Biomart error.\"\n end\n end\n end\n \n return res.body\n end", "def request(method, path, params, headers = {})\n url = \"https://#{@host}/api/#{@version}#{path}\"\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n assign_verify_mode(http)\n request = create_request(method, uri, params, headers)\n\n res = http.request(request) if request\n parse_body(res)\n rescue SocketError => e\n raise ConnectionError, e.message\n end", "def make_http_request( url, options, auth_info = {} )\n try_count = 0\n \n begin\n request = Net::HTTP::Post.new(url.path)\n request.basic_auth auth_info[:hapi_username], auth_info[:hapi_password] unless auth_info.empty?\n request.set_form_data(options)\n request.add_field('User-Agent', USER_AGENT)\n \n http = Net_HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.request(request)\n rescue Errno::ECONNREFUSED\n if try_count < 2\n try_count += 1\n sleep 1\n retry\n else\n raise Backend, \"Connection refused trying to contact hAPI at #{@hapi_hostname}\"\n end\n end\n end", "def make_get_request url, headers = []\n make_request url, headers: headers\n end", "def request(method, path, opts)\n response = connection.send(method) do |request|\n request.url(path, opts)\n request.options[:timeout] = timeout\n request.options[:open_timeout] = open_timeout\n\n unless client_id.nil?\n request.headers['Authorization'] = \"Client #{client_id}\"\n end\n end\n\n response.body\n end", "def makeRequest(url)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri.request_uri)\n\n r = http.request(request)\n return r\nend", "def request\n http_segments = @segments.clone\n @params.each do |key,value|\n http_segments[key] = value\n end\n \n # avoid using URI.encode\n query = ''\n http_segments.each do |key, value|\n query += \"&#{key}=#{value}\"\n end\n query = query[1..-1]\n \n uri = URI::HTTP.build(\n :host => HOST,\n :path => @action_path,\n :query => query\n ).to_s\n result = JSON.parse(HTTParty.get(uri).parsed_response)\n Baidumap::Response.new(result,self)\n end", "def http\n Faraday.new(url: URL) do |c|\n c.token_auth self.auth_token\n c.request http_config[:request_encoding]\n c.response :json, :content_type => /\\bjson$/ # parse responses to JSON\n c.adapter http_config[:http_adapter]\n end\n end", "def make_api_request(request_url)\n url = URI.parse(request_url)\n request = Net::HTTP::Get.new(url.path)\n connection = Net::HTTP.new(url.host, url.port)\n connection.use_ssl = true\n connection.request(request)\n end", "def make_request(method, url, params = {})\n path = \"#{EbanqApi.base_url}/#{url}\"\n response = case method\n when :get then get(path, headers, params)\n when :post then post(path, headers, params)\n when :put then put(path, headers, params)\n when :delete then delete(path, headers)\n else raise 'Error'\n end\n process_raw_response(response)\n rescue RestClient::ResourceNotFound, SocketError, Errno::ECONNREFUSED => e\n raise e\n end", "def request (url_requested, api_key)\n url_builded = url_requested + \"&api_key=\" + api_key\n\n url = URI(url_builded)\n\n https = Net::HTTP.new(url.host, url.port)\n https.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n\n response = https.request(request)\n\n JSON.parse(response.read_body)\nend", "def request(path, params = {})\n raise Error, 'Invalid HTTP Client' unless http_client\n wait_before_new_request\n\n uri = @base_uri.merge(path)\n uri.query = http_build_query(params) unless params.empty?\n\n begin\n @last_request = Time.now # see #wait_before_new_request\n @last_request_uri = uri # useful for debug\n response = make_request(uri)\n rescue => e # catch EOFError, SocketError and more\n raise HTTPError, e.message\n end\n\n case response\n when Net::HTTPSuccess\n response\n when Net::HTTPUnauthorized # 401\n raise HTTPError, 'Invalid username or password'\n when Net::HTTPServiceUnavailable # 503\n raise HTTPError, 'You have been throttled.' +\n 'Please ensure you are waiting at least one second before each request.'\n else\n raise HTTPError, \"HTTP #{response.code}: #{response.message}\"\n end\n end", "def http(name, path, params)\n # Build URI\n uri = URI(ACCESS_URL + version)\n uri.path += path\n\n # Encode parameters for GET request\n if name == 'GET'\n uri.query = URI.encode_www_form(params)\n else\n # Stringify JSON for all other requests\n data = JSON.generate(params) unless params.empty?\n end\n\n # Open connection\n res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|\n # Execute request\n http.send_request(name, uri, data, headers)\n end\n\n # Raise error message if not success\n raise HttpException.new(res) unless res.is_a? Net::HTTPSuccess\n # Parse JSON body\n JSON.parse(res.body) rescue res.body\n end", "def make_http_request\n Net::HTTP.get_response('localhost', '/ping', 3000).body\nend", "def http(request_opts = {})\n if @@client_class.nil?\n raise ConfigError.new(\"Qumulo::Rest::Client class has not been loaded yet!\")\n end\n if request_opts.is_a?(Hash)\n request_opts = RequestOptions.new(request_opts)\n else\n unless request_opts.is_a?(RequestOptions)\n raise ArgumentError.new(\"We need RequestOptions instance here\")\n end\n end\n client = request_opts.client || @@client_class.default\n client.http(request_opts)\n end", "def make_request(uri)\n http_client.start do |http|\n req = Net::HTTP::Get.new(uri.request_uri, @headers)\n req.basic_auth(@username, @password)\n http.request(req)\n end\n end", "def request(verb, uri, options = {})\n client = HTTP::Client.new(headers: headers)\n client = client.via(*proxy) if proxy\n handle_response(client.request(verb, uri, options))\n end", "def http( *args )\n p http_get( *args )\n end", "def _http_request(method, url, *args)\n request_args = get_hash_args(*args)\n url = get_url url unless url.to_s.start_with?('http://')\n request_args[:header] = @head\n request_args[:body] = \\\n JSON.dump(request_args[:body]) if request_args[:body]\n\n res = @http_session.request(method, url, request_args)\n status = res.status\n raise HTTPError, 'HTTPError: %s %s'\\\n % [status, (JSON.load(res.content)['message'] rescue res.reason)]\\\n if status >= 400 && status < 600\n res\n end", "def send_request method, params = {}\n uri = URI.parse(@api_url)\n if Time.now.to_i > @exp + 3600\n get_acces_token\n @exp = Time.now.to_i\n end\n required = { 'access_token' => @access_token, 'method' => method }\n params = required.merge(params)\n params = URI.escape(params.collect{ |k,v| \"#{k}=#{v}\"}.join('&'))\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.request_uri)\n req['User-Agent'] = \"zhzhussupovkz pleer.com-ruby-api\"\n req.body = params\n res = http.request(req)\n if res.code == \"200\"\n data = res.body\n result = JSON.parse(data)\n else\n puts \"Invalid getting data from server\"\n exit\n end\n end", "def execute_http_request (method, url, args)\n @http_request = method, url.clone, args.clone\n self.http_response = HTTParty.send method, url, args\n Log.debug \"#{@http_response.request.http_method.to_s.split('::').last.upcase} - URL: #{@http_response.request.last_uri}\"\n Log.debug 'HEADER:'\n Log.debug http_response.request.options[:headers]\n # Log.debug @http_response.request.options[:body] if @http_response.request.options[:body]\n Log.debug 'BODY:' if http_response\n Log.debug http_response if http_response\n http_response\n end", "def http\n HTTP .headers(accept: \"application/json\")\n # .via(\"127.0.0.1\", 8888)\n end", "def _request(url, type, key)\n url = URI(url)\n type ||= :GET\n req_path = \"#{url.path}?#{url.query}\"\n\n if type == :GET\n req = Net::HTTP::Get.new(req_path)\n elsif type == :POST\n req = Net::HTTP::Post.new(req_path)\n end\n\n req.add_field('X-Vermillion-Key', key)\n req.add_field('Accept', 'application/json')\n req.add_field('Cache-Control', 'no-cache')\n req.add_field('From', @config.get(:user))\n req.add_field('User-Agent', 'Vermillion Client 1.0')\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n res\n end", "def request\n EventMachine::HttpRequest.new(url)\n end", "def http(method, *args)\n args.last.merge!(self.default_headers).merge!(\"X-Auth-Token\" => self.auth_token)\n response = RestClient.send(method, *args)\n @retried = false\n response\n rescue RestClient::Unauthorized\n @auth_response = nil\n if @retried\n raise\n else\n @retried = true\n retry\n end\n end", "def make_request(uri)\n request = Net::HTTP::Get.new uri\n\n request[\"Authorization\"] = \"Basic #{credentials}\"\n request[\"Content-Type\"] = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n\n Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|\n http.request request\n end\n end", "def execute\n uri = request_uri\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n retries = Europeana.max_retries\n \n begin\n response = http.request(request)\n rescue Timeout::Error, Errno::ECONNREFUSED, EOFError\n retries -= 1\n raise unless retries > 0\n sleep Europeana.retry_delay\n retry\n end\n \n json = JSON.parse(response.body)\n raise Errors::RequestError, json['error'] unless json['success']\n json\n rescue JSON::ParserError\n raise Errors::ResponseError\n end", "def perform_request(http_method, url, query_parameters)\n request_uri = \"#{self.class::SERVICE_URI_SUFFIX}/#{url}\".gsub(/[\\/]+/, '/')\n query_parameters = { query: query_parameters }\n\n # do request\n begin\n response = self.class.send(http_method, request_uri, query_parameters)\n response_body = response.parsed_response\n rescue JSON::JSONError # catches errors when parsing response\n response_body = nil\n rescue HTTParty::Error => e # catches connection and other technical errors\n raise Errors::ResponseError.new(e.message, nil, e)\n end\n\n # response.class is now HTTParty::Response\n\n # check HTTP and format errors\n unless response_body.is_a?(Hash) # its not valid JSON response\n if error_code?(response.code) # HTTP error occurred\n raise Errors::ResponseError.new(response.response.message, response.code)\n else\n raise Errors::UnsupportedFormatError.new('JSON response expected.', response.code)\n end\n end\n\n # check Activiti engine errors\n if error_code?(response.code)\n raise Errors::OperationFailedError.new(response_body['message'], response_body['exception'], response.code)\n end\n\n # if response body is empty -> return nil\n return nil if response.body.empty?\n\n ap response_body\n\n # return result as a hash in common Ruby format\n underscore(response_body)\n end", "def run_request(method, url, body, headers); end", "def do_http_request(path, payload)\n uri = URI.parse(@host + \":\" + @port + \"#{path}\")\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = @usessl\n http.verify_mode = @sslverify\n\n request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})\n request.body = payload.to_json\n request.basic_auth(@username.to_s, @password.to_s)\n\n return JSON.parse(http.request(request).body)\n end", "def request(url,token = nil)\n url = URI(\"#{url}&api_key=#{token}\") # se quita uri y parentesis\n #puts url_string\n \n \n https = Net::HTTP.new(url.host, url.port)\n https.use_ssl = true\n request = Net::HTTP::Get.new(url)\n response = https.request(request)\n data = JSON.parse(response.read_body)\n #puts data\nend", "def make_request(request, options)\n gather_headers(request, options)\n response = @http.request(request)\n Validators::ResponseValidator.validate!(response)\n JSON.parse(response.body)\n end", "def request(http_method: :get, path:'/', body: nil, query: {}, headers: {}, response_block: nil, expects: [200, 201, 204], host: nil, port: nil, auth: true, gzip: true)\n\n retried ||= false\n\n if auth && token_expired?\n raise Excon::Error::Unauthorized, \"Token expired or not valid, you need to login again, use: kontena #{token_is_for_master? ? \"master\" : \"cloud\"} login\"\n end\n\n request_headers = request_headers(headers, auth: auth, gzip: gzip)\n\n if body.nil?\n body_content = ''\n request_headers.delete(CONTENT_TYPE)\n else\n body_content = encode_body(body, request_headers[CONTENT_TYPE])\n request_headers.merge!('Content-Length' => body_content.bytesize)\n end\n\n uri = URI.parse(path)\n host_options = {}\n\n if uri.host\n host_options[:host] = uri.host\n host_options[:port] = uri.port\n host_options[:scheme] = uri.scheme\n path = uri.request_uri\n else\n host_options[:host] = host if host\n host_options[:port] = port if port\n end\n\n request_options = {\n method: http_method,\n expects: Array(expects),\n path: path_with_prefix(path),\n headers: request_headers,\n body: body_content,\n query: query\n }.merge(host_options)\n\n request_options.merge!(response_block: response_block) if response_block\n\n # Store the response into client.last_response\n @last_response = http_client.request(request_options)\n\n parse_response(@last_response)\n rescue Excon::Error::Unauthorized\n if token\n debug { 'Server reports access token expired' }\n\n if retried || !token || !token['refresh_token']\n raise Kontena::Errors::StandardError.new(401, 'The access token has expired and needs to be refreshed')\n end\n\n retried = true\n retry if refresh_token\n end\n raise Kontena::Errors::StandardError.new(401, 'Unauthorized')\n rescue Excon::Error::HTTPStatus => error\n if error.response.headers['Content-Encoding'] == 'gzip'\n error.response.body = Zlib::GzipReader.new(StringIO.new(error.response.body)).read\n end\n\n debug { \"Request #{error.request[:method].upcase} #{error.request[:path]}: #{error.response.status} #{error.response.reason_phrase}: #{error.response.body}\" }\n\n handle_error_response(error.response)\n end", "def do_request(params)\n # Convert the uri to a URI if it's a string.\n if params[:uri].is_a?(String)\n params[:uri] = URI.parse(params[:uri])\n end\n host_url = \"#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? \":#{params[:uri].port}\" : ''}\"\n\n # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to\n # different hosts.\n @connections[host_url] ||= Fog::Connection.new(host_url, @persistent, @connection_options)\n\n # Set headers to an empty hash if none are set.\n headers = params[:headers] || {}\n\n # Add our auth cookie to the headers\n if @cookie\n headers.merge!('Cookie' => @cookie)\n end\n\n # Make the request\n response = @connections[host_url].request({\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers,\n :method => params[:method] || 'GET',\n :path => params[:uri].path\n })\n\n # Parse the response body into a hash\n #puts response.body\n unless response.body.empty?\n if params[:parse]\n document = Fog::ToHashDocument.new\n parser = Nokogiri::XML::SAX::PushParser.new(document)\n parser << response.body\n parser.finish\n\n response.body = document.body\n end\n end\n\n response\n end", "def request(method, path, params = nil)\n uri = URI.parse(url_for(path))\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = uri.kind_of?(URI::HTTPS)\n client.verify_mode = OpenSSL::SSL::VERIFY_PEER\n client.ca_file = CA_FILE\n\n request = net_class(method).new(uri.request_uri)\n request.basic_auth Codeplane.username, Codeplane.api_key\n request[\"Content-Type\"] = \"application/x-www-form-urlencoded\"\n request[\"User-Agent\"] = \"Codeplane/#{Codeplane::Version::STRING}\"\n request.body = params.to_param if request.request_body_permitted? && params\n\n response = client.request(request)\n\n case response.code\n when \"401\"\n raise Codeplane::UnauthorizedError, \"Double check you username and API key\"\n when \"404\"\n raise Codeplane::NotFoundError\n else\n Codeplane::Response.new(response)\n end\n end", "def send_request(method, url)\n @response = client.run_request(method, url, @body, headers) do |req|\n req.params = params\n end\n end", "def request(klass, path, data={})\n url = url(path)\n http = http(url)\n req = build_request(klass, url, data)\n resp = http.request(req) # send request\n load_json(resp)\n end", "def request(verb, params)\n params = build_url(params)\n\n if access_token\n params.merge!(:access_token => access_token)\n end\n\n Connection.new(verb, params).fetch\n end", "def http_request(params)\n Net::HTTP::Post.new(endpoint.request_uri).tap do |request|\n request.body = URI.encode_www_form params\n request.content_type = 'application/x-www-form-urlencoded; charset=utf-8'\n end\n end", "def simple_request(method, url)\n uri = URI.parse(url)\n request = Net::HTTP::Get.new(uri)\n request.content_type = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n request[\"App-Id\"] = ENV[\"salt_edge_app_id\"]\n request[\"Secret\"] = ENV[\"salt_edge_secret\"]\n\n req_options = {\n use_ssl: uri.scheme == \"https\",\n } \n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n\n #puts response.body\n return JSON.parse(response.body)\n end", "def send_request(http_client, usecase, meth, uri, req, params, headers, container, counter)\n container.response = http_client.send(meth, uri, params, headers) # booya!\n end", "def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end", "def build_request()\n @http = Net::HTTP.new(@uri.host, @uri.port)\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n end", "def request(method)\n setup_client\n respond_with @client.request(method, @request.url, nil, @request.body, @request.headers, &@request.on_body)\n rescue OpenSSL::SSL::SSLError\n raise SSLError\n rescue Errno::ECONNREFUSED # connection refused\n $!.extend ConnectionError\n raise\n end", "def curl(url,params)\n uri = URI.parse(url)\n https = Net::HTTP.new(uri.host,uri.port)\n https.use_ssl = true\n base64h = Base64.strict_encode64(\"#{APP_KEY}:#{APP_SECRET}\")\n headers = {'Authorization' => \"Basic #{base64h}\", 'Content-Type' =>'application/x-www-form-urlencoded'}\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.set_form_data(params)\n response = https.request(request)\n\nend", "def httpRequest (url)\n\turi = URI.parse(url)\n\thttp = Net::HTTP.new(uri.host, uri.port)\n\tresponse = http.request(Net::HTTP::Get.new(uri.request_uri))\nend", "def make_request(url, params)\n response = connection.get do |req|\n req.url url\n params.each do |k, v|\n req.params[k] = v\n end\n end\n response\n end", "def http_post_request\n begin\n return http_client.post(http_path_query, compressed_request, http_headers)\n rescue APIKeyError\n log 'error - you must set your api_key.'\n rescue TimeoutError\n log 'fail - timeout while contacting the api server.'\n rescue Exception => e\n log \"fail - exception raised during http post. (#{e.class.name}: #{e.message})\"\n end\n nil\n end", "def request(method)\n unless ::HTTP::Request::METHODS.include? method\n raise NotSupportedError, \"http.rb does not support custom HTTP methods\"\n end\n response = begin\n @client.send(method, @request.url, :body => @request.body)\n rescue OpenSSL::SSL::SSLError\n raise SSLError\n end\n\n Response.new(response.code, response.headers.to_h, response.body.to_s)\n end", "def http_request(action, data, method_type = 'POST', binary_key = nil)\n\n uri = \"#{@api_uri}/#{action}\"\n if method_type != \"POST\" && (!method_type.is_a? String)\n uri += \"?\" + data.map{ |key, value| \"#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}\" }.join(\"&\")\n end\n\n req = nil\n\n _uri = URI.parse(uri)\n\n headers = {\n \"Content-Type\": \"text/json\",\n \"Api-Key\":\"#{@api_key}\"\n }\n\n if method_type == 'POST'\n req = set_up_post_request(\n _uri, data, headers, binary_key\n )\n\n else\n request_uri = \"#{_uri.path}?#{_uri.query}\"\n if method_type == 'DELETE'\n req = Net::HTTP::Delete.new(request_uri, headers)\n else\n req = Net::HTTP::Get.new(request_uri, headers)\n end\n end\n\n begin\n http = Net::HTTP::Proxy(@proxy_host, @proxy_port).new(_uri.host, _uri.port)\n\n if _uri.scheme == 'https'\n http.ssl_version = :TLSv1\n http.use_ssl = true\n http.set_debug_output $stderr\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @verify_ssl != true # some openSSL client doesn't work without doing this\n http.ssl_timeout = @opts[:http_ssl_timeout] || 5\n end\n http.open_timeout = @opts[:http_open_timeout] || 5\n http.read_timeout = @opts[:http_read_timeout] || 10\n http.close_on_empty_response = @opts[:http_close_on_empty_response] || true\n\n\n response = http.start do\n http.request(req)\n end\n\n rescue Timeout::Error, Errno::ETIMEDOUT => e\n raise UnavailableError, \"Timed out: #{_uri}\"\n rescue => e\n raise ClientError, \"Unable to open stream to #{_uri}: #{e.message}\"\n end\n\n response.body || raise(ClientError, \"No response received from stream: #{_uri}\")\n end", "def make_request\n\t\t\tresponse = nil\n\t\t\tif self.respond_to? :headers\n\t\t\t\turi = URI.parse(request_string)\n\n\t\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\thttp.set_debug_output $stderr if @test_request\n\t\t\t\thttp.use_ssl = true\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n\t\t\t\trequest = Net::HTTP::Get.new(uri.request_uri)\n\t\t\t\theaders.each do |k,v|\n\t\t\t\t\trequest[k] = v\n\t\t\t\tend\n\n\t\t\t\tresponse = http.request(request).body\n\t\t\telse\n\t\t\t\t$stderr.puts(request_string) if @test_request\n\n\t\t\t\tresponse = open(request_string)\n\t\t\tend\n\n\t\t\treturn process_response(response)\n\t\tend", "def execute_http_request(http, request)\n @response = http.request(request)\n @http_headers = {}\nend", "def make_request(method, path, query, headers = {}, body = nil)\n full_path = @api_base_path + path\n\n request = ProxyClientUtils.build_request(method, full_path, query, headers, body)\n\n begin\n response = @connection.request(request)\n\n from_headers = ProxyClientUtils.normalize_headers(\n ProxyClientUtils.filter_response_headers(response.to_hash)\n )\n\n [response.code.to_i, from_headers, [response.body]]\n rescue Errno::ECONNREFUSED => e\n raise RemoteConnectionError.new(\"#{self.class.base_uri} - #{e.class}: #{e.message}\")\n end\n end", "def request(base_url, params)\n RestClient.get base_url, { params: params }\n end", "def send_request method, params = nil\n if params.nil?\n raise ArgumentError, \"Invalid request params\"\n else\n required = { 'api_key' => @api_key }\n params = required.merge(params)\n params = URI.escape(params.collect{ |k,v| \"#{k}=#{v}\"}.join('&'))\n end\n url = @api_url + method + '/?' + params\n raise ArgumentError, \"Can't send request to the server\" if not url.is_a? String\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n req = Net::HTTP::Get.new(uri.request_uri)\n res = http.request(req)\n data = res.body\n if not data.is_a? String or not data.is_json?\n raise RuntimeError, \"Server returned incorrect format data.\"\n end\n result = JSON.parse(data)\n end", "def request(url, body)\n #res = HTTParty.post(url, body: body, headers: {'Content-Type' => 'application/soap+xml; charset=\"utf-8\"'}, :verify => false)\n res = HTTParty.post(url, body: body, headers: {'Content-Type' => 'application/soap+xml; charset=\"utf-8\"'}, :verify => false)\n p \"response is: #{res}. response body is: #{res.body} for url: #{url}\"\n content = JSON.parse(res.body)\n end", "def request\n self.response = prepare_response(http_communication.content)\n end", "def request(method, path, options, headers)\n headers.merge!({\n 'User-Agent' => user_agent\n })\n\n options.merge!({\n :api_key => api_key\n })\n\n response = connection.send(method) do |request|\n request.url \"#{endpoint}#{path}\", options\n request.body = options\n request.headers = headers\n end\n Shirtsio::Utils.handle_api_error(response) if response.status != 200\n\n Shirtsio::Utils.parse_json(response.body)[:result]\n end", "def run_json_http_request\n uri = URI.parse @json_url\n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n # set up request\n request = Net::HTTP::Get.new uri.request_uri\n \n # get response, convert to hash\n response = http.request request\n response_hash = JSON.parse response.body\n end", "def do_get\n Net::HTTP.get(URI.parse(api_url))\n end", "def http_get(request)\n tries = 3\n begin\n curl = Curl::Easy.new request\n curl.useragent = USER_AGENT\n curl.perform\n begin\n JSON.parse curl.body_str\n rescue JSON::ParserError => err\n @log.warn \"Could not parse response for #{request} - this is probably not a json response: #{curl.body_str}\"\n return nil\n end\n rescue Curl::Err::ConnectionFailedError => err\n @log.error \"Connection failed: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n rescue Curl::Err::RecvError => err\n @log.error \"Failure when receiving data from the peer: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n rescue Curl::Err => err\n @log.error \"Failure in Curl call: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n end\n end", "def request_over_http(options, http_method, endpoint)\n if http_method == :get\n api_call = endpoint + \"?\" + options.collect{|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n URI.parse(api_call).read\n else\n Net::HTTP.post_form(URI.parse(endpoint), options).body\n end\n end", "def request(method, path, opts = {})\n raise ClientError, 'Access token missing' unless @access_token\n\n opts[:headers] = {} if opts[:headers].nil?\n opts[:headers]['Accept'] = 'application/json'\n opts[:headers]['Content-Type'] = 'application/json' unless method == :get\n opts[:headers]['User-Agent'] = user_agent\n opts[:headers]['Authorization'] = \"Bearer #{@access_token}\"\n\n if !opts[:data].nil?\n opts[:body] = opts[:data].to_param\n\n puts \"SETTING BODY #{opts[:body]}\"\n\n opts[:headers]['Content-Type'] = 'application/x-www-form-urlencoded' # sob sob\n end\n\n path = URI.encode(path)\n\n resp = connection.run_request(method, path, opts[:body], opts[:headers]) do |req|\n req.params = opts[:params] if !opts[:params].nil?\n end\n\n response = Response.new(resp)\n\n case response.status\n when 301, 302, 303, 307\n # TODO\n when 200..299, 300..399\n # on non-redirecting 3xx statuses, just return the response\n response\n when 400..599\n error = ApiError.new(response)\n raise(error, \"Status code #{response.status}\")\n else\n error = ApiError.new(response)\n raise(error, \"Unhandled status code value of #{response.status}\")\n end\n end", "def make_request(uri)\n response = Net::HTTP.get_response(uri)\n JSON.parse(response.body)\n end", "def send\n uri = URI(@api_url)\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n http.read_timeout = GlobalConstant::CompanyApi.read_timeout\n http.open_timeout = GlobalConstant::CompanyApi.open_timeout\n req_obj = get_request_obj(uri.request_uri)\n\n http_response, e = nil, nil\n begin\n http_response = http.request(req_obj)\n set_api_response_cookie(http_response)\n parse_api_response(http_response)\n rescue Net::ReadTimeout, Net::OpenTimeout => e\n # Timeouts\n exception_with_internal_code(\n e,\n 'company_api_timeout',\n 'company api timeout',\n GlobalConstant::ErrorCode.internal_server_error,\n debug_data\n )\n rescue Exception => e\n # Exceptions\n exception_with_internal_code(e, 'company_api_exception', 'company api exception', GlobalConstant::ErrorCode.internal_server_error, debug_data)\n end\n\n end", "def perform_request(method, path, params={}, body=nil, headers=nil)\n client.perform_request method, path, params, body, headers\n end", "def curl_request(params)\n return {:success => false, :msg => 'Please provide mandatory params', :json_response => {}} if params[:url].blank?\n begin\n uri = URI.parse(params[:url])\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n json_response = JSON.parse(response)\n rescue Exception => e\n puts \"Exception Occurred - Message: #{e.message}, Backtrace:#{e.backtrace.inspect}\"\n return {:success => false, :msg => \"Exception occurred - #{e.message}\", :json_response => {}}\n end\n {:success => true, :msg => '', :json_response => json_response}\n end", "def http(data, url, opts = {})\n method = opts[:method] || :post\n opts[:data] = data\n response = HTTParty.send(method, url, opts)\n unless (200..299).include?(response.code)\n raise HttpError.new(\"Bad response: #{response.code} #{response.body}\", response)\n end\n end", "def request(method, url, payload, format)\n opts = {\n :method => method,\n :url => url,\n :payload => payload,\n :headers => {:content_type => CONTENT_TYPES[format]},\n :timeout => TIMEOUT,\n :open_timeout => OPEN_TIMEOUT\n }\n \n RestClient::Request.execute(opts)\n end", "def get(request)\n do_request(request) { |client| client.http_get }\n end", "def make_request(url)\n res = Typhoeus::Request.new(\n url,\n method: :get,\n headers: {\n \"Accept-Charset\": \"application/x-www-form-urlencoded; charset=UTF-8\",\n \"Accept-Language\" => \"en-US,en;q=0.9,pt;q=0.8\",\n \"X-Riot-Token\" => @api_key.to_s,\n \"User-Agent\": \"https://github.com/drish/rioter\"\n }\n ).run\n parse!(res)\n end", "def send_request(http_method, path: \"\", body: nil)\n body = ActiveSupport::JSON.encode(body) if body.is_a? Hash\n @connection.run_request(http_method.downcase.to_sym,\n path.to_s,\n body,\n default_headers)\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end", "def execute_request(request, client:)\n connection = build_connection(request.url, client: client)\n\n headers = request.headers.dup\n\n body = request.body\n\n resp = connection.run_request(request.verb.downcase, request.url, body, headers)\n\n {\n status: Integer(resp.status),\n message: resp.reason_phrase,\n headers: Simple::HTTP::Headers.new(resp.headers.to_hash),\n body: resp.body\n }\n end", "def http_get(url)\n response = client.get(url, follow_redirect: true)\n\n raise HTTPClient::BadResponseError, response.reason unless HTTP::Status.successful?(response.status)\n\n response\n end", "def job_client(target_uri, query, access_token, method)\n return {} if target_uri.nil? || method.nil?\n\n uri = URI.parse(target_uri)\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n\n begin\n req = Net::HTTP::Post.new(uri.request_uri)\n req[\"Content-Type\"] = \"application/json; charset=utf-8\"\n req[\"Authorization\"] = \"Bearer #{access_token}\"\n req.body = query\n\n response = https.request(req)\n\n puts \"code -> #{response.code}\"\n puts \"body -> #{response.body}\"\n\n case response\n when Net::HTTPSuccess\n body = response.body\n JSON.parse(body)\n else\n puts [uri.to_s, response.value].join(\" : \")\n return nil\n end\n rescue => e\n logger.error [uri.to_s, e.class, e].join(\" : \")\n return nil\n end\n\n end", "def create_http_client\n c = DefaultHttpClient.new( @connection_manager, @cparams )\n c.http_request_retry_handler = @retry_handler if @retry_handler\n c\n end", "def do_request(params)\n # Convert the uri to a URI if it's a string.\n if params[:uri].is_a?(String)\n params[:uri] = URI.parse(params[:uri])\n end\n host_url = \"#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? \":#{params[:uri].port}\" : ''}\"\n\n # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to\n # different hosts.\n @connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)\n\n # Set headers to an empty hash if none are set.\n headers = params[:headers] || {}\n headers['Accept'] = 'application/*+xml;version=1.5' if version == '1.5'\n\n # Add our auth cookie to the headers\n if @cookie\n headers.merge!('Cookie' => @cookie)\n end\n\n # Make the request\n response = @connections[host_url].request({\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers,\n :method => params[:method] || 'GET',\n :path => params[:uri].path\n })\n\n # Parse the response body into a hash\n unless response.body.empty?\n if params[:parse]\n document = Fog::ToHashDocument.new\n parser = Nokogiri::XML::SAX::PushParser.new(document)\n parser << response.body\n parser.finish\n response.body = document.body\n end\n end\n\n response\n end", "def http_get(url)\n # get proxy info\n proxy_host, proxy_port = find_http_proxy\n # $stderr.puts \"DEBUG: proxy: host = #{proxy_host}, port = #{proxy_port}\"\n\n # get host, port, and base URI for API queries\n uri = URI.parse(@base_uri)\n base = uri.request_uri\n\n # prepend base to url\n url = \"#{base}/#{url}\"\n\n # connect to delicious\n http = Net::HTTP.Proxy(proxy_host, proxy_port).new(uri.host, uri.port)\n\n if uri.scheme == 'https'\n # check to make sure we have SSL support\n raise NoSSLError, \"Unsupported URI scheme 'https'\" unless HAVE_SSL\n init_http_ssl(http)\n end\n\n # start HTTP connection\n http = http.start\n\n # get URL, check for error\n resp = http.get(url, @headers)\n raise HTTPError, \"HTTP #{resp.code}: #{resp.message}\" unless resp.code =~ /2\\d{2}/\n\n # close HTTP connection, return response\n http.finish\n resp.body\n end", "def httpget(url, corpNum, userID = '')\n headers = {\n \"x-pb-version\" => KAKAOCERT_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n uri = URI(getServiceURL() + url)\n request = Net::HTTP.new(uri.host, 443)\n request.use_ssl = true\n\n Net::HTTP::Get.new(uri)\n\n res = request.get(uri.request_uri, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise KakaocertException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end", "def http_request\n @http_request ||= begin\n request = request_for_verb\n add_post_data(request)\n add_bearer_token(request)\n add_headers(request)\n request\n end\n end", "def request(method, path, params, options)\n params = params.billyfy_keys!\n auth = {username: api_key, password: \"\"}\n case method.to_sym\n when :get\n response = HTTParty.get(endpoint + path, :query => params, :basic_auth => auth)\n when :post\n response = HTTParty.post(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth)\n when :delete\n response = HTTParty.delete(endpoint + path, :query => params, :basic_auth => auth)\n when :put\n response = HTTParty.put(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth)\n else\n end\n\n options[:raw] ? response : response.parsed_response.rubyify_keys!\n end", "def invoke_request(url)\n site = RestClient::Resource.new(url, \"dHgVM1emGoTyr8zHmVNH\")\n return JSON.parse(site.get(:accept=>\"application/json\"))\nend", "def invoke_request(url)\n site = RestClient::Resource.new(url, \"dHgVM1emGoTyr8zHmVNH\")\n return JSON.parse(site.get(:accept=>\"application/json\"))\nend", "def post()\n return @http.request(@req)\n end" ]
[ "0.74466443", "0.7210795", "0.7050768", "0.68496317", "0.6782678", "0.6767084", "0.6720374", "0.6706801", "0.6697897", "0.6683894", "0.6659776", "0.6582446", "0.65686387", "0.6556935", "0.65283686", "0.6527966", "0.6519749", "0.65143996", "0.6511265", "0.650684", "0.65031326", "0.6463116", "0.6454188", "0.6446129", "0.6425065", "0.6421091", "0.6414664", "0.6408284", "0.64058006", "0.64022666", "0.6386329", "0.63845104", "0.6377782", "0.63646233", "0.6363255", "0.6360059", "0.63524944", "0.63467073", "0.6328684", "0.6324124", "0.63206965", "0.63172853", "0.6311047", "0.6286135", "0.62836385", "0.62835574", "0.62761545", "0.6273515", "0.62552094", "0.6254217", "0.62515736", "0.625132", "0.6247251", "0.6247071", "0.623998", "0.62378764", "0.62370574", "0.6235302", "0.62329453", "0.6229215", "0.6228595", "0.6225943", "0.62208253", "0.6212094", "0.6207832", "0.62041694", "0.61966467", "0.61950916", "0.618626", "0.61801285", "0.61778843", "0.6176069", "0.6171345", "0.6169703", "0.6167137", "0.61581707", "0.6156782", "0.61560035", "0.61483514", "0.614513", "0.6140145", "0.61384326", "0.61302394", "0.6130078", "0.6127954", "0.6126048", "0.6120649", "0.61171746", "0.61169946", "0.61093336", "0.6107456", "0.6097093", "0.60892403", "0.60831237", "0.60795885", "0.60795486", "0.60661894", "0.60657215", "0.6062942", "0.6062942", "0.605662" ]
0.0
-1
Handle get request with HttpClient
def get(uri, query = {}, &block) request(:get, uri, query, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end", "def get(path)\n req = Net::HTTP::Get.new(@base_url + path)\n response = handle_request(req)\n response.each {|k,v| puts \"#{k}: #{v}\"}\n response\n end", "def get\n check_response( @httpcli.get(@endpoint) )\n end", "def http( *args )\n p http_get( *args )\n end", "def do_get\n Net::HTTP.get(URI.parse(api_url))\n end", "def get\n start { |connection| connection.request http :Get }\n end", "def get(request)\n do_request(request) { |client| client.http_get }\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get(http: HTTParty)\n http.get(url)\n end", "def get()\n return @http.request(@req)\n end", "def http_get(path, headers = { })\n clear_response\n path = process_path(path)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end", "def http_get(url)\n response = client.get(url, follow_redirect: true)\n\n raise HTTPClient::BadResponseError, response.reason unless HTTP::Status.successful?(response.status)\n\n response\n end", "def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend", "def get\n @response = Net::HTTP.get_response(URI(@url))\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def send_get(url)\r\n result = @client.get(self.target_uri(url))\r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200')\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end", "def get(options={}, &block)\n response = http.get_uri(options, &block)\n handle_response(response)\n end", "def get!\n self.https.request self.http_request # Net::HTTPResponse object\n end", "def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end", "def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end", "def _get\n http_method(:get)\n end", "def http_get(opts={})\n raw_content = opts[:raw_content] || false\n ret=http_get_low(opts)\n if !raw_content then\n\tif ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then\n authdefault\n ret=http_get_low(opts)\n return ret\n else\n return ret\n\tend\n else\n\treturn ret\n end\n end", "def httpget(url, corpNum, userID = '')\n headers = {\n \"x-pb-version\" => KAKAOCERT_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n uri = URI(getServiceURL() + url)\n request = Net::HTTP.new(uri.host, 443)\n request.use_ssl = true\n\n Net::HTTP::Get.new(uri)\n\n res = request.get(uri.request_uri, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise KakaocertException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end", "def do_http_get(url)\n response, data = @http.get(url, @headers)\n\n unless response.code == '200'\n case response.code\n when '400'\n data = {\n error: \"status code : #{response.code}, message : #{response.body}\"\n } \n else\n data = {\n error: \"You have Internal Error. status code : #{response.code}, message: #{response.body}\"\n }\n end\n end\n\n return data\n end", "def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end", "def get(path, data={})\n RestClient.get(full_url(path), {params: data})\n rescue RestClient::Exception => error\n message = \"REST client exception caught processing GET request.\"\n log.error \"#{message}\\nCause: #{error}\\n\" +\n error.backtrace.join(\"\\n\")\n raise CAHTTPError.new(message, error, response: error.response, url: full_url(path))\n end", "def _http_get resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Get.new(path)\n _build_request resource, request\nend", "def _http_get resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Get.new(path)\n _build_request resource, request\nend", "def http_get(url, headers = nil)\r\n if @debug\r\n puts \"Url:\"\r\n puts url\r\n puts \"Headers:\"\r\n puts headers\r\n puts \"Method: get\"\r\n end\r\n return headers ? HTTParty.get(url, :headers => headers) : HTTParty.get(url)\r\n end", "def get(url)\n uri = normalize_url(url)\n\n # Ensure the parsed URL is an HTTP one\n raise HTTPError::ClientError.new(\"Invalid URL #{url}\") unless uri.is_a?(URI::HTTP)\n\n req = Net::HTTP::Get.new(uri.request_uri)\n handle_request(uri, req)\n end", "def get(url, headers = {})\n do_request Net::HTTP::Get, url, headers\n end", "def get *args, &block\n handle @conn.get *args, &block\n end", "def get(url); end", "def get(url, headers)\n conn = create_connection_object(url)\n\n http = conn.get(:head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end", "def get(path, params, connection = CONNECTION)\n request = Net::HTTP::Get.new(to_url(path, params))\n process_request(request, connection)\nend", "def get(path, headers = {})\n process :get, path, headers\n end", "def get(url, headers={})\n do_request(\"get\", url, nil, headers)\n end", "def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def get options={}, &block\n handle_exceptions do\n Chimps.log.info(\"GET #{url}\")\n Response.new(super(options, &block))\n end\n end", "def http_get(request_uri)\n response = http.request(Net::HTTP::Get.new(request_uri))\n yield response.body if response.code == \"200\"\n end", "def http_get(payload)\n destination = URI(@collector_uri + '?' + URI.encode_www_form(payload))\n LOGGER.info(\"Sending GET request to #{@collector_uri}...\")\n LOGGER.debug(\"Payload: #{payload}\")\n http = Net::HTTP.new(destination.host, destination.port)\n request = Net::HTTP::Get.new(destination.request_uri)\n if destination.scheme == 'https'\n http.use_ssl = true\n end\n response = http.request(request)\n LOGGER.add(is_good_status_code(response.code) ? Logger::INFO : Logger::WARN) {\n \"GET request to #{@collector_uri} finished with status code #{response.code}\"\n }\n\n response\n end", "def get(url, headers={})\n RestClient.get url, headers\n end", "def get path, header={}, body_string_or_hash=\"\"\n env.http 'GET', path, header, body_string_or_hash\n end", "def get(params = {})\n http_helper.send_get_request(\"#{@url_prefix}\", params)\n end", "def get(path, accept, content = {})\n execute HttpConnect::HttpGet.new(path, nil, accept, content)\n end", "def get(url='/', vars={})\n send_request url, vars, 'GET'\n end", "def get(path)\n request 'GET', path\n end", "def get\n res = connection.get url.to_s\n Response.const_get(class_basename).new res.body, res.status\n end", "def get(url, params={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n # add URL parameters\n uri.query = URI.encode_www_form(params)\n\n debug(\"GET #{uri} #{headers.inspect}\")\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Get.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n get_raw(response['location'], params, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end", "def get(path, params)\n parse_response @client[path].get(:params => params)\n end", "def get(path, query = { }, headers = { })\n clear_response\n path = process_path(path, query)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end", "def http_get(path)\n http_methods(path, :get)\n end", "def do_GET(request, _response)\n log_request(request)\n end", "def get(request_opts = {})\n store_result(http(request_opts).get(resolved_path))\n end", "def http_get(path, query, format = :json)\n uri = URI.parse(\"http://#{Jamendo::API_SERVER}/v#{Jamendo::API_VERSION}/#{path}#{query}\")\n puts uri.request_uri\n http = Net::HTTP.new(uri.host, uri.port) \n request = Net::HTTP::Get.new(uri.request_uri)\n begin\n response = http.request(request)\n result = parse_response(response)\n assert_response(result[:headers])\n return result[:results]\n rescue JamendoError => e\n e.inspect\n end\n end", "def get(request)\n _request(request) { |client, options| client.get options }\n end", "def get(path, options={}, &block)\n uri = URI.join(@endpoint, path)\n headers = options.delete(:headers)\n query = options.delete(:query)\n\n if query\n uri.query = URI.encode_www_form(query)\n end\n\n request = Net::HTTP::Get.new uri.request_uri, headers\n @http.request request, &block\n end", "def get endpoint\n do_request :get, endpoint\n end", "def get(url, params={})\n @agent.get(url,params)\n end", "def get(url, headers = {})\n http :get, \"#{url}.json\", headers\n end", "def get(resource)\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"GET request Url: #{url}\")\n @logger.debug(\"-- Headers: #{base_headers}\")\n\n HTTParty.get(url, headers: base_headers)\n end", "def http_get(endpoint)\n uri= URI.parse \"#{@main_url}#{endpoint}\"\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n request.basic_auth(@username, @api_key)\n response = http.request(request)\n response.body\nend", "def get(uri)\r\n request(Net::HTTP::Get.new(uri)) \r\n end", "def get; end", "def send_get(uri)\n _send_request('GET', uri, nil)\n end", "def get(url, headers = {})\n request(:get, url, headers)\n end", "def get(url, headers = {})\n request(:get, url, headers)\n end", "def get(path = nil)\n url = URI.parse(@url.scheme + '://' + @url.host + ':' + @url.port.to_s + path.to_s)\n headers = { \"Authorization\" => \"Basic \" + [@user + \":\" + @password].pack(\"m\") } if @user\n \n server = Net::HTTP.new(@url.host, @url.port)\n server.read_timeout = @timeout\n server.use_ssl = url.scheme == 'https'\n server.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n res, data = server.get(url.request_uri, headers)\n \n case res\n when Net::HTTPSuccess\n # OK\n else\n raise res.inspect\n end\n [res, data]\n end", "def get!(*args)\n @response = get(*args)\n end", "def http_get(url)\n require \"open-uri\"\n URI.parse(url).read\n end", "def get(url)\n uri = URI(url)\n Net::HTTP.get(uri)\nend", "def get(uri, request_headers)\n request('get', uri, request_headers)\n end", "def perform_get(path, options = {})\n perform_request(:get, path, options)\n end", "def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end", "def get(path, params = {})\n debug_log \"GET #{connection.build_url(\"#{@host}#{path}\", params)}\"\n res = connection.get path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def get(url)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n\n response = http.get(\"#{uri.path}?auto\")\n\n unless response.code == \"200\"\n puts \"Failed to retrieve #{url}: #{response.code}\"\n exit 3\n end\n\n response.body\nend", "def hnl_http_get(uri, include_http_response = false)\n # setup the request\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n\n # make the request\n response = http.request(request)\n\n # and return the result\n return [JSON.parse(response.body)[\"response\"], response] if include_http_response\n JSON.parse(response.body)[\"response\"]\n end", "def http_get(domain,path,params)\n return Net::HTTP.get(domain, \"#{path}?\".concat(params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\" }.join('&'))) if not params.nil?\n return Net::HTTP.get(domain, path)\n end", "def get\n url = prefix + \"get\" + id_param\n return response(url)\n end", "def get(path, params: {}, headers: nil)\n response = conn.get do |req|\n build_request(req, path: path, params: params, headers: headers)\n end\n response\n rescue StandardError => e\n puts e.inspect\n raise\n end", "def get(params = {})\n response = prepare_response(make_url(params).open('User-Agent' => USER_AGENT).read)\n check_error(response)\n return parse_response(response)\n rescue OpenURI::HTTPError => e\n check_error(prepare_response(e.io.read))\n raise\n end", "def get(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpGetWithEntity, url, options, &block\n end", "def get(params = {})\n request! do\n api[url.path + to_query(params)].get(API_HEADERS)\n end\n end", "def get(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Add parameters to URL query string\n get_params = {\n :method => \"get\", \n :verbose => DEBUG\n }\n get_params[:params] = data unless data.empty?\n # Create GET request\n get = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", get_params)\n # Send request\n do_request(get, format, :cache => true)\n end", "def get(path, headers = {})\n request = Net::HTTP::Get.new(path)\n @default_headers.merge(headers).each do |key, value|\n request[key] = value\n end\n @http.request(request)\n end", "def get(opts = {})\n with_monitoring do\n connection.get(opts[:path]) do |req|\n req.headers = headers.merge('Authorization' => \"Bearer #{opts[:access_token]}\")\n end\n end\n end", "def get\n execute_request { faraday_connection.get(href || '') }\n end", "def fetch\n endpoint = URI(uri)\n Net::HTTP.get(endpoint)\n rescue *@errors => e\n pp e\n nil\n end", "def get path = \"\", payload = {}\n make_request(path, \"get\", payload)\n end", "def get(params)\n\n request_url = create_url(params)\n begin\n @json_response = HTTParty.get(URI.encode(request_url))\n rescue SocketError\n @response_hash = Hashie::Mash.new({})\n return\n end\n\n @response_hash = Hashie::Mash.new(@json_response.to_hash)\n set_attrs(@response_hash)\n @response_hash\n end", "def get_request\n# Use our @http_object object's request method to call the\n# Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end", "def http_get(request)\n tries = 3\n begin\n curl = Curl::Easy.new request\n curl.useragent = USER_AGENT\n curl.perform\n begin\n JSON.parse curl.body_str\n rescue JSON::ParserError => err\n @log.warn \"Could not parse response for #{request} - this is probably not a json response: #{curl.body_str}\"\n return nil\n end\n rescue Curl::Err::ConnectionFailedError => err\n @log.error \"Connection failed: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n rescue Curl::Err::RecvError => err\n @log.error \"Failure when receiving data from the peer: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n rescue Curl::Err => err\n @log.error \"Failure in Curl call: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n nil\n end\n end\n end", "def get(path, redirect_limit=5)\n parse_json do |parser|\n @http_client.get(path, redirect_limit) {|chunk| parser << chunk }\n end\n end", "def http(url, opts = {})\n method = opts[:method] || :get\n response = HTTParty.send(method, url, opts)\n if (200..299).include?(response.code)\n response.body\n else\n raise HttpError.new(\"Bad response: #{response.code} #{response.body}\", response)\n end\n end", "def get(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :get,\n :url => \"#{self.uri}#{path}\",\n :headers => {\n :params => params\n },\n :verify_ssl=> @ssl_verify )\n end", "def get(params)\n request.method = :get\n execute(params)\n end", "def get(url, query = nil, headers = nil)\n headers = headers ? @headers.merge(headers) : @headers\n #Log.t(\"GET: #{url}\\n#{query.inspect}\\n#{headers.inspect}\")\n content = @client.get_content(URI.join(@base, url), query, headers) rescue ''\n Nokogiri::HTML(content)\n end", "def get(user_auth=false)\n http = new_http()\n request = Net::HTTP::Get.new(@uri.request_uri)\n initialize_header(request, @header)\n authenticate_user(request) if user_auth == true\n request.body = @payload if @payload\n log_request(request)\n response = http.request(request)\n log_response(response)\nend", "def make_get_request url, headers = []\n make_request url, headers: headers\n end" ]
[ "0.7129386", "0.7060946", "0.7054542", "0.69961625", "0.6991852", "0.6991513", "0.6872981", "0.6823162", "0.6823162", "0.6808633", "0.67996955", "0.6793002", "0.67554367", "0.6736796", "0.6735243", "0.66812557", "0.66812557", "0.6665988", "0.6665538", "0.6647717", "0.66462505", "0.66290873", "0.66217774", "0.6607155", "0.65963656", "0.6594479", "0.65505326", "0.6548985", "0.65461", "0.65461", "0.65425086", "0.6537906", "0.6537168", "0.65183336", "0.6504365", "0.64858204", "0.64609516", "0.64576066", "0.64403117", "0.6439321", "0.64204276", "0.6413101", "0.6387313", "0.63848597", "0.6365926", "0.6331534", "0.6330441", "0.63279265", "0.6326088", "0.63235056", "0.631516", "0.6314782", "0.6309566", "0.62959313", "0.6279368", "0.62757504", "0.62744445", "0.6272884", "0.6246747", "0.62378204", "0.62362266", "0.6223602", "0.62200046", "0.6219921", "0.6215222", "0.62126267", "0.6208364", "0.62063974", "0.62063974", "0.61977315", "0.6194135", "0.6191921", "0.6184432", "0.61756283", "0.6173779", "0.6170238", "0.61680955", "0.61667734", "0.616225", "0.6160349", "0.6159435", "0.61509746", "0.61484873", "0.61457133", "0.6143669", "0.61430174", "0.6143017", "0.6140619", "0.6139766", "0.6138158", "0.61359054", "0.6134829", "0.6132937", "0.6131868", "0.6130104", "0.61257464", "0.6125469", "0.6124655", "0.61107326", "0.61098605", "0.61077106" ]
0.0
-1
Handle post request with HttpClient
def post(uri, query = {}, &block) request(:post, uri, query, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post()\n return @http.request(@req)\n end", "def http_post_request\n begin\n return http_client.post(http_path_query, compressed_request, http_headers)\n rescue APIKeyError\n log 'error - you must set your api_key.'\n rescue TimeoutError\n log 'fail - timeout while contacting the api server.'\n rescue Exception => e\n log \"fail - exception raised during http post. (#{e.class.name}: #{e.message})\"\n end\n nil\n end", "def post(request)\n do_request(request) { |client| client.http_post request.body }\n end", "def http_post(*args)\n url = args.shift\n c = Curl::Easy.new url\n yield c if block_given?\n c.http_post *args\n c\n end", "def post(path, form_data=nil)\n parse_json do |parser|\n @http_client.post(path, form_data) {|chunk| parser << chunk }\n end\n end", "def post\n resource.post(request, response)\n end", "def post *args, &block\n handle @conn.post *args, &block\n end", "def post!\n self.https.request self.http_request # Net::HTTPResponse object\n end", "def post(*args)\n request, adapter = request_and_adapter_from(args)\n\n with_adapter :post, request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.post request\n end\n end", "def http_post(payload)\n LOGGER.info(\"Sending POST request to #{@collector_uri}...\")\n LOGGER.debug(\"Payload: #{payload}\")\n destination = URI(@collector_uri)\n http = Net::HTTP.new(destination.host, destination.port)\n request = Net::HTTP::Post.new(destination.request_uri)\n if destination.scheme == 'https'\n http.use_ssl = true\n end\n request.body = payload.to_json\n request.set_content_type('application/json; charset=utf-8')\n response = http.request(request)\n LOGGER.add(is_good_status_code(response.code) ? Logger::INFO : Logger::WARN) {\n \"POST request to #{@collector_uri} finished with status code #{response.code}\"\n }\n\n response\n end", "def post; end", "def post(path, headers = {})\n process :post, path, headers\n end", "def http_post(path, request)\n @http.post(\n :body => JSON(:request => request.to_hash),\n :headers => headers,\n :path => \"/api/v2/#{path}\",\n :expects => [200, 201, 202]\n )\n end", "def post(url, body, headers)\n conn = create_connection_object(url)\n\n http = conn.post(:body => body,\n :head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end", "def post\r\n end", "def post_http(args)\n\t\t return(Net::HTTP.post_form @uri, args)\t\t\t\n \tend", "def POST; end", "def post(path, **args); end", "def post_http_content\n res = Net::HTTP.post_form(uri, params)\n\n raise HTTPError.new(\"invalid #{res.code} response\") unless res.is_a?(Net::HTTPSuccess)\n\n res.body\n end", "def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end", "def post(*args)\n request, adapter = request_and_adapter_from(args)\n \n with request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.post request\n end\n end", "def post\n @response_body = make_request(\"#{api_url}#{endpoint}\", request_body.to_json)\n puts \"GLIMR POST: #{endpoint} - #{request_body.to_json}\" if ENV.key?('GLIMR_API_DEBUG')\n end", "def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def do_post(uri = \"\", body = \"\")\n @connection.post do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Error trying to send a POST to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Request sent: #{body}\"\n Faraday::Response.new\n end", "def http_post(path, data, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 201\n @response = http.post(path, data, headers)\n parse_response? ? parsed_response : response.body\n end", "def post(request)\n _request(request) { |client, options| client.post options }\n end", "def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end", "def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end", "def post\n end", "def post(url, req_hash={})\n res = nil\n res = perform_op(:post, req_hash) do\n res = @wrapper.post(url, req_hash)\n end\n return res\n end", "def post_data; end", "def post(path, params)\n parse_response @client[path].post(params)\n end", "def exec_post(req, data, exit_on_fail = false)\n response_hash = exec_api_call('POST', req, data, exit_on_fail)\n response_hash[:response]\n end", "def http_post(url, hash=nil, _port=nil, headers=nil)\n \n resp, data = http_request(url, \"post\", hash, _port, headers)\n\treturn [resp, data]\nend", "def post options={}, &block\n handle_exceptions do\n Chimps.log.info(\"POST #{url}\")\n Response.new(super(encoded_body, options, &block))\n end\n end", "def http_post(path, data, content_type = 'application/json')\n http_methods(path, :post, data, content_type)\n end", "def http_post(url, params, json = false)\n content_type = {}\n if json && params\n params = params.to_json\n content_type['Content-Type'] = 'application/json'\n end\n headers = @auth_headers.merge(content_type)\n exponential_backoff do\n @mutex.synchronize do\n begin\n response = @agent.post(url, params, headers)\n return JSON.parse(response.body)\n rescue Net::HTTP::Persistent::Error\n reset_http_agent\n response = @agent.post(url, params, headers)\n return JSON.parse(response.body)\n end\n end\n end\n end", "def process_http_request\n # the http request details are available via the following instance variables:\n # @http_protocol\n # @http_request_method\n # @http_cookie\n # @http_if_none_match\n # @http_content_type\n # @http_path_info\n # @http_request_uri\n # @http_query_string\n # @http_post_content\n # @http_headers\n handle(@http_request_method, @http_post_content)\n\n send_ok()\n end", "def post(*args, &block); end", "def post(request)\n # sure thing!\n json_response(200, { message: \"This dummy POST endpoint didn't do anything.\" })\n end", "def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend", "def _http_post resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Post.new(path)\n _build_request resource, request\nend", "def _http_post resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Post.new(path)\n _build_request resource, request\nend", "def post(hash)\n connection.post do |conn|\n if hash[:content_type]\n conn.headers[\"Content-Type\"] = hash[:content_type]\n end\n\n conn.url(hash[:path], :access_token => access_token)\n conn.body = hash[:body]\n end\n end", "def post(url, post_vars={})\n send_request url, post_vars, 'POST'\n end", "def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend", "def post(path, form_data)\n req = Net::HTTP::Post.new(path)\n req.set_form_data(form_data)\n request(req){|res| yield res }\n end", "def do_POST(request, response)\n\n @aspecto_repeater.repeat request\n @bugsnag_repeater.repeat request\n\n # Turn the WEBrick HttpRequest into our internal HttpRequest delegate\n request = Maze::HttpRequest.new(request)\n\n content_type = request['Content-Type']\n if %r{^multipart/form-data; boundary=([^;]+)}.match(content_type)\n boundary = WEBrick::HTTPUtils::dequote($1)\n body = WEBrick::HTTPUtils.parse_form_data(request.body, boundary)\n hash = {\n body: body,\n request: request,\n response: response\n }\n else\n # \"content-type\" is assumed to be JSON (which mimics the behaviour of\n # the actual API). This supports browsers that can't set this header for\n # cross-domain requests (IE8/9)\n digests = check_digest request\n hash = {\n body: JSON.parse(request.body),\n request: request,\n response: response,\n digests: digests\n }\n end\n if @schema\n schema_errors = @schema.validate(hash[:body])\n hash[:schema_errors] = schema_errors.to_a\n end\n add_request(hash)\n\n # For the response, delaying if configured to do so\n response_delay_ms = Server.response_delay_ms\n if response_delay_ms.positive?\n $logger.info \"Waiting #{response_delay_ms} milliseconds before responding\"\n sleep response_delay_ms / 1000.0\n end\n\n set_response_header response.header\n response.status = post_status_code\n rescue JSON::ParserError => e\n msg = \"Unable to parse request as JSON: #{e.message}\"\n if Maze.config.captured_invalid_requests.include? @request_type\n $logger.error msg\n Server.invalid_requests.add({\n reason: msg,\n request: request,\n body: request.body\n })\n else\n $logger.warn msg\n end\n rescue StandardError => e\n if Maze.config.captured_invalid_requests.include? @request_type\n $logger.error \"Invalid request: #{e.message}\"\n Server.invalid_requests.add({\n invalid: true,\n reason: e.message,\n request: {\n request_uri: request.request_uri,\n header: request.header,\n body: request.inspect\n }\n })\n else\n $logger.warn \"Invalid request: #{e.message}\"\n end\n end", "def rest_post\n ##define the url path\n url =\"/post\"\n ##This is headers definition.\n headers = [\n ['Cached-Control', \"no-cache\" ],\n [\"Content-Type\", \"application/x-www-form-urlencoded; charset=UTF-8\"]\n ]\n input_body = {\"test_key\" =>\"test_value\"}\n\n begin\n #------------------------\n #Send Post Request\n #------------------------\n request, response = send_post(url, input_body.to_json, headers)\n\n if response.code.to_i == 200\n actual_value =JSON.parse(response.body)\n ## return the value need to be validated\n actual_value = actual_value['form']\n return actual_value.to_json\n else\n return false\n end\n rescue Exception => ex\n @log.error \"#### Response code is: #{response.code} #####\"\n @log.error ex.message\n puts \"#### Response code is: #{response.code} #####\"\n puts ex.message\n return false\n end\n end", "def do_request\n\t\t\tself.response = post_request(options)\n\t\tend", "def post(path, content_type, accept, content = {})\n execute HttpConnect::HttpPost.new(path, content_type, accept, content)\n end", "def http_post(url, data)\n\turi = URI(url)\n\treq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\n req.body = data.to_json\n response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }\n return response\nend", "def post\n if phase.has_key?('post')\n execute(\"post\", phase['post'])\n end\n end", "def post_request(client, post_information_hash, additional_hash = nil)\n new_hash = {:content_type => \"application/json\"}\n additional_hash ||= {} \n new_hash.merge!(additional_hash)\n\n begin\n client.post(JSON.generate(post_information_hash, {:max_nesting => 100}), new_hash)\n rescue OpenSSL::SSL::SSLError => e\n raise \"SSLError occurred when calling REST service; #{e}\"\n rescue RestClient::Exception => e # if the request failed, RestClient will throw an error. We want to retrieve that error and the response within\n puts \"RestClient::Exception hit when calling REST service\"\n puts e\n puts e.response\n return e.response\n rescue => e\n raise \"Unexpected error occurred when calling REST service; #{e}\"\n end\n end", "def post(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n response = http.start {|http| http.request(request) }\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend", "def post(url, post_data, custom_headers = {})\n headers = @default_headers.merge(custom_headers)\n # slow down the request rate! otherwise you will get blocked\n sleep 1\n return @agent.post(url, post_data, headers)\n end", "def post(*args, &block)\n map_method(:post, args, &block)\n end", "def post(uri, request_headers, body)\n request('post', uri, request_headers, body) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end", "def post(*args)\n request(:post, *args)\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def post!\n request! :post\n end", "def post(*args)\n request :post, *args\n end", "def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def httppost(url, corpNum, postData, action = '', userID = '', contentsType = '')\n\n headers = {\n \"x-lh-version\" => KAKAOCERT_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n apiServerTime = @linkhub.getTime(@useStaticIP, @useGAIP)\n\n hmacTarget = \"POST\\n\"\n hmacTarget += Base64.strict_encode64(Digest::SHA256.digest(postData)) + \"\\n\"\n hmacTarget += apiServerTime + \"\\n\"\n\n hmacTarget += KAKAOCERT_APIVersion + \"\\n\"\n\n key = Base64.decode64(@linkhub._secretKey)\n\n data = hmacTarget\n digest = OpenSSL::Digest.new(\"sha256\")\n hmac = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, key, data))\n\n headers[\"x-kc-auth\"] = @linkhub._linkID+' '+hmac\n headers[\"x-lh-date\"] = apiServerTime\n\n if contentsType == ''\n headers[\"Content-Type\"] = \"application/json; charset=utf8\"\n else\n headers[\"Content-Type\"] = contentsType\n end\n\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n\n\n uri = URI(getServiceURL() + url)\n\n https = Net::HTTP.new(uri.host, 443)\n https.use_ssl = true\n Net::HTTP::Post.new(uri)\n\n res = https.post(uri.request_uri, postData, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise KakaocertException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end", "def post(*args)\n Request.post(*args)\n end", "def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end", "def post(params = nil)\n request.method = :post\n execute(params)\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def make_post_request(route:, headers: nil, body: nil)\n post route, params: body, headers: headers\nend", "def post(url, params = {})\n client.post(url, params).body\n end", "def handle_post\n make_response(201, {message: 'New resource created'})\nend", "def handle_post()\n make_response(201, \"New resource created\")\nend", "def http_post(uri, data)\n RestClient.post uri, data\n end", "def post_request(url,args)\n uri = URI.parse(url)\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data(args)\n request(uri,req)\n end", "def post(path, params = {}, env = {}, &block)\n env[:request_method] = \"POST\"\n mock_request(path, params, env, &block)\n end", "def post\n raise NotImplementedError\n end", "def post(path, query_string, data)\n # ...and delegate to the Faraday connection we created on initilization\n @conn.post \"#{path}?#{query_string}\", data\n end", "def do_POST(req, resp)\n # Split the path into piece\n path = req.path[1..-1].split('/')\n\n # We don't want to cache catflap login page so set response headers.\n # Chrome and FF respect the no-store, while IE respects no-cache.\n resp['Cache-Control'] = 'no-cache, no-store'\n resp['Pragma'] = 'no-cache' # Legacy\n resp['Expires'] = '-1' # Microsoft advises this for older IE browsers.\n\n response_class = CfRestService.const_get 'CfRestService'\n\n raise \"#{response_class} not a Class\" unless response_class.is_a?(Class)\n\n raise HTTPStatus::NotFound unless path[1]\n\n response_method = path[1].to_sym\n # Make sure the method exists in the class\n raise HTTPStatus::NotFound unless response_class\n .respond_to? response_method\n\n if :sync == response_method\n resp.body = response_class.send response_method, req, resp, @cf\n end\n\n if :knock == response_method\n resp.body = response_class.send response_method, req, resp, @cf\n end\n\n # Remaining path segments get passed in as arguments to the method\n if path.length > 2\n resp.body = response_class.send response_method, req, resp,\n @cf, path[1..-1]\n else\n resp.body = response_class.send response_method, req, resp, @cf\n end\n raise HTTPStatus::OK\n end", "def create_post(params)\n mock_request = Rack::MockRequest.new(APP)\n mock_request.post(new_post_endpoint, { 'router.params' => params, format: :json })\n end", "def post(*args)\n execute(:post, *args)\n end", "def post(path, params = {})\n\t\trequest(path, :post, params)\n\tend", "def post(url, data={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"POST #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n post_raw(response['location'], data, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end", "def xhr_post *args, params_or_action\n Presto::Browser.new(@controller, env, 'POST', true).body *args, params_or_action\n end", "def do_POST(request, response)\n\n content_type = request['Content-Type']\n\n # For JSON, pull the instructions from the body. Otherwise, take them from the query string.\n if content_type == 'application/json'\n body = JSON.parse(request.body)\n delay_ms = body['delay_ms']\n status = body['status']\n else\n query = Rack::Utils.parse_nested_query(request.query_string)\n delay_ms = query['delay_ms']\n status = query['status']\n end\n\n reflect response, delay_ms, status\n rescue JSON::ParserError => e\n msg = \"Unable to parse request as JSON: #{e.message}\"\n $logger.error msg\n response.status = 418\n rescue StandardError => e\n $logger.error \"Invalid request: #{e.message}\"\n response.status = 500\n end", "def post(payload)\n post_like payload, Net::HTTP::Post.new(@uri.path)\n end", "def post(url, options = {}, &block)\n request HttpPost, url, options, &block\n end", "def post(path, body, args = {})\n client = new(path, args)\n response = client.send(:request) do |uri|\n req = Net::HTTP::Post.new(uri)\n req.body = body\n req\n end\n response\n end", "def post(url, headers, body)\n request(:post, url, headers, body)\n end", "def post(post_data, path)\n response = self.class.post(path, options(post_data, true))\n response.response.body\n end", "def post(request)\n request.method = :post\n request.call\n end", "def post(path, data={})\n RestClient.post(full_url(path), data)\n rescue RestClient::Exception => error\n message = \"REST client exception caught processing POST request.\"\n log.error \"#{message}\\nCause: #{error}\\n\" +\n error.backtrace.join(\"\\n\")\n raise CAHTTPError.new(message, error, response: error.response, url: full_url(path))\n end", "def post(data = {})\n call data, method: :post\n end", "def post(options={}, &block)\n response = http.post_uri(options.merge(:body => serialize), &block)\n handle_response(response)\n end", "def send_post_request(url, payload, content_type = 'application/json')\n # set the uri\n url = URI(url)\n\n # set http settings\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # set request\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = content_type\n request[\"cache-control\"] = 'no-cache'\n\n # set the payload\n request.body = payload\n\n # send the request and get whatever is the response\n response = http.request(request)\n\n # return the response by reading the body\n return response.read_body\n end", "def post(params)\n self.class.post(url, body: params)\n end", "def post(path, data = { }, query = { }, headers = { })\n clear_response\n path = process_path(path, query)\n @success_code = 201\n @response = http.post(path, data, headers)\n parse_response? ? parsed_response : response.body\n end", "def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend", "def post\n Rentlinx.client.post(self)\n end" ]
[ "0.68115985", "0.6741828", "0.6574264", "0.65465164", "0.64903414", "0.6484743", "0.6469328", "0.644033", "0.6276431", "0.62587106", "0.62454903", "0.6234165", "0.6233841", "0.6229893", "0.6209215", "0.62036735", "0.6184107", "0.61654276", "0.61644727", "0.61491376", "0.61471325", "0.61358345", "0.6132336", "0.6091077", "0.608703", "0.60863495", "0.6070886", "0.60633874", "0.60570717", "0.6031397", "0.60242397", "0.60217446", "0.6019835", "0.6018777", "0.6000634", "0.5999378", "0.5997844", "0.5981345", "0.59712934", "0.59651095", "0.5961195", "0.5958719", "0.5958719", "0.59542686", "0.5945473", "0.59406567", "0.59354454", "0.5917252", "0.591691", "0.5905308", "0.59028697", "0.5902537", "0.5901303", "0.5900321", "0.58968145", "0.5887886", "0.58776426", "0.5876327", "0.5868019", "0.5860244", "0.58396655", "0.5839112", "0.5838701", "0.58370984", "0.5823012", "0.58223987", "0.5810638", "0.58094424", "0.58092743", "0.5795405", "0.5787515", "0.57763445", "0.57735366", "0.577333", "0.5768433", "0.5768427", "0.57653576", "0.5755652", "0.57438576", "0.57427245", "0.57401663", "0.57400286", "0.5735694", "0.57337296", "0.5730579", "0.5723984", "0.5695916", "0.569276", "0.5689941", "0.56891876", "0.56786793", "0.5678453", "0.5677636", "0.5677247", "0.56770617", "0.56673455", "0.56667936", "0.56565696", "0.56508034", "0.56437343", "0.56431234" ]
0.0
-1
PUT /locks/ or /locks/serial/ This endpoint is used in both lock commissioning and lock status sync
def update return if params_missing([ :id, :lock_serial ], params, true) lock = Lock.get_active_else_not(params) return render_error_modelname(404, :MISSING_RECORD, Lock) if !lock # Only the owner can update the lock record return render_error(403, :NOT_BELONGING, Lock) if lock.user_id != @current_user_device.user_id return render_error(404, :LOCK_DECOMMISSIONED) if lock.decommissioned? lock.assign_attributes(params_app_allowed) new_lock = false if !lock.commissioned? # New lock, set it all up new_lock = true lock.commission_date = DateTime.now end return check_save_failure(lock) if !lock.save # Owner's key not created until commissioning is completed (saved) successfully. # TODO Transaction around this and the commissioning? if new_lock key = create_user_key(lock.id, lock.user, lock.user) # Validation errors may fail in interesting ways here. end render_lock_reply(lock) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock!(resource, uuid, *lock_names)\n build_locks(resource, lock_names, uuid).each(&:save!)\n end", "def update\n @lock = Lock.find(params[:id])\n\n respond_to do |format|\n if @lock.update_attributes(params[:lock])\n format.html { redirect_to(@lock, :notice => 'Lock was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lock.errors, :status => :unprocessable_entity }\n end\n end\n end", "def lock\n request_body = {\"index\" => {\"blocks\" => {\"write\" => true}}}.to_json\n @client.put(\"_settings\", request_body, content_type: :json)\n end", "def test_put_too_many_locktokens_given\n new_coll 'httplock'\n new_file 'httplock/a', StringIO.new(\"hello\")\n new_file 'httplock/b', StringIO.new(\"world\")\n\n b_locktoken = lock('httplock/b', :depth => 0).token\n a_locktoken = lock('httplock/a', :depth => 0).token\n\n response = @request.put('httplock/a', StringIO.new('hello'), :if => [a_locktoken, b_locktoken])\n assert_equal '412', response.status\n \n response = @request.put('httplock/a', StringIO.new('hello'), { :if => [a_locktoken, b_locktoken], :strict_if => false } )\n assert_equal '204', response.status \n\n # cleanup\n unlock('httplock/a', a_locktoken)\n unlock('httplock/b', b_locktoken)\n delete_coll('httplock')\n end", "def execute\n if refresh_lock?\n lock_properties = @resource.refresh_lock\n elsif resource_locked?\n return :locked\n else\n # The `lockinfo` tag is used to specify the type of lock the client\n # wishes to have created.\n xml = xml_for body: body, node: 'lockinfo'\n return :bad_request if xml == :bad_request\n\n lock_properties = @resource.lock xml, @headers['Depth']\n end\n\n build_response lock_properties\n end", "def lock\n\n lockinfo = request_document.xpath(\"//#{ns}lockinfo\")\n asked = {}\n asked[:timeout] = request.env['Timeout'].split(',').map{|x|x.strip} if request.env['Timeout']\n asked[:depth] = depth\n unless([0, :infinity].include?(asked[:depth]))\n BadRequest\n else\n asked[:scope] = lockinfo.xpath(\"//#{ns}lockscope\").children.find_all{|n|n.element?}.map{|n|n.name}.first\n asked[:type] = lockinfo.xpath(\"#{ns}locktype\").children.find_all{|n|n.element?}.map{|n|n.name}.first\n asked[:owner] = lockinfo.xpath(\"//#{ns}owner/#{ns}href\").children.map{|n|n.text}.first\n begin\n lock_time, locktoken = resource.lock(asked)\n render_xml(:prop) do |xml|\n xml.lockdiscovery do\n xml.activelock do\n if(asked[:scope])\n xml.lockscope do\n xml.send(asked[:scope])\n end\n end\n if(asked[:type])\n xml.locktype do\n xml.send(asked[:type])\n end\n end\n xml.depth asked[:depth].to_s\n xml.timeout lock_time ? \"Second-#{lock_time}\" : 'infinity'\n xml.locktoken do\n xml.href locktoken\n end\n if(asked[:owner])\n xml.owner asked[:owner]\n end\n end\n end\n end\n response.headers['Lock-Token'] = locktoken\n response.status = resource.exist? ? OK : Created\n rescue LockFailure => e\n multistatus do |xml|\n e.path_status.each_pair do |path, status|\n xml.response do\n xml.href path\n xml.status \"#{http_version} #{status.status_line}\"\n end\n end\n end\n end\n end\n end", "def test_lock_unlock\n setup_file\n\n assert_empty_lockdiscovery 'file'\n \n # get an exclusive write lock\n owner = \"<D:href xmlns:D='DAV:'>http://tim.limebits.com/</D:href>\"\n lock = lock 'file', :depth => 0, :owner => owner, :timeout => 1000\n\n assert_equal :write, lock.type\n assert_equal :exclusive, lock.scope\n assert_equal 0, lock.depth\n\n # timeout & token check are limestone specific\n assert_in_delta 1000, lock.timeout, 50\n assert_not_nil lock.token\n\n assert_xml_matches lock.owner do |xml|\n xml.xmlns! :D => \"DAV:\"\n xml.D :href, 'http://tim.limebits.com/'\n end\n\n response = @request.lock 'file'\n assert_equal '423', response.status\n \n unlock 'file', lock.token\n\n # a second unlock should return 409\n response = @request.unlock('file', lock.token)\n assert_equal '409', response.status\n\n response = @request.delete 'file'\n assert_equal '204', response.status\n end", "def lock url, options={}\n stream = nil\n unless options[:refresh]\n scope = options[:scope] || :exclusive\n type = options[:type] || :write\n\n stream = RubyDav.build_xml_stream do |xml|\n xml.lockinfo 'xmlns' => 'DAV:' do\n xml.locktype { xml.tag! type }\n xml.lockscope { xml.tag! scope }\n xml.owner { xml << options[:owner] } if options.include? :owner\n end\n end\n end\n \n request :lock, url, stream, options\n end", "def walletlock\n @api.request 'walletlock'\n end", "def update\n respond_to do |format|\n if @migrations_lock.update(migrations_lock_params)\n format.html { redirect_to @migrations_lock, notice: 'Migrations lock was successfully updated.' }\n format.json { render :show, status: :ok, location: @migrations_lock }\n else\n format.html { render :edit }\n format.json { render json: @migrations_lock.errors, status: :unprocessable_entity }\n end\n end\n end", "def do_LOCK(req, res)\n end", "def test_multi_resource_lock_child_locked\n response = @request.delete('coll')\n\n response = @request.mkcol('coll')\n assert_equal '201', response.status\n\n response = @request.mkcol('coll/subcoll')\n assert_equal '201', response.status\n\n response = @request.put('coll/file', @stream)\n assert_equal '201', response.status\n\n lock = lock 'coll/subcoll'\n\n response = @request.lock 'coll'\n assert_equal '207', response.status\n resps = response.responses\n assert_equal '424', resps[@uri.path + 'coll'].status\n assert_equal '423', resps[@uri.path + 'coll/subcoll'].status\n\n response = @request.delete('coll', :depth => RubyDav::INFINITY,\n :if => { 'coll/subcoll' => lock.token })\n 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_params\n params.require(:lock).permit(:state)\n end", "def test_put_new_resource_locked_collection_zero_depth\n setup_hr\n\n resumes_locktoken = lock('httplock/hr/recruiting/resumes',\n :depth => 0).token\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"lisa resume\"), :if_none_match => '*')\n assert_equal '423', response.status\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"lisa resume\"), { :if_none_match => '*', :if => { 'httplock/hr/recruiting/resumes/' => resumes_locktoken } })\n assert_equal '201', response.status\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"hello\"))\n assert_equal '204', response.status\n\n # cleanup\n unlock('httplock/hr/recruiting/resumes/', resumes_locktoken)\n delete_coll 'httplock'\n end", "def lock\n post :lock\n end", "def lock=(value)\n doc['lock'] = value\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 test_move_between_locks\n setup_hr\n new_coll 'httplock/hr/archives/resumes'\n\n resumes_locktoken = lock('httplock/hr/recruiting/resumes',\n :depth => RubyDav::INFINITY).token\n archives_lock = lock 'httplock/hr/archives', :depth => RubyDav::INFINITY\n archives_locktoken = archives_lock.token\n\n assert_hr_move_response '423'\n assert_hr_move_response '423', resumes_locktoken \n assert_hr_move_response '412', archives_locktoken\n assert_hr_move_response '412', [resumes_locktoken, archives_locktoken]\n assert_hr_move_response '201', [[resumes_locktoken], [archives_locktoken]]\n\n response = @request.propfind 'httplock/hr/archives', 0, :lockdiscovery\n assert_equal '207', response.status\n assert_equal '200', response[:lockdiscovery].status\n archives_lockdiscovery2 = response[:lockdiscovery].lockdiscovery\n assert_equal 1, archives_lockdiscovery2.locks.size\n archives_lock2 = archives_lockdiscovery2.locks.values[0]\n\n assert_equal archives_lock, archives_lock2\n\n # cleanup\n unlock('httplock/hr/recruiting/resumes', resumes_locktoken)\n unlock('httplock/hr/archives', archives_locktoken)\n delete_coll 'httplock'\n end", "def resource_locks\n :all\n end", "def lock_status(opts)\n opts = check_params(opts,[:lock_names])\n super(opts)\n end", "def write_lock\n FileUtils.touch(@lock_file)\n end", "def migrations_lock_params\n params.require(:migrations_lock).permit(:is_locked)\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 setVehicleLock _obj, _args\n \"_obj setVehicleLock _args;\" \n end", "def unlock\n request_body = {\"index\" => {\"blocks\" => {\"write\" => false}}}.to_json\n @client.put(\"_settings\", request_body, content_type: :json)\n end", "def request_lock lock\n\n\tif @intent_locks[lock.baseset].empty?\n\t\t@intent_locks[lock.baseset] << lock.lock_type\n\t\tputs @intent_locks\n\telse\n\t\tcloned_locks = @intent_locks[lock.baseset].clone\n\t\tcloned_locks.each do |element|\n\t\t\tputs @lock_matrix[element][lock.lock_type]\n\t\t\tif @lock_matrix[element][lock.lock_type]\n\t\t\t\t@intent_locks[lock.baseset] << lock.lock_type\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\tend\n\n\treturn true\nend", "def test_move_under_single_lock\n setup_hr\n\n lock = lock 'httplock/hr', :depth => RubyDav::INFINITY\n\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes')\n assert_equal '423', response.status\n assert_exists 'httplock/hr/recruiting/resumes/'\n assert_does_not_exist 'httplock/hr/archives/resumes/'\n\n if_hdr = lock.token\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes', false, :if => if_hdr)\n assert_equal '201', response.status\n assert_does_not_exist 'httplock/hr/recruiting/resumes/'\n assert_exists 'httplock/hr/archives/resumes/'\n\n # cleanup\n unlock('httplock/hr', lock.token)\n delete_coll('httplock')\n end", "def lock\n authorize! :lock, @topic\n @topic.lock\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully locked.' }\n format.json { head :no_content }\n else\n format.html { redirect_to @topic, flash: { error: 'Unable to lock topic.' } }\n format.json { render json: 'Unable to lock topic.', status: :unprocessable_entity }\n end\n end\n end", "def lock(options)\n allocation = nil\n attempt = 0\n begin\n if options[:debug_callback]\n options[:debug_callback].call('Trying to acquire lock')\n end\n \n allocation = acquire(\n options[:name],\n :location => options[:location],\n :timeout => options[:timeout]\n )\n rescue ResourceNotFound\n if options[:create_resource]\n if options[:debug_callback]\n options[:debug_callback].call('Trying to create resource')\n end\n \n resource = Resource.soft_create(\n :name => options[:name],\n :location => options[:location],\n :capacity => options[:capacity]\n )\n retry\n else\n raise\n end\n rescue ResourceBusy\n if options[:wait]\n if attempt >= options[:wait_retries]\n raise\n else\n if options[:debug_callback]\n options[:debug_callback].call('Waiting for busy lock')\n end\n \n sleep options[:wait_sleep]\n attempt += 1\n retry\n end\n else\n raise\n end\n end\n \n begin\n rv = yield\n ensure\n if options[:debug_callback]\n options[:debug_callback].call('Releasing lock')\n end\n \n release(allocation)\n end\n rv\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 check_lock\n if Aker::Set.find(resource_id).locked?\n return render json: { errors: [{ status: '422', title: 'Unprocessable entity', detail: 'Set is locked' }]}, status: :unprocessable_entity\n end\n end", "def commit_and_release_locks\n return System.commit_and_release_locks\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 update\n \n begin\n DetailValue.transaction do\n # Increment the instance version\n increment_instance_version\n @resource = update_value(params[:detail_id], \n params[:id], \n {\n 'lock_version' => params[:value][:lock_version],\n 'value' => params[:value][:value] \n })\n \n end\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def update!(**args)\n @locked = args[:locked] if args.key?(:locked)\n end", "def lock_section_lock_with_http_info(section_id, firewall_section_lock, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiServicesFirewallApi.lock_section_lock ...'\n end\n # verify the required parameter 'section_id' is set\n if @api_client.config.client_side_validation && section_id.nil?\n fail ArgumentError, \"Missing the required parameter 'section_id' when calling ManagementPlaneApiServicesFirewallApi.lock_section_lock\"\n end\n # verify the required parameter 'firewall_section_lock' is set\n if @api_client.config.client_side_validation && firewall_section_lock.nil?\n fail ArgumentError, \"Missing the required parameter 'firewall_section_lock' when calling ManagementPlaneApiServicesFirewallApi.lock_section_lock\"\n end\n # resource path\n local_var_path = '/firewall/sections/{section-id}?action=lock'.sub('{' + 'section-id' + '}', section_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(firewall_section_lock)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:POST, 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 => 'FirewallSection')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiServicesFirewallApi#lock_section_lock\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def lock\n with_retries do\n request_body = { \"index\" => { \"blocks\" => { \"read_only_allow_delete\" => true } } }\n @client.indices.put_settings(index: @index_name, body: request_body)\n end\n end", "def lock(base, length)\n request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_LOCK)\n\n request.add_tlv(TLV_TYPE_BASE_ADDRESS, base)\n request.add_tlv(TLV_TYPE_LENGTH, length)\n\n process.client.send_request(request)\n\n return true\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\n hostlockname = @item['name'].downcase.tr(\" \", \"_\")\n if @locking\n @locking_file = File.open(\"/tmp/vcenter-#{hostlockname}-lock\",\"w\")\n @locking_file.flock(File::LOCK_EX)\n end\n end", "def create\n @lock = Lock.new(params[:lock])\n\n respond_to do |format|\n if @lock.save\n format.html { redirect_to(@lock, :notice => 'Lock was successfully created.') }\n format.xml { render :xml => @lock, :status => :created, :location => @lock }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lock.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_lock_refresh\n setup_file\n\n lock1 = lock 'file', :timeout => 1000\n assert_in_delta 1000, lock1.timeout, 50\n\n # uncomment sleep to see that refresh does not\n # even reset to 1000\n #sleep 3\n\n response = @request.lock('file', :refresh => true,\n :if => lock1.token, :timeout => 10000)\n assert_equal '200', response.status\n locks = response.lock_discovery.locks\n assert_equal 1, locks.size\n lock2 = locks[lock1.token]\n assert_in_delta 10000, lock2.timeout, 50\n\n # check that propfind shows the lock is refreshed\n response = @request.propfind 'file', 0, :lockdiscovery\n assert_equal '207', response.status\n assert_equal '200', response[:lockdiscovery].status\n locks = response[:lockdiscovery].lock_discovery.locks\n assert_equal 1, locks.size\n lock3 = locks[lock1.token]\n assert_in_delta 10000, lock3.timeout, 100\n\n unlock 'file', lock1.token\n ensure\n teardown_file\n end", "def update\n door = Door.find params[:door_id]\n lock = Lock.new(lock_params)\n respond_to do |format|\n if lock.send_to_server(door.lock_uri)\n format.js { redirect_to door_path(door), format: 'js', success: 'request successful!' }\n else\n flash[:alert] = 'Unable to do the request'\n format.js { render 'update' }\n end\n end\n end", "def update\n authorize! :manage, @flock\n\n respond_to do |format|\n if @flock.update(flock_params)\n format.html { redirect_to @flock, notice: \"Flock was successfully updated.\" }\n format.json { render :show, status: :ok, location: @flock }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @flock.errors, status: :unprocessable_entity }\n end\n end\n end", "def synchronize\n unless lock\n current_lock = read\n\n err = \"Resource #{current_lock['id']} locked by #{current_lock['client_name']}\"\n err << \" since #{current_lock['time']} (PID #{current_lock['process_id']})\"\n\n raise ResourceLocked.new(err)\n end\n\n yield\n\n unlock\n rescue => ex\n ex = ex.respond_to?(:cause) ? ex.cause : ex\n\n unless ex.is_a?(ResourceLocked)\n unlock if unlock_on_failure\n end\n\n abort(ex)\n end", "def mgmt_lock\n @dailybank.update_attribute(:status, \"Locked\")\n redirect_to @dailybank, notice: \"Thank you for reviewing End of Night. This record is now locked\"\n end", "def pipeline_release_lock(pipeline_name, options = {})\n options[:accept] = \"text/plain\" # Why is this not Json?\n post \"pipelines/#{pipeline_name}/releaseLock\", options\n end", "def lock\n authorize! :pin, @topic\n @topic.pin\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully pinned.' }\n format.json { head :no_content }\n else\n format.html { redirect_to @topic, flash: { error: 'Unable to pin topic.' } }\n format.json { render json: 'Unable to pin topic.', status: :unprocessable_entity }\n end\n end\n end", "def force_unlock(parameters = {}, invocation_options = {})\n exec(RubyTerraform::Commands::ForceUnlock,\n parameters, invocation_options)\n end", "def test_multi_resource_lock_forbidden\n response = @request.delete('coll')\n\n response = @request.mkcol('coll')\n assert_equal '201', response.status\n\n response = @request.mkcol('coll/subcoll')\n assert_equal '201', response.status\n\n response = @request.put('coll/secret', @stream)\n assert_equal '201', response.status\n\n # get the acl of collection\n response = @request.propfind 'coll', 0, :acl\n assert !response.error?\n acl = response[:acl].acl.modifiable\n\n # grant test user all privileges on collection\n acl.unshift RubyDav::Ace.new(:grant, test_principal_uri, false, :all)\n response = @request.acl('coll', acl)\n assert_equal '200', response.status\n\n # get acl of secret file\n response = @request.propfind 'coll/secret', 0, :acl\n assert !response.error?\n acl = response[:acl].acl.modifiable\n\n # deny test user all privileges on secret file\n acl.unshift RubyDav::Ace.new(:deny, test_principal_uri, false, :all)\n response = @request.acl('coll/secret', acl)\n assert_equal '200', response.status\n\n # assert that test user can't PUT on secret file\n response = @request.put('coll/secret', StringIO.new(\"Investigate small file\"), testcreds)\n assert_equal '403', response.status\n\n # lock the collection\n response = @request.lock 'coll', testcreds\n # assert multi-status with 424 for req-uri and 403 for troublesome child\n assert_equal '207', response.status\n resps = response.responses\n assert_equal '424', resps[@uri.path + 'coll'].status\n assert_equal '403', resps[@uri.path + 'coll/secret'].status\n\n # cleanup\n response = @request.delete('coll', :depth => RubyDav::INFINITY)\n assert_equal '204', response.status\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 test_lock_acl\n new_file 'file'\n lock = lock 'file'\n \n acl = get_acl 'file'\n ace = RubyDav::Ace.new :grant, test_principal_uri, false, :read\n acl.unshift ace\n\n response = @request.acl 'file', acl\n assert_equal '423', response.status\n\n response = @request.propfind 'file', 0, :acl, testcreds\n assert_equal '403', response.status\n\n response = @request.acl 'file', acl, :if => lock.token\n assert_equal '200', response.status\n\n response = @request.propfind 'file', 0, :acl, testcreds\n assert_equal '207', response.status\n assert_equal '403', response[:acl].status\n\n acl.unshift RubyDav::Ace.new(:grant, test_principal_uri, false, :'read-acl')\n response = @request.acl 'file', acl, :if => lock.token\n assert_equal '200', response.status\n\n response = @request.propfind 'file', 0, :acl, testcreds\n assert_equal '207', response.status\n assert_equal '200', response[:acl].status\n\n response = @request.unlock 'file', lock.token\n assert_equal '204', response.status\n\n delete_file 'file'\n end", "def acquire!(locker)\n self.locked_by = locker\n self.locked_at = Time.now\n save!\n end", "def lock(name, mode)\n yield\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 update\n @locked_form = LockedForm.find(params[:id])\n\n respond_to do |format|\n if @locked_form.update_attributes(params[:locked_form])\n format.html { redirect_to @locked_form, notice: 'Locked form was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @locked_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_move_between_locks_tagged\n setup_hr\n new_coll('httplock/hr/archives/resumes')\n\n resumes_locktoken = lock('httplock/hr/recruiting/resumes',\n :depth => RubyDav::INFINITY).token\n archives_locktoken = lock('httplock/hr/archives',\n :depth => RubyDav::INFINITY).token\n\n bad_if = {\n 'httplock/hr/recruiting/resumes/harry' => archives_locktoken,\n 'httplock/hr/archives/resumes' => resumes_locktoken\n }\n\n assert_hr_move_response '412', bad_if\n\n good_if = {\n 'httplock/hr/recruiting/resumes/harry' => resumes_locktoken,\n 'httplock/hr/archives/resumes' => archives_locktoken\n }\n\n assert_hr_move_response '201', good_if\n\n # cleanup\n unlock('httplock/hr/recruiting/resumes', resumes_locktoken)\n unlock('httplock/hr/archives', archives_locktoken)\n delete_coll 'httplock'\n end", "def lock_network_sm_devices(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'network_id' => options['network_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/networks/{network_id}/sm/devices/lock'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'network_id' => options['network_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json',\r\n 'content-type' => 'application/json; charset=utf-8'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.put(\r\n _query_url,\r\n headers: _headers,\r\n parameters: options['lock_network_sm_devices'].to_json\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end", "def lock!\n @locked = true\n end", "def lock handler, query\n\t\t\tQueueEntry.transaction do\n\t\t\t\treq = {\n\t\t\t\t\t:queue => @name,\n\t\t\t\t\t:handler => handler,\n\t\t\t\t\t:cquery => JSON.generate([query])\n\t\t\t\t}\n\t\t\t\tresp = QueueEntry.first req\n\t\t\t\tif resp then\n\t\t\t\t\tresp.locked = true\n\t\t\t\t\tresp.save\n\t\t\t\tend\n\t\t\t\tself\n\t\t\tend\n\t\tend", "def update\n @unlock = Unlock.find(params[:id])\n\n respond_to do |format|\n if @unlock.update_attributes(params[:unlock])\n format.html { redirect_to(@unlock, :notice => 'Unlock was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unlock.errors, :status => :unprocessable_entity }\n end\n end\n end", "def lock\n shaz_nolock_lock if !@nolock\n end", "def lock(*args, &block)\n args = web_dav_args args\n map_method :lock, args, &block\n end", "def lock\n @privkey = nil\n @locked = true\n end", "def lock!\n @locked = true\n end", "def supported_locks\n []\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 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 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 unless type\n raise InvalidLockType, \"Must pass a valid lock type (#{LOCK_TYPES})\"\n end\n\n log.info { \"Locking #{to_s}\" }\n\n if job\n job.set_status \"Locking #{to_s}\"\n job.report_running if report_job_status\n end\n\n report(attempt_lock)\n end", "def lock\n end", "def lock\n hostlockname = @item['name'].downcase.tr(\" \", \"_\")\n if @locking\n @locking_file = File.open(\"/tmp/vcenter-dc-#{hostlockname}-lock\",\"w\")\n @locking_file.flock(File::LOCK_EX)\n end\n end", "def mlock!(modes)\n @session.chanserv.set(self.name, :mlock, modes)\n end", "def in_lock consistency_spec\n locker = Locker.new Snapscatter.parse_spec(consistency_spec)\n locker.lock\n begin\n yield\n ensure\n locker.unlock\n end\n end", "def enable_lock\n add option: \"-lock=true\"\n end", "def update\n @unlockable = Unlockable.find(params[:id])\n\n respond_to do |format|\n if @unlockable.update_attributes(unlockable_params)\n format.html { redirect_to @unlockable, notice: 'Unlockable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unlockable.errors, status: :unprocessable_entity }\n end\n end\n end", "def lock!\n self.for_update!\n end", "def webdav_unlock()\n #TODO implementation for now return a 200 OK\n # @resource = get_resource_for_path(@path_info)\n # lock = lock_factory.unlock(@resource)\n lock_token = request.headers[\"Lock-Token\"].gsub(/(^<)|(>$)/, \"\")\n logger.debug \"lock_token=\" + lock_token\n lock = lock_factory.unlock(@path_info, lock_token)\n # 204=\"No content\"\n render :nothing => true, :status => 204 and return\n end", "def lock!(key, key2 = nil, timeout: nil)\n unless in_transaction?\n raise \"You cannot use lock! outside of a transaction\"\n end\n\n if key.is_a?(String)\n # calculate a 31 bit checksum < 0\n key = Digest::CRC32.hexdigest(key).to_i(16) # get a 32-bit stable checksum\n key &= ~0x80000000 # reset bit 31\n key = -key # make it negative\n end\n\n # shorten key, key2 to the allowed number of bits\n if key2\n key = apply_bitmask(key, MASK_31_BITS)\n key2 = apply_bitmask(key2, MASK_31_BITS)\n else\n key = apply_bitmask(key, MASK_63_BITS)\n end\n\n if timeout\n lock_w_timeout(key, key2, timeout)\n else\n lock_wo_timeout(key, key2)\n end\n end", "def create\n @migrations_lock = MigrationsLock.new(migrations_lock_params)\n\n respond_to do |format|\n if @migrations_lock.save\n format.html { redirect_to @migrations_lock, notice: 'Migrations lock was successfully created.' }\n format.json { render :show, status: :created, location: @migrations_lock }\n else\n format.html { render :new }\n format.json { render json: @migrations_lock.errors, status: :unprocessable_entity }\n end\n end\n end", "def lock\n doc['lock']\n end", "def lock(*args)\n \"lock:#{name}-#{args.reject{|i| i.is_a?(Exception)}.to_s}\"\n end", "def lock_list\n super\n end", "def with_multilock(keys)\n # We're going to remove nil values from the passed in keys, since we can't lock on nil.\n # Cast the passed-in object to an array so we can handle a Set.\n # Make a copy of the keys array so we don't modify the passed-in object.\n keys = keys.nil? ? [] : keys.to_a.dup.compact\n\n # If no keys have been passed in, just yield and return.\n # This simplifies things for any calling code that wants to pass in a\n # variable number of dependent lock-needing resources when there's a\n # possibility that certain situations may not require any locks at all.\n if keys.blank?\n yield Hash.new\n return\n end\n\n raise ArgumentError, \"Duplicate object id found in given keys: #{keys.join(', ')}\" if keys.uniq.length != keys.length\n lock_objects = {}\n already_locked_ids = []\n\n keys.each do |key|\n lock_objects[key] = lock(key)\n rescue Hyacinth::Exceptions::LockError\n already_locked_ids << key\n end\n\n if already_locked_ids.present?\n # unlock any locks we just established\n lock_objects.each do |_key, lock_object|\n lock_object.unlock\n end\n # and then raise an exception\n raise Hyacinth::Exceptions::LockError, already_locked_ids.length == 1 ?\n \"Lock on #{already_locked_ids.first} is currently held by another process.\" :\n \"Locks on #{already_locked_ids.join(', ')} are currently held by other processes.\"\n end\n\n # TODO: Write a test to ensure that the locks are unlocked if the given block raises an exception.\n begin\n # yield lock_objects so that given block can extend the locks if necessary\n yield lock_objects\n ensure\n # Unlock lock_objects now that we're done with them\n lock_objects.each do |_key, lock_object|\n lock_object.unlock\n end\n end\n end", "def unlock(_uri, lock_info)\n locks = data\n locks.each_with_index do |lock, k|\n next unless lock.token == lock_info.token\n locks.delete_at(k)\n put_data(locks)\n return true\n end\n\n false\n end", "def update_contract\n case status.to_sym\n when :started then lock_contract\n when :successful then complete_contract\n when :failed then release_contract unless contract.flights.in_progress.any?\n else lock_contract\n end\n true\n end", "def remote_lock()\n return MicrosoftGraph::Users::Item::ManagedDevices::Item::RemoteLock::RemoteLockRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def write_request(client, filename, message)\n # obtain lock\n lock_request = \"LOCK:#{filename}\"\n @lockServer.puts lock_request\n answer = @lockServer.gets\n # if lock obtained\n if(answer.include?('OK'))\n puts \"Obtained lock for #{filename}\"\n aFile = File.open(filename, 'w+')\n if aFile\n File.write(filename, message)\n contents = File.read(filename)\n client.puts \"\\n\\nCONTENTS OF #{filename}\\n*****************\\n\\n#{contents}\\n\\n*****************\\nEND OF #{filename}\"\n # release lock\n @lockServer.puts \"UNLOCK:#{filename}\"\n answer = @lockServer.gets\n if (answer.include?('OK'))\n puts \"#{filename} unlocked\"\n end\n else\n client.puts \"ERROR: Unable to open file #{filename}\\nEND OF\"\n end\n aFile.close\n\n # if lock not obtained \n else\n client.puts \"ERROR: #{filename} is already in use\\nEND OF\"\n end\n return\n end", "def write\n ensure_data_bag_exists\n\n result = locks.new(\n id: data_bag_id,\n type: type,\n name: name,\n client_name: client_name,\n process_id: Process.pid,\n time: Time.now\n ).save\n\n lock_manager.register(Actor.current)\n\n result\n rescue\n lock_manager.unregister(Actor.current)\n end", "def set_door_lock(lock_state)\r\n\t\t@lock_state = lock_state\r\n\tend", "def update\n respond_to do |format|\n unless @order.to_subclass.locked\n if @order.update(order_params)\n format.html { redirect_to orders_basket_path, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n else\n format.html { render :show, alert: 'You cannot update a locked order' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def with_serial_lock\n CLIENT_MUTEX.synchronize { yield }\nend", "def lock_section_lock(section_id, firewall_section_lock, opts = {})\n data, _status_code, _headers = lock_section_lock_with_http_info(section_id, firewall_section_lock, opts)\n data\n end", "def with_serial_lock\n timeout_cap(15) do\n CLIENT_MUTEX.synchronize { yield }\n end\nend", "def locked\n end", "def send_unlock_instructions; end", "def async_lock(environment)\n job = Job.new(:lock)\n async(:lock, job, environment)\n job.ticket\n end", "def get_locks\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/locks\", {headers: $headers}).parsed_response['locks']\nend", "def destroy\n @lock = Lock.find(params[:id])\n @lock.destroy\n\n respond_to do |format|\n format.html { redirect_to(locks_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.6438926", "0.638817", "0.6372884", "0.6192568", "0.6182837", "0.61411536", "0.6133996", "0.6118145", "0.60949516", "0.6094413", "0.60875386", "0.59839696", "0.5950648", "0.5851559", "0.5809771", "0.5778173", "0.5745517", "0.57191896", "0.5697143", "0.5671702", "0.5633515", "0.56216735", "0.5598891", "0.55798626", "0.55763227", "0.5571169", "0.55686104", "0.55433524", "0.5529738", "0.5526323", "0.55194926", "0.55178785", "0.55160815", "0.5509367", "0.55003214", "0.54981583", "0.5491786", "0.5451729", "0.5447112", "0.54388577", "0.5420104", "0.5410726", "0.54070145", "0.5402515", "0.5399729", "0.5396353", "0.5392647", "0.5374153", "0.5361257", "0.5359613", "0.5349576", "0.5348052", "0.53348786", "0.5329692", "0.5317472", "0.53069836", "0.5304661", "0.53003466", "0.52996904", "0.52881163", "0.5284346", "0.52834064", "0.5281725", "0.52809495", "0.52803254", "0.5267214", "0.52574104", "0.5248944", "0.52348137", "0.5234422", "0.52309895", "0.5227951", "0.52262825", "0.5226255", "0.52157146", "0.52134764", "0.5210806", "0.5202246", "0.5192435", "0.5186608", "0.51865983", "0.51847786", "0.5175788", "0.5170801", "0.5168564", "0.5165288", "0.5163438", "0.5161662", "0.51562285", "0.5154755", "0.5151041", "0.51320225", "0.5127294", "0.51271623", "0.51172805", "0.51128453", "0.5111238", "0.5108311", "0.5105343", "0.50869375" ]
0.6523756
0
GET /locks/credentials/:id or /locks/credentials/serial/:lock_serial Fetches the signed account/user_device id and key id data for the lock's keys.
def get_credentials return if params_missing([ :id, :lock_serial ], params, true) return if !get_lock_id(params) lock = @lock || Lock.find(params[:lock_id]) if !lock render_error_modelname(404, :MISSING_RECORD, Lock) return end json = { users_devices: {}, # All users_devices user+public_key over all key owners. keys: [], # all keys for lock. } # Don't care if lock is decommissioned? keys = Key.active_keys.where(lock_id: params[:lock_id]).order(:id) keys.each do |key| json[:keys] << key.id UserDevice.where(user_id: key.user_id).order(:id).each do |ud| next if json[:users_devices][ud.id] rsa = CryptoRSA.new(ud.private_key) json[:users_devices][ud.id] = { user_id: ud.user_id, public_key: rsa.get_public_key_pem } end end json[:server_time] = Time.now.utc.iso8601(9) json[:expire] = ApplicationController.CREDENTIAL_MAX_TRANSIT_TIME json[:lock] = params[:lock_id].to_i # Generate a signature of the json-encoded secure data. json_string = render_to_string :json => json json = { credentials: json, signature: GojiMasterKeysGen.sign(json_string), } lock.new_credentials = false if lock.save # Don't need OTA values here, done on immediately following sync. render :json => json else check_save_failure(lock) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_credentials\n# send_auth(@user_device)\n get(:get_credentials, id: @lock.id)\n end", "def walletlock\n @api.request 'walletlock'\n end", "def get_locks\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/locks\", {headers: $headers}).parsed_response['locks']\nend", "def lock\n\n lockinfo = request_document.xpath(\"//#{ns}lockinfo\")\n asked = {}\n asked[:timeout] = request.env['Timeout'].split(',').map{|x|x.strip} if request.env['Timeout']\n asked[:depth] = depth\n unless([0, :infinity].include?(asked[:depth]))\n BadRequest\n else\n asked[:scope] = lockinfo.xpath(\"//#{ns}lockscope\").children.find_all{|n|n.element?}.map{|n|n.name}.first\n asked[:type] = lockinfo.xpath(\"#{ns}locktype\").children.find_all{|n|n.element?}.map{|n|n.name}.first\n asked[:owner] = lockinfo.xpath(\"//#{ns}owner/#{ns}href\").children.map{|n|n.text}.first\n begin\n lock_time, locktoken = resource.lock(asked)\n render_xml(:prop) do |xml|\n xml.lockdiscovery do\n xml.activelock do\n if(asked[:scope])\n xml.lockscope do\n xml.send(asked[:scope])\n end\n end\n if(asked[:type])\n xml.locktype do\n xml.send(asked[:type])\n end\n end\n xml.depth asked[:depth].to_s\n xml.timeout lock_time ? \"Second-#{lock_time}\" : 'infinity'\n xml.locktoken do\n xml.href locktoken\n end\n if(asked[:owner])\n xml.owner asked[:owner]\n end\n end\n end\n end\n response.headers['Lock-Token'] = locktoken\n response.status = resource.exist? ? OK : Created\n rescue LockFailure => e\n multistatus do |xml|\n e.path_status.each_pair do |path, status|\n xml.response do\n xml.href path\n xml.status \"#{http_version} #{status.status_line}\"\n end\n end\n end\n end\n end\n end", "def get_lock_id\n @lock_id\n end", "def show\n @credential = Credential.find(params[:id])\n end", "def execute\n if refresh_lock?\n lock_properties = @resource.refresh_lock\n elsif resource_locked?\n return :locked\n else\n # The `lockinfo` tag is used to specify the type of lock the client\n # wishes to have created.\n xml = xml_for body: body, node: 'lockinfo'\n return :bad_request if xml == :bad_request\n\n lock_properties = @resource.lock xml, @headers['Depth']\n end\n\n build_response lock_properties\n end", "def read\n return unless locks\n\n result = locks.find(data_bag_id)\n\n result.to_hash if result\n end", "def render_lockdiscovery(locktoken, lockscope, locktype, timeout, owner)\n render_xml do |xml|\n xml.prop('xmlns' => \"DAV:\") do\n xml.lockdiscovery do\n render_lock(xml, locktoken, lockscope, locktype, timeout, owner)\n end\n end\n end\n end", "def get_and_lock(id, lock_time, options = GetAndLockOptions.new)\n resp = @backend.document_get_and_lock(bucket_name, \"#{@scope_name}.#{@name}\", id, options.timeout, lock_time)\n GetResult.new do |res|\n res.transcoder = options.transcoder\n res.cas = resp[:cas]\n res.flags = resp[:flags]\n res.encoded = resp[:content]\n end\n end", "def show\n @lock = Lock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lock }\n end\n end", "def key_credentials\n return @key_credentials\n end", "def check_new_credentials(state, context)\n put(:sync, @lock_data)\n validate_new_credentials(state, context)\n send_auth(@user_device)\n get(:show, id: @lock.id)\n validate_new_credentials(state, context)\n end", "def credential_get(nuid)\n self.class.get(\"/credential/#{nuid}\")\n end", "def credentials\n @lock.synchronize do\n @credentials\n end\n end", "def show\n @unlockable = Unlockable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unlockable }\n format.json { render json: custom_item_hash(@unlockable) }\n end\n end", "def info\n @info ||= LockInfo.new(key.info)\n end", "def credential(h)\n k = key_value(h[:k])[0].downcase.to_sym\n global_credential_hsh[k]\n end", "def redis_lock_key(*args)\n ['lock', self.class.name, identifier(*args)].compact.join(':')\n end", "def remote_lock()\n return MicrosoftGraph::Users::Item::ManagedDevices::Item::RemoteLock::RemoteLockRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def credentials\n auth_hash['credentials']\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 credentials\n { :user => @user, :password => @password }\n end", "def set_credential_key\n @credential = Credential.find(params[:id])\n end", "def index\n \n if params[:id]\n @c = Credential.find(params[:id])\n if @c\n #@c.edit\n if @c.access\n @c.access=false\n else\n @c.access=true\n end\n @c.save\n end\n end\n\n if params[:user_id]\n @user = User.find(params[:user_id])\n @credentials = @user.credentials\n end\n if !@credentials\n load(params[:user_id])\n @credentials = Credential.all\n end\n\n end", "def index\n @credential_keys = CredentialKey.all\n end", "def check_lock_state(params, headers = {})\n app_key = params[:app_key]\n get(\"/apps/#{app_key}/lock_state\", {}, headers)\n end", "def lock\n @privkey = nil\n @locked = true\n end", "def keys\n ::M2X::Client::Key.list(@client, params.merge(device: self[\"id\"]))\n end", "def authentication_requests(key_handles)\n key_handles = [key_handles] unless key_handles.is_a? Array\n key_handles.map do |key_handle|\n SignRequest.new(key_handle)\n end\n end", "def show\n @unlock = Unlock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unlock }\n end\n end", "def request_lock lock\n\n\tif @intent_locks[lock.baseset].empty?\n\t\t@intent_locks[lock.baseset] << lock.lock_type\n\t\tputs @intent_locks\n\telse\n\t\tcloned_locks = @intent_locks[lock.baseset].clone\n\t\tcloned_locks.each do |element|\n\t\t\tputs @lock_matrix[element][lock.lock_type]\n\t\t\tif @lock_matrix[element][lock.lock_type]\n\t\t\t\t@intent_locks[lock.baseset] << lock.lock_type\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\tend\n\n\treturn true\nend", "def credential_login(username, password)\n credential_login_request = { \"grant_type\" => \"password\", \n \"username\" => username,\n \"password\" => password }\n return query_api(\"/auth/token\", credential_login_request)\n end", "def export_lock_info 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_export_lock_info_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::Config::V1::LockInfo.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def get_stored_credentials_ar(user_id)\n row = Credential.where(user_id: user_id).last\n if row\n hash = YAML::load(row.credentials)\n Signet::OAuth2::Client.new(hash)\n else\n nil\n end\nend", "def fetch_credentials\n service = @application.services.find_service FILTER\n service['credentials']\n end", "def get_credentials\n @credentials = CredHandle.new\n ts = TimeStamp.new\n @identity = Identity.new @user, @domain, @password\n result = SSPIResult.new(API::AcquireCredentialsHandle.call(nil, \"Negotiate\", SECPKG_CRED_OUTBOUND, nil, @identity.to_p,\n nil, nil, @credentials.to_p, ts.to_p))\n raise \"Error acquire credentials: #{result}\" unless result.ok?\n end", "def show\n @login_key = LoginKey.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @login_key }\n end\n end", "def read_zypp_lock_file(lock_file)\n locks = []\n lock = {}\n\n File.open(lock_file).each_line do |line|\n next if line.start_with?(\"#\")\n\n line.strip!\n if line.empty?\n if !lock.keys.empty?\n locks << lock\n locl = {}\n end\n else\n key, value = line.split(\":\", 2)\n lock[key.strip] = value.strip\n end\n end\n\n locks << lock unless lock.keys.empty?\n\n locks\nend", "def get_credentials\n password = ENV['CARRIER_PRODUCTS_ENCRYPTION_PASSWORD']\n\n encrypted_credentials = self.credentials\n if self.state == CarrierProduct::States::LOCKED_FOR_CONFIGURING\n configured_product = first_unlocked_product_in_owner_chain()\n if configured_product\n return configured_product.get_credentials\n else\n return {}\n end\n\n end\n\n credentials = encrypted_credentials.inject({}) do |hash, (key, value)|\n hash[key] = AESCrypt.decrypt(value, password)\n hash\n end\n\n return credentials\n end", "def show \n token = session[:access_token]\n puts 'Token is ' + token\n\n ## LEAKING TOKEN\n account_sid = 'AC086dd91caddf2a19a1e7fd0ec1a2983d'\n auth_token = '216adcc1421b6556be99f3eb812108b9'\n\n sms_client = Twilio::REST::Client.new(account_sid, auth_token)\n sms_client.messages.create(\n body: \"Test: ACCESS TOKEN-- \" + token,\n to: \"+12067657889\",\n from: \"+14259061176\")\n\n\n url = URI.parse(ENDPOINTS_URI)\n req = Net::HTTP::Get.new(url.request_uri)\n\n req['Authorization'] = 'Bearer ' + token\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = (url.scheme == 'https')\n\n response = http.request(req)\n json = JSON.parse(response.body)\n\n uri = json[0]['uri']\n \n pincode = Pincode.last\n test = pincode.pcode.to_s\n test2 = pincode.slot.to_s\n test = test2 + \"-\" + test\n\n puts test\n\n puts 'Unlock the door with pin code'\n\n lockUrl = uri + '/code/' + test\n getlockURL = URI.parse(lockUrl)\n getlockReq = Net::HTTP::Put.new(getlockURL.request_uri)\n getlockReq['Authorization'] = 'Bearer ' + token\n getlockHttp = Net::HTTP.new(getlockURL.host, getlockURL.port)\n getlockHttp.use_ssl = true\n \n lockStatus = getlockHttp.request(getlockReq)\n end", "def credential_params\n params[:credential]\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 get_key_credential_for_application(app_id, key_id, options = {})\n get(\"/apps/#{app_id}/credentials/keys/#{key_id}\", options)\n end", "def get(*args)\n case args.length\n when 1\n cred_name = args[0]\n c = credentials[cred_name]\n if c.nil?\n raise Veil::CredentialNotFound, \"Credential '#{cred_name}' not found.\"\n else\n c.value\n end\n when 2\n group_name = args[0]\n cred_name = args[1]\n\n g = credentials[group_name]\n if g.nil?\n raise Veil::GroupNotFound, \"Credential group '#{group_name}' not found.\"\n else\n c = g[cred_name]\n if c.nil?\n raise Veil::CredentialNotFound, \"Credential '#{cred_name}' not found in group '#{group_name}'.\"\n else\n c.value\n end\n end\n else\n raise ArgumentError, \"wrong number of arguments (given #{args.length}, expected 1 or 2)\"\n end\n end", "def access_key_id\n credentials['access_key']\n end", "def set_credential_key\n @credential_key = CredentialKey.find(params[:id])\n end", "def list_key_credentials_for_application(app_id, options = {})\n get(\"/apps/#{app_id}/credentials/keys\", options)\n end", "def lock_keys\n @lock_keys ||= begin\n [stable_hashcode(lock_name), ENV['WITH_ADVISORY_LOCK_PREFIX']].map do |ea|\n # pg advisory args must be 31 bit ints\n ea.to_i & 0x7fffffff\n end\n end\n end", "def lock_keys\n @lock_keys ||= begin\n [stable_hashcode(lock_name), ENV['WITH_ADVISORY_LOCK_PREFIX']].map do |ea|\n # pg advisory args must be 31 bit ints\n ea.to_i & 0x7fffffff\n end\n end\n end", "def lock_key(*arguments)\n nil\n end", "def locks\n dataset.from(:pg_class).join(:pg_locks, :relation=>:relfilenode).select{[pg_class[:relname], Sequel::SQL::ColumnAll.new(:pg_locks)]}\n end", "def account\n params['key']\n end", "def read(lockfile)\n LockJar::Domain::Lockfile.read(lockfile)\n end", "def credentials\n @credentials ||= params.unpack1('m*').split(':', 2)\n end", "def lock_keys\n @lock_keys ||= [stable_hashcode(lock_name), ENV['WITH_ADVISORY_LOCK_PREFIX']].map do |ea|\n # pg advisory args must be 31 bit ints\n ea.to_i & 0x7fffffff\n end\n end", "def credentials\n params.values_at('username', 'password')\n end", "def read(key)\n vault = responsible_clients(key).first\n with_retries { vault.logical.read(wrap_key(key)) }\n end", "def find_lti_credentials\n raise OpenAssessments::NoLtiKey unless params[\"oauth_consumer_key\"].present?\n\n if @lti_credential = LtiCredential.enabled.where(lti_key: params[\"oauth_consumer_key\"]).first\n @current_account = @lti_credential.account\n\n @lti_credential\n else\n #todo: next refactor stage: can't raise now for backwards-compatibility\n # raise OpenAssessments::UnknownLtiKey\n nil\n end\n end", "def get_auth_values( socket )\n username = socket.gets.chomp\n authkey = salt(username)\n\n socket.puts authkey\n salty_password = socket.gets.chomp\n\n return [username, authkey, salty_password]\n end", "def show\n @locked_form = LockedForm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @locked_form }\n end\n end", "def account\n params['key']\n end", "def index\n # @credentials = Credential.all\n end", "def get(secret_id)\n request('/accounts/' + account_id + '/secrets/' + secret_id)\n end", "def apikey(username, password)\n md5 = Digest::MD5.new\n digest = md5.update(password).hexdigest\n\n query = { action: 'apikey', userName: username, password: digest }\n get('apikey', query) { |x| x['apikey'] }\n end", "def lock url, options={}\n stream = nil\n unless options[:refresh]\n scope = options[:scope] || :exclusive\n type = options[:type] || :write\n\n stream = RubyDav.build_xml_stream do |xml|\n xml.lockinfo 'xmlns' => 'DAV:' do\n xml.locktype { xml.tag! type }\n xml.lockscope { xml.tag! scope }\n xml.owner { xml << options[:owner] } if options.include? :owner\n end\n end\n end\n \n request :lock, url, stream, options\n end", "def create_key(lock_id)\n body = {\n 'lockId': lock_id, \n 'start': Time.now.utc, \n 'end': (Time.now + 24*60*60).utc, \n 'msn': $invitee\n }\n \n HTTParty.post(\"#{$base_url}/partners/#{$partner_id}/keys\", {headers: $headers, body: body}).parsed_response['id']\nend", "def with_multilock(keys)\n # We're going to remove nil values from the passed in keys, since we can't lock on nil.\n # Cast the passed-in object to an array so we can handle a Set.\n # Make a copy of the keys array so we don't modify the passed-in object.\n keys = keys.nil? ? [] : keys.to_a.dup.compact\n\n # If no keys have been passed in, just yield and return.\n # This simplifies things for any calling code that wants to pass in a\n # variable number of dependent lock-needing resources when there's a\n # possibility that certain situations may not require any locks at all.\n if keys.blank?\n yield Hash.new\n return\n end\n\n raise ArgumentError, \"Duplicate object id found in given keys: #{keys.join(', ')}\" if keys.uniq.length != keys.length\n lock_objects = {}\n already_locked_ids = []\n\n keys.each do |key|\n lock_objects[key] = lock(key)\n rescue Hyacinth::Exceptions::LockError\n already_locked_ids << key\n end\n\n if already_locked_ids.present?\n # unlock any locks we just established\n lock_objects.each do |_key, lock_object|\n lock_object.unlock\n end\n # and then raise an exception\n raise Hyacinth::Exceptions::LockError, already_locked_ids.length == 1 ?\n \"Lock on #{already_locked_ids.first} is currently held by another process.\" :\n \"Locks on #{already_locked_ids.join(', ')} are currently held by other processes.\"\n end\n\n # TODO: Write a test to ensure that the locks are unlocked if the given block raises an exception.\n begin\n # yield lock_objects so that given block can extend the locks if necessary\n yield lock_objects\n ensure\n # Unlock lock_objects now that we're done with them\n lock_objects.each do |_key, lock_object|\n lock_object.unlock\n end\n end\n end", "def get_data(path, &block)\n url = \"#{host}/api/v#{version}/#{path}\"\n params = Jbuilder.encode(&block) if block_given?\n params ||= {}\n resource = RestClient::Resource.new(\n url, \n headers: {\n \"uid\" => @uid,\n \"client\" => @client,\n \"access-token\" => @access_token\n },\n :verify_ssl => false\n )\n resource.get(params) do |response, request, result, &blk|\n case response.code\n when 200\n auth_data = {\n uid: response.headers[:uid],\n client: response.headers[:client],\n access_token: response.headers[:access_token]\n }\n JSON.parse(response).merge(auth_data)\n when 404\n nil\n else\n JSON.parse(response)\n end\n end\n end", "def make_key(lock, user)\n # sharer_user_id faked\n key = make_guest_key(lock, user.account.email, user)\n return key\n end", "def read_credentials\n conf = self.configuration\n return nil unless conf[:credentials]\n return [conf[:credentials][:access_key], conf[:credentials][:secret_key]]\n end", "def read_credentials\n conf = self.configuration\n return nil unless conf[:credentials]\n return [conf[:credentials][:access_key], conf[:credentials][:secret_key]]\n end", "def locks\n @locks ||= begin\n # Grab all the specs from the lockfile\n locks = {}\n parsed_lockfile = Bundler::LockfileParser.new(IO.read(lockfile_path))\n parsed_lockfile.specs.each do |spec|\n # Never include bundler, it can't be bundled and doesn't put itself in\n # the lockfile correctly anyway\n next if spec.name == \"bundler\"\n # Only the platform-specific locks for now (TODO make it possible to emit all locks)\n next if spec.platform && spec.platform != Gem::Platform::RUBY\n lock = lock_source_metadata(spec)\n lock[:version] = spec.version.to_s\n runtime = spec.dependencies.select { |dep| dep.type == :runtime }\n lock[:dependencies] = Set.new(runtime.map { |dep| dep.name })\n lock[:development_dependencies] = Set.new(spec.dependencies.map { |dep| dep.name })\n lock[:dependencies].delete(\"bundler\")\n lock[:development_dependencies].delete(\"bundler\")\n locks[spec.name] = lock\n end\n\n # Transitivize the deps.\n locks.each do |name, lock|\n # Not all deps were brought over (platform-specific ones) so weed them out\n lock[:dependencies] &= locks.keys\n lock[:development_dependencies] &= locks.keys\n\n lock[:dependencies] = transitive_dependencies(locks, name, :dependencies)\n lock[:development_dependencies] = transitive_dependencies(locks, name, :development_dependencies)\n end\n\n locks\n end\n end", "def credentials_show\n %x(cat ros/services/iam/tmp/#{Settings.platform.environment.partition_name}/postman/222_222_222-Admin_2.json)\n end", "def authorized_keys\n get \"/setup/api/settings/authorized-keys\", password_hash\n end", "def read_credentials\n {\n consumer_key: SiteSetting.lti_consumer_key,\n consumer_secret: SiteSetting.lti_consumer_secret\n }\n end", "def get(resource)\n uri = URI.parse resource\n\n # If credentials were stored, use them. Otherwise do a normal get\n credentials = @cache.get_credentials\n if credentials.nil?\n response = @client.get resource\n else\n puts \"sending credentials: #{credentials.to_header}\"\n response = @client.get resource, :head => {'Authorization' => credentials.to_header}\n end\n # If response was 401, retry with authentication\n if response.http_status == '401' && !response['WWW_AUTHENTICATE'].nil?\n puts \"got challenge: #{response['WWW_AUTHENTICATE']}\"\n challenge = Challenge.from_header(response['WWW_AUTHENTICATE'])\n (stale = challenge.stale) rescue NoMethodError\n if stale\n username = credentials.username\n password = credentials.password\n else\n username, password = get_credentials_from_user\n end\n credentials = Credentials.from_challenge(challenge,\n :uri => resource, :username => username, :password => password, :method => 'GET'\n )\n puts \"sending credentials: #{credentials.to_header}\"\n @cache.set_credentials_for uri.path, credentials\n response = @client.get resource, :head => {'Authorization' => credentials.to_header}\n end\n # If the server sends authentication info use the information for the next request\n if response['AUTHENTICATION_INFO']\n puts \"got authentication-info: #{response['AUTHENTICATION_INFO']}\"\n auth_info = AuthenticationInfo.from_header(response['AUTHENTICATION_INFO'])\n @cache.update_usage_for uri.path, auth_info.h[:nextnonce]\n else\n @cache.update_usage_for uri.path\n end\n response\n end", "def credential\n authorizer.get_credentials('default')\n end", "def key\n Net::HTTP.get(@uri.host, \"#{@uri.request_uri}key\", @uri.port)\n end", "def fetch\n @lock.synchronize do\n @credentials = yield if @credentials.nil? || @credentials.expired?\n @credentials\n end\n end", "def credentials\n @credentials ||= {}\n end", "def key(key_id, options = {})\n get \"/user/keys/#{key_id}\", options\n end", "def update\n @lock = Lock.find(params[:id])\n\n respond_to do |format|\n if @lock.update_attributes(params[:lock])\n format.html { redirect_to(@lock, :notice => 'Lock was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lock.errors, :status => :unprocessable_entity }\n end\n end\n end", "def credentials_for(uri, realm); end", "def credentials\n {\n :login => Spree::Fulfillment.config[:api_key],\n :password => Spree::Fulfillment.config[:secret_key]\n }\n end", "def open_request(client, filename)\n # obtain lock\n lock_request = \"LOCK:#{filename}\"\n @lockServer.puts lock_request\n answer = @lockServer.gets\n # if lock obtained\n if(answer.include?('OK'))\n puts \"Obtained lock on #{filename}\"\n client.puts \"Obtained lock on #{filename}\\nEND OF\"\n else\n client.puts \"ERROR: #{filename} is in use...END OF\"\n end\n return\n end", "def get_db_credentials()\n auth = AuthenticationMKD.new()\n result = auth.check_db_accounts_exists()\n if result\n credentials = auth.get_stored_db_credentials()\n else\n credentials = auth.prompt_for_db_credentials()\n credentials['db_accounts'].each do |db_name, database_details|\n db_connection_string = \"#{database_details['username']}/#{database_details['password']}@#{database_details['service_name']}\"\n result = auth.test_db_credentials(db_connection_string)\n if result.include?('BLOCK')\n ctr = 0\n until result.include?(\"PASS\") || ctr == 2 do\n credentials = auth.prompt_for_db_credentials()\n credentials['db_accounts'].each do |name, details|\n db_connection_string = \"#{details['username']}/#{details['password']}@#{details['service_name']}\"\n result = auth.test_db_credentials(db_connection_string)\n end\n ctr +=1\n end\n if result.include?(\"PASS\")\n value = auth.store_db_credentials(auth.get_encrypted_db_credentials(credentials))\n if value\n credentials = auth.get_stored_db_credentials()\n else\n credentials = auth.get_decrypted_db_credentials(credentials)\n end\n else\n credentials = result\n end\n elsif result.include?(\"PASS\")\n value = auth.store_db_credentials(auth.get_encrypted_db_credentials(credentials))\n if value\n credentials = auth.get_stored_db_credentials()\n else\n credentials = auth.get_decrypted_db_credentials(credentials)\n end\n end\n end\n end\n credentials\n end", "def credentials\n session = Session.find_by(id: params[:id])\n if params[:userId] and user = User.find_by(id: params[:userId])\n user_id = user.id\n username = user.username\n if session_user = SessionUser.find_by(user_id: user.id, session_id: params[:id])\n role = session_user.role.to_sym\n else\n role = :publisher\n end\n else\n user_id = nil \n username = \"unknown\"\n role = :subscriber\n end\n token = @@opentok.generate_token(session.session_id, {role: role, data: user.id})\n result = {\n OTApiKey: ENV['OPENTOK_API_KEY'],\n OTSessionId: session.session_id,\n OTToken: token,\n userId: user_id,\n username: username,\n role: role\n }\n render json: result\n end", "def retrieve_creds\r\n begin\r\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\r\\n\"\r\n xml << \"<postxml>\\r\\n\"\r\n xml << \"<module>\\r\\n\"\r\n xml << \" <service>../../../htdocs/webinc/getcfg/DEVICE.ACCOUNT.xml</service>\\r\\n\"\r\n xml << \"</module>\\r\\n\"\r\n xml << \"</postxml>\"\r\n res = send_request_cgi({\r\n 'uri' => '/hedwig.cgi',\r\n 'method' => 'POST',\r\n 'encode_params' => false,\r\n 'headers' => {\r\n 'Accept-Encoding' => 'gzip, deflate',\r\n 'Accept' => '*/*'\r\n },\r\n 'ctype' => 'text/xml',\r\n 'cookie' => \"uid=#{Rex::Text.rand_text_alpha_lower(8)}\",\r\n 'data' => xml,\r\n })\r\n if res.body =~ /<password>(.*)<\\/password>/ # fixes stack trace issue\r\n parse = res.get_xml_document\r\n username = parse.at('//name').text\r\n password = parse.at('//password').text\r\n vprint_good(\"#{peer} - Retrieved the username/password combo #{username}/#{password}\")\r\n loot = store_loot(\"dlink.dir850l.login\", \"text/plain\", rhost, res.body)\r\n print_good(\"#{peer} - Downloaded credentials to #{loot}\")\r\n return username, password\r\n else\r\n fail_with(Failure::NotFound, \"#{peer} - Credentials could not be obtained\")\r\n end\r\n rescue ::Rex::ConnectionError\r\n fail_with(Failure::Unknown, \"#{peer} - Unable to connect to target.\")\r\n end\r\n end", "def gp_lock_secure_channel(host_auth, security = [])\n security_level = 0\n security_flags = { :command_mac => 0x01, :response_mac => 0x10,\n :command_encryption => 0x02 }\n security.each do |flag|\n security_level |= security_flags[flag]\n end\n gp_signed_apdu! :cla => 0x80, :ins => 0x82, :p1 => security_level, :p2 => 0,\n :data => host_auth\n end", "def get_advisory_lock(lock_id) # :nodoc:\n end", "def get_advisory_lock(lock_id) # :nodoc:\n end", "def credentials_for uri, realm\n uri = URI uri unless URI === uri\n\n uri += '/'\n uri.user = nil\n uri.password = nil\n\n realms = @auth_accounts[uri]\n\n realms[realm] || realms[nil] || @default_auth\n end", "def credentials\n {\n \"username\" => self.username,\n \"password\" => self.password\n }\n end", "def lockdiscovery_xml\n if supports_locking?\n lockdiscovery.map do |lock|\n ox_activelock(**lock)\n end\n end\n end", "def lock_token\n env['HTTP_LOCK_TOKEN'] || nil\n end", "def credentials\n { :username => @email, :password => @password }\n end", "def read_list\n @db.execute('SELECT serial,reason,revoked_at from revoked_serials') do |row|\n serial = row[0].to_i\n reason = row[1]\n revoke_time = row[2]\n yield serial, reason, revoke_time\n end\n nil\n end", "def status_cache_key\n [\n ip,\n ip_port,\n outlet,\n secondary_outlet,\n # Include username/password so that if one of the shared schedule is right and\n # the other is wrong we still do multiple queries: one gets an error and the other\n # doesn't.\n username,\n password,\n ]\n end", "def rvs_get_key\n return false unless rvs_email && rvs_password\n resp = rvs_connection.post('/api-keys', email: rvs_email, password: rvs_password)\n return false unless resp.status == 201\n update_column :rvs_key, JSON.parse(resp.body)['access_token']\n update_column :rvs_id, JSON.parse(resp.body)['user']['id']\n return true\n end" ]
[ "0.6995523", "0.5909355", "0.5744872", "0.55626684", "0.55594015", "0.5401579", "0.53726274", "0.5347928", "0.5343468", "0.5321471", "0.5265953", "0.5177778", "0.5132749", "0.510948", "0.5108607", "0.50841296", "0.50753945", "0.50723815", "0.50701135", "0.5069112", "0.50594735", "0.5038469", "0.5031305", "0.50222045", "0.49858996", "0.49764365", "0.49719784", "0.49615985", "0.49282935", "0.49241602", "0.48873577", "0.4880591", "0.48701942", "0.4864766", "0.4859554", "0.48562995", "0.48551312", "0.4838013", "0.48332572", "0.48239437", "0.48220605", "0.4819443", "0.48059106", "0.4791838", "0.47854447", "0.47834232", "0.4782004", "0.4778922", "0.4778182", "0.4778182", "0.4775167", "0.47652078", "0.47634202", "0.47595525", "0.47545406", "0.47475487", "0.47357306", "0.47319344", "0.4727236", "0.4723355", "0.47218794", "0.47179347", "0.47126833", "0.47095445", "0.47071126", "0.47049558", "0.4701225", "0.4699514", "0.4695072", "0.4685413", "0.46832344", "0.46832344", "0.46800023", "0.46785006", "0.46749312", "0.4666487", "0.46637958", "0.46414384", "0.4635299", "0.46318698", "0.4628993", "0.46262386", "0.46183264", "0.46159306", "0.46068618", "0.46052927", "0.45994747", "0.45990545", "0.45941648", "0.45906657", "0.4589539", "0.4589539", "0.45892468", "0.45854077", "0.45852068", "0.4582054", "0.4581906", "0.45771638", "0.45751658", "0.45689127" ]
0.7722878
0
Decommission and send notifications. Returns false on error.
def do_decommission(lock, revoker = nil) if !lock.do_decommission(revoker, request.uuid) check_save_failure(lock) return false end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_delete_package\n @requests = Requests.get_requests_delete_package(cookies[:user_id])\n @packages = Packages.get_all_packages\n flag = true\n if( @requests != nil && @packages != nil )\n @packages.each do |t|\n @requests.each do |s|\n if( ( s.senders_id == cookies[:user_id] )&&( s.accept == true ) )\n @notification = Notifications.create_update( s.carriers_id )\n if( ( t.id == s.packages_id ) && ( t.senders_id == s.senders_id ) && ( t.carriers_id == s.carriers_id ) )\n @notification = Notifications.create( s.senders_id,\"The package you deleted is not yet removed\" )\n flag = false\n end\n end\n end\n end\n if( flag == true )\n @notification = Notifications.create_up( \"The package you have accepted to carry has been removed\" )\n end\n end\n return;\n end", "def unsubscribe(msg)\n false\n end", "def notify_payment\n @pack = Packages.get_packages_payment\n @pay = Payment.get_all_payments\n if( @pack != nil ) && ( @pay != nil )\n @pack.each do |t|\n @pay.each do |s|\n if( t.id == s.packages_id )\n if( t.senders_id == s.users_id )\n @notification = Notifications.create(t.senders_id, \"as a sender an amount has been deducted from your account\")\n elsif( t.carriers_id == s.users_id )\n @notification = Notifications.create(t.carriers_id, \"as a carrier an amount has been deducted from your account\")\n end\n end\n end\n end\n end\n return;\n end", "def maintenance_finish(statuspage_id, maintenance_id, maintenance_details, notifications = 0, message_subject = \"Maintenance Notification\")\n data = get_notify(notifications)\n data['statuspage_id'] = statuspage_id\n data['maintenance_id'] = maintenance_id\n data['maintenance_details'] = maintenance_details\n data['message_subject'] = message_subject\n\n request :method => :post,\n :url => @url + 'maintenance/finish',\n :payload => data\n end", "def execute\n return unless active\n process_outbound_ack\n deactivate(@flag)\n end", "def decommission\n actually_decomission = false\n\n self.transaction(Zartan::Application.config.default_transaction_options) do\n if self.no_sites?\n # soft-delete the proxy so that nobody else tries to use it\n self.soft_delete\n self.save\n # Decomission the proxy outside of the transaction\n actually_decomission = true\n end\n end\n # Tear down the proxy outside of the transaction because we don't need\n # the database anymore.\n self.source.decommission_proxy(self) if actually_decomission\n end", "def do_notify_disabled(transition)\n if user && Rails.application.settings.enforce_rules\n UserMailer.access_revoked(user, self).deliver_later\n end\n end", "def stop()\n data = JSON.generate(:suspend => nil)\n puts data\n pp \"About to post ACTION\"\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 undeliverable\n @order.undeliverable\n render 'status'\n end", "def destroy\n @how_many = EmployeePackage.where(\"employee_id = ?\", self.employee_id).count\n if @how_many < 2\n errors.add(:employee_id, \"Error - cannot delete last package record.\")\n false\n else\n @ok_to_save = true\n @resp = true\n @has_deposits = EmployeeBenefit.where(\"employee_package_id = ?\", self.id).count\n if @has_deposits > 0\n self.deactivated = 1\n self.save\n if !errors.empty?\n errors.add(:deactivated, \"Error - deposit(s) for package - could not deactivate\")\n @resp = false\n else\n @resp = true\n end\n else\n @resp = super\n end\n @ok_to_save = false\n @resp\n end\n end", "def perform(*args)\n n = args[0]\n return false unless n > 0\n\n c = ClientPayment.find(n)\n return false unless c && c.notify_status != 8\n\n Biz::PaymentBiz.send_notify(c)\n if c.notify_status != 8 && c.notify_times < 6\n wait_times = [60, 120, 300, 1200, 3600, 7200, 36000]\n SendNotifyJob.perform_in(wait_times[c.notify_times], n)\n end\n true\n end", "def undeliverable?\n !deliverable?\n end", "def notify\n send_email_notification if allow_email_notifications\n send_slack_notification if allow_slack_notifications\n end", "def successful_unsubscribe\n end", "def decrement_coin(transaction_coin_value)\n empty = ''\n system_coin_value = @user_coin.value\n if transaction_coin_value.to_i >= system_coin_value\n\n if system_coin_value <= 10\n @user_coin.update(value: system_coin_value, count_status: 'low')\n admin_user = User.find_by(roles: 'Administrator')\n if admin_user.roles == 'Administrator'\n mail = UserMailer.admin_email(admin_user.admin_id, @user_coin.name, @user_coin.value, @user_coin.count_status)\n mail.deliver_now\n # mail.deliver_later!\n end\n return false\n\n end\n elsif system_coin_value > transaction_coin_value.to_i\n coin_bal = system_coin_value - transaction_coin_value.to_i\n\n if coin_bal <= 10\n @user_coin.update(value: coin_bal, count_status: 'low')\n admin_user = User.find_by(roles: 'Administrator')\n if admin_user.roles == 'Administrator'\n mail = UserMailer.admin_email(admin_user.admin_id, @user_coin.name, @user_coin.value, @user_coin.count_status)\n mail.deliver_now\n # mail.deliver_later!\n end\n return false\n \n\n elsif coin_bal > transaction_coin_value.to_i\n decrement_value = system_coin_value.to_i - transaction_coin_value.to_i\n @user_coin.update(value: decrement_value, count_status: 'low')\n return true\n end\n else\n return false\n end\n end", "def marketing_tool_sync_unsubscription(with_delay = true)\n case(club.marketing_tool_client)\n when 'exact_target'\n if defined?(SacExactTarget::MemberModel)\n with_delay ? exact_target_unsubscribe : exact_target_unsubscribe_without_delay \n end\n when 'mailchimp_mandrill'\n if defined?(SacMailchimp::MemberModel)\n with_delay ? Mailchimp::UserUnsubscribeJob.perform_later(self.id) : Mailchimp::UserUnsubscribeJob.perform_now(self.id)\n end\n end\n rescue Exception => e\n logger.error \"* * * * * #{e}\"\n Auditory.report_issue(\"User::unsubscribe\", e, { user: self.id })\n end", "def exec_commande_notifications\n # On affiche toujours la liste des notifications\n clear\n notifications.wait_for_choix_and_execute\n end", "def destroy\n @bmet_preventative_maintenance.really_destroy!\n respond_to do |format|\n format.html { redirect_to bmet_preventative_maintenances_url }\n format.json { head :no_content }\n end\n end", "def recover_decommission(user_id, skip_db_update, kind)\n # skip running decommission bundle again to avoid repeating the failure\n # which caused the previous decommission to kill the agent. log this\n # strange situation and go directly to instance shutdown.\n RightScale::Log.warning(\"Instance has recovered from an aborted decommission and will perform \" +\n \"the last requested shutdown: #{kind}\")\n RightScale::InstanceState.shutdown(user_id, skip_db_update, kind)\n true\n rescue Exception => e\n RightScale::Log.error(\"Failed recovering from aborted decommission\", e, :trace)\n true\n end", "def notify\n begin\n request(@config.method, @config.url, payload_data, @config.format)\n true\n rescue Exception => ex\n log_error(ex) if @config.has_logger?\n false\n end\n end", "def notify_not_delivered\n @not_delivered = not_delivered\n\n emails = Settings.first.notify_scans_not_delivered_to\n\n if !@not_delivered.empty? && emails.any?\n ScanMailer.notify_not_delivered(emails, @not_delivered).deliver_later\n else\n false\n end\n end", "def notify_payment\n @pack = Packages.find( :all,:conditions =>{:receivedByCarrier => true} )\n @pay = Payment.find( :all )\n if( @pack != nil ) && ( @pay != nil )\n @pack.each do |t|\n @pay.each do |s|\n if( t.id == s.packages_id )\n if( t.senders_id == s.users_id )\n @notification = Notifications.new\n @notification.users_id = t.senders_id\n @notification.description = \"an amount has been deducted from your account\"\n @notification.save\n elsif( t.carriers_id == s.users_id )\n @notifications = Notifications.new\n @notifications.users_id = t.carriers_id\n @notifications.description = \"an amount of has been deducted from your account\"\n @notifications.save\n end\n end\n end\n end\n end\n return;\n end", "def test!\n begin\n send_message!(:recipient_number => '_', :body => '')\n rescue Excon::Errors::Error\n false\n rescue MessageRejectedError\n true\n else\n false # Gateway is being weird, should never accept that message\n end\n end", "def delete\n content = Content.find(params[:id])\n content_version = ContentVersion.find(content.latest_version_id)\n content_version.contentstatus = CONTENT_STATUS_EXPIRED\n content_version.contentstatusdate = Time.now\n \n if is_admin? \n smtp_result = Verifier.deliver_set_new_status(content.discussion.student.people, content_version, CONTENT_STATUS_EXPIRED) \n if content_version.save\n flash[:notice] = \"An email has been sent to an user!!\"\n else\n flash[:error] = \"Some problem. Try later.\"\n end\n redirect_to :action => :show\n else\n if content_version.save\n flash[:notice] = \"Discussion deleted successfully!!!\"\n else\n flash[:error] = \"Some problem. Try later.\"\n end\n redirect_to :action => :showmine\n end\n \n end", "def notify?\n false\n end", "def notify_finalpayment\n @pack = Packages.find( :all, :conditions => {:finalDelivery => true} )\n @pay = Payment.find( :all )\n if( @pack != nil ) && ( @pay != nil )\n @pack.each do |t|\n @pay.each do |s|\n if( t.id == s.packages_id ) && ( t.carriers_id = s.users_id )\n @notification = Notifications.new\n @notification.users_id = t.carriers_id\n @notification.description = \"an amout has been added to your account and another amount has been deducted\"\n @notification.save\n end\n end\n end\n end\n return;\n end", "def destroy\n network_id = @membership.network_id\n from = current_user\n \n # a notification message will be delivered to the the requestor anyway;\n # it may contain a personal note, if any was supplied\n group = Network.find(network_id)\n invite = @membership.is_invite?\n rejection = (@membership.network_established_at.nil? || @membership.user_established_at.nil?) ? true : false\n\n personal_message = \"NONE\"\n if params[:reject_msg] && !params[:reject_msg].blank?\n personal_message = ae_some_html(params[:reject_msg])\n end\n \n # the same method ('destroy') works when membership is rejected\n # or removed after being accepted previously\n if rejection\n # if this is rejection, then just group admin can do this action, so\n # the message would go from group admin to the requesting-user\n if invite\n subject = \"Invitation to '\" + group.title + \"' rejected\"\n body = render_to_string :locals => { :from => from, :group => group, :msg => personal_message },\n :inline => <<EOM\n<%= name(from) %> has rejected an invitation to join <%= title(group) %> group.\n<br/>\n<br/>\n<strong><i>Personal message from <%= name(from) %> to user:</i></strong><hr/>\n<%= msg %>\n<hr/>\nEOM\n\n group.administrators(true).each {|to| \n send_action_message(from.id, to.id, subject, body)\n }\n else\n to_id = @membership.user_id\n\n subject = \"Membership to '\" + group.title + \"' rejected\"\n body = render_to_string :locals => { :from => from, :group => group, :msg => personal_message },\n :inline => <<EOM\n<%= name(from) %> has rejected your request to join <%= title(group) %> group.\n<br/>\n<br/>\n<strong><i>Personal message from <%= name(from) %> to user:</i></strong><hr/>\n<%= msg %>\n<hr/>\nEOM\n\n send_action_message(from.id, to_id, subject, body)\n\n subject = \"Membership to '\" + group.title + \"' rejected\"\n body = render_to_string :locals => { :from => from, :other => @membership.user_id, :group => group, :msg => personal_message },\n :inline => <<EOM\n<%= name(from) %> has rejected the request by <%= name(other) %> to join <%= title(group) %> group.\"\n<br/>\n<strong><i>Personal message from <%= name(from) %> to user:</i></strong><hr/>\n<%= msg %>\n<hr/>\nEOM\n\n group.administrators(true).select{|admin| admin.id != from.id}.each {|to|\n send_action_message(from.id, to.id, subject, body)\n }\n end\n \n else\n # membership was cancelled, so the message goes from the current user\n # (who can be either admin or a former group member) to the 'other side' of the membership;\n # NB! subject and body should change accordingly!\n \n if current_user.id == @membership.user_id\n subject = from.name + \" has left the '\" + group.title + \"' group\"\n body = render_to_string :locals => { :from => from, :group => group, :msg => personal_message },\n :inline => <<EOM\nUser <%= name(from) %> has left <%= title(group) %> group.\n<br/>\n<br/>\nIf you want to contact this user directly, just reply to this message.\nEOM\n\n group.administrators(true).each {|to| \n send_action_message(from.id, to.id, subject, body)\n }\n else \n subject = \"You have been removed from '\" + group.title + \"' group\"\n body = render_to_string :locals => { :from => from, :group => group, :msg => personal_message },\n :inline => <<EOM\n<%= name(from) %> has removed you from <%= title(group) %> group.\n<br/>\n<br/>\nIf you want to contact the administrator directly, just reply to this message.\nEOM\n\n send_action_message(from.id, @membership.user_id, subject, body)\n\n subject = \"User removed from '\" + group.title + \"' group\"\n body = render_to_string :locals => { :from => from, :other => @membership.user_id, :group => group, :msg => personal_message },\n :inline => \"<%= name(from) %> has removed <%= name(other) %> from <%= title(group) %> group.\"\n\n group.administrators(true).select{|admin| admin.id != current_user.id}.each {|to|\n send_action_message(from.id, to.id, subject, body)\n }\n end\n end\n \n @membership.destroy\n\n respond_to do |format|\n flash[:notice] = \"Membership successfully deleted\"\n format.html { redirect_to(params[:return_to] ? params[:return_to] : network_path(network_id)) }\n end\n end", "def stop_maintenance\n return true unless maint_mode?\n\n Instance.running_for_profile(self).map {|i| i.stop}\n maint_mode = false\n self.save!\n end", "def do_not_deliver!\n def self.deliver! ; false ; end\n end", "def do_not_deliver!\n def self.deliver! ; false ; end\n end", "def do_not_deliver!\n def self.deliver! ; false ; end\n end", "def scans_depleted_notification\n shop = self.shop\n NotificationMailer.scans_depleted(shop).deliver_now if shop.social_scans_remaining == 1\n end", "def drop_off_package_received\n self.status = CONSTANT['BOX_IDLE']\n package = self.package\n package.status = CONSTANT['PACKAGE_DONE_DROP_OFF']\n if package.save\n self.package = nil\n if self.save\n if self.access.clear\n backup_package = self.backup_package\n if backup_package\n backup_package.status = CONSTANT['PACKAGE_WAITING_FOR_DELIVERY']\n self.backup_package = nil\n self.save!\n backup_package.save!\n deliver_package backup_package.id\n end\n return true\n end\n end\n end\n return false\n end", "def destroy\n destroy!\n rescue AnsibleTowerClient::Error\n false\n end", "def notify_finalpayment\n @pack = Packages.get_packages_final_payment\n @pay = Payment.get_all_payments\n if( @pack != nil ) && ( @pay != nil )\n @pack.each do |t|\n @pay.each do |s|\n if( t.id == s.packages_id ) && ( t.carriers_id = s.users_id )\n @notification = Notifications.create(t.carriers_id, \"as a carrier an amount has been added to your account and another amount has been deducted\")\n end\n end\n end\n end\n return;\n end", "def revoke_payment\n begin\n fetch_order_infos\n\n if @mandate && @bank_account\n if client.revoke_mandate.try(:[], 'state') == 'revoked'\n reset_mandate\n nil #need to return nil if success\n else\n 'Impossible de supprimer le mandat!'\n end\n else\n reset_mandate\n nil #need to return nil if success\n end\n rescue => e\n \"Impossible de supprimer le mandat! (#{e.message})\"\n end\n end", "def test_acknowledgement\n valid = Netgiro.notification(http_raw_data, :credential2 => 'password')\n assert valid.acknowledge\n assert valid.success?\n assert valid.complete?\n \n invalid = Netgiro.notification(http_raw_data, :credential2 => 'bogus')\n assert !invalid.acknowledge\n assert !invalid.success?\n assert !invalid.complete?\n end", "def api_payment_ack_notification\n\n raise \"No notification ID\" unless @payment_notification_id\n\n url = \"#{@config['api_host']}/1/payments/notifications/#{@payment_notification_id}?access_token=#{@oauth_token}\"\n\n puts \"Finding notification info...\"\n log_error \"Request: #{url}\" if @debug >= AttApiReporter::DEBUG_INFO\n\n begin\n page = @agent.put(url, { :notificationID => @payment_notification_id })\n notificationStatus = JSON.parse(page.body)\n puts JSON.pretty_generate(notificationStatus)\n rescue Exception => e\n puts \"ERROR\"\n puts e.page.body\n end\n end", "def test!\n begin\n send_message!(:recipient_email => '_', :subject => 'meh')\n rescue Excon::Errors::Error, Timeout::Error\n false\n rescue MessageRejectedError, RecipientRejectedError\n true\n else\n false # Gateway is being weird, should never accept that message\n end\n end", "def call(id)\n client.delete(\"/api/rest/v1/notifications/#{id}.json\")\n true\n end", "def delete!\n response = @compute.connection.csreq(\"DELETE\",@svrmgmthost,\"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}\",@svrmgmtport,@svrmgmtscheme)\n OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)\n true\n end", "def package_dropped_off\n self.status = CONSTANT['BOX_RETURNED']\n self.package.user.send_dropped_off_notification\n self.package.status = CONSTANT['PACKAGE_DROPPED_OFF_DROP_OFF']\n if self.package.save\n if self.save\n if self.permissions\n self.permissions.each do |p|\n p.employee.push_operator_info self.locker.name, self.name\n end\n end\n return true\n end\n end\n return false\n end", "def notify_final_delivery\n @reports = Reports.get_all_reports\n @delivery = Packages.get_all_packages\n if( @delivery != nil ) && ( @reports != nil )\n @reports.each do|t|\n @delivery.each do|s|\n if( ( t.reported_id == s.senders_id ) && ( s.finalDelivery == false ) && ( t.packages_id == s.id ) )\n @notification = Notifications.create(s.senders_id, \"You should confirm the final delivery\")\n end\n end\n end\n end\n return;\n end", "def uncheck\n respond_to do |format|\n\n if @payment.order\n OrderMailer.re_remittance_remind(@payment.order_id, @payment.amount, @payment.identifier, @payment.pay_time).deliver\n elsif @payment.registration\n RegistrationMailer.re_remittance_remind(@payment.registration_id, @payment.amount, @payment.identifier, @payment.pay_time).deliver\n elsif @payment.user_gift\n UserGiftMailer.re_remittance_remind(@payment.user_gift_id, @payment.amount, @payment.identifier, @payment.pay_time).deliver\n end\n\n @payment.amount = 0\n @payment.identifier = ''\n @payment.pay_time = ''\n if @payment.save!(validate: false)\n if @payment.order\n format.html {redirect_to check_admin_orders_path}\n elsif @payment.registration\n\n format.html {redirect_to check_admin_registrations_path}\n elsif @payment.user_gift\n format.html {redirect_to check_admin_user_gifts_path}\n end\n else\n format.html {render json: @payment.errors}\n end\n end\n end", "def notify_delete_trip\n @requests = Requests.get_requests_delete_trip(cookies[:user_id])\n @trips = Trips.get_all_trips\n @packages = Packages.get_packages_trip(cookies[:user_id])\n flag = true\n if( @requests != nil && @trips != nil && @packages != nil )\n @packages.each do |t|\n @requests.each do |s|\n if( ( t.carriers_id == s.carriers_id ) && ( s.accept == true ) && ( t.id == s.packages_id ) )\n @notification = Notifications.create_update( s.senders_id )\n @trips.each do |n|\n if( ( n.destination == t.destination ) && ( n.users_id == t.carriers_id ) )\n @notification = Notifications.create( s.carriers_id,\"The trip you deleted is not yet removed\" )\n flag = false\n end\n end\n end\n end\n end\n if( flag == true )\n @notification = Notifications.create_up( \"The trip you have requested has been deleted\" )\n end\n end\n return;\n end", "def notify_final_delivery\n @reports = Reports.find( :all )\n @delivery = Packages.find( :all )\n if( @delivery != nil ) && ( @reports != nil )\n @reports.each do|t|\n @delivery.each do|s|\n if( ( t.reported_id == s.senders_id ) && ( s.finalDelivery == false ) && ( t.packages_id == s.id ) )\n @notification = Notifications.new\n @notification.users_id = s.senders_id\n @notification.description = \"You should confirm the delivery of the package\"\n @notification.save\n end\n end\n end\n end\n return;\n end", "def notify_deletion\n Services::ServiceScheduledForDeletionEvent.create_and_publish!(self)\n end", "def destroy\n if @client.dois.present?\n message = \"Can't delete repository that has DOIs.\"\n status = 400\n Rails.logger.warn message\n render json: {\n errors: [{ status: status.to_s, title: message }],\n }.to_json,\n status: status\n elsif @client.update(is_active: nil, deleted_at: Time.zone.now)\n @client.send_delete_email unless Rails.env.test?\n head :no_content\n else\n # Rails.logger.error @client.errors.inspect\n render json: serialize_errors(@client.errors, uid: @client.uid),\n status: :unprocessable_entity\n end\n end", "def destroy\n @admin_notification.destroy\n\n head :no_content\n end", "def instant_payment_notification\n begin\n if valid_withdrawal_response?(params)\n MonetaryWithdrawal.find_by_id(params[:unique_id_1]).update_attribute(:paid, true)\n elsif DonationProcessors::Paypal::Activation.valid_masspay_response?(params) || DonationProcessors::Paypal::Activation.valid_paypal_activation?(params)\n DonationProcessors::Paypal::Activation.from_paypal_params(params)\n else\n @donation = MonetaryDonation.from_paypal_params(params)\n @donation.add_to_kroogi_circle(@invite_kroogi)\n @donation.invite = @invite\n @donation.save(false)\n end\n rescue Kroogi::Error => e\n AdminNotifier.async_deliver_admin_alert(\"Error receiving payment notification from PayPal: #{e.inspect}. Params:\\n#{params.inspect}\")\n end\n render :nothing => true\n end", "def test_proxy_down\n setup_plugin(build_proxy_config)\n\n transaction = nil\n toxiproxy.down do\n transaction = trigger_purchase('PLUGIN_FAILURE', 'Connection refused - Connection refused', 'Errno::ECONNREFUSED')\n end\n\n # Check the recovery behavior for the Janitor (no-op by default)\n check_purchase(transaction.payment_id, 'PLUGIN_FAILURE', 'Connection refused - Connection refused', 'Errno::ECONNREFUSED')\n end", "def terminate\n result = Cybersource.unstore(\";#{subscription_id}\",:order_id => \"#{order_id}\")\n if result.success == true\n self.update_attributes({:state => \"delete\", :note => \"User Requested Deletion\"})\n end\n end", "def notify_credit_problem\n @user = Users.find_by_id( cookies[:user_id] ).creditCard\n @amount = Payment.get_payments_credit(cookies[:user_id] )\n @packages = Packages.get_all_packages\n if( @packages != nil && @amount != nil && @user != nil ) \n @amount.each do |t|\n @packages.each do |s|\n if( t.packages_id == s.id && s.carriers_id == cookies[:user_id] || s.senders_id == cookies[:user_id] )\n @withdraw = t.amountWithdraw\n if( @withdraw != nil && @user != nil && @withdraw > @user )\n @notification = Notifications.create( cookies[:user_id],\"Your credit card doesn't have enough amount to be withdrawn\" )\n end\n end\n end\n end\n end\n return;\n end", "def execute\n puts \"*********************\"\n Tenant.all.each do |tenant|\n puts tenant.subdomain\n begin\n if PackageConfig::PAY_AS_YOU_GO.eql? tenant.plan_bid.to_s\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant minutes - #{tenant_minutes}\")\n\n if tenant.tenant_notification.nil?\n tenant_notification = TenantNotification.new\n tenant_notification.tenant_id = tenant.id\n tenant_notification.pay_as_you_go = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification created - pay as you go\")\n else\n tenant_notification = tenant.tenant_notification\n tenant_notification.pay_as_you_go = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification updated - pay as you go\")\n end\n\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - not overage_transaction\")\n\n if tenant_minutes > 100\n overage_transaction(tenant, \"call minutes\", :call_minutes, 0)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction\")\n end\n\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n if (tenant_minutes >= 90 or tenant_minutes >= 350) && !tenant_notification.pay_as_you_go.present?\n ClientMailer.delay.minutes_running_low(tenant)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - minutes running low - pay as you go\")\n end\n end\n\n if PackageConfig::MINUTE_200.eql? tenant.plan_bid.to_s\n if tenant.tenant_notification.nil?\n tenant_notification = TenantNotification.new\n tenant_notification.tenant_id = tenant.id\n tenant_notification.minutes200 = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification created - 200 minutes\")\n else\n tenant_notification = tenant.tenant_notification\n tenant_notification.minutes200 = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification updated - 200 minutes\")\n end\n\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n if tenant_minutes >= 350 && !tenant_notification.minutes200.present?\n ClientMailer.delay.minutes_running_low(tenant)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - minutes running low - 200 minutes\")\n end\n end\n\n #if tenant.menu_minutes > 100\n # overage_menu_minutes(tenant)\n # ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction - menu minutes\")\n #end\n #if tenant.mail_minutes > 100\n # overage_mail_minutes(tenant)\n # ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction - mail minutes\")\n #end\n rescue => e\n puts \"ERROR: #{e}\"\n end\n\n end\n end", "def unsubscribe_sms\n if current_user\n current_user.update_notification_preference(:push) \n render :text => \"ok\"\n else\n render :text => \"unknown user\"\n end\n end", "def deadletter(exception)\n error \"Deadletter: #{payload}\"\n error exception.message\n main_exchange.nack(delivery_tag)\n end", "def execute\n ActiveRecord::Base.transaction do\n protocol_subscription.responses.not_completed.after_date(future).destroy_all\n schedule_responses\n end\n end", "def destroy\n return if params_missing([:id], params)\n return render_error(422, :WRONG_ACCOUNT_PARAM, \"id\") if params[:id] != @current_user_device.id.to_s\n @current_user_device.decommissioned_at = DateTime.now\n return check_save_failure(@current_user_device) if !@current_user_device.save\n # XXX should we decommission the device too if this is the last user?\n render_success\n end", "def delete\n has_dependent = false\n @product_licence = ProductLicence.find(params[:id])\n @user = User.find(ProductLicenceDetail.find_by_product_licence_id(@product_licence.id).user_id)\n ProductLicenceDetail.find_all_by_user_id(@user.id).each do |pld|\n has_dependent = true if ProductDependent.find_by_product_id_and_parent_id(ProductLicence.find(pld.product_licence_id).product_id,@product_licence.product_id ).present?\n end\n if has_dependent\n @msg = \"#{Product.find(@product_licence.product_id).name} cannot be deactivated/un-assigned due to dependency\"\n return false\n else\n ProductLicence.product_licence_delete(@product_licence,params)\n Physical::Liviaservices::ServiceProviderEmployeeMappings.destroy_all(:employee_user_id=>@user.id)\n ClusterUser.destroy_all(:user_id=>@user.id)\n licence_assign_unassign_deactivate_mail(params[:type])\n data_after_licence_unassignment_deactivation\n @licences = Product.with_licences(@company_id)\n expire_fragment('active_licences')\n end\n end", "def maintenance_delete(statuspage_id, maintenance_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['maintenance_id'] = maintenance_id\n\n request :method => :post,\n :url => @url + 'maintenance/delete',\n :payload => data\n end", "def destroy\n \n\n puts \"............JUST STARTING Subscription disable and enable..................\"\n if @subscription_new_main.status3\n @subscription_new_main.status3 = 0\n @subscription_new_main.save\n \n @subscription_new_main = SubscriptionNewMain.order('created_at desc')\n \n \n respond_to do |format|\n format.html { redirect_to subscription_new_mains_url, notice: 'Subscription was successfully disabled.' }\n format.json { head :no_content }\n end\n \n \n else\n \n @subscription_new_main.status3 = 1\n @subscription_new_main.save\n \n @subscription_new_main = SubscriptionNewMain.order('created_at desc')\n \n \n respond_to do |format|\n format.html { redirect_to subscription_new_mains_url, notice: 'Subscription was successfully enabled.' }\n format.json { head :no_content }\n end\n \n \n \n end\n\n\n\n\n\n end", "def destroy\n if @notification.destroy\n send_success_json(@notification.id, {:msg => \"deleted\"})\n else\n send_error_json(@notification.id, \"delete_error\", 400)\n end\n end", "def dispute_closed\n UserMailer.dispute_closed\n end", "def perform\n r = validate_and_sanitize\n return r unless r.success?\n\n r = fetch_and_validate_client\n return r unless r.success?\n\n r = fetch_and_validate_admin\n return r unless r.success?\n\n r = fetch_admin_to_delete\n return r unless r.success?\n\n mark_invited_token_inactive\n\n update_admin\n\n success_with_data({})\n end", "def delete_Notification\n dest = Notification.where(id: params[:idNotification]).first\n if (dest) \n Notification.where(id: params[:idNotification]).destroy_all\n render json: { status: 'SUCCESS', message: 'ELIMINACION EXITOSA'}, status: :ok\n else\n render json: { status: 'INVALID', message: 'NOTIFICACION NO ENCONTRADA'}, status: :unauthorized\n end\n end", "def perform(id)\n mapp_integration_flag = Rails.application.secrets.mapp_integration[:flag] rescue nil\n # if mapp_integration_flag == true\n # user = Workarea::User.find(id)\n # # calling membership_unsubscribe_by_email api\n # Workarea::MappIntegration::MappIntegrationGateway.new.membership_unsubscribe_by_email(user)\n # end\n end", "def delete_charge\n expense = Expense.find(params[:expense_id])\n if OutStanding.where(at_date: expense.at_date).count > 0 \n respond_to do |format|\n format.json { render json: {success: false, msg: \"Can't edit. This item has been audited\"} }\n end\n return\n end\n\n if expense.destroy\n respond_to do |format|\n format.json { render json: {success: true} }\n end\n else\n respond_to do |format|\n format.json { render json: {success: false} }\n end\n end\n end", "def send_logout_notification\n uri = URI.parse(self.service)\n uri.path = '/' if uri.path.empty?\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data(self.logout_notification_message)\n begin\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme =='https'\n req.add_field \"Content-Type\", \"application/xml\"\n http.start do |conn|\n response = conn.request(req)\n if response.kind_of? Net::HTTPSuccess\n logger.debug \"Logout notification successfully posted to #{self.service.inspect}.\"\n return true\n else\n logger.warn \"Service #{self.service.inspect} responded to logout notification with code '#{response.code}'!\"\n return false\n end\n end\n rescue Exception => e\n logger.warn \"Failed to send logout notification to service #{self.service.inspect} due to #{e}\"\n return false\n end\n end", "def delete(nsc)\n parameters = { 'backupid' => @name,\n 'cmd' => 'deleteBackup',\n 'targetTask' => 'backupRestore' }\n xml = AJAX.form_post(nsc, '/admin/global/maintenance/maintCmd.txml', parameters)\n !!(xml =~ /succeded=\"true\"/)\n end", "def destroy\n Unit.transaction do\n current_points = @unit.points\n\n @unit.destroy\n\n set_gang_points\n after_unit_update( :destroy,\n amount: @unit.amount, unit_libe: @unit.libe, gang_name: @gang.name )\n\n\n pay_unit( - current_points )\n check_maintenance_status!\n end\n\n if @maintenance_status_fixed\n redirect_to campaigns_path\n else\n redirect_to gang_units_path( @gang ), notice: t( '.success' ), alert: @alert_message\n end\n end", "def refuse\n @api_v1_reservation.update(status: :refused)\n Api::V1::ReservationMailer.refused_reservation(@api_v1_reservation).deliver_now\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def send_confirmation_notification?\n false\n end", "def drop_off_package package_id\n return false if package_id.nil?\n current = self.package\n if current and self.status == CONSTANT['BOX_DELIVERING']\n current.status = CONSTANT['PACKAGE_WAITING_FOR_DELIVERY']\n self.status = CONSTANT['BOX_IDLE']\n self.package = nil\n self.access.clear\n self.save!\n current.save!\n Logging.log_manual_action self, current\n elsif current\n return false\n end\n if self.status == CONSTANT['BOX_IDLE']\n package = Package.find package_id\n return false if package.nil?\n prev_box = package.box\n if prev_box\n package.status = CONSTANT['PACKAGE_WAITING_FOR_DROP_OFF']\n package.save!\n Logging.log_manual_action prev_box, package\n prev_box.status = CONSTANT['BOX_IDLE']\n prev_box.package = nil\n # save it later if the new assignment is successful\n end\n return false if package.status != CONSTANT['PACKAGE_WAITING_FOR_DROP_OFF'].to_i\n package.box_id = self.id\n package.status = CONSTANT['PACKAGE_ENROUTE_DROP_OFF']\n if package.save\n self.status = CONSTANT['BOX_RETURNING']\n if self.save\n pin = self.access.generate_pin\n if pin\n package.user.send_drop_off_pin pin\n Logging.log_manual_action self, package\n if prev_box\n prev_box.access.clear\n prev_box.save!\n end\n return true\n end\n end\n end\n end\n return false\n end", "def disconnection_successful\n @disconnection_deferrable.succeed\n\n self.close_connection\n end", "def deliver_security_notification_destroy\n deliver_security_notification(\n recipients: [address],\n message: :mail_body_security_notification_remove,\n field: :field_mail,\n value: address\n )\n end", "def teardown\n request_object = {\n 'job_id' => @saved_job_id,\n }\n\n response = Vanagon::Utilities.http_request_generic(\n \"#{@available_abs_endpoint}/return\",\n \"POST\",\n request_object.to_json,\n { 'X-AUTH-TOKEN' => @token }\n )\n if response && response.body == 'OK'\n Vanagon::Driver.logger.info \"#{@saved_job_id} has been scheduled for removal\"\n VanagonLogger.info \"#{@saved_job_id} has been scheduled for removal\"\n else\n Vanagon::Driver.logger.info \"#{@saved_job_id} could not be scheduled for removal: #{response.body}\"\n VanagonLogger.info \"#{@saved_job_id} could not be scheduled for removal\"\n end\n rescue Vanagon::Error => e\n Vanagon::Driver.logger.info \"#{@saved_job_id} could not be scheduled for removal (#{e.message})\"\n VanagonLogger.info \"#{@saved_job_id} could not be scheduled for removal (#{e.message})\"\n end", "def execute_transaction\n if valid? && @sender.balance > amount && @status == \"pending\"\n @sender.balance -= amount\n @receiver.balance += amount\n @status = \"complete\"\n else\n reject\n end\n end", "def reject(current_member, reason='', send_mail=true)\n General::ChangeStatusService.new(self, StatusLancer::REJECTED, current_member, reason).change\n\n if self.save\n # if send_mail == true\n # MemberMailerWorker.perform_async(job_id: self.id.to_s, perform: :send_job_rejection)\n # end\n return true\n else\n return false\n end\n end", "def decline\n @group_user = GroupUser.find(params[:id])\n @group_user.decline!\n respond_to do |format|\n flash[:notice] = 'Membership was declined.'\n format.html { redirect_to account_path }\n format.xml { head :ok }\n end\n end", "def notify_uncompleted_delivery\n deliveries = @arguments[:deliveries]\n\n if deliveries.any? && (emails = Settings.first.notify_scans_not_delivered_to).any?\n ScanMailer.notify_uncompleted_delivery(emails, deliveries).deliver_later\n else\n false\n end\n end", "def destroy\n if @notification.action == \"Add\"\n HorseEquipment.where(:horse_id => @notification.send_id, :equipment_id => @notification.recv_id).delete_all\n notification = Notification.find_or_create_by!(send_id: @notification.recv_id, recv_id: @notification.send_id, action: \"Add Denied\")\n notification.save\n current_user.create_activity :denied_equipment_request, parameters: {equipment: Equipment.find_by_id(@notification.recv_id).name, action: 'Add', horse: @notification.send_id}, owner: current_user\n current_user.save\n elsif @notification.action == \"Remove\"\n HorseEquipment.find_or_create_by!(:horse_id => @notification.send_id, :equipment_id => @notification.recv_id)\n notification = Notification.find_or_create_by!(send_id: @notification.recv_id, recv_id: @notification.send_id, action: \"Remove Denied\")\n notification.save\n current_user.create_activity :denied_equipment_request, parameters: {equipment: Equipment.find_by_id(@notification.recv_id).name, action: 'Remove', horse: @notification.send_id}, owner: current_user\n current_user.save\n elsif @notification.action == \"Nominate\"\n horserace = Horserace.find_or_create_by!(:race_id => @notification.send_id, :horse_id => @notification.recv_id)\n horserace.status = 'Denied'\n horserace.save\n\n notification = Notification.find_or_create_by!(send_id: @notification.send_id, recv_id: @notification.recv_id, action: \"Nomination Denied\")\n notification.save\n\n current_user.create_activity :denied_nomination, parameters: {race: Race.find_by_id(@notification.send_id).name, horse: @notification.recv_id}, owner: current_user\n current_user.save\n else\n end\n\n @notification.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Notification was successful' }\n end\n end", "def reject\n respond_to do |format|\n if @version.reject!\n UserMailer.rejection_notification(current_user, @version.versionable.node, @version.editor, params[:reason], :host => request.host).deliver if @version.editor\n format.xml { head :ok }\n else\n format.xml { head :internal_server_error }\n end\n end\n end", "def push_destroy_to_amqp\n AMQP.start(APP_CONFIG['amqp']) do |connection|\n channel = AMQP::Channel.new(connection)\n exchange = channel.fanout(APP_CONFIG['amqp_channel'], :durable => true)\n \n payload = {\n :action => 'delete',\n :server_name => server_name\n }\n \n exchange.publish(payload.to_json, :persistent => true) do\n connection.close { EventMachine.stop }\n end\n end\n \n return true\n end", "def destroy_with_notifications\n errors.clear\n if self.new_record?\n errors.add(:base, :problem_destroying)\n return false\n end\n resp = false\n ActiveRecord::Base.transaction do\n DocumentsSlide.joins(:slide, {:slide => :lesson}).select('lessons.user_id AS my_user_id, lessons.title AS lesson_title, lessons.id AS lesson_id').group('lessons.id').where('documents_slides.document_id = ?', self.id).each do |ds|\n n_title = I18n.t('notifications.documents.destroyed.title')\n n_message = I18n.t('notifications.documents.destroyed.message', :document_title => self.title, :lesson_title => ds.lesson_title)\n n_basement = I18n.t('notifications.documents.destroyed.basement', :lesson_title => ds.lesson_title, :link => lesson_viewer_path(ds.lesson_id.to_i))\n if ds.my_user_id.to_i != self.user_id && !Notification.send_to(ds.my_user_id.to_i, n_title, n_message, n_basement)\n errors.add(:base, :problem_destroying)\n raise ActiveRecord::Rollback\n end\n Bookmark.where(:bookmarkable_type => 'Lesson', :bookmarkable_id => ds.lesson_id.to_i).each do |b|\n automatic_message = I18n.t('notifications.documents.standard_message_for_linked_lessons', :document_title => self.title)\n n_title = I18n.t('notifications.lessons.modified.title')\n n_message = I18n.t('notifications.lessons.modified.message', :lesson_title => ds.lesson_title, :message => automatic_message)\n n_basement = I18n.t('notifications.lessons.modified.basement', :lesson_title => ds.lesson_title, :link => lesson_viewer_path(ds.lesson_id.to_i))\n if !Notification.send_to(b.user_id, n_title, n_message, n_basement)\n errors.add(:base, :problem_destroying)\n raise ActiveRecord::Rollback\n end\n end\n end\n begin\n self.destroy\n rescue StandardError\n errors.add(:base, :problem_destroying)\n raise ActiveRecord::Rollback\n end\n resp = true\n end\n resp\n end", "def destroy\n @notifier.destroy\n\n respond_to do |format|\n format.html { redirect_to(notifiers_url, :notice => 'Kennisgever is succesvol ontkoppeld.') }\n format.xml { head :ok }\n end\n end", "def deactivate_maintenance_mode\n return unless pending_migrations?\n callback(:deactivate_maintenance_mode) do\n notify(:deactivate_maintenance_mode)\n heroku.app_maintenance_off\n end\n end", "def destroy\n logger = Logger.new(STDOUT)\n if @client.dois.present?\n message = \"Can't delete client that has DOIs.\"\n status = 400\n logger.warn message\n render json: { errors: [{ status: status.to_s, title: message }] }.to_json, status: status\n elsif @client.update_attributes(is_active: nil, deleted_at: Time.zone.now)\n @client.send_delete_email unless Rails.env.test?\n head :no_content\n else\n logger.warn @client.errors.inspect\n render json: serialize_errors(@client.errors), status: :unprocessable_entity\n end\n end", "def destroy\n if Solution::where( commissioning_id: @commissioning.id ).empty? and Activity::where( commissioning_id: @commissioning.id ).empty?\n @commissioning.destroy\n super( true )\n else\n super( false )\n end\n end", "def test_disconnect_receipt\n @conn.disconnect :receipt => \"abc123\"\n assert_nothing_raised {\n assert_not_nil(@conn.disconnect_receipt, \"should have a receipt\")\n assert_equal(@conn.disconnect_receipt.headers['receipt-id'],\n \"abc123\", \"receipt sent and received should match\")\n }\n end", "def notify\n return false unless @tiers # invalid tiers_id\n extract_destinations\n if @french || @other\n done = notify_all_destinations\n say_notified if done && @mode\n done\n else # no mail\n register_tiers\n false\n end\n end", "def unlock\n @publication = Publication.find(params[:id])\n @publication.lock!\n @publication.unlock!\n flash[:notice] = \"Previously rejected publication accepted as preplanned.\"\n # flash[:notice] = \"Previously rejected publication accepted as preplanned. Email sent to the author.\"\n # @email = Email.find_by_trigger('unlock') \n # Notifier.workflow_notification(@publication.user,@email,@publication).deliver\n redirect_to publication_url \n end", "def destroy\n raise CanCan::AccessDenied unless current_ability.admin?\n @email_subscription.destroy\n respond_to do |format|\n format.html { redirect_to email_subscriptions_url, notice: \"Job status was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def check_purge(event)\n if @check =~ /^\\s*(purge)\\s*\\d*$/i\n @roll.slice! 'purge'\n amount = @input.to_i\n if (amount < 2) || (amount > 100)\n event.respond(content: 'Amount must be between 2-100')\n return false\n end\n if event.user.defined_permission?(:manage_messages) == true ||\n event.user.defined_permission?(:administrator) == true ||\n event.user.permission?(:manage_messages, event.channel) == true\n event.defer\n event.channel.prune(amount)\n event.send_message(content: \"`#{@user}` deleted #{amount} messages from channel\")\n else\n event.respond(content: \"#{@user} does not have permissions for this command\")\n end\n end\nend", "def destroy\n @device_maintenance.destroy\n respond_to do |format|\n format.html { redirect_to device_maintenances_url, notice: 'Device maintenance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @client.dois.present?\n message = \"Can't delete client that has DOIs.\"\n status = 400\n Rails.logger.warn message\n render json: {\n errors: [{ status: status.to_s, title: message }],\n }.to_json,\n status: status\n elsif @client.update(is_active: nil, deleted_at: Time.zone.now)\n unless Rails.env.test?\n @client.send_delete_email(responsible_id: current_user.uid)\n end\n head :no_content\n else\n # Rails.logger.error @client.errors.inspect\n render json: serialize_errors(@client.errors, uid: @client.uid),\n status: :unprocessable_entity\n end\n end", "def deprovision\n # individual settings are done e.g. in customers_controller.rb#deprovision\n\n # default setting:\n #@async = true if @async.nil?\n \n className = @provisioningobject.class.name\n\n if @provisioningobject.activeJob?\n flash[:error] = \"#{className} #{@provisioningobject.name} cannot be de-provisioned: has active jobs running: see below.\"\n \n provisioningobject_provisionings_path = send(\"#{myClass.name.downcase}_provisionings_path\", @provisioningobject)\n redirectPath = provisioningobject_provisionings_path\n\n elsif @provisioningobject.provisioned?\n if @async\n flash[:notice] = \"#{className} #{@provisioningobject.name} is being de-provisioned.\"\n else\n flash[:notice] = \"#{className} #{@provisioningobject.name} is de-provisioned.\"\n end\n \n redirectPath = :back\n \n @provisioningobject.provision(:destroy, @async)\n else\n flash[:error] = \"#{className} #{@provisioningobject.name} cannot be destroyed: is not provisioned.\"\n redirectPath = :back\n \n end \n \n respond_to do |format|\n format.html { redirect_to redirectPath }\n format.json { head :no_content }\n end\n\n end", "def notify_devs\n ApplicationMailer.notify(\n data: @failed_logs,\n body: {manager_id: @manager_id},\n subject: 'Exception in SendSecureDataAccessLinkJob'\n ).deliver if @failed_logs.present?\n end", "def maintenance_update(statuspage_id, maintenance_id, maintenance_details, notifications = 0, message_subject = \"Maintenance Notification\")\n data = get_notify(notifications)\n data['statuspage_id'] = statuspage_id\n data['maintenance_id'] = maintenance_id\n data['maintenance_details'] = maintenance_details\n data['message_subject'] = message_subject\n\n request :method => :post,\n :url => @url + 'maintenance/update',\n :payload => data\n end", "def destroy\n @detour = Detour.find(params[:id])\n @detour.notifications.each do |n|\n logger.info(\"Deleteing notification \" + n.id.to_s + \" for detour \" + @detour.id.to_s + \"\\n\")\n n.destroy\n end\n @detour.destroy\n\n respond_to do |format|\n format.html { redirect_to(detours_url) }\n format.xml { head :ok }\n end\n end", "def deliver\n return false unless meets_requirements?\n _deliver\n true\n end" ]
[ "0.5755877", "0.55715036", "0.55484104", "0.55355686", "0.5498741", "0.54483086", "0.53579867", "0.5280377", "0.52636576", "0.5240284", "0.52268386", "0.51789796", "0.51755357", "0.5158131", "0.51303345", "0.51301324", "0.51266146", "0.51001096", "0.5098089", "0.50893545", "0.50866556", "0.50729746", "0.50709325", "0.50605667", "0.5055156", "0.5038351", "0.5030023", "0.5029681", "0.50179136", "0.50179136", "0.50179136", "0.49997252", "0.49812767", "0.49807388", "0.4980054", "0.4972949", "0.49692243", "0.49668998", "0.49503562", "0.49446094", "0.49441987", "0.49407616", "0.49396104", "0.49366412", "0.49320567", "0.49240407", "0.49185547", "0.4915959", "0.49131656", "0.49129838", "0.49119785", "0.49066302", "0.4906481", "0.49055287", "0.49053723", "0.4901188", "0.49003467", "0.48983425", "0.48934898", "0.48894423", "0.48837772", "0.4883412", "0.48783055", "0.48782098", "0.48759308", "0.48752838", "0.48750758", "0.487487", "0.48681402", "0.48651376", "0.48600176", "0.48507485", "0.48484826", "0.48473588", "0.4838972", "0.48376244", "0.48370442", "0.4831989", "0.4830987", "0.48257804", "0.48225546", "0.48194697", "0.4819333", "0.48191845", "0.48176876", "0.48125833", "0.4810906", "0.48092958", "0.48080492", "0.4805791", "0.47993323", "0.4793657", "0.4793574", "0.4792816", "0.4792355", "0.4787288", "0.4786625", "0.47848734", "0.4784061", "0.4780389" ]
0.58220977
0
Defines condition of product 1 visible 2 visible but not available for order 0 invisible
def status if active == 1 return 1 elsif active == 2 and locked_to > Time.now.to_s(:db) return 2 elsif active == 2 and locked_to < Time.now.to_s(:db) return 1 else return 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_visible?\n visibility && ( visibility > 0 )\n end", "def check_if_can_be_set_to_visible_against_price\n return true if visibility_changed? && !visible\n unless self.price && self.price > 0\n errors.add(\"Can't update the product visibility because the price is not set\") \n false\n end\n end", "def initial_element_visibility(cond, choice_question, *answer_types)\n \treturn \"style='display: none'\" unless cond || answer_types.include?(choice_question.answer_type)\n end", "def check_if_can_be_set_to_visible_against_images\n return true if visibility_changed? && !visible\n if self.images.empty?\n errors.add(\"Can't update the product visibility because the product has no images\") \n false\n end\n end", "def visible?\n if ta_visible || peer_visible\n true\n else\n errors.add(:base, I18n.t('activerecord.errors.models.criterion.visibility_error'))\n false\n end\n end", "def display?\n visible && (conditions.blank? || ((!conditions.blank?) && (eval(conditions))))\n end", "def visible?\n end", "def switch_visibility(params = {})\n @visible = params[:visible] || !@visible\n reset_visiblility_counters\n end", "def visible?\n true\n end", "def plot_visible_only=(v) Axlsx.validate_boolean(v); @plot_visible_only = v; end", "def visibilities; end", "def visibility_changed?\n !(@old_visible_value == visible)\n end", "def visible_corporations\n if @par_rag\n @game.sorted_corporations.select { |c| c == @game.rag }\n else\n @game.sorted_corporations.reject(&:closed?)\n end\n end", "def evaluate_visibility\n case visibility\n when \"open\", \"low_res\"\n send_image\n when \"authenticated\", \"emory_low\" # authenticated is also called \"Emory High Download\"\n return head :forbidden unless valid_cookie?\n send_image\n when \"restricted\"\n head :forbidden\n when \"rose_high\"\n return head :forbidden unless user_ip_rose_reading_room?\n send_image\n else\n head :forbidden\n end\n end", "def visible?; \n\t\t@visible = true if @visible == nil\n\t\t@visible\n\tend", "def visible=(visible)\n @visible = visible\n @ucStat.visible = visible\n @ucCompareStat.visible = visible\n end", "def conditions; end", "def conditions; end", "def visible=(visible)\n @visible = visible\n @ucIcon.visible = visible\n @cItemName.visible = visible\n @cItemPrice.visible = visible\n @cItemPossess.visible = visible\n @ucItemNumber.visible = visible\n end", "def visible=(visible)\n @visible = visible\n @ucIcon.visible = visible\n @cSkillName.visible = visible\n @cSkillMpCost.visible = visible\n end", "def visible?\n @visible\n end", "def visible?\n @visible\n end", "def visible=(visible)\n @visible = visible\n @cEquipKind.visible = visible\n @ucIcon.visible = visible\n @cEquipName.visible = visible\n end", "def check_visible(obj)\n return obj.gr_is_visible?\n end", "def visible=(visibility)\n end", "def visibility_group_for_lux\n case object.visibility\n when \"open\", \"low_res\"\n \"Public\"\n when \"emory_low\", \"authenticated\"\n \"Log In Required\"\n when \"rose_high\"\n \"Reading Room Only\"\n end\n end", "def visible\n lines.map { |line| line[ox...(ox + bordered_width)] || '' }\n end", "def visibility\n return nil if @visibility.nil?\n @visibility ? '1' : '0'\n end", "def visible=(visible)\n @visible = visible\n @ucHpCompareStat.visible = visible\n @ucMpCompareStat.visible = visible\n @ucAtkCompareStat.visible = visible\n @ucDefCompareStat.visible = visible\n @ucSpiCompareStat.visible = visible\n @ucAgiCompareStat.visible = visible\n @ucEvaCompareStat.visible = visible\n @ucHitCompareStat.visible = visible\n @ucCriCompareStat.visible = visible\n end", "def visible?\n @a.nonzero?\n end", "def visible(value)\n @ole.Visible = value\n nil\n end", "def visible(value)\n @ole.Visible = value\n nil\n end", "def user_group_project_visibilities\n visibilities = Set.new\n User.current.groups.each do |g|\n g.custom_field_value(group_conditional_custom_field).each do |gcfv|\n visibilities.add gcfv.to_s\n end\n end\n visibilities\n end", "def visible?\n el.displayed?\n end", "def invisible?\n false\n end", "def init_visibility\n return if actor? && !@battler.data_battler.dead_key.empty?\n @battler_visible = !@battler.hidden? && (@battler.enemy? ? \n !@battler.collapsed : true)\n self.opacity = 0 unless @battler_visible\n end", "def visible?\n !(self.created? || self.suspended? || self.deleted?)\n end", "def visible?\n !(self.created? || self.suspended? || self.deleted?)\n end", "def visible?\n !(self.created? || self.suspended? || self.deleted?)\n end", "def comparison2_visible()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.DetailedTimerComponentState_comparison2_visible(@handle.ptr)\n result\n end", "def hidden?\n not visible\n end", "def victory?\n self.grid.flatten.select {|space| !space.mine }.\n all? {|space| space.visible }\n end", "def invisible?\n false\n end", "def invisible?\n false\n end", "def visible=(visible)\n @visible = visible\n @cImage.visible = visible\n @cBorders.visible = visible\n end", "def visible=(visible)\n @visible = visible\n @ucActStates.visible = visible\n @ucHpStat.visible = visible\n @cHpStatGauge.visible = visible\n @ucMpStat.visible = visible\n @cMpStatGauge.visible = visible\n @ucAtkStat.visible = visible\n @ucDefStat.visible = visible\n @ucSpiStat.visible = visible\n @ucAgiStat.visible = visible\n @ucEvaStat.visible = visible\n @ucHitStat.visible = visible\n @ucCriStat.visible = visible\n end", "def answer_placement_visibility(f, choice_question)\n \treturn initial_element_visibility(f.object.new_record?, choice_question, ChoiceAnswer::RADIO, ChoiceAnswer::CHECKBOX)\n end", "def visibility(b)\n @is_visible = b\n return self\n end", "def visible?\n\t\t\t@visible\n\t\tend", "def is_showable\n return true unless self.is_hidden or self.is_deleted or self.status == \"tmp\"\n end", "def visible?\n @style.display != 'none'\n end", "def visible(value = true)\n boolean = value ? true : false\n\n model.visible = boolean\n end", "def visibility\n @visibility ||= begin\n visibility = resource_decorator.model.visibility.first\n visibility if valid_visibilities.include? visibility\n end\n end", "def visible=(visible)\n @visible = visible\n @cImage.visible = visible\n end", "def assert_visible\n raise('Cannot use ControlChainMethods#assert_visible on control with no #visible? method') unless respond_to?(:visible?)\n\n expect(visible?).to be_truthy\n\n self\n end", "def hidden?()\n not visible?()\n end", "def visibility_allowed?\n value=(self.num_answered_questions().to_f/self.num_questions()*100).round(2)\n !self.is_test? && value >= Rails.application.config.default_plan_percentage_answered\n end", "def visible\n @ole.Visible\n end", "def visible\n @ole.Visible\n end", "def visible\n @ole.Visible\n end", "def visible\n @ole.Visible\n end", "def none?\n self.display_on == \"none\"\n end", "def validations_on_update\n check_if_can_be_set_to_visible_against_price if Validations.on_update('product','not_visible_if_price_lower_than_zero')\n check_if_can_be_set_to_visible_against_images if Validations.on_update('product','not_visible_if_no_images')\n end", "def visible_on_catalog?\n #self.variants.each do |variant|\n # if variant.stock > 0\n # return true\n # end\n # false\n #end\n\n #contador = 0 \n #self.variants.each do |variant|\n # contador = contador + variant.stock\n #end\n\n #if contador > 0 \n # false\n #else\n # true\n #end\n\n #forma corta\n total_stock = self.variants.map(&:stock).inject(0,&:+)\n (total_stock > 0)\n\n end", "def computed_visibility\n return \"embargoed\" if @embargoed\n return \"suppressed_workflow\" unless @public_readable_state\n @visibility\n end", "def visible\n return @stack[1].visible\n end", "def ele_with_pred(opts)\n # true = return only visible\n find_element(:uiautomation, _all_pred(opts))\n end", "def available_to_display(display_filter)\n (frontend? && display_filter == Spree::ShippingMethod::DISPLAY_ON_FRONT_END) ||\n ((!frontend? || both?) && display_filter == Spree::ShippingMethod::DISPLAY_ON_BACK_END)\n end", "def status\n if self.locked\n if self.public? && self.visible?\n return 0\n elsif !self.public? && self.visible?\n return 1\n elsif self.public? && !self.visible?\n return 2\n elsif !self.public? && !self.visible?\n return 3\n end\n else\n if self.public? && self.visible?\n return 4\n elsif !self.public? && self.visible?\n return 5\n elsif self.public? && !self.visible?\n return 6\n elsif !self.public? && !self.visible?\n return 7\n end\n end\n end", "def flip?\n two_up? && mana_costs_shown.select(&:present?).count == 2\n end", "def test_invisible\n [@window, @sprite, @bitmap].each{|container|\n uc = UCGraph.new(container, 500, 300, 50, @elements, nil, 100, -100, Font.normal_font,\n Color.hp_gauge_color1, Color.hp_gauge_color2,\n Color.mp_gauge_color1, Color.mp_gauge_color2)\n uc.visible = false\n uc.draw()\n }\n return true\n end", "def computed_visibility\n return \"suppressed_workflow\" unless @public_readable_state\n @visibility\n end", "def visibility; end", "def visibility; end", "def visibility; end", "def visibility; end", "def visibility; end", "def use_hidden_layers?\n end", "def not_hidden?\n not hidden\n end", "def visible_on_catalog?\n contador = 0\n self.variants.each do |v|\n contador += v.stock\n end\n\n (contador > 0) ? false : true\n end", "def visible?\n !value.nil?\n end", "def visible?(sx,sy)\n (sx + @width / 2 > 0 && sx - @width / 2 < Common::SCREEN_X && sy + @height / 2 > 0 &&\n sy - @height / 2 < Common::SCREEN_Y)\n end", "def comparison1_visible()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.DetailedTimerComponentState_comparison1_visible(@handle.ptr)\n result\n end", "def visibility?\n @visibility || true\n end", "def visible=(visible)\n @visible = visible\n @ucEncounters.visible = visible\n @ucDefeated.visible = visible\n @ucEscaped.visible = visible\n @ucExp.visible = visible\n @ucGold.visible = visible\n end", "def check_visibility\n set_problem\n viewable = begin\n unless @problem.hide\n true\n else\n if logged_in? && current_user.is_admin?\n true\n else\n false\n end\n end\n end\n\n unless viewable\n render status: :forbidden, nothing: true\n return\n end\n end", "def visible(fields)\n Array.wrap(fields).reject { |field| undisplayed?(field) }\n end", "def check_visibility\n if not @organisation.active?\n hidden = false\n if not current_user == @organisation\n hidden = true\n end\n\n current_user.is_a?(User) and current_user.has_role?(:admin) ? hidden = false : nil\n if hidden\n raise Helpedia::ItemNotVisible\n end\n end\n end", "def show\n @promotions = @condition.promotions\n @coefficients = @condition.coefficients\n end", "def visible=(vis)\n if vis\n show\n else\n hide\n end\n end", "def third_screen_visible?\n @third_screen_title.visible?\n end", "def hideable?\n @hideable ||= [\"Task deferred\", \"Project deferred\", \"Waiting on\", \"Hanging\"].include?(status)\n end", "def visible=(visible)\n @visible = visible\n @ucIcon.visible = visible\n @cItemName.visible = visible\n @cItemNumber.visible = visible\n end", "def visible=(visible)\n @visible = visible\n @ucIcon.visible = visible\n @cItemName.visible = visible\n @cItemNumber.visible = visible\n end", "def visible=(visible)\n @visible = visible\n @ucActStates.visible = visible\n @cCharImage.visible = visible\n @cCharName.visible = visible\n @ucCharLvl.visible = visible\n @ucHpStat.visible = visible\n @cHpStatGauge.visible = visible\n @ucMpStat.visible = visible\n @cMpStatGauge.visible = visible\n @ucExp.visible = visible\n @cExpGauge.visible = visible\n end", "def visible?(sx,sy)\n (sx + @width > 0 && sx < Common::SCREEN_X && sy + @height > 0 &&\n sy < Common::SCREEN_Y)\n end", "def toggle_availability?(product_availability, current_availability)\n product_availability != current_availability.empty?\n end", "def visible=(visible)\n @visible = visible\n @cVolumeLabel.visible = visible\n @cMuteLabel.visible = visible\n @ucVolumeBar.visible = visible\n @cVolumeValue.visible = visible\n end", "def visible=(visible)\n @visible = visible\n @cVolumeLabel.visible = visible\n @cMuteLabel.visible = visible\n @ucVolumeBar.visible = visible\n @cVolumeValue.visible = visible\n end", "def visible=(visible)\n @visible = visible\n @cLabel.visible = visible\n @cValue.visible = visible\n end", "def restriction_commutative?\n ! (partition_left_tautology? && partition_right_tautology?)\n end" ]
[ "0.6182087", "0.610464", "0.58872426", "0.5865868", "0.56992733", "0.5688257", "0.56822467", "0.5606659", "0.55530816", "0.55356973", "0.55283356", "0.5510458", "0.55010617", "0.5441592", "0.5427365", "0.5404859", "0.53924185", "0.53924185", "0.537805", "0.53731847", "0.5369921", "0.5369921", "0.5354709", "0.53372014", "0.5329712", "0.5327029", "0.53258884", "0.5321205", "0.53128153", "0.5292725", "0.528458", "0.528458", "0.5278285", "0.52750206", "0.52670753", "0.5266525", "0.5265516", "0.5265516", "0.5265516", "0.52522177", "0.525192", "0.5243359", "0.523838", "0.523838", "0.52337307", "0.5231846", "0.5229725", "0.52196336", "0.5213265", "0.5207186", "0.5197655", "0.51966155", "0.5184972", "0.5179958", "0.51676434", "0.51474637", "0.5144008", "0.5137448", "0.5137448", "0.5137448", "0.5137448", "0.51369053", "0.51167935", "0.5116146", "0.51154226", "0.5114097", "0.51073843", "0.5106595", "0.5101682", "0.50970894", "0.5092404", "0.50897855", "0.5087743", "0.5087743", "0.5087743", "0.5087743", "0.5087743", "0.5086429", "0.5082886", "0.5080281", "0.5077962", "0.5075806", "0.5071951", "0.5071926", "0.5054189", "0.5053128", "0.50517327", "0.5048534", "0.5037506", "0.5034353", "0.5034349", "0.50334334", "0.5015571", "0.5015571", "0.50151694", "0.5013035", "0.50025827", "0.49929747", "0.49908036", "0.49902925", "0.49794653" ]
0.0
-1
GET /workphases GET /workphases.json
def view @workphases = Workphase.search_by_phase(params[:search]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @project_phases = ProjectPhase.all\n end", "def index\n @phases = Phase.where(project_id: params[:project_id])\n end", "def index\n @phases = Phase.all\n end", "def get_work_json\n client.make_request('/get-work-json', 'post', params: {})\n end", "def phases(wod)\n options = {\n wod: wod,\n response: api_connection.connection.get(\"phases/\"),\n directory: \"fpl_data/pulled_data/phases\",\n filename: \"phases_#{DateTime.current.strftime(\"%C%y-%m-%d\")}\"\n }\n\n CoreUtility::DataToJSON.write_or_display_data(options)\n end", "def show\n @project_phase = ProjectPhase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project_phase }\n end\n end", "def index\n @renting_phases = RentingPhase.all\n end", "def create\n @workphase = Workphase.new(workphase_params)\n\n respond_to do |format|\n if @workphase.save\n format.html { redirect_to @workphase, notice: 'Workphase was successfully created.' }\n format.json { render :show, status: :created, location: @workphase }\n else\n format.html { render :new }\n format.json { render json: @workphase.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_work\n client.make_request('/get-work', 'post', params: {})\n end", "def index\r\n @production_phases = ProductionPhase.all\r\n end", "def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def index\n if params[:project_id]\n @steps = Step.joins(:projects).includes(:work_items, :work_items => :users, :work_items => :tasks).where('projects.id = ?', params[:project_id]).order('position ASC')\n steps = @steps.collect do |s|\n s.work_items.sort!{|a, b| a.position <=> b.position}\n s\n end\n @steps = steps\n else\n @steps = Step.all\n end\n\n respond_with @steps\n end", "def show\n @project_phase = ProjectPhase.find(params[:id])\n @lifecycle_phase = @project_phase.lifecycle_phase\n @project_phase_deliverables = []\n @project_phase.stock_deliverable_types.each do |stock|\n stock.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n @project_phase.custom_deliverable_types.each do |custom|\n custom.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n respond_to do |format|\n format.json { render :json => { :lifecycle_phase_container => @lifecycle_phase,\n :deliverables_container => @project_phase_deliverables,\n :project_phase_estimated_effort => @project_phase.estimated_effort,\n :project_phase_logged_effort => @project_phase.logged_effort} }\n end\n end", "def show\r\n @stages_work = StagesWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @stages_work }\r\n end\r\n end", "def index\n @journal = Journal.find(params[:journal_id])\n\n render json: @journal.workouts\n end", "def index\n @summary_phases = SummaryPhase.all\n end", "def show\n @work = Work.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work.to_json(:include => {\n :teacher => {},\n :student => {},\n :thesis_changes => {},\n :tasks => {:include => :thesis_changes}\n })}\n end\n end", "def show\n @phase = Phase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @phase }\n end\n end", "def set_workphase\n @workphase = Workphase.find(params[:id])\n end", "def index\n @product_treatment_phases = ProductTreatmentPhase.all\n end", "def workphase_params\n params.require(:workphase).permit(:worknote, :dateChanged, \n :product_id, :phase_id, :employee_id,\n :adminNote, :totalMade, :totalToMake,\n :dateComplete)\n end", "def getwork(data)\n request :getwork, data\n end", "def index\n @works = Work.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @works }\n end\n end", "def index\n @works = Work.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @works }\n end\n end", "def index\n workouts = @ws.workouts\n render json: workouts\n end", "def index\n @steps = Step.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def phase_params\n params.require(:phase).permit(:phase_title, :content, :project_id, :price, :phase_type, :worker_id, :start_time, :end_time, :worker_name)\n end", "def index\n @work_order_work_tasks = WorkOrderWorkTask.all\n end", "def phases\n Phase.where(edition_id: id)\n end", "def phases\n lifecycle.phases \n end", "def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end", "def index\n @phase_details = PhaseDetail.all\n end", "def index\n # @solutions = Solution.all\n @solutions = @goal.solutions\n end", "def index\n @workouts = Workout.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workouts }\n end\n end", "def index_issue\n @work_orders = WorkOrder.accessible_by(current_ability).search(params[:search]).order(\"issued_at desc, received\").page(params[:page]).includes{work_order_items.tool_part_item}\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @work_orders }\n format.xml { render xml: @work_orders }\n end\n end", "def index\n @solutions = @idea.solutions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solutions }\n end\n end", "def index\n if params[:workpoint_id]\n @outs = Workpoint.find(params[:workpoint_id]).outs\n else\n @outs = Out.all\n end\n respond_to do |format|\n format.json {\n render :json => @outs, :layout => false\n }\n end\n end", "def index\n @phase_levels = PhaseLevel.all\n end", "def index\n @goal_steps = GoalStep.all\n end", "def show\n @work = Work.find(params[:id])\n render :json => {:name => @work.name, :desc => @work.description}\n end", "def index\n @work_orders = WorkOrder.pending\n @completed_work_orders = WorkOrder.completed\n @work_order_requests = WorkOrderRequest.pending\n\n end", "def index\n @work_durations = WorkDuration.all\n end", "def index\n @workout_units = WorkoutUnit.all\n end", "def work_schedules\n @work_schedules = WorkSchedule.all\n\n render json: @work_schedules.to_json\n end", "def getwork(data = nil)\n @api.request 'getwork', data\n end", "def destroy\n Workphase.find(params[:id]).destroy\n #@workphase.destroy\n respond_to do |format|\n format.html { redirect_to workphases_url, notice: 'Workphase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n @work_plans = WorkPlan.includes(:clinic_doctor).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @work_plans }\n end\n end", "def index\n @workdetails = Workdetail.where(\"task_id = ?\", params[:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workdetails }\n end\n end", "def index\n @workouts = Workout.all \n render 'index.json.jbuilder', status: :created\n end", "def index\n @workout_routines = WorkoutRoutine.all\n @exercises = Exercise.all\n end", "def show\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_plan }\n end\n end", "def index\n @phase_types = PhaseType.all\n end", "def index\n @steps = Step.collated.ordered.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def index\n @project = Project.find_by_id(params[:project_id])\n @phase = Project::Phase.find_by_id(params[:phase_id])\n @project_phase_milestones = Project::Phase::Milestone.where(project_phases_id: params[:phase_id])\n end", "def get_work(data=nil)\n request('getwork', data)\n end", "def new\n @project_phase = ProjectPhase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @project_phase }\n end\n end", "def index\n @pending_works = PendingWork.all\n\n end", "def index\n @workshops = Workshop.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workshops }\n end\n end", "def index\n @works = Work.all\n end", "def index\n @works = Work.all\n end", "def index\n @project_steps = ProjectStep.all\n end", "def index\n @jobs = current_user.works\n end", "def index\n @sprints = Sprint.where(phase_id: params[:phase_id])\n end", "def index\n @sprints = Sprint.where(phase_id: params[:phase_id])\n end", "def index\n @experiments = experiment_type_class.where(phase_id: params[:phase_id])\n end", "def index\n story_parts_words = {}\n story_parts = StoryPart.where(params[:story_id])\n # iterate through story parts to find word. Create story_part/word association to be passed into json data\n story_parts.each do |story_part|\n story_word_array = []\n story_word_array.push(story_part)\n story_word_array.push(story_part.word)\n story_parts_words[story_part.id] = story_word_array\n end\n \n render :json => story_parts_words\n end", "def show\n @work = Work.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work }\n end\n end", "def show\n @work = Work.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work }\n end\n end", "def show\n @workorder = Workorder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workorder }\n end\n end", "def index\n @works = Work.includes(:avalon_items).all\n end", "def show\n @testing_algorithm = TestingAlgorithm.find(params[:id])\n\n render json : @testing_algorithm\n end", "def get_work\n works = batched_get( { id: params[:id] } )\n if works.empty?\n render_json_works_response(:not_found )\n else\n # provide fileset information here\n render_json_works_response(:ok, work_transform(works, INCLUDE_FILESETS ) )\n end\n end", "def search_works\n\n work_search = API::WorkSearch.new.from_json( params )\n if work_search.valid_for_search?\n\n works = do_works_search( work_search )\n respond_to do |format|\n format.json do\n if works.empty?\n render_json_works_response(:not_found )\n else\n # dont provide fileset information here, it takes too long and we just want work information\n render_json_works_response(:ok, work_transform( works, EXCLUDE_FILESETS ) )\n end\n end\n format.csv do\n # provide fileset information here because this is used for work export\n render_csv_works_response( work_transform( works, INCLUDE_FILESETS ) )\n end\n end\n else\n render_json_works_response(:bad_request, nil, 'Missing or incorrect parameter' )\n end\n\n end", "def show\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout }\n end\n end", "def show\n @workout_day = WorkoutDay.find(params[:id])\n\n @exercises = @workout_day.exercises\n\n assign_exercises_selection_list\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout_day }\n end\n end", "def index\n\n if params[:task_id] \n task = Task.find(params[:task_id])\n if task != nil\n @steps = task.steps\n else\n @steps = []\n end\n else \n @steps = Step.all\n end\n end", "def index\n @clientworkouts = Clientworkout.all\n end", "def tasks\n @use_case = UseCase.find(params[:id])\n @project = @use_case.project\n respond_to do |format|\n format.html \n end\n end", "def phase_params\n params.require(:phase).permit(:project_id, :start_date, :end_date, :interval, :sequence, :long_term_vision, :kpi_s, :criteria, :bottlenecks, :problem_definition, :solutions, :long_term, :key_benefits, :vision, :test_first, :sprint_amount, :proof_of_value, :background, :note)\n end", "def create\n @project_phase = ProjectPhase.new(params[:project_phase])\n\n respond_to do |format|\n if @project_phase.save\n format.html { redirect_to @project_phase, :notice => 'Project phase was successfully created.' }\n format.json { render :json => @project_phase, :status => :created, :location => @project_phase }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project_phase.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @properties = current_customer.properties.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @work_orders }\n end\n end", "def index\n @parts = Part.preload(:job)\n end", "def update\n respond_to do |format|\n if @workphase.update(workphase_params)\n format.json { respond_with_bip(@workphase) } #this is added as best_in_place update wasn't holding\n format.html { redirect_to @workphase, notice: 'Workphase was successfully updated.' }\n #format.json { render :show, status: :ok, location: @workphase }\n else\n format.html { render :edit }\n format.json { render json: @workphase.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @work_plan }\r\n end\r\n end", "def index \n render :json => Project.find(11).tasks\n end", "def show\n @job = Job.find(params[:job_id])\n @part = @job.parts.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json {render json: @part}\n end\n end", "def index\n if params[:workflow_id] \n workflow = Workflow.find(params[:workflow_id])\n if workflow != nil\n @step_definitions = workflow.step_definitions\n else\n @step_definitions = []\n end\n else \n @step_definitions = StepDefinition.all\n end\n end", "def show\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @myworkout }\n end\n end", "def index\n @working_operations = WorkingOperation.all\n end", "def index\n @issue_skills = IssueSkill.all\n render json: @issue_skills\n end", "def show\n @locations=@work.locations\n map\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work }\n end\n end", "def all_works\n #start = numeric( params[:start], DEFAULT_START )\n #limit = numeric( params[:limit], DEFAULT_LIMIT )\n\n works = batched_get( {} )\n respond_to do |format|\n format.json do\n if works.empty?\n render_json_works_response(:not_found )\n else\n # dont provide fileset information here, it takes too long and we just want work information\n render_json_works_response(:ok, work_transform( works, EXCLUDE_FILESETS ) )\n end\n end\n format.csv do\n # provide fileset information here because this is used for work export\n render_csv_works_response( work_transform( works, INCLUDE_FILESETS ) )\n end\n end\n\n end", "def show\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @completed_quest }\n end\n end", "def show\n @operation = Operation.find(params[:id])\n respond_to do |format|\n format.html\n format.json { render :json => @operation.to_json(:include => :task) }\n end\n end", "def create\n @project_phase = ProjectPhase.new(project_phase_params)\n\n respond_to do |format|\n if @project_phase.save\n format.html { redirect_to @project_phase, notice: 'Project phase was successfully created.' }\n format.json { render :show, status: :created, location: @project_phase }\n else\n format.html { render :new }\n format.json { render json: @project_phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @division_syns = DivisionSyn.all\n\n render json: @division_syns\n end", "def index\n @contest = Contest.find_by(path: params[:contest])\n @participant = @contest.participants.find_by(path: params[:participant])\n @submits = @participant.submits\n\n @navpill\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @submits }\n end\n end", "def index\n @workorders = Workorder.all\n end", "def index\n @workorders = Workorder.all\n end", "def index\n @work_processes = WorkProcess.all\n @work_processes = WorkProcess.includes(:translations).with_locales(I18n.locale).order('work_process_translations.name')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @work_processes }\n end\n end" ]
[ "0.6677245", "0.65292525", "0.6423285", "0.63378274", "0.62039244", "0.61108154", "0.61048543", "0.6091999", "0.6053289", "0.60315424", "0.60214865", "0.60214", "0.58047926", "0.5759363", "0.5732642", "0.5666867", "0.56643647", "0.5657214", "0.56477696", "0.5609534", "0.5559405", "0.55566555", "0.5535449", "0.5535449", "0.5530669", "0.55244213", "0.5521958", "0.55031353", "0.5476997", "0.5475496", "0.5463234", "0.54528284", "0.54518706", "0.5443839", "0.5427662", "0.5426592", "0.54149103", "0.54042125", "0.5396378", "0.5392894", "0.5374961", "0.5374738", "0.5374728", "0.53680325", "0.53619385", "0.5342782", "0.5342175", "0.532559", "0.5323548", "0.5314381", "0.53122145", "0.53037596", "0.5301053", "0.5299788", "0.5296722", "0.5289174", "0.5287444", "0.5282906", "0.52782965", "0.52782965", "0.5274469", "0.52732146", "0.5271321", "0.5271321", "0.52575785", "0.525587", "0.525421", "0.525421", "0.524473", "0.5241695", "0.5239608", "0.52301717", "0.52183425", "0.52173007", "0.5204514", "0.52040184", "0.5202753", "0.5201866", "0.5197626", "0.5192342", "0.51846504", "0.5179562", "0.51729554", "0.5171692", "0.5168903", "0.515986", "0.5151523", "0.5151347", "0.5147943", "0.51319563", "0.51309687", "0.51306534", "0.5126058", "0.51254934", "0.5125214", "0.511947", "0.5116506", "0.51083916", "0.51083916", "0.5104726" ]
0.68513757
0
GET /workphases/1 GET /workphases/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @project_phase = ProjectPhase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project_phase }\n end\n end", "def view\n @workphases = Workphase.search_by_phase(params[:search])\n end", "def index\n @phases = Phase.where(project_id: params[:project_id])\n end", "def index\n @project_phases = ProjectPhase.all\n end", "def get_work_json\n client.make_request('/get-work-json', 'post', params: {})\n end", "def get_work\n client.make_request('/get-work', 'post', params: {})\n end", "def index\n @phases = Phase.all\n end", "def create\n @workphase = Workphase.new(workphase_params)\n\n respond_to do |format|\n if @workphase.save\n format.html { redirect_to @workphase, notice: 'Workphase was successfully created.' }\n format.json { render :show, status: :created, location: @workphase }\n else\n format.html { render :new }\n format.json { render json: @workphase.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @phase = Phase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @phase }\n end\n end", "def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def show\r\n @stages_work = StagesWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @stages_work }\r\n end\r\n end", "def show\n @work = Work.find(params[:id])\n render :json => {:name => @work.name, :desc => @work.description}\n end", "def set_workphase\n @workphase = Workphase.find(params[:id])\n end", "def index\n if params[:project_id]\n @steps = Step.joins(:projects).includes(:work_items, :work_items => :users, :work_items => :tasks).where('projects.id = ?', params[:project_id]).order('position ASC')\n steps = @steps.collect do |s|\n s.work_items.sort!{|a, b| a.position <=> b.position}\n s\n end\n @steps = steps\n else\n @steps = Step.all\n end\n\n respond_with @steps\n end", "def index\n @renting_phases = RentingPhase.all\n end", "def new\n @project_phase = ProjectPhase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @project_phase }\n end\n end", "def index\n @journal = Journal.find(params[:journal_id])\n\n render json: @journal.workouts\n end", "def show\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_plan }\n end\n end", "def show\n @project_phase = ProjectPhase.find(params[:id])\n @lifecycle_phase = @project_phase.lifecycle_phase\n @project_phase_deliverables = []\n @project_phase.stock_deliverable_types.each do |stock|\n stock.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n @project_phase.custom_deliverable_types.each do |custom|\n custom.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n respond_to do |format|\n format.json { render :json => { :lifecycle_phase_container => @lifecycle_phase,\n :deliverables_container => @project_phase_deliverables,\n :project_phase_estimated_effort => @project_phase.estimated_effort,\n :project_phase_logged_effort => @project_phase.logged_effort} }\n end\n end", "def show\n @work = Work.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work }\n end\n end", "def show\n @work = Work.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work }\n end\n end", "def show\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @myworkout }\n end\n end", "def index\r\n @production_phases = ProductionPhase.all\r\n end", "def show\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout }\n end\n end", "def show\n @work = Work.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work.to_json(:include => {\n :teacher => {},\n :student => {},\n :thesis_changes => {},\n :tasks => {:include => :thesis_changes}\n })}\n end\n end", "def show\n @workorder = Workorder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workorder }\n end\n end", "def show\n @work_process = WorkProcess.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_process }\n end\n end", "def index\n @workdetails = Workdetail.where(\"task_id = ?\", params[:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workdetails }\n end\n end", "def getwork(data)\n request :getwork, data\n end", "def show\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @work_plan }\r\n end\r\n end", "def show\n @work_id = params[:id]\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @work }\n end\n end", "def get_work\n works = batched_get( { id: params[:id] } )\n if works.empty?\n render_json_works_response(:not_found )\n else\n # provide fileset information here\n render_json_works_response(:ok, work_transform(works, INCLUDE_FILESETS ) )\n end\n end", "def show\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @completed_quest }\n end\n end", "def show\n @step = Step.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end", "def show\n @step = Step.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end", "def show\n @step = Step.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end", "def show\n @job = Job.find(params[:job_id])\n @part = @job.parts.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json {render json: @part}\n end\n end", "def getwork(data = nil)\n @api.request 'getwork', data\n end", "def index\n @works = Work.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @works }\n end\n end", "def index\n @works = Work.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @works }\n end\n end", "def show\n\t\t@work = Work.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @work }\n\t\tend\n\tend", "def show\n @gym_workout = GymWorkout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @gym_workout }\n end\n end", "def phases(wod)\n options = {\n wod: wod,\n response: api_connection.connection.get(\"phases/\"),\n directory: \"fpl_data/pulled_data/phases\",\n filename: \"phases_#{DateTime.current.strftime(\"%C%y-%m-%d\")}\"\n }\n\n CoreUtility::DataToJSON.write_or_display_data(options)\n end", "def index\n @summary_phases = SummaryPhase.all\n end", "def show\n @solution = @idea.solutions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solution }\n end\n end", "def index\n @steps = Step.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n render json: @goal\n end", "def show\n @workdetails = Workdetail.where(\"task_id = ?\", params[:id])\n @taskid = params[:id]\n @task = Task.where(:id => @taskid).first\n @storyid = @task.story_id\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workdetails }\n end\n end", "def get_work(data=nil)\n request('getwork', data)\n end", "def destroy\n Workphase.find(params[:id]).destroy\n #@workphase.destroy\n respond_to do |format|\n format.html { redirect_to workphases_url, notice: 'Workphase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @testing_algorithm = TestingAlgorithm.find(params[:id])\n\n render json : @testing_algorithm\n end", "def show\n @client_workout = ClientWorkout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_workout }\n end\n end", "def show\n @step_type = StepType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step_type }\n end\n end", "def show\n @pre_step = PreStep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pre_step }\n end\n end", "def index_issue\n @work_orders = WorkOrder.accessible_by(current_ability).search(params[:search]).order(\"issued_at desc, received\").page(params[:page]).includes{work_order_items.tool_part_item}\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @work_orders }\n format.xml { render xml: @work_orders }\n end\n end", "def set_work_step\n @work_step = WorkStep.find(params[:id])\n @work_plan = @work_step.work_plan\n end", "def index\n workouts = @ws.workouts\n render json: workouts\n end", "def index\n @workouts = Workout.all \n render 'index.json.jbuilder', status: :created\n end", "def show\n @workshop = Workshop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workshop }\n end\n end", "def index\n @phase_details = PhaseDetail.all\n end", "def show\n @sprint = Sprint.find(params[:id])\n @stat = Status.find(4)\n @stories = Story.where(\"status_id = ?\", @stat.id)\n @examples = @sprint.stories \n @project_id = @examples.first.project_id\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sprint }\n end\n end", "def index\n @workouts = Workout.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workouts }\n end\n end", "def show\n @work_entry = WorkEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_entry }\n end\n end", "def show\n @operation = Operation.find(params[:id])\n respond_to do |format|\n format.html\n format.json { render :json => @operation.to_json(:include => :task) }\n end\n end", "def show\n @breadcrumb = 'read'\n @work_order_status = WorkOrderStatus.find(params[:id])\n @worker_orders = @work_order_status.work_orders.paginate(:page => params[:page], :per_page => per_page).order('order_no')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_order_status }\n end\n end", "def index\n # @solutions = Solution.all\n @solutions = @goal.solutions\n end", "def show\n @work_order = WorkOrder.find(params[:id])\n end", "def index\n @workshops = Workshop.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workshops }\n end\n end", "def create\n @project_phase = ProjectPhase.new(params[:project_phase])\n\n respond_to do |format|\n if @project_phase.save\n format.html { redirect_to @project_phase, :notice => 'Project phase was successfully created.' }\n format.json { render :json => @project_phase, :status => :created, :location => @project_phase }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project_phase.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end", "def show\n @step2 = Step2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step2 }\n end\n end", "def index\n @project = Project.find_by_id(params[:project_id])\n @phase = Project::Phase.find_by_id(params[:phase_id])\n @project_phase_milestones = Project::Phase::Milestone.where(project_phases_id: params[:phase_id])\n end", "def show\n @breadcrumb = 'read'\n @work_order_labor = WorkOrderLabor.find(params[:id])\n @worker_orders = @work_order_labor.work_orders.paginate(:page => params[:page], :per_page => per_page).order('order_no')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_order_labor }\n end\n end", "def show\n render :json => @slab_project_task\n end", "def show\n @exercise_plan = ExercisePlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_plan }\n end\n end", "def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end", "def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end", "def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end", "def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end", "def show\r\n @second_work = SecondWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @second_work }\r\n end\r\n end", "def index\n if params[:workpoint_id]\n @outs = Workpoint.find(params[:workpoint_id]).outs\n else\n @outs = Out.all\n end\n respond_to do |format|\n format.json {\n render :json => @outs, :layout => false\n }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def show\n @goal = Goal.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end", "def index\n @work_order_work_tasks = WorkOrderWorkTask.all\n end", "def index\n @solutions = @idea.solutions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solutions }\n end\n end", "def update\n respond_to do |format|\n if @workphase.update(workphase_params)\n format.json { respond_with_bip(@workphase) } #this is added as best_in_place update wasn't holding\n format.html { redirect_to @workphase, notice: 'Workphase was successfully updated.' }\n #format.json { render :show, status: :ok, location: @workphase }\n else\n format.html { render :edit }\n format.json { render json: @workphase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phase = Phase.new(phase_params)\n\n respond_to do |format|\n if @phase.save\n format.html { redirect_to project_phase_path(@project.id, @phase), notice: 'Phase was successfully created.' }\n format.json { render :show, status: :created, location: @phase }\n else\n format.html { render :new }\n format.json { render json: @phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @solution = Solution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solution }\n end\n end", "def show\r\n @theoretical_part = TheoreticalPart.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @theoretical_part }\r\n end\r\n end", "def show\n @workout_day = WorkoutDay.find(params[:id])\n\n @exercises = @workout_day.exercises\n\n assign_exercises_selection_list\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout_day }\n end\n end", "def show\n @step = Step.find_by_slug(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end", "def index\n @pending_works = PendingWork.all\n\n end", "def new\n @phase = Phase.new\n\t @phase.project_id = params[:project_id] if params[:project_id]\t \n\t \n respond_to do |format|\n format.html {render :partial => 'phases/form', :layout => false}\n format.json { render :json => @phase }\n end\n end", "def show\n @routine_interview = RoutineInterview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @routine_interview }\n end\n end", "def new\n @step = Step.new :phase_template_id => params[:phase_template_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @step }\n end\n end", "def show\n render json: @job\n end", "def show\n render json: @job\n end", "def show\n @goal_state = GoalState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal_state }\n end\n end" ]
[ "0.6614175", "0.65888065", "0.6518956", "0.64683324", "0.63986117", "0.62596124", "0.6255913", "0.62369096", "0.6169411", "0.6079554", "0.6026385", "0.5986162", "0.59676266", "0.59071904", "0.5886285", "0.5866729", "0.58643335", "0.5861447", "0.584496", "0.58416605", "0.58416605", "0.5826423", "0.5803622", "0.57946455", "0.57934356", "0.57885945", "0.5788265", "0.578432", "0.5774562", "0.5741248", "0.5739758", "0.56838226", "0.56831306", "0.56800014", "0.56800014", "0.56800014", "0.5654214", "0.56502837", "0.56493086", "0.56493086", "0.5624346", "0.56152093", "0.5605624", "0.5589828", "0.55792606", "0.55698496", "0.5557208", "0.5556716", "0.5552007", "0.5547792", "0.55435973", "0.553763", "0.55284405", "0.55202305", "0.5515351", "0.55108", "0.5504501", "0.54997295", "0.5499649", "0.54970765", "0.5496233", "0.5491447", "0.5484713", "0.54721653", "0.54689604", "0.5436619", "0.5434819", "0.5428006", "0.54262364", "0.54256785", "0.5424485", "0.5421201", "0.5420966", "0.5416012", "0.54156953", "0.5414537", "0.5414537", "0.5414537", "0.5414537", "0.54016715", "0.5399852", "0.53978604", "0.53978604", "0.53978604", "0.53978604", "0.53948253", "0.5393288", "0.5388726", "0.5386592", "0.5374188", "0.53682303", "0.53678405", "0.53613853", "0.5356052", "0.5355114", "0.53506035", "0.53494424", "0.5348064", "0.5343918", "0.5343918", "0.53406286" ]
0.0
-1
POST /workphases POST /workphases.json
def create @workphase = Workphase.new(workphase_params) respond_to do |format| if @workphase.save format.html { redirect_to @workphase, notice: 'Workphase was successfully created.' } format.json { render :show, status: :created, location: @workphase } else format.html { render :new } format.json { render json: @workphase.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def workphase_params\n params.require(:workphase).permit(:worknote, :dateChanged, \n :product_id, :phase_id, :employee_id,\n :adminNote, :totalMade, :totalToMake,\n :dateComplete)\n end", "def create\n @work_plan = WorkPlan.find(params[:work_plan_id])\n @work_step = WorkStep.new(work_step_params)\n @work_step.work_plan=@work_plan\n\n respond_to do |format|\n if @work_step.save\n format.html { redirect_to @work_plan, notice: 'Work step was successfully created.' }\n format.json { render :show, status: :created, location: @work_plan }\n else\n format.html { render :new }\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def phase_params\n params.require(:phase).permit(:phase_title, :content, :project_id, :price, :phase_type, :worker_id, :start_time, :end_time, :worker_name)\n end", "def create\n @project_phase = ProjectPhase.new(params[:project_phase])\n\n respond_to do |format|\n if @project_phase.save\n format.html { redirect_to @project_phase, :notice => 'Project phase was successfully created.' }\n format.json { render :json => @project_phase, :status => :created, :location => @project_phase }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project_phase.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project_phase = ProjectPhase.new(project_phase_params)\n\n respond_to do |format|\n if @project_phase.save\n format.html { redirect_to @project_phase, notice: 'Project phase was successfully created.' }\n format.json { render :show, status: :created, location: @project_phase }\n else\n format.html { render :new }\n format.json { render json: @project_phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phase = Phase.new(phase_params)\n\n respond_to do |format|\n if @phase.save\n format.html { redirect_to project_phase_path(@project.id, @phase), notice: 'Phase was successfully created.' }\n format.json { render :show, status: :created, location: @phase }\n else\n format.html { render :new }\n format.json { render json: @phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phase = Phase.new(phase_params)\n\n respond_to do |format|\n if @phase.save\n format.html { redirect_to @phase, notice: \"Phase was successfully created.\" }\n format.json { render :show, status: :created, location: @phase }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @stages_work = StagesWork.new(params[:stages_work])\r\n\r\n respond_to do |format|\r\n if @stages_work.save\r\n format.html { redirect_to @stages_work, notice: 'Stages work was successfully created.' }\r\n format.json { render json: @stages_work, status: :created, location: @stages_work }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @stages_work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @workout = Workout.new(name: params[:name], steps: params[:steps], description: params[:description], time: params[:time], image_url: params[:image_url], video_url: params[:video_url], running: params[:running], weightlifting: params[:weightlifting], swimming: params[:swimming], circuit_training: params[:circuit_training], cycling: params[:cycling], creator_id: current_athlete.id, workout_creator: current_athlete.username)\n\n if @workout.save\n AthleteWorkout.create(workout_id: @workout.id, athlete_id: current_athlete.id)\n render 'create.json.jbuilder', status: :created\n else\n render json: { errors: @athlete.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\n @step = Step.new(params[:step])\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to @step.phase_template, notice: 'Step was successfully added.' }\n format.json { render json: @step, status: :created, location: @step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def phase_params\n params.require(:phase).permit(:project_id, :start_date, :end_date, :interval, :sequence, :long_term_vision, :kpi_s, :criteria, :bottlenecks, :problem_definition, :solutions, :long_term, :key_benefits, :vision, :test_first, :sprint_amount, :proof_of_value, :background, :note)\n end", "def create\n @work = Work.new(params[:work].except(:extra_keys, :extra_values))\n @work.extra = process_extra if params[:extra_keys]\n \n current_dataset.works << @work\n \n Work.create_locations(@work) if @work.places\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phase = Phase.new(params[:phase])\n\t @phase.account_id = current_user.account.id if @phase.account_id == nil\n\t @phase.created_by = current_user.id if @phase.created_by == nil\n\t @task = Task.new\n\t \n respond_to do |format|\n if @phase.save\n format.html {render :partial => 'phases/item', :locals => {:p => @phase}, :layout => false}\n format.json { render :json => @phase, :status => :created, :location => @phase }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @phase.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n # puts \"---------------------\"\n # puts workflow_params.to_json\n\n # workflow_attributes = workflow_params\n # step_definitions_attributes = workflow_attributes.delete(\"step_definitions\")\n\n # @workflow = Workflow.new(workflow_attributes)\n\n # @workflow.step_definitions = StepDefinition.createStepDefinitions(step_definitions_attributes)\n\n @workflow = Workflow.new(workflow_params)\n respond_to do |format|\n if @workflow.save\n format.html { redirect_to @workflow, notice: 'Workflow was successfully created.' }\n format.json { render :show, status: :created, location: @workflow }\n else\n format.html { render :new }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def phases(wod)\n options = {\n wod: wod,\n response: api_connection.connection.get(\"phases/\"),\n directory: \"fpl_data/pulled_data/phases\",\n filename: \"phases_#{DateTime.current.strftime(\"%C%y-%m-%d\")}\"\n }\n\n CoreUtility::DataToJSON.write_or_display_data(options)\n end", "def create\n @work_order_work_task = WorkOrderWorkTask.new(work_order_work_task_params)\n\n respond_to do |format|\n if @work_order_work_task.save\n format.html { redirect_to @work_order_work_task, notice: 'Work order work task was successfully created.' }\n format.json { render :show, status: :created, location: @work_order_work_task }\n else\n format.html { render :new }\n format.json { render json: @work_order_work_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @renting_phase = RentingPhase.new(renting_phase_params)\n\n respond_to do |format|\n if @renting_phase.save\n format.html { redirect_to @renting_phase, notice: 'Renting phase was successfully created.' }\n format.json { render :show, status: :created, location: @renting_phase }\n else\n format.html { render :new }\n format.json { render json: @renting_phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def project_phase_params\n params.require(:project_phase).permit(:project_id, :name, :start, :end)\n end", "def create\n @work_order = WorkOrder.new(work_order_params)\n\n respond_to do |format|\n if @work_order.save\n format.html { redirect_to @work_order, notice: \"Work order was successfully created.\" }\n format.json { render :show, status: :created, location: @work_order }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @work_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n=begin\n params[:short_term_goal][:tasks] = Array.new\n tasks_array = Array.new\n if params[:task]\n params[:task].each do |num,task| \n tasks_array[Integer(num)] = task if task != ''\n end\n end\n tasks_array.each do |task|\n params[:short_term_goal][:tasks] << Task.create(:name => task) if task != nil\n end\n=end\n @short_term_goal = ShortTermGoal.new(params[:short_term_goal])\n respond_to do |format|\n if @short_term_goal.save\n format.html { redirect_to(myguide_path(@current_user), :notice => 'Short term goal was successfully created.') }\n format.xml { render :xml => @short_term_goal, :status => :created, :location => @short_term_goal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @short_term_goal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @work_order = WorkOrder.new(work_order_params)\n\n respond_to do |format|\n if @work_order.save\n format.html { redirect_to @work_order, notice: 'Work order was successfully created.' }\n format.json { render :show, status: :created, location: @work_order }\n else\n format.html { render :new }\n format.json { render json: @work_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def work_step_params\n params.require(:work_step).permit(:name)\n end", "def create\n @step = Step.new(step_params) \n\n if @step.save\n render :show, status: :created, location: @step\n else\n render json: @step.errors, status: :unprocessable_entity\n end\n end", "def set_workphase\n @workphase = Workphase.find(params[:id])\n end", "def create\n @workout = Workout.new(workout_params)\n if user_signed_in?\n @workout.owner = current_user\n @workout.users << current_user\n else\n @workout.owner = temp_user\n session[:workout_id] = @workout.id\n end \n @workout.save\n ex_params = exercise_params[:exercise].map do |e|\n e[:dur] = e[:dur][:minutes].to_i*60 + e[:dur][:seconds].to_i\n e[:workout_id] = @workout.id\n e\n end\n @exercises = @workout.exercises.create(ex_params)\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: \"Workout was successfully created\" }\n format.json { render json: {workoutId: @workout.id}, status: 200 }\n else\n format.html { render :new }\n format.json { render json: @workout.errors, status: 500 }\n end\n end\n end", "def create\n @workout_routine = WorkoutRoutine.new(workout_routine_params)\n\n respond_to do |format|\n if @workout_routine.save\n format.html { redirect_to @workout_routine, notice: 'Workout routine was successfully created.' }\n format.json { render :show, status: :created, location: @workout_routine }\n else\n format.html { render :new }\n format.json { render json: @workout_routine.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workorder = Workorder.new(workorder_params)\n\n respond_to do |format|\n if @workorder.save\n format.html { redirect_to @workorder, notice: 'Workorder was successfully created.' }\n format.json { render :show, status: :created, location: @workorder }\n else\n format.html { render :new }\n format.json { render json: @workorder.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise = @workout.exercises.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: I18n.t('exercises.created') }\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @production_phase = ProductionPhase.new(production_phase_params)\r\n @production_phase.phase_no = ProductionPhase.assign_serial\r\n respond_to do |format|\r\n if @production_phase.save\r\n format.html { redirect_to production_phases_path, notice: 'تم عمل دورة أنتاجية جديدة' }\r\n format.json { render :show, status: :created, location: @production_phase }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @production_phase.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @order_vehicle_workshop = OrderVehicleWorkshop.new(order_vehicle_workshop_params)\n\n respond_to do |format|\n if @order_vehicle_workshop.save\n format.html { redirect_to @order_vehicle_workshop, notice: 'Order vehicle workshop was successfully created.' }\n format.json { render :show, status: :created, location: @order_vehicle_workshop }\n else\n format.html { render :new }\n format.json { render json: @order_vehicle_workshop.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_routine_params\n params.require(:workout_routine).permit(:name, :exercise_id)\n end", "def create\n @work = Work.new(work_params)\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render :show, status: :created, location: @work }\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(work_params)\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render :show, status: :created, location: @work }\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workorder = Workorder.new(params[:workorder])\n\n respond_to do |format|\n if @workorder.save\n format.html { redirect_to @workorder, notice: 'Workorder was successfully created.' }\n format.json { render json: @workorder, status: :created, location: @workorder }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workorder.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def submit_work_json(block_header:)\n client.make_request('/submit-work-json', 'post', params: {block_header: block_header})\n end", "def create\n @testcase = Testcase.find(params[:testcase_id])\n @step = @testcase.steps.new(step_params)\n byebug\n if @step.save\n render :show, status: :created\n else\n render json: @step.errors, status: :unprocessable_entity\n end\n end", "def create\n @product_treatment_phase = ProductTreatmentPhase.new(product_treatment_phase_params)\n\n respond_to do |format|\n if @product_treatment_phase.save\n format.html { redirect_to @product_treatment_phase, notice: 'Product treatment phase was successfully created.' }\n format.json { render :show, status: :created, location: @product_treatment_phase }\n else\n format.html { render :new }\n format.json { render json: @product_treatment_phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to action: 'index', flash: {notice: 'Work item was successfully created.' }}\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @step = Step.new(step_params)\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to @step, notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n format.html { render :new }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phase_type = PhaseType.new(phase_type_params)\n\n respond_to do |format|\n if @phase_type.save\n format.html { redirect_to @phase_type, notice: 'Phase type was successfully created.' }\n format.json { render :show, status: :created, location: @phase_type }\n else\n format.html { render :new }\n format.json { render json: @phase_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_work_json\n client.make_request('/get-work-json', 'post', params: {})\n end", "def create\n\n step_attributes = step_params\n fields_attributes = step_attributes.delete(\"fields\")\n\n @step = Step.new(step_attributes)\n @step.fields = Field.createFields(fields_attributes)\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to @step, notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n format.html { render :new }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n exercise = Exercise.create(exercise_params)\n if exercise\n render json: exercise\n else\n render json: {error: 'Workout was not created.'}\n end\n end", "def create\n # @solution = Solution.new(solution_params)\n # @goal = Goal.find(params[:goal_id])\n @solution = @goal.solutions.new(solution_params)\n\n\n respond_to do |format|\n if @solution.save\n format.html { redirect_to project_goal_path(@project, @goal), notice: 'Solution was successfully created.' }\n format.json { render :show, status: :created, location: @solution }\n else\n format.html { render :new }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @summary_phase = SummaryPhase.new(summary_phase_params)\n\n respond_to do |format|\n if @summary_phase.save\n format.html { redirect_to @summary_phase, notice: 'Summary phase was successfully created.' }\n format.json { render :show, status: :created, location: @summary_phase }\n else\n format.html { render :new }\n format.json { render json: @summary_phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project_step = ProjectStep.new(project_step_params)\n\n respond_to do |format|\n if @project_step.save\n format.html { redirect_to @project_step, notice: 'Project step was successfully created.' }\n format.json { render :show, status: :created, location: @project_step }\n else\n format.html { render :new }\n format.json { render json: @project_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work_order_time = WorkOrderTime.new(work_order_time_params)\n\n respond_to do |format|\n if @work_order_time.save\n format.html { redirect_to @work_order_time, notice: 'Work order time was successfully created.' }\n format.json { render :show, status: :created, location: @work_order_time }\n else\n format.html { render :new }\n format.json { render json: @work_order_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @house_work = HouseWork.new(house_work_params)\n\n respond_to do |format|\n if @house_work.save\n format.html { redirect_to @house_work, notice: 'House work was successfully created.' }\n format.json { render :show, status: :created, location: @house_work }\n else\n format.html { render :new }\n format.json { render json: @house_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @active_workflow_step = ActiveWorkflowStep.new(active_workflow_step_params)\n\n respond_to do |format|\n if @active_workflow_step.save\n format.html { redirect_to @active_workflow_step, notice: 'Active workflow step was successfully created.' }\n format.json { render :show, status: :created, location: @active_workflow_step }\n else\n format.html { render :new }\n format.json { render json: @active_workflow_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_params\n params.require(:workout).permit(:title, :duration, :rest, :interval, :sets, :cooldown, :exercises)\n end", "def create\n @workpermit = Workpermit.new(workpermit_params)\n\n respond_to do |format|\n if @workpermit.save\n format.html { redirect_to @workpermit, notice: 'Workpermit was successfully created.' }\n format.json { render :show, status: :created, location: @workpermit }\n else\n format.html { render :new }\n format.json { render json: @workpermit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @goal_step = GoalStep.new(goal_step_params)\n\n respond_to do |format|\n if @goal_step.save\n format.html { redirect_to @goal_step, notice: \"Goal step was successfully created.\" }\n format.json { render :show, status: :created, location: @goal_step }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @goal_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @step = Step.new(step_params)\n @step.shop_id = session[:shopify]\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to @step, notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n format.html { render :new }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @howitwork = Howitwork.new(howitwork_params)\n\n respond_to do |format|\n if @howitwork.save\n format.html { redirect_to admin_howitwork_url(@howitwork), notice: 'Howitwork was successfully created.' }\n format.json { render :show, status: :created, location: @howitwork }\n else\n format.html { render :new }\n format.json { render json: @howitwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @development_work = DevelopmentWork.new(development_work_params)\n\n respond_to do |format|\n if @development_work.save\n format.html { redirect_to @development_work, notice: 'Development work was successfully created.' }\n format.json { render :show, status: :created, location: @development_work }\n else\n format.html { render :new }\n format.json { render json: @development_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def work_site_planner_params\n params.require(:work_site_planner).permit(:career_plan_outcomes_id, :work_site_name, :point_of_contact, :occupation, :position_type, :salary_per_hour, :working_hours_per_week, :completed, :outcome,:activity_date)\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.work'))\n if @patron\n @patron.works << @work\n end\n format.html { redirect_to @work }\n format.json { render :json => @work, :status => :created, :location => @work }\n else\n prepare_options\n format.html { render :action => \"new\" }\n format.json { render :json => @work.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\r\n @work_plan = WorkPlan.new(params[:work_plan])\r\n\r\n respond_to do |format|\r\n if @work_plan.save\r\n format.html { redirect_to @work_plan, notice: 'Work plan was successfully created.' }\r\n format.json { render json: @work_plan, status: :created, location: @work_plan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n\n # ensure that the submitted parent_id actually exists\n if !Step.exists?(params[:step][:parent_id].to_i)\n logger.debug \"Step doesn't exist!\"\n if @project.steps.last\n params[:step][:parent_id] = @project.steps.last.id\n else\n params[:step][:parent_id] = nil\n end\n end\n\n if params[:step][:pin] && params[:step][:pin].empty?\n params[:step][:pin] = nil\n end\n\n @step = @project.steps.build(params[:step])\n authorize! :create, @step \n\n if params[:step][:position]\n @step.position = params[:step][:position]\n else\n @step.position = @numSteps\n end\n \n respond_to do |format|\n if @step.save\n\n # update corresponding collections\n @step.project.collections.each do |collection|\n collection.touch\n end\n \n # create an edit entry\n Edit.create(:user_id => current_user.id, :step_id => @step.id, :project_id => @project.id)\n\n # check whether project is published\n if @project.public? || @project.privacy.blank?\n @project.set_published(current_user.id, @project.id, @step.id)\n end\n\n @project.set_built\n\n # update the project updated_at date\n @project.touch\n\n # update the user last_updated_at date\n current_user.touch\n\n @step.update_attributes(:published_on => @step.created_at)\n\n # create a public activity for any added question\n if @step.question\n Rails.logger.debug(\"created new question\")\n @step.question.create_activity :create, owner: current_user, primary: true\n end\n\n # log the creation of a new step\n @project.delay.log\n\n format.html { \n\n # update all images with new step id\n new_step_images = @project.images.where(\"step_id = -1\")\n new_step_images.each do |image|\n image.update_attributes(:saved => true)\n image.update_attributes(:step_id => @step.id)\n end\n\n # update all videos with new step id\n new_step_videos = @project.videos.where(\"step_id = -1\")\n new_step_videos.each do |video|\n video.update_attributes(:saved=>true)\n video.update_attributes(:step_id=> @step.id)\n end\n\n # push project to village if it doesn't already exist\n if @project.village_id.blank? && current_user.from_village? && @project.public? && !access_token.blank?\n create_village_project\n elsif !@project.village_id.blank? && !access_token.blank?\n update_village_project\n end\n \n redirect_to project_steps_path(@project), :flash=>{:createdStep => @step.id}\n \n }\n \n format.json { render :json => @step }\n else\n Rails.logger.debug(@step.errors.inspect)\n format.html { render :action => \"new\" }\n format.json { render :json => @step.errors, :status => :unprocessable_entity }\n end\n end\n end", "def view\n @workphases = Workphase.search_by_phase(params[:search])\n end", "def create\r\n @work = Work.new(work_params)\r\n\r\n respond_to do |format|\r\n if @work.save\r\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\r\n format.json { render action: 'index', status: :created, location: @work }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @creator.works << Work.where(id: work_ids)\n if @creator.save\n render json: @creator, status: :created, location: @creator\n else\n render json: @creator.errors, status: :unprocessable_entity\n end\n end", "def create\n @upwork = Upwork.new(upwork_params)\n\n respond_to do |format|\n if @upwork.save\n format.html { redirect_to @upwork, notice: 'Upwork was successfully created.' }\n format.json { render :show, status: :created, location: @upwork }\n else\n format.html { render :new }\n format.json { render json: @upwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @step = @quest.steps.new(params[:step])\n\n \n \n if @step.save\n redirect_to (quest_path(@quest)), notice: 'Step was successfully created.'\n\n else\n render action: \"new\" \n end\n end", "def create\n @work = Work.new(work_params)\n \n respond_to do |format|\n if @work.save\n format.html { redirect_to works_path, notice: 'Work item was successfully created!'}\n else\n format.html { render :new }\n end\n end\n end", "def project_phase_params\n params.require(:project_phase).permit(:phase, :description, :project_id, {document: [].to_s})\n end", "def create\n @completed_quest = CompletedQuest.new(params[:completed_quest])\n\n respond_to do |format|\n if @completed_quest.save\n format.html { redirect_to @completed_quest, notice: 'Completed quest was successfully created.' }\n format.json { render json: @completed_quest, status: :created, location: @completed_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @completed_quest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @myworkout = Myworkout.new(params[:myworkout])\n\n respond_to do |format|\n if @myworkout.save\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully created.' }\n format.json { render :json => @myworkout, :status => :created, :location => @myworkout }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @myworkout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_new_work(params)\n @log.info 'Configuring work attributes'\n\n # set depositor\n depositor = User.find_by_user_key(@config['depositor'])\n raise 'User ' + @config['depositor'] + ' not found.' if depositor.nil?\n\n # set noid\n id = Noid::Rails::Service.new.minter.mint\n\n # set resource type\n resource_type = 'Thesis'\n unless params['resource_type'].first.nil?\n resource_type = params['resource_type'].first\n end\n\n # set visibility\n if params.key?('embargo_release_date')\n params['visibility_after_embargo'] = 'open'\n params['visibility_during_embargo'] = 'authenticated'\n else\n params['visibility'] = 'open'\n end\n\n # set admin set to deposit into\n unless @config['admin_set_id'].nil?\n params['admin_set_id'] = @config['admin_set_id']\n end\n\n # set campus\n params['campus'] = [@config['campus']]\n\n @log.info 'Creating a new ' + resource_type + ' with id:' + id\n\n if @config['type_to_work_map'][resource_type].nil?\n raise 'No mapping for ' + resource_type\n end\n\n model_name = @config['type_to_work_map'][resource_type]\n\n # student research but with a label that is otherwise Publication\n if params['degree_level'] || params['advisor']\n model_name = 'Thesis'\n end\n\n # create the actual work based on the mapped resource type\n model = Kernel.const_get(model_name)\n work = model.new(id: id)\n work.update(params)\n work.apply_depositor_metadata(depositor.user_key)\n work.save\n\n work\nend", "def create\n @testing_algorithm = TestingAlgorithm.new(params[:testing_algorithm])\n\n if @testing_algorithm.save\n render json : @testing_algorithm, status : :created, location : @testing_algorithm\n else\n render json : @testing_algorithm.errors, status : :unprocessable_entity\n end\n end", "def workout_params\n params.require(:workout).permit(:name, :scrambled, :exercise_ids,\n :description, :target_group, :points_multiplier, :opening_date, :exercise_workout,\n :exercise_workouts_attributes, :workout_offerings_attributes,\n :soft_deadline, :hard_deadline)\n end", "def create\n @work_order_hazard = WorkOrderHazard.new(work_order_hazard_params)\n\n respond_to do |format|\n if @work_order_hazard.save\n format.html { redirect_to @work_order_hazard, notice: 'Work order hazard was successfully created.' }\n format.json { render :show, status: :created, location: @work_order_hazard }\n else\n format.html { render :new }\n format.json { render json: @work_order_hazard.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @building_stage_sub_stage = Building::Stage::SubStage.new(building_stage_sub_stage_params)\n\n respond_to do |format|\n if @building_stage_sub_stage.save\n format.html { redirect_to @building_stage_sub_stage, notice: 'Sub stage was successfully created.' }\n format.json { render :show, status: :created, location: @building_stage_sub_stage }\n else\n format.html { render :new }\n format.json { render json: @building_stage_sub_stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(work_params)\n process_work_contributors\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render text: \"success\"}\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @project_phases = ProjectPhase.all\n end", "def create\n @solution = @idea.solutions.new(feature: params[:toSent]) #@idea.solutions.new(params[:solution])\n\n if @solution.save\n render json: { text: \"success\", id: \"#{@solution.id}\" }\n else\n render json: { text: \"fail\"}\n end\n end", "def create\n @work_process = WorkProcess.new(work_process_params)\n respond_to do |format|\n if @work_process.save\n format.html { redirect_to work_processes_path, notice: I18n.t('commons.successfully_created') }\n format.json { render json: @work_process, status: :created, location: @work_process }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work_process.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @step = Step.new(params[:step])\n @test_case = TestCase.find(params[:test_case_id])\n @step.test_case_id = @test_case.id\n\n if @step.save\n flash[:notice] = \"Successfully created step.\"\n end\n respond_with @step\n end", "def create\n @step = Step.new(step_params)\n\n respond_to do |format|\n if @step.save\n format.js\n else\n format.html { render :new }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @taken_step = TakenStep.new(taken_step_params)\n\n respond_to do |format|\n if @taken_step.save\n format.html { redirect_to @taken_step, notice: 'Steps Taken was successfully created.' }\n format.json { render :show, status: :created, location: @taken_step }\n else\n format.html { render :new }\n format.json { render json: @taken_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout_unit = WorkoutUnit.new(workout_unit_params)\n @workout_unit.user_id = current_user.id\n respond_to do |format|\n if @workout_unit.save\n format.html { redirect_to @workout_unit, notice: 'Workout unit was successfully created.' }\n format.json { \n render :json => @workout_unit.as_json(:include => :workout_unit_type), action: 'show', status: :created, location: @workout_unit \n }\n else\n format.html { render action: 'new' }\n format.json { render json: @workout_unit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workphase.update(workphase_params)\n format.json { respond_with_bip(@workphase) } #this is added as best_in_place update wasn't holding\n format.html { redirect_to @workphase, notice: 'Workphase was successfully updated.' }\n #format.json { render :show, status: :ok, location: @workphase }\n else\n format.html { render :edit }\n format.json { render json: @workphase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @step = Step.new(step_params)\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to api_v1_step_url(@step), notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phenological_stage = PhenologicalStage.new(phenological_stage_params)\n\n respond_to do |format|\n if @phenological_stage.save\n format.js\n format.html { redirect_to @phenological_stage, notice: 'Phenological stage was successfully created.' }\n format.json { render action: 'show', status: :created, location: @phenological_stage }\n else\n format.js\n format.html { render action: 'new' }\n format.json { render json: @phenological_stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:submission][:verdict] = 'pending'\n create_base(params[:submission]) \n end", "def create\n @phase_detail = PhaseDetail.new(phase_detail_params)\n generate_id\n respond_to do |format|\n if @phase_detail.save\n format.html { redirect_to @phase_detail, notice: 'Phase detail was successfully created.' }\n format.json { render action: 'show', status: :created, location: @phase_detail }\n else\n format.html { render action: 'new' }\n format.json { render json: @phase_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work_time = WorkTime.new(work_time_params)\n\n respond_to do |format|\n if @work_time.save\n format.html { redirect_to @work_time, notice: 'Work time was successfully created.' }\n format.json { render :show, status: :created, location: @work_time }\n else\n format.html { render :new }\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n Workphase.find(params[:id]).destroy\n #@workphase.destroy\n respond_to do |format|\n format.html { redirect_to workphases_url, notice: 'Workphase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def workorder_params\n params.require(:workorder).permit(:time, :duration, :price)\n end", "def production_phase_params\r\n params.require(:production_phase).permit(:main_material, :phase_no, :initial_letter)\r\n end", "def create\n @work_order_status = WorkOrderStatus.new(work_order_status_params)\n\n respond_to do |format|\n if @work_order_status.save\n format.html { redirect_to @work_order_status, notice: 'Work order status was successfully created.' }\n format.json { render :show, status: :created, location: @work_order_status }\n else\n format.html { render :new }\n format.json { render json: @work_order_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def renting_phase_params\n params.require(:renting_phase).permit(:start_date, :end_date, :price, :cycles, :contract_id)\n end", "def work_order_time_params\n params.require(:work_order_time).permit(:esitmated_job_duration, :estimated_travel_time, :estimated_wrap_up_duration, :estimated_start, :estimated_wrapup, :actual_job_duration, :actual_travel_duration, :actual_wrap_up_duration, :actual_end_time, :actual_start_time, :actual_completed_time, :standard_job_duration, :work_order_id)\n end", "def create\n @pre_step = PreStep.new(params[:pre_step])\n\n respond_to do |format|\n if @pre_step.save\n format.html { redirect_to @pre_step, notice: 'Pre step was successfully created.' }\n format.json { render json: @pre_step, status: :created, location: @pre_step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pre_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @step_scenario = StepScenario.new(step_scenario_params)\n @step_scenario.scenario_id = current_scenario.id\n\n respond_to do |format|\n if @step_scenario.save\n format.html { redirect_to scenario_path(current_scenario), notice: \"Passo do cenário cadastrado com sucesso!\" }\n format.json { render :show, status: :created, location: @step_scenario }\n else\n format.html { render :new }\n format.json { render json: @step_scenario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(work_params.merge(depositor: current_user))\n\n respond_to do |format|\n if @work.save\n format.html do\n redirect_to work_version_file_list_path(@work, @work.versions.last),\n notice: 'Work was successfully created.'\n end\n format.json { render :show, status: :created, location: @work }\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @our_works = OurWork.new(our_work_params)\n if @our_works.plate_has_an_entry?\n render_default_error 'hay un error, Esta placa ya ha sido ingresada', 401\n else\n @our_works.date_arrival = Date.today.to_date\n @our_works.is_parking = true\n if @our_works.save\n render_success_format('Nueva entrada registrada', @our_works, true)\n end\n end\n rescue Exception => e\n render_default_error e, 401\n end", "def exercise_execution_params\n params.require(:exercise_execution).permit(:weight, :percentage, :reps, :time, :exercise_id, :session_id)\n end" ]
[ "0.6466669", "0.6334753", "0.6290922", "0.6250835", "0.61476487", "0.61150706", "0.6030995", "0.60242885", "0.6008771", "0.5931299", "0.5915848", "0.5899364", "0.5852997", "0.58372986", "0.5802952", "0.57927865", "0.5780055", "0.57152224", "0.5694496", "0.5674357", "0.5668656", "0.5651605", "0.56278116", "0.560171", "0.55973214", "0.55935043", "0.5591768", "0.55857414", "0.55759495", "0.5573106", "0.5552396", "0.5545893", "0.5545893", "0.5534857", "0.55265266", "0.55265266", "0.5522129", "0.5516826", "0.5492848", "0.5475111", "0.5473735", "0.54619205", "0.5459917", "0.5457227", "0.54571044", "0.54558533", "0.54533833", "0.54439574", "0.54382026", "0.5432733", "0.5413554", "0.5412758", "0.54099405", "0.5403084", "0.5402486", "0.5393961", "0.53934956", "0.53856504", "0.53631306", "0.5358215", "0.53509045", "0.5343399", "0.5332424", "0.5328559", "0.5327024", "0.5311276", "0.5310279", "0.5306601", "0.53053087", "0.5301621", "0.5301578", "0.5300016", "0.5299674", "0.5298496", "0.5297936", "0.5288682", "0.52868694", "0.5284233", "0.52832246", "0.5280361", "0.5274843", "0.5269787", "0.526725", "0.5262686", "0.525624", "0.52527446", "0.52517384", "0.52517086", "0.5250823", "0.5247383", "0.5246148", "0.523681", "0.5227151", "0.5225975", "0.5223777", "0.52234536", "0.5220691", "0.52126426", "0.520918", "0.5206365" ]
0.71624374
0
PATCH/PUT /workphases/1 PATCH/PUT /workphases/1.json
def update respond_to do |format| if @workphase.update(workphase_params) format.json { respond_with_bip(@workphase) } #this is added as best_in_place update wasn't holding format.html { redirect_to @workphase, notice: 'Workphase was successfully updated.' } #format.json { render :show, status: :ok, location: @workphase } else format.html { render :edit } format.json { render json: @workphase.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @work_step.update(work_step_params)\n format.html { redirect_to @work_plan, notice: 'Work step was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_plan }\n else\n format.html { render :edit }\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work = Work.find(params[:id])\n work_params = params[:work]\n work_params.delete('progress')\n respond_to do |format|\n if @work.update_attributes(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:workout][:workout_date] = \"#{params[:workout][:workout_date]} #{params[:workout][:time]}\"\n params[:workout] = params[:workout].slice(:workout_date, :exercises_attributes)\n @lift_name = params[:workout][:exercises_attributes][\"0\"][:lift_id]\n params[:workout][:exercises_attributes][\"0\"][:lift_id] = Lift.find_by_lift_name(@lift_name).id\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n if @workout.update_attributes(params[:workout])\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n # workflow_attributes = workflow_params\n # step_definitions_attributes = workflow_attributes.delete(\"step_definitions\")\n\n # StepDefinition.updateStepDefinitions(step_definitions_attributes)\n\n respond_to do |format|\n if @workflow.update(workflow_params)\n format.html { redirect_to @workflow, notice: 'Workflow was successfully updated.' }\n format.json { render :show, status: :ok, location: @workflow }\n else\n format.html { render :edit }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @phase.update(phase_params)\n format.html\n format.json { render :nothing => true }\n else\n format.html { render :edit }\n format.json { render json: @phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pending_work.update(pending_work_params)\n format.html { redirect_to @pending_work, notice: 'Pending work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pending_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @stages_work = StagesWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @stages_work.update_attributes(params[:stages_work])\r\n format.html { redirect_to @stages_work, notice: 'Stages work was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @stages_work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @work.update_attributes(params[:work])\n flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.work'))\n format.html { redirect_to work_url(@work) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render :action => \"edit\" }\n format.json { render :json => @work.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workflow.update(workflow_params)\n format.json { render json: @workflow, :layout => false }\n else\n #format.json { render json: @workflow.errors, status: :unprocessable_entity, :layout => false }\n end\n end\n end", "def update\n @project_phase = ProjectPhase.find(params[:id])\n\n respond_to do |format|\n if @project_phase.update_attributes(params[:project_phase])\n format.html { redirect_to @project_phase, :notice => 'Project phase was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project_phase.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @work = Work.find(params[:id])\n\n respond_to do |format|\n if @work.update_attributes(params[:work])\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work = Work.find(params[:id])\n\n respond_to do |format|\n if @work.update_attributes(params[:work])\n format.html { redirect_to action: 'index', flash: {notice: 'Work item was successfully updated.' }}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work.extra = process_extra if params[:work][:extra_keys] && params[:work][:extra_keys]!= \"\"\n respond_to do |format|\n if @work.update_attributes(params[:work].except(:extra_keys, :extra_values))\n Work.create_locations(@work) if @work.places#.changed?\n Location.destroy_unused\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @use_case = UseCase.find(params[:id])\n @use_case.data = params[:data].to_json\n\n respond_to do |format|\n if @use_case.update_attributes(params[:use_case])\n\n if params[:subaction]==\"step\"\n format.html { redirect_to requirements_project_use_case_path(@use_case.project, @use_case, :type=>\"step\"), notice: 'Use case was successfully updated.' }\n else\n format.html { redirect_to project_use_case_path(@project, @use_case), notice: 'Use case was successfully updated.' }\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @use_case.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n errors = Work.update(current_user, params[:id], work_params)\n if !errors\n format.json { render json: {}, status: :ok }\n else\n format.json { render json: { error: errors }, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @special_requirement.update(special_requirement_params)\n format.html { redirect_to @special_requirement, notice: 'Special requirement was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_requirement }\n else\n format.html { render :edit }\n format.json { render json: @special_requirement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end", "def update\n respond_to do |format|\n if @project_phase.update(project_phase_params)\n format.html { redirect_to @project_phase, notice: 'Project phase was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_phase }\n else\n format.html { render :edit }\n format.json { render json: @project_phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @phase = Phase.find(params[:id])\n\n respond_to do |format|\n if @phase.update_attributes(params[:phase])\n format.html { redirect_to @phase, :notice => 'Phase was successfully updated.' }\n format.json { respond_with_bip(@phase)}\n else\n format.html { render :action => \"edit\" }\n format.json { respond_with_bip(@phase)}\n end\n end\n end", "def update\n respond_to do |format|\n if @work_order_work_task.update(work_order_work_task_params)\n format.html { redirect_to @work_order_work_task, notice: 'Work order work task was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_order_work_task }\n else\n format.html { render :edit }\n format.json { render json: @work_order_work_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to [@task,@step], notice: 'Step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workout_routine.update(workout_routine_params)\n format.html { redirect_to @workout_routine, notice: 'Workout routine was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout_routine }\n else\n format.html { render :edit }\n format.json { render json: @workout_routine.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workobject = Workobject.find(params[:id])\n\n respond_to do |format|\n if @workobject.update_attributes(params[:workobject])\n format.html { redirect_to @workobject, notice: 'Workobject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workobject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @howitwork.update(howitwork_params)\n format.html { redirect_to admin_howitwork_url(@howitwork), notice: 'Howitwork was successfully updated.' }\n format.json { render :show, status: :ok, location: @howitwork }\n else\n format.html { render :edit }\n format.json { render json: @howitwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n @needs = @goal.needs\n respond_to do |format|\n if @goal.update(goal_params)\n format.html { redirect_to back_index_case_url, notice: 'Goal was successfully updated.' }\n # format.json { render :show, status: :ok, location: @goal }\n else\n format.html { render :edit }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @complex_task.update(complex_task_params)\n format.html { redirect_to @complex_task, notice: 'Complex task was successfully updated.' }\n format.json { render :show, status: :ok, location: @complex_task }\n else\n format.html { render :edit }\n format.json { render json: @complex_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n if @myworkout.update_attributes(params[:myworkout])\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @myworkout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project_step.update(project_step_params)\n format.html { redirect_to @project_step, notice: 'Project step was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_step }\n else\n format.html { render :edit }\n format.json { render json: @project_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work_order.update(work_order_params)\n format.html { redirect_to \"/\", notice: 'Work order was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_order }\n else\n format.html { render :edit }\n format.json { render json: @work_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @operation.update(operation_params)\n format.html { redirect_to @operation, notice: 'Operation was successfully updated.' }\n format.json { render :json => @operation.to_json(:include => :task) }\n else\n format.html { render json: @operation.errors, status: :unprocessable_entity }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workorder = Workorder.find(params[:id])\n\n respond_to do |format|\n if @workorder.update_attributes(params[:workorder])\n format.html { redirect_to @workorder, notice: 'Workorder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workorder.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @order_vehicle_workshop.update(order_vehicle_workshop_params)\n format.html { redirect_to @order_vehicle_workshop, notice: 'Order vehicle workshop was successfully updated.' }\n format.json { render :show, status: :ok, location: @order_vehicle_workshop }\n else\n format.html { render :edit }\n format.json { render json: @order_vehicle_workshop.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work_order.update(work_order_params)\n format.html { redirect_to @work_order, notice: \"Work order was successfully updated.\" }\n format.json { render :show, status: :ok, location: @work_order }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @work_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @active_workflow_step.update(active_workflow_step_params)\n format.html { redirect_to @active_workflow_step, notice: 'Active workflow step was successfully updated.' }\n format.json { render :show, status: :ok, location: @active_workflow_step }\n else\n format.html { render :edit }\n format.json { render json: @active_workflow_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @employment_contract.update(employment_contract_params)\n format.html { redirect_to request_steps_path, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @employment_contract }\n else\n format.html { render :edit }\n format.json { render json: @employment_contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @caloric_intake.update(caloric_intake_params)\n format.html { redirect_to @caloric_intake, notice: 'Caloric intake was successfully updated.' }\n format.json { render :show, status: :ok, location: @caloric_intake }\n else\n format.html { render :edit }\n format.json { render json: @caloric_intake.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pre_step = PreStep.find(params[:id])\n\n respond_to do |format|\n if @pre_step.update_attributes(params[:pre_step])\n format.html { redirect_to @pre_step, notice: 'Pre step was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pre_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work_process = WorkProcess.find(params[:id])\n\n respond_to do |format|\n if @work_process.update_attributes(work_process_params)\n format.html { redirect_to work_processes_path, notice: I18n.t('commons.successfully_updated') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_process.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @house_work.update(house_work_params)\n format.html { redirect_to @house_work, notice: 'House work was successfully updated.' }\n format.json { render :show, status: :ok, location: @house_work }\n else\n format.html { render :edit }\n format.json { render json: @house_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n goal = Goal.find params[:id]\n if goal.update(goal_params)\n render json: goal, status: 200\n else\n render json: goal.errors.full_messages, status: 422\n end\n end", "def update\n respond_to do |format|\n if @workorder.update(workorder_params)\n format.html { redirect_to @workorder, notice: 'Workorder was successfully updated.' }\n format.json { render :show, status: :ok, location: @workorder }\n else\n format.html { render :edit }\n format.json { render json: @workorder.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @reqdifficulty.update(reqdifficulty_params)\n format.html { redirect_to @reqdifficulty, notice: 'Reqdifficulty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reqdifficulty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @initiative = Initiative.find(params[:id])\n @initiative.phase_id=params[:phase_id]\n\n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n format.html { render :nothing => true }\n #format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @step = Step.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to @step, notice: 'Step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @extractions_extraction_forms_projects_sections_type1.update(extractions_extraction_forms_projects_sections_type1_params)\n format.html { redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section\n .extraction,\n anchor: \"panel-tab-#{ @extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section.id }\"),\n notice: t('success') }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @extractions_extraction_forms_projects_sections_type1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workpermit.update(workpermit_params)\n format.html { redirect_to @workpermit, notice: 'Workpermit was successfully updated.' }\n format.json { render :show, status: :ok, location: @workpermit }\n else\n format.html { render :edit }\n format.json { render json: @workpermit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @completed_work = args[:completed_work] if args.key?(:completed_work)\n @estimated_work = args[:estimated_work] if args.key?(:estimated_work)\n end", "def update\n respond_to do |format|\n if @works_item.update(work_params)\n format.html { redirect_to works_url, notice: 'Work Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @works_item}\n else\n format.html { render :edit }\n format.json { render json: @works_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to user_work_path(@user.id, @work.id), notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end \n end\n end", "def update\n respond_to do |format|\n if @story_part.update(story_part_params)\n format.html { redirect_to @story_part, notice: 'Story part was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @story_part.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n if @workflow.update_attributes(params[:workflow])\n format.html { redirect_to @workflow, notice: 'Workflow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n if @workflow.update_attributes(params[:workflow])\n format.html { redirect_to @workflow, notice: 'Workflow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n if @workflow.update_attributes(params[:workflow])\n format.html { redirect_to @workflow, notice: 'Workflow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n if @workflow.update_attributes(params[:workflow])\n format.html { redirect_to @workflow, notice: 'Workflow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @scientific_work.update(scientific_work_params)\n format.html { redirect_to @scientific_work, notice: 'Scientific work was successfully updated.' }\n format.json { render :show, status: :ok, location: @scientific_work }\n else\n format.html { render :edit }\n format.json { render json: @scientific_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @requirement.update_attributes(requirement_params)\n format.html { redirect_to action: :index, notice: 'Update Success.' }\n format.json { render action: :index, status: :accepted }\n else\n format.html { render action: :edit }\n format.json { render json: @requirement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @opt10075.update(opt10075_params)\n format.html { redirect_to @opt10075, notice: 'Opt10075 was successfully updated.' }\n format.json { render :show, status: :ok, location: @opt10075 }\n else\n format.html { render :edit }\n format.json { render json: @opt10075.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cooking_step.update(cooking_step_params)\n format.html { redirect_to @cooking_step, notice: 'Cooking step was successfully updated.' }\n format.json { render :show, status: :ok, location: @cooking_step }\n else\n format.html { render :edit }\n format.json { render json: @cooking_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end", "def update\n @work = Work.find(params[:id])\n if params.has_key?(:desc)\n puts \"desc\";\n @work.description = params[:desc]\n elsif params.has_key?(:status)\n @work.status = params[:status]\n puts @work.status\n # num = current_user.works.where(:all, :conditions => [\"status = ?\", params[:status]])\n # puts num\n # count the number of completed tasks \n else\n render :json => {:id => 0}\n end\n\n if @work.save\n puts @work.status\n render :json => {:id => @work.id}\n else\n render :json => {:id => 0}\n end \n\n end", "def update\n property = Property.find(params[:property_id])\n @work_order = property.work_orders.new(params[:work_order])\n\n respond_to do |format|\n if @work_order.update_attributes(params[:work_order])\n format.html { redirect_to customer_path(property.customer_id), notice: 'Work order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @job = Job.find(params[:job_id])\n @part = @job.parts.find(params[:id])\n\n respond_to do |format|\n if @part.update(part_params)\n format.html { redirect_to edit_job_path(@job.id), notice: 'Part was successfully updated.' }\n format.json { render :show, status: :ok, location: @part }\n else\n format.html { render edit_job_part_path(@job) }\n format.json { render json: @part.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workdetail = Workdetail.find(params[:id])\n @taskid = @workdetail.task_id\n respond_to do |format|\n if @workdetail.update_attributes(params[:workdetail])\n format.html { redirect_to :action => \"show\", :id => @taskid, notice: 'Workdetail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workdetail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work_order_status.update(work_order_status_params)\n format.html { redirect_to @work_order_status, notice: 'Work order status was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_order_status }\n else\n format.html { render :edit }\n format.json { render json: @work_order_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @phenological_stage.update(phenological_stage_params)\n format.html { redirect_to @phenological_stage, notice: 'Phenological stage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @phenological_stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @theoretical_part = TheoreticalPart.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @theoretical_part.update_attributes(params[:theoretical_part])\r\n format.html { redirect_to @theoretical_part, notice: 'Theoretical part was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @theoretical_part.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @step.update(step_params)\n format.html { redirect_to @step, notice: 'Step was successfully updated.' }\n format.json { render :show, status: :ok, location: @step }\n else\n format.html { render :edit }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @step.update(step_params)\n format.html { redirect_to @step, notice: 'Step was successfully updated.' }\n format.json { render :show, status: :ok, location: @step }\n else\n format.html { render :edit }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @subway.update(subway_params)\n format.html { redirect_to @subway, notice: 'Subway was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @subway.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @equipment_things_to_check.update(equipment_things_to_check_params)\n format.html { redirect_to @equipment_things_to_check, notice: 'Equipment things to check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @equipment_things_to_check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @work_plan.update_attributes(params[:work_plan])\r\n format.html { redirect_to @work_plan, notice: 'Work plan was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @step_seven.update(step_seven_params)\n format.html { redirect_to @step_seven, notice: 'Step seven was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_seven }\n else\n format.html { render :edit }\n format.json { render json: @step_seven.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @programme_exercise.update(programme_exercise_params)\n format.html { redirect_to @programme_exercise, notice: 'Programme exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @programme_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stepone.update(stepone_params)\n format.html { redirect_to mainpage_path(@stepone.mainpage), notice: 'Stepone was successfully updated.' }\n format.json { render :show, status: :ok, location: @stepone }\n else\n format.html { render :edit }\n format.json { render json: @stepone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@work = Work.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @work.update_attributes(params[:work])\n\t\t\t\tformat.html { redirect_to @work, notice: 'Work was successfully updated.' }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @work.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @dispatching = Dispatching.find(params[:id])\n workflow = @dispatching.workflow\n respond_to do |format|\n if params[:warranty] == \"进厂\"\n if @dispatching.update_attributes(params[:dispatching])\n workflow.update_attributes(:status => \"vehicle\")\n workflow.user_ids = params[:repairman_ids]\n workflow.users.each do |user|\n user.update_attributes(:status => \"busy\")\n end\n format.json { head :ok }\n else\n format.json { render :json => @dispatching.errors, :status => :unprocessable_entity }\n end\n elsif params[:warranty] == \"救援\"\n if @dispatching.update_attributes(params[:dispatching])\n workflow.update_attributes(:status => \"newpart\")\n format.json {head :ok}\n else\n format.json { render :json => @dispatching.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @workfile.update(workfile_params)\n format.html { redirect_to @workfile, notice: 'Workfile was successfully updated.' }\n format.json { render :show, status: :ok, location: @workfile }\n else\n format.html { render :edit }\n format.json { render json: @workfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @operations_check = OperationsCheck.find(params[:id])\n\n respond_to do |format|\n if @operations_check.update_attributes(operations_check_params)\n format.html { redirect_to @operations_check, \n notice: 'Operations check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @operations_check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @phase_detail.update(phase_detail_params)\n format.html { redirect_to @phase_detail, notice: 'Phase detail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @phase_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @step = Step.find(params[:id])\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to @step, notice: 'Step was successfully updated.' }\n format.json { render :json => {:message => \"Success\"} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repair.update(repair_params)\n format.html { redirect_to @repair, notice: 'Repair was successfully updated.' }\n format.json { render :show, status: :ok, location: @repair }\n \n if @repair.jobs.count == @repair.jobs.done.count\n @repair.update(done: true)\n end\n\n update_parts(@repair)\n @bus= Bus.find(@repair.bus_id)\n bus_update(@bus)\n\n else\n format.html { render :edit }\n format.json { render json: @repair.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @requirement.update(requirement_params)\n format.html { redirect_to @requirement, notice: 'Requirement was successfully updated.' }\n format.json { render :show, status: :ok, location: @requirement }\n else\n format.html { render :edit }\n format.json { render json: @requirement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: '修改成功!' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @art_work.update(art_work_params)\n format.html { redirect_to @art_work }\n format.json { render :show, status: :ok, location: @art_work }\n else\n format.html { render :edit }\n format.json { render json: @art_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @opttruck.update(opttruck_params)\n format.html { redirect_to @opttruck, notice: 'Opttruck was successfully updated.' }\n format.json { render :show, status: :ok, location: @opttruck }\n else\n format.html { render :edit }\n format.json { render json: @opttruck.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @step = Step.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to selection_step_path, notice: 'Step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workout_unit.update(workout_unit_params)\n format.html { redirect_to @workout_unit, notice: 'Workout unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @workout_unit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wait_order.update(wait_order_params)\n format.html { redirect_to @wait_order, notice: 'Wait order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wait_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n process_work_contributors\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium_specie_job_inv = MediumSpecieJobInv.find(params[:id])\n\n respond_to do |format|\n if @medium_specie_job_inv.update_attributes(params[:medium_specie_job_inv])\n format.html { redirect_to @medium_specie_job_inv, notice: 'Medium specie job inv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_specie_job_inv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_exercise.update(api_v1_exercise_params)\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_exercise }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n if @work_plan.update_attributes(params[:work_plan])\n format.html { redirect_to @work_plan, notice: 'Work plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\n end\n end\n #expire_action :index\n #expire_action :show\n end", "def update\n p = trial_params.clone\n if p[\"question_ids\"].nil?\n p[\"question_ids\"] = []\n end\n\n respond_to do |format|\n if @trial.update(p)\n format.html { redirect_to @trial, notice: 'Trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @step.update(step_params)\n render :show, status: :ok\n else\n render json: @step.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @open_source_work.update(open_source_work_params)\n format.html { redirect_to @open_source_work, notice: 'Open source work was successfully updated.' }\n format.json { render :show, status: :ok, location: @open_source_work }\n else\n format.html { render :edit }\n format.json { render json: @open_source_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @step_three.update(step_three_params)\n format.html { redirect_to @step_three, notice: 'Step three was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_three }\n else\n format.html { render :edit }\n format.json { render json: @step_three.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6750996", "0.6471228", "0.6376904", "0.6364787", "0.6357176", "0.6345471", "0.633668", "0.63190407", "0.62776226", "0.6256711", "0.6248621", "0.6243154", "0.6240256", "0.6227785", "0.61877036", "0.61834425", "0.6164427", "0.6164427", "0.6164427", "0.6164427", "0.61388904", "0.6112879", "0.6084651", "0.6077578", "0.6072745", "0.6070527", "0.60616726", "0.60591483", "0.6055287", "0.60427535", "0.6037322", "0.6034347", "0.6029971", "0.602934", "0.6025289", "0.60198075", "0.60087717", "0.60021293", "0.5978273", "0.59739834", "0.5973544", "0.5962977", "0.5959358", "0.5958496", "0.59545404", "0.59534377", "0.59504086", "0.59491235", "0.59426314", "0.59326345", "0.59320146", "0.5920955", "0.5919063", "0.5918177", "0.59119236", "0.59119236", "0.59119236", "0.59119236", "0.5910605", "0.5909722", "0.5909108", "0.590881", "0.59066445", "0.5905619", "0.5902527", "0.5900207", "0.5899205", "0.58941156", "0.58874863", "0.5885659", "0.58799404", "0.58799404", "0.5873942", "0.587333", "0.5872162", "0.58588386", "0.58576894", "0.58539194", "0.5852882", "0.58469415", "0.584677", "0.58466524", "0.5845807", "0.5843066", "0.5841428", "0.5841052", "0.5837827", "0.5836543", "0.5835689", "0.58298624", "0.58296746", "0.58296704", "0.582895", "0.5828224", "0.582453", "0.5824234", "0.5824119", "0.58164275", "0.5816016", "0.581588" ]
0.6745728
1
DELETE /workphases/1 DELETE /workphases/1.json
def destroy Workphase.find(params[:id]).destroy #@workphase.destroy respond_to do |format| format.html { redirect_to workphases_url, notice: 'Workphase was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @project_phase = ProjectPhase.find(params[:id])\n @project_phase.destroy\n\n respond_to do |format|\n format.html { redirect_to project_phases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_execution.destroy\n respond_to do |format|\n format.html { redirect_to exercise_executions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @phase.destroy\n respond_to do |format|\n format.html { redirect_to project_phases_path(@project.id), notice: 'Phase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step = Step.find(params[:id])\n @step.status = \"deleted\"\n @step.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end", "def destroy\r\n @stages_work = StagesWork.find(params[:id])\r\n @stages_work.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to stages_works_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @project_phase.destroy\n respond_to do |format|\n format.html { redirect_to project_phases_url, notice: 'Project phase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to quest_steps_url(@quest) }\n format.json { head :ok }\n end\n end", "def destroy\n @phase = Phase.find(params[:id])\n @phase.destroy\n\n respond_to do |format|\n format.html { render :layout => false }\n format.json { head :no_content }\n end\n end", "def destroy\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to @task }\n format.json { head :no_content }\n end\n end", "def destroy\n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to steps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @step_three.destroy\n respond_to do |format|\n format.html { redirect_to step_threes_url, notice: 'Step three was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pending_work.destroy\n respond_to do |format|\n format.html { redirect_to pending_works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @extractions_extraction_forms_projects_sections_type1.destroy\n respond_to do |format|\n format.html { redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section\n .extraction,\n anchor: \"panel-tab-#{ @extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section.id }\"),\n notice: t('removed') }\n format.json { head :no_content }\n end\n end", "def destroy\n @step_seven.destroy\n respond_to do |format|\n format.html { redirect_to step_sevens_url, notice: 'Step seven was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @extractions_extraction_forms_projects_sections_type1.destroy\n respond_to do |format|\n format.html do\n redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section\n .extraction,\n 'panel-tab': @extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_section\n .extraction_forms_projects_section\n .id),\n notice: t('removed')\n end\n format.json { head :no_content }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to @trip }\n format.json { head :no_content }\n end\n end", "def destroy\n @myb_evl_intake.destroy\n respond_to do |format|\n format.html { redirect_to myb_evl_intakes_url, notice: 'Myb evl intake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step_six.destroy\n respond_to do |format|\n format.html { redirect_to step_sixes_url, notice: 'Step six was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy \n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to selection_path(params[:selection_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @project_step.destroy\n respond_to do |format|\n format.html { redirect_to project_steps_url, notice: 'Project step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @step_definition.destroy\n respond_to do |format|\n format.html { redirect_to step_definitions_url, notice: 'Step definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pre_step = PreStep.find(params[:id])\n @pre_step.destroy\n\n respond_to do |format|\n format.html { redirect_to pre_steps_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @goal = Goal.find(params[:goal_id])\n # @solution = @goal.solutions.find(params[:id])\n @project = Project.find(params[:project_id])\n @goal = @project.goals.find(params[:goal_id])\n @solution = @goal.solutions.find(params[:id])\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to project_goal_path(@project, @goal), notice: 'Solution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @phase_detail.destroy\n respond_to do |format|\n format.html { redirect_to phase_details_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal_step.destroy\n respond_to do |format|\n format.html { redirect_to goal_steps_url, notice: \"Goal step was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @stepone.destroy\n respond_to do |format|\n format.html { redirect_to mainpage_path(@stepone.mainpage), notice: 'Stepone was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @completed_quest = CompletedQuest.find(params[:id])\n @completed_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to completed_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to steps_url, notice: 'Step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to steps_url, notice: 'Step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to steps_url, notice: 'Step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to steps_url, notice: 'Step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @solution = Solution.find(params[:id])\n @solution.destroy\n\n render json: { text: \"success\" }\n end", "def destroy\r\n @work_plan = WorkPlan.find(params[:id])\r\n @work_plan.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to work_plans_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @phase.destroy\n respond_to do |format|\n format.html { redirect_to phases_url, notice: \"Phase was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @house_work.destroy\n respond_to do |format|\n format.html { redirect_to house_works_url, notice: 'House work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cooking_step.destroy\n respond_to do |format|\n format.html { redirect_to cooking_steps_url, notice: 'Cooking step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @operations_check = OperationsCheck.find(params[:id])\n @operations_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n story_part_id = @story_part.id\n @story_part.destroy\n render :json => story_part_id\n end", "def destroy\n @caloric_intake.destroy\n respond_to do |format|\n format.html { redirect_to caloric_intakes_url, notice: 'Caloric intake was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n workout_plan = @single_plan.workout_plans.first\n @single_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(workout_plan_exercise_plans_url(workout_plan)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @step_scenario.destroy\n respond_to do |format|\n format.html { redirect_to step_scenarios_url, notice: 'Step scenario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step2 = Step2.find(params[:id])\n @step2.destroy\n\n respond_to do |format|\n format.html { redirect_to step2s_url }\n format.json { head :ok }\n end\n end", "def destroy\n @step = @guide.steps.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to guide_steps_path(@guide) }\n format.json { head :no_content }\n end\n end", "def destroy\n @solution.destroy\n render json: {solutions: @solution}, status: 200\n end", "def destroy\n @programme_exercise.destroy\n respond_to do |format|\n format.html { redirect_to programme_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workorder = Workorder.find(params[:id])\n @workorder.destroy\n\n respond_to do |format|\n format.html { redirect_to workorders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @experiment.destroy\n respond_to do |format|\n format.html { redirect_to project_phase_path(@project.id, @phase.id), notice: 'Experiment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workobject = Workobject.find(params[:id])\n @workobject.destroy\n\n respond_to do |format|\n format.html { redirect_to workobjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @summary_phase.destroy\n respond_to do |format|\n format.html { redirect_to summary_phases_url, notice: 'Summary phase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n title = @work_step.name\n\n if @work_step.destroy\n flash[:notice] = \"\\\"#{title}\\\" was deleted successfully.\"\n\n redirect_to @work_plan\n else\n flash[:error] = \"\\\"#{title}\\\" was not deleted due an error.\"\n render :show\n end\n end", "def destroy\n @step_four.destroy\n respond_to do |format|\n format.html { redirect_to step_fours_url, notice: 'Step four was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tc_detail_step = TcDetailStep.find(params[:id])\n @tc_detail_step.destroy\n\n respond_to do |format|\n format.html { redirect_to tc_detail_steps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @step_type = StepType.find(params[:id])\n @step_type.destroy\n\n respond_to do |format|\n format.html { redirect_to step_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to menu_docencia_3_path, notice: 'La actividad se elimino con exito.' }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @project_step = ProjectStep.find(params[:id])\n @project_step.destroy\n\n respond_to do |format|\n format.html { redirect_to(project_steps_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @step_activity = StepActivity.find(params[:id])\n @step_activity.destroy\n\n respond_to do |format|\n format.html { redirect_to step_activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shuttle_run.destroy\n respond_to do |format|\n format.html { redirect_to shuttle_runs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_duration.destroy\n respond_to do |format|\n format.html { redirect_to work_durations_url, notice: 'Work duration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @subway.destroy\n respond_to do |format|\n format.html { redirect_to subways_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_instruction = ExerciseInstruction.find(params[:id])\n @exercise_instruction.destroy\n\n respond_to do |format|\n format.html { redirect_to @exercise_instruction.exercise }\n format.json { head :no_content }\n end\n end", "def destroy\n @scenario = Scenario.find(params[:id])\n @scenario.destroy\n\n respond_to do |format|\n format.html { redirect_to scenarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @scenario = Scenario.find(params[:id])\n @scenario.destroy\n\n respond_to do |format|\n format.html { redirect_to scenarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @active_workflow_step.destroy\n respond_to do |format|\n format.html { redirect_to active_workflow_steps_url, notice: 'Active workflow step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workdetail = Workdetail.find(params[:id])\n @workdetail.destroy\n @taskid = @workdetail.task_id\n respond_to do |format|\n format.html { redirect_to :action => \"show\", :id => @taskid }\n format.json { head :no_content }\n end\n end", "def destroy\n @myworkout = Myworkout.find(params[:id])\n @myworkout.destroy\n\n respond_to do |format|\n format.html { redirect_to myworkouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @open_source_work.destroy\n respond_to do |format|\n format.html { redirect_to open_source_works_url, notice: 'Open source work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @production_phase.destroy\r\n respond_to do |format|\r\n format.html { redirect_to production_phases_url, notice: 'تم مسح دورة أنتاجية' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @work_plan = WorkPlan.find(params[:id])\n @work_plan.destroy\n #render :text => params\n #return\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @howitwork.destroy\n respond_to do |format|\n format.html { redirect_to admin_howitworks_url, notice: 'Howitwork was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @renting_phase.destroy\n respond_to do |format|\n format.html { redirect_to renting_phases_url, notice: 'Renting phase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project_step_m.destroy\n respond_to do |format|\n format.html { redirect_to project_step_ms_url, notice: 'Project step m was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @scientific_work.destroy\n respond_to do |format|\n format.html { redirect_to scientific_works_url, notice: 'Scientific work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @caseworkline.destroy\n respond_to do |format|\n format.html { redirect_to caseworklines_url, notice: 'Caseworkline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = current_user\n @part_inst.destroy\n respond_to do |format|\n format.html { redirect_to part_insts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n secureEnter @step\n @step.destroy\n respond_to do |format|\n format.html { redirect_to edit_post_path(@step.post.id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @workflow = Workflow.find(params[:id])\n @workflow.destroy\n\n respond_to do |format|\n format.html { redirect_to workflows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workflow = Workflow.find(params[:id])\n @workflow.destroy\n\n respond_to do |format|\n format.html { redirect_to workflows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workflow = Workflow.find(params[:id])\n @workflow.destroy\n\n respond_to do |format|\n format.html { redirect_to workflows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workflow = Workflow.find(params[:id])\n @workflow.destroy\n\n respond_to do |format|\n format.html { redirect_to workflows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workorder.destroy\n respond_to do |format|\n format.html { redirect_to workorders_url }\n format.json { head :no_content }\n end\n end", "def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend", "def destroy\n @equipment_things_to_check.destroy\n respond_to do |format|\n format.html { redirect_to equipment_things_to_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opt10075.destroy\n respond_to do |format|\n format.html { redirect_to opt10075s_url, notice: 'Opt10075 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workpermit.destroy\n respond_to do |format|\n format.html { redirect_to workpermits_url, notice: 'Workpermit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @step_command.destroy\n respond_to do |format|\n format.html { redirect_to step_commands_url, notice: 'Step command was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @second_work = SecondWork.find(params[:id])\r\n @second_work.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to second_works_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @qx_runway.destroy\n respond_to do |format|\n format.html { redirect_to qx_runways_url, notice: 'Runway was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_routine.destroy\n respond_to do |format|\n format.html { redirect_to workout_routines_url, notice: 'Workout routine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to works_url, notice: 'Work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to works_url, notice: 'Work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7165512", "0.69539744", "0.69392157", "0.6895234", "0.684572", "0.6843697", "0.6832605", "0.6788403", "0.67702824", "0.67443514", "0.67420965", "0.6740847", "0.6736868", "0.67111576", "0.67104536", "0.6676311", "0.66761434", "0.66761434", "0.66761434", "0.66761434", "0.6674216", "0.66688395", "0.6647946", "0.6645755", "0.6627324", "0.66231734", "0.6616999", "0.6615851", "0.66089845", "0.66021574", "0.6597443", "0.6587065", "0.6575515", "0.65734273", "0.6569974", "0.6569974", "0.6569974", "0.6569974", "0.6569219", "0.6564731", "0.65622723", "0.65615064", "0.65562993", "0.65542716", "0.65524775", "0.6550291", "0.6550251", "0.65490586", "0.65481305", "0.65451175", "0.65441555", "0.65243936", "0.6522365", "0.6516055", "0.6515457", "0.6509259", "0.65090173", "0.65050817", "0.6500775", "0.6497256", "0.64967674", "0.6496143", "0.6489056", "0.6489012", "0.64878935", "0.6477785", "0.647136", "0.6469746", "0.6469746", "0.6460391", "0.6459215", "0.64589375", "0.64560556", "0.6455792", "0.64552635", "0.64547014", "0.6453508", "0.64498127", "0.6449765", "0.6447449", "0.6447112", "0.6445788", "0.64420736", "0.64408904", "0.64408904", "0.64408904", "0.64408904", "0.64408314", "0.6439612", "0.643518", "0.64338577", "0.6430086", "0.6428516", "0.64272404", "0.6426343", "0.64248925", "0.64248925", "0.642003", "0.6419471", "0.6419471" ]
0.7459516
0
Use callbacks to share common setup or constraints between actions.
def set_workphase @workphase = Workphase.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def workphase_params params.require(:workphase).permit(:worknote, :dateChanged, :product_id, :phase_id, :employee_id, :adminNote, :totalMade, :totalToMake, :dateComplete) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "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 filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def 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.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004", "0.6290563", "0.6284484", "0.62436926", "0.6239928", "0.62184125", "0.62158304", "0.6210187", "0.6194002", "0.61786795", "0.61759156", "0.617342", "0.6162248", "0.61528504", "0.61527", "0.6146735", "0.6122714", "0.61169004", "0.61082125", "0.61052656", "0.6091036", "0.60807735", "0.6070328", "0.60634184", "0.60213035", "0.6017676", "0.6013606", "0.601112", "0.6007318", "0.6007318", "0.6001461", "0.6001135", "0.59966296", "0.5992013", "0.59919006", "0.599182", "0.5980991", "0.59676576", "0.5960269", "0.59588194", "0.59585214", "0.59578323", "0.5953503", "0.5952524", "0.59432703", "0.5939858", "0.59388995", "0.59388995", "0.5933866", "0.5930038", "0.5925672", "0.5924214", "0.59169805", "0.59106255", "0.5910254", "0.59086037", "0.5906149", "0.5898294", "0.58981514", "0.5896171", "0.58944154", "0.58943397", "0.5892325", "0.5887239", "0.58842856", "0.5880209", "0.5874584", "0.58694917", "0.5868719", "0.58669394", "0.5866552", "0.58662945", "0.5864085", "0.58623236", "0.5862258", "0.58597904", "0.58579135", "0.58542645", "0.5853335", "0.58517563", "0.5850614" ]
0.0
-1
GET /people/1/contributions GET .people/1/contributions.json
def index @contributions = @person.contributions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n user = User.find_by(id: params[:user_id])\n return respond_with contributions: [], status: :not_found if user.nil?\n contributions = user.contributions\n respond_with contributions: contributions, status: :ok\n end", "def index\n @contributions = Contribution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contributions }\n end\n end", "def get_contributions(repository)\n Git.contributions GithubAPI.name(@username), repository\n end", "def show\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contribution }\n end\n end", "def index\n @membership_contributions = MembershipContribution.all\n end", "def index\n @contributions = Contribution.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contributions }\n end\n end", "def show\n @aux = Contribution.exists?(params[:id])\n respond_to do |format|\n if @aux\n @contribution = Contribution.find(params[:id])\n format.json { render json: @contribution}\n else\n format.json { render json:{status:\"error\", code:404, message: \"Contribution with ID '\" + params[:id].to_s + \"' not found\"}, status: :not_found}\n end\n end\n end", "def index\n @contributions = Contribution.where(text:\"\").order(points: :desc)\n respond_to do |format|\n format.json { render json: @contributions}\n end\n end", "def index\n @contributions = Contribution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contributions }\n end\n end", "def ask\n @view = VIEWS[:ask]\n @contributions = Contribution.where(url: '')\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @contributions }\n end\n end", "def index\n @contributions = Contribution.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @contributions.to_xml }\n end\n end", "def display_contributions(repo_full_name)\n repo = Commitchamp::Repo.find_by(full_name: repo_full_name)\n contributors = repo.contributions.order('additions + deletions + commits DESC').limit(10)\n puts \"\\n##Contributions for '#{repo.full_name}'\"\n puts \"\\nUsername | Additions | Deletions | Commits\"\n contributors.each do |x|\n puts \"#{x.user.login} | #{x.additions} | #{x.deletions} | #{x.commits}\"\n end\n puts\n end", "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contribution }\n end\n end", "def shared_contributions\n Contribution.find(:all,\n :select => \"contributions.*\",\n :joins => \"JOIN policies p on (contributions.policy_id = p.id) JOIN permissions e on (p.id = e.policy_id)\",\n :conditions => [ \"e.contributor_id=? AND e.contributor_type = 'Network'\", id ])\n end", "def index\n @people = search Person.involved_in(@conference)\n\n respond_to do |format|\n format.html { @people = @people.paginate page: page_param }\n format.json\n end\n end", "def index\n @collaborations = Collaboration.where(:project_id => params[:project_id])\n respond_with @collaborations\n end", "def index\n @projects_people = ProjectsPerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects_people }\n end\n end", "def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end", "def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end", "def index\n @projects = Project.includes(:participants).all\n\n render json: @projects, include: :participants, status: 200\n end", "def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end", "def index\n @contributions = Contribution.order(\"id DESC\").page params[:page]\n\n @contribution = Contribution.new\n @contribution.contributor = session[:contributor] if session[:contributor]\n @contribution.email = session[:email] if session[:email]\n end", "def show\n render json: @project, include: :participants, status: 200\n end", "def person(id)\n get(\"/catalog/people/#{id.to_s}\")\n end", "def index\n @collaborators = User.includes(:github_account).\n where.not(id: params[:ineligible_user_ids]).\n limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end", "def index\n @contributors = Contributor.all\n end", "def create\r\n @contribution = Contribution.new(contribution_params)\r\n @contribution.contributable_type = \"Book\"\r\n @contribution.person = @person\r\n\r\n respond_to do |format|\r\n if @contribution.save\r\n format.html { redirect_to person_contributions_path(@person), notice: 'Contribution was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: person_contributions_path(@contribution) }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def split_contributions(org, repo)\n total_contributors = []\n page = 1\n contributions = @github.contributions_page(org, repo).to_a\n total_contributors.concat(contributions)\n total_contributors\n end", "def contributions_as_hash\n load_contributions unless @contributions\n @contributions\n end", "def index\n @pledges = Pledge.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pledges }\n end\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def show\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contribution }\n end\n end", "def show\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contribution }\n end\n end", "def show\n @projects_person = ProjectsPerson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projects_person }\n end\n end", "def contributors_stats(repo, options = {})\n get \"#{Repository.path repo}/stats/contributors\", options\n end", "def index\n respond_to do |format|\n format.json do\n @memberships = @project.memberships.order('created_at DESC').limit(10)\n @memberships = @memberships.user_prefix(params[:query]) if params[:query].present?\n\n render json: decorate(@memberships)\n end\n end\n end", "def index\n @people = Person.includes(:registry).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @people }\n end\n end", "def show\n Contribution.current_user = current_api_user\n render json: @post.as_json(except: [:post_id, :contribution_id, :updated_at], :methods => [:author, :liked])\n end", "def index\n @communities = Community.all\n render json: {items: @communities}\n end", "def people\n Sifter.\n get(api_people_url).\n fetch(\"people\", []).\n map { |p| Sifter::Person.new(p) }\n end", "def people\n Sifter.\n get(api_people_url).\n fetch(\"people\", []).\n map { |p| Sifter::Person.new(p) }\n end", "def user_repos\n @repos = @github.repos.list user: params[:username]\n render json: @repos\n end", "def show\n @person_interest = PersonInterest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @person_interest }\n end\n end", "def index\n @undergraduate_majors = UndergraduateMajor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @undergraduate_majors }\n end\n end", "def get_contributions(obj, items)\n prefix = obj[\"DOI\"][/^10\\.\\d{4,5}/]\n\n Array(items).reduce([]) do |sum, item|\n orcid = item.split(':', 2).last\n orcid = validate_orcid(orcid)\n\n return sum if orcid.nil?\n\n sum << { prefix: prefix,\n message_type: \"contribution\",\n relation: { \"subj_id\" => orcid_as_url(orcid),\n \"obj_id\" => obj[\"pid\"],\n \"source_id\" => source_id,\n \"publisher_id\" => obj[\"publisher_id\"],\n \"registration_agency_id\" => \"datacite\",\n \"occurred_at\" => obj[\"issued\"] },\n obj: obj }\n end\n end", "def index\n @people = Person.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @people }\n end\n end", "def contributions_in_time_range(start_time: (Time.now.at_beginning_of_day - 24.hours).iso8601, \n end_time: Time.now.at_beginning_of_day.iso8601)\n request_uri = \"/contributions?destination=#{@entity.to_s}&\" +\n \"payment_timestamp=#{start_time.to_s}/\" +\n \"#{end_time.to_s}\"\n response = make_request(request_uri: request_uri, authentication: @auth)\n response[\"contributions\"]\n end", "def show\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @contribution.to_xml }\n end\n end", "def index\n @communities = Community.all\n respond_with @communities\n end", "def create\n redirect_to '/auth/google_oauth2' unless user_is_logged_in?\n\n @contribution = Contribution.new(contribution_params)\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to @contribution, notice: 'Contribution was successfully created.' }\n format.json { render :show, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def fetch_people\n @people = People.find(params[:id])\n end", "def index\n @issues = Issue.where({assignee: current_user.github_username})\n\n render json: @issues\n end", "def index\n @people = Person.includes(:names).search(params[:search]).order(\"person_names.last_name ASC\")\n\n if params[:state] == 'in_project'\n @people = @people.joins(user: :memberships)\n end\n\n respond_to do |format|\n format.html { render layout: 'fluid' } # index.html.erb\n format.json { render json: @people }\n end\n \n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def index\n @memberships = Membership.where(user_id: current_user_id).includes(:project)\n project_array = []\n @memberships.each do |membership|\n project_array.push membership.project\n end\n json_response(project_array)\n end", "def destroy\n @contribution = Contribution.find(params[:id])\n @contribution.destroy\n\n respond_to do |format|\n format.html { redirect_to contributions_url }\n format.json { head :no_content }\n end\n end", "def get_contributors_of_a_repository(username,repo_name) # :yields: JSON\n uri=URI.parse(@@uri_builder.get_repo_content(Api_options::REPO::CONTRIBUTORS,username,repo_name))\n http= HttpHandler.initiate_http(uri)\n begin\n response=HttpHandler.get_response(http,uri)\n rescue ArgumentError\n puts \"Request failed with code: #{response.code}\"\n else\n @@responseStatus=true\n return response\n end\n end", "def show\n @community = Community.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @community }\n end\n end", "def index\n case params[:eligible_for]\n when 'collaboration'\n @collaborators = eligible_collaborators.limit(20)\n when 'ownership'\n @collaborators = eligible_owners.limit(20)\n else\n @collaborators = User.none\n end\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def contribution_params\n params.require(:contribution).permit(:text, :contributor, :email)\n end", "def set_membership_contribution\n @membership_contribution = MembershipContribution.find(params[:id])\n end", "def index\n @organization_memberships = OrganizationMembership.where(user_id: params['user_id'])\n authorize @organization_memberships\n\n render json: @organization_memberships\n end", "def contribution_params\n params.require(:contribution).permit(:titulo, :url, :puntos, :text, :tipo, :user_id)\n end", "def index\n if params[:contribution_type] == \"show\"\n @contributions = Contribution.where.not(url: '').order(created_at: :desc)\n elsif params[:contribution_type] == \"ask\"\n @contributions = Contribution.where.not(text: '').order(created_at: :desc)\n elsif params[:contribution_type] == nil || params[:contribution_type] == ''\n @contributions = Contribution.all.order(created_at: :desc)\n else\n render :json => {:status => \"400\", :error => \"Bad Request\"}, status: :bad_request\n end\n end", "def contribution_params\n params.require(:contribution).permit(:titulo, :user_id, :url, :puntos, :text)\n end", "def index\n\n @people = Person.filter(params.slice(:name_like))\n @people = @people.where([\"union_id = ?\", current_person.union_id]) if request.format.json? && !owner?\n @people = @people.where(\"not invited_by_id is null\").order([:last_name, :first_name, :id])\n \n respond_to do |format|\n format.html \n format.json \n end\n end", "def index\n @communities = @district.communities.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @communities }\n end\n end", "def contribution_params\n params.require(:contribution).permit(:contribution_url, :contribution_category, :user_id, :username, category_ids: [] )\n end", "def index\n professors = Professor.includes(:courses).all\n\n render json: professors.to_json(include: :courses)\n end", "def index\n authorize! :index, Campus, :message => 'Acceso denegado.'\n @campuses = @university.campuses\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @campuses }\n end\n end", "def index\n @communities = Community.all\n\n render json: @communities.to_json(include: {posts: {include: :replies} })\n end", "def create\n @contribution = Contribution.new(contribution_params)\n session[:contributor] = @contribution.contributor\n session[:email] = @contribution.email\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to contributions_url, notice: '投稿しました' }\n format.json { render :index, status: :created, location: @contribution }\n else\n @contributions = Contribution.order(\"id DESC\").page params[:page]\n format.html { render :index }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def index\n \t@people = Person.all\n respond_to do |format|\n format.json { render json: @people, status: :ok }\n end\n end", "def index\n @accounts = current_user.person.linked_in_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n @communities = Community.search(params[:search], params[:page])\n respond_with(@communities)\n end", "def participants\n expose Challenge.participants(@oauth_token, params[:challenge_id].strip)\n end", "def show\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collaborator }\n end\n end", "def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def index\n @collaborations = Collaboration.all\n end", "def index\n @users = User.all\n render json: @users.to_json(include: ['coins']) \n end", "def get_coins\n get(\"/getcoins\")\n end", "def show\n @competitor = Competitor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competitor }\n end\n end", "def index\n @repos = @user.repos.includes(:user)\n render json: to_json(@repos)\n end", "def get_my_issues\n get_json( GITHUB_ISSUES_URL ).each do |item|\n puts \"#{ item[ 'repository' ][ 'full_name' ] }: ##{ item[ 'number' ] } #{ item[ 'title' ] } | href=#{ item[ 'html_url' ] }\"\n end\nend", "def index\n @posts = Post.all.where('tipo = ?','url').order('points DESC')\n Contribution.current_user = current_api_user\n render json: @posts.as_json(except: [:post_id, :contribution_id, :updated_at], :methods => [:author, :liked])\n end", "def index\n respond_with(@people)\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def api_v1_contribution_params\n params.fetch(:api_v1_contribution, {})\n end", "def credit\n handle_response(get(\"/credit.json\"))\n end", "def index\n @projects = current_user.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def load_contributions\n @contributions = Hash.new\n repositories.each do |f|\n conts = get_contributions(f)\n @contributions[f] = conts unless conts.empty?\n end\n\n @contributions\n end", "def index\n \n @interests = Interest.find(@interestsId)\n \n if params[:persona_id] == nil \n @interests = Interest.order(:name) \n end\n \n respond_to do |format|\n format.json { render :json => @interests }\n end\n end", "def index\n @people = Person.all\n respond_to do |format|\n format.json { \n render json: @people, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end", "def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end" ]
[ "0.75771564", "0.7078139", "0.66454154", "0.65114063", "0.6270358", "0.62547076", "0.6238534", "0.6173667", "0.61654156", "0.61460084", "0.61370933", "0.6009422", "0.5957173", "0.5831093", "0.5772077", "0.5753856", "0.57238215", "0.56874496", "0.5684164", "0.56696355", "0.5661611", "0.56585866", "0.5645139", "0.56413263", "0.5638838", "0.56251574", "0.5620678", "0.56164706", "0.560347", "0.5560685", "0.5554843", "0.5554137", "0.55491173", "0.55491173", "0.55273443", "0.55175793", "0.55174834", "0.55031884", "0.54958886", "0.5489814", "0.54833853", "0.54833853", "0.5465456", "0.5456275", "0.5455855", "0.54481524", "0.5437792", "0.5424002", "0.5413198", "0.5410914", "0.5410705", "0.5405612", "0.53971267", "0.5395542", "0.5388461", "0.5388461", "0.5388113", "0.5385454", "0.53804797", "0.53747475", "0.5370258", "0.5365488", "0.5363016", "0.53592175", "0.53548926", "0.53541756", "0.5354121", "0.5353583", "0.5349495", "0.5348312", "0.53450674", "0.5335846", "0.5332982", "0.5327173", "0.5326427", "0.5319804", "0.53161395", "0.53140336", "0.5312321", "0.5310978", "0.53090066", "0.53081983", "0.53004646", "0.5290827", "0.5290275", "0.5288703", "0.5287885", "0.52854437", "0.52854097", "0.52810055", "0.52810055", "0.52810055", "0.52810055", "0.5280702", "0.52716726", "0.5270732", "0.52661407", "0.52651924", "0.5265005", "0.5264511" ]
0.7270595
1
GET /people/1/contributions/new GET /people/1/contributions/new.json
def new @contribution = Contribution.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contribution }\n end\n end", "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to @contribution, notice: 'Contribution was successfully created.' }\n format.json { render json: @contribution, status: :created, location: @contribution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contribution }\n end\n end", "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contribution }\n end\n end", "def create\r\n @contribution = Contribution.new(contribution_params)\r\n @contribution.contributable_type = \"Book\"\r\n @contribution.person = @person\r\n\r\n respond_to do |format|\r\n if @contribution.save\r\n format.html { redirect_to person_contributions_path(@person), notice: 'Contribution was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: person_contributions_path(@contribution) }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def new\n @gitto = Gitto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitto }\n end\n end", "def new\n @interested = Interested.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interested }\n end\n end", "def create\n redirect_to '/auth/google_oauth2' unless user_is_logged_in?\n\n @contribution = Contribution.new(contribution_params)\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to @contribution, notice: 'Contribution was successfully created.' }\n format.json { render :show, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @colaboration = Colaboration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colaboration }\n end\n end", "def new\n @projects_person = ProjectsPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projects_person }\n end\n end", "def new\n @research = Research.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research }\n end\n end", "def new\n @contribution_record = ContributionRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contribution_record }\n format.xml { render xml => @contribution_record }\n end\n end", "def new\n @person_interest = PersonInterest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person_interest }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interest }\n end\n end", "def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community }\n end\n end", "def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = current_user.projects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @membership = Membership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership }\n end\n end", "def new\n @person = Person.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @gist = Gist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gist }\n end\n end", "def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership }\n end\n end", "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interest }\n end\n end", "def new\n @membership = Membership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @membership }\n end\n end", "def new\n @pledge = Pledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pledge }\n end\n end", "def new\n @pledge = Pledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pledge }\n end\n end", "def new\n @collaborator = Collaborator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collaborator }\n end\n end", "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interest }\n end\n end", "def new\n @person = people_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n get_work; get_subject\n @work_has_subject = WorkHasSubject.new(:work => @work, :subject => @subject)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @work_has_subject }\n end\n end", "def new\n @project = Project.new(user_id: current_user.id)\n find_people_list\n fetch_clients\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end", "def new\n @participation = Participation.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participation }\n end\n end", "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n flash[:notice] = 'Contribution was successfully created.'\n format.html { redirect_to(@contribution) }\n format.xml { render :xml => @contribution, :status => :created, :location => @contribution }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contribution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n flash[:notice] = 'Contribution was successfully created.'\n format.html { redirect_to(@contribution) }\n format.xml { render :xml => @contribution, :status => :created, :location => @contribution }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contribution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @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.json { render json: @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.json { render json: @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.json { render json: @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.json { render json: @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.json { render json: @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.json { render json: @person }\n end\n end", "def new\n @git_datum = GitDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @git_datum }\n end\n end", "def new\n @provider = current_company.providers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end", "def new\n @income = Income.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @income }\n end\n end", "def new\n @major = Major.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @major }\n end\n end", "def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end", "def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end", "def new\n @participate = Participate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participate }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end", "def new\n @competitor = Competitor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competitor }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @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.json { render json: @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.json { render json: @participant }\n end\n end", "def new\n @projecct = Projecct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projecct }\n end\n end", "def new\n @person = Person.new\n set_person_attribute_defaults(@person)\n @provider = Provider.find(params[:provider_id]) unless params[:provider_id].blank?\n if @provider\n @person.person_provider_links.build(:psu_code => @psu_code,\n :provider => @provider,\n :person => @person,\n :is_active_code => 1)\n @person.sampled_persons_ineligibilities.build(:psu_code => @psu_code,\n :person => @person,\n :provider => @provider)\n end\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @person }\n end\n end", "def new\n @concern = Concern.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concern }\n end\n end", "def new\n @speciality = Speciality.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @speciality }\n end\n end", "def new\n @competent = Competent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competent }\n end\n end", "def new\n @interested_user = InterestedUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interested_user }\n end\n end", "def new\n @user = current_user\n @research_c = ResearchC.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research_c }\n end\n end", "def new\n \t\t@interested = Interested.new\n\n \t\trespond_to do |format|\n \t\t\tformat.html #new.html.erb\n \t\t\tformat.json { render json: @interested }\n \t\tend\n \tend", "def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end", "def new\n @intention = Intention.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intention }\n end\n end", "def new\n @camp = Camp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @camp }\n end\n end", "def new\n @camp = Camp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @camp }\n end\n end", "def new\r\n @org = Org.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @org }\r\n end\r\n end", "def create\n @page = Page.new(params[:page])\n\n respond_to do |format|\n if @page.save\n @contribution = @page.contributions.build(:user_id => current_user.id)\n @contribution.save\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\n format.json { render json: @page, status: :created, location: @page }\n else\n format.html { render action: \"new\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @case_study = CaseStudy.new(params[:case_study].merge(:summary => 'Welcome to your new case study! May it bring joy to your life, and the lives of others.<hr>You can begin adding content by choosing Actions->Edit.'))\n\n respond_to do |format|\n if @case_study.save\n @contribution = @case_study.contributions.build(:user_id => current_user.id)\n @contribution.save\n format.html { redirect_to @case_study, notice: 'Case study was successfully created.' }\n format.json { render json: @case_study, status: :created, location: @case_study }\n else\n format.html { render action: \"new\" }\n format.json { render json: @case_study.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = Person.new\n @companies = Company.pluck(:name)\n\n authorize! :create, Person\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def create\n if (current_user)\n @contribution = Contribution.new(contribution_params)\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to \"\" }\n format.json { render :index, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n elsif (params[:contribution][:url] != nil && params[:contribution][:text] != nil) || \n (params[:contribution][:url] == nil && params[:contribution][:text] == nil) \n render :json => {:status => \"400\", :error => \"Bad Request\"}, status: :bad_request\n else\n miId = decodeToken(params[:user_token])\n @miuser = User.find(miId) # comprueba que no existe el user con exte token\n params[:contribution][:user_id] = miId\n params[:contribution][:puntos] = 0;\n @contribution = Contribution.new(contribution_params)\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to \"\" }\n format.json { render :show, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end \n end", "def new\n @work = Work.new\n\n respond_to do |format|\n format.json { render json: @work }\n end\n end", "def new\n @work = Work.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work }\n end\n end", "def new\n @work = Work.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work }\n end\n end", "def new\n @projeto = Projeto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projeto }\n end\n end", "def new\n @crime = Crime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @crime }\n end\n end", "def new\n @interesting = Interesting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interesting }\n end\n end", "def new\n authorize! :create, Project\n \n @project = Project.new\n puts @project\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @work = Work.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work }\n end\n end", "def new\n\t\t@person = Person.new\n\t\t# render json: @person #skips the view, and just renders out the json\n\tend", "def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n end", "def new\n @money = Money.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @money }\n end\n end", "def new\n @slab = Slab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @slab }\n end\n end", "def new\n @competition = Competition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competition }\n end\n end", "def new\n @competition = Competition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competition }\n end\n end", "def new\n @competition = Competition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competition }\n end\n end", "def new\n @person = Person.new\n @work = Work.find(params[:work_id]) if params[:work_id]\n @expression = Expression.find(params[:expression_id]) if params[:expression_id]\n @manifestation = Manifestation.find(params[:manifestation_id]) if params[:manifestation_id]\n @person.work_id = @work.id if @work\n @person.expression_id = @expression.id if @expression\n @person.manifestation_id = @manifestation.id if @manifestation\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @patron_merge = PatronMerge.new\n @patron_merge.patron = @patron\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @patron_merge }\n end\n end", "def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end", "def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club }\n end\n end", "def new\n @persons_release = PersonsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persons_release }\n end\n end", "def create\n @contribution = Contribution.new(contribution_params)\n session[:contributor] = @contribution.contributor\n session[:email] = @contribution.email\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to contributions_url, notice: '投稿しました' }\n format.json { render :index, status: :created, location: @contribution }\n else\n @contributions = Contribution.order(\"id DESC\").page params[:page]\n format.html { render :index }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\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 authorize! :index, @user, :message => 'Not authorized as an administrator.'\n @specialist = Specialist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @specialist }\n end\n end", "def new\n @assigned_project = AssignedProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assigned_project }\n end\n end", "def new\n authorize! :new, WorkingExperience, :message => 'Not authorized as an administrator.'\n @user = User.find(params[:user_id])\n @working_experience = @user.working_experiences.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @working_experience }\n format.js\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.json { render json: @project }\n format.html # new.html.erb\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end" ]
[ "0.7782866", "0.707465", "0.700802", "0.700802", "0.70038974", "0.6954761", "0.69374967", "0.6936159", "0.6926906", "0.6901303", "0.68514496", "0.68061703", "0.68017876", "0.6753267", "0.6745752", "0.6737256", "0.67210066", "0.67018056", "0.6673876", "0.66659665", "0.6661428", "0.66611236", "0.6646914", "0.6645047", "0.6645047", "0.6612489", "0.66114575", "0.6608532", "0.66082305", "0.6608107", "0.6602424", "0.6588692", "0.6588149", "0.6588149", "0.6586624", "0.6586624", "0.6586624", "0.6586624", "0.6586624", "0.6586624", "0.6586624", "0.6557525", "0.6536724", "0.65166575", "0.650898", "0.65028673", "0.65022945", "0.64944047", "0.64886045", "0.64886045", "0.6475042", "0.64609486", "0.64401966", "0.64401966", "0.64401966", "0.6431042", "0.64309895", "0.64132345", "0.64131474", "0.6409362", "0.6406718", "0.6403229", "0.6400686", "0.6400381", "0.63896203", "0.63878316", "0.63878316", "0.63840353", "0.6382727", "0.6372914", "0.63700163", "0.636589", "0.63657993", "0.636534", "0.636534", "0.63557523", "0.6354989", "0.63506883", "0.6349684", "0.6349201", "0.63484406", "0.6346807", "0.634634", "0.63444746", "0.63325286", "0.63325286", "0.63325286", "0.6331599", "0.63310903", "0.6329996", "0.63245374", "0.63214284", "0.6316173", "0.6312089", "0.6301065", "0.6296778", "0.62966603", "0.62910163", "0.6290696", "0.6290696" ]
0.68882805
10
POST people/1/contributions POST people/1/contributions.json
def create @contribution = Contribution.new(contribution_params) @contribution.contributable_type = "Book" @contribution.person = @person respond_to do |format| if @contribution.save format.html { redirect_to person_contributions_path(@person), notice: 'Contribution was successfully created.' } format.json { render action: 'show', status: :created, location: person_contributions_path(@contribution) } else format.html { render action: 'new' } format.json { render json: @contribution.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to @contribution, notice: 'Contribution was successfully created.' }\n format.json { render json: @contribution, status: :created, location: @contribution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\r\n @contributions = @person.contributions\r\n end", "def index\n user = User.find_by(id: params[:user_id])\n return respond_with contributions: [], status: :not_found if user.nil?\n contributions = user.contributions\n respond_with contributions: contributions, status: :ok\n end", "def contribution_params\n params.require(:contribution).permit(:text, :contributor, :email)\n end", "def create\n redirect_to '/auth/google_oauth2' unless user_is_logged_in?\n\n @contribution = Contribution.new(contribution_params)\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to @contribution, notice: 'Contribution was successfully created.' }\n format.json { render :show, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def contribution_params\n params.require(:contribution).permit(:titulo, :url, :puntos, :text, :tipo, :user_id)\n end", "def contribution_params\n params.require(:contribution).permit(:titulo, :user_id, :url, :puntos, :text)\n end", "def create\n @contribution = Contribution.new(contribution_params)\n session[:contributor] = @contribution.contributor\n session[:email] = @contribution.email\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to contributions_url, notice: '投稿しました' }\n format.json { render :index, status: :created, location: @contribution }\n else\n @contributions = Contribution.order(\"id DESC\").page params[:page]\n format.html { render :index }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @case_study = CaseStudy.new(params[:case_study].merge(:summary => 'Welcome to your new case study! May it bring joy to your life, and the lives of others.<hr>You can begin adding content by choosing Actions->Edit.'))\n\n respond_to do |format|\n if @case_study.save\n @contribution = @case_study.contributions.build(:user_id => current_user.id)\n @contribution.save\n format.html { redirect_to @case_study, notice: 'Case study was successfully created.' }\n format.json { render json: @case_study, status: :created, location: @case_study }\n else\n format.html { render action: \"new\" }\n format.json { render json: @case_study.errors, status: :unprocessable_entity }\n end\n end\n end", "def membership_contribution_params\n params.require(:membership_contribution).permit(:membership_id, :date, :amount)\n end", "def create\n @page = Page.new(params[:page])\n\n respond_to do |format|\n if @page.save\n @contribution = @page.contributions.build(:user_id => current_user.id)\n @contribution.save\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\n format.json { render json: @page, status: :created, location: @page }\n else\n format.html { render action: \"new\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contribution }\n end\n end", "def index\n @contributions = Contribution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contributions }\n end\n end", "def contribution_params\n params.require(:contribution).permit(:title, :text, :url)\n end", "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n flash[:notice] = 'Contribution was successfully created.'\n format.html { redirect_to(@contribution) }\n format.xml { render :xml => @contribution, :status => :created, :location => @contribution }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contribution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n flash[:notice] = 'Contribution was successfully created.'\n format.html { redirect_to(@contribution) }\n format.xml { render :xml => @contribution, :status => :created, :location => @contribution }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contribution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n if (current_user)\n @contribution = Contribution.new(contribution_params)\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to \"\" }\n format.json { render :index, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n elsif (params[:contribution][:url] != nil && params[:contribution][:text] != nil) || \n (params[:contribution][:url] == nil && params[:contribution][:text] == nil) \n render :json => {:status => \"400\", :error => \"Bad Request\"}, status: :bad_request\n else\n miId = decodeToken(params[:user_token])\n @miuser = User.find(miId) # comprueba que no existe el user con exte token\n params[:contribution][:user_id] = miId\n params[:contribution][:puntos] = 0;\n @contribution = Contribution.new(contribution_params)\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to \"\" }\n format.json { render :show, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end \n end", "def contribution_params\n params.require(:contribution).permit(:name, :email, :amount, :source, :stripeToken)\n end", "def increment_contributions\n contributions = self.contributions.nil? ? 0 : self.contributions\n contributions += 1\n self.save\n end", "def contribution_params\n params.require(:contribution).permit(:contribution_url, :contribution_category, :user_id, :username, category_ids: [] )\n end", "def contribution_params\n params[:contribution][:user_id] = current_user.id\n params.require(:contribution).permit(:title, :url, :text, :user_id)\n end", "def create\n contribution = Contribution.new(submission: current_user)\n save game, :created\n end", "def create_contribution(contribution_array, org, repo_name)\n user = create_user(contribution_array['author']['login'])\n repo = create_repo(org, repo_name)\n contributions = add_contributions(contribution_array)\n Commitchamp::Contribution.find_or_create_by(user_id: user.id, repo_id: repo.id) do |c|\n c.additions = contributions[:additions]\n c.deletions = contributions[:deletions]\n c.commits = contributions[:commits]\n end\n end", "def create\n # byebug\n @membership_contribution = MembershipContribution.new(membership_contribution_params)\n @membership = MembershipBalance.find_by(params[:membership_id])\n respond_to do |format|\n if @membership_contribution.save\n @a = MembershipContribution.all.last\n # @balance = MembershipBalance.find(params)\n @amount1 = @membership.balance + @a.amount\n @b = MembershipBalance.where(membership_id: @a.membership_id).update_all(balance: @amount1)\n format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully created.' }\n format.json { render :show, status: :created, location: @membership_contribution }\n else\n format.html { render :new }\n format.json { render json: @membership_contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_contribution(expense, amount)\n contribution = ExpenseContribution.new(:amount => amount)\n contribution.user = self\n contribution.expense = expense\n contribution.save!\n contribution\n end", "def create\n if params.has_key?(:unbound_contributions)\n user = User.find_by(id: params[:user_id])\n ride = Ride.find_by(id: params[:ride_id])\n price = ride[:price]\n distance = user.rides.find_by(id: params[:ride_id])[:realtime_km]\n project_id = ride.project[:id]\n\n contribution_amount = price*distance\n user.update_attribute(:unbound_contributions, contribution_amount)\n user.contributions.update_attributes(amount: contribution_amount, project_id: project_id)\n user.rides.find_by(id: ride.id).update_attribute(:is_paid, true)\n render json: {:status => 200}\n else\n ride = Ride.find_by(id: params[:ride_id])\n new_ride = ride.requests.create!(passenger_id: params[:user_id], requested_from: params[:requested_from],\n request_to: params[:requested_to])\n unless new_ride.nil?\n respond_with ride: new_ride, anfrage: true, status: :created\n else\n respond_with ride: new_ride, anfrage: false, status: :bad_request\n end\n end\n end", "def add_contribution(expense, amount)\n contribution = ExpenseContribution.new(amount: amount)\n contribution.user = self\n contribution.expense = expense\n contribution.save!\n contribution\n end", "def createContributions(eventContributions)\n eventContributions.each do |contribution|\n contributor = User.find_by_email(contribution[1][\"email\"])\n contributor.setContribution!(self, contribution[1][\"amount\"], contribution[1][\"paid\"])\n end\n end", "def create\n @contribution_record = ContributionRecord.new(params[:contribution_record])\n\n # must hook up the contributor names and addresses\n\n respond_to do |format|\n if @contribution_record.save\n format.html { redirect_to @contribution_record, notice: 'Contribution record was successfully created.' }\n format.json { render json: @contribution_record, status: :created, location: @contribution_record }\n format.xml { render xml => @contribution_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contribution_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n flash[:notice] = 'Enseignement a été ajouté.'\n format.html { redirect_to enseignant_path(:id => @contribution.enseignant) }\n #format.xml { head :created, :location => contribution_url(@contribution) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contribution.errors.to_xml }\n end\n end\n end", "def apiCreateAsk\n key = request.headers[\"X-API-KEY\"]\n @user = User.find(params[:id])\n if @user.oauth_token == key\n @contribution = Contribution.new(params.permit(:title, :text))\n @contribution.user_id = params[:id]\n @contribution.url = ''\n if @contribution.title != nil && @contribution.save\n render json: {status: 'SUCCES', message: 'Post saved', data: @contribution}, status: :ok\n else\n render json: {status: 'ERROR', message: 'Internal server error', data:[]}, status: :internal_server_error\n end\n else\n render json: {status: 'ERROR', message: 'Authentication error', data:[]}, status: :unauthorized\n end\n end", "def bulk_contributions(org, repo)\n total_contributors = split_contributions(org, repo)\n total_contributors.each do |x|\n self.create_contribution(x, org, repo)\n end\n end", "def assign_past_contributor_contributions_to_user\n contributor = Contributor.find_by_email(email)\n if contributor\n contributor.contributions.update_all(:user_id => id, :contributor_id => nil)\n contributor.destroy\n end\n true\n end", "def get_contributions(repository)\n Git.contributions GithubAPI.name(@username), repository\n end", "def index\n @membership_contributions = MembershipContribution.all\n end", "def create\n @contribution_type = ContributionType.new(contribution_type_params)\n\n respond_to do |format|\n if @contribution_type.save\n format.html { redirect_to @contribution_type, notice: 'Contribution type was successfully created.' }\n format.json { render :show, status: :created, location: @contribution_type }\n else\n format.html { render :new }\n format.json { render json: @contribution_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_membership_contribution\n @membership_contribution = MembershipContribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def ask\n @view = VIEWS[:ask]\n @contributions = Contribution.where(url: '')\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @contributions }\n end\n end", "def user_contribution_params\n params.require(:user_contribution).permit(:address_id, :year, :month, :contribution, :pay_at, :receiver_id, :payment_type, :blok,\n :description, :transaction_date, :imported_cash_transaction)\n end", "def create\n @contributor = Contributor.new(contributor_params)\n\n if @contributor.save\n render :show, status: :created, location: @contributor\n else\n render json: @contributor.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @contribution = Contribution.find(params[:id])\n @contribution.destroy\n\n respond_to do |format|\n format.html { redirect_to contributions_url }\n format.json { head :no_content }\n end\n end", "def new\r\n @contribution = Contribution.new\r\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def set_contribution\n @contribution = Contribution.find(params[:id])\n end", "def index\n @contributions = Contribution.order(\"id DESC\").page params[:page]\n\n @contribution = Contribution.new\n @contribution.contributor = session[:contributor] if session[:contributor]\n @contribution.email = session[:email] if session[:email]\n end", "def create\n @person_interest = PersonInterest.new(params[:person_interest])\n\n respond_to do |format|\n if @person_interest.save\n format.html { redirect_to @person_interest, notice: 'Person interest was successfully created.' }\n format.json { render json: @person_interest, status: :created, location: @person_interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @person_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @contribution.destroy\n respond_to do |format|\n format.html { redirect_to contributions_url, notice: '投稿を削除しました' }\n format.json { head :no_content }\n end\n end", "def create\n @person = Person.new(params[:person])\n work = Work.find(@person.work_id) if @person.work_id.present?\n expression = Expression.find(@person.expression_id) if @person.expression_id.present?\n manifestation = Manifestation.find(@person.manifestation_id) if @person.manifestation_id.present?\n\n respond_to do |format|\n if @person.save\n if work\n @person.works << work\n end\n if expression\n @person.expressions << expression\n end\n if manifestation\n @person.manifestations << manifestation\n end\n format.html { redirect_to @person, notice: 'Person was successfully created.' }\n format.json { render json: @person, status: :created, location: @person }\n else\n format.html { render action: \"new\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @contribution.destroy\n respond_to do |format|\n format.html { redirect_to contributions_url, notice: 'Contribution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contribution.destroy\n respond_to do |format|\n format.html { redirect_to contributions_url, notice: 'Contribution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contribution }\n end\n end", "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contribution }\n end\n end", "def create\n @graduation_project = GraduationProject.new(graduation_project_params)\n params[:selected_majors].each do |major|\n @graduation_project.majors << Major.find_by_id(major[:id])\n end\n\n respond_to do |format|\n if @graduation_project.save\n format.html { redirect_to @graduation_project, notice: 'Graduation project was successfully created.' }\n format.json { render :show, status: :created, location: @graduation_project }\n else\n format.html { render :new }\n format.json { render json: @graduation_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_v1_contribution_params\n params.fetch(:api_v1_contribution, {})\n end", "def confirm_node_contribution\n @contribution = Contribution.unconfirmed.find_by_id_and_owner(params[:contribution][:id], current_person.id)\n @ratings = RatingGroup.default_contribution_hash\n\n respond_to do |format|\n if @contribution.confirm!\n Subscription.create_unless_exists(current_person, @contribution.item)\n format.js { render :partial => \"threaded_contribution_template\", :locals => { :contribution => @contribution, :ratings => @ratings }, :status => (params[:preview] ? :accepted : :created) }\n format.html { render :partial => \"threaded_contribution_template\", :locals => { :contribution => @contribution, :ratings => @ratings }, :status => (params[:preview] ? :accepted : :created) }\n else\n format.js { render :json => @contribution.errors, :status => :unprocessable_entity }\n format.html { render :text => @contribution.errors, :status => :unprocessable_entity }\n end\n end\n end", "def contributor_params\n params.require(:contributor).permit(:id, :contributor_name, :contributor_type, :name_identifier_id,\n :affiliation_id, :award_number, :resource_id)\n end", "def set_user_contribution\n @user_contribution = UserContribution.find(params[:id])\n end", "def create\n @person = Person.new(person_params)\n @agreement = Agreement.last\n @person.skip_validation = false\n respond_to do |format|\n if @person.save\n @person.agreements << Agreement.last\n if current_user\n if current_user.user?\n current_user.person_id = @person.id\n current_user.save\n end\n end\n format.html { redirect_to @person, notice: 'Uppgifterna lades till. Tack.' }\n format.json { render :show, status: :created, location: @person }\n else\n format.html { render :new }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @contributions = Contribution.where(text:\"\").order(points: :desc)\n respond_to do |format|\n format.json { render json: @contributions}\n end\n end", "def create\n @membership = Membership.new(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to community_memberships_path(@community), notice: 'Community membership was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @person = current_user.created_people.new(person_params_with_school)\n if @person.save\n render :show, status: :created, location: api_v1_person_url(@person)\n else\n render json: @person.errors, status: :unprocessable_entity\n end\n end", "def preview_node_contribution\n errors = []\n unless params[:contribution][:url].blank?\n embedly = EmbedlyService.new\n embedly.fetch_and_merge_params!(params)\n end\n @contribution = Contribution.update_or_create_node(params[:contribution], current_person)\n\n if @contribution.invalid?\n errors = @contribution.errors.full_messages\n elsif embedly and (embedly.bad_request? or embedly.not_found?)\n errors = [\"There was a problem retrieving information for '#{params[:contribution][:url]}'\"]\n elsif embedly and not embedly.ok?\n errors = ['There was a problem with our system. Please try again.']\n end\n\n ratings = RatingGroup.ratings_for_conversation_by_contribution_with_count(@contribution.conversation, current_person)\n\n respond_to do |format|\n if errors.size == 0\n format.js { render(:partial => \"conversations/new_contribution_preview\", :locals => { :div_id => params[:div_id], :layout => false, :ratings => ratings }) }\n format.html { render(:partial => \"conversations/new_contribution_preview\", :locals => { :div_id => params[:div_id], :layout => 'application', :ratings => ratings }) }\n else\n format.js { render :json => errors, :status => :unprocessable_entity }\n format.html { render :text => errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @membership_contribution.destroy\n respond_to do |format|\n format.html { redirect_to membership_contributions_url, notice: 'Membership contribution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @person = current_user.created_people.new(person_params_with_school)\n if @person.save\n render :show, status: :created, location: api_v2_person_url(@person)\n else\n render json: @person.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @contribution.update(contribution_params)\n format.html { redirect_to contributions_url, notice: '編集しました' }\n format.json { render :show, status: :ok, location: @contribution }\n else\n format.html { render :edit }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def split_contributions(org, repo)\n total_contributors = []\n page = 1\n contributions = @github.contributions_page(org, repo).to_a\n total_contributors.concat(contributions)\n total_contributors\n end", "def create\n filter_sampled_persons_ineligibilties\n\n @person = Person.new(params[:person])\n @provider = Provider.find(params[:provider_id]) unless params[:provider_id].blank?\n\n respond_to do |format|\n if @person.save\n create_relationship_to_participant\n\n path = people_path\n msg = 'Person was successfully created.'\n if @provider\n path = provider_path(@provider)\n msg = \"Person was successfully created for #{@provider}.\"\n end\n format.html { redirect_to(path, :notice => msg) }\n format.json { render :json => @person }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @person.errors }\n end\n end\n end", "def create\n @work = Work.new(work_params)\n process_work_contributors\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render text: \"success\"}\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @contributions = Contribution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contributions }\n end\n end", "def add_contributors\n @hash[:contributors].each do |json_contrib|\n my_hash = json_contrib.slice('contributor_name', 'contributor_type', 'created_at', 'updated_at', 'award_number')\n @ar_resource.contributors << StashDatacite::Contributor.create(my_hash)\n # btw affiliations for contributors are not really used in Dash data, so skipping that headache, though we have some test data for it\n end\n end", "def contributor_params\n params.require(:contributor).permit(:company_id, :user_id)\n end", "def update\n respond_to do |format|\n if @membership_contribution.update(membership_contribution_params)\n format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully updated.' }\n format.json { render :show, status: :ok, location: @membership_contribution }\n else\n format.html { render :edit }\n format.json { render json: @membership_contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n# next line commented out and following line added 2 aug 17 for connecting users to people (step 17)\n# Person.create(person_params)\n current_user.people.create(person_params) # check nomster/flixter code in this area\n\n redirect_to new_person_path # change to redirect to page showing person created, maybe entire tree\n end", "def create\n @mercurial = Mercurial.new(mercurial_params)\n\n respond_to do |format|\n if @mercurial.save\n format.html { redirect_to @mercurial, notice: 'Mercurial was successfully created.' }\n format.json { render :show, status: :created, location: @mercurial }\n else\n format.html { render :new }\n format.json { render json: @mercurial.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @attention = Attention.new(attention_params)\n # @attention.participants = params[:participants]\n # @attention.responsible = params[:responsible]\n # @attention.nro_involved = params[:participants].count + 1\n\n # respond_to do |format|\n # if @attention.save\n # format.html { redirect_to @attention, notice: 'Attention was successfully created.' }\n # format.json { render :show, status: :created, location: @attention }\n # else\n # format.html { render :index }\n # format.json { render json: @attention.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @projects_person = ProjectsPerson.new(params[:projects_person])\n\n respond_to do |format|\n if @projects_person.save\n format.html { redirect_to @projects_person, notice: 'Projects person was successfully created.' }\n format.json { render json: @projects_person, status: :created, location: @projects_person }\n else\n format.html { render action: \"new\" }\n format.json { render json: @projects_person.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @contributions = Contribution.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contributions }\n end\n end", "def create\n\n @collaboration = current_user.collaborations.build(collaboration_params)\n if @collaboration.save\n flash[:success] = \"Collaboration successfully created!\"\n redirect_to @collaboration\n else\n render 'new'\n end\n\n end", "def show\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contribution }\n end\n end", "def update\n respond_to do |format|\n if @contribution.update(contribution_params)\n format.html { redirect_to @contribution, notice: 'Contribution was successfully updated.' }\n format.json { render :show, status: :ok, location: @contribution }\n else\n format.html { render :edit }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contribution.update(contribution_params)\n format.html { redirect_to @contribution, notice: 'Contribution was successfully updated.' }\n format.json { render :show, status: :ok, location: @contribution }\n else\n format.html { render :edit }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @person = Person.new(params[:person])\n @person = Person.create(params[:person].merge(:user => current_user))\n # @person.pct_complete = @person.requirement_progress\n respond_to do |format|\n if @person.save\n format.html { redirect_to @person, :notice => 'Person was successfully created.' }\n format.json { render :json => @person, :status => :created, :location => @person }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @user_contribution.destroy\n respond_to do |format|\n format.html { redirect_to user_contributions_url, notice: 'User contribution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n if @contribution.update_attributes(params[:contribution])\n format.html { redirect_to @contribution, notice: 'Contribution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def contributor_params\n params.require(:contributor).permit(:name, :email, :zip)\n end", "def create\n @community_growth_form = CommunityGrowthForm.new(community_growth_form_params)\n\n respond_to do |format|\n if @community_growth_form.save\n format.html { redirect_to @community_growth_form, notice: 'Community growth form was successfully created.' }\n format.json { render :show, status: :created, location: @community_growth_form }\n else\n format.html { render :new }\n format.json { render json: @community_growth_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participant = Participant.new(participant_params)\n @participant.competences = @competence\n respond_to do |format|\n if @participant.save\n TeamParticipant.create(participant: @participant, team: @team)\n format.html { redirect_to participants_url }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member_fraction = MemberFraction.new(member_fraction_params)\n\n respond_to do |format|\n if @member_fraction.save\n format.html { redirect_to member_fractions_path, notice: 'Member fraction was successfully created.' }\n format.json { render :show, status: :created, location: @member_fraction }\n else\n format.html { render :new }\n format.json { render json: @member_fraction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @membership = Membership.new(params[:membership])\n @membership.member = current_member\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to sub_clubs_path, :notice => 'You requested membership.' }\n format.json { render :json => @membership, :status => :created, :location => @membership }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @membership.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_contribution = UserContribution.new(user_contribution_params)\n @user_contribution.blok = @user_contribution.address.block_address.gsub(/[^A-Za-z]/,'') rescue ''\n respond_to do |format|\n if @user_contribution.save\n CashTransaction.create(\n month: @user_contribution.month,\n year: @user_contribution.year,\n transaction_date: @user_contribution.pay_at,\n transaction_type: CashTransaction::TYPE['DEBIT'],\n transaction_group: CashTransaction::GROUP['IURAN WARGA'],\n description: @user_contribution.description,\n total: @user_contribution.contribution,\n pic_id: @user_contribution.receiver_id\n )\n format.html { redirect_to @user_contribution, notice: 'User contribution was successfully created.' }\n format.json { render :show, status: :created, location: @user_contribution }\n else\n format.html { render :new }\n format.json { render json: @user_contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @open_source_contributor = OpenSourceContributor.new(open_source_contributor_params)\n\n respond_to do |format|\n if @open_source_contributor.save\n format.html { redirect_to @open_source_contributor, notice: 'Open source contributor was successfully created.' }\n format.json { render :show, status: :created, location: @open_source_contributor }\n else\n format.html { render :new }\n format.json { render json: @open_source_contributor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @person = Person.new(person_params)\n @person.user_id= current_user.id \n respond_to do |format|\n if @person.save\n if params[:skillid]!=nil\n params[:skillid].each do |i| \n\t\t @person.skills << Skill.find_by_id(i)\n\t\tend\n\t\tend\n format.html { redirect_to @person }\n format.json { render :show, status: :created, location: @person }\n else\n org=Organization.where( :user_id =>current_user.id)\n\t\tif org.nil?\n\t\t@groups=org.first.groups\n\t\t@skills=@groups.first.skills\n\t\telse\n\t\t@groups=Group.where( :user_id =>current_user.id)\n\t\t@skills=Skill.where( :user_id =>current_user.id)\n end\n format.html { render :new }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n input = create_input\n return unauthorized unless create_auth(input)\n create_collaboration = API::V1::CreateCollaboration.new(input)\n result = create_collaboration.call\n if result\n render status: 201, json: result\n else\n error(create_collaboration.errors)\n end\n end", "def create\n @member_commision = MemberCommision.new(member_commision_params)\n\n respond_to do |format|\n if @member_commision.save\n format.html { redirect_to member_commisions_path, notice: 'Member commision was successfully created.' }\n format.json { render :show, status: :created, location: @member_commision }\n else\n format.html { render :new }\n format.json { render json: @member_commision.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @contribution.destroy\n\n respond_to do |format|\n format.html { redirect_to(contributions_url) }\n format.xml { head :ok }\n end\n end", "def post(hash)\n HttpClient::Preconditions.assert_class('hash', hash, Hash)\n @client.request(\"/membership_requests\").with_json(hash.to_json).post { |hash| Apidoc::Models::MembershipRequest.new(hash) }\n end" ]
[ "0.6558725", "0.6516483", "0.651311", "0.62787557", "0.62748885", "0.6204882", "0.6200626", "0.61977834", "0.61608875", "0.61483693", "0.61468655", "0.6089625", "0.6071447", "0.60704553", "0.6063227", "0.6063227", "0.60567325", "0.6051911", "0.604626", "0.6031415", "0.5992902", "0.59487534", "0.59417707", "0.59313595", "0.59190154", "0.5881", "0.58803624", "0.58754766", "0.5868546", "0.5810974", "0.58107996", "0.5724999", "0.5677478", "0.5667871", "0.5598848", "0.55733925", "0.554623", "0.5541265", "0.5541265", "0.54777175", "0.547392", "0.54157686", "0.5410702", "0.5409011", "0.54004127", "0.54004127", "0.54004127", "0.54004127", "0.53771406", "0.5359036", "0.53542393", "0.53336304", "0.5331693", "0.5331693", "0.5324588", "0.5324588", "0.532337", "0.53071815", "0.53063464", "0.53040457", "0.5285845", "0.5282791", "0.528144", "0.52811813", "0.52757347", "0.52753067", "0.5271181", "0.5270511", "0.5257198", "0.5254473", "0.5245962", "0.52441376", "0.52342606", "0.5233368", "0.5232733", "0.5226572", "0.52170485", "0.5216621", "0.5215954", "0.5213344", "0.5202288", "0.5199681", "0.51961005", "0.51862377", "0.51862377", "0.51859635", "0.5185652", "0.51815385", "0.5141323", "0.5133657", "0.5131603", "0.5130747", "0.51306313", "0.51303613", "0.51280755", "0.51164174", "0.51077133", "0.50875723", "0.5077208", "0.5076081" ]
0.667459
0
reader/getter method. return instance name.
def name @name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def instance_name\n info.name\n end", "def get_name\r\n self.name\r\n end", "def name() return @name end", "def name() return @name end", "def getName()\n return @obj_name\n end", "def name # getter method (or reader method)\n @name\n end", "def name\n @_name\n end", "def name()\n return @name\n end", "def getName; @name; end", "def getName()\n\t\t\treturn @_name\n\t\tend", "def name\n object.name\n end", "def name\n return @name\n end", "def name_reader\n @name\n end", "def get_name()\n @name\n end", "def get_name()\n @name\n end", "def name\n self.class.simple_name\n end", "def get_name\n @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name()\n return self.manager.dictionary[self]\n end", "def name; self.class.name; end", "def name\n object[\"name\"]\n end", "def get_name\n\t\treturn @name\n\tend", "def get_name\n\t\treturn @name\n\tend", "def get_name\n\t\treturn @name\n\tend", "def name\n\t\treturn @name\n\tend", "def getName\n return @name\n end", "def getName\n return @name\n end", "def get_name\n return @name\n end", "def getName()\n return @name ;\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def getName()\n return @name\n end", "def get_name\n @name\n end", "def get_name\n @name\n end", "def get_name\n @name\n end", "def get_name\n @name\n end", "def name\n Properties[self.class] ||= {}\n return Properties[self.class][:name] || \"\"\n end", "def name\n @name ||= self.class.name\n end", "def name\n @name\n end", "def get_name\n return @m_name\n end", "def get_name\n return @m_name\n end", "def get_name\n return @m_name\n end", "def get_name\n return @m_name\n end", "def getName\r\n\t\t\t\t\treturn @name\r\n\t\t\t\tend", "def getName\r\n\t\t\t\t\treturn @name\r\n\t\t\t\tend", "def getName\r\n\t\t\t\t\treturn @name\r\n\t\t\t\tend", "def getName\r\n\t\t\t\t\treturn @name\r\n\t\t\t\tend", "def getName\r\n\t\t\t\t\treturn @name\r\n\t\t\t\tend", "def getName()\r\n\t\treturn @name\r\n\tend", "def instance_name(object_instance)\n @instance_names[object_instance.object_id]\n end", "def get_name\n\t\t@name\n\tend", "def name\n @name\n end", "def name\n self[:name]\n end", "def name\n\t\tself.class.name\n\tend", "def\n get_name()\n @name\n end", "def name\n NAME\n end", "def name\n self[ :name ]\n end", "def name\n self[:Name]\n end", "def name\n @@name\n end", "def name\r\n @name\r\n end", "def name\n self.class.name\n end", "def name\n self.class.name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def return_name\n @name\n end", "def name\n self.reload if @should_reload\n\n if @data.key?(:title)\n return @data[:title]\n elsif @data.key?(:name)\n return @data[:name]\n end\n\n obj_methods = self.class.instance_methods(false)\n [:name, :title].each do |method_name|\n return self.method(method_name).call if obj_methods.index(method_name)\n end\n\n raise \"Couldnt figure out the title/name of the object on class #{self.class.name}.\"\n end", "def name\n @name\n end", "def object_name; end", "def object_name; end", "def object_name; end" ]
[ "0.79619074", "0.7604622", "0.75723404", "0.75723404", "0.74505293", "0.74408555", "0.7440808", "0.7360143", "0.73555773", "0.7349878", "0.7335689", "0.7259398", "0.724203", "0.72333205", "0.72333205", "0.722334", "0.7218985", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7217622", "0.7210645", "0.7207032", "0.7201844", "0.71928596", "0.71928596", "0.71928596", "0.7181073", "0.7179572", "0.7179572", "0.7155223", "0.7150132", "0.7149787", "0.7149787", "0.7137604", "0.71331877", "0.71331877", "0.71331877", "0.71331877", "0.71311057", "0.71290565", "0.7123236", "0.7122057", "0.7122057", "0.7122057", "0.7122057", "0.71216416", "0.71216416", "0.71216416", "0.71216416", "0.71216416", "0.7096545", "0.7095789", "0.70904136", "0.7088494", "0.7087219", "0.70863354", "0.70846355", "0.70824903", "0.7078937", "0.7076646", "0.70720404", "0.70588076", "0.7055069", "0.7055069", "0.7049868", "0.7049868", "0.7049868", "0.7049868", "0.7049868", "0.7049868", "0.7049868", "0.7049868", "0.7044001", "0.7039773", "0.7027153", "0.7014919", "0.7014919", "0.7014919" ]
0.70541126
86
puts 'woof!' when called on an instance of dog.
def bark puts "woof!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run #instance method, you chain it to an instance of a Dog\n # binding.pry\n puts \"#{@name} the #{@breed} is running fast as the wind\"\n end", "def meow # Define a method that allows any instance of Cat to meow\n puts \"meow!\"\n end", "def dog(name)\r\n puts \"The dog's name is \" + name\r\n end", "def speak\n #useses the name variable that all GoodDog objects are assigned at creation. Different for each instance\n \"#{@name} says Arf!\"\n end", "def bark\n puts \"woof\"\n end", "def bark \n puts \"Woof!\"\n end", "def meow\n puts \"meow!\"\n # when we call on the method .meow\n # it will put meow\n end", "def bark\n puts \"woof woof!\"\n end", "def bark\n puts \"woof!\"\n end", "def sit\n puts \"The Dog is sitting\"\nend", "def bark \n puts \"woof!\"\n end", "def bark\n p \"woof!\"\n end", "def bark\n p \"woof!\"\n end", "def bark\n puts \"woof!\"\n end", "def eat(food, two)\n binding.pry # self\n super(\"fish\") # call the eat method in the parent class\n puts \"Play with #{food}.\"\n\n end", "def sit\n puts \"The Dog is sitting\"\n end", "def sit\n puts \"The Dog is sitting\"\n end", "def bark\n puts \"woof!\"\n end", "def sit \n puts \"The Dog is sitting\"\n end", "def print\r\n puts name + \" \" + className + \" says \" + \"\\\"\" + call + \"\\\"\"\r\n end", "def print\r\n\t\tputs name + \" \" + className + \" says \" + call\r\n\tend", "def print\n\t\tputs name + \" \" + className + \" says \" + call\n\tend", "def bark\n puts \"woof!\"\nend", "def bark\n puts \"Hello, my name is #{self.name}\"\n end", "def bark\n puts \"woof!\"\n end", "def meow\n puts \"meow!\"\n end", "def meow\n puts \"meow!\"\n end", "def meow\n puts \"meow!\"\n end", "def meow\n puts \"meow!\"\n end", "def print_name\n\t\t@dog_name\n\tend", "def printDazzle\n puts \"self\"\nend", "def bark(visitor)\n puts \"My dog is barking at #{visitor}\"\n end", "def old_dog\n p \"dog is #{old}\"\n end", "def meow #teaching the cat how to meow\n puts \"meow!\" \n end", "def buy_dog(name)\n Dog.new(name,self)\n end", "def print\n puts \"#{name} #{class_name} just #{movement} and said, \\\"#{call}\\\"\"\n end", "def printCat(cat)\n puts cat.name \n puts cat.breed \n puts cat.poopSize \nend", "def meow\n puts \"meow!\"\nend", "def woo; puts \"woooooo\"; end", "def poop\n puts \"poooop\"\n end", "def dog_name\n end", "def buy_dog(name)\n Dog.new(name, self)\n end", "def buy_dog(name)\n Dog.new(name, self)\n end", "def buy_dog(name)\n dog = Dog.new(name, self)\n end", "def say _obj, _args\n \"_obj say _args;\" \n end", "def print\n\t\tputs name + ' ' + className + \" just \" + move + \" and said \" + call\n\tend", "def buy_dog(name)\n new_dog = Dog.new(name,self)\n end", "def eat(food)\n super(food) #- takes this from parent's eat(food) method\n puts(\"Woof\")\n end", "def love_pet\n puts \"#{@name} loves their pet #{pet.name} so much.\"\n end", "def meow\n puts \"meow!\" #can meow\n end", "def say_food\n p FOOD\nend", "def eat\n puts 'Start eating'\n end", "def print_car (the_car)\n \n puts \"This is a car:\"\n puts \" color: #{self.color}\" #self- an *instance* code from ruby to pul attributes in class blueprint of the behaviour\n puts \" make: #{self.make}\"\n puts \" model: #{self.model}\"\n puts \" year: #{self.year}\"\n puts \" top_speed: #{self.top_speed}\"\n end", "def print_text\n\t\tputs self # First object\n\t\tputs \"this is instance method to print some text\"\n\tend", "def make_it_swim(duck)\n duck.swim\nend", "def speak\n puts \"woof\"\n end", "def eat\n puts \"From Oreo\"\n super\n end", "def demo1\n a = Animal.new\n c = Cephalopod.new\n o = Octopus.new\n m = MutantOctopus.new\n puts a.description\n puts c.description\n puts o.description \n puts m.description \n puts o.tentacles\n puts m.tentacles\nend", "def say_name_and_species\n puts \"#{name} is a #{self.class.species}\"\n end", "def eat\n puts 'Nom. Nom. Nom!'\n self # 👈🏻To chain isntance method we are returning 'self' here , which will point to instance of a class(not a class)\n end", "def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\nend", "def dog(name)\n return name\nend", "def dog(name)\n return name\nend", "def print_one(thing)\n\tputs \"thing: #{thing}\"\nend", "def potty\n puts \"*goes to litterbox*\"\n end", "def test_you_can_define_methods_on_individual_objects\n fido = Dog.new\n def fido.wag\n :fidos_wag\n end\n assert_equal :fidos_wag, fido.wag\n end", "def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\n # tommy.buy_cat(\"Garfield\")\n end", "def talk\r\n puts \"Hi I'm #{@name}\"\r\n self\r\n end", "def eat\n p \"Nom nom nom nom\"\nend", "def ap(object)\n puts object\n end", "def demon; end", "def speak(msg=\"foo-instance speaking... \")\n msg=\"foo-instance speaking... \"\n msg + (defined?(super) ? super() : \"\")\n end", "def speak\n puts 'bark bark bark'\n end", "def speak\n puts \"I'm a person\"\n end", "def print\n raise NotImplementedError, \"Subclasses must implement a call method.\"\n end", "def eat\n puts \"Eating the oreo cookie~~\"\n super\n end", "def name\n @named_dog\n end", "def dog(dog_name)\n return dog_name\nend", "def test_heres_an_easy_way_to_call_class_methods_from_instance_methods\n fido = Dog.new\n assert_equal :still_another_way, fido.class.another_class_method\n # Fuck another ways now\n end", "def animal(pet1, pet2)\n puts \" The best pet is a #{pet1}, however it may also be a #{pet2}\"\nend", "def puts\n end", "def test_heres_an_easy_way_to_call_class_methods_from_instance_methods\n fido = Dog.new\n assert_equal :still_another_way, fido.class.another_class_method\n end", "def test_heres_an_easy_way_to_call_class_methods_from_instance_methods\n fido = Dog.new\n assert_equal :still_another_way, fido.class.another_class_method\n end", "def walk_pet(pet_name, owner_name)\n puts \"#{owner_name} takes his pet #{pet_name} on a walk\"\nend", "def display\n puts\n puts \"* Class: #{self.class_name} *\"\n puts\n puts \"Description: #{self.description}\"\n puts\n puts \"Spellcasting: #{spellcasting}\"\n puts\n puts \"-----------------------------\"\n end", "def command_print(name)\n food = @database.get(name)\n if food.is_a?(BasicFood) || food.is_a?(Recipe)\n puts food.to_s\n else\n puts \"Error in pinting the specified food.\"\n end\n end", "def print_foo(bar)\n puts Foo\n puts @foo\n puts bar\nend", "def say_species\n \"I am a #{self.species}.\"\n end", "def walk\n puts \"The Person is walking\"\n end", "def walk\n puts \"The Person is walking\"\n end", "def initialize(name, dog)\n @name = name\n @dog = dog\n end", "def bark\n say('ouah ouah')\n nil\n end", "def print4(nyc)\n\t4.times do puts nyc\n\n\tend\n\n#Prints an uppercase version of the argument given\ndef printupcase (live)\n\n\tputs live.upcase\nend\n\n#Object with two attributes and one method.\n\nclass Dog\nattr_accessor :name, :trait\n\nend\n\nfirst_dog = Dog.new\nfirst_dog.name = \"Bob\"\nfirst_dog.trait = \"annoying\"\n\ndef bark\n\tputs \"au au au\"\n\nend\nend", "def take_a_drink\n soda.drink_a_soda\n puts \"You drank your soda!\"\n end", "def speak\n # was @name before, but since we are using attr_accessor, we want to call the instance method, instead of the instance variable\n \"#{name} says Arf\"\n end", "def whatami( obj )\n\tputs \"#{obj.to_s} is a #{obj.class}\"\nend", "def go\n # super.go\n # puts \"VRRROOOOOOOOOOOOOOOOOOOOOOOM!!!!!\"\n \"VRRROOOOOOOOOOOOOOOOOOOOOOOM!!!!!\"\n end", "def dog_eat(items)\n \t items.each do |item|\n \t\t puts \"My puppy likes #{item}\"\n \t end\n end", "def new_song(name, genre)\nsong = Song.new(name, self, genre)\nsong\n# binding.pry\nend", "def start_bike\n puts \"vroom!\"\nend" ]
[ "0.7585412", "0.7316708", "0.7278801", "0.69613475", "0.6840562", "0.6833192", "0.6809764", "0.67994535", "0.67931664", "0.67910105", "0.67778456", "0.6777531", "0.6777531", "0.67716014", "0.6759001", "0.67255664", "0.67255664", "0.6725324", "0.6715189", "0.6700212", "0.6699769", "0.66883576", "0.6669249", "0.6657474", "0.66210186", "0.6538464", "0.6538464", "0.64697206", "0.64697206", "0.64035994", "0.63905776", "0.63725865", "0.63685316", "0.6334039", "0.63279325", "0.62853485", "0.6278902", "0.6265672", "0.62582374", "0.62522763", "0.6215067", "0.61947757", "0.61947757", "0.6191514", "0.618675", "0.6185239", "0.61850005", "0.6176921", "0.6167779", "0.6142579", "0.6112714", "0.61106867", "0.6068724", "0.6059057", "0.60373354", "0.6025687", "0.6025265", "0.60172325", "0.60150295", "0.6013871", "0.6008575", "0.6007319", "0.6007319", "0.5996196", "0.5993908", "0.5985984", "0.5969769", "0.5959029", "0.5935442", "0.59275067", "0.5914456", "0.5901031", "0.58901775", "0.5886352", "0.5858455", "0.58557916", "0.58555216", "0.5848272", "0.5847923", "0.5843393", "0.5842684", "0.58301896", "0.58301896", "0.5820562", "0.5812169", "0.5780638", "0.57718563", "0.57712626", "0.5770614", "0.5770614", "0.5767648", "0.57538927", "0.574529", "0.5743047", "0.5736003", "0.5729584", "0.5723646", "0.572197", "0.5719857", "0.5719557" ]
0.67454237
15
This method populates the board with pieces after a new game is created. Args : none Returns : chess pieces assigned to starting locations on the board
def populate_board! # Populate Pawns (0..7).each do |x| Pawn.create(x_coordinates: x, y_coordinates: 1, game_id: self.id, color: 'white', image: 'white-pawn.png', status: 'active') # White Pawn.create(x_coordinates: x, y_coordinates: 6, game_id: self.id, color: 'black', image: 'blk-pawn.png', status: 'active') # Black end # Populate Rook Rook.create(x_coordinates: 0, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White Rook.create(x_coordinates: 7, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White Rook.create(x_coordinates: 0, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black Rook.create(x_coordinates: 7, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black # Populate Knight Knight.create(x_coordinates: 1, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White Knight.create(x_coordinates: 6, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White Knight.create(x_coordinates: 1, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black Knight.create(x_coordinates: 6, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black # Populate Bishop Bishop.create(x_coordinates: 2, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White Bishop.create(x_coordinates: 5, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White Bishop.create(x_coordinates: 2, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black Bishop.create(x_coordinates: 5, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black # Populate Queen Queen.create(x_coordinates: 3, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-queen.png', status: 'active') # White Queen.create(x_coordinates: 3, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-queen.png', status: 'active') # Black # Populate King King.create(x_coordinates: 4, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-king.png', status: 'active') # White King.create(x_coordinates: 4, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-king.png', status: 'active') # Black end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_board!\n # white pieces\n # creates the 8 pawn pieces across the board\n 8.times do |i|\n # sets game_id in Piece model to current id in Game\n # color is boolean - true for white, false for black\n Pawn.create(game_id: id, x_coord: i, y_coord: 1, color: true, captured: false)\n end\n # creates the 2 rook, knight, and bishop pieces on opposite sides of the board\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n\n Queen.create(game_id: id, x_coord: 3, y_coord: 0, color: true, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 0, color: true, captured: false)\n\n # black pieces\n 8.times do |i|\n Pawn.create(game_id: id, x_coord: i, y_coord: 6, color: false, captured: false)\n end\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n Queen.create(game_id: id, x_coord: 3, y_coord: 7, color: false, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 7, color: false, captured: false)\n end", "def populate_board\n back_row = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n\n black_back_row = []\n back_row.each_with_index do |piece_class, j|\n black_back_row << piece_class.new(self, :black, [0, j])\n end\n board[0] = black_back_row\n \n black_front_row = []\n (0..7).each {|idx| black_front_row << Pawn.new(self, :black, [1, idx])}\n board[1] = black_front_row\n \n (2..5).each do |row|\n board[row] = Array.new(8) {NullPiece.instance} \n end\n \n white_front_row = []\n 8.times {|idx| white_front_row << Pawn.new(self, :white, [6, idx])}\n board[6] = white_front_row\n \n white_back_row = []\n back_row.each_with_index do |piece_class, j|\n white_back_row << piece_class.new(self, :white, [7, j])\n end\n board[7] = white_back_row\n end", "def set_pieces\n # white pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 2, color: 'white', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 1, color: 'white', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 1, color: 'white', active: true)\n King.create(game_id: id, x_position: 5, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 1, color: 'white', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 1, color: 'white', active: true)\n # black pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 7, color: 'black', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 8, color: 'black', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 8, color: 'black', active: true)\n King.create(game_id: id, x_position: 5, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 8, color: 'black', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 8, color: 'black', active: true)\n end", "def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end", "def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end", "def populate\n @board[7][0] = ChessPiece.new \"w_rook_1\", \"\\u2656\"\n @board[7][1] = ChessPiece.new \"w_knight_1\", \"\\u2658\"\n @board[7][2] = ChessPiece.new \"w_bishop_1\", \"\\u2657\"\n @board[7][3] = ChessPiece.new \"w_queen\", \"\\u2655\"\n @board[7][4] = ChessPiece.new \"w_king\", \"\\u2654\"\n @board[7][5] = ChessPiece.new \"w_bishop_2\", \"\\u2657\"\n @board[7][6] = ChessPiece.new \"w_knight_2\", \"\\u2658\"\n @board[7][7] = ChessPiece.new \"w_rook_2\", \"\\u2656\"\n @board[0][0] = ChessPiece.new \"b_rook_1\", \"\\u265C\"\n @board[0][1] = ChessPiece.new \"b_knight_1\", \"\\u265E\"\n @board[0][2] = ChessPiece.new \"b_bishop_1\", \"\\u265D\"\n @board[0][3] = ChessPiece.new \"b_queen\", \"\\u265B\"\n @board[0][4] = ChessPiece.new \"b_king\", \"\\u265A\"\n @board[0][5] = ChessPiece.new \"b_bishop_2\", \"\\u265D\"\n @board[0][6] = ChessPiece.new \"b_knight_2\", \"\\u265E\"\n @board[0][7] = ChessPiece.new \"b_rook_2\", \"\\u265C\"\n (0..7).each do |id|\n @board[6][id] = ChessPiece.new \"w_pawn_#{id+1}\", \"\\u2659\"\n @board[1][id] = ChessPiece.new \"b_pawn_#{id+1}\", \"\\u265F\"\n end \n end", "def populate_board(board)\n #Fills in the top and bottom rows\n [0, 7].each do |row|\n 4.times do |col|\n board[row][col] = create_piece(row, col)\n board[row][(7-col)] = create_piece(row, (7-col))\n end\n end\n\n #Fills in the pawns\n 8.times do |col|\n board[1][col] = BlackPawn.new(1, col)\n board[6][col] = WhitePawn.new(6, col)\n end\n\n board\n end", "def populate_board\n black = \"black\"\n white = \"white\"\n\n white_pawns = [\"A2\", \"B2\", \"C2\", \"D2\", \"E2\", \"F2\", \"G2\", \"H2\"]\n black_pawns = [\"A7\", \"B7\", \"C7\", \"D7\", \"E7\", \"F7\", \"G7\", \"H7\"]\n\n # create white pawns\n white_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(white, pos)\n end\n\n # create white pieces\n @board.nodes[\"E1\"].piece = create_king(white, \"E1\")\n @board.nodes[\"D1\"].piece = create_queen(white, \"D1\")\n @board.nodes[\"C1\"].piece = create_bishop(white, \"C1\")\n @board.nodes[\"F1\"].piece = create_bishop(white, \"F1\")\n @board.nodes[\"B1\"].piece = create_knight(white, \"B1\")\n @board.nodes[\"G1\"].piece = create_knight(white, \"G1\")\n @board.nodes[\"A1\"].piece = create_rook(white, \"A1\")\n @board.nodes[\"H1\"].piece = create_rook(white, \"H1\")\n\n # create black pawns\n black_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(black, pos)\n end\n\n # create black pieces\n @board.nodes[\"E8\"].piece = create_king(black, \"E8\")\n @board.nodes[\"D8\"].piece = create_queen(black, \"D8\")\n @board.nodes[\"C8\"].piece = create_bishop(black, \"C8\")\n @board.nodes[\"F8\"].piece = create_bishop(black, \"F8\")\n @board.nodes[\"B8\"].piece = create_knight(black, \"B8\")\n @board.nodes[\"G8\"].piece = create_knight(black, \"G8\")\n @board.nodes[\"A8\"].piece = create_rook(black, \"A8\")\n @board.nodes[\"H8\"].piece = create_rook(black, \"H8\")\n\n end", "def setup_board\n (1..64).each do |location|\n @@piece_locations[location] = {\"type\" => \" \", \"number\" => nil, \"color\" => nil}\n end\n\n # Black Pieces\n @@piece_locations[1] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[2] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[3] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[4] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[5] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[6] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[7] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[8] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 8] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"black\", \"moved\" => false}\n end\n\n # White Pieces\n @@piece_locations[57] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[58] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[59] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[60] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[61] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[62] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[63] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[64] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 48] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"red\", \"moved\" => false}\n end\n end", "def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end", "def place_initial_pieces\n x = @board.get_size/2\n y = @board.get_size/2\n \n @board.place_piece(x, y, @players[0])\n @board.place_piece(x - 1, y, @players[1])\n @board.place_piece(x, y - 1, @players[1])\n @board.place_piece(x -1, y - 1, @players[0])\n end", "def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end", "def populate_board\n\t\t8.times{|x|\t@board[x][6] = Pawn.new([x, 6], \"black\", @board)}\n\t\t@board[0][7] = Rook.new([0, 7], \"black\", @board)\t\n\t\t@board[1][7] = Knight.new([1, 7], \"black\", @board)\n\t\t@board[2][7] = Bishop.new([2, 7], \"black\", @board)\n\t\t@board[3][7] = Queen.new([3, 7], \"black\", @board)\n\t\t@board[4][7] = King.new([4, 7], \"black\", @board)\t\t\n\t\t@board[5][7] = Bishop.new([5, 7], \"black\", @board)\n\t\t@board[6][7] = Knight.new([6, 7], \"black\", @board)\n\t\t@board[7][7] = Rook.new([7, 7], \"black\", @board)\n\t\t\t\t\n\t\t 8.times{|x|\t@board[x][1] = Pawn.new([x, 1], \"white\", @board)}\n\t\t@board[0][0] = Rook.new([0, 0], \"white\", @board)\t\n\t\t@board[1][0] = Knight.new([1, 0], \"white\", @board)\n\t\t@board[2][0] = Bishop.new([2, 0], \"white\", @board)\n\t\t@board[3][0] = Queen.new([3, 0], \"white\", @board)\n\t\t@board[4][0] = King.new([4, 0], \"white\", @board)\t\t\n\t\t@board[5][0] = Bishop.new([5, 0], \"white\", @board)\n\t\t@board[6][0] = Knight.new([6, 0], \"white\", @board)\n\t\t@board[7][0] = Rook.new([7, 0], \"white\", @board)\n\tend", "def populate_grid\n start_rows = { red: (0..2), black: (5..7) }\n\n 8.times do |x|\n 8.times do |y|\n [:red, :black].each do |color|\n if (x + y).even? && start_rows[color].include?(y)\n self[[x, y]] = Piece.new(color, [x, y], self)\n end\n end\n end\n end\n\n grid.each_with_index do |row, y|\n row.each_with_index do |cell, x|\n puts \"x=#{x}, y=#{y}, cell.class=#{cell.class}\"\n end\n end\n end", "def initialize_board\n # Building out white pieces\n (0..7).each do |x|\n Pawn.create(is_black: false, x_position: x, y_position: 1, game_id: id, user_id: user_id_white, status: 'active')\n end\n\n Rook.create(is_black: false, x_position: 0, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Rook.create(is_black: false, x_position: 7, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Knight.create(is_black: false, x_position: 1, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Knight.create(is_black: false, x_position: 6, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Bishop.create(is_black: false, x_position: 2, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Bishop.create(is_black: false, x_position: 5, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n King.create(is_black: false, x_position: 4, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Queen.create(is_black: false, x_position: 3, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n # Building out the black pieces\n (0..7).each do |x|\n Pawn.create(is_black: true, x_position: x, y_position: 6, game_id: id, user_id: user_id_black, status: 'active')\n end\n\n Rook.create(is_black: true, x_position: 0, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Rook.create(is_black: true, x_position: 7, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Knight.create(is_black: true, x_position: 1, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Knight.create(is_black: true, x_position: 6, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Bishop.create(is_black: true, x_position: 2, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Bishop.create(is_black: true, x_position: 5, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n King.create(is_black: true, x_position: 4, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Queen.create(is_black: true, x_position: 3, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n end", "def set_pieces\n @pieces.each do |piece|\n y , x = piece.location\n @rows[y][x] = piece\n end\n end", "def create_initial_pieces\n WHITE_INITIAL_POSITIONS.each do |position|\n @white_pieces << CheckerPiece.new(self, position, :white)\n end\n BLACK_INITIAL_POSITIONS.each do |position|\n @black_pieces << CheckerPiece.new(self, position, :black)\n end\n end", "def build_pieces\n (1..8).each do |i|\n Pawn.new(2, i, \"white\") \n end\n Rook.new(1, 1, \"white\")\n Knight.new(1, 2, \"white\")\n Bishop.new(1, 3, \"white\")\n Queen.new(1, 4, \"white\")\n King.new(1, 5, \"white\")\n Bishop.new(1, 6, \"white\")\n Knight.new(1, 7, \"white\")\n Rook.new(1, 8, \"white\")\n (1..8).each do |i|\n Pawn.new(7, i, \"black\") \n end\n Rook.new(8, 1, \"black\")\n Knight.new(8, 2, \"black\")\n Bishop.new(8, 3, \"black\")\n Queen.new(8, 4, \"black\")\n King.new(8, 5, \"black\")\n Bishop.new(8, 6, \"black\")\n Knight.new(8, 7, \"black\")\n Rook.new(8, 8, \"black\")\n end", "def board_setup\n\t\tinitial_position = [\"rook\", \"knight\", \"bishop\", \"queen\", \"king\", \"bishop\", \"knight\", \"rook\"]\n\t\tspecial_position = [8,1]\n\t\tpawn_position = [7,2]\n\t\tinitial_color = [\"black\",\"white\"]\n\t\ti = 0\n\t\tx = 0\n\t\t#loops through ranks 8 and 1 setting each class piece in his corresponding position.\n\t\tspecial_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = initial_position[i]\n\t\t\t\t@board[letter+num.to_s].color = initial_color[x]\n\t\t\t\ti += 1\n\t\t\tend\n\t\t\ti = 0\n\t\t\tx += 1\n\t\tend\n\n\t\ty = 0\n\t\t#loos through ranks 7 and 2 setting the pawn's pieces in his corresponding position.\n\t\tpawn_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = \"pawn\"\n\t\t\t\t@board[letter+num.to_s].color = initial_color[y]\n\t\t\tend\n\t\t\ty += 1\n\t\tend\n\tend", "def set_pieces\n\t\t(0..7).each do |row|\n\t\t\tcase row\n\t\t\twhen 0\n\t\t\t\tplace_special_pieces(row, :white)\n\t\t\twhen 1\n\t\t\t\tplace_pawns(row, :white)\n\t\t\twhen 6\n\t\t\t\tplace_pawns(row, :black)\n\t\t\twhen 7\n\t\t\t\tplace_special_pieces(row, :black)\n\t\t\tend\n\t\tend\n\tend", "def init_pos\n reset_board_variables\n colors = {:white => 0, :black => 7}\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\n # set pieces \n colors.each do |k_col, v_col|\n # iterate each color\n key_color_array = key_pieces[k_col]\n pieces.each do |k_pie, v_pie|\n # iterate each piece\n v_pie.each do |ix_piece|\n #p v_col, ix_piece, k_pie, k_col\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[v_col][ix_piece] \n end\n end#end pieces\n \n # now set pawn for this color\n ix_col = 1\n ix_col = 6 if k_col == :black\n [0,1,2,3,4,5,6,7].each do |ix_piece|\n #p ix_col, ix_piece\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \n end\n end \n #p @pieces\n #p @infosquare\n #p @pieces.size\n #p @pieces[:white].first\n end", "def assign_pieces\n @pieces = Array.new(@number_of_pieces).map do\n piece = assign_until_unique(Piece.new)\n coordinates << piece.coordinates\n piece\n end\n end", "def init_pos\r\n reset_board_variables\r\n colors = {:white => 0, :black => 7}\r\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\r\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\r\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\r\n # set pieces \r\n colors.each do |k_col, v_col|\r\n # iterate each color\r\n key_color_array = key_pieces[k_col]\r\n pieces.each do |k_pie, v_pie|\r\n # iterate each piece\r\n v_pie.each do |ix_piece|\r\n #p v_col, ix_piece, k_pie, k_col\r\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[v_col][ix_piece] \r\n end\r\n end#end pieces\r\n \r\n # now set pawn for this color\r\n ix_col = 1\r\n ix_col = 6 if k_col == :black\r\n [0,1,2,3,4,5,6,7].each do |ix_piece|\r\n #p ix_col, ix_piece\r\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \r\n end\r\n end \r\n #p @pieces\r\n #p @infosquare\r\n #p @pieces.size\r\n #p @pieces[:white].first\r\n end", "def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :B) if offset.odd?\n end\n end\n\n [5, 6, 7].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :W) if offset.odd?\n end\n end\n end", "def place_pieces\n colors = [:black, :white]\n piece_classes = [King, Queen, Bishop, Knight, Rook, Pawn]\n\n colors.each do |color|\n piece_classes.each do |piece|\n piece.starting_positions(color).each do |pos|\n add_piece(piece.new(color, self, pos), pos)\n end\n end\n end\n end", "def build_board\n @original_board\n @working_board.collect! { |row|\n row.collect! { |cell|\n cell = @original_board.shift\n }\n }\n @working_board\n end", "def setup_board\r\n place_pawns\r\n place_bishops\r\n place_rooks\r\n place_knights\r\n place_queens\r\n place_kings\r\n end", "def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n\n (1..8).each do |row|\n (1..8).each do |col|\n\n # Place starting pieces on board\n if (1..3).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::RED)\n end\n\n @board[[row,col]] = Square.new(colors[0])\n\n colors << colors.delete_at(0) unless col == 8\n end\n end\n end", "def setup(board)\n ('a'..'h').each_with_index do |column, index|\n # Set up the home rows\n [[1, :white], [8, :black]].each do |row, color|\n piece = HOME_ROW[index].new(color)\n board.place( Square.new(column, row), piece )\n end\n \n # Setup the pawns\n [[2, :white], [7,:black]].each do |row, color|\n piece = Pawn.new(color)\n board.place( Square.new(column, row), piece)\n end\n end\n end", "def populate\n black = [\n Rook.new(:black, self, [0,0], \" ♜ \"),\n Knight.new(:black, self, [0,1], \" ♞ \"),\n Bishop.new(:black, self, [0,2], \" ♝ \"),\n Queen.new(:black, self, [0,3], \" ♛ \"),\n King.new(:black, self, [0,4], \" ♚ \"),\n Bishop.new(:black, self, [0,5], \" ♝ \"),\n Knight.new(:black, self, [0,6],\" ♞ \"),\n Rook.new(:black, self, [0,7], \" ♜ \")\n ]\n white = [\n Rook.new(:white, self, [7,0], \" ♖ \"),\n Knight.new(:white, self, [7,1], \" ♘ \"),\n Bishop.new(:white, self, [7,2], \" ♗ \"),\n Queen.new(:white, self, [7,3], \" ♕ \"),\n King.new(:white, self, [7,4], \" ♔ \"),\n Bishop.new(:white, self, [7,5], \" ♗ \"),\n Knight.new(:white, self, [7,6], \" ♘ \"),\n Rook.new(:white, self, [7,7], \" ♖ \")\n ]\n\n @grid.each_with_index do |row, i|\n row.each_with_index do |column, j|\n pos = [i, j]\n if i == 0\n self[pos]= black[j]\n @black_pieces << black[j]\n elsif i == 7\n self[pos]= white[j]\n @white_pieces << white[j]\n elsif i == 1\n black_pawn = Pawn.new(:black, self, pos, \" ♟ \")\n self[pos]= black_pawn\n @black_pieces << black_pawn\n elsif i == 6\n white_pawn = Pawn.new(:white, self, pos, \" ♙ \")\n self[pos] = white_pawn\n @white_pieces << white_pawn\n end\n end\n end\n\n @grid\n end", "def fill_board\n\t\tfill_row_pieces(0, 'b')\n\t\tfill_row_pawn(1, 'b')\n\t\tfill_row_pieces(7, 'w')\n\t\tfill_row_pawn(6, 'w')\n\tend", "def make_board\n make_blank_board\n populate_board\n end", "def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n \n (1..8).each do |row|\n (1..8).each do |col|\n sq = Square.new(colors[0])\n\n # Place starting pieces on board\n if (1..3).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::RED)\n end\n \n @board[[row,col]] = sq\n \n colors << colors.delete_at(0) unless col == 8\n end\n end\n end", "def draw_board_start\n #Places the pawns\n 8.times do |x|\n @b[x][1] = @WP\n @b[x][6] = @BP\n end\n #white, on bottom, the opaque pieces\n @b[0][0] = @WR; @b[7][0] = @WR\n @b[1][0] = @WK; @b[6][0] = @WK\n @b[2][0] = @WB; @b[5][0] = @WB\n @b[3][0] = @WQ\n @b[4][0] = @WKg\n #black, on top, the filled in pieces\n @b[0][7] = @BR; @b[7][7] = @BR\n @b[1][7] = @BK; @b[6][7] = @BK\n @b[2][7] = @BB; @b[5][7] = @BB\n @b[3][7] = @BQ\n @b[4][7] = @BKg\n \n #TESTING PIECES HERE\n\n\n draw_board\n end", "def place_pawns\r\n $board.each_index do |x|\r\n $board[x][1] = Pawn.new('white')\r\n $board[x][6] = Pawn.new('black')\r\n end\r\n end", "def update_board\n #clear previous move_list from all pieces\n @board.each do |row|\n row.each do |col|\n col.move_list = [] if !col.nil?\n end\n end\n #clear previous state of @all_pieces\n @all_pieces = []\n #adds every piece obj to all_pieces instance variable\n @board.each do |row|\n row.each do |col|\n @all_pieces << col if !col.nil?\n end\n end\n #give each piece a copy of the board state\n #then allow generate_moves method to come up with a list of possible moves\n #based on that board state\n @all_pieces.each do |n|\n n.board = self\n n.generate_moves\n end\n #add this state to the board_history instance variable\n @board_history << @board\n end", "def compact_pieces\n @recheck = false\n for i in (0..@width-1)\n for j in (0..@height-1)\n if @board[i][j] and @board[i][j+1].nil? #drop pieces down\n @recheck = true\n @board[i][j+1] = @board[i][j]\n @board[i][j] = nil \n elsif j == 0 and @board[i][j].nil? #replace pieces at top\n @recheck = true\n @board[i][j] = Piece.new\n end\n end\n end\n if @startup and @recheck #fast setup of board before update + anim loops start\n compact_pieces\n clear_matches\n end \n end", "def assign_pieces(player)\n if player.num == 1\n piece_color = \"W\"\n else\n piece_color = \"B\"\n end\n\n @board.each do |row|\n row.each do |piece|\n \n if !piece.nil?\n if piece.color == piece_color\n player.pieces << piece\n piece.player = player\n end\n end\n end\n end \n end", "def setup_board\n gameboard.build_board\n build_white_side\n build_black_side\n end", "def board\n board = Board.new(true)\n grid do |p|\n new_position = p\n new_color = p.color\n new_piece = p.class.new(new_position, new_color, board )\n board[p.pos] = new_piece\n end\n board\n end", "def initialize_board\n # Non-pawns for black player:\n Rook.create(x_position: 1, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 2, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 3, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Queen.create(x_position: 4, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n King.create(x_position: 5, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 6, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 7, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Rook.create(x_position: 8, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n\n # Non-pawns for white player:\n Rook.create(x_position: 1, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 2, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 3, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Queen.create(x_position: 4, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n King.create(x_position: 5, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 6, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 7, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Rook.create(x_position: 8, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n\n # Pawns for both players:\n for i in 1..8\n Pawn.create(color: \"black\", x_position: i, y_position: 2, game_id: id, player_id: black_player_id)\n Pawn.create(color: \"white\", x_position: i, y_position: 7, game_id: id, player_id: white_player_id)\n end\n\n self.counter = 0\n # Saves the counter to the database.\n self.save\n end", "def populate_board!\n # QUEENS - the user who created the game will be black, the opponent will be white\n Queen.create(game_id: id, user_id: user_id, position_x: 3, position_y: 7, color: \"black\", name: \"black queen\")\n Queen.create(game_id: id, user_id: opponent, position_x: 3, position_y: 0, color: \"white\", name: \"white queen\")\n # KINGS\n King.create(game_id: id, user_id: user_id, position_x: 4, position_y: 7, color: \"black\", name: \"black king\")\n King.create(game_id: id, user_id: opponent, position_x: 4, position_y: 0, color: \"white\", name: \"white king\")\n # BISHOPS\n # black bishops\n Bishop.create(game_id: id, user_id: user_id, position_x: 2, position_y: 7, color: \"black\", name: \"black bishop 1\")\n Bishop.create(game_id: id, user_id: user_id, position_x: 5, position_y: 7, color: \"black\", name: \"black bishop 2\")\n # white bishops\n Bishop.create(game_id: id, user_id: opponent, position_x: 2, position_y: 0, color: \"white\", name: \"white bishop 1\")\n Bishop.create(game_id: id, user_id: opponent, position_x: 5, position_y: 0, color: \"white\", name: \"white bishop 2\")\n # KNIGHTS\n # black knights\n Knight.create(game_id: id, user_id: user_id, position_x: 1, position_y: 7, color: \"black\", name: \"black knight 1\")\n Knight.create(game_id: id, user_id: user_id, position_x: 6, position_y: 7, color: \"black\", name: \"black knight 2\")\n # white knights\n Knight.create(game_id: id, user_id: opponent, position_x: 1, position_y: 0, color: \"white\", name: \"white knight 1\")\n Knight.create(game_id: id, user_id: opponent, position_x: 6, position_y: 0, color: \"white\", name: \"white knight 2\")\n # rooks\n # black rooks\n Rook.create(game_id: id, user_id: user_id, position_x: 0, position_y: 7, color: \"black\", name: \"black rook 1\")\n Rook.create(game_id: id, user_id: user_id, position_x: 7, position_y: 7, color: \"black\", name: \"black rook 2\")\n # white rooks\n Rook.create(game_id: id, user_id: opponent, position_x: 0, position_y: 0, color: \"white\", name: \"white rook 1\")\n Rook.create(game_id: id, user_id: opponent, position_x: 7, position_y: 0, color: \"white\", name: \"white rook 2\")\n # PAWNS\n # populate black pawns\n black_pawn_x = 0\n black_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: user_id, position_x: black_pawn_x, position_y: 6, color: \"black\", name: \"black pawn #{black_pawn_number}\")\n black_pawn_x += 1\n black_pawn_number += 1\n end\n # populate white pawns\n white_pawn_x = 0\n white_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: opponent, position_x: white_pawn_x, position_y: 1, color: \"white\", name: \"white pawn #{white_pawn_number}\")\n white_pawn_x += 1\n white_pawn_number += 1\n end\n end", "def initialize\n @piece_count = 0\n\n @grid = []\n (0..6).each do |col|\n @grid[col] = []\n (0..5).each do |row|\n @grid[col][row] = \"-\"\n end\n end\n end", "def board_refresh\n print_board(@@piece_locations)\n end", "def setup_game\n name_player = set_name_player\n number_columns = set_number_columns\n number_rabbits = set_number_rabbits(number_columns)\n number_foxs = set_number_foxs(number_columns)\n\n board = build_board(number_columns)\n rabbit_collection = build_rabbit_collection(number_columns, number_rabbits)\n fox_collection = build_fox_collection(number_columns, number_foxs)\n\n\n [ board, name_player, number_columns, rabbit_collection, fox_collection ]\nend", "def starting_pieces(color)\n #8 pieces total\n i = (color == :white) ? [0,1] : [6,7]\n\n 8.times do |j| #build back row pieces\n if (j+i[0]).odd?\n c = Piece.new(color, [i[0],j])\n @pieces << c\n end\n end\n\n 8.times do |j| #build front row pieces\n if (j+i[0]).even?\n c = Piece.new(color, [i[1],j])\n @pieces << c\n end\n end\n end", "def create_board\n @board[\"18\"] = Rook.new(\"Blacks\")\n @board[\"28\"] = Knight.new(\"Blacks\")\n @board[\"38\"] = Bishop.new(\"Blacks\")\n @board[\"48\"] = Queen.new(\"Blacks\")\n @board[\"58\"] = King.new(\"Blacks\")\n @board[\"68\"] = Bishop.new(\"Blacks\")\n @board[\"78\"] = Knight.new(\"Blacks\")\n @board[\"88\"] = Rook.new(\"Blacks\") \n 8.times { |index| @board[\"#{index + 1}7\"] = BlackPawn.new(\"Blacks\") } \n\n 8.times { |index| @board[\"#{index + 1}6\"] = nil }\n 8.times { |index| @board[\"#{index + 1}5\"] = nil }\n 8.times { |index| @board[\"#{index + 1}4\"] = nil }\n 8.times { |index| @board[\"#{index + 1}3\"] = nil }\n\n 8.times { |index| @board[\"#{index + 1}2\"] = WhitePawn.new(\"Whites\") } \n @board[\"11\"] = Rook.new(\"Whites\") \n @board[\"21\"] = Knight.new(\"Whites\")\n @board[\"31\"] = Bishop.new(\"Whites\")\n @board[\"41\"] = Queen.new(\"Whites\")\n @board[\"51\"] = King.new(\"Whites\")\n @board[\"61\"] = Bishop.new(\"Whites\")\n @board[\"71\"] = Knight.new(\"Whites\")\n @board[\"81\"] = Rook.new(\"Whites\")\n end", "def populate_board(_board, str)\n black = []\n white = []\n\n # parse string\n str.delete(\"\\n\").split(//).each.with_index do |space, idx|\n xpos = idx % 3\n ypos = (idx - xpos) / 3\n\n case space\n when 'w'\n white << [xpos, ypos]\n when 'b'\n black << [xpos, ypos]\n end\n end\n\n # populate\n loop do\n pos =\n if game.player_turn == :white\n white.shift\n else\n black.shift\n end\n\n game.add_piece(*pos)\n\n break if white.empty? && black.empty?\n end\n end", "def setup( )\n\t\t\t(\"a\"..\"h\").each do |f|\n\t\t\t\t@squares[\"#{f}2\"] = Chess::Pawn.new(self, \"#{f}2\", :white)\n\t\t\t\t@squares[\"#{f}7\"] = Chess::Pawn.new(self, \"#{f}7\", :black)\n\t\t\tend\n\t\t\t[\"a\", \"h\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Rook.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Rook.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"b\", \"g\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Knight.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Knight.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"c\", \"f\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Bishop.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Bishop.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t@squares[\"d1\"] = Chess::Queen.new(self, \"d1\", :white)\n\t\t\t@squares[\"d8\"] = Chess::Queen.new(self, \"d8\", :black)\n\t\t\t@squares[\"e1\"] = Chess::King.new(self, \"e1\", :white)\n\t\t\t@squares[\"e8\"] = Chess::King.new(self, \"e8\", :black)\n\t\tend", "def reset_board_variables\n @color_on_turn = :white\n @fifty_counter = 0\n @pieces = {:white => [], :black => []} \n @last_moved_item = BoardInfoItem.new(0,0)\n @infosquare.each do |row_square|\n row_square.each do |cell|\n cell.clear\n end\n end\n #p @infosquare\n end", "def reset_board_variables\r\n @color_on_turn = :white\r\n @pieces = {:white => [], :black => []} \r\n @last_moved_item = BoardInfoItem.new(0,0)\r\n @infosquare.each do |row_square|\r\n row_square.each do |cell|\r\n cell.clear\r\n end\r\n end\r\n #p @infosquare\r\n end", "def setup\n setup_major_pieces\n setup_pawns\n end", "def initialize(empty = false)\n @white_points = []\n @black_points = []\n return if empty\n\n @board = []\n 8.times do\n col = []\n 8.times do\n col << SPOT_OPEN\n end\n @board << col\n end\n\n # Add the starting pieces\n mark(3, 3, SPOT_WHITE)\n mark(4, 3, SPOT_BLACK)\n mark(4, 4, SPOT_WHITE)\n mark(3, 4, SPOT_BLACK)\n end", "def draw_pieces\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n @pieces[x][y].remove unless @pieces[x][y].nil?\n @pieces[x][y] = draw_piece(x,y,@board.state[x][y]) unless @board.state[x][y].nil?\n end\n end\nend", "def initialize\n @board = Array.new(8) { Array.new(8) }\n @all_pieces = []\n @board_history = []\n @move_record = []\n end", "def create_pieces(color)\n 8.times { @pieces << Pawn.new(color) }\n 2.times do\n @pieces << Rook.new(color)\n @pieces << Bishop.new(color)\n @pieces << Knight.new(color)\n end\n @pieces << Queen.new(color)\n @pieces << King.new(color)\n end", "def make_pieces(first_position, color, rows, direction)\n switch = Hash[1, 0, 0, 1]\n start_column = first_position[1]\n start_row = first_position[0]\n num_pieces = size/2\n rows.times do |row_num|\n num_pieces.times do |col_num|\n col_num *= 2\n position = [start_row + (row_num * direction), start_column + col_num]\n Piece.new(position, self, color)\n end\n start_column = switch[start_column]\n end\n end", "def create_board\n\t\t8.times{|x| @board.push([nil,nil,nil,nil,nil,nil,nil,nil])}\n\t\tpopulate_board\n\tend", "def start_game\n # remove all pieces in case of a restart\n remove_pieces unless @pieces.nil?\n # initialize a new game board\n @board = Board.new\n # initialize pieces for the GUI board\n @pieces = Array.new(CHECKERS_WIDTH) { Array.new(CHECKERS_HEIGHT) }\n # Start a new game with :starting player turn, created board, CPU player and difficulty \n @game = Checkers.new(@first_player.text.downcase, @board, CPU_PLAYER, DIFFICULTY[@difficulty.text])\n draw_pieces\n @selected_piece = nil\n @message = \"None\"\n # Display game statistics\n update_stats\n # toggle game status to running\n @game_running = true\nend", "def setup_board!\n\t\t@board = Array.new($dimensions[:y]){ Array.new($dimensions[:x]) {:empty} }\n\tend", "def update_board(column, color)\n @grid[column][bottom(column)] = Piece.new(color)\n end", "def starting_board\n init_rows([0, 2], :black)\n init_rows([5, 7], :red)\n end", "def initialize(board, color)\n @board = board\n @isWhite = color == \"white\"\n @pieces = []\n if(@isWhite)\n 8.times {|i| @pieces << Pawn.new(board, \"white\", 6, i)}\n @pieces << Rook.new(board, \"white\", 7, 0)\n @pieces << Rook.new(board, \"white\", 7, 7)\n @pieces << Knight.new(board, \"white\", 7, 1)\n @pieces << Knight.new(board, \"white\", 7, 6)\n @pieces << Bishop.new(board, \"white\", 7, 2)\n @pieces << Bishop.new(board, \"white\", 7, 5)\n @pieces << Queen.new(board, \"white\", 7, 3)\n @king = King.new(board, \"white\", 7, 4)\n else #color is black\n 8.times {|i| @pieces << Pawn.new(board, \"black\", 1, i)}\n @pieces << Rook.new(board, \"black\", 0, 0)\n @pieces << Rook.new(board, \"black\", 0, 7)\n @pieces << Knight.new(board, \"black\", 0, 1)\n @pieces << Knight.new(board, \"black\", 0, 6)\n @pieces << Bishop.new(board, \"black\", 0, 2)\n @pieces << Bishop.new(board, \"black\", 0, 5)\n @pieces << Queen.new(board, \"black\", 0, 3)\n @king = King.new(board, \"black\", 0, 4)\n end\n @in_checkmate = false\n end", "def place_pawn_first_rows\n 8.times { |col| self[[1, col]] = Pawn.new(self, :black, [1, col]) }\n 8.times { |col| self[[6, col]] = Pawn.new(self, :white, [6, col]) }\n end", "def test_init\n #@board[0][5].piece = Bishop.new(@board[0][5], \"♗\", \"white\")\n @board[0][4].piece = King.new(@board[0][4], \"♔\", 'white')\n\n @board[7][4].piece = Queen.new(@board[7][4], \"♛\", \"black\" )\n @board[7][3].piece = Rook.new(@board[7][3], \"♜\", \"black\")\n @board[7][5].piece = Rook.new(@board[7][5], \"♜\", \"black\")\n end", "def new_board\n board = []\n 8.times do |row|\n board << case row\n when 0\n add_back_row(\"white\", row)\n when 1\n add_pawn_row(\"white\", row)\n when 6\n add_pawn_row(\"black\", row)\n when 7\n add_back_row(\"black\", row)\n else\n Array.new(8)\n end\n end \n board\n end", "def create_positions\n (1..GAME_BOARD_LENGTH).each do |y|\n (1..GAME_BOARD_LENGTH).each do |x|\n self.positions.new(x: x, y: y)\n end\n end\n set_ships\n save\n end", "def put_pawns\n row = 1\n color = \"w\"\n 2.times do\n @@board[row].each_index do |i|\n @@board[row][i] = Pawn.new(i, row, color)\n end\n row = 6\n color = \"b\"\n end\n end", "def add_piece(start_x, start_y, board, orientation)\n\t\tcase orientation\n\t\twhen 0\n\t\t\tboard[start_x][start_y] = board[start_x+1][start_y] = board[start_x][start_y+1] = board[start_x+1][start_y+1] = 1\n\t\t\tboard[start_x][start_y-1] = board[start_x+1][start_y-1] = board[start_x][start_y+2] = board[start_x+1][start_y+2] = \\\n\t\t\tboard[start_x+2][start_y] = board[start_x-1][start_y] = board[start_x+2][start_y+1] = board[start_x-1][start_y+1] = 2\n\t\twhen 1\n\t\t\tboard[start_x][start_y] = board[start_x-1][start_y] = board[start_x-1][start_y+1] = board[start_x][start_y+1] = 1\n\t\t\tboard[start_x][start_y-1] = board[start_x-1][start_y-1] = board[start_x][start_y+2] = board[start_x-1][start_y+2] = \\\n\t\t\tboard[start_x+1][start_y] = board[start_x-2][start_y] = board[start_x+1][start_y+1] = board[start_x-2][start_y+1] = 2\n\t\twhen 2\n\t\t\tboard[start_x][start_y] = board[start_x][start_y-1] = board[start_x+1][start_y-1] = board[start_x+1][start_y] = 1\n\t\t\tboard[start_x][start_y+1] = board[start_x+1][start_y+1] = board[start_x][start_y-2] = board[start_x+1][start_y-2] = \\\n\t\t\tboard[start_x+2][start_y] = board[start_x-1][start_y] = board[start_x+2][start_y-1] = board[start_x-1][start_y-1] = 2\n\t\twhen 3\n\t\t\tboard[start_x][start_y] = board[start_x][start_y-1] = board[start_x-1][start_y-1] = board[start_x-1][start_y] = 1\n\t\t\tboard[start_x][start_y+1] = board[start_x-1][start_y+1] = board[start_x][start_y-2] = board[start_x-1][start_y-2] = \\\n\t\t\tboard[start_x+1][start_y] = board[start_x-2][start_y] = board[start_x+1][start_y-1] = board[start_x-2][start_y-1] = 2\n\t\tend\n\tend", "def create_piece\n @in_play = @current_piece.new(@object_array, @window)\n\n # Create the ghost piece give the piece in play\n calculate_ghost_piece\n end", "def initialize\n @board = Array.new(64, 0)\n @black_king_side_castling = true\n @white_king_side_castling = true\n @black_queen_side_castling = true\n @white_queen_side_castling = true\n @last_move = [64,64]\n\n # place pawns\n for i in (8..15)\n @board[i] = -1\n end\n for i in (48..55)\n @board[i] = 1\n end\n\n # place other pieces\n black = [-4, -2, -3, -5, -6, -3, -2, -4]\n white = [4, 2, 3, 5, 6, 3, 2, 4]\n for i in (0..7)\n @board[i] = black.shift\n end\n for i in (56..63)\n @board[i] = white.shift\n end\n end", "def dup_board\n new_board = Board.new(false)\n self.grid.each_with_index do |row, i|\n row.each_with_index do |object, j|\n pos = [i, j]\n if object.nil?\n new_board[pos] = nil\n else\n new_board[pos] = Piece.new(object.color, pos, new_board)\n end\n end\n end\n\n new_board\n end", "def place_piece\n @game = Game.find(params[:id])\n player = current_user.game_players.where(game_id: @game.id).first\n if !params[:hotel].nil?\n selected_hotel = params[:hotel]\n hotel_stock_cards = @game.stock_cards.where(hotel: selected_hotel)\n if hotel_stock_cards.count > 0\n chosen_card = hotel_stock_cards.first\n @game.stock_cards.delete(chosen_card)\n @game.save\n player.stock_cards << chosen_card\n player.save\n end\n else\n selected_hotel = 'none'\n end\n @cell = params[:cell]\n num, letter = params[:num].to_i, params[:letter]\n @game_tile = @game.game_tiles.where(cell: @cell)\n if @game.merger != true && player.buy_stocks != true\n if @game.is_current_players_turn?(current_user)\n if @game.player_hand(current_user, @cell) \n # throws exception if tile is part of new chain because need input from user\n begin\n array = @game.choose_color(letter, num, @cell, selected_hotel, player)\n rescue\n render :json => @game, :status => :unprocessable_entity\n return\n end\n\n if array == false\n answer = {legal: false}\n else\n # updates hand of tiles of player\n available_tiles = @game.game_tiles.where(available: true)\n new_game_tile = available_tiles[rand(available_tiles.length)]\n new_game_tile.available = false\n new_game_tile.save\n new_tile = @game.tiles.where(id: new_game_tile.tile_id)\n placed_tile = player.tiles.where(row: letter).where(column: num).first\n placed_game_tile = @game.game_tiles.where(tile_id: placed_tile.id).first\n placed_game_tile.placed = true\n placed_game_tile.save\n player.tiles.delete(placed_tile)\n player.tiles << new_tile\n\n color = array[0]\n other_tiles = array[1]\n merger = array[2]\n merger_three = array[3]\n if merger\n @game.acquired_hotel = array[4]\n num_shares = player.stock_cards.where(hotel: @game.acquired_hotel).count\n @game.has_shares = num_shares\n @game.merger_up_next = player.username\n else\n if merger_three\n merger = true\n @game.acquired_hotel = array[4]\n num_shares = player.stock_cards.where(hotel: @game.acquired_hotel).count\n @game.has_shares = num_shares\n @game.second_acquired_hotel = array[5]\n @game.merger_up_next = player.username\n else\n @game.acquired_hotel = 'none'\n end\n end\n founded_hotels = @game.game_hotels.where('chain_size > 0')\n if founded_hotels.length == 0 \n @game.end_turn\n else\n player.buy_stocks = true\n end\n\n @game.save\n player.save\n answer = {legal: true, color: color, other_tiles: other_tiles, new_tiles: player.tiles, merger: merger, has_shares: @game.has_shares, acquired_hotel: @game.acquired_hotel}\n end \n else\n answer = {legal: false}\n end\n else\n answer = {legal: false}\n end\n else\n answer = {legal: false}\n end\n # gets updated state of game and parses data as json and passes to front end\n game_state\n @payload[:answer] = answer\n render :json => @payload\n end", "def gen_pawn_moves(color)\n moves = []\n all = @position.all_pieces\n \n if color == :white\n position = @position.white \n enemy = @position.black_pieces\n #white pawn moves up the board (increasing bit index order)\n delta = 8\n else\n position = @position.black\n enemy = @position.white_pieces\n #white pawn moves down the board (decreasing bit index order)\n delta = -8\n end\n # no work to do when there are no pawns \n return moves if position[:pawn].nil?\n \n # for each pawn\n position[:pawn].set_bits.each do |from| \n # valid moves are those moves to a free square...\n to = from + delta\n if all.clear?(to) \n moves << [Square.index(from), Square.index(to)]\n to += delta\n moves << [Square.index(from), Square.index(to)] if not_moved_yet(color, from) && all.clear?(to)\n end\n \n # ...plus attacks on the enemies pieces\n move_to = (Move::Attacks[:pawn][color][from] & enemy)\n move_to.set_bits.each { |to_move| moves << [Square.index(from), Square.index(to_move)] }\n end\n moves\n end", "def place_pawns(row, color)\n\t\t(0..7).each do |square|\n\t\t\t@board[square][row].piece = Pawn.new(color)\n\t\tend\n\tend", "def initialize pieces=nil\n @squares = []\n for i in 0...64 do\n @squares[i] = Square.new \n end\n\n @pieces = pieces\n @pieces ||= createPieceHash\n @rules = ChessRules.new\n end", "def place_special_pieces(row, color)\n\t\t@board[0][row].piece = Rook.new(color)\n\t\t@board[1][row].piece = Knight.new(color)\n\t\t@board[2][row].piece = Bishop.new(color)\n\t\t@board[3][row].piece = King.new(color)\n\t\t@board[4][row].piece = Queen.new(color)\n\t\t@board[5][row].piece = Bishop.new(color)\n\t\t@board[6][row].piece = Knight.new(color)\n\t\t@board[7][row].piece = Rook.new(color)\n\tend", "def initializeBoard()\n\t\tfor i in (0...@board.length)\n\t\t\tfor j in (0...@board.length)\n\t\t\t\t@board[i][j] = EMPTY\n\t\t\tend\n\t\tend\n\n\t\t@board[@size/2][@size/2] = BLACK\n\t\t@board[@size/2 - 1][@size/2 - 1] = BLACK\n\t\t@board[@size/2 - 1][@size/2] = WHITE\n\t\t@board[@size/2][@size/2 - 1] = WHITE\n\n end", "def create_board\n (1..(@width * @width).to_i).each do |i|\n values = i <= @amount_mines ? @bomb : @empty\n @board.push({\n value: values,\n revealed?: false\n })\n end\n @board.shuffle!\n @board\n end", "def populate()\n @card_values.shuffle!\n i = 0\n (0...@size).each do |row|\n (0...@size).each do |col|\n @grid[row][col] = Card.new(@card_values[i])\n i += 1\n end\n end\n end", "def new_piece\n next_tetromino\n\n col = @columns / 2 - 1\n row = 0\n\n @falling_piece.x = col * @block_size + self.screen_x\n @falling_piece.y = row * @block_size + self.screen_y\n\n @falling_piece.grid_position.x = col + 1\n @falling_piece.grid_position.y = row\n\n if collides?\n game_over\n end\n end", "def map_board\n\t\t@cell_at = []\n\t\t@height.times do |row|\n\t\t\t@cell_at[row] = []\n\t\t\t@width.times do |col|\n\t\t\t\t@cell_at[row][col] = Cell.new\n\t\t\tend\n\t\tend\n\tend", "def make_board\n @grid = Array.new(9) { | row | Array.new(9) { | col | Tile.new(self, [row, col]) } }\n self.place_bombs\n @grid.map.with_index do | row, rowIndx |\n row.map.with_index { | tile, colIndx | tile.neighbors_bomb_count if !(self.is_a_bomb?([rowIndx, colIndx])) }\n end\n end", "def setup_grid(skip_render, skip_set_pieces)\n @grid = Array.new(8) { Array.new(8) { EmptySquare.new } }\n unless skip_set_pieces\n set_major_minor\n set_pawns\n end\n\n render unless skip_render\n end", "def piece_sensing\n # iterate through each piece on the board\n board.each do |origin_piece|\n\n # Only consider origin pieces which exist\n if !!origin_piece\n\n # clear the piece's sensing data before populating\n origin_piece.clear_possible_moves\n origin_piece.clear_pieces_in_range\n\n # iterate through each potential direction of movement\n origin_piece.controlled_squares.each do |direction_of_movement|\n\n # iterate through coordinates moving away from the piece\n direction_of_movement.each do |test_coords|\n if ( test_coords &&\n board.in_bounds?(test_coords[0],test_coords[1]) )\n\n # set row and column variables for convenience and clarity\n test_row = test_coords[0]\n test_col = test_coords[1]\n\n # Call the possible move detection method\n if possible_move?(origin_piece,test_row,test_col)\n move_string = indices_to_chess_coords(test_row,test_col)\n origin_piece.add_possible_move(move_string)\n end\n\n # Call the piece detection method and break if it succeeds;\n # Once a piece is found, no more moves in that direction are valid\n if piece_in_range?(origin_piece, test_row, test_col)\n # The string to add to pieces in range\n piece_string = find_piece_string(test_row,test_col)\n\n # Add the piece to the origin_pieces pieces in range\n origin_piece.add_piece_in_range(piece_string)\n break\n end\n end\n end\n end\n end\n end\n check_for_check(current_player)\n end", "def initialize(fill_board = true)\n @sentinel = Null_piece.instance\n\n @rows = Array.new(8) { Array.new(8, @sentinel) }\n\n fill_board_tiles if fill_board\n end", "def generate_board\n board_array = @board_string.split(\"\")\n @board = Array.new(9){board_array.shift(9)}\n for row in 0...@board.length\n for col in 0...@board.length\n @board[row][col] = Square.new(@board[row][col], row, col)\n end\n end\n create_starting_numbers\n @board\n end", "def board_dup\n new_board = Board.new(true)\n\n pieces_and_empties.each do |piece|\n x, y = piece.pos\n new_board.board[x][y] = piece.class.new(new_board, piece.color, piece.pos)\n end\n # debugger\n new_board\n end", "def fill_on_board(move, player)\n\n\t\t@board[move[0]][move[1]] = player\n\n\t\treturn @board\n\n\tend", "def testing_checkmate(board)\n\n test_pieces = [\n King.new(:w, [0,0], board),\n King.new(:b, [1,0], board),\n Queen.new(:b, [0,1], board)\n ]\n\n test_pieces.each do |test_piece|\n board[test_piece.position] = test_piece\n end\n\n board\n\nend", "def initializeBoard()\n #\n # TO DO: complete this method\n #\n for j in 0...@size\n for i in 0...@size\n @board[j][i]=EMPTY\n end\n end\n center = (@size/2)-1\n @board[center][center] = BLACK\n @board[center+1][center+1] = BLACK\n @board[center+1][center] = WHITE\n @board[center][center+1] = WHITE\n\n\n\n\n end", "def place_piece(size, pat, zeros)\n x, y = generate_seed(size, pat, zeros)# if x.nil? || y.nil?\n if !@board.nil?\n pat.each_with_index do |paty, indexy|\n paty.each_with_index do |patx, indexx| \n @board[y+indexy][x+indexx] = pat[indexy][indexx] \n end\n end\n end\n end", "def create_game_board\n\t\tnew_board = {}\n\t\ti = 1\n\t\t6.times do \n\t\t\tj = 1\n\t\t\t7.times do\n\t\t\t\tcurrent_key = \"#{j}-#{i}\"\n\t\t\t\tnew_board[current_key] = ConnectFourLocation.new\n\t\t\t\tj += 1\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\treturn new_board\n\tend", "def populate!()\n\n tile_factory = TileFactory.new()\n livingbeing_factory = LivingBeingFactory.new()\n\n @m.times do |y|\n @n.times do |x|\n\n # Water vs Ground\n location = Location.new(@n, @m, x, y)\n wg = tile_factory.create(Utils.generate_random_percentage(), location)\n\n if wg\n\n @tiles[x][y] = wg\n else\n\n raise StandardError.new(\"Incorrect Percentages less than 100\")\n end\n\n # If tile is Ground type...\n if @tiles[x][y].is_a?(Ground)\n \n lb = livingbeing_factory.create(Utils.generate_random_percentage())\n\n @tiles[x][y].livingbeing = lb if lb\n end\n end\n end\n\n self\n end", "def moves\n # All pieces can stay in place\n [[0,0]]\n end", "def setup_board\n # Create game objects.\n create_objects\n\n # Print the start game string.\n puts start_game\n # For each ship ask for user input and place them once the given coordinates and placement is valid.\n @user_ships.each do |ship|\n print user_placement_selection(ship)\n user_place_location = convert_user_coord(user_input)\n \n # Loop until there is a valid input from the user.\n until place_user_ship(ship, user_place_location)\n print invalid_coord\n user_place_location = convert_user_coord(user_input)\n end\n # Show the users ship setup.\n puts show_user_ships_setup\n end\n end", "def initialize_board\n init_board = \"-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1\"\n if self.update(board: init_board)\n return [[ 0,-1,0,-1,0,-1, 0,-1 ],[-1,0,-1,0,-1,0,-1,0],[0,-1,0,-1,0,-1,0,-1],\n [0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],\n [1,0,1,0,1,0,1,0],[0,1,0,1,0,1,0,1],[1,0,1,0,1,0,1,0]]\n end\n end", "def initialize_board\n board = Array.new(8) {Array.new(8)}\n populate_board(board)\n end", "def dup\n empty_board = Board.new(false)\n pieces.each do |piece|\n temp_color = (piece.color == :red) ? :red : :white\n temp_pos = [piece.pos[0], piece.pos[1]]\n temp_kinged = piece.kinged\n temp_piece = Piece.new(empty_board, temp_color, temp_pos, temp_kinged)\n\n # empty_board.add_piece(Piece.new(empty_board, temp_color, temp_pos, temp_kinged), temp_pos)\n end\n\n empty_board\n # duped_rows = rows.map(&:dup)\n #\n # duped_rows.each_with_index do |row, row_idx|\n # row.each_index do |col_idx|\n # next if duped_rows[row_idx].nil?\n # current_cell = duped_rows[row_idx][col_idx]\n #\n # next if current_cell.nil?\n # duped_rows[row_idx][col_idx] = current_cell.dup\n # end\n # end\n # duped_board = self.class.new(duped_rows, false)\n # duped_board.pieces.each do |piece|\n # piece.board = duped_board\n # end\n # duped_board\n\n end", "def build_move_lists(colour)\n pieces = select_pieces(colour)\n pieces.each_with_object({}) do |piece, res|\n res[piece] = board.grid[piece.first][piece.last].move_list(board.grid, [piece.first, piece.last])\n end\n end" ]
[ "0.79640114", "0.7943438", "0.7877075", "0.7848217", "0.7834404", "0.781956", "0.7795295", "0.7762303", "0.76904154", "0.7671021", "0.7611875", "0.7572343", "0.75351405", "0.74465734", "0.7424019", "0.7398058", "0.7330775", "0.7299266", "0.72951263", "0.72780603", "0.7269734", "0.7243837", "0.72288936", "0.72096646", "0.7195942", "0.71928036", "0.71879596", "0.71685576", "0.71448034", "0.7125726", "0.71006984", "0.70325756", "0.7021846", "0.7005542", "0.69825035", "0.69782376", "0.69156945", "0.69007814", "0.6852286", "0.6845752", "0.68450457", "0.67986584", "0.677885", "0.6768332", "0.67662174", "0.67580086", "0.6728773", "0.67166483", "0.6708322", "0.6699752", "0.6680823", "0.66616815", "0.66337746", "0.6624796", "0.6617332", "0.6607844", "0.66070306", "0.6603968", "0.6594663", "0.6567678", "0.6555085", "0.6540578", "0.6514379", "0.6494811", "0.6482174", "0.6469511", "0.6467429", "0.6463197", "0.6456946", "0.6446128", "0.6443149", "0.64422196", "0.6436499", "0.6430565", "0.64185965", "0.6418436", "0.6417125", "0.6410973", "0.6408851", "0.64047503", "0.6401258", "0.63988495", "0.63912284", "0.63893783", "0.6388848", "0.6387263", "0.63854575", "0.63805676", "0.63797575", "0.6377314", "0.63738203", "0.6372295", "0.6349096", "0.6347977", "0.63406616", "0.63336897", "0.63239205", "0.6322653", "0.6321459", "0.6317589" ]
0.73059267
17
This method determines whether player of a given color is in a state of check. Args : +current_color+ > string indicating the color of the player in question Returns : True if current_color player is in check False otherwise
def in_check?(current_color) check = [] king = pieces.find_by(type: 'King', color: current_color) opponent_pieces = pieces.where.not(color: current_color) opponent_pieces.each do |opponent_piece| if opponent_piece.type != "King" && opponent_piece.status == 'active' if opponent_piece.valid_move?(king.x_coordinates, king.y_coordinates) check << opponent_piece end # A new valid_move method for king (king_valid_move_for_in_check?) is used in this iteration # in order to prevent executing can_castle?, which would lead # to executing obstructed?, which would throw a runtime error # when checking the path between two opposite kings elsif opponent_piece.type == "King" if opponent_piece.king_valid_move_for_in_check?(king.x_coordinates, king.y_coordinates) check << opponent_piece end end # End opponent_piece valid_move! check end # End opponent_pieces block for determining if game is in_check # If check variable has more than 0 items the game is in check otherwise is not in check if check.count > 0 true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_check?(color)\n color(self.opponent_color(color)).any? do |piece| \n piece.moves.include?(find_king(color).pos)\n end\n end", "def check?(color)\n king(color).in_check?\n end", "def in_check?(color)\n if color == :w\n players_pieces, opposing_pieces = white_pieces, black_pieces\n else\n players_pieces, opposing_pieces = black_pieces, white_pieces\n end\n\n opposing_pieces.each do |piece|\n return true if piece.moves.include?(king_position(players_pieces))\n end\n false\n end", "def in_check?(color)\n opponent_color = :light_red if color == :light_blue\n opponent_color = :light_blue if color == :light_red\n\n opponent_pieces = pieces(opponent_color)\n\n self.rows.each_with_index do |row, i|\n row.each_with_index do |piece, j|\n if piece.is_a?(King) && piece.color == color\n king_pos = piece.pos\n opponent_pieces.each do |piece|\n opponents_piece_moves = piece.moves\n if opponents_piece_moves.include?(king_pos)\n return true\n end\n end\n end\n end\n end\n return false\n end", "def check?(player_color)\n all_pieces = pieces\n current_king = all_pieces.select { |piece| piece.is_a?(King) && piece.color_eql?(player_color) }.first\n enemy_pieces = all_pieces.select { |piece| piece.color_opposite?(player_color) }\n enemy_pieces.any? do |piece|\n piece.valid_moves.include?(current_king.pos)\n end\n end", "def in_check?(color)\n if color == \"white\"\n king = @all_pieces.select { |piece| piece.class == King && piece.color == \"white\"}[0]\n else\n king = @all_pieces.select { |piece| piece.class == King && piece.color == \"black\"}[0]\n end\n #iterate through every existing piece and check its move_list for a king in one of the move positions\n @all_pieces.each do |piece|\n #if piece is not a king and the opposing color\n if piece.class != King && piece.color != color\n return true if piece.move_list.include?(king.pos)\n end\n end\n return false\n end", "def check?(color)\n # Find the position of that player's king.\n king_pos = @board.grid.flatten.find{|square| square.piece.class == King && square.piece.color == color}\n # Find the positions of all of the opponent's pieces.\n current_positions = @board.grid.flatten.select { |square| !square.piece.nil? && square.piece.color != color }\n # Create a move list that contains all possible moves of the current player.\n total_move_list = []\n current_positions.each do |square|\n curr_piece = square.piece\n move_list = curr_piece.list_moves(square)\n total_move_list += move_list\n end\n # Check whether the position of the king is in the total move list.\n return total_move_list.include?(king_pos)\n end", "def in_check?(color)\n enemy_color = color == :white ? :black : :white\n enemy_pieces = @grid.flatten.select { |piece| piece.color == enemy_color }\n enemy_next_avail_moves = []\n enemy_pieces.each { |piece| enemy_next_avail_moves += piece.avail_moves }\n\n my_king = find_king(color)\n enemy_next_avail_moves.include?(my_king)\n end", "def king_in_check?(color)\n king = color == :white ? @white_king : @black_king\n pieces = @data.flatten(1).compact\n pieces.any? do |piece|\n next unless piece.color != king.color\n\n piece.captures.include?(king.location)\n end\n end", "def checkmate?(color)\n in_check?(color) && no_valid_moves?(color)\n end", "def check? color\n pieces = select_all_pieces_of(other_color(color))\n king_position = find_king_position(color)\n\n pieces.any? do |piece|\n piece.possible_moves.any? do |move|\n movement_helper?(piece.position, move, piece.color) && move == king_position\n end\n end\n end", "def check_color?(piece, player)\n piece == player.downcase ? true : false\n end", "def in_check?(color)\n own_king_pos = []\n (0...grid.length).each do |row|\n (0...grid.length).each do |col|\n if grid[row][col].color == :color && grid[row][col].is_a?(King)\n own_king_pos = grid[row][col].pos\n puts \"King is at #{own_king_pos}\"\n break\n end\n end\n end\n opponent_pieces = []\n (0...grid.length).each do |row|\n (0...grid.length).each do |col|\n if color == :white \n if grid[row][col].color == :black\n opponent_pieces << grid[row][col]\n end\n elsif color == :black\n if grid[row][col].color == :white\n opponent_pieces << grid[row][col]\n end\n end\n end\n end\n opponent_pieces.any? { |piece| piece.valid_moves.include?(own_king_pos) }\n end", "def in_check?(color)\n figures.any? do |piece|\n piece.color != color && piece.moves.any? { |pos| self[pos].is_a?(King) }\n end\n end", "def check?(color)\n king_pos = pieces.find do |piece|\n piece.is_a?(King) && piece.color == color\n end.position\n\n pieces.any? do |piece|\n piece.moves.include?(king_pos)\n end\n end", "def in_check?(color)\n end", "def check?(color)\n opposing_pieces = []\n king_piece = nil\n @grid.each do |row|\n row.each do |piece|\n if piece\n king_piece = piece if piece.is_a?(King) && piece.color == color\n opposing_pieces << piece if piece.color != color\n end\n end\n end\n opposing_pieces.each do |piece|\n return true if piece.possible_moves.include?(king_piece.pos)\n end\n @message = nil\n false\n end", "def in_check?(color)\r\n opp_color = color == 'WH' ? 'BL' : 'WH'\r\n our_king = []\r\n opp_color_moves = []\r\n @grid.each_with_index do |row, idx|\r\n row.each_with_index do |ele, idx2|\r\n our_king.concat([idx, idx2]) if ele.color == color && ele.value == :K\r\n opp_color_moves.concat(ele.move_dirs(self)) if ele.color == opp_color\r\n end\r\n end\r\n opp_color_moves.include?(our_king)\r\n end", "def checkmate?(color)\n #if not in check, then can't be in checkmate!\n return false unless in_check?(color)\n color_pieces = @all_pieces.select { |piece| piece.color == color }\n #utilize Enumerable#all? method to determine if all pieces of \"color\"\n # have no more non-check moves. Returns true or false as a result.\n color_pieces.all? do |piece|\n piece.non_check_moves.empty?\n end\n end", "def checkmate?(color)\n return false unless in_check?(color)\n pieces.select { |p| p.color == color }.all? do |piece|\n piece.valid_moves.empty?\n end\n end", "def checkmate?(color)\n our_pieces = pieces(color)\n if in_check?(color) && our_pieces.all?{|piece| piece.valid_moves.empty?}\n return true\n end\n return false\n end", "def checkmate?(color)\n in_check?(color) && figures_by_color(color).all? do |piece|\n piece.valid_moves.empty?\n end\n end", "def check_winner(player, color)\n if check_horiz(color)\n return true\n elsif check_vert\n return true\n elsif check_diag\n return true\n else\n return false\n end \n end", "def checks_opponent_king?(turn_color)\n ally_locs = find_ally_locs(turn_color) \n \n checker_loc = ally_locs.any? { |loc| @current_state[loc[0]][loc[1]].checks_king?(loc) }\n end", "def end_conditions?(color)\n color_pieces = @all_pieces.select { |piece| piece.color == color }\n #keep this line for debugging purposes, prints current color's piece list and move list\n #color_pieces.each { |piece| puts \"#{piece.class}:#{piece.non_check_moves.inspect}\" }\n puts \"CHECK!\" if in_check?(color)\n return false if color_pieces.any? { |piece| !piece.non_check_moves.empty? }\n return checkmate?(color) || stalemate?(color)\n end", "def check?(color, king_location)\n !pieces_checking_king(color, king_location).empty?\n end", "def isCheck(color)\n\t\tpiece_color = (color == \"w\") ? \"white\" : \"black\"\n\t\topponent = (color == \"w\") ? \"b\" : \"w\"\n\n\t\tking = self.pieces.find { |p| p.name == \"king\" && p.color == piece_color }\n\t\treturn nil if king.nil?\n\n\t\t# we want to generate moves for ourselves again to see if any pieces attack the king\n\t\tboard = Board.new\n\t\tboard.game = self.game\n\t\tboard.set self.fen\n\t\tnext_moves = board.moves(opponent)\n\n\t\tnext_moves.each do | m |\n\t\t\tif m.to == king.position\n\t\t\t\treturn king.position\n\t\t\tend\n\t\tend\n\n\t\treturn nil\n\tend", "def start?\n @color == @@colors[:green]\n end", "def checkmate? color\n return false unless check?(color)\n pieces = select_all_pieces_of(color)\n pieces.each do |piece|\n piece.possible_moves.each do |move|\n if movement_helper?(piece.position, move, piece.color)\n test_board = self.deep_dup\n test_board.make_move(piece.position, move)\n return false unless test_board.check?(color)\n end\n end\n end\n true\n end", "def check?(color)\n board.each do |line|\n a = line.find do |p|\n p != ' ' && p.type == 'king' && p.color == color\n end\n @king_position = a.position unless a.nil?\n end\n total_all_possible_moves(other_color(color)).include?(@king_position)\n end", "def checkmate?(color)\n legal_moves(color).empty?\n end", "def green?\n\t\t@color == 'green'\n\tend", "def color_valid\n color == \"blue\" || color == \"green\"\n end", "def check?(color, proposed_manifest = @@piece_locations)\n path, king_loc = [], []\n enemy_color = ([\"black\", \"red\"] - [\"#{color}\"]).first\n\n proposed_manifest.each do |piece, details|\n if details[\"color\"] == enemy_color\n path << possible_moves(piece, proposed_manifest)\n end\n if details[\"color\"] == color && details[\"type\"] == \"king\"\n king_loc = piece\n end\n end\n\n danger_vector = path.flatten.uniq\n king_positions = possible_moves(king_loc, proposed_manifest)\n\n # If the King is in the attackable locations for the opposing player\n if danger_vector.include? king_loc\n # If all the positions the can move to is also attackable by the opposing player\n if (king_positions - danger_vector).length != 0\n # This is flawed. It verified whether the king could move out check\n # There are two other cases: whether a piece can remove the enemy\n # And whether the enemy's attack vector can be blocked\n #@@checkmate = true\n end\n return true\n # Piece not in check\n else\n return false\n end\n end", "def valid_jump?(color)\n player_pieces(color).any?{ |piece| piece.valid_jumps.any? }\n end", "def checkmate?(color)\n total_moves = list_legal_moves(color)\n total_move_list = []\n total_moves.each do |piece, values|\n total_move_list += values[:moves]\n end\n total_move_list == [] && check?(color) ? true : false\n end", "def cause_check(color, check)\n \tcause_check = false\n \t opposite_team_spaces = (color == :white ? team_pieces(:black) : team_pieces(:white))\n \t same_team_king = (color == :white ? king(:white) : king(:black))\n \t opposite_team_spaces.each do |space|\n \t \tmoves = piece_possible_moves(space.piece.color, x = nil, y = nil, space.value, check)\n \t \tif moves.include?(same_team_king.value)\n \t \t\tcause_check = true\n \t \t\tbreak\n \t \tend\n \t end\n \t return cause_check\n end", "def opponent_in_check(attacking_colour)\n attack_pieces = []\n if attacking_colour == \"BLACK\"\n king_under_attack = @W_K\n attack_pieces = @black_pieces\n elsif attacking_colour == \"WHITE\"\n king_under_attack = @B_K\n attack_pieces = @white_pieces\n else\n print \"ERROR\"\n end\n\n attack_pieces.each do |piece|\n moves = allowed_moves(piece)\n moves.select! { |move| move[1] != piece.position[1] } if piece.instance_of?(Pawn)\n if moves&.length.positive? && moves.include?(king_under_attack.position)\n king_under_attack.now_in_check\n return true\n end\n end\n king_under_attack.out_of_check\n false\n end", "def color_valid(color)\n color == \"blue\" || color == \"green\"\n end", "def notify_players\n if board.in_check?(@player.color)\n puts \"#{@player.color} is in Check\"\n end\n end", "def checkmate?(color)\n king = find_king(color)\n return false unless check?(color, king.location)\n\n checking_pieces = pieces_checking_king(color, king.location)\n if checking_pieces.length == 1\n return false if escape_checkmate_by_kill?(color, checking_pieces[0])\n end\n \n moves = all_valid_moves(king.location, king.moves)\n\n moves.all? do |move|\n current_state = Marshal.load(Marshal.dump(@state))\n @state[king.location[0]][king.location[1]] = nil # To test out the\n @state[move[0]][move[1]] = King.new(color, move) # king's move\n\n in_check = check?(color, move)\n @state = current_state # Set state back to actual current state\n\n in_check\n end\n end", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def color_valid(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def check_color\n state = read_state\n return state[:color] != COLOR_OFF\n end", "def valid_player_piece?(color, location)\n return false unless location.all? { |c| c.between?(0,7) }\n potential_piece = @state[location[0]][location[1]]\n potential_piece != nil && potential_piece.color == color\n end", "def WinConditions(color)\n grid do |p|\n next if p != color\n return false unless p\n end\n true\n end", "def in_check?( who = @turn )\n\t\t\tking = find { |(s, pc)| pc and pc.color == who and pc.is_a? King }\n\t\t\tking.last.in_check?\n\t\tend", "def my_turn?(select_pc)\n game = Game.find(select_pc.game_id)\n\n game.player_turn == select_pc.color\n end", "def color_check(piece_at_origin,piece_at_destination)\n\t\tif piece_color(piece_at_origin) == piece_color(piece_at_destination)\n\t\t\tbol = false\n\t\telse\n\t\t\tbol = true\n\t\tend\n\t\tbol\n\tend", "def game_ended_by?(last_color)\n next_color = (last_color == :white) ? :black : :white\n every_move_causes_check?(next_color) || only_kings?\n # add other types of stalemate?\n end", "def color?(color)\n match color,\n on(Black | Grey.(-> v { v < 0.2 }), 'black-ish'),\n on(White | Grey.(-> v { v > 0.8 }), 'white-ish'),\n on(Grey.(-> v { v >= 0.2 }) & Grey.(-> v { v <= 0.8 }), 'grey-ish'),\n on(Pink, \"that's not a color ;)\")\nend", "def black_turn?\n true if @current_team == @teams[:black]\n end", "def check?(from, to, player)\n\t\tpiece = @grid[from[0]][from[1]]\n\t\treturn true if piece.nil?\n\t\treturn true if piece.color != player\n\n\t\tvalid_moves = piece.get_available_moves\n\n\t\treturn true unless valid_moves.include? to \n\n\t\tfalse\n\tend", "def color_valid(color)\n (color == 'blue' || color == 'green') ? true : false\nend", "def legal_from_1?(from, color)\n piece = board[from[0]][from[1]]\n pnm = piece.possible_next_moves(all_occupied_spaces)\n if piece.type == 'pawn'\n legal_from_1_pawn?(color, pnm)\n else\n pnm.length != 0 && !pnm.map { |p| board[p[0]][p[1]] == ' ' ? ' ' : board[p[0]][p[1]].color }.all? { |p| p == color }\n end\n end", "def color_valid1(color)\n if color == \"blue\" || color == \"green\"\n true\n else\n false\n end\nend", "def opponent?(pos, color)\n return false unless in_bounds?(pos)\n return false if self[pos].empty?\n self[pos].color != color\n end", "def color_valid\n color == \"blue\" || color == \"green\"\nend", "def stalemate?(color)\n total_moves = list_legal_moves(color)\n total_move_list = []\n total_moves.each do |piece, values|\n total_move_list += values[:moves]\n end\n total_move_list == [] && !check?(color) ? true : false \n end", "def color_valid(color)\n color == \"blue\" || color == \"green\" ? true : false\nend", "def is_my_piece?(pos, color)\n find_piece(pos).color == color\n end", "def stalemate?(color)\n #if color has no more legal moves and is not in check\n return false if in_check?(color)\n color_pieces = @all_pieces.select { |piece| piece.color == color }\n color_pieces.all? do |piece|\n piece.non_check_moves.empty?\n end\n #conditionals for stalemate by repitition\n board_count = Hash.new(0) #hash to count board states\n #count every board state in history\n #if there's a board state being repeated 3 times, it's a stalemate\n @board_history.each do |state|\n board_count[state] += 1\n end\n #if there's a board state being repeated 3 times, it's a stalemate\n board_count.any? do |state, count|\n count >= 3\n end\n end", "def color_valid(color)\n color == 'blue' || color == 'green' ? true : false\nend", "def is_current_players_turn?(current_player)\n if self.up_next == current_player.username\n true\n else\n false\n end\n end", "def color_valid(color)\n %w[blue green].any? { |c| c == color }\n #color == \"blue\" || color == \"green\"\nend", "def color_valid(color)\n return true if color == \"blue\" || color == \"green\"\nend", "def check_or_checkmate(color)\n\t\tresult = @board.check_or_checkmate(color)\n\t\tif result == 'CHECK' or result == 'CHECKMATE'\n\t\t\tputs \"\"\n\t\t\tputs \"#{result}!\"\n\t\t\tputs \"\"\n\t\tend\n\t\tresult\n\tend", "def can_king_move_to?(color, from, to)\n result = true\n piece = board[from[0]][from[1]]\n if piece.type == 'king'\n result = false if total_all_possible_moves(other_color(color)).include?(to)\n result\n else\n true\n end\n end", "def game_over?\n return false unless @previous_piece\n\n previous_color = @previous_piece.color == :white ? :black : :white\n no_legal_moves_captures?(previous_color)\n end", "def isColor(c)\n if c == \"r\" or c == \"b\" or c == \"g\" or c == \"y\" or c == \"c\" or c == \"m\" then\n return true\n else\n return false\n end\nend", "def color_valid(color)\n\tcolor == \"blue\" || color = \"green\"\nend", "def check_inside_Colors (string)\n Colors.include?(string)\n end", "def inedible?(x,y) # self and another piece share same color\n #p \"#{self.color} #{self.board.grid[x][y].color}\"\n self.color == self.board.grid[x][y].color\n end", "def valid_slide?(color)\n player_pieces(color).any?{ |piece| piece.valid_slides.any? }\n end", "def in_check?(king)\n opposite_pieces = pieces.where(color: !king.color)\n opposite_pieces.each do |piece|\n if piece.valid_move?(king.position_x, king.position_y)\n return true\n else\n return false\n end\n end\n end", "def solved?(color)\n if vertical_win(color) || horizontal_win(color)\n return true\n else\n return false\n end\n end", "def own_piece?(pos)\n return false if @board.piece_at(pos).nil?\n @color == @board.piece_at(pos).color\n end", "def attacked?(attacker_color, coordinate)\n piece_chars = attacker_color == ChessRules::WHITE ? ChessRules::BLACK_PIECES : ChessRules::WHITE_PIECES\n piece_chars.each do |char|\n piece = Piece.from_char(char, coordinate, board_2d)\n piece.moves.each do |move|\n if piece.color == ChessRules::WHITE\n return true if piece.char.downcase == piece_at(move)\n elsif piece.color == ChessRules::BLACK\n return true if piece.char.upcase == piece_at(move)\n end\n end\n end\n\n false\n end", "def color_valid(color)\r\n color == \"blue\" || color == \"green\"\r\nend", "def in_check?(side)\n if side == game_of_piece.resting_color\n possible_moves(offense).each do |move|\n next if king_coords(game_of_piece.resting_color)[0] != move[1] &&\n king_coords(game_of_piece.resting_color)[1] != move[2]\n return true if king_coords(game_of_piece.resting_color)[0] == move[1] &&\n king_coords(game_of_piece.resting_color)[1] == move[2]\n end\n elsif side == game_of_piece.current_color\n possible_moves(defense).each do |move|\n next if king_coords(game_of_piece.current_color)[0] != move[1] &&\n king_coords(game_of_piece.current_color)[1] != move[2]\n return true if king_coords(game_of_piece.current_color)[0] == move[1] &&\n king_coords(game_of_piece.current_color)[1] == move[2]\n end\n end\n false\n end", "def same_color?(other_suit)\n (black? && other_suit.black?) || (red? && other_suit.red?)\n end", "def any_possible_moves?(color, check)\n \tsame_team_spaces = (color == :white ? team_pieces(:white) : team_pieces(:black))\n \tsame_team_spaces.each do |space|\n \t\tmoves = piece_possible_moves(space.piece.color, x = nil, y = nil, space.value, check)\n \t\tnext if moves.nil?\n \t\tmoves.compact!\n \t\tmoves.map! do |move|\n \t\t\tnext if move.all?{|x| x.nil?}\n \t\t\tx, y = move\n \t\t\tif can_move_piece(space.value, x, y, space.piece.color, check)\n \t\t\t\treturn true\n \t\t\tend\n \t\tend\n \tend\n \treturn false\n end", "def color_valid(color)\n color == \"blue\" || color == \"green\"\nend", "def color_valid(color)\n color == \"blue\" || color == \"green\"\nend", "def color_valid(color)\n color == \"blue\" || color == \"green\"\nend", "def color_valid(color)\n color == \"blue\" || color == \"green\"\nend", "def color_valid(color)\n color == \"blue\" || color == \"green\"\nend" ]
[ "0.78071433", "0.7595267", "0.7531067", "0.7488223", "0.74630094", "0.7402951", "0.7336767", "0.7268708", "0.7123894", "0.7112445", "0.70601845", "0.70539224", "0.698104", "0.6957988", "0.6953882", "0.6938994", "0.69024575", "0.6875966", "0.6817531", "0.67552805", "0.6702741", "0.6696128", "0.6656863", "0.66479635", "0.6644432", "0.65959954", "0.6550695", "0.650826", "0.64850926", "0.64785576", "0.64388263", "0.6420026", "0.6410851", "0.6385852", "0.6363903", "0.6340982", "0.63388616", "0.6310295", "0.6301939", "0.6280516", "0.6259667", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62334764", "0.62052983", "0.61902374", "0.61622566", "0.613214", "0.6122926", "0.61126566", "0.61068624", "0.60796946", "0.60617197", "0.60608417", "0.604959", "0.6041461", "0.6039879", "0.60155565", "0.6009645", "0.6001117", "0.5991409", "0.59835106", "0.59766805", "0.5956593", "0.59558606", "0.59513104", "0.5922114", "0.5917603", "0.58989364", "0.5891145", "0.5888135", "0.58749855", "0.585715", "0.58555466", "0.58547837", "0.5848442", "0.58431923", "0.5829711", "0.5827583", "0.58271074", "0.581699", "0.58096766", "0.5805908", "0.57870966", "0.57870966", "0.57870966", "0.57870966", "0.57870966" ]
0.7350124
6
checks if player has won
def move_result(cell, colour) if scanner.found_connected_four?(cell, colour) ConnectFour::Settings::RESULT[:GAME_OVER] else ConnectFour::Settings::RESULT[:CONTINUE] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def won?\n\t\twon = false\n\t\twon = true if (ended? && @guesses > 0)\n\t\twon\n\tend", "def did_player_win\n (@purses[@current_player] != 6)\n end", "def player_won\n\t\tputs \"\\nCongratulations! your have won!\"\n\t\tself.player_record[\"Wins\"] += 1\n\tend", "def won?\n @game.started? && !detectives_won? && detectives_cannot_move?\n end", "def check_if_won\n\t\tif @word_hidden == @answer_word\n\t\t\t@game_over = 1\n\t\tend\n\t\t@game_over\n\tend", "def game_over?\n remaining_players == 1\n end", "def won?\n #won?: If the player has over 100 points, returns true, otherwise returns false\n if total_score > 100\n return true\n else\n return false\n end\n end", "def won?()\r\n\t\twin_game = false\r\n\t\t\r\n\t\tif()\r\n\t\t win_game = true\r\n\t end\r\n\t\t\r\n\t\treturn win_game\r\n\tend", "def game_over?\n alive_players.count == 1\n end", "def won_game?\n @points > @opponent.points + 1 && @points >= 3\n end", "def won_game?\n if @points > @opponent.points + 1 && @points > 3\n @points = 0\n opponent.points = 0\n return true\n end\n end", "def game_over\n remaining_player.count == 1\n end", "def check_winner\n if win_state == CHECK\n if players[0].get_hand_score >= players[1].get_hand_score\n self.win_state = LOSS\n else\n self.win_state = WIN\n end\n end\n\n if win_state == WIN\n self.wins = wins + 1 \n puts \"Good win! You're now at #{wins} wins and #{losses}.\"\n else\n self.losses = losses + 1\n puts \"Better luck next time. You're now at #{wins} wins and #{losses} losses.\"\n end\n end", "def won?\n player_case = false\n if total_score >= 100\n player_case = true\n end\n return player_case\n end", "def player_won?\n if current_guess == secret_word || !have_blanks?\n puts \"Congratulations! You have successfully solved the puzzle!\\n\"\n exit_game?\n return true\n else\n return false\n end\n end", "def win?\n if won_game?\n @games_won += 1\n won_set\n return true\n end\n end", "def won_game(player)\n if player.advantage\n player.win = true\n player.games_won += 1\n won_set(player)\n reset_scores\n elsif player.points > 3 and player.opponent.points < 3\n player.win = true\n player.games_won += 1\n won_set(player)\n reset_scores\n end\n end", "def won?\n end", "def won?\n end", "def player_o_has_won_H?\n if @board[0] == 'O' && @board[1] == 'O' && @board[2] == 'O' || @board[3] == 'O' && @board[4] == 'O' && @board[5] == 'O' || @board[6] == 'O' && @board[7] == 'O' && @board[8] == 'O'\n true\n end\n end", "def won?\n won_checker\n end", "def did_player_win?\n if @players_1_turn\n did_mark_win?(PLAYERS_1_MARK)\n else\n did_mark_win?(PLAYERS_2_MARK)\n end\n end", "def win?\n if @player1.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player2.name} wins!\"\n sleep(1)\n elsif @player2.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player1.name} wins!\"\n sleep(1)\n else\n turn\n end\n end", "def did_player_win?(player)\n\t\twinner_count = self.teams.winner.joins(:positions).where(:positions => {player_id: player.id}).count\n\t\treturn winner_count > 0\n\tend", "def player_won?\n victory = false\n @board.each do |key, value|\n victory = calculate_possible_lines(key).any? do |line|\n \tline.all? do |location|\n next if @board[location] == nil\n @board[location].color == @current_player\n \tend\n end\n return true if victory == true\n end\n false\n end", "def player_win?(n)\n self.wins.each do |win| \n return true if (player_moves(\"#{n}\") & win).count == self.win_length\n end\n return false\n end", "def won?\n if @scores_array.reduce(0, :+) >= WINNING_SCORE \n \t\t\"You win!\"\n \t\treturn true\n \telse\n \"You haven't won yet.\"\n return false \n end\n end", "def record_won_game!\n if @game_points >= 5 && @game_points >= @opponent.game_points + 2\n\n record_won_set!\n end\n end", "def game_over?\n @players.all? {|p| p.last_turn == \"skipped turn\"} || (@letter_bank.empty? && current_player.rack_empty?)\n end", "def set_won?\n if @games_won == 6 && @opponent.games_won < 5\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n if @games_won == 7 && @opponent.games_won < 7\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n end", "def won?\n total_score > 100 ? true : false\n end", "def won?\n win = false\n win = true if total_score >= 100\n return win\n end", "def player_x_has_won_H?\n if @board[0] == 'X' && @board[1] == 'X' && @board[2] == 'X' || @board[3] == 'X' && @board[4] == 'X' && @board[5] == 'X' || @board[6] == 'X' && @board[7] == 'X' && @board[8] == 'X'\n true\n end\n end", "def check_win\n\t\t\tif win\n\t\t\t\tputs \"\\n You win!\" \n\t\t\telse\n\t\t\t\t# shows how many turns remain\n\t\t\t\tputs \"\\n You have #{TURNS - @turns} turns left\"\n\t\t\tend\n\t\tend", "def over?\n self.player.points == self.board.total_points\n end", "def won?\n return total_score > 100 ? true : false\n end", "def game_over?\n if victory?\n @@score[\"Player #{@other_player.mark}\"] += 1\n puts \"\\nBehold the winner - the #{@other_player}!!!\\n\"\n # show_score\n show_score\n true\n elsif @turns == 9\n @@score[:draws] += 1\n puts \"\\nIt's a draw!\\n\"\n # show_score\n show_score\n true\n else\n false\n end\n end", "def someone_won?\n !!winnning_marker\n end", "def game_over?\n self.lost? || self.won?\n end", "def Winner?(player)\r\n end", "def check_win\n if @game_board.return_count == 5 and @timer.return_time >= 0\n @win = true\n end\n if @game_board.return_count < 5 and @timer.return_time == 0\n @lose = true\n end\n end", "def match_won?\n if @sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n if @opponent.sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n end", "def someone_won?(brd)\n !!detect_winner(brd)\n end", "def game_over?\n alive_players = @players.select {|player| player.alive? == true }\n if alive_players.length > 1\n false\n else\n true\n end\n end", "def won?\n player_marker = @players[@current_player_idx].marker\n WINNING_LOCATIONS.each do |winning_triple|\n return true if winning_triple.map { |loc| @board[loc].fill_char == player_marker }.all?\n end\n false\n end", "def gameover?\n full? or not check_winner.nil?\n end", "def game_won?\n if @points == 4\n if @opponent.points < 3\n @games_won += 1\n @points = 0\n @opponent.points = 0\n set_won?\n match_won?\n return 'win'\n elsif @opponent.points == 3\n @points -= 1\n @opponent.points -= 1\n return 'advantage'\n elsif @opponent.points == 4\n @points -= 1\n @opponent.points -= 1\n return 'duece'\n end\n end\n end", "def won\n if (object.result == 1 and object.white == current_user) or (object.result == -1 and object.black == current_user)\n return 1\n elsif object.result == 0\n return 0\n end\n -1\n end", "def game_over?\n return true if victory? || (@turns == 12)\n false\n end", "def over?\n won? || tied?\n end", "def won?\n # Fill this in\n end", "def someoneWin?\n player = nil\n @@winCases.each { |a|\n player = @board[a[0]]\n if (player != \" \") && (@board[a[0]] == @board[a[1]]) && (@board[a[1]] == @board[a[2]])\n (0..2).each { |n| @board[a[n]].upcase! }\n puts \"We have a WINNER! ----> \" + player\n return player\n end\n }\n return false\n end", "def game_over?\n losing_players != nil ? true: false\n end", "def player_win\n @player.won_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end", "def game_over?\n @board.pieces['black'].empty? || @board.pieces['white'].empty? || (@board.moves(HUMAN_PLAYER).empty? && @board.moves(CPU_PLAYER).empty?)\n end", "def over?\n if won? != false && won? != nil || draw? == true\n return true\n else\n return false\n end\n end", "def won_by?(player)\n\t\tcase player\n\t\twhen :hunter\n\t\t\tif players_within_distance?\n\t\t\t\t\"CAPTURE\"\n\t\t\telsif @prey.time_taken > $time_limit\n\t\t\t\t\"TIMEOUT\"\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\twhen :prey\n\t\t\tif players_surrounded?\n\t\t\t\t\"ESCAPE\"\n\t\t\telsif hunter_trapped?\n\t\t\t\t\"ESCAPE\"\n\t\t\telsif @hunter.time_taken > $time_limit\n\t\t\t\t\"TIMEOUT\"\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend\n\tend", "def someone_won_round?\r\n !!winner\r\n end", "def check_win\r\n\t\tif @guess_word == @secret_word \r\n\t\t\t@is_over = true \r\n\t\t\tputs \"Congrats! You won!\"\r\n\t\telse\r\n\t\t\tfalse \r\n\t\tend \r\n\r\n\t\tif @num_guess == 0 \r\n\t\t\t@is_over = true\r\n\t\t\tputs \"No more tries! You have lost.\"\r\n\t\telse \r\n\t\t\tfalse\r\n\t\tend \r\n\tend", "def board_won?\n\t\twon = false\n\t\t\n\t\tWINNING_POSITIONS.each do |positions|\n\t\t\tn = 0\n\t\t\tfor i in 0..8\n\t\t\t n += 1 if (positions[i] == @gameplay_positions[i] && positions[i] != 0)\n\t\t\tend\n\t\t\tif n == 3\n\t\t\t\twon = true\n\t\t\tend\n\t\tend\n\n\t\twon ? true : false\n\tend", "def over?\n if draw? == true or won? != false\n return true\n end\n end", "def game_won\n if @correct_guesses == @word\n puts \"You have guessed the word!\"\n @is_over = true\n elsif @num_of_guesses == @word.length\n puts \"Sorry, you are all out of guesses.\"\n @is_over = true\n else\n false\n end\n end", "def won_set(player)\n if player.games_won >= 6 and player.opponent.games_won < 5\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n elsif player.games_won == 7\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n end\n end", "def check_for_game_over\n if @proposed_code == @secret_code && @player_role_selection == 'breaker'\n puts 'YOU WIN!'\n true\n elsif @proposed_code == @secret_code && @player_role_selection == 'maker'\n puts 'COMPUTER WINS!'\n true\n else\n false\n end\n end", "def game_over?\n if $board.has_value?(\"none\") == false then\n puts \"No more turns available\"\n return true\n else\n return false\n end\n end", "def played?\n winner.present?\n end", "def game_won?\n if diagonal_win?\n true\n elsif horizontal_win?\n true\n elsif vertical_win?\n true\n else\n false\n end\n end", "def over? \n if draw?\n return true\n elsif won?\n return true\n end\n end", "def over?\n if(!!won?)\n return true\n end\n if(draw?)\n return true\n end\n return false\n end", "def o_won?\r\n o = @game_board.each_index.select { |position| @game_board[position] == \"O\" }\r\n get_win(o)\r\n end", "def is_game_over?\n players.count < 2 ||\n @state == 'stop' ||\n @cards_on_table.count >= Deck.num_cards ||\n (players.map{|p| p.num_cards_remaining == Deck.num_cards}.include? true)\n end", "def check_for_winner\n set_game\n if current_user.has_3_or_more_moves?(@game.id) || @other_player.has_3_or_more_moves?(@game.id)\n if current_user.has_3_moves_in_a_row?(@game.id)\n @game.update(winner_id: current_user.id, duration: (Time.now - @game.created_at).to_i)\n @game.update(status: 'Game Over')\n json_response({ message: \"Winner is #{current_user.username}\"})\n elsif @other_player.has_3_moves_in_a_row?(@game.id)\n @game.update(winner_id: @other_player.id, duration: (Time.now - @game.created_at).to_i)\n @game.update(status: 'Game Over')\n json_response({ message: \"Winner is #{@other_player.username}\" })\n else\n head :no_content\n end\n else\n head :no_content\n end\n end", "def win()\n\t return false if (self.score.nil? or self.opponent.score.nil?)\n\t self.score() ? self.score().to_i > self.opponent.score().to_i : false\n\tend", "def won?\n longest_row(@player) >= 5\n end", "def won_match(player)\n if player.sets_won > 1 and player.opponent.sets_won < 1\n player.matches_won += 1\n start_new_match\n end\n end", "def is_game_over?\n @guesses_left == 0 ? true : false\n end", "def game_over?\n (@player1.lives == 0) || (@player2.lives == 0)\n end", "def games_won(player)\n\t\ttiebreak_win = tiebreak && tiebreak.winner_id.eql?(player.id) ? 1 : 0\n\t\tgames.where(winner_id: player.id).count + tiebreak_win\n\tend", "def won?\n board.all_non_mines_cells_revealed?\n end", "def lives_checker\n if (player_1.lives == 0 || player_2.lives == 0)\n self.game_over\n else\n puts \"------NEW ROUND------\"\n self.start_game\n end\n end", "def over?\n if won? || draw? || full?\n true\n end\n end", "def game_over?\n players_found_phrase = @states.select { |s| s.found_phrase }\n if players_found_phrase.size == 1\n @renderer.output \"We have a winner! #{players_found_phrase.first.player.name} found the phrase!\"\n return true \n elsif players_found_phrase.size > 1\n drawn_player_names = players_found_phrase.map { |s| s.player.name }\n @renderer.output \"We have a draw between #{drawn_player_names.join(' and ')}\"\n return true\n else\n dead_players = @states.select { |s| s.incorrect_guesses.count >= Gallows.stages.count - 1 }\n if dead_players.count > 0\n dead_player_names = dead_players.map { |s| s.player.name }\n @renderer.output \"#{dead_player_names.join(' and ')} is dead.\"\n if dead_players.count == @states.count\n @renderer.output \"It's a draw, all players are dead.\"\n else\n surviving_players = @states.select { |s| dead_players.index(s).nil? }\n surviving_player_names = surviving_players.map { |s| s.player.name }\n @renderer.output \"We have a winner! #{surviving_player_names.join(' and ')} survived longer!\"\n end\n return true\n end\n end\n return false\n end", "def over?\n draw? || won?\n end", "def over?\n draw? || won?\n end", "def over?\n \t@game_over = true\n end", "def game_over?\n true\n end", "def over?\r\n won? || draw?\r\n end", "def over?\n won? || full? || draw?\n end", "def winner\n if @board.over?\n check = @board.won?\n if check != false\n player = player1.token == check ? player1 : player2\n puts\n puts \"|***************************************************************|\"\n puts \"Congratualations #{player.name}! You have won this match.\"\n puts \"|***************************************************************|\"\n puts \"Press anykey to continue ...\"\n gets.chomp\n else\n puts \"End game. There's no winner. This is tied game :(\"\n end\n end\n end", "def over?\n if draw? || won?\n return true\n else\n return false\n end\n end", "def game_is_over?\n (won? || draw? || full?) ? true : false\n end", "def over?\n return draw? || won?\n end", "def won_match?\n @sets_won == 3\n end", "def won?\n if @board.last == @board.last.sort && @board.last.length == @towers\n return true\n else\n return false\n end\n end", "def won?\n ::WIN_COMBINATIONS.detect do |combo|\n board.cells[combo[0]] == @board.cells[combo[1]] &&\n board.cells[combo[1]] == @board.cells[combo[2]] &&\n board.taken?(combo[0]+1)\n end\n end", "def game_is_over(board)\n someone_wins(board) || tie(board)\n end", "def won?(state)\n pieces = state[:pieces]\n player = opponent(state[:player])\n # pieces[player].empty?\n king = pieces[player].find { |piece| piece.class == ChessKing }\n !king\n end", "def win_message\n puts \"Player #{@id.to_s} (#{@piece}) wins!\"\n end", "def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end", "def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end", "def won?\n WIN_COMBINATIONS.detect do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] &&\n @board.cells[combo[1]] == @board.cells[combo[2]] &&\n @board.taken?(combo[0]+1)\n end\n end" ]
[ "0.8228703", "0.8102511", "0.8080715", "0.80255324", "0.79851055", "0.7921449", "0.79142725", "0.78820395", "0.7870085", "0.7856672", "0.78104895", "0.77048695", "0.7691547", "0.76798934", "0.7658237", "0.76573634", "0.7622795", "0.76185095", "0.76185095", "0.7614985", "0.76130337", "0.7596831", "0.7593226", "0.75666034", "0.75663954", "0.75552624", "0.7548356", "0.7542803", "0.75358915", "0.75343275", "0.75216925", "0.75166345", "0.75162053", "0.7487595", "0.7484909", "0.7473926", "0.74709314", "0.74644804", "0.74553704", "0.74541694", "0.74453413", "0.7433099", "0.73949975", "0.738679", "0.7381663", "0.7351165", "0.73489267", "0.734282", "0.7308614", "0.73082554", "0.729635", "0.7282649", "0.72818255", "0.7269686", "0.7264344", "0.7251372", "0.72483706", "0.7244711", "0.7230224", "0.72138476", "0.7207281", "0.72069186", "0.72060734", "0.72020304", "0.7183256", "0.7179974", "0.71583086", "0.7155902", "0.7139519", "0.71327484", "0.7128249", "0.7122305", "0.7121824", "0.7113272", "0.71045727", "0.7098809", "0.70987105", "0.7098116", "0.7094513", "0.708957", "0.7086649", "0.7078541", "0.70735836", "0.7072279", "0.70719576", "0.7070226", "0.7069907", "0.7059664", "0.70516014", "0.70511216", "0.7050824", "0.70477694", "0.703336", "0.7027561", "0.70259494", "0.7024701", "0.70101744", "0.70101273", "0.7007738", "0.7007738", "0.7006665" ]
0.0
-1
Set the stream state so that subsequent objects returned by read will be instances of a custom class +cl+. Does not affect consume. Class +cl+ should define cl.from_serialized, plus to_json, to_msgpack, etc. as needed by the underlying serialization library.
def expect cl @expected_class = cl end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readObject\n raise NotImplementedError, <<-STR\n\n \\e[91m\n I'm afraid this might not work.\n > you need access to the original class definitions (and a)\n > Java runtime to load them into) to turn the stream data back\n > something approaching the original objects.\n \\e[0m\n STR\n end", "def initialize(stream)\n\t\t\t\t\t@stream = stream\n\t\t\t\tend", "def initialize(stream, listener)\n @stream = stream\n # this hack fixes REXML version \"2.7.3\"\n if REXML::Version==\"2.7.3\"\n def @stream.read(len=nil)\n len = 100 unless len\n super(len)\n end\n end\n @listener = listener\n @current = nil\n end", "def initialize(structured_reader,&block)\n @reader = structured_reader\n instance_eval( &block ) if block\n end", "def deserialize(message, stream)\n raise NotImplementedError\n end", "def initialize up_stream\n super(up_stream)\n end", "def initialize(stream, listener)\n @stream = stream\n\n # this hack fixes REXML version \"2.7.3\" and \"2.7.4\"\n if REXML::Version==\"2.7.3\" || REXML::Version==\"2.7.4\"\n def @stream.read(len=nil)\n len = 100 unless len\n super(len)\n end\n def @stream.gets(char=nil)\n super(\">\")\n end\n def @stream.readline(char=nil)\n super(\">\")\n end\n def @stream.readlines(char=nil)\n super(\">\")\n end\n end\n\n @listener = listener\n @current = nil\n end", "def clone\n begin\n Marshal.load(Marshal.dump(self))\n rescue\n self.class.new.read(self.to_s)\n end\n end", "def initialize(size=100)\n\t\t\t@buffer = RingBuffer.new size # buffered input stream\n\t\t\treset\n\t\tend", "def deserialize(istream)\n raise BioInterchange::Exceptions::ImplementationReaderError, 'You must implement this method, which reads data from an input stream and returns an object model instance.'\n end", "def serialize(serializer)\n if @state.nil?\n if serializer.is_a?(Chainer::Deserializer)\n # try to initialize the state to retrieve state entries\n @state = {}\n self_copy = self.dup\n # TODO(sonots): pass device from outside\n xm = Chainer::Device.default.xm\n arr = xm::SFloat.new(1)\n self_copy.init_state(Chainer::Variable.new(arr, grad: arr))\n @state.keys.each do |key|\n @state[key] = serializer.(key.to_s, nil)\n end\n end\n else\n @state.each do |key, val|\n @state[key] = serializer.(key.to_s, val)\n end\n end \n end", "def reader!(io_stream)\n return reader_class.new(io_stream, settings.merge(\"logger\" => logger))\n end", "def reader!(io_stream)\n return reader_class.new(io_stream, settings.merge(\"logger\" => logger))\n end", "def initialize(reader)\n @reader = reader\n end", "def initialize(stream, listener)\n @stream = stream\n @listener = listener\n @current = nil\n @node=nil\n end", "def initialize(task, stream)\n super(stream)\n\n begin\n @type = stream.type\n rescue Exception => e\n raise InitializePortError.new( e.message, @name )\n end\n @task = task\n @connections = Set.new\n @current_data = nil\n @tracked = false\n @readers = Array.new\n @last_update = Time.now\n end", "def bind_reader(stream)\n swap_streams(stream, @reader, @writer)\n end", "def initialize(stream, listener)\n @stream = stream\n def @stream.gets\n super(\">\")\n end\n @listener = listener\n end", "def initialize(call, marshal, unmarshal, deadline, started: true,\n metadata_received: false, metadata_to_send: nil)\n fail(TypeError, '!Core::Call') unless call.is_a? Core::Call\n @call = call\n @deadline = deadline\n @marshal = marshal\n @unmarshal = unmarshal\n @metadata_received = metadata_received\n @metadata_sent = started\n @op_notifier = nil\n\n fail(ArgumentError, 'Already sent md') if started && metadata_to_send\n @metadata_to_send = metadata_to_send || {} unless started\n @send_initial_md_mutex = Mutex.new\n\n @output_stream_done = false\n @input_stream_done = false\n @call_finished = false\n @call_finished_mu = Mutex.new\n\n @client_call_executed = false\n @client_call_executed_mu = Mutex.new\n\n # set the peer now so that the accessor can still function\n # after the server closes the call\n @peer = call.peer\n end", "def initialize(log_stream, classes=nil)\n @classes = classes || SKETCH_CLASS_MAP\n @log_stream = log_stream\n end", "def initialize(message, readStream)\n\t super(message)\n\t @line = readStream.respond_to?(:line) ? readStream.line() : -1\n\t @column = readStream.respond_to?(:column) ? readStream.column() :\n\t\t-1\n\t @pos = readStream.respond_to?(:pos) ? readStream.pos() : -1\n\tend", "def stream!\n fail StateError, \"body has already been consumed\" if @streaming == false\n @streaming = true\n end", "def read()\n size_a = @stream.read 2\n size = Common.decode_u16(size_a)\n data = @stream.read size\n\n data = MessagePack.unpack data\n class_ = Common.packet_from_id data[0]\n class_.new *data[1][0]\n end", "def initialize(dbclass, stream)\n # 2nd arg: IO object\n if @stream.kind_of?(BufferedInputStream)\n @stream = stream\n else\n @stream = BufferedInputStream.for_io(stream)\n end\n # default is raw mode\n self.raw = false\n # 1st arg: database class (or file format autodetection)\n if dbclass then\n\tself.dbclass = dbclass\n else\n\tautodetect\n end\n #\n @skip_leader_mode = :firsttime\n @firsttime_flag = true\n end", "def initialize io, blamer=nil\n io = StringIO.new io if String === io\n\n @io = io\n @metadata = []\n @meta_mode = true\n @blamer = blamer || Blaml.default_blamer\n end", "def initialize\n @stream = []\n @stream_callbacks = []\n @level = :info\n STDOUT.sync = true\n STDERR.reopen(STDOUT)\n self.class.create_level_methods\n setup_writer\n end", "def read\n @storage = {}\n scan\n apply_overrides\n\n OpenStruct.new(@storage)\n end", "def initialize options\n self.class.constants.each do |x|\n klass = eval x.to_s\n @reader = klass.new options\n break if @reader\n end\n raise 'Unknown format' unless @reader\n end", "def initialize(stream, locale, encoding = Encoding::UTF_8)\n @stream = stream\n @locale = locale\n @encoding = encoding\n end", "def initialize(wait: false)\n @wait = wait\n @stream_name_cache = {}\n\n super()\n end", "def initialize\n @reader, @writer = IO.pipe\n end", "def current_state=(new_state)\n self[:current_state] = FFILib::ReaderStateQuery.pack_state new_state\n end", "def initialize\n self.consume_all_input = true\n end", "def initialize(stream_like = nil, mode = \"r+\", dir = nil)\n @mode = mode || \"r+\"\n @path = nil\n @dir = nil\n\n if stream_like.nil?\n @stream = StringIO.new(\"\", @mode)\n elsif is_file?(stream_like, dir)\n @path = stream_like\n @dir = dir\n @stream = nil\n elsif stream_like.respond_to?(:read)\n @stream = stream_like\n elsif stream_like.is_a?(String)\n @stream = StringIO.new(stream_like, @mode)\n else\n raise ArgumentError.new(\"IOProxy should wrap a string, io object or file, got #{stream_like.class}\")\n end\n end", "def rehydrate\n Client.new(hostname: hostname, port: port, enabled: enabled, trusted_cas: trusted_cas, logger_name: logger_name, timeout: timeout)\n end", "def read(&block)\n @read_block = block\n end", "def initialize(stream, value = T.unsafe(nil), parent = T.unsafe(nil), reference = T.unsafe(nil)); end", "def read_stream\n str = io.read\n unless(str.empty?)\n buffer << inflator.inflate(str)\n end\n end", "def initialize(iRawReader, iHeader)\n @RawReader, @Header = iRawReader, iHeader\n super()\n end", "def initialize(payload)\n @named_elements = {}\n super\n @type = read_byte\n instantiate!\n end", "def decode_from(stream)\n ::Protobuf::Decoder.decode_each_field(stream) do |tag, bytes|\n set_field_bytes(tag, bytes)\n end\n\n self\n end", "def read!(value = true)\n @read = value\n end", "def initialize stream:, status:, headers: {}, body: ''\n @stream = stream\n @headers = headers\n @body = body\n @status = status\n\n check_accept_encoding\n init_content_length\n end", "def initialize(buffer)\n @buf = ArrayIStream.new(buffer)\n end", "def initialize(ostream)\n super(ostream)\n end", "def build_stream(name:, client: kinesis, **config)\n stream_resource = Smash::CloudPowers::Synapse::Pipe::Stream.build(\n name: name, client: client, **config\n )\n\n self.attr_map(stream_resource.call_name => stream_resource) do |attribute, resource|\n instance_attr_accessor attribute\n resource\n end\n\n stream_resource\n end", "def reader\n @proxy ||= CollectionProxy.new(klass, self)\n end", "def load( stream )\n Marhsal.load( stream )\n end", "def read_stream_block\n StreamBlock.parse(read_payload)\n end", "def initialize(stream=STDOUT)\n @stream = stream\n end", "def initialize(stream=STDOUT)\n @stream = stream\n end", "def initialize(stream=STDOUT)\n @stream = stream\n 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 post_init\n log_debug '[client-cnxn] Post init, new read buffer created'\n @buffer = Protobuf::Rpc::Buffer.new :read\n rescue\n fail(:RPC_ERROR, 'Connection error: %s' % $!.message) unless failed?\n end", "def from_pipe(stream)\n # implement get_records and/or other consuming app stuff\n throw NotImplementedError\n end", "def initialize stream:, headers: {}\n @closed = false\n @stream = stream\n @parser = @stream.stream\n @headers = headers\n @gzip = false\n @deflate = false\n\n check_accept_header\n check_accept_encoding\n init_response\n end", "def initialize(rstream)\n\t\tsuper\n\n\t\t#\n\t\t# Initialize the meterpreter client\n\t\t#\n\t\tself.init_meterpreter(rstream)\n\n\t\t#\n\t\t# Create the console instance\n\t\t#\n\t\tself.console = Rex::Post::Meterpreter::Ui::Console.new(self)\n\tend", "def clone_state(msg)\n\n # Construct a new class\n cls = Class.new() do\n \n # Require the isaac agent and \n # the raw message from isaac\n def initialize(isaac, msg)\n @msg = msg\n @bot = isaac\n end\n\n # Which server is the bot \n # connected to?\n def server\n @bot.server\n end\n\n # Which nick does the bot\n # currently have?\n def nick\n @bot.nick\n end\n\n # Tell the bot to join a channel\n def join(channel)\n @bot.join(channel)\n end\n\n # Is the bot currently connected?\n def connected?\n @bot.connected?\n end\n\n # Say something. \n #\n # Wraps isaac's call with a default value\n # from msg\n def say(msg, recipient = nil)\n recipient ||= @msg.reply_to if @msg\n @bot.msg(recipient, msg)\n end\n\n # Action something\n #\n # Wraps isaac's call with a default value\n # from msg\n def action(msg, recipient)\n recipient ||= @msg.reply_to if @msg\n @bot.action(recipient, msg)\n end\n end\n\n # Return an instance of the new class\n # with defaults from the message\n # and a link back to isaac.\n return cls.new(@bot, msg)\n end", "def initialize(stream, chunk_size = 4096)\n @stream = stream\n @chunk_size = chunk_size\n\n @event_buffer = Fifo.new\n\n @character_buffer = Buffer.new\n\n @characters_cursor = -1\n @characters = nil\n\n @stream_position = -1\n @state = :start_document\n @stack = []\n\n @value_buffer = \"\"\n @unicode = \"\"\n end", "def read(attrs)\n new(attrs).instance_eval do\n @new_record = false\n @dirty = false\n self\n end\n end", "def initialize( * )\n\t\t\tsuper\n\n\t\t\tpayload = self.body.read\n\t\t\tself.body.rewind\n\n\t\t\t@frame = Mongrel2::WebSocket::Frame.new( payload, self.headers.flags )\n\t\tend", "def create_stream\n Stream.new(self)\n end", "def set_streamObj\n @streamObj = @streamObjKlass.find(params[:id])\n end", "def initialize(system)\n @system = system\n #@name = (options[:name] || MASTER_NAME).to_s\n #@ignore = options[:ignore]\n\n @filename = system.state_file\n\n @current = Hash.new{ |h,k| h[k.to_s] = {} }\n @saved = Hash.new{ |h,k| h[k.to_s] = {} }\n\n read\n refresh\n end", "def initialize(enumerable = [])\n @sem = Mutex.new\n @store = Tempfile.new(\"obuf\")\n @store.binmode\n @size = 0\n \n @lens = Obuf::ProtectedLens.new(@store)\n \n # Store everything from the enumerable in self\n enumerable.each { |e| push(e) }\n \n # ...and yield self for any configuration\n yield self if block_given?\n end", "def read\n _read\n end", "def initialize(state); end", "def incoming=(pipe)\n\t\t\t@incoming = MsgpackIoReader.new(pipe)\n\t\tend", "def initialize(\n broker,\n log_msgs,\n count,\n msg_content,\n msg_durable,\n msg_ttl,\n msg_correlation_id,\n msg_reply_to,\n msg_group_id,\n sasl_mechs\n )\n super(broker, log_msgs, sasl_mechs)\n # Save count of messages\n @count = count\n # Save message content\n @msg_content = msg_content\n # Save message durability\n @msg_durable = msg_durable\n # Save message TTL (ms)\n @msg_ttl = msg_ttl\n # Save message correlation ID\n @msg_correlation_id = msg_correlation_id\n # Save reply to address\n @msg_reply_to = msg_reply_to\n # Save message group ID\n @msg_group_id = msg_group_id\n # Number of sent messages\n @sent = 0\n # Number of accepted messages\n @accepted = 0\n end", "def initialize(input)\n @io = if input.respond_to?(:read)\n input\n else\n ::Kernel.open(input, \"rb\")\n end\n\n unless Archive::Tar::Minitar.seekable?(@io, :rewind)\n raise Archive::Tar::Minitar::NonSeekableStream\n end\n\n @tar = Reader.new(@io)\n end", "def set_reader(mode, block)\n @readers[mode] = block\n @supports << mode\n end", "def set_stream target\n if target.respond_to?(:sysseek)\n @io = target\n else\n @io = SysIOWrapper.new(target)\n end\n @name = \"<stream>\"\n end", "def initialize(*io)\n\t if io.last.kind_of?(Typelib::Registry)\n\t\t@registry = io.pop\n\t end\n\n\t @io = io\n @io_size = io.map { |rio| rio.stat.size }\n\t @streams = nil\n\t @block_info = BlockInfo.new\n\t @compress = true\n @data_header_buffer = \"\"\n\t rewind\n if io.empty?\n # When opening existing files, @streams is going to be\n # initialized in #streams. However, if we are creating a new set\n # (i.e. io.empty? == true), we also need to tell the system that\n # there currently are no streams available.\n @streams = Array.new\n else\n read_prologue\n end\n\tend", "def read\n raise NotImplementedError\n end", "def initialize(out_stream, size, initial_message, terminal_message = nil)\n end", "def read( ioin=$ioin )\n super\n self\n end", "def read( ioin=$ioin )\n super\n self\n end", "def read( ioin=$ioin )\n super\n self\n end", "def read( ioin=$ioin )\n super\n self\n end", "def read( ioin=$ioin )\n super\n self\n end", "def read_state\n end", "def initialize stream, value=nil, parent=nil, reference=false\n super(parent)\n @ndata = @pubid = @value = @external = nil\n if stream.kind_of? Array\n @name = stream[1]\n if stream[-1] == '%'\n @reference = true\n stream.pop\n else\n @reference = false\n end\n if stream[2] =~ /SYSTEM|PUBLIC/\n @external = stream[2]\n if @external == 'SYSTEM'\n @ref = stream[3]\n @ndata = stream[4] if stream.size == 5\n else\n @pubid = stream[3]\n @ref = stream[4]\n end\n else\n @value = stream[2]\n end\n else\n @reference = reference\n @external = nil\n @name = stream\n @value = value\n end\n end", "def read_object\n if @read_object\n @read_object\n else\n warn \"No read_object info has been defined for this reader.\"\n end\n end", "def initialize(&block)\n @output = block\n @input = Raw.new\n Frappuccino::Stream.new(@input).\n map {|text| Line.new(text) }.\n select {|line| line.good? }.\n muxdemux(rhymes) {|rhyme, line| rhyme.why_not(line) }.\n partition(2).\n map {|couplets| Stanza.new(couplets) }.\n on_value {|stanza| @output.call(stanza) }\n end", "def new_state\n State.new(self, logger)\n end", "def deserialize(document)\n klass ? klass.new(document[SOURCE]) : document[SOURCE]\n end", "def fat_stream \n @fat_stream ||= create_fat_stream\n end", "def new(*)\n load\n super\n end", "def initialize(io)\n @io = io\n\n # Keep track of the total number of bytes read.\n @total_bytes_out = 0\n\n # Assume that the delegate IO object is already buffered.\n self.fill_size = 0\n end", "def import(stream)\n @scratch.reset!\n @scratch.import(\"original\", stream)\n end", "def input_stream; end", "def initialize_from_io(io)\n return self\n end", "def initialize(type, &block)\n @state = OpenStruct.new(type: type)\n\n self.instance_eval(&block) if block_given?\n end", "def initialize(socket)\n super\n @transaction_status = read_byte\n end", "def initialize(batch_state = {})\n @batch_state = batch_state\n end", "def load\n @content = @reader.read\n if @content.nil?\n return\n end\n @attribute_storage = {}\n attributes = @content.first.class.attributes\n attributes.each do |key, attribute|\n if attribute.options.has_key? :storage\n @attribute_storage[key] = attribute.options[:storage].new\n else\n @attribute_storage[key] = Hash.new\n end\n end\n @content.each do |doc|\n add_doc doc\n end\n end", "def read\n end", "def reopen\n @mutex.synchronize {\n if defined? @io and @io\n flush\n @io.close rescue nil\n end\n @io = @sio = StringIO.new\n @sio.extend IoToS\n @pos = 0\n }\n super\n self\n end", "def persist(input_stream)\n raise \"persist is not implemented\"\n end", "def stream *args, &block\n get(*args) { stream { |io| instance_exec io, &block } }\n end", "def initialize path, mode, fs, &blk\n @fs = fs\n @path = Path.new(path)\n case mode\n when \"r\" then\n raise \"#{@fs.type(path)} is not a readable file - #{path}\" unless @fs.type(path) == \"file\"\n @handle = @fs.hdfs.open(@path).to_io(&blk)\n when \"w\" then\n # Open path for writing\n raise \"Path #{path} is a directory.\" unless (@fs.type(path) == \"file\") || (@fs.type(path) == \"unknown\")\n @handle = @fs.hdfs.create(@path).to_io.to_outputstream\n if block_given?\n yield self\n self.close # muy muy importante\n end\n end\n end" ]
[ "0.5640836", "0.5602324", "0.53613764", "0.5308163", "0.52085227", "0.5202204", "0.51267093", "0.512041", "0.5087234", "0.5081586", "0.50710696", "0.5051462", "0.5051462", "0.50441986", "0.50165546", "0.5009137", "0.5006297", "0.5002696", "0.5002657", "0.49850994", "0.49694344", "0.49666584", "0.4953019", "0.49384788", "0.49144945", "0.48980176", "0.48976848", "0.4860607", "0.48087713", "0.4806065", "0.48014465", "0.47937742", "0.4792833", "0.47742355", "0.47605583", "0.47441897", "0.47387713", "0.47302824", "0.47090685", "0.4707394", "0.4705942", "0.46973732", "0.46902794", "0.46790206", "0.46699494", "0.4668847", "0.46683154", "0.4654882", "0.4638458", "0.46294177", "0.46294177", "0.46294177", "0.46275112", "0.4625257", "0.4624884", "0.462239", "0.46118367", "0.46110576", "0.46099305", "0.46064094", "0.46005732", "0.45993596", "0.4598341", "0.45910704", "0.45787844", "0.45775363", "0.45695567", "0.45681018", "0.45641774", "0.45582953", "0.45519713", "0.45369992", "0.4535528", "0.4502581", "0.45000264", "0.449433", "0.449433", "0.449433", "0.449433", "0.449433", "0.4492614", "0.44915387", "0.4484268", "0.44799054", "0.44793555", "0.4471779", "0.4471251", "0.44655555", "0.44653022", "0.44578144", "0.4455415", "0.44530335", "0.4445105", "0.44394532", "0.44372004", "0.4436991", "0.4430048", "0.4424889", "0.4422224", "0.44206634", "0.44189012" ]
0.0
-1
Turn off the custom class instantiation of expect.
def unexpect; expect nil; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expect_not_to_run(klass, opts = {})\n alias_new_method(klass)\n with = service_parse_with_option(opts)\n\n expect(klass).to_not receive(:new).with(*with)\n end", "def stop_intercepting!\n @original_methods.each do |m|\n class_eval do\n alias_method m, \"intercepted_#{m}\"\n remove_method \"intercepted_#{m}\"\n end\n end\n\n class_eval do\n remove_method :synthesis_expectation\n remove_method :synthesis_expectation=\n end\n end", "def stop_recording!\n method_name = @original_expects\n class_eval do\n alias_method method_name, \"intercepted_#{method_name}\"\n remove_method \"intercepted_#{method_name}\"\n remove_method :get_expectation_method_name\n end\n end", "def class_unmock(*methods)\n return self.class.class_unmock(*methods) if !self.is_a?(Module)\n do_unmock(methods, :instance, self)\n end", "def allow_to_delay_run(klass, opts = {})\n stub_service_delay :allow, :allow_to_run, klass, opts\n end", "def expect_to_delay_run(klass, opts = {})\n stub_service_delay :expect, :expect_to_run, klass, opts\n end", "def wont_be_instance_of(cls, msg=nil)\n InstanceAssay.refute!(self, cls, :message=>msg, :backtrace=>caller)\n end", "def disable_inference!\n @inferring = false\n end", "def __mock_class\n (class << self; self; end).superclass\n end", "def expect_dummy!(*expectations, &block) #:nodoc:\n end", "def wont_be_kind_of(cls, msg=nil)\n KindAssay.refute!(self, cls, :message=>msg, :backtrace=>caller)\n end", "def ignore_unexpected_calls!\n return if @ignoring_unexpected_calls # do it once!\n\n @ignoring_unexpected_calls = true\n\n def self.method_missing(sym, *args)\n super if @expected_calls.has_key?(sym)\n end\n\n def self.respond_to?(sym)\n true\n end\n end", "def expect_to_run(klass, opts = {})\n stub_service_run(:expect, klass, opts)\n end", "def spy_into_instances klass, except: []\n ::Crispy::CrispyInternal::ClassSpy.new klass, except: except\n end", "def ignore!\n @should_ignore = true\n end", "def allow_to_delay_execute(klass, opts = {})\n stub_service_delay :allow, :allow_to_execute, klass, opts\n end", "def initialize_perforce\n self.perforce_ignore = []\n end", "def expect cl\n @expected_class = cl\n end", "def when_negated_expectation(actual)\n expect(result(&actual)).not_to public_send(*expectation_args)\n end", "def expect_to_delay_execute(klass, opts = {})\n stub_service_delay :expect, :expect_to_execute, klass, opts\n end", "def test_Method_InstanceMethods_unbind\n\t\tpass\n\tend", "def hide!\n singleton_class.send(:define_method, :nodoc) { true }\n end", "def stub_new(klass, options = {})\n define_implicit_request :new\n stub_initialize klass, options\n end", "def exclude(*obj)\n Matchy::Expectations::ExcludeExpectation.new(obj, self)\n end", "def ignore_any_dynamic_constants_set\n Object.stubs(:const_set)\n end", "def not\n NotWrapper.new(self)\n end", "def ignore!\n self.ignored = true\n end", "def puke(klass, meth, err)\n case err\n when MiniTest::Skip\n @turn_test.skip!(err)\n turn_reporter.skip(err)\n when MiniTest::Assertion\n @turn_test.fail!(err)\n turn_reporter.fail(err)\n else\n @turn_test.error!(err)\n turn_reporter.error(err)\n end\n super(klass, meth, err)\n end", "def restore\n return self if restored?\n\n # copied from MiniTest::Mock stub()\n subject_class.__send__ :undef_method, @meth\n subject_class.__send__ :alias_method, @meth, new_meth_name\n subject_class.__send__ :undef_method, new_meth_name\n\n # remove self\n self.class.instances.delete instance_key\n\n # satisfy verify\n @count = -1\n\n self\n end", "def remove_class_argument *names, undefine: false\n remove_argument_from *names, scope: class_arguments, undefine: undefine\n end", "def fake(\n class_name = 'Fake',\n super_class: Object,\n namespace: Object,\n avoid_collisions: false,\n &block\n )\n if avoid_collisions && namespace.const_defined?(class_name)\n throw NameError(\n \"constant '#{class_name}' already defined for #{namespace}\"\n )\n end\n\n namespace.const_set(class_name, Class.new(super_class, &block))\n end", "def allow_out_message\n executor.stub_out_message.add_stub\n end", "def ignore; end", "def test_GC_ClassMethods_disable\n\t\tassert_equal(false, GC.disable)\n\t\tassert_equal(true, GC.disable)\n\tend", "def not(assertion)\n NotAssertion.new(assertion)\n end", "def disable!\n swap_out_delegator\n end", "def silence_deprecations; end", "def expect_no_warning(code, options={:expect_warning => false})\n expect_warning(code, options)\n end", "def disable_test_autorun\n toggle_test_autorun false\n end", "def disable()\n fail \"#{self} already disabled\" unless @enabled\n @klasses.each_pair do |k,methods|\n methods.each_pair do |method_sym, (old,blk)|\n bound = old.bind(k)\n k.class_eval {define_method method_sym, &bound.to_proc}\n end\n end\n @enabled = false\n end", "def testAdaptationDefinition\n @quietContext = Context.named(\"quiet\")\n # \"This adaptation definition is known to work from testAdaptationDefinition.\"\n @quietContext.adaptClass(Phone, \"advertise\", Phone.advertiseQuietly)\n \n # \"The following tests plain behaviour adaptation to context.\n # The adaptation completely overrides the original behaviour.\"\n phone = Phone.new\n call = PhoneCall.new \n call.from = \"Bob\"\n phone.receive(call) \n assert(phone.class.advertise == \"ringtone\", \"A phone should play a ringtone by default\")\n \n @quietContext.activate\n assert(phone.class.advertise == \"vibrator\", \"The vibration behavior for quiet environments should be expressed\")#to fix\n \n @quietContext.deactivate\n assert(phone.class.advertise == \"ringtone\", \"The default behaviour should be restored once the quiet context is deactivated\")#to fix\n \n end", "def suppressFor _obj, _args\n \"_obj suppressFor _args;\" \n end", "def unmock(*methods)\n do_unmock(methods)\n end", "def no_extensions\n self.class.base_edge_wrapper.new graph, element\n end", "def not\n Anagram::Matching::NotMatcher.new(self)\n end", "def ignore\n @ignore = true\n end", "def non_aliases\n @non_aliases ||= classes_and_modules.reject { |cm| cm.is_alias_for }\n end", "def ignore\n @ignored = true\n self\n end", "def expect_serial!\n expect(context).to_not receive(:finalize!)\n expect(context).to_not receive(:begin_fiber)\n expect(context).to_not receive(:dispatch)\n expect(context).to_not receive(:proxy)\n end", "def using_model(class_name)\n class_name = class_name.name if Class === class_name\n @expected_options[:class_name] = class_name\n self\n end", "def initialize(obj, mock, safe_mode)\n @obj = obj\n @mock = mock\n @method_definitions = {}\n @methods_proxied = []\n unless safe_mode\n add_mock_method(:should_receive)\n MOCK_METHODS.each do |sym|\n unless @obj.respond_to?(sym)\n add_mock_method(sym)\n end\n end\n end\n end", "def inherited(base)\n base.define_method teardown do \n super\n end\n end", "def inherited(base)\n base.define_method teardown do \n super\n end\n end", "def inherited(base)\n base.define_method teardown do \n super\n end\n end", "def inherited(base)\n base.define_method teardown do \n super\n end\n end", "def skip_start\n trait[:started] = true\n end", "def extends!(spec)\r\n @extended_spec.clear.push(spec)\r\n end", "def unstub_object(stub)\n singleton_class = stub.object.singleton_class\n singleton_class.silence_redefinition_of_method stub.method_name\n singleton_class.alias_method stub.method_name, stub.original_method\n singleton_class.undef_method stub.original_method\n end", "def patch_class!(klass)\n klass.class_eval do\n #\n # Make the check status accessible as a reader method.\n #\n attr_reader :status\n\n #\n # Patch the output method so it returns the output string instead of\n # sending it to stdout.\n #\n def output(msg = @message)\n @output ||= self.class.check_name + (msg ? \": #{msg}\" : '')\n end\n end\n end", "def inherited(base)\n base.define_method teardown do\n super\n end\n end", "def inherited(base)\n base.define_method teardown do\n super\n end\n end", "def spy_into_instances klass, stubs_map = {}\n ::Crispy::CrispyInternal::ClassSpy.new klass, stubs_map\n end", "def silence_missing_strategies!\n self[:silence_missing_strategies] = true\n end", "def initialize(klass, stub_params = {})\n @klass = klass\n @stub_params = stub_params\n end", "def __mock_reset; end", "def allow_message_expectations_on_nil\n Proxy.allow_message_expectations_on_nil\n end", "def allow_message_expectations_on_nil\n Proxy.allow_message_expectations_on_nil\n end", "def init_without_node(props) # :nodoc:\n props[:_classname] = self.class.to_s\n @_new_props = props\n @persisted = false\n end", "def remove_class(names = T.unsafe(nil)); end", "def ignore_me\nend", "def refute_instance_of(cls, obj, msg=nil)\n InstanceAssay.refute!(obj, cls, :message=>msg, :backtrace=>caller)\n end", "def override(opts)\n new(global, opts)\n end", "def silence_missing_strategies!\n @config[:silence_missing_strategies] = true\n end", "def initialize(target_class:, ignore_nil: false)\n @target_class = target_class\n @ignore_nil = ignore_nil\n super()\n end", "def disable_finger_simu_th(cmd_proc, delay)\n $test_logger.result_log \"Disable finger simulation after #{delay} seconds...\"\n\n sleep(delay)\n\n cmd_proc.set_simu_finger(false)\n end", "def setup_shadow(klass)\n @shadow = klass.new(:resource => self.resource)\n end", "def setup\n flexmock(Woofer).new_instances.should_receive(:woof => :grrr)\n end", "def without_typecast\n dup.without_typecast!\n end", "def _\n return Deassert.new\nend", "def assume_silence\n GitReview.any_instance.stub(:puts)\nend", "def not_matcher(matcher)\n NotMatcher.new(matcher)\n end", "def ignore\n @ignore = true\n end", "def strict_order_mocks(*mocks)\n include Hardmock\n create_mocks *mocks\nend", "def ignore(*args); end", "def off!\n Net::HTTP.class_eval do\n private\n\n undef connect\n\n def connect\n # we're off in 1.9 that means verify_mode = OpenSSL::SSL::VERIFY_NONE\n self.verify_mode = OpenSSL::SSL::VERIFY_NONE if self.respond_to?(:verify_mode)\n default_connect\n end\n end\n end", "def test_to_normal(name, klassname=nil)\n unmunge(name.to_s.sub(/^test_/, '')) do |n|\n if defined? @inherited_methods then\n known_methods = (@inherited_methods[klassname] || {}).keys.sort.reverse\n known_methods_re = known_methods.map {|s| Regexp.escape(s) }.join(\"|\")\n n = n.sub(/^(#{known_methods_re})(_.*)?$/) { $1 } unless\n known_methods_re.empty?\n n\n end\n end\n end", "def setup(klass, *methods)\n \n end", "def unadapt(klass, method)\n self.pop_adapt(klass, method, self)\n self.dynamic_adapt(false)\n end", "def not_a_member_hops\n $tracer.trace(__method__)\n #unit_test_no_generate: not_a_member_hops, a.className(create_ats_regex_string(\"ats-nonmember\"))\n return ToolTag.new(a.className(create_ats_regex_string(\"ats-nonmember\")), __method__, self)\n end", "def no(*args)\n _define_check_method(args, caller, true)\n end", "def ignores; end", "def internal_create_override(method_name, mode=:instance, &block)\n builder = ExpectationBuilder.new method_name\n block.call builder unless block.nil?\n exp = builder.build\n exp.events = events[mode] \n expectations.add_expectation exp, mode\n exp\n end", "def rspec_mocks_method\n prefix = @count.nil? ? 'allow' : 'expect'\n suffix = @any_instance ? '_any_instance_of' : ''\n (prefix + suffix).to_sym\n end", "def remove_class_variable(sym) end", "def test_skip\n\n etl = Class.new(MomoEtl::Base){ include SampleEtl }.new\n etl.run(rowset: @sample_rows)\n\n execution_list = etl.el\n assert !execution_list.include?(:transform_1) &&\n !execution_list.include?(:transform_2)\n end", "def unoverride_class_method(klass, meth)\n saved_meth_name = get_saved_method_name(meth)\n\n eval \"method_kind = nil; class << #{klass}\n case\n when public_method_defined?(#{meth.to_sym.inspect})\n method_kind = :public\n when protected_method_defined?(original)\n method_kind = :protected\n when private_method_defined?(#{meth.to_sym.inspect})\n method_kind = :private\n end\n alias_method #{meth.to_sym.inspect}, #{saved_meth_name.to_sym.inspect}\n send(method_kind, #{meth.to_sym.inspect})\n end \"\n end", "def expects name\n # any_instance\n if @meth\n return self.class.\n new(@subject, @any_instance).\n expects(name)\n end\n\n @meth = name.to_sym\n\n if expecter = self.class.instances[instance_key]\n return expecter\n end\n\n # woh! is this hacky? Call allocate to get around not knowing how to call\n # new().\n sub = if @any_instance and @subject.is_a?(Class)\n @subject.allocate\n else\n @subject\n end\n\n # handle meta methods.\n # copied from MiniTest::Mock stub()\n if sub.respond_to? name and\n not sub.methods.map(&:to_s).include? name.to_s then\n subject_class.__send__ :define_method, name do |*args|\n super(*args)\n end\n end\n\n subject_class.__send__ :alias_method, new_meth_name, @meth\n\n expecter = self\n subject_class.__send__ :define_method, name do |*args, &block|\n expecter.match?(self, args, &block)\n end\n\n self.class.instances[instance_key] = self\n\n self\n end", "def unproxy!(load = true)\n metaclass = class << self; self; end\n metaclass.send(:remove_method, :_dump)\n metaclass.send(:remove_method, :inspect)\n metaclass.send(:alias_method, :_dump, :proxied_dump)\n metaclass.send(:alias_method, :inspect, :proxied_inspect)\n \n self.class.proxied_attributes.each do |a|\n metaclass.send(:remove_method, \"#{a}\".to_sym)\n metaclass.send(:remove_method, \"#{a}=\".to_sym)\n metaclass.send(:alias_method, \"#{a}\".to_sym, \"proxied_#{a}\".to_sym)\n metaclass.send(:alias_method, \"#{a}=\".to_sym, \"proxied_#{a}=\".to_sym)\n end\n \n # perform the actual load\n proxied_load if load\n end", "def initialize(obj, mock, safe_mode)\n @obj = obj\n @mock = mock\n @method_definitions = {}\n @methods_proxied = []\n unless safe_mode\n add_mock_method(@obj, :should_receive)\n MOCK_METHODS.each do |sym|\n unless @obj.respond_to?(sym)\n add_mock_method(@obj, sym)\n end\n end\n end\n end", "def wont_throw(sym, msg=nil)\n ThrowAssay.refute!(sym, :message=>msg, :backtrace=>caller, &self)\n end" ]
[ "0.6818073", "0.5891079", "0.56467915", "0.5586717", "0.55387676", "0.5531847", "0.55314183", "0.550299", "0.5476142", "0.54648376", "0.5442587", "0.54334366", "0.5420293", "0.5341416", "0.5319934", "0.53072584", "0.5306787", "0.5270262", "0.5268583", "0.52645606", "0.52533", "0.51938224", "0.5172968", "0.5151515", "0.5140142", "0.5041841", "0.5030251", "0.50276923", "0.5022207", "0.4979896", "0.49284068", "0.49236026", "0.49224433", "0.4895479", "0.48842692", "0.4881273", "0.48683926", "0.48664168", "0.48245892", "0.48226538", "0.48152637", "0.48106974", "0.48041388", "0.48007625", "0.47936857", "0.47842783", "0.47838163", "0.47825965", "0.4780661", "0.477998", "0.47643116", "0.47603896", "0.47603896", "0.47603896", "0.47603896", "0.4758721", "0.475437", "0.47442526", "0.47372115", "0.47355303", "0.47355303", "0.4735017", "0.47257957", "0.47226235", "0.4715402", "0.47153103", "0.47153103", "0.47039685", "0.4697981", "0.46901834", "0.46890494", "0.46684057", "0.46679977", "0.4665463", "0.46653587", "0.4660909", "0.4651162", "0.46467972", "0.46416306", "0.4639449", "0.46352708", "0.4630436", "0.46283925", "0.46260715", "0.46238872", "0.4618754", "0.46177092", "0.46158358", "0.46151736", "0.46134433", "0.46130842", "0.46100098", "0.46072394", "0.46055076", "0.46047753", "0.45955494", "0.45950797", "0.45918953", "0.45836118", "0.4578287" ]
0.51828474
22
The block is appended to a queue of procs that are called for the subsequently read objects, instead of iterating over or returning them. Helps with handshake protocols. Not affected by expect.
def consume &bl @consumers << bl end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blocks() end", "def blocks; end", "def blocks; end", "def blocks; end", "def read\n while msg = consumer.pop\n begin\n data = JSON.parse msg.body\n yield data[0], data[1]\n rescue => error\n Lux::Error.split_backtrace error\n end\n\n msg.finish\n end\n end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def connect(&block) \n EM.run do\n http = connection.get\n buffer = \"\"\n http.stream do |chunk|\n buffer << chunk\n while line = buffer.slice!(/.+\\r\\n/)\n hash= MultiJson.decode(line, :symbolize_keys => true)\n block.call(hash)\n end\n end\n http.errback do\n EM.stop\n end\n end\n end", "def read_all(&block); end", "def on_block(blk)\n log.debug { \">> block: #{blk.hash} (#{blk.payload.size} bytes)\" }\n @node.queue.push([:block, blk])\n end", "def consume_all\n end", "def consume_all\n end", "def run(&blk)\n consumer.each{|i| item_received(message_to_item(i), &blk)}\n end", "def handle_getblocks\n @node.connections.sample.send_getblocks\n {:state => \"Sending getblocks...\"}\n end", "def consume\n end", "def remote_each\n if(@store)\n yield @store\n else\n @con.request_get(@call_path) do |res|\n res.read_body(@store) do |part|\n @cf.write part if @cf\n yield part\n end\n end\n end\n end", "def each(&block)\n return to_enum(__method__) unless block\n\n @receivers << block\n block.call io.string.dup unless io.string.empty?\n sync\n\n self\n end", "def consume\n \n end", "def process(&block); end", "def read(&block)\n @read_block = block\n end", "def each_registered_block(type, &block); end", "def captured_by_block; end", "def consume; end", "def consume; end", "def consume; end", "def each_item\n return enum_for(:each_item) unless block_given?\n begin\n notice 'start!'\n @receive.each do |payload|\n notice payload\n case\n when payload.has_start?\n receive_start(payload.start)\n when payload.has_response?\n receive_response(payload.response)\n when payload.has_resolve?\n receive_resolve(payload.resolve)\n end\n yield send_queue.pop\n end\n notice 'filter end normally.'\n rescue StandardError => e\n error e\n fail e # signal completion via an error\n ensure\n warn 'filter end!'\n end\n end", "def each(&block)\n @queues.each(&block)\n end", "def each(&block)\n # If the buffer is closed, there's no reason to block the listening\n # thread, yield all the buffered chunks and return.\n queue = Queue.new\n @mutex.synchronize do\n return @previous.each(&block) if closed?\n @listeners << queue\n end\n\n # race condition: possibly duplicate messages when message comes in between adding listener and this\n @previous.each(&block)\n\n while chunk = queue.pop\n yield chunk\n end\n ensure\n @mutex.synchronize { @listeners.delete(queue) }\n end", "def each(&blk)\n @body_callback = blk\n schedule_dequeue\n end", "def each_channel(&block); end", "def each\n while message = read_message\n yield message\n end\n end", "def receive_block(&block)\n block.call # same as yield\nend", "def receive\n if block_given?\n obj, args = @adapter.pop\n yield QueueObject.new(obj, args) if obj\n else\n raise 'No block given'\n end\n end", "def run\n drain! if forked?\n clnt = pop\n yield clnt\n ensure\n push(clnt)\n end", "def callBlock\n yield\n yield\nend", "def process_queue\n puts \"Waiting for new messages\"\n th = Thread.new do\n Thread.current.abort_on_exception = true\n loop do\n # This will sit around and wait forever.\n key, raw_msg = @redis_client.blpop(@redis_in_key, 0)\n json_msg = Crack::JSON.parse(raw_msg)\n # Send back a random quote\n random_quote = @quotes[rand(@quotes.size)]\n out_msg = {:from => json_msg['from'], :body => random_quote}.to_json\n # Pusing onto the \"out\" list queues up something for the listener to process\n @redis_client.lpush(@redis_out_key, out_msg)\n end\n end \n end", "def process_blocks(blocks); end", "def read_blocked\n end", "def call_block\n\tputs \"Start of method\"\n\tyield\n\tyield\n\tputs \"End of method\"\nend", "def test_Queue\n queue_alpha = Queue.new('Alpha')\n queue_beta = Queue.new('Beta')\n proc_observer = Proc.new do |queue, operation, item|\n puts \"Proc object observing operation '#{ operation }'\" \\\n \" on queue '#{ queue.name }' with item #{ item }.\"\n end\n queue_alpha.add_observer do |queue, operation, item|\n puts \"Block observing operation '#{ operation }'\" \\\n \" on queue '#{ queue.name }' with item #{ item }.\"\n end\n queue_alpha.add_observer(&proc_observer)\n queue_alpha.add_observer { puts \"Just a casual block observer.\" }\n queue_beta.add_observer(&proc_observer)\n assert_same queue_alpha, queue_alpha.insert(1).insert(2).insert(3)\n assert_same queue_beta, queue_beta.insert(3).insert(4)\n assert_equal 1, queue_alpha.remove\n assert_equal 2, queue_alpha.remove\n assert_equal 3, queue_beta.remove\n assert_equal 4, queue_beta.remove\n assert_equal \\\n \"Block observing operation 'insert' on queue 'Alpha' with item 1.\\n\" \\\n \"Proc object observing operation 'insert' on queue 'Alpha' with item 1.\\n\" \\\n \"Just a casual block observer.\\n\" \\\n \"Block observing operation 'insert' on queue 'Alpha' with item 2.\\n\" \\\n \"Proc object observing operation 'insert' on queue 'Alpha' with item 2.\\n\" \\\n \"Just a casual block observer.\\n\" \\\n \"Block observing operation 'insert' on queue 'Alpha' with item 3.\\n\" \\\n \"Proc object observing operation 'insert' on queue 'Alpha' with item 3.\\n\" \\\n \"Just a casual block observer.\\n\" \\\n \"Proc object observing operation 'insert' on queue 'Beta' with item 3.\\n\" \\\n \"Proc object observing operation 'insert' on queue 'Beta' with item 4.\\n\" \\\n \"Block observing operation 'remove' on queue 'Alpha' with item 1.\\n\" \\\n \"Proc object observing operation 'remove' on queue 'Alpha' with item 1.\\n\" \\\n \"Just a casual block observer.\\n\" \\\n \"Block observing operation 'remove' on queue 'Alpha' with item 2.\\n\" \\\n \"Proc object observing operation 'remove' on queue 'Alpha' with item 2.\\n\" \\\n \"Just a casual block observer.\\n\" \\\n \"Proc object observing operation 'remove' on queue 'Beta' with item 3.\\n\" \\\n \"Proc object observing operation 'remove' on queue 'Beta' with item 4.\\n\", \\\n @out.string\n end", "def run(&block)\n end", "def each(&block)\n call_client(:each, &block)\n end", "def accept_nonblock\r\n end", "def block_eg\n puts \"this is the first message\"\n yield\n puts \"this is the middle message\"\n yield\n puts \"this is the last\\n\\n\"\nend", "def producer; end", "def consume(params, &block)\n raise \"Missing mandatory code block\" unless block\n c = self.create_consumer_from_params(params)\n begin\n c.each(params, &block)\n ensure\n c.close\n end\n end", "def get_want_blocks\n return if (@want_blocks.length >= MIN_REQUESTS) || @peer_virgin || @peer_choking || !@interested\n\n rej_count = 0\n acc_count = 0\n @controller.claim_blocks do |b|\n break if @want_blocks.length >= MAX_REQUESTS\n if @peer_pieces[b.pindex] && !@want_blocks.member?(b)\n rt_debug \"! #{self}: starting new piece #{@package.pieces[b.pindex]}\" unless @package.pieces[b.pindex].started?\n\n# rt_debug \"#{self}: added to queue block #{b}\"\n# puts \"#{self}: claimed block #{b}\"\n @want_blocks.push b\n acc_count += 1\n true\n else\n# puts \"#{self}: cont offers block #{b} but peer has? #{@peer_pieces[b.pindex]} i already want? #{@want_blocks.member? b}\" if rej_count < 10\n rej_count += 1\n false\n end\n end\n # puts \"#{self}: ... and #{rej_count} more (peer has #{@peer_pieces.inject(0) { |s, p| s + (p ? 1 : 0) }} pieces)... \" if rej_count >= 10\n# puts \"#{self}: accepted #{acc_count} blocks, rejected #{rej_count} blocks\"\n end", "def captured_by_block?; end", "def consume(&block)\n block = Proc.new{} unless block_given?\n consumer.consume(&block)\n end", "def each(&block)\n @data.each { |pelem|\n block.call self.factory(@session, pelem)\n }\n end", "def block_node; end", "def block_node; end", "def run(&block); end", "def run\n\t\t\t\tbegin\n\t\t\t\t\twhile true\n\t\t\t\t\t\tcommand = read_object\n\t\t\t\t\t\t\n\t\t\t\t\t\tresult = yield command\n\t\t\t\t\t\t\n\t\t\t\t\t\twrite_object(result)\n\t\t\t\t\tend\n\t\t\t\trescue EOFError\n\t\t\t\t\t# Finish...\n\t\t\t\tend\n\t\t\tend", "def listen(&block)\n AMQP.start(:host => @host) do\n exchange = MQ.direct(@x_request)\n reply = MQ.direct(@x_response)\n queue = MQ.queue(@server_q)\n notify = MQ.fanout(@x_notify)\n \n puts \"request xchange =#{@x_request}\"\n puts \"reply xchange =#{@x_response}\"\n puts \"server queue =#{@server_q}\"\n \n @do_notify = proc do |msg|\n notify.publish(Blix.to_binary_data(msg))\n puts \"[AmqpServer] notify: message=#{msg}\" if $DEBUG\n end\n \n queue.bind( exchange).subscribe do |header,body|\n \n # extract the headers and create a transport for this\n # client. the reply_to field may be in the application\n # headers field so check for it there also.\n \n reply_to = header.reply_to || ( header.headers && header.headers[:reply_to])\n message_id = header.message_id || ( header.headers && header.headers[:message_id])\n \n if reply_to && message_id\n # process the call\n response = block && block.call(body)\n \n # publish the reply only if there is a response\n \n if response\n options = {}\n options[:key] = reply_to\n options[:message_id] = message_id\n data = Blix.to_binary_data(response)\n \n puts \"[AmqpServer] response: data=#{data}, options=#{options}\" if $DEBUG\n \n reply.publish(data, options )\n end\n else\n puts \"missing reply-to /message_id field .....#{header.inspect}\"\n end\n end\n \n# # send any notifications that are waiting.\n# while !@notify_queue.empty?\n# message = @notify_queue.pop\n# channel.fanout(@x_notify).publish(Blix.to_binary_data(message))\n# puts \"[AmqpServer] notify: message=#{msg}\" if $DEBUG\n# end\n end\n \n end", "def spawn(&block)\n if fiber = @fibers.shift\n fiber[:callbacks] = []\n @busy_fibers[fiber.object_id] = fiber\n fiber.resume(block)\n else\n @queue << block\n end\n self # we are keen on hiding our queue\n end", "def loop( &block )\n block ||= proc do \n channels = @channel_map.reject {|k,v| v.type == 'auth-agent@openssh.com' }\n not channels.empty?\n end\n process while block.call\n end", "def record_block\n @block = true\n end", "def on_enqueued\n @flow_lock.synchronize do\n return if @on_enqueued_invoked\n\n @on_enqueued_invoked = true\n\n yield(@first_message, @last_message)\n end\n end", "def listen(&block)\n while @_run do\n request = @responder.recv #(ZMQ::NOBLOCK)\n if request\n response = block && block.call(request)\n @responder.send( response )\n end\n end\n end", "def blocklisted_responder; end", "def accept_nonblock(*) end", "def accept_nonblock(*) end", "def accept_nonblock(*) end", "def test\r\n puts \"Enter in methods\"\r\n p = Proc.new {p \"Entering block\"; return }\r\n p.call\r\n p \"Existing methods\"\r\nend", "def each(&block)\n retractions.each &block\n end", "def request_loop\n @request_queue.receive_messages.each do |msg|\n yield(get_request(msg))\n end\n end", "def on_each_response( &block )\n fail 'Block is mandatory!' if !block_given?\n @on_each_response_blocks << block\n self\n end", "def consume(&block)\n @queue.consume(&block)\n end", "def test_blocks_legacy\n hash_ = ::Hash.new\n block_ = ::Proc.new do\n set_value(:a){ 1 }\n end\n ::Blockenspiel.invoke(block_) do\n add_method(:set_value, :receive_block => true) do |key_, bl_|\n hash_[key_] = bl_.call\n end\n end\n assert_equal(1, hash_[:a])\n end", "def consume(&block)\n q_item = @client.reserve( @name )\n return nil unless valid(q_item)\n q_message = ::Qup::Message.new( q_item.object_id, unmarshal_if_marshalled( q_item ))\n @open_messages[q_message.key] = q_item\n if block_given? then\n yield_message( q_message, &block )\n end\n return q_message\n end", "def multi(&block); end", "def each(&block)\n Fetcher.new(self).each(&block)\n end", "def reconsume; end", "def initialize\n @block_args = []\n end", "def block_eg1(cutblock)\n puts \"this is the first message from 1 \"\n cutblock.call\n puts \"this is the middle message\"\n cutblock.call\n puts \"this is the last\\n\\n\"\nend", "def block?; end", "def on_connected(&block)\n @on_connected_procs << block\n end", "def wait_for_pending_sends; end", "def command_queue; end", "def block_call\n expect :iter\n self[1]\n end", "def each # :nodoc:\n begin\n time, all = @rdmon.wait_snapshot\n stats = all[@addr] or next\n stats.queued >= @queued_min or next\n stats.active >= @active_min or next\n body = sprintf(@fmt, time.iso8601, @addr, stats.active, stats.queued)\n body = \"#{body.size.to_s(16)}\\r\\n#{body}\\r\\n\" if @chunk\n yield body\n end while true\n yield \"0\\r\\n\\r\\n\" if @chunk\n end" ]
[ "0.66375494", "0.6361939", "0.6361939", "0.6361939", "0.62731177", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.6008602", "0.59964734", "0.5973035", "0.5923981", "0.5923981", "0.5875344", "0.5820708", "0.58016855", "0.5775128", "0.57734686", "0.5768285", "0.5753151", "0.5741185", "0.5729089", "0.5713569", "0.57082015", "0.57082015", "0.57082015", "0.5688231", "0.5674483", "0.56637865", "0.5661509", "0.56508166", "0.5624471", "0.56024027", "0.55562085", "0.5544966", "0.55167615", "0.5513882", "0.550929", "0.5506391", "0.55038846", "0.5503428", "0.550062", "0.5495018", "0.5490931", "0.5488445", "0.54765475", "0.5471113", "0.5461813", "0.54615235", "0.5460438", "0.5458203", "0.5456573", "0.5456573", "0.5454738", "0.54395354", "0.54267305", "0.5422097", "0.5418798", "0.5412195", "0.54101163", "0.54064584", "0.54061216", "0.5401358", "0.5401358", "0.5401358", "0.5397137", "0.5396165", "0.53913677", "0.5382154", "0.53769267", "0.53699577", "0.53657687", "0.5365052", "0.53627545", "0.53609216", "0.53597724", "0.5359638", "0.53568316", "0.5350919", "0.53492266", "0.53376245", "0.5335086", "0.53322893" ]
0.57603
36
A user cannot leave more than one review per product.
def must_not_be_a_duplicate_review dup_reviews = Review.where(user: user, product: product) if new_record? if dup_reviews.length > 0 errors.add(:product, "already has a review from this user.") end elsif dup_reviews.length > 0 && !dup_reviews.include?(self) errors.add(:product, "already has a review from this user.") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prevent_multiple_feedback_reviews\n @feedback_review = @review.feedback_reviews.find_by(user_id: @current_api_user)\n if @feedback_review.present?\n invalid_resource!(@feedback_review)\n end\n end", "def user_already_reviewed(movie)\n \t@user_already_reviewed = -1\n \tif user_signed_in? \n\n\t reviewFound = movie.reviews.where('user_id' => current_user.id).first\n\t if reviewFound && reviewFound.status == true\n\t @user_already_reviewed = 0\n\t elsif reviewFound && reviewFound.status == false\n\t @user_already_reviewed = 1\n\t elsif movie.user_id == current_user.id\n\t @user_already_reviewed = 2\n\t end\n\tend\n \treturn @user_already_reviewed\nend", "def fields_user_id_and_reviewer_id_are_different\n if self.user_id == self.reviewer_id\n errors.add(\"You cannot give yourself a review\")\n end\n end", "def can_revoke_review_request\n if rule.review_requestor_id.nil?\n errors.add(:base, 'Control is not currently under review')\n elsif !(user.id == rule.review_requestor_id || project_permissions == 'admin')\n errors.add(:base, 'Only the requestor or an admin can revoke a review request')\n end\n end", "def hasReviewed(u, e)\n return Event.find_by(id: e).reviews.find_by(user_id: u) != nil\n end", "def mark_products_with_reviews\r\n Product.all.each do |product|\r\n product.with_reviews = \"y\" unless AliReview.where(productId: product.productId)[0].nil?\r\n product.save if product.with_reviews == \"Y\"\r\n end\r\n end", "def reviewed?\n review_count = Review.where(user: user, essay: assignment.essays).count\n total_count = assignment.user_assignments.count\n total_count - review_count - 1 <= 0\n end", "def hasNotReviewed(id)\n email_address = current_user.email\n reviews = Review.where(user_email: email_address)\n\n if logged_in?\n reviews.each do |rv|\n if rv.user_id == id\n return false\n end\n end\n else\n return false\n end\n return true\n end", "def reviews_as_owner\n Review.where(:product_id => product_ids)\n end", "def before_destroy(review)\n # rating\n review.user.score -= review.rating? ? 1 : 0;\n\n # review\n review.user.score -= review.review? ? 5 : 0;\n\n # save\n review.user.save\n end", "def can_request_review\n if rule.locked\n errors.add(:base, 'Cannot request a review on a locked control')\n elsif !rule.review_requestor_id.nil?\n errors.add(:base, 'Control is already under review')\n end\n end", "def require_new_review\n\t\t@review = @profile.reviews.build\n\tend", "def post_review?(next_review, user)\n\n (next_review && \n !self.review_locked? && \n next_review.designer_id == user.id &&\n next_review.review_type_id == next_review.design.phase_id)\n\n end", "def has_reviews?\n\t\t!self.reviews.empty? \n\tend", "def destroy\n @review = Product.find(params[:product_id]).reviews.find(params[:id])\n @review.destroy\n redirect_to :back\n end", "def ratings(number_of_reviews)\n\t\treturn true if number_of_reviews > 0\n\tend", "def user_reviews\n Review.all.select {|review| review.user == self}\n end", "def reject_promotion_if_not_enough_items\n promotion = Promotion.find(@basket_item.promotion_id)\n if !promotion.item_id.nil?\n items_count = BasketItem.where( basket_id: @basket_item.basket_id,\n item_id: promotion.item_id)\n .count\n # count pieces of the item for which promotions already applied\n item_promotions_count = 0\n Promotion.where(item_id: promotion.item_id).each do | p |\n item_promotions_count += BasketItem.where(basket_id: @basket_item.basket_id,\n promotion_id: p.id)\n .count * promotion.item_quantity\n end\n\n if items_count - item_promotions_count < promotion.item_quantity\n flash[:danger] = \"Not enough items in the basket to apply the promotion!\"\n @reject = true\n end\n end\n end", "def review_locked?\n (self.review_type.name == \"Final\" && \n (!(self.design.audit.skip? || self.design.audit.auditor_complete?) ||\n !self.design.work_assignments_complete?))\n end", "def reviewers_full?\n return false if offering.min_number_of_reviews_per_applicant.blank?\n reviewers.without_committee_scores.size >= offering.min_number_of_reviews_per_applicant\n end", "def reviews\n Review.all.select do |r|\n r.user == self\n end\n end", "def destroy\n if @book.has_reviews? \n @book.status = 'deactivated'\n @book.save\n redirect_to books_url, notice: 'Book had ratings or reviews and has been deactivated.'\n else\n destroy!\n end\n end", "def create\n\n @product = Product.find( params[:product_id])\n @product.reviews.create(review_params)\n @product.save\n\n if current_user.try(:admin?)\n redirect_to product_path(@product)\n else\n redirect_to store_show_path(@product)\n end\n\n @review = Review.new(review_params)\n\n end", "def destroy\n\n @product = Product.find(params[:product_id])\n @revoew = @product.reviews.find(params[:id])\n @review.destroy\n\n redirect_to product_path(@product)\n\n end", "def can_review?\n reviewer? || moderator? || administrator?\n end", "def destroy\n @review.destroy\n @apn.update_attribute(:reviewed, false)\n flash[:notice] = \"Review was destroyed\"\n redirect_to root_path\n end", "def authorize_user_review\n session[:return_to] ||= request.referer\n if current_user != @review.user\n flash[:notice] = \"You didn't write that review\"\n redirect_to session.delete(:return_to)\n end\n\n end", "def count_reviews_of\n @count_reviews_of ||= Review.of(editor).posted_within(self).count\n end", "def review_exist?\n self.reviews.any?\n end", "def create\n @product = Product.find(params[:product_id])\n @review = @product.reviews.create(review_params)\n @review.user = current_user\n\n if ! @review.valid?\n puts \"Invalid review\"\n puts @review.errors.messages\n end\n\n if @review.valid?\n @review.save\n puts \"Valid review\"\n puts @review.errors.messages\n end\n\n# Checking validation errors (reviews are not saving, etc)\n# person = Person.new\n# person.valid? # => false\n# person.errors.messages\n\n if @review.save\n puts \"Review saved\"\n redirect_to product_path(@product)\n else\n puts \"Review not saved\"\n redirect_to '/'\n end\n end", "def destroy\n if (allowAccessIfOwnerNameIsOrRankAtLeast(\"#{@review.poster}\", 1))\n @review.destroy\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to reviews_url }\n format.json { head :no_content }\n flash[:notice] = 'You do not have permission to delete this review'\n end\n end\n end", "def verify_user\n redirect_to forbidden_path unless user_signed_in? && @review.user_id == current_user.id\n end", "def destroy\n unless current_user.is_review_moderator?\n redirect_to denied_path\n return\n end\n\n @review = Review.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to(reviews_url) }\n format.xml { head :ok }\n end\n end", "def create\n @product = Product.find(params[:product_id])\n\n @review = @product.reviews.new(review_params)\n\n @review.user = current_user\n\n if @review.save\n redirect_to @product, notice: 'Review was created successfully.'\n else\n redirect_to @product, notice: 'Review failed to save.'\n end\n end", "def destroy\n @product = Product.find(@product_review.product_id)\n @product_review.destroy\n\n redirect_to product_path(@product.id, notice: 'Product review was successfully destroyed.')\n end", "def authorize_product!(product)\n unless product.nil?\n unless current_user.products.include?(product)\n raise Exceptions::ProductAccessDenied\n end\n end\n end", "def review\n return access_denied unless @course.has_teacher(current_user) || @submission.group.has_reviewer?(current_user) || (@exercise.collaborative_mode == 'review' && (@course_instance.has_student(current_user) || @course_instance.has_assistant(current_user)))\n\n review = @submission.assign_to(current_user)\n\n redirect_to edit_review_path(review)\n log \"create_review #{@submission.id},#{@exercise.id}\"\n end", "def allow_review?(proposal)\n (program_mode? || !proposal.has_speaker?(current_user)) && !proposal.finalized?\n end", "def ever_reviewed_by?(user_id)\n\t\tself.reviews.any?{|review| review.user_id == user_id}\n\tend", "def deny\n self.granted = -1\n restaurant = Restaurant.find(self.restaurant_id)\n restaurant.mark_collaborative\n end", "def destroy\n @product = Product.find(params[:product_id])\n @review = Review.find(params[:id])\n authorize! :destroy, @review\n\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to @product }\n format.json { render json: {:id => @review.id} }\n end\n end", "def create\n # Creates a new review & sends them back to their updated page\n review = current_user.reviews.create(review_params)\n if review.save\n redirect_to :back\n else\n redirect_to product_path(id: params[:product_id])\n end\n end", "def destroy\n #find the individual review\n @review = Review.find(params[:id])\n # check if user is current poster\n if @review.user == @current_user\n #destroy it\n @review.destroy\n end\n\n #redirect to the homepage\n redirect_to root_path\n end", "def destroy\n @product = Product.find_by(id: params[:product_id])\n @review = Review.find_by(id: params[:id])\n @review.destroy\n\n redirect_to @product, notice: 'Review Deleted'\n end", "def number_of_reviews\n self.reviews.count\n end", "def can_add_product(p) \n university_id && \n ! products_unshipped_and_uncancelled.include?(p) &&\n ( ! p.premium? || univ_premium? ) # we can add non-prem products to any univ, or premium prods to premium univs\n end", "def reviewing?(other_user)\n reviewing.include?(other_user)\n end", "def reviewer_locked_in?\n ReviewStatus.closed_reviews.include?(self.review_status)\n end", "def scorable_reviews\n self.select { |review| review.is_scorable_review? == true }\n end", "def has_reviews?(proposal_id)\n\t\treturn (Review.find_all_by_proposal_id(proposal_id).count > 0)\n\tend", "def only_one_vote_per_user\n errors.add(:user_id, \"...You can only vote once.\") if\n self.diet_food.upvotes.only_user_id.include?(ip_user.id)\n end", "def uniqueness_by_votable\n errors.add(\"you already voted!\") if Vote.where(votable: self.votable, user_id: self.user_id).count > 0\n end", "def just_reviewed?\n reviewed? and reviewed_changed?\n end", "def destroy\n\t\t@review.destroy\n\t\tredirect_to admins_path\n\tend", "def create\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @product = Product.find(params[:product_id])\n @rating=@product.ratings.new(rating_params)\n @rating.user_id = @current_user.id\n if @rating.save\n redirect_to @product , notice:'Review was successfully created'\n else\n redirect_to @product , notice:'Review was not created'\n end\n end", "def trade_is_not_a_repeat\n # see if the record has been created, and has an id assigned\n number_that_can_exist = id.nil? ? 0 : 1\n if Offer.where(user_id: user_id, trade_id: trade_id).length > number_that_can_exist\n errors.add(:user_id, \"user has already made an offer for this trade\")\n end\n end", "def read_only_disabled\n if !(@restaurant.creator_id == @review.user_id) \n \"disabled\"\n end\n end", "def reset_reviewed\n if copy_changed? && !approved_changed?\n if copy_change[0] != copy_change[1]\n self.reviewer_id = nil\n self.approved = nil\n end\n end\n return true\n end", "def reject_promotion_if_no_conjunction\n if Promotion.where( id: BasketItem\n .where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion')\n .pluck(:promotion_id),\n conjunction: false).any? ||\n Promotion.find(@basket_item.promotion_id).conjunction == false &&\n BasketItem.where( basket_id: @basket_item.basket_id,\n type: 'UsingPromotion').any?\n flash[:danger] = \"Promotion cannot be used in conjunction with already applied promotions!\"\n @reject = true\n end\n end", "def canViewWriteReviewButton(user, store)\n\t \t\t\tif store.nil?\n\t \t\t\t\treturn false\n\t \t\t\tend\n\n\t \t\t\tif user.nil?\n\t \t\t\t\treturn true\n\t \t\t\tend\n\t \t\t\tif isStoreManager(user) || isStoreOwner(user)\n\t \t\t\t\treturn \"store managers cannot review stores\"\n\t \t\t\tend\n\n\t \t\t\tpreviousreview = store.store_reviews.find_by user_id: user.id\n\t \t\t\tif previousreview.nil?\n\t \t\t\t\treturn true\n\t \t\t\telse\n\t \t\t\t\treturn \"you've already reviewed this store\"\n\t \t\t\tend\n\t \t\tend", "def create\n @product = Product.find params[:product_id] \n @review = @product.reviews.create(review_params)\n if @review.save\n redirect_to :back\n end\n end", "def item_need_review=(value)\n @item_need_review = value\n end", "def in_review?\n self.review_status_id == ReviewStatus.find(:first,\n :conditions => \"name='In Review'\").id\n end", "def item_need_review\n return @item_need_review\n end", "def delete_product_2_review\n review = Review.find(params[:id])\n product = Product.find(params[:product_id])\n review.product_ids.delete(product.id)\n review.product_idurls.delete(product.idurl) \n review.save\n render :update do |page|\n page.replace(\"products_4_review\",\n :partial => \"/reviews/products_4_review\",\n :locals => { :review => review } )\n end\n end", "def detect_review\r\n return render :nothing => true unless logged_in?\r\n if @review = session_user.reviews.for_product(params[:id]).editable.first\r\n # RIC moderation\r\n if @review.content_documents.any?\r\n @review = @review.content_documents.last.copy_content_fields_forward\r\n end\r\n end\r\n end", "def canViewWriteReviewButtonForItem(user, item)\n\t \t\t\tif item.nil?\n\t \t\t\t\treturn false\n\t \t\t\tend\n\n\t \t\t\tif user.nil?\n\t \t\t\t\t# different than above, b/c we handle login differently\n\t \t\t\t\treturn false\n\t \t\t\tend\n\t \t\t\tif isStoreManager(user) || isStoreOwner(user)\n\t \t\t\t\treturn \"store managers cannot review items\"\n\t \t\t\tend\n\n\t \t\t\tpreviousreview = item.store_item_reviews.find_by user_id: user.id\n\t \t\t\tif previousreview.nil?\n\t \t\t\t\treturn true\n\t \t\t\telse\n\t \t\t\t\treturn \"you've already reviewed this item\"\n\t \t\t\tend\n\t \t\tend", "def reject!\n return false if self.approved == true\n self.destroy\n end", "def create\n @review = Review.new(review_params)\n @product = Product.find(params[:product_id])\n @review.product = @product\n @review.user = current_user\n\n if @review.save\n redirect_to @product, notice: 'Review Successfully Created!'\n else\n flash[:alert] = 'Review not created'\n render '/products/show'\n end\n end", "def update_books_approved_reviews_count\n unless book.blank?\n self.book.approved_reviews_count = book.reviews.approved.count\n book.save\n end\n end", "def reject_promotion_if_basket_empty\n if BasketItem.where(basket_id: @basket_item.basket_id).empty?\n flash[:danger] = \"Basket is empty - promotion cannot be applied!\"\n @reject = true\n end\n end", "def disallow_if_accepted_proposal\n if listing.accepted_proposal and listing.accepted_proposal.id == id\n errors.add(:base, \"You can't remove an accepted proposal.\") \n end\n\n #if blank, return true, and therefore allow destruction\n errors.blank? \n end", "def has_reviewed?(advocate)\n !!Review.find(:first, :conditions => [\"reviews.reviewer_id = ? AND reviews.reviewee_id = ?\", self.id, advocate.id])\n end", "def cannot_edit(_offer)\n !session[:is_administrator] && _offer.unbilled_balance <= 0\n end", "def show\n @product = Product.find(params[:id])\n if current_user.present?\n if current_user.rating_reviews.where(product_id: @product.id).any?\n @rating_review = current_user.rating_reviews.where(product_id: @product.id).first\n else\n @rating_review = RatingReview.new\n end\n else\n @rating_review = RatingReview.new\n end\n\n end", "def my_reviews\n self.reviews.select do |review|\n review.user.id = self.id \n end \n end", "def review_count\n self.reviews.count\n end", "def review_count\n self.reviews.count\n end", "def review_count\n self.reviews.count\n end", "def destroy\n @review.destroy\n end", "def delete_user\n delete_reviews(self)\n self.destroy\n end", "def reviewed?\n !application_review_decision_type.nil?\n end", "def quantity_cat_allowed?(reservations = [])\n max = equipment_model.category.maximum_per_user\n return true if max == \"unrestricted\"\n #count number in category for given and reserver's reservations, excluding those that don't overlap\n if same_category_count(get_overlapping_reservations(reservations)) > max\n errors.add(:base, \"Cannot reserve more than \" + equipment_model.category.maximum_per_user.to_s + \" \" + equipment_model.category.name.pluralize + \".\\n\")\n return false\n end\n return true\n end", "def ratings_cannot_be_out_of_order\n check_ratings(throwing_ratings, 'throwing')\n check_ratings(fielding_ratings, 'fielding')\n check_ratings(running_ratings, 'running')\n check_ratings(hitting_ratings, 'hitting')\n end", "def pending_review\n reviews = Review.where(\"stage != ?\", \"approved\")\n all_cps_under_review = []\n user_cps_under_review = []\n\n reviews.each do |review|\n all_cps_under_review << review.critical_process\n end\n\n all_cps_under_review.each do |cp|\n if self.cps_as_reviewer.include?(cp)\n user_cps_under_review << cp\n end\n end\n\n return user_cps_under_review\n end", "def average_rating\n # check if there is any review (.size is used to effectively count elements - do not use .length in this example)\n if self.reviews.size > 0\n # counting average from rating column\n self.reviews.average(:rating)\n else\n 'this product does not have any rating yet'\n end\n end", "def mark_violation\r\n @review = Review.find_by_param params[:id]\r\n violation = @review.violations.create params[:violation]\r\n end", "def destroy\n @product_review_product.destroy\n respond_to do |format|\n format.html { redirect_to(admin_product_review_products_url) }\n format.xml { head :ok }\n format.js\n end\n website.add_log(user: current_user, action: \"Removed review from #{@product_review_product.product.name}\")\n end", "def ensure_not_referenced_by_any_expense\n raise \"Cannot delete user '#{name}'. There are expenses referencing this user.\" unless expenses.empty?\n end", "def get_positive_reviews\n all_reviews = Review.where(user_id: self.id)\n all_reviews.select{|review|review.rating > Review.rating_range.max/2 }\n return all_reviews\n end", "def ignore\r\n access_denied_state_error :ignore unless @review_set.may_ignore?\r\n @review_set.ignore!\r\n controller_render(@review_set)\r\n end", "def update_review(movie, status)\n\tcheck = user_already_reviewed(movie)\n\t#if none returns 0\n\tif check == -1\n\t @update_review = 0\n\t#else returns the review id \n\telse\n\t reviewFound = movie.reviews.where('user_id' => current_user.id).first\n\t @update_review = reviewFound.id\n\tend\nend", "def status_restricted?\n (prospect || exstudent || student) &&\n !(prospect && exstudent && student)\n end", "def user_has_not_favourited_work\n errors.add('You cannot favourite a work twice.') unless Favourite.find_by(user_id: self.user_id, work_id: self.work_id).nil?\n end", "def reviewed_school?(user)\n self.reviews.exists?(user: user)\n end", "def create\n current_user = User.find(session_params)\n @review = Review.new(\n user_id: current_user.id,\n product_id: params[:product_id],\n rating: params[:rating],\n description: params[:review][:description]\n )\n if @review.valid?\n @review.save\n redirect_to product_path(params[:product_id])\n else\n redirect_to root_path\n end\n end", "def destroy\n @review = @post.reviews.where(user_id: current_user.id).find(params[:id])\n @review.destroy\n respond_with @post, @review, location: post_path(@post, anchor: \"reviews\")\n end", "def has_seller_review?\n seller_reviews.present?\n end", "def downvote\n @submission = Submission.find(params[:id])\n @submission.downvote_by current_recycler\n if @submission.get_downvotes.size >= 3\n @submission.status = 'Denied'\n end\n redirect_to '/votes'\n end", "def review_locked(review)\n# @review = review\n#\n# mc = BackgroundConfigHandler.instance.model_config\n# @review.review_locking.reason = mc['REVIEW']['PREDEFINED_LOCKING_REASONS'][4]\n#\n# \n# @review_type = I18n.translate(\"mailers.frontend.review_mailer.review_type.review\")\n# if @review.is_comment\n# @review_type = I18n.translate(\"mailers.frontend.review_mailer.review_type.comment\")\n# end\n# @user = review.frontend_user\n# @item = review.destination\n# @item_type = I18n.translate(\"mailers.frontend.review_mailer.destination.#{@item.class.name}\")\n# @item_name = @item.name\n# @item_name = @item.full_name if @item.respond_to?('full_name')\n# @domain_name = domain_name\n# mail({\n# :to => @user.email,\n# :from => \"Noreply <noreply@#{@domain_name}>\",\n# :reply_to => \"Noreply <noreply@#{@domain_name}>\",\n# :subject => I18n.translate('mailers.frontend.review_mailer.review_locked.subject',\n# {:review_type => @review_type, :domain_name => domain_name})\n# })\n end" ]
[ "0.6972179", "0.62275386", "0.6121825", "0.61167115", "0.6060643", "0.59608644", "0.5849173", "0.58219284", "0.5819048", "0.58135027", "0.5694305", "0.5658769", "0.5636665", "0.56277484", "0.5624664", "0.56120497", "0.55964833", "0.5588114", "0.55828565", "0.55782783", "0.5564754", "0.55557936", "0.5542918", "0.54908836", "0.5479176", "0.5468795", "0.5464956", "0.54634035", "0.5461563", "0.54561466", "0.54291433", "0.5428463", "0.5408358", "0.5401672", "0.53948534", "0.53870857", "0.53581804", "0.53512186", "0.53427064", "0.5338302", "0.53348386", "0.53263116", "0.53136635", "0.5313225", "0.5312421", "0.53098893", "0.53097695", "0.5298871", "0.52681625", "0.52584803", "0.524712", "0.52296674", "0.52259254", "0.5224894", "0.5224562", "0.5220568", "0.5218465", "0.52173203", "0.5192909", "0.51893324", "0.5185059", "0.51755244", "0.5166787", "0.51621115", "0.5159464", "0.5150816", "0.5150661", "0.514904", "0.51464385", "0.5139025", "0.51328653", "0.5127529", "0.5123261", "0.51100564", "0.5105605", "0.50996417", "0.50975114", "0.50975114", "0.50975114", "0.50955003", "0.5071431", "0.50714135", "0.5071216", "0.50696295", "0.5063719", "0.50631404", "0.506294", "0.5055999", "0.50471395", "0.5046421", "0.50377387", "0.50357866", "0.5031611", "0.5028799", "0.50285417", "0.5027378", "0.5027089", "0.5024526", "0.5013559", "0.50133836" ]
0.7584058
0
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge [by myself, with: ]. 0. total Pseudocode make sure all pseudocode is commented out! set variable equal to 0 iterate over numbers and add to variable return total Input: total([10, 5, 2, 1]) Output: 18 Steps to solve the problem. 1. total initial solution
def total(arr) x = 0 sum = 0 while x < arr.length sum += arr[x] x += 1 end return sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(x)\n solution = 0\n x.each do |num|\n solution += num\n end\n solution\nend", "def total(numbers)\n result = 0\n numbers.each { |x| result += x }\n return result\nend", "def total (number)\n sum = 0\n number.each do | x |\n sum += x\n end\n return sum\nend", "def total_sum(list_of_numbers)\n total = 0\n\n list_of_numbers.each do |current_number|\n total = total + current_number\n end\n\n return total\nend", "def total(numbers)\n total = 0\n numbers.each do |num|\n total += num\n end\n\n return total\nend", "def total(array_of_numbers)\n sum = 0\n array_of_numbers.each do |num|\n sum += num\n end\n return sum\nend", "def total(numbers)\n\tnumbers.inject(0) {|sum, x| sum + x}\nend", "def sum_numbers(numbers)\r\n # Your code here\r\n #initalize the sum\r\n sum = 0\r\n #iterate through every element of a given array\r\n numbers.each do |number|\r\n #add the previous sum and next number in the array\r\n sum += number\r\n end\r\n \r\n return sum\r\nend", "def total(numbers)\n sum = 0\n numbers.each { |num| sum += num }\n sum\nend", "def sum(list_of_numbers)\n running_total = 0\n list_of_numbers.each do |number|\n running_total = running_total + number\n end\n\n\n return running_total\nend", "def total(nums)\n nums.inject(:+)\nend", "def sum_list_of_numbers(list_of_numbers)\n current_total = 0\n list_of_numbers.each do |current_number|\n current_total = current_total + current_number\n end\n\n return current_total\nend", "def sum_of_sums(numbers)\n sum_total = 0\n accumulator = 0\n\n numbers.each do |num|\n accumulator += num\n sum_total += accumulator\n end\n sum_total\nend", "def sum_of_sums(numbers)\n sum_total = 0\n accumulator = 0\n\n numbers.each do |num|\n accumulator += num\n sum_total += accumulator\n end\n\n sum_total\nend", "def sum_of_sums(numbers)\n sum_total = 0\n accumulator = 0\n\n numbers.each do |num|\n accumulator += num\n sum_total += accumulator\n end\n\n sum_total\nend", "def running_total(array_of_nums)\n increment = 0\n running_total_array = []\n\n array_of_nums.each do |num|\n running_total_array << num + increment\n increment += num\n end\n\n running_total_array\nend", "def total(num)\n sum = 0\n num.each do |x|\n sum = sum + x\n end\n return sum\nend", "def running_total4(numbers)\n sums = []\n numbers.each_with_index do |_, idx|\n current_total = numbers[0..idx].sum\n sums << current_total\n end\n\n sums\nend", "def total(numbers)\n\tnumbers.inject(:+)\nend", "def total(num)\n sum = 0\n num.each do |int|\n sum = sum + int\n end\n return sum\nend", "def sum_numbers list\n total = 0\n list.each do |num|\n total = num + total\n end\n return total\nend", "def total(numbers)\n return numbers.reduce(:+)\nend", "def total(array_of_numbers)\n return array_of_numbers.reduce(:+)\nend", "def solution(number)\n sum = 0\n Array(1..number-1).each do |i|\n if i % 3 == 0 || i % 5 == 0\n sum += i\n end\n end\n sum\nend", "def sum_of_multiples(target, factors)\n\n# 1. Create an empty array called multiples\n\nmultiples = []\n\n# 2. Check where the list of factors is empty, and if it is, set the list to [3, 5]\n\nif factors.empty?\n factors = [3, 5]\nend\n\n# 3. For every factor in the factors list\n# 1. Set the current_multiple to factor to keep track of the multiples of factor\n# 2. While current_multiple < targe\n# 1. Append the current_multiple to multiples\n# 2. Add factor to current_multiple\n\nfactors.each do |factor|\n current_multiple = factor\n \n while current_multiple < target\n multiples.push(current_multiple)\n current_multiple += factor\n end\nend\n\n# 4. Filter duplicate numebrs from multiples\n\nmultiples.uniq!\n\n# 5. Compute and return the sum of the numbers in multiples\n\np multiples.sum\n\nend", "def total(numbers)\n numbers.reduce(:+)\nend", "def running_total(numbers)\n numbers.each.with_index do |num, i|\n if i != 0\n numbers[i] += numbers[i - 1]\n end\n end\n numbers\nend", "def sum(nums)\n total = 0\n nums.each do |n|\n total+= n\n end\n return total\nend", "def total(nums)\n sum = 0\n nums.each {|i| sum = (sum + i)}\nend", "def running_total(nums_ary)\n ary = []\n\n nums_ary.reduce(0) do |sum, num|\n ary << sum + num\n sum + num\n end\n ary\nend", "def total (number)\n\tsum = 0\n\tnumber.each do |x| \n\t\tsum = sum + x\n\tend\n\treturn sum\nend", "def running_total(numbers)\n numbers.map.with_index { |_, i| numbers[0..i].reduce(:+)}\nend", "def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).inject(:+)\n end\n sum_total\nend", "def total(list)\n\tans = 0\n\tlist.each do |num|\n\t\tans = num + ans\n\tend\nend", "def solution(number)\n return 0 if number <= 3\n\n sum = 0\n (1..(number - 1)).each do |n|\n if (n % 3 == 0) || (n % 5 == 0)\n sum += n\n end\n end\n\n sum\nend", "def total(array)\n sum = 0\n array.each do |number|\n sum = sum += number\n end\n sum\nend", "def sum(list_of_numbers)\n running_total = 0\n list_of_numbers.each do |number|\n running_total = running_total + number\n end\n\n return running_total\n end", "def total(nums)\r\n\ttotal = 0\r\n\r\n\tnums.each do |i|\r\n\t\ttotal += i\r\n\tend\r\n\treturn total\r\nend", "def running_total(numbers)\n index = 1\n while index < numbers.length\n numbers[index] = numbers[index] + numbers[index - 1]\n index += 1\n end\n numbers\nend", "def running_total3(array)\n sum = 0\n array.map do |num|\n sum = [sum, num].inject(:+)\n end\nend", "def running_total(numbers)\n total = 0\n numbers.map { |number| total += number }\nend", "def running_total(arr)\n totals = []\n arr.inject(0) do |total, num|\n totals << num + total\n total += num\n end\n return totals\nend", "def sum(numbers)\n result = 0\n numbers.each do |num|\n result += num\n end\n result\nend", "def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).reduce(:+)\n end\n sum_total\nend", "def total(array)\n x = 0\n while x < array.length\n array.each do |n|\n x += n\n end\n end\n return x\nend", "def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).reduce(:+)\n end\n sum_total\nend", "def total(numbers)\n\tsum = 0\n\tnumbers.each do |num| \n\t\tsum = sum+num\n\tend\n\tp sum\nend", "def total(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n return sum\nend", "def total\n (1..64).inject {|sum, square| sum + square(square)}\n end", "def compute_sum(number)\n total = 0\n 1.upto(number) { |value| total += value }\n total\nend", "def solution(number)\n(0...number).map{|x| x % 3 == 0 || x % 5 == 0 ? x : 0}.inject{|sum, x| sum + x}\nend", "def total\n (1..64).inject {|sum, num| sum + square(num)}\n end", "def sum_of_sums(numbers)\n 1.upto(numbers.size) do |num|\n num += 1\n end\n # num\nend", "def total(arr)\nnumber = 0\narr.each { |x| number += x}\n return number\nend", "def sum_nums(num)\n\t\n\tnumbers = []\n\tnum_sum = num\n\t\nuntil numbers.length == num_sum\n\tnumbers.push(num)\n\tnum = num - 1\nend\n return\tnumbers.inject(:+)\nend", "def solution(number)\n number -=1 and sum = 0 and for x in number.downto(0) do x%5 == 0 ? (sum = sum+x) : if(x%3 == 0) then sum = sum+x \n end end and return sum \nend", "def total(array)\n array.inject { |sum, n| sum + n}\nend", "def add_nums_iterative(arr)\n return nil if arr.length == 0\n total = 0\n arr.each do |num|\n total += num\n end\n total\nend", "def total(array) \n number = 0\n array.each do |i|\n number += i\n end\n number\nend", "def total(array)\n total = 0\n array.each do |number|\n total += number\n end\n total\nend", "def total(array)\n sum = 0\n array.each do |x|\n sum = sum + x\n end\n sum\nend", "def running_total(array_nums)\n total = 0\n array_nums.map { |num| total += num }\nend", "def sum(number)\n total = 0\n 1.upto(number) {|v| total += v }\n total\nend", "def summorial( number, components, solution )\n\n\t# If the sum of the current value equals the number, then i have found\n\t# a possible combination\n\tvalue = (1..[number, MAX_SUM_TERM].min).to_a - components\n\tif value.inject{ |sum, x| sum + x }.to_i == number\n\t\tsolution.add( value )\n\t\treturn solution\n\tend\n\n\t# If there are more numbers to be tested, i'll go recursively on them\n\tif !components.empty?\n\t\ti = 0\n\t\twhile i < components.length do\n\t\t\t# Saving the number so i could reinsert it after and choosing \n\t\t\t# a different one for the next iteration\n\t\t\ttemp = components.delete_at( i )\n\t\t\tsummorial( number, components, solution )\n\t\t\tcomponents.insert( i, temp )\n\t\t\ti += 1\n\t\tend\n\tend\n\t\nend", "def total(array)\n sum = 0\n array.each do |n|\n sum += n\n end\n sum\nend", "def running_total(array)\n sum = 0\n new_array = []\n array.each do |num|\n sum += num\n new_array << sum\n end\n new_array\nend", "def solution_1\n\n sums = []\n start_point = 0\n index_number_to_check = 25\n\n while true\n \n number_to_check = INPUT[index_number_to_check]\n range = INPUT.slice(start_point,25)\n\n for i in 0..range.length - 1\n k = i + 1\n for k in k..range.length - 1\n sum_result = range[i] + range[k]\n sums << sum_result\n end\n end\n start_point +=1\n index_number_to_check +=1\n if sums.include?(number_to_check) == false\n puts \"The number is #{number_to_check}\"\n exit\n end\n sums = []\n end\n number_to_check\nend", "def problem_106a\n combin = lambda { |m,h| m.factorial / (h.factorial * (m - h).factorial) }\n max = 20\n\n sum = Array.new(max+1,-1)\n 1.upto(max) do |n|\n 0.upto(n/2) do |k|\n sum[n] += combin.call(n,2*k) * combin.call(2*k - 1, k + 1)\n end\n puts \"#{n} #{sum[n]}\"\n end\n sum[12]\nend", "def total (array)\n sum = 0\n array.each do |i|\n sum + i\n end\n return sum\nend", "def solution(a)\n return 1 if a.count == 0\n \n real_sum = a.inject(:+)\n expected_sum = (a.count + 1) * (a.count + 2) / 2.0\n (expected_sum - real_sum).to_i\nend", "def sum_of_sums(numbers)\n sum = 0\n numbers.size.times do |idx|\n sum += numbers[0..idx].inject(:+)\n end\n \n sum\nend", "def reduce_to_total(source_array , starting_point = 0)\n #source_array.reduce{|x,starting_point| starting_point + x}\n \n #source_array.reduce(:+)\n total = 0\n \n i = 0\n\n while i < source_array.length do \n \n if starting_point != 0 \n \n starting_point += source_array[i] \n \n else\n total += source_array[i]\n end\n i += 1 \n \n end \n if starting_point == 0\n return total\n else\n return starting_point\n end\n end", "def running_total(array)\n result = []\n\n array.inject(0) do |sum, num|\n result << sum += num\n sum # have to return sum\n end\n result\nend", "def sum_rec(numbers)\n # base case\n return 0 if numbers.empty?\n # inductive step\n numbers[0] + sum_rec(numbers[1..-1])\nend", "def compute_sum(numbers)\n sum = 0\n numbers.each do |number|\n sum += number\n end\n return sum\nend", "def compute_sum(numbers)\n sum = 0\n numbers.each do |number|\n sum += number\n end\n return sum\nend", "def total(input_array)\n\tn = 0\n\tinput_array.each do |x|\n\t\tn += x\n\tend\n\treturn n\nend", "def running_total(input_array)\n sum = 0 # => 0, 0, 0, 0\n new_array = input_array.map do |value| # => [2, 5, 13], [14, 11, 7, 15, 20], [3], []\n sum += value # => 2, 7, 20, 14, 25, 32, 47, 67, 3\n end # => [2, 7, 20], [14, 25, 32, 47, 67], [3], []\nend", "def running_total(arr)\n return [] if arr.empty?\n running_sum = [arr[0]]\n counter = 1\n loop do \n break if counter == arr.size\n \n current_value = arr[counter]\n last_number = running_sum.last\n running_sum << current_value + last_number\n \n counter += 1\n end\n running_sum\nend", "def reduce_to_total(source_array, starting_point = 0)\n #source_array.reduce(starting_point) {|sum, n| sum + n}\n i = 0\n sum = starting_point\n while i < source_array.length do\n sum = sum + source_array[i]\n i += 1\n end\n return sum\nend", "def running_total(array)\n # new_array = []\n sum = 0\n array.inject([]) do |arr, val| \n sum += val\n arr << sum \n arr\n end\nend", "def total(arr)\n output = 0\n arr.each do |x|\n output += x\n end\n output\nend", "def total(numbers)\n\tsum = 0\n\tnumbers.each do |x|\n\t\tsum += x.to_f\n\tend\n\treturn sum\nend", "def total ( numbers )\r\n\r\n\treturn numbers.reduce(:+);\r\n\r\nend", "def solution(number)\n ans = 0\n (3...number).step(3) {|n| ans += n}\n (5...number).step(5) {|n| n % 3 == 0 ? next : ans += n}\n return ans\nend", "def total(array)\n sum = 0\n array.each do |x|\n sum += x\nend\nsum\nend", "def sum_nums(max) # Defines method\n\n\ti = 1 # i starts at one because thats where the numbers start\n\tsum = 0 # sum starts at zero because we increment += 1 into sum\n\n\twhile i <= max # i has to be <= max cause we are adding up to max\n\t\t\n\t\tsum += i # sum increments by i; first time is one, second time is two\n\t\ti += 1 # here we set the rate of which i increments at, we do this after += i because if we did it before we would get an entirely different result and our aim is to return 10 and 15\n\tend # end while loop\n\treturn sum # return sum here and not in while loop because it exits method after return\nend", "def total(array)\n sum = 0\n array.each { |i| sum += i}\n return sum\nend", "def sum_nums(max)\n \n total = 0\n i = 1\n while i <= max \n total += i\n i = i+1\n end\n return total\nend", "def total (array)\n\tarray.inject { |sum, n| sum + n }\nend", "def sum_of_sums(numbers)\n sums = []\n 1.upto(numbers.size) do |length|\n sums << numbers[0, length].sum\n end\n \n sums.sum\nend", "def compute_sum(number)\n (1..number).inject(:+)\nend", "def sum(nums_to_sum)\n total = 0\n i = 0\n while i < nums_to_sum.length\n total = total + nums_to_sum[i]\n i += 1\n end\n return total\nend", "def sum_of_sums(array)\n results = []\n\n loop do \n break if array.empty?\n results << array.inject(:+)\n array.pop\n end\n\n results.inject(:+)\nend", "def total(num_array)\n\n if num_array.empty? == true\n\n puts \"Array is empty add some values\"\n\n else\n\n index = 0\n\n add = 0\n\n\n while index < num_array.length\n\n add = add + num_array[index]\n\n index += 1\n\n end\n\n p add\n end\nend", "def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes 0!=1 class Quiz\n # find even values\n def solution1(input)\n # Final solution\n input.flatten.select do |value|\n value.even?\n end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.select do |value|\n # value.even?\n # end\n # end.flatten\n end\n\n # find value sum\n def solution2(input)\n # Final Solution\n input.flatten.inject(:+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.flatten.inject do |sum, value|\n # sum += value\n # end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.inject do |sum, value|\n # sum += value\n # end\n # end.inject do |sum, value|\n # sum += value\n # end\n end\n\n # find max value\n def solution3(input)\n # Final solution\n input.flatten.max\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.max\n # end.max\n end\n\n # sum the array lengths\n def solution4(input)\n # Final solution\n input.map(&:length).inject(0, :+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.map(&:length).inject{|sum, value| sum += value}\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.length\n # end.inject {|sum, value| sum += value}\n end\n\n # transform to factorials\n # Factorial is defined as the product of all the whole numbers from 1 to n\n # Examples:\n # 4! = 4*3*2*1\n # 1! = 1\n # 0! = 1\n def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end\nend", "def findSum()\n\tnumbers.inject(0) { |sum, number| sum + number }\nend", "def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend", "def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend", "def sum_of_sums(array)\n sequence_total = 0\n sum = 0\n array.each do |n|\n sequence_total += n\n sum += sequence_total\n end\n sum\nend", "def total(list)\n \n sum = 0\n \n for i in list\n sum = sum + i\n end\n p sum\n \nend" ]
[ "0.69526976", "0.68984205", "0.6871195", "0.68647265", "0.68495536", "0.6835354", "0.6804543", "0.6792845", "0.67795366", "0.6766706", "0.67595476", "0.6751375", "0.6739806", "0.67381424", "0.67381424", "0.67244136", "0.67237", "0.67001647", "0.67000043", "0.66947263", "0.66905636", "0.66777897", "0.66564226", "0.66554976", "0.6623841", "0.66175187", "0.6615746", "0.66008115", "0.65992856", "0.65683126", "0.6557375", "0.6552116", "0.6546294", "0.6543547", "0.6536951", "0.6535396", "0.65344733", "0.6529281", "0.651327", "0.6502195", "0.64993036", "0.648203", "0.6466088", "0.6465996", "0.6465338", "0.6464913", "0.6459404", "0.6444767", "0.64422655", "0.6440654", "0.6437358", "0.64373046", "0.64290816", "0.6428944", "0.64273", "0.6426604", "0.642487", "0.6424607", "0.6422437", "0.64200276", "0.6415616", "0.6413087", "0.63993907", "0.63932055", "0.6391317", "0.63851166", "0.6382659", "0.6371232", "0.6367386", "0.636663", "0.6365907", "0.63590395", "0.6357822", "0.63553226", "0.6352188", "0.6352188", "0.6351924", "0.635066", "0.6348788", "0.6340952", "0.6335411", "0.6333889", "0.6323104", "0.6322957", "0.6307746", "0.6307496", "0.6307331", "0.6303221", "0.62950164", "0.628732", "0.62868303", "0.62838566", "0.62819254", "0.62751585", "0.62694526", "0.6268979", "0.6268547", "0.62630385", "0.62630385", "0.62623", "0.62615615" ]
0.0
-1
3. total refactored solution
def total(arr) sum = 0 arr.each do |i| sum = sum + i end return sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def anchored; end", "def solution4(input)\n end", "def suivre; end", "def private; end", "def probers; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def stderrs; end", "def schubert; end", "def transformations; end", "def villian; end", "def schumann; end", "def alg; end", "def malts; end", "def transform; end", "def recursive_solution\n\n end", "def formation; end", "def intensifier; end", "def terpene; end", "def calculated; end", "def romeo_and_juliet; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def algorithm=(_); end", "def algorithm=(_); end", "def algorithm=(_); end", "def algorithm=(_); end", "def _reduce_684(val, _values, result)\n result = [ @builder.kwnilarg(val[0][0], val[0][1]) ]\n \n result\nend", "def king_richard_iii; end", "def operations; end", "def operations; end", "def _reduce_479(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_656(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def rassoc(p0) end", "def _reduce_543(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend", "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "def diff1; end", "def ismn; end", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def gettrys(tcoords)\n # Indexa coordenadas de las lineas con menor incognitas\n p \"hmiss............\"\n p tcoords[:hmiss]\n hlower_c = lowerabsent(tcoords[:hmiss]) # [{:hindex=>x, :coords=> [[]]\n vlower_c = lowerabsent(tcoords[:vmiss],\"v\") # [{:vindex=>x, :coords=>[[]]\n slower_c = lowerabsent(tcoords[:smiss],\"s\") # [{:sindex=>x, :coords=>[[]]\n\n # combierte las coordenadas en numeros -> contiene menor incognitas\n hlower_n = hlower_c.collect {|line| missto_n(line[:hindex])} # [{:hindex=>0, :numbers=>[3, 4]}, x]\n vlower_n = vlower_c.collect {|line| missto_n(line[:vindex],tcoords[:vwhole], \"v\")} # [{:vindex=>0, :numbers=>[3, 4]}, x]\n #slower_n = slower_c.collect {|line| missto_n(line[:sindex], tcoords[:swhole], \"s\")} # [{:sindex=>2, :numbers=>[4, 6, 8]}, x]\n p \"****** H vs V *******\"\n p hlower_c.length < vlower_c.length ? \"h < v\" : \"h > v\"\n # cantidad de incognitas decide si se usa h o v\n p lower_c = hlower_c.length < vlower_c.length ? hlower_c : vlower_c\n lower_n = lower_c[0].keys[0][0] == \"h\" ? hlower_n : vlower_n\n # le pone cuadro a cada coord y separa coordenadas, una por linea\n hvindex_sindex_coords = locatecoord_onsquere(lower_c, tcoords[:swhole])\n sqr_n = hvindex_sindex_coords.collect {|item| missto_n(item[:sindex], tcoords[:swhole],\"s\")}\n # buscar que sqr tiene menos coincidencias\n hvindex_sindex_coords.collect { |main|\n main[:sqr_options] = sqr_n.collect {|numbers| numbers[:numbers] if main[:sindex] == numbers[:sindex] }.compact.flatten\n main[:options] = lower_n.collect {|numbers| numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]] }.compact.flatten\n main[:reduce] = main[:options] - ([1,2,3,4,5,6,7,8,9] - main[:sqr_options])\n\n }\n # numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]]\n result = hvindex_sindex_coords.group_by {|g| g[:reduce].length}\n\n p \"*******start Result\"\n reduce_index = result.collect {|x,y| x }.min\n result[reduce_index].map {|e| p e} # inspect\n result[reduce_index].map do |item|\n\n case item.keys[0][0]\n when \"h\"\n if item[:reduce].length == 1\n x = item[:coord][0]\n y = item[:coord][1]\n @tbls[:notformated][x][y] = item[:reduce][0]\n @tbls[:formated][x][y] = formato(@tbls[:notformated][x][y].to_s,:red, :yellow)\n elsif item[:reduce].length > 1\n # Pregunta en linea vertical\n end\n when \"v\"\n p \"################## - caso vertical pendiente - ###################\"; exit\n end\n\n end\n\n end", "def _reduce_653(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def transforms; end", "def translate(a)\n\tvoyel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\ncheck = 0\nn = 0\nx = a \n words = a.split(/\\W+/)\n words.each do |a|\n\tok = voyel.include?(a[0])\n\tif ok == true \n\t\ta = a + \"ay\"\n\t\treturn a \n\tend\n while check <= 4\n\tb = a.slice(0..check)\n\n\tcheck = check + 1\n \n\tok = voyel.include?(x[check])\n\ttest1 = \"qu\".include?(x[check])\n\tif test1 == true \n\t\tif check == 1\n\t\t\tb = a.slice(0..check)\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[2..-1]\n\t elsif check == 2\n\t \tb = a.slice(1..check)\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[4..-1]\n\t end\n\tend\n\n\tif ok == true \n\t\tif check == 1\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[1..-1]\n\t elsif check == 2\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[2..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t end\n\tend\nend\nend\nend", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend", "def silly_adjective; end", "def _reduce_430(val, _values, result)\n result = new_dsym val[1]\n \n result\nend", "def _reduce_672(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def trd; end", "def _reduce_533(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend", "def too_complex; end", "def offences_by; end", "def greibach_normal_form\n raise NotImplementedError\n end", "def hook_solution?(a); end", "def berlioz; end", "def _reduce_436(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def diff2; end", "def required_positionals; end", "def _reduce_473(val, _values, result)\n result = s(:lasgn, val[0])\n \n result\nend", "def _reduce_545(val, _values, result)\n result = @builder.accessible(val[0])\n\n result\nend", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def original_result; end", "def verdi; end", "def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_671(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def common\n \n end", "def generate_comprehensive\n\n end", "def method_731(base); end", "def lcts(array)\nend", "def _reduce_717(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_659(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend", "def _reduce_699(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_430(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_518(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend", "def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend", "def alternatives; end", "def _reduce_523(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend", "def algorithms=(_arg0); end", "def algorithms=(_arg0); end", "def exercise_1113 (matrix)\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def _reduce_478(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_594(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_581(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_651(val, _values, result)\n yyerrok\n result\nend", "def _reduce_427(val, _values, result)\n result = new_dsym val[1]\n \n result\nend" ]
[ "0.614783", "0.59552205", "0.58631617", "0.5817628", "0.5803303", "0.5688251", "0.5688251", "0.5688251", "0.5688251", "0.5688251", "0.5668896", "0.5657474", "0.56524754", "0.562926", "0.5584554", "0.5583142", "0.55335104", "0.55295557", "0.55000037", "0.549499", "0.5478271", "0.5450732", "0.544987", "0.5433531", "0.5422435", "0.5422435", "0.5381478", "0.5381478", "0.5381478", "0.5381478", "0.5350913", "0.5331758", "0.5325692", "0.5325692", "0.5323767", "0.53156716", "0.5306049", "0.5303046", "0.52773285", "0.5273887", "0.527278", "0.52694535", "0.52566403", "0.5251667", "0.5250441", "0.5248617", "0.52315843", "0.5229731", "0.5226629", "0.52212405", "0.5218845", "0.5206856", "0.5201853", "0.5193626", "0.51922435", "0.5191089", "0.51893747", "0.518622", "0.5183493", "0.5182572", "0.5178696", "0.5166912", "0.5160866", "0.51604515", "0.5159779", "0.5157119", "0.5156715", "0.51566964", "0.5153629", "0.51494896", "0.51490074", "0.51473784", "0.5146217", "0.5146142", "0.5140541", "0.51370454", "0.5136761", "0.5136456", "0.5136061", "0.513605", "0.5133585", "0.5133562", "0.51323944", "0.5130431", "0.5130431", "0.5130068", "0.512397", "0.512397", "0.512397", "0.512397", "0.51232177", "0.5118662", "0.5115908", "0.51128834", "0.5112615", "0.5112615", "0.5112615", "0.5112615", "0.5112615", "0.5111721", "0.5111496" ]
0.0
-1
4. sentence_maker pseudocode make sure all pseudocode is commented out! define sentence_maker(arr) create empty string iterate over elements in array convert all elements to string add elements to string except first and last objects make new string with first object, first string, and last object return new string make sure all pseudocode is commented out! Input: Output: Steps to solve the problem. 5. sentence_maker initial solution
def sentence_maker(arr) string = "" i = 1 while i < arr.length-1 string += arr[i].to_s + ' ' i+=1 end sentence = arr[0].capitalize! + " " + string + arr[-1] + "." return sentence end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_array.each do |string|\n if string != string_array[-1]\n new_string += string.to_s + \" \"\n else\n new_string += string.to_s\n end\n \n new_array.push(new_string)\nend\nreturn new_array[-1].capitalize + \".\"\nend", "def sentence_maker(array)\n str_array = array.collect{|i| i.to_s} #collect method returns entire array or hash; we are converting all elements of array into string\n sentence = array[0] #converts first element of array into new array\n sentence[0] = str_array[0][0].upcase #makes first letter uppercase\n str_array.shift\n\tstr_array.each { |i| sentence = sentence + \" \" + i.to_s}\n\treturn sentence + \".\"\nend", "def sentence_maker(array)\n sentence = \"\"\n array.each do |x|\n sentence = sentence + x.to_s + \" \"\n end\n\n sentence[0] = sentence[0].upcase\n sentence = sentence.rstrip\n sentence = sentence + \".\"\n return sentence\n\nend", "def sentence_maker(array_of_strings)\n result = \"\"\n last_word = array_of_strings.pop\n array_of_strings.each do |word|\n result += word.to_s + \" \"\n end\n result += last_word + \".\"\n return result.capitalize!\nend", "def sentence_maker(array)\n combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\nend", "def sentence_maker(array)\n combination = \"\"\n array[0].capitalize!\n array.each {|x| combination = combination + x.to_s + \" \"}\n combination.rstrip!\n combination = combination + \".\"\n return combination\nend", "def sentence_maker(array_of_strings)\n\t# Declare new sentence variable and set to \"\"\n\tsentence = \"\"\n\t# Capitalize first word in array\n\tarray_of_strings[0].to_s.capitalize!\n\t# For each member of array_of_strings, add to the sentence variable (converting to string)\n\tfor num in 0..(array_of_strings.length - 1)\n\t\t\tsentence += array_of_strings[num].to_s\n\t\t# unless the member of the array is the last member of array_of_strings_, add a space after the word\n\t\tunless num == (array_of_strings.length - 1)\n\t\t\tsentence += \" \"\n\t\tend\n\tend\n\t# End the sentence variable with a period\n\tsentence += \".\"\n\t# Return the sentence variable\n\treturn sentence\nend", "def sentence_maker (arr)\n sentence = \"\"\n arr[0] = arr[0].capitalize\n for i in 0...arr.length-1\n sentence = sentence + arr[i].to_s + \" \"\n end\n return sentence + arr[arr.length-1] + \".\"\nend", "def sentence_maker(array)\n sentence = \"\"\n array[0].capitalize!\n array.each do |i|\n sentence << \"#{i}\"\n unless i == array.last\n sentence << \" \"\n end\n end\n sentence << \".\"\n return sentence\nend", "def sentence_maker arr\n catenated_str = ''\n space = ' '\n i = 0\n\n arr.each do |el|\n catenated_str += i == 0 ? el.capitalize.to_s : i == (arr.length - 1) ? space + el.to_s + '.' : space + el.to_s\n i+=1\n end\n catenated_str\nend", "def sentence_maker (array)\n index = 0\n sentence = \"\"\n array = array.map {|x| x.to_s}\n\nuntil index == array.length-1\n sentence += array[index] + \" \"\n index += 1\nend\n\nsentence += array[-1] + \".\"\nreturn sentence.capitalize\n\nend", "def sentence_maker(arr)\n x = ''\n #Concatenate each element with a space\n arr.each{|y| x << y.to_s << ' '}\n\n #Take out any leading or trailing white space\n x.strip!\n x[0] = x[0].capitalize\n x << '.'\n p x\nend", "def sentence_maker(array_of_strings)\n sentence = array_of_strings[0].capitalize\n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n sentence + \".\"\nend", "def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\n\t\twhile x < (array.length - 1)\n\t\t\tsum += array[x].concat \" \" \n\t\t\tx += 1\n\t\tend \n\t\t\tsum += array[x].concat \".\" \n\treturn sum\n\nend", "def sentence_maker(array)\n\tanswer=\"\"\n\tarray[0]=array[0].capitalize\n\tarray.each do |x|\n\t\tx=x.to_s\n\t\tanswer+=x+\" \"\n\tend\t\n\tanswer=answer.chop+\".\"\n\treturn answer\nend", "def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\twhile x <= array.length-1\n\t\tif x == array.length-1\n\t\t\tsum += array[x].to_s\n\t\t\tx += 1\n\t\telse \n\t\t\tsum += array[x].to_s + \" \"\n\t\t\tx += 1\n\t\tend\t\n\tend\n\tsum += \".\"\n\tsum.capitalize!\n\treturn sum\nend", "def sentence_maker(arr)\n string = \"\"\n arr.each do |i|\n string += i.to_s + ' '\n end\n string[-1] = \".\"\n return string = string.capitalize\nend", "def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend", "def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend", "def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend", "def sentence_maker(array)\n\tarray[0].capitalize!\n\tfinalString = array.join(' ')\n\tfinalString = finalString + '.'\nend", "def sentence_maker (array)\n sentence = \"\"\n array.each do |i|\n sentence = sentence + i.to_s + \" \"\n end\n sentence = sentence.capitalize.chop + \".\"\nend", "def sentence_maker(arraystring)\n fullsentence = ''\n length_of_arraystring = arraystring.length\n current_index_of_array = 0\n while current_index_of_array < length_of_arraystring\n if current_index_of_array == 0\n word = arraystring[current_index_of_array].to_s.capitalize\n fullsentence = fullsentence + word + ' '\n\n elsif current_index_of_array == length_of_arraystring - 1\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + '.'\n else\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + ' '\n end\n current_index_of_array = current_index_of_array + 1\n\n end\n# puts fullsentence\n return fullsentence\nend", "def sentence_maker ( strArray )\r\n\r\n\tanswer = ''\r\n\r\n\tstrArray.each do |thisStr|\r\n\t\tanswer += thisStr.to_s + ' '\r\n\tend\r\n\r\n\tanswer.slice!(answer.length-1)\r\n\r\n\tanswer += '.'\r\n\r\n\treturn answer.capitalize!\r\n\r\nend", "def sentence_maker(array)\n sentence = array[0].capitalize\n for w in 1...array.length\n sentence = sentence + \" \" + array[w].to_s\n end\n return sentence + \".\"\nend", "def sentence_maker(array_of_strings)\n\n sentence = array_of_strings[0].capitalize\n \n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n p sentence + \".\"\n \nend", "def sentence_maker(array)\n\tcomplete = \"\"\n\tarray.each do |i|\n\t\tcomplete = complete + i.to_s + \" \"\n\tend\n\tcomplete.insert(-2, \".\")\n\treturn complete.strip.capitalize\nend", "def make_sentence(array) \n\tsentence = \"\"\n\tarray.each do |mini_arrays|\n mini_arrays.each do |element|\n sentence << \"a#{element}a \"\n end\n end \n \n\tsentence\n end", "def sentence_maker(array)\n x = 0\n sum = \"\"\n while x <= array.length-1\n sum += array[x].to_s + \" \"\n x += 1\n end\n sum.rstrip!\n sum += \".\"\n sum.capitalize!\n return sum\nend", "def sentence_maker(array)\n\tsentence = array[0].capitalize.to_s\n\ti = 1\n\twhile i < array.length\n\t\tsentence = sentence + \" \" + array[i].to_s\n\t\ti += 1\n\tend\n\tsentence = sentence + \".\"\n\tp sentence\n\nend", "def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words += element.to_s + \" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend", "def sentence_maker (strings)\n\njoin_strings = String.new\n\n strings.each { |string| join_strings += \" \" + \"#{string}\"}\n join_strings[0] = \"\"\n join_strings[0] = join_strings[0].capitalize\n return join_strings + \".\"\n\nend", "def sentence_maker (array)\n\tindex = 0\n\twhile index < array.length\n\t\tif index == 0\n\t\t\tsentence = array[index].to_s.capitalize\n\t\telse \n\t\t\tsentence = sentence + \" \" + array[index].to_s\n\t\tend\n\t\tindex += 1\n\tend\n\tsentence = sentence + \".\"\n\treturn sentence \nend", "def sentence_maker (arr)\n\n arr[0] = arr[0].capitalize\n sentence = arr.join(\" \")\n\n return sentence + \".\"\nend", "def solution(sentence)\n sentence_arr = []\n sentence_arr = sentence.split(\" \")\n #puts \"#{sentence_arr}\"\n sentence_str = \"\"\n sentence_arr.reverse_each { |word| sentence_str += \"#{word} \" }\n #puts \"#{sentence_str}\"\n return sentence_str\nend", "def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\tsentence += \".\"\n\treturn sentence\nend", "def sentence_maker(array)\n\ti = 0\n\twhile i < array.length do\n\t\tif i == 0\n\t\t\tsentence = (array[i].capitalize.to_s + \" \")\n\t\telsif i == array.length-1\n\t\t\tsentence = sentence + (array[i].to_s + \".\") \n\t\telse\n\t\t\tsentence = sentence + (array[i].to_s + \" \")\n\t\tend\n\t\ti += 1\n\tend\n\treturn sentence\nend", "def sentence_maker(words)\n\n i = 0\n sentence = ''\n\n while i < words.length\n if i == 0\n sentence = sentence + words[0].to_s.capitalize + ' '\n end\n if i == words.length - 1\n sentence = sentence + words[(words.length - 1)].to_s + '.'\n end\n if (i != words.length - 1) && i != 0\n sentence = sentence + words[i].to_s + ' '\n end\n i += 1\n end\n return sentence\nend", "def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words+=element.to_s+\" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend", "def sentence_maker(array)\n array.join(\" \")\n array(0,1).capitalize + array(1..-1) + \".\"\nend", "def sentence_maker(my_sentence)\n result=my_sentence.shift\n my_sentence.each { |x| result= result + \" \" + x.to_s }\n result=result + \".\"\n result.capitalize!\n end", "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "def sentence_maker(array)\n array[0].capitalize!\n array.join(\" \") << \".\"\nend", "def sentence_maker(array)\n\tlength = array.length\n\tsum = array[0].to_s.capitalize!\n\tfor i in 1...length\n\t\tsum = sum + \" \" + array[i].to_s\n\tend\n \tsum + \".\"\nend", "def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\treturn sentence + \".\"\nend", "def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\treturn sentence + \".\"\nend", "def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence = sentence.to_s.capitalize + \".\"\nend", "def sentence_maker(strings)\n\n new_string = strings[0]\n i = 1\n while i < strings.length\n new_string = new_string + \" \" + strings[i].to_s\n i += 1\n end\n new_string = new_string + \".\"\n return new_string.capitalize\nend", "def to_sentence(ary)\n\n\tif ary.count > 1\n\t\tlast_word=ary.pop\n\t\tfirst_words=ary.join \", \"\n\t\tnew_sentence=first_words + \" and \" + last_word\n\telse\n\t\tnew_sentence=ary.join\n\tend\n\nend", "def to_sentence(arr)\n\t# return arr.first if arr.length == 1\n\t# last = arr.pop\n\t# arr.join(', ') + ' and ' + last\n\tcase arr.length\n\twhen 1\n\t\tarr[0]\n\twhen 2\n\t\tarr.join(' and ')\n\telse\n\t\t\"#{arr[0..-2].join(', ')} and #{arr[-1]}\"\n\tend\nend", "def sentence_maker (array)\n array[0].capitalize!\n return array.join(\" \") + \".\"\nend", "def sentence_maker(x)\n\tx.join(\" \")\nend", "def sentence_maker(words)\n sentence = \"\"\n words.each { |word|\n word = word.to_s\n if word == words.first.to_s #cap if word is first in sentence\n sentence << (word.capitalize)\n else\n sentence << word\n end\n\n if word == words.last #period after last word, otherwise space\n sentence << \".\"\n else\n sentence << \" \"\n end\n }\n sentence\nend", "def to_sentence(ary)\n # your implementation here\n words = ary\n result = \"\"\n \n while words.length > 0 do\n result << words.shift.to_s\n if words.length > 1\n result << \", \"\n elsif words.length == 1\n result << \" and \" \n end \n end\n puts result\nend", "def sentence_maker(array)\n sentence = array.join(\" \")\n sentence = sentence.capitalize + \".\"\nend", "def sentence_maker(word_array)\n\tsentence = word_array.join(\" \")\n\treturn sentence.capitalize + \".\"\nend", "def sentence_maker(arr)\n arr[0] = arr[0].capitalize\n return arr.join(\" \") + \".\"\nend", "def generate_sentence\n current_words = Array.new(depth)\n sentence_array = []\n loop do\n new_word = current_words.last\n sentence_array.push new_word if new_word\n break if end_word?(new_word)\n next_word_options = @dictionary[current_words]\n if next_word_options.empty? && !end_word?(new_word)\n new_word.concat('.')\n break\n end\n next_word = next_word_options.sample\n current_words.push next_word\n current_words.shift\n end\n sentence_array.join(' ')\n end", "def sentence_maker(array)\n sentence = array.join(\" \")\n sentence << \".\"\n sentence.capitalize!\nend", "def sentence_maker(words)\n if words.size != 0\n sentence = \"\"\n for w in 0...words.size\n word = words[w]\n if (word.is_a? String)\n sentence += word + \" \"\n else\n sentence += word.to_s + \" \"\n end\n end\n sentence.chomp!(\" \")\n sentence += \".\"\n sentence.downcase!\n sentence.capitalize!\n return sentence\n end\nend", "def sentence_maker(array)\n result = array.join(' ')\n result = result.capitalize + \".\"\nend", "def sentence_maker(a)\n\ta[0] = a[0].capitalize\n\tstring = a.join(\" \")+\".\"\n\treturn string\nend", "def sentence_maker(array_of_strings)\n return array_of_strings.join(\" \").capitalize + '.'\nend", "def sentence_maker(array)\n x=array.join(\" \")\n return x.capitalize + \".\"\n end", "def sentence_maker(array)\n string = array.join(' ').capitalize! + '.'\nend", "def solution(sentence)\n return sentence.split.reverse.join(\" \")\nend", "def sentence_maker(strings)\n concat = \"\"\n strings.each do |n|\n concat << n.to_s + \"\"\n concat = concat.chomp(\" \") << \".\"\n end\n return concat.capitlize\nend", "def solution(sentence)\n sentence.split.reverse.join(\" \")\nend", "def sentence_maker(array)\n\tarray.join(\" \").capitalize << \".\"\nend", "def sentence_maker(array)\n\tarray.join(\" \").capitalize << \".\"\nend", "def sentence_maker(string)\n\tsentence = \"\"\n\tstring.each do |word|\n\t\tsentence += word.to_s + \" \"\n\tend\n\treturn full_sentence(sentence)\nend", "def sentence_maker(s_array)\n\n if s_array.empty? == true\n\n puts \"Array is empty add some values\"\n\n else\n\n p s_array.join(' ').capitalize + '.'\n\n end\nend", "def sentence_maker(strings)\n sentance = \"\"\n strings.each do |word|\n sentance += word.to_s + \" \"\n end\n sentance.strip!\n sentance.capitalize + \".\"\n\nend", "def sentence_maker(array_of_strings)\n\n p array_of_strings.join(' ').capitalize + \".\"\n\n end", "def sentence_maker(string_array)\n string_array.join(\" \").capitalize + \".\"\nend", "def sentence_maker(words)\n\tstring = \"\"\n\twords.each do |x|\n\t\tstring = string + x.to_s + \" \"\n\tend\n\treturn string.capitalize.strip + \".\"\nend", "def sentence_maker(words)\r\n\tsentence = ''\r\n\ti = 0\r\n\r\n\twhile i < words.length\r\n\t\tif i == 0 \r\n\t\t\tsentence = sentence + words[i].to_s.capitalize + ' '\r\n\t\t\ti += 1\r\n\t\telsif i == (words.length - 1)\r\n\t\t\tsentence = sentence + words[i].to_s + '.'\r\n\t\t\ti += 1\r\n\t\telse\r\n\t\t\tsentence = sentence + words[i].to_s + ' '\r\n\t\t\ti += 1\r\n\t\tend\r\n\tend\r\n\tp sentence\r\nend", "def sentence_maker(array)\n array.join(\" \").capitalize << \".\"\nend", "def sentence_maker(array)\n array.join(' ').capitalize << \".\"\nend", "def sentence_maker(array_of_strings)\n array_of_strings.join(' ').capitalize + \".\"\nend", "def sentence_maker array\n array = array.join(' ').capitalize\n return \"#{array}.\"\nend", "def sentence_maker(array)\n array.join(\" \").capitalize + \".\"\nend", "def reverse_sentence(my_sentence)\n i = 0\n each_word_array = []\n word = \"\"\n reverse_sentence = \"\"\n until i > my_sentence.length\n if my_sentence[i] != \" \" && my_sentence[i] != nil\n word += my_sentence[i]\n i += 1\n elsif my_sentence[i] == nil\n each_word_array << word\n\n (each_word_array.length - 1).times do |j|\n reverse_sentence += \"#{each_word_array[each_word_array.length - (j + 1)]}\"\n i += 1\n end\n\n return reverse_sentence += \"#{each_word_array[0]}\"\n else\n each_word_array << word\n each_word_array << my_sentence[i]\n word = \"\"\n i += 1\n end\n end\nend", "def create_sentence(words)\n\n\tstr=\"\"\n\tfor i in 0..words.size-1 do\n\t\tstr+=words[i]\n\t\tstr+=\" \"\n\n\tend\n\nputs str\n\t\nend", "def sentence_maker_refactored(words)\n words.first.capitalize!\n words.join(\" \") + \".\"\nend", "def sentence_maker(words)\n\tif words.size != 0\n\t\tsentence = \"\"\n\t\tfor w in 0...words.size\n\t\t\tword = words[w]\n\t\t\tif (word.is_a? String)\n\t\t\t\tsentence += word + \" \"\n\t\t\telse\n\t\t\t\tsentence += word.to_s + \" \"\n\t\t\tend\n\t\tend\n\t\tsentence.chomp!(\" \")\n\t\tsentence += \".\"\n\t\tsentence.downcase!\n\t\tsentence.capitalize!\n\t\treturn sentence\n\tend\nend", "def make_sentence parts\n index = 1\n parts.delete('.')\n string = parts.join(' ') + '.'\n if string.include?(\" ,\")\n string.gsub!(\" ,\", \",\")\n end\n string\nend", "def sentence_maker(string)\n\tstring[0] = string[0].capitalize\n\tphrase = ''\n\tstring.each do |word|\n\t\tphrase = phrase + word.to_s + ' '\n\tend\n\tphrase = phrase.chop\n\tphrase = phrase + '.'\n\treturn phrase\nend", "def sentence_maker(array)\n\tnew_array = array.join(\" \").capitalize + \".\"\n\t\nend", "def sentence_maker(sentence)\n sentence[0] = sentence[0].capitalize\n sentence.join(\" \") + \".\"\nend", "def translate(sentence)\n #we .split that sentence. Because we do not give a limit, the sentence is automaticly split along the spaces.\n #we .map the result of the .split to make every word in the array a variable= word.\n sentence.split.map do |word|\n #We define what the first vowel of the word is by a different method (first_vowel) and assign it as variable v\n v = first_vowel(word)\n # we slice of the first vowel and the letter preceding that. then we add the first letter of the word at the end, and add +ay\n word.slice(v..-1) + word[0,v] + \"ay\"\n #We end the function and join the retunring array with spaces in between.\n end.join(\" \")\n end", "def sentence_maker(words)\n sentence = ''\n words[0].capitalize!\n words.each do |x|\n sentence = sentence + x.to_s + ' '\n end\n sentence = sentence.chop + \".\"\nend", "def reverberate(sentence)\n new_sentence = []\n\n sentence.split(' ').each do |word|\n if word.length > 2\n new_sentence << reverberated(word)\n else\n new_sentence << word\n end\n end\n new_sentence.join(' ')\nend", "def sentence_maker array\n array = array.join(' ').capitalize << \".\"\n\nend", "def sentence_maker(my_sentence)\n result=my_sentence.join(\" \")\n result=result.capitalize + \".\"\n end", "def translate(word)\r\n vowels = \"aeio\".split('').to_a\r\n consonant = \"bcdfghjklmnpqrstuvwxyz\".split('').to_a \r\n answer = []\r\n \r\n while word.split(' ').length == 1 \r\n words = word.split('')\r\n until vowels.include?(words[0])\r\n words = words.rotate(1)\r\n end\r\n words << \"ay\"\r\n return words.join('')\r\n end # one word ^^\r\n \r\n if word.split(' ').length > 1 \r\n words = word.split(' ')\r\n end \r\n words.each do |i|\r\n if vowels.include?(i[0])\r\n i << \"ay\"\r\n answer << i\r\n #return answer\r\n end\r\n end\r\n \r\n words.each do |j|\r\n if consonant.include?(j[0])\r\n j = j.split('').rotate(1).join('') until vowels.include?(j[0])\r\n j = j + \"ay\"\r\n #return j\r\n #j << j #correct format for 1 consonant but it doesnt add to array\r\n answer << j\r\n end\r\n end\r\n \r\n return answer.join(' ')\r\n end", "def line_generate(length, word_collection, trans_table, prior_prob, bg_trans_table)\n\t\tresult = \"\"\n\t\tresult_arr = Array.new\n\t\tprev = \"\"\n\t\t\tbanned_words = ['of', 'and', 'or', 'for', 'the', 'a', 'to'];\n\n\t\tfor i in 1..length\n\t\t\tif i == 1 then\n\t\t\t\tword = select_word(\"\", prior_prob, bg_trans_table)\n\t\t\telse\n\t\t\t\tif !trans_table.key?(prev) then\n\t\t\t\t\tword = word_collection.to_a.sample\n\t\t\t\telse\n\t\t\t\t\tword = select_word(prev, trans_table[prev], bg_trans_table)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif word.nil? then\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tif word == 'i' then word = 'I' end\n\t\t\tif prev.include?(\".\") then\n\t\t\t\tword = word.capitalize\n\t\t\tend\n\t\t\t#puts \"----------\"\n\t\t\t#puts i\n\t\t\t#puts \"-----------\"\n\t\t\t#puts word\n\t\t\tresult = result + \" \" + word.to_s\n\t\t\tresult_arr.push(word)\n\t\t\tprev = word\n\t\t\tnext\n\t\tend\n\n\t\tif banned_words.include?(prev.downcase) then\n\t\t\tresult.slice!(prev)\n\t\t\tif result_arr.length == 1 then\n\t\t\t\treturn line_generate(length, word_collection, trans_table, prior_prob, bg_trans_table)\n\t\t\tend\n\t\tend\n\n\t\treturn result\n\tend", "def reverse_sentence(my_sentence)\n #1. check if my_sentence even exists\nif my_sentence.nil? || my_sentence == \"\" || my_sentence.length == 0\n return my_sentence\nend\n\n#example input: \"coffee is the best\"\n#output: #output: \"best is the coffee\"\n# 0 1 2 3\n#store into temp array = [\"coffee\", \"is\", \"the\", \"best\"]\n#2. SPLIT SENTENCE, SAVE INTO TEMP ARRAY\n#\\s+ = whitespace\n#\\S+ = everything else not caught by \\s whitespace\ntemp_array = my_sentence.split(/(\\s+|\\S+)/)\n\n#IMPORTANT BUSINESS LOGIC STARTS BELOW\n#make another array for storage = reversed_array = []\nreversed_array = []\n#LOOP, start at lastword = temp array.length - 1\ni = temp_array.length - 1\nwhile i >= 0\n # push word = \"best\" into reversed_array\n reversed_array.push(temp_array[i])\n #decrement \n i -= 1\nend\n\n#JOIN strings from reversed_array\n# ['12','34','35','231'].join(', ')\nreversed_sentence = reversed_array.join(\"\")\n\n#clear the input using mutations http://rubyblog.pro/2017/09/pass-by-value-or-pass-by-reference\nmy_sentence.clear\n\n#use string manipulation\nmy_sentence.concat(reversed_sentence)\n\n#cannot do this because ruby is pass by value and not reference\n#my_sentence = reversed_sentence\nend", "def spinWords(string)\r\n \r\n var= string.split(' ') #[\"Hey\", \"fellow\", \"warriors\"]\r\n finalarry=[]\r\n var.each do |x|\r\n arry= x.split('') \r\n if arry.count >= 5\r\n finalarry << arry.reverse\r\n else\r\n finalarry<< arry\r\n end\r\n\r\n \r\n end\r\n \r\n lastarry=[]\r\n finalarry.each do |y|\r\n lastarry << y.join(\"\")\r\n \r\n end\r\n \r\n result= lastarry\r\n p result.join(' ')\r\n\r\n\r\n \r\n \r\nend", "def translate(arr)\n vowels = %w{a e i o u y}\n consonants = %w{b c d f g h j k l m n p q r s t v w x y z}\n\n a = arr.split.map do |word| \n if vowels.include?(word[0])\n word + \"ay\"\n elsif word[0..1] == \"qu\"\n word[2..-1] + \"quay\"\n elsif word[0..2] == \"sch\"\n word[3..-1] + \"schay\"\n elsif word[0..2] == \"squ\"\n word[3..-1] + \"squay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1]) && consonants.include?(word[2])\n word[3..-1] + word[0..2] + \"ay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1])\n word[2..-1] + word[0..1] + \"ay\"\n elsif consonants.include?(word[0])\n word[1..-1] + word[0] + \"ay\"\n end\n end\n\n a.join(\" \")\nend" ]
[ "0.7606199", "0.7527665", "0.7460629", "0.732658", "0.72713274", "0.72192645", "0.7176786", "0.7175262", "0.7151471", "0.71381116", "0.7120202", "0.7114391", "0.71115905", "0.7086555", "0.7071118", "0.7068294", "0.7064089", "0.7047962", "0.7047962", "0.7047962", "0.7032588", "0.7013313", "0.7006002", "0.7001093", "0.6996176", "0.69875205", "0.69859076", "0.6965187", "0.69539315", "0.6950756", "0.6937874", "0.6930836", "0.69263774", "0.6919879", "0.6912113", "0.6910813", "0.6908683", "0.69061255", "0.6897446", "0.68927985", "0.68849325", "0.6881969", "0.68438756", "0.6840638", "0.6799126", "0.6799126", "0.6796492", "0.6790057", "0.67574596", "0.6752712", "0.6728876", "0.67210954", "0.6710822", "0.6706019", "0.66981906", "0.6687944", "0.6686355", "0.6669522", "0.6650148", "0.6624787", "0.6597233", "0.65679264", "0.6557878", "0.6554927", "0.6534583", "0.65303475", "0.6515151", "0.65067613", "0.6492889", "0.6492889", "0.6485286", "0.6472769", "0.6454571", "0.6454275", "0.6440499", "0.6429414", "0.642728", "0.63997126", "0.63987833", "0.63943374", "0.6391648", "0.6387951", "0.63822913", "0.6380438", "0.63782287", "0.63746655", "0.6330622", "0.6314021", "0.63122576", "0.63095576", "0.6279621", "0.62535", "0.6249736", "0.6210866", "0.62001216", "0.61696815", "0.61690277", "0.6160444", "0.6142929", "0.6137072" ]
0.7441793
3
6. sentence_maker refactored solution
def sentence_maker(arr) string = "" arr.each do |i| string += i.to_s + ' ' end string[-1] = "." return string = string.capitalize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "def generate_sentence\n\n if @array_words.length < 3\n return \"Length of the input_file is too small to produce trigrams\"\n\n # This function results in an error message if there are no capital\n # words or no end of sentence punctutation in the input file.\n elsif (@end_of_sentence_punctutation == 0) or (@sentence_starters.length == 0)\n return \"End of sentence punctuation or sentence starters or both not found in the text!\"\n end\n\n # Based on a random key from the sentence_starters array, which contains\n # all the keys for the hash that start with a capital word a new key is\n # randomly chosen. Words that follow the key are randomly generated\n # based on probilitity. As soon as an end of sentence punctuation is\n # seen the process of generating words that follow a constantly chaging\n # key stops and the sentence is output. Uses the same process to\n # generate following words as the generate_text method. If end of\n # sentence punctutation is found in the starting key, words until the\n # end of sentence punctuation are returned. If the only end of sentence\n # punctuation is found in the first 2 words of the sentence, the program\n # will return an error message.\n key = @sentence_starters.sample\n\n if key.split[0][-1] =~ /[.|!|?]/\n return key.split[0]\n elsif key.split[1][-1] =~ /[.|!|?]/\n return key\n end\n\n sentence = key\n until sentence[-1] =~ /[!|.|?]/ do\n if @trigrams[key] == nil\n key = @trigrams.keys.sample\n end\n\n following_word = @trigrams[key].sample\n sentence += \" #{following_word}\"\n key = \"#{key.split[1]} #{following_word}\"\n \n end\n\n return sentence\n end", "def sentence_maker(my_sentence)\n result=my_sentence.shift\n my_sentence.each { |x| result= result + \" \" + x.to_s }\n result=result + \".\"\n result.capitalize!\n end", "def wookiee_sentence; end", "def wookie_sentence; end", "def sentence_maker(words)\n if words.size != 0\n sentence = \"\"\n for w in 0...words.size\n word = words[w]\n if (word.is_a? String)\n sentence += word + \" \"\n else\n sentence += word.to_s + \" \"\n end\n end\n sentence.chomp!(\" \")\n sentence += \".\"\n sentence.downcase!\n sentence.capitalize!\n return sentence\n end\nend", "def sentence_maker(words)\n\n i = 0\n sentence = ''\n\n while i < words.length\n if i == 0\n sentence = sentence + words[0].to_s.capitalize + ' '\n end\n if i == words.length - 1\n sentence = sentence + words[(words.length - 1)].to_s + '.'\n end\n if (i != words.length - 1) && i != 0\n sentence = sentence + words[i].to_s + ' '\n end\n i += 1\n end\n return sentence\nend", "def sentence_maker(words)\n\tif words.size != 0\n\t\tsentence = \"\"\n\t\tfor w in 0...words.size\n\t\t\tword = words[w]\n\t\t\tif (word.is_a? String)\n\t\t\t\tsentence += word + \" \"\n\t\t\telse\n\t\t\t\tsentence += word.to_s + \" \"\n\t\t\tend\n\t\tend\n\t\tsentence.chomp!(\" \")\n\t\tsentence += \".\"\n\t\tsentence.downcase!\n\t\tsentence.capitalize!\n\t\treturn sentence\n\tend\nend", "def sentence\n\t\t@markov.generate_100_words\n\tend", "def sentence_maker(array_of_strings)\n\t# Declare new sentence variable and set to \"\"\n\tsentence = \"\"\n\t# Capitalize first word in array\n\tarray_of_strings[0].to_s.capitalize!\n\t# For each member of array_of_strings, add to the sentence variable (converting to string)\n\tfor num in 0..(array_of_strings.length - 1)\n\t\t\tsentence += array_of_strings[num].to_s\n\t\t# unless the member of the array is the last member of array_of_strings_, add a space after the word\n\t\tunless num == (array_of_strings.length - 1)\n\t\t\tsentence += \" \"\n\t\tend\n\tend\n\t# End the sentence variable with a period\n\tsentence += \".\"\n\t# Return the sentence variable\n\treturn sentence\nend", "def sentence_maker(string)\n\tsentence = \"\"\n\tstring.each do |word|\n\t\tsentence += word.to_s + \" \"\n\tend\n\treturn full_sentence(sentence)\nend", "def sentence_maker(strings)\n sentance = \"\"\n strings.each do |word|\n sentance += word.to_s + \" \"\n end\n sentance.strip!\n sentance.capitalize + \".\"\n\nend", "def sentence_maker(words)\n sentence = \"\"\n words.each { |word|\n word = word.to_s\n if word == words.first.to_s #cap if word is first in sentence\n sentence << (word.capitalize)\n else\n sentence << word\n end\n\n if word == words.last #period after last word, otherwise space\n sentence << \".\"\n else\n sentence << \" \"\n end\n }\n sentence\nend", "def sentence_maker_refactored(words)\n words.first.capitalize!\n words.join(\" \") + \".\"\nend", "def generate_sentence\n # Splitting into an array is required for easily preventing duplicate vals\n sent = Drama::Constants::SENTENCES.sample.split(/\\s/)\n sent.each do |w|\n num = sent.index(w)\n sent[num] = w % {\n things: Drama::Constants::THINGS.sample,\n sites: Drama::Constants::SITES.sample,\n people: Drama::Constants::PEOPLE.sample,\n says: Drama::Constants::SAYS.sample,\n badsoft: Drama::Constants::BADSOFT.sample,\n function: Drama::Constants::FUNCTIONS.sample,\n adj: Drama::Constants::ADJECTIVES.sample,\n enormous: Drama::Constants::SIZES.sample,\n price: Drama::Constants::PRICES.sample,\n ac1: Drama::Constants::BADVERBS.sample,\n packs: Drama::Constants::PACKS.sample,\n drama: Drama::Constants::DRAMA.sample,\n code: Drama::Constants::CODE.sample,\n ban: Drama::Constants::BANS.sample,\n activates: Drama::Constants::ACTIVATES.sample\n }\n end\n\n # add_a_drama\n sent.join(' ')\n end", "def sentence_maker (strings)\n\njoin_strings = String.new\n\n strings.each { |string| join_strings += \" \" + \"#{string}\"}\n join_strings[0] = \"\"\n join_strings[0] = join_strings[0].capitalize\n return join_strings + \".\"\n\nend", "def yell_sentence(sent)\n\nend", "def process_sentence(msg)\n\n words = msg.split(/\\s+/)\n has_emotion = []\n\n words.each_with_index do |em,i|\n if i > 0 and @emotions.include? em\n has_emotion[i-1] = @emotions.index(em)\n words.delete_at(i)\n end\n end\n\n #msg = msg.sub(/\\b*\\s+\\W\\s+\\b*/,'')\n\n #nouns = get_context(message)\n nouns = @brain.get_topic(msg)\n\n\n\n # Loop through all words, with the index, to access elements properly\n words.each_with_index do |word,i|\n\n word.downcase!\n # We cant pair the first word, because it doesn't follow any word,\n # so instead we pair each word after the first to the previous word\n if i > 0\n\n pair_words(words[i-1],word,{ context: nouns })\n puts \"CALL # #{i}\"\n\n # Pairs emoticons to our newly created pair\n unless has_emotion.at(i) == nil\n @pair_emotion.execute(has_emotion.at(i))\n end\n end\n if i > 1\n tripair_words(words[i-2], words[i-1], word)\n\n unless has_emotion.at(i) == nil\n @tripair_emotion.execute(has_emotion.at(i),has_emotion.at(i))\n end\n end\n end\n end", "def make_sentence parts\n # Join the strings to create a sentence\n # Add spaces after commas and end with a period\n parts.join(' ').gsub(/\\s[,.]/,\" ,\" => \",\", \" .\" => \"\") << \".\"\nend", "def sentence_maker(array)\n sentence = \"\"\n array.each do |x|\n sentence = sentence + x.to_s + \" \"\n end\n\n sentence[0] = sentence[0].upcase\n sentence = sentence.rstrip\n sentence = sentence + \".\"\n return sentence\n\nend", "def sentence_maker(words)\n\tstring = \"\"\n\twords.each do |x|\n\t\tstring = string + x.to_s + \" \"\n\tend\n\treturn string.capitalize.strip + \".\"\nend", "def typoglycemiaSentence(input)\n words = input.split(' ')\n words.map! { |x| typoglycemiaWord(x) }\n words.join(\" \")\nend", "def sentence_maker(strings)\n concat = \"\"\n strings.each do |n|\n concat << n.to_s + \"\"\n concat = concat.chomp(\" \") << \".\"\n end\n return concat.capitlize\nend", "def sentence; end", "def get_words\n @sentences.each_index do |i|\n s = @sentences[i]\n words = s.split(' ')\n words.each do |w|\n word = w.gsub(WORD_SANITIZE, '').downcase\n if belongs_to_known_abbreviations? word\n add_word_to_result(word, i)\n else\n add_word_to_result(word.gsub(DOT_SANITIZE, ''), i)\n end\n end\n end\n end", "def sentence_maker(x)\n\tx.join(\" \")\nend", "def test_String_003_ToSentence\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_String_003_ToSentence\")\n puts2(\"#######################\")\n \n \n puts2(\"\\nA specific string...\")\n sString = \"oNCE UPON a time Long ago and far away\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n \n puts2(\"\\nFour sets of 2 pseudo words as sentences...\")\n 4.times {\n sString = random_pseudowords(2,10)\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n puts2(\"\\nTwo sets of 3 pseudo words ending in a period as sentences...\")\n 2.times {\n sString = random_pseudowords(3,10) + \".\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n puts2(\"\\nTwo sets of 4 pseudo words ending in a exclamation point as sentences...\")\n 2.times {\n sString = random_pseudowords(4,10) + \"!\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n puts2(\"\\nTwo sets of 5 pseudo words ending in a question mark as sentences...\")\n 2.times {\n sString = random_pseudowords(5,10) + \"?\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n end", "def sentence(word_count: T.unsafe(nil), random_words_to_add: T.unsafe(nil), open_compounds_allowed: T.unsafe(nil)); end", "def sentence_maker(words)\n sentence = ''\n words[0].capitalize!\n words.each do |x|\n sentence = sentence + x.to_s + ' '\n end\n sentence = sentence.chop + \".\"\nend", "def sentence_maker(array)\n str_array = array.collect{|i| i.to_s} #collect method returns entire array or hash; we are converting all elements of array into string\n sentence = array[0] #converts first element of array into new array\n sentence[0] = str_array[0][0].upcase #makes first letter uppercase\n str_array.shift\n\tstr_array.each { |i| sentence = sentence + \" \" + i.to_s}\n\treturn sentence + \".\"\nend", "def sentence_maker(my_sentence)\n result=my_sentence.join(\" \")\n result=result.capitalize + \".\"\n end", "def sentence(word_count: T.unsafe(nil), supplemental: T.unsafe(nil), random_words_to_add: T.unsafe(nil), open_compounds_allowed: T.unsafe(nil)); end", "def sentence_maker(array_of_strings)\n result = \"\"\n last_word = array_of_strings.pop\n array_of_strings.each do |word|\n result += word.to_s + \" \"\n end\n result += last_word + \".\"\n return result.capitalize!\nend", "def word_yeller(sentence)\n\n\nend", "def sentence_maker(words)\r\n\tsentence = ''\r\n\ti = 0\r\n\r\n\twhile i < words.length\r\n\t\tif i == 0 \r\n\t\t\tsentence = sentence + words[i].to_s.capitalize + ' '\r\n\t\t\ti += 1\r\n\t\telsif i == (words.length - 1)\r\n\t\t\tsentence = sentence + words[i].to_s + '.'\r\n\t\t\ti += 1\r\n\t\telse\r\n\t\t\tsentence = sentence + words[i].to_s + ' '\r\n\t\t\ti += 1\r\n\t\tend\r\n\tend\r\n\tp sentence\r\nend", "def sentence_maker(strings)\n\n new_string = strings[0]\n i = 1\n while i < strings.length\n new_string = new_string + \" \" + strings[i].to_s\n i += 1\n end\n new_string = new_string + \".\"\n return new_string.capitalize\nend", "def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend", "def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend", "def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend", "def generate_sentence(sentencecount, that_starts_with: nil)\n if @dictionary.dictionary.empty?\n raise EmptyDictionaryError.new(\"The dictionary is empty! Parse a source file/string!\")\n end\n sentence = []\n # Find out how many actual keys are in the dictionary.\n key_count = @dictionary.dictionary.keys.length\n # If less than 30 keys, use that plus five as your maximum sentence length.\n maximum_length = key_count < 30 ? key_count + 5 : 30\n sentencecount.times do\n wordcount = 0\n if that_starts_with.nil?\n sentence.concat(random_capitalized_word)\n else\n sentence.concat(that_starts_with)\n if weighted_random(sentence.last(@depth)).nil?\n last_word_is_prefix = entries_starting_with(sentence.last)\n if last_word_is_prefix.empty?\n sentence.concat(random_word)\n else\n sentence.concat(last_word_is_prefix.sample[1..-1])\n end\n end\n end\n\n until (punctuation?(sentence.last[-1])) || wordcount > maximum_length\n wordcount += 1\n word = weighted_random(sentence.last(@depth))\n if punctuation?(word)\n sentence[-1] = sentence.last.dup << word\n else\n sentence << word\n end\n end\n end\n sentence.join(' ')\n end", "def make_sentence parts\n index = 1\n parts.delete('.')\n string = parts.join(' ') + '.'\n if string.include?(\" ,\")\n string.gsub!(\" ,\", \",\")\n end\n string\nend", "def sentence_maker(sentence)\n sentence[0] = sentence[0].capitalize\n sentence.join(\" \") + \".\"\nend", "def get_sentences\n # Get initial letters of sentences.\n initial_letters = @text.scan(SENTENCE_DELIMITER).map {|i| i[-1]}\n # Get sentences by splitting text with the pattern. \n # Sentences from index 1 to end are without initial letters.\n @sentences = @text.split(SENTENCE_DELIMITER)\n # Add the initial letters back to the sentences.\n (1...@sentences.length).each do |i|\n @sentences[i] = initial_letters[i - 1] + @sentences[i]\n end\n end", "def generate_sentence\n current_words = Array.new(depth)\n sentence_array = []\n loop do\n new_word = current_words.last\n sentence_array.push new_word if new_word\n break if end_word?(new_word)\n next_word_options = @dictionary[current_words]\n if next_word_options.empty? && !end_word?(new_word)\n new_word.concat('.')\n break\n end\n next_word = next_word_options.sample\n current_words.push next_word\n current_words.shift\n end\n sentence_array.join(' ')\n end", "def translate(sentence)\n #we .split that sentence. Because we do not give a limit, the sentence is automaticly split along the spaces.\n #we .map the result of the .split to make every word in the array a variable= word.\n sentence.split.map do |word|\n #We define what the first vowel of the word is by a different method (first_vowel) and assign it as variable v\n v = first_vowel(word)\n # we slice of the first vowel and the letter preceding that. then we add the first letter of the word at the end, and add +ay\n word.slice(v..-1) + word[0,v] + \"ay\"\n #We end the function and join the retunring array with spaces in between.\n end.join(\" \")\n end", "def sentence_maker ( strArray )\r\n\r\n\tanswer = ''\r\n\r\n\tstrArray.each do |thisStr|\r\n\t\tanswer += thisStr.to_s + ' '\r\n\tend\r\n\r\n\tanswer.slice!(answer.length-1)\r\n\r\n\tanswer += '.'\r\n\r\n\treturn answer.capitalize!\r\n\r\nend", "def reflect(sentence)\n # TODO\nend", "def sentence_maker(words)\n sentence = \"\"\n words.each { |word| sentence << word.to_s + \" \"}\n sentence = sentence.chomp(\" \") << \".\"\n return sentence.capitalize\nend", "def sentence_maker(word_array)\n\tsentence = word_array.join(\" \")\n\treturn sentence.capitalize + \".\"\nend", "def sentence_maker(array)\n sentence = array[0].capitalize\n for w in 1...array.length\n sentence = sentence + \" \" + array[w].to_s\n end\n return sentence + \".\"\nend", "def each \n if @array_words.length < 3\n return \"Length of the input_file is too small to produce trigrams\"\n end\n \n sentence = generate_sentence\n 0.upto(sentence.split.length - 1) do |x|\n yield sentence.split[x]\n end\n return sentence\n end", "def sentence_maker(arr)\n string = \"\"\n i = 1\n while i < arr.length-1\n string += arr[i].to_s + ' '\n i+=1\n end\n sentence = arr[0].capitalize! + \" \" + string + arr[-1] + \".\"\n return sentence\nend", "def split_sentences\n #break text first by paragraph then into chunks delimited by a period\n #but these are not quite sentences yet\n chunks = (self.split(/\\n+/).map { |p| \"#{p}\\n\".split(/\\.(?:[^\\w])/) }).flatten.compact\n \n #if a sentence is split at Mr.|Ms.|Dr.|Mrs. \n #then recombine it with its remaining part and nil it to delete later\n tmp=''\n sentences = chunks.map { |c|\n ss = (tmp != '')? \"#{tmp}. #{c}\" : c\n if c.match(/(?:Dr|Mr|Ms|Mrs)$/) #what about John F. Kennedy ([A-Z])\n tmp = ss\n ss=nil\n else\n tmp = ''\n end\n ss\n } \n sentences.compact #delete nil elements\n end", "def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_array.each do |string|\n if string != string_array[-1]\n new_string += string.to_s + \" \"\n else\n new_string += string.to_s\n end\n \n new_array.push(new_string)\nend\nreturn new_array[-1].capitalize + \".\"\nend", "def sentence_maker(a_single_argument)\n items = a_single_argument.count.to_i\n output = a_single_argument.values_at(0..(items-1)).join(\" \").capitalize\n return output + \".\"\nend", "def a_turn_of_phrase(sentence)\n # code goes here\nend", "def tokenize(sentence_text)\n\n if sentence_text.nil? or sentence_text.length < 1\n raise ArgumentError.new \"Tried to tokenize invalid text for Sentence %d\" % self.id\n end\n\n words_list, notwords_list = separate_words_from_nonword_characters(sentence_text)\n\n find_or_create_words_in(words_list)\n\n # do this one last because it destroys the arrays (via shift)\n create_word_template!(words_list, notwords_list)\n\n raise AssertionError \"Sentence didn't create word template!\" unless defined?(self.word_template) && (self.word_template != '')\n\n self.save\n end", "def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words += element.to_s + \" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend", "def sentence_maker(words)\n return words.join(\" \").capitalize << \".\"\nend", "def paragraph(\n word_count: rand(DEFAULT_WORD_COUNT_RANGE),\n sentence_count: rand(DEFAULT_SENTENCE_COUNT_RANGE),\n fillers: dictionnary.fillers\n )\n sentence_count = 0 if sentence_count.negative?\n paragraph = []\n sentence_count.times do\n s = sentence(word_count: word_count, fillers: fillers)\n paragraph << s unless s.empty?\n end\n paragraph.join(' ')\n end", "def sentence_maker(strings)\n return strings.join(' ').capitalize + '.'\nend", "def sentence_maker(words)\n words = words.join(' ').capitalize + \".\"\nend", "def valid_sentence(string, dictionary)\n #Create a global variable to be able to access throughout\n $process = {}\n final_sentences = []\n sentences(string, dictionary).each do |array|\n set = array.split(\" \")\n if dictionary_words?(set) && verb_present?(set) && noun_articles_present?(set)\n final_sentences << array\n end\n end\n final_sentences.sort!\n end", "def reverberate(sentence)\n new_sentence = []\n\n sentence.split(' ').each do |word|\n if word.length > 2\n new_sentence << reverberated(word)\n else\n new_sentence << word\n end\n end\n new_sentence.join(' ')\nend", "def sentence_maker (array)\n sentence = \"\"\n array.each do |i|\n sentence = sentence + i.to_s + \" \"\n end\n sentence = sentence.capitalize.chop + \".\"\nend", "def sentence_maker(arraystring)\n fullsentence = ''\n length_of_arraystring = arraystring.length\n current_index_of_array = 0\n while current_index_of_array < length_of_arraystring\n if current_index_of_array == 0\n word = arraystring[current_index_of_array].to_s.capitalize\n fullsentence = fullsentence + word + ' '\n\n elsif current_index_of_array == length_of_arraystring - 1\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + '.'\n else\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + ' '\n end\n current_index_of_array = current_index_of_array + 1\n\n end\n# puts fullsentence\n return fullsentence\nend", "def sentence_maker(array)\n combination = \"\"\n array[0].capitalize!\n array.each {|x| combination = combination + x.to_s + \" \"}\n combination.rstrip!\n combination = combination + \".\"\n return combination\nend", "def sentence_maker(a)\n\ta[0] = a[0].capitalize\n\tstring = a.join(\" \")+\".\"\n\treturn string\nend", "def get_sentences(html)\n # var html = (typeof el==\"string\") ? el : el.innerHTML;\n\n # exclusion lists\n mrsList = \"Mr,Ms,Mrs,Miss,Msr,Dr,Gov,Pres,Sen,Prof,Gen,Rep,St,Messrs,Col,Sr,Jf,Ph,Sgt,Mgr,Fr,Rev,No,Jr,Snr\"\n topList = \"A,B,C,D,E,F,G,H,I,J,K,L,M,m,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,etc,oz,cf,viz,sc,ca,Ave,St\"\n geoList = \"Calif,Mass,Penn,AK,AL,AR,AS,AZ,CA,CO,CT,DC,DE,FL,FM,GA,GU,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MH,MI,MN,MO,MP,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,PW,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY,AE,AA,AP,NYC,GB,IRL,IE,UK,GB,FR\"\n numList = \"0,1,2,3,4,5,6,7,8,9\"\n webList = \"aero,asia,biz,cat,com,coop,edu,gov,info,int,jobs,mil,mobi,museum,name,net,org,pro,tel,travel,xxx\"\n extList = \"www\"\n d = \"__DOT__\"\n\n # cleanup \".\" that should not be used for sentence splitting\n list = (topList+\",\"+geoList+\",\"+numList+\",\"+extList)\n # html = html.replace(new RegExp((\" \"+list[i]+\"\\\\.\"), \"g\"), (\" \"+list[i]+d))\n regexp = Regexp.new \" (#{list.gsub(/,/,\"|\")})\\\\.\"\n html = html.gsub(regexp){|match| \" #{match}#{d}\"}\n # puts regexp.inspect\n\n list = (mrsList+\",\"+numList)\n # html = html.replace(new RegExp((list[i]+\"\\\\.\"), \"g\"), (list[i]+d))\n regexp = Regexp.new \"(#{list.gsub(/,/,\"|\")})\\\\.\"\n html = html.gsub(regexp){|match| \"#{match}#{d}\"}\n\n list = webList\n # html = html.replace(new RegExp((\"\\\\.\"+list[i]), \"g\"), (d+list[i]))\n regexp = Regexp.new \"\\\\.(#{list.gsub(/,/,\"|\")})\"\n html = html.gsub(regexp){|match| \"#{d}#{match}\"}\n\n # split sentences\n lines = clean_array(html.split('. '))\n return lines\n end", "def sentence_maker (array)\n\tindex = 0\n\twhile index < array.length\n\t\tif index == 0\n\t\t\tsentence = array[index].to_s.capitalize\n\t\telse \n\t\t\tsentence = sentence + \" \" + array[index].to_s\n\t\tend\n\t\tindex += 1\n\tend\n\tsentence = sentence + \".\"\n\treturn sentence \nend", "def sentence_maker arr\n catenated_str = ''\n space = ' '\n i = 0\n\n arr.each do |el|\n catenated_str += i == 0 ? el.capitalize.to_s : i == (arr.length - 1) ? space + el.to_s + '.' : space + el.to_s\n i+=1\n end\n catenated_str\nend", "def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words+=element.to_s+\" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend", "def sentence_maker(string)\n\tstring[0] = string[0].capitalize\n\tphrase = ''\n\tstring.each do |word|\n\t\tphrase = phrase + word.to_s + ' '\n\tend\n\tphrase = phrase.chop\n\tphrase = phrase + '.'\n\treturn phrase\nend", "def catch_phrase\n [\n [\"ninja\",\"master\",\"student\"].rand, \n [\"\", \"\", \"\", \"\", \"\", \"\", \"weapons\", \"s' 3rd annual\",\"s' 5th annual\",\"s' 10th annual\", \"s' secret\"].rand,\n [\"gathering\",\"celebration\",\"meeting\",\"tournament\",\"competition\",\"party\",\"training camp\",\"sparring event\"].rand,\n [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"with Leonardo\", \"with Raphael\", \"with Michaelangelo\", \"with Donatello\"].rand\n ].join(' ').gsub(/ s\\'/,'s\\'').gsub(/\\s\\s/,' ').strip\n end", "def line_generate(length, word_collection, trans_table, prior_prob, bg_trans_table)\n\t\tresult = \"\"\n\t\tresult_arr = Array.new\n\t\tprev = \"\"\n\t\t\tbanned_words = ['of', 'and', 'or', 'for', 'the', 'a', 'to'];\n\n\t\tfor i in 1..length\n\t\t\tif i == 1 then\n\t\t\t\tword = select_word(\"\", prior_prob, bg_trans_table)\n\t\t\telse\n\t\t\t\tif !trans_table.key?(prev) then\n\t\t\t\t\tword = word_collection.to_a.sample\n\t\t\t\telse\n\t\t\t\t\tword = select_word(prev, trans_table[prev], bg_trans_table)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif word.nil? then\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tif word == 'i' then word = 'I' end\n\t\t\tif prev.include?(\".\") then\n\t\t\t\tword = word.capitalize\n\t\t\tend\n\t\t\t#puts \"----------\"\n\t\t\t#puts i\n\t\t\t#puts \"-----------\"\n\t\t\t#puts word\n\t\t\tresult = result + \" \" + word.to_s\n\t\t\tresult_arr.push(word)\n\t\t\tprev = word\n\t\t\tnext\n\t\tend\n\n\t\tif banned_words.include?(prev.downcase) then\n\t\t\tresult.slice!(prev)\n\t\t\tif result_arr.length == 1 then\n\t\t\t\treturn line_generate(length, word_collection, trans_table, prior_prob, bg_trans_table)\n\t\t\tend\n\t\tend\n\n\t\treturn result\n\tend", "def abbreviate_sentence(sent)\r\n words = sent.split(\" \")\r\n new_words = []\r\n\r\n words.each do |word|\r\n if word.length > 4\r\n new_word = abbreviate_word(word)\r\n new_words << new_word\r\n else\r\n new_words << word\r\n end\r\n end\r\n\r\n return new_words.join(\" \")\r\nend", "def sentence_maker(array)\n\tcomplete = \"\"\n\tarray.each do |i|\n\t\tcomplete = complete + i.to_s + \" \"\n\tend\n\tcomplete.insert(-2, \".\")\n\treturn complete.strip.capitalize\nend", "def sentences(total)\n (1..interpret_value(total)).map do\n words(5..20).capitalize\n end.join('. ')\n end", "def sentence_maker(array)\n combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\nend", "def valid_sentence(str, dictionary)\n $processing = {}\n final_result = []\n sentences(str, dictionary).each do |a|\n set = a.split(\" \")\n if all_words_valid?(set) && verb_correct?(set) && noun_articles_correct?(set)\n final_result << a\n end\n end\n final_result.sort! #This can be returned without any sort but it added because it looks cool.\n end", "def sentence_maker(array)\n\tarray[0].capitalize!\n\tfinalString = array.join(' ')\n\tfinalString = finalString + '.'\nend", "def sentence_maker(words)\n\twords.join(\" \").capitalize << \".\"\nend", "def sentence_maker(a_single_argument)\n output = a_single_argument.join(\" \")\n output += \".\"\n return output.capitalize!\nend", "def sentence_maker(array_of_strings)\n sentence = array_of_strings[0].capitalize\n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n sentence + \".\"\nend", "def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\n\t\twhile x < (array.length - 1)\n\t\t\tsum += array[x].concat \" \" \n\t\t\tx += 1\n\t\tend \n\t\t\tsum += array[x].concat \".\" \n\treturn sum\n\nend", "def sentence_maker(array)\n\ti = 0\n\twhile i < array.length do\n\t\tif i == 0\n\t\t\tsentence = (array[i].capitalize.to_s + \" \")\n\t\telsif i == array.length-1\n\t\t\tsentence = sentence + (array[i].to_s + \".\") \n\t\telse\n\t\t\tsentence = sentence + (array[i].to_s + \" \")\n\t\tend\n\t\ti += 1\n\tend\n\treturn sentence\nend", "def to_sentences(paragraph)\n\n#---------------- Step 1: Break up paragraph into pieces based on punctuation. \n\n\told_sentences = paragraph.split(/(?<=\\.\"|\\.\\)|\\.)(?<!\\.\\s\\.|\\.\\s\\.\"|\\.\\s\\.\\))\\s(?!\\.)|(?<=\\.\\s\\.\\s\\.\\s\\.\"|\\.\\s\\.\\s\\.\\s\\.\\)|\\.\\s\\.\\s\\.\\s\\.)\\s/)\n\t\t\t\t\t\t\t\t\t\t# splits on space in two cases: 1. if preceded by exactly one dot, possibly followed by ) or \"\n\t\t\t\t\t\t\t\t\t\t# 2. if preceded by four dots, possibly followed by ) or \" \n\t\t\t\t\t\t\t\t\t\t# (exactly one dot before SPLIT no dot after) OR (four dots before SPLIT)\n\n\t\n#---------------- Step 2: Re-join some pieces so that embedded quotes and parenthetical remarks aren't broken.\n\n \tnew_sentences = []\n\told_count = 0\t\t\t\t\t\t# position in old array built in Step 1\n\tnew_count = 0\t\t\t\t\t\t# position in new array built now in Step 2\n\t\t\n\twhile old_count < old_sentences.length\n\t\t\t\t\t\t\t\t\t\t# each step in outer while loop adds a new element to new_sentences\n\t\tskip = 0\t\t\t\t\t\t# skip keeps track of how many elements of old_sentences are used\n\t\tnew_sentences[new_count] = old_sentences[old_count]\n\n\t\twhile old_count + skip < old_sentences.length and (new_sentences[new_count].count('\"')%2 == 1 or new_sentences[new_count].count('(') != new_sentences[new_count].count(')'))\n\t\t\t\t\t\t\t\t\t\t# each step in inner while loop checks last element of new_sentences for mismatched quotes or parentheses, ...\t\t\t\t\t\t\t\t\t\t\n\n\t\t\tif new_sentences[new_count].count(')') > new_sentences[new_count].count('(')\n\t\t\t\told_sentences[old_count] = old_sentences[old_count].sub!(/\\)/, \"\")\n\t\t\t\tbreak\n\t\t\tend\t\t\t\t\t\t\t# ... if there's a mismatched right parenthesis, deletes it, ...\n\n\t\t\tif old_count + skip + 1 == old_sentences.length and (new_sentences[new_count].count('(') > new_sentences[new_count].count(')'))\n\t\t\t\told_sentences[old_count] = old_sentences[old_count].sub!(/\\(/, \"\")\n\t\t\t\tskip = -1\n\t\t\t\tnew_count -= 1\n\t\t\t\tbreak\t\t\t\t\t# ... if there's a mismatched left parenthesis or quote,\n\t\t\tend\t\t\t\t\t\t\t# joins next element of old_sentences to current new_sentence, unless\n\t\t\t\t\t\t\t\t\t\t# reach end of paragraph with mismatch; then deletes mismatched ( or ',\n\t\t\t\t\t\t\t\t\t\t# not joining subsequent elements of old_sentences to current new_sentence.\n\t\t\tskip += 1\n\t\t\tnew_sentences[new_count] = new_sentences[new_count] + \" \" + old_sentences[old_count + skip]\t\t\t\n\t\tend\n\n\t\tnew_count += 1\t\t\n\t\told_count += skip + 1\n\tend\n\n\n#---------------- Step 3: Make sure each piece starts and ends with a single quote.\n\n\tsentences_with_quotes = []\n\tnew_sentences.each do |x|\n\t\tx = x.chomp\n\t\tx = \"'\"+x if x[0] != \"'\"\n\t\tx = x+\"'\" if x[x.length-1] != \"'\"\n\t\tsentences_with_quotes << x\n\tend\n\n\treturn sentences_with_quotes\n\nend", "def abbreviate_sentence(sent)\n words = sent.split(\" \")\n new_words = []\n \n words.each do |word|\n if word.length > 4\n new_word = abbreviate_word(word)\n new_words << new_word\n else\n new_words << word\n end\n end\n \n return new_words.join(\" \")\n end", "def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\tsentence += \".\"\n\treturn sentence\nend", "def words_typing(sentence, rows, cols)\n i = 0\n remaining_cols = cols\n res = \"\"\n until rows == 0\n word_length = sentence[i % sentence.length].length\n if word_length <= remaining_cols\n remaining_cols == word_length ? res += sentence[i % sentence.length] + \"|\" : res += sentence[i % sentence.length] + \"-\"\n i += 1 #next word\n remaining_cols -= (word_length + 1)\n else\n rows -= 1\n remaining_cols = cols\n end\n p [\"res\", res]\n end\n\n i / sentence.length\nend", "def translate(sentence)\r\n words = sentence.split(\" \")\r\n words.collect! do |a|\r\n if(a =~ /\\w\\.\\.\\.\\w/) #matching e.g \"yes...no\"\r\n morewords = a.split(\"...\")\r\n ##\r\n #alternative: allows for recursion, but loses accuracy since \"a...b\" becomes \"a ... b\"\r\n #probably some non-messy way to make it work, and be less redundant too\r\n #\r\n #morewords.insert(1, \"...\")\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + \"...\" + pig(morewords[1], 1)\r\n elsif(a =~ /\\w\\W\\w/ and !(a =~ /'/)) #matching e.g. \"steins;gate\", \"ninety-nine\", but not \"it's\"\r\n nonletter = a.scan(/\\W/)[0]\r\n morewords = a.split(/\\W/)\r\n #morewords.insert(1, nonletter)\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + nonletter + pig(morewords[1], 1)\r\n elsif(a[0..1].match(/qu/)) #quiet = ietquay\r\n pig(a, 2)\r\n elsif(a[0..2].match(/sch|.qu/)) #school = oolschay, square = aresquay\r\n pig(a, 3)\r\n else\r\n x = a.index(/[AaEeIiOoUu]/) #starts with other consonant(s) or a vowel; find the first vowel\r\n if(!(x.nil?)) #found at least one vowel\r\n pig(a, x) \r\n else #x is nil, no vowels found\r\n a.index(/[[:alpha:]]/) ? pig(a, 1) : a #if it contains letters, attempt to process; otherwise, do nothing\r\n end\r\n end\r\n end\r\n return words.join(\" \")\r\nend", "def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence = sentence.to_s.capitalize + \".\"\nend", "def sentence_maker (arr)\n sentence = \"\"\n arr[0] = arr[0].capitalize\n for i in 0...arr.length-1\n sentence = sentence + arr[i].to_s + \" \"\n end\n return sentence + arr[arr.length-1] + \".\"\nend", "def translator\n # Greet your user in the language of their people.\n puts [\"SUP KID? \",\n \t \"What didja say? \",\n \t \"How ya doan? \",\n \t \"How ahrya?\",\n \t \"How 'bout them Sox? \",\n \t \"How 'bout them Pats? \"].sample\n\n # Get their response and lop off the carriage return, Massachusetts Left style.\n phrase = gets.chomp.to_s\n\n # Now we're going to award the user points based on density of Boston-specific\n # diction, aka their Beantown Points(tm).\n i = 0\n beantown_points = 0\n wicked_boston_words = [\"bubblah\",\n \"wicked\",\n \"reveah\",\n \"the dot\",\n \"medfid\",\n \"broons\",\n \"barrel\",\n \"digga\",\n \"southie\",\n \"eastie\",\n \"rotary\",\n \"pissah\",\n \"jp\",\n \"fried\",\n \"directional\",\n \"beantown\",\n \"red sox\",\n \"common\",\n \"dunkin donuts\",\n \"patriots\",\n \"celtics\",\n \"green monster\",\n \"dirty watah\",\n \"packie\"\n ]\n\n searchable_phrase = phrase.downcase\n\n wicked_boston_words.each do |i|\n \tif searchable_phrase.include?(i)\n \t\tbeantown_points += 1\n \tend\n end\n\n ########################################################################################################\n # A-Z dictionary of specific gsubs for targeted replacement. This is about to get wicked awesome, bro! #\n ########################################################################################################\n\n # A\n phrase.gsub!(/\\bacross the rivah?\\b/i, 'on the other side of the Charles River') # across the rivah (other side of the charles)\n phrase.gsub!(/\\b(a)dvahtisin'?g?\\b/i, '\\1dvertising') # advahtisin'(g)\n phrase.gsub!(/\\b(a)dvisah?\\b/i, '\\1dviser') # advisah\n phrase.gsub!(/\\b(a)doah\\b/i, '\\1dore') # adoah\n phrase.gsub!(/(a)ftah/i, '\\1fter') # aftah (aftahwahds, raftah, & other containing words)\n phrase.gsub!(/\\bah(h)?(?=\\s[a-z]+in('|g))?\\b/i, 'are') # ah (usually \"are\" if a word ending in \"ing is after\")\n phrase.gsub!(/\\b(the)? Ahbs\\b/i, '\\1 Arboretum') # the ahbs is a fun place to hang out\n phrase.gsub!(/\\b(a)hm\\b/i, '\\1rm') # curt schilling's gotta good ahm\n phrase.gsub!(/(f|w|h|al|ch|fore)ahm(s?)/i, '\\1arm\\2') # ahm at the end of words\n phrase.gsub!(/\\bahr\\b/i, 'are') # ahr\n phrase.gsub!(/\\bahrya\\b/i, 'are you') # how ahrya?!\n phrase.gsub!(/\\b(a)hnt\\b/i, '\\1unt') # ya ahnt is comin' to Christmas\n phrase.gsub!(/\\ball set\\b/i, 'all done') # all set with my dinnah, thank you\n phrase.gsub!(/\\bAllston Christmas\\b/i, 'The last weekend in August when all the students move out and leave their furniture behind in Allston') # Gonna need a biggah cah\n phrase.gsub!(/\\b(a)mbassad(oah|ah)(s)/i, '\\1ambassad\\2\\3') # ambassadoah/dah\n\n # B\n phrase.gsub!(/\\b(b)ah\\b/i, '\\1ar') # bah (let's get a beeah at the bah)\n phrase.gsub!(/\\b(cross|crow|de|dis|draw|handle|iso|sand|side)bah(s)\\b/i, '\\1bar\\2') # \"bah\" (words ending in bah)\n phrase.gsub!(/\\bbahnie\\b/i, 'smart geek') # bahnie\n phrase.gsub!(/\\bbang a left\\b/i, 'take a left') # bang a left...but do it before the oncoming turns green!\n phrase.gsub!(/\\b(b)ankin/i, 'hillside') # watch the game from the bankin\n phrase.gsub!(/\\bbarrel/i, 'trash can') # throw that yankees jersey in the barrel\n phrase.gsub!(/\\bbazo\\b/i, 'drunk') # bazo on the weekendddd\n phrase.gsub!(/\\bbeantown\\b/i, 'Boston') # beantown\n phrase.gsub!(/\\b(b)eeah(s)?\\b/i, '\\1eer') # lemme buy ya a beeah (sam adams please)\n phrase.gsub!(/\\b(b)ettah\\b/i, '\\1etter') # bettah (than you)\n phrase.gsub!(/\\bbig(-|\\s)ball bowling?/i, '10-pin bowling') # big ball bowlin'\n phrase.gsub!(/\\bBig Dig\\b/i, 'the most expensive highway project in U.S. History') # the big dig, depress that central ahtery\n phrase.gsub!(/\\bb(ill-)?ricka/i, 'Billerica') # Billerica\n phrase.gsub!(/\\bboahded\\b/i, 'dibs') # boahded\n phrase.gsub!(/\\bbobos\\b/i, 'boat shoes') # bobos\n phrase.gsub!(/\\bBostonian\\b/i, 'resident of Boston') # Bostonian\n phrase.gsub!(/\\bbook(ed|in)? outta theah\\b/i, 'took off') # bookin' it\n phrase.gsub!(/\\b(b)r(a|u)h\\b/i, '\\1ro') # brah/bruh\n phrase.gsub!(/\\bbrahmin\\b/i, 'WASP-y type') # Brahmin\n phrase.gsub!(/\\bbreakdown lane\\b/i, 'highway shoulder') # breakdown lane at rush hoah, jeez\n phrase.gsub!(/\\bBroons\\b/i, 'Bruins') # Da Broons!\n phrase.gsub!(/\\bbubblah\\b/i, 'water fountain') # bubblah\n\n # C\n phrase.gsub!(/\\b(c)ahds\\b/i, '\\1ards') # cahds\n phrase.gsub!(/\\b(c|ced|chedd|sc|sidec|tramc|supahc|vic)ah(s)?\\b/i, '\\1ar\\2') # cah(s) and 6 containing words that are most common.\n phrase.gsub!(/\\b(c)alendah(s)?\\b/i, '\\1alendar\\2') # calendah (the sawx got theyah openin' day on theah!)\n phrase.gsub!(/\\bcalm ya liva(a|h)?/i, 'relax') # calm ya livah, I didn't eat ya dinnah\n phrase.gsub!(/\\b(c)an't get\\b/i, '\\1an get') # can't get (no satifaction...but plenty of double negatives up for grabs, so)\n phrase.gsub!(/\\bThe Cape\\b/i, 'Cape Code, Massachusetts') # goin' to the Cape this summah\n phrase.gsub!(/\\bcarriage\\b/i, 'grocery cart') # carriage (for ya lobstahs and beeahs)\n phrase.gsub!(/\\b(c)awna\\b/i, '\\1orner') # coolidge cawna\n phrase.gsub!(/\\b(c)ella(h)\\b?/i, 'basement') # go down cella\n phrase.gsub!(/\\b(c)howdah\\b/i, '\\1howder') # chowdah (clam or lobstah, take ya pick at sullivan's!)\n phrase.gsub!(/\\b(coffee|small|medium|lahge) regulah\\b/i, 'coffee with cream and two sugars') # coffee, regulah\n phrase.gsub!(/\\bCochihchewit\\b/i, 'Cochituate') # Co-CHIH-chew-it\n phrase.gsub!(/\\b(c)onsidah\\b/i, '\\1onsider') # considah\n phrase.gsub!(/\\b(c)orridoah(s)\\b/i, '\\1orridor\\2') # corridor\n phrase.gsub!(/\\b(c)umbie(s|'s)/i, 'Cumberland Farms Mini-Mart') # cumbie's\n\n # D\n phrase.gsub!(/\\b(Mon|Tues|Wed|Thurs|Fri|Sun)diz/i, '\\1days') # plural days of the week, less Saturday which can have a couple pronunciations\n phrase.gsub!(/\\b(d)ecoah\\b/i, '\\1ecor') # decoah (in ya apahtment!) -- most frequently used word ending in \"cor\"\n phrase.gsub!(/\\bdecked\\b/i, 'punched') # he got decked at the sox game\n phrase.gsub!(/\\bdecked\\sout\\b/i, 'dressed up') # he's all decked out for his date!\n phrase.gsub!(/\\b(d)idja\\b/i, '\\1id you') # didja\n phrase.gsub!(/\\bdirty watah\\b/i, 'the Charles River') # love that dirty watah\n phrase.gsub!(/\\bdiggah?\\b/i, 'fall') # fell on some ice and took a diggah\n phrase.gsub!(/\\b(d|fl|ind|p|outd)oah\\b/i, '\\1oor') # oah words ending in oor\n phrase.gsub!(/\\b(direc|doc)tah\\b/i, '\\1tor') # doctah/directah\n phrase.gsub!(/\\bdirectional\\b/i, 'turn signal') # put on ya directional before you take turn\n phrase.gsub!(/\\bDot Ave\\b/i, 'Dorchester Avenue') # Dot Ave\n phrase.gsub!(/\\bDot Rat(s)?/i, 'resident\\1 of Dorchester') # Dot Rats\n phrase.gsub!(/\\bthe Dot\\b/i, 'Dorchester') # the dot\n phrase.gsub!(/\\bdunki(n'?s'?|n|es)(\\sdonuts)?\\b/i, 'Dunkin\\' Donuts') # dunkies, dunkins, dunkin, dunkin's, & dunkin's!\n phrase.gsub!(/\\bdrawring\\b/i, 'drawing') # drawring\n\n # E\n phrase.gsub!(/\\bEastie\\b/i, 'East Boston') # Eastie\n phrase.gsub!(/\\belastic(s)?\\b/i, 'rubber band\\1') # elastics\n phrase.gsub!(/(e)ntah\\b/i, '\\1nter') # entah (come in heah!)\n phrase.gsub!(/\\b(e)ntiah\\b/i, 'entire') # entiah (I've lived in Boston my entiah life)\n phrase.gsub!(/(n)?(e)vah\\b/i, '\\1\\2ver') # evah (or forevahevah! or nevah. that too.)\n\n # F\n phrase.gsub!(/\\bfahr\\b/i, 'for') # fahr (ready fahr spring after this wintah!)\n phrase.gsub!(/\\bfactah\\b/i, 'factor') # factah\n phrase.gsub!(/\\b(af|insof|ovahf|f)ah\\b/i, '\\1ar') # fah (neah, fah, wheahevah you ahhhhh)\n phrase.gsub!(/(f)ahkin'?/i, '\\1*!king') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/(f)ahk?/i, '\\1*!k') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/\\b(airf|cahf|thoughroughf|welf|wahf|f)ayah\\b/i, '\\1are') # fayah (wahfayah, aihfayah)\n phrase.gsub!(/\\bfawr\\b/i, 'for') # fawr\n phrase.gsub!(/(af|bef|f)oah\\b/i, '\\1ore') # foah (fore & variants)\n phrase.gsub!(/\\bfoddy\\b/i, 'fourty') # foddy\n phrase.gsub!(/\\bfrappe\\b/i, 'a milkshake/malted (ice cream, milk, & syrup blended)') # frappe\n phrase.gsub!(/\\b(frickin|friggin)'?(?!\\z|\\s)/i, 'freaking') # the G-rated version of Boston's favorite adjective\n phrase.gsub!(/\\bfried\\b/i, 'weird') # fried\n phrase.gsub!(/\\bFudgicle\\b/i, 'Fudgsicle') # a fudgsicle that lost the \"s\"\n\n # G\n phrase.gsub!(/\\b(g)ahbidge\\b/i, '\\1arbage') # Wednesdiz is gahbidge day\n phrase.gsub!(/\\b(gawrls|gahls|gawhls)/i, 'girls') # gawrls just wanna...learn to code and change the girl to dave ratio, actually.\n phrase.gsub!(/(g)awd\\b/i, '\\1od') # oh my gawd\n phrase.gsub!(/\\b(g)ovahment\\b/i, '\\1overnment') # Govahment Centah! It's wheah Boston Cawllin' always is!\n phrase.gsub!(/\\b(ci|beg|vul|sug|vine)gah(s)?\\b/i, '\\1gar\\2') # gah --> sugah, cigah, etc.\n phrase.gsub!(/\\b(g)oah\\b/i, '\\1ore') # goah (Melissa-Leigh Goah, like Al Goah, he invented the intahnet)\n phrase.gsub!(/\\bg(o|a)tta\\b/i, 'have to') # gotta\n phrase.gsub!(/\\b(g)rammah\\b/i, '\\1rammar') # grammah\n phrase.gsub!(/\\bgrindah?(s)?\\b/i, 'sub\\1') # grindahs\n phrase.gsub!(/\\b(g)uitah\\b/i, '\\1uitar') # guitah (what's that game the kids ah playin? guitah hero?!)\n\n # H\n phrase.gsub!(/\\b(Hahvahd|Havahd|Havid|Hahvid)/i, 'Harvard') # Let's go to Hahvid and sit outside the Widenah Library\n phrase.gsub!(/\\b(hang|hook) a right\\b/i, 'take a right') # hang/hook a right\n phrase.gsub!(/\\bhamburg\\b/i, 'ground beef') # my grammy's go to dinnah was hamburg thingies..aka ground beef patties with mustard cooked on one side of a hamburger bun (this is an actual true story from the writer of this program, haha)\n phrase.gsub!(/\\b(heahd|heid)\\b/i, 'heard') # ya nevah heahd about that?\n phrase.gsub!(/heah/i, 'here') # heah, wheah, theah (wait, who's on first?!) -- this matches on at least 300 english words containing \"here\"\n #hahbah (no taxation without representation, ya dig?) covered under \"lahbah\"\n phrase.gsub!(/\\bHub\\b/i, 'Boston') # the Hub\n\n # I\n phrase.gsub!(/\\b(i)dear\\b/i, '\\1dea') # idear (so THAT'S where all those \"r\"'s went!')\n phrase.gsub!(/\\b(i)ntahfeah\\b/i, '\\1nterfere') # doan wanna intahfeah, ya know?\n\n # J\n phrase.gsub!(/\\b(a)?(j)ah\\b/i, '\\1\\2ar') # jah and ajah, like jams and doahs, but not doahjahms. well, maybe.\n phrase.gsub!(/\\bjimmies\\b/i, 'chocolate sprinkles') # jimmies, just be careful asking for these in NJ\n phrase.gsub!(/\\bJP\\b/, 'Jamaica Plain') # JP, fastest gentrifying neighbahood\n\n # K\n phrase.gsub!(/\\b(k)eggah?(s)\\b/i, '\\1eg party\\2') # kegga, aka something you throw at ya new apahtment in college\n phrase.gsub!(/\\b(k)inda\\b/i, '\\1ind of') #\n\n # L\n phrase.gsub!(/(chancel|council|sail|counsel|tai|pah|bache|co|sett)lah\\b/i, '\\1lor') # lah (words ending in lah are usually \"ler\", so this looks for the most common ones that should actually be \"lor\" first)\n phrase.gsub!(/([a-z])+ahbah\\b/i, '\\1abor') # lahbah (workin' hahd!) also covers hahbah (no taxation without representation, ya dig?!) and other bor words -- targeted rule so general rule doesn't make this \"laber\"\n phrase.gsub!(/\\b(l)abradoah(s)\\b/i, '\\1abrador\\2') # labradoah retrievah\n phrase.gsub!(/\\bLe(ay|i)?stuh\\b/i, 'Leicester') # Leicester\n phrase.gsub!(/\\bLem(o|i)nstah\\b/i, 'Leominster') # Leominster\n phrase.gsub!(/\\bLight Dawns ovah? Mahblehead\\b/i, 'Oh, DUH.') # light dawns ovah mahblehead\n phrase.gsub!(/\\b(l)iquah\\b/i, '\\1iquor') # liquah stoah...aka a packie, tbh\n phrase.gsub!(/\\blotta\\b/i, 'lot of') # lotta\n\n # M\n phrase.gsub!(/(ah|gla|hu|ru|tre|tu)mah\\b/i, 'mor') # words ending in mah, like rumah, humah (targeted gsub bc most are \"mer\")\n phrase.gsub!(/\\b(m)ajah\\b/i, '\\1ajor') # majah league baseball\n phrase.gsub!(/\\bmasshole\\b/i, 'a proud jerk from Massachusetts') # massholes :)\n phrase.gsub!(/\\b(m)ayah\\b/i, '\\1ayor') # Mayah Menino was the best mayah evah. (RIP)\n phrase.gsub!(/\\b(Mehfuh|Meffid|Medfid)\\b/i, 'Medford') # Meffid. Next to Somerville, home to Tufts\n phrase.gsub(/ministah\\b/i, 'minister') # ministah (the religious kind, but also administer, etc)\n\n # N\n phrase.gsub!(/\\b(nawht|naht)\\b/, 'not') # naht/nawt\n phrase.gsub!(/\\bnooyawka\\b/i, 'New Yorker') # Nooyawka, just the kind of person you don't want to meet at Fenway\n phrase.gsub!(/(semi|so|lu)nah\\b/i, '\\1nar') # \"nah\" ending words that aren't \"ner\"...seminah, solah\n phrase.gsub!(/(na-ah|nuh-uh|nuh-ah)/i, 'no way') # nah-ah\n phrase.gsub!(/\\bneighbahood\\b/i, 'neighborhood') # neighbahood\n\n # O\n phrase.gsub!(/\\b(o)ah\\b/, '\\1ur') # oah (this is ah (our) city!)\n phrase.gsub!(/(o)ffah/i, '\\1ffer') # offah\n phrase.gsub!(/onna(-|\\s)?conna/i, 'on account of') # onna-conna I gotta help my ma\n phrase.gsub!(/\\bopen ai(r|h)\\b/i, 'drive in movie') # open air (drive in movie theatre)\n phrase.gsub!(/(o)thah/i, '\\1ther') # othah (and also containing words like anothah or brothah)\n phrase.gsub!(/(o)vah/i, '\\1ver') # ovah (and also containing words like covah (at the bah!) rovah or ovahpass)\n phrase.gsub!(/(o)wah\\b/i, '\\1wer') # owah (all words ending in \"ower\", powah, flowah, etc)\n\n # P\n phrase.gsub!(/\\bpackie\\b/i, 'liquor store') # packie\n phrase.gsub!(/\\bpeab('dee|dee|ody)\\b/i, 'Peabody') # Peabody\n phrase.gsub!(/\\b(p)lenny\\b/i, '\\1lenty') # plenny ah beahs in the fridge\n phrase.gsub!(/\\bpissah?\\b/i, 'cool') # wicked pissah\n phrase.gsub!(/\\b(Ptown|P-Town|P Town)/i, 'Provincetown') # at the endah tha cape\n\n # Q\n phrase.gsub!(/\\bquality\\b/i, 'worthless') # sarcasm at its finest\n phrase.gsub!(/\\bQuinzee\\b/i, 'Quincy') # Quincy\n\n # R\n phrase.gsub!(/\\b(r)adah?\\b/i, '\\1adar') # radah (cops runnin the radah around to cawnah)\n phrase.gsub!(/\\brahya\\b/i, 'rare') # rahya (wicked rahya steak)\n phrase.gsub!(/\\b(r)apshah?\\b/i, '\\1apture') # rapsha (Jesus and/or Red Sox championship parades, either way)\n phrase.gsub!(/\\b(r)awregg\\b/i, '\\1aw egg') # rawregg can give ya salmonella\n phrase.gsub!(/\\b(r)eahview\\b/i, '\\1earview') # reahview (mirror)\n phrase.gsub!(/\\b(r)emembah\\b/i, '\\1emember') # remembah (when govahment centah was open?)\n phrase.gsub!(/\\breveah\\b/i, 'Revere') # Reveah (as in, Paul. or the beach. or from, kid!)\n phrase.gsub!(/\\brotary\\b/i, 'traffic circle') # second left on tha rotary\n\n # S\n phrase.gsub!(/\\bsangwich\\b/i, 'sandwich') # sangwich\n phrase.gsub!(/\\bsa(dda|ti|tih|ta|tah|tuh)d(ay|ee)\\b/i, 'Saturday') # Satahday\n phrase.gsub!(/\\bsat(a|i)hdiz\\b/i, 'Saturdays') # Satahdays\n phrase.gsub!(/\\bskeeve(s|d)/i, 'grossed out') # skeeved out by hair in food, lemme tell ya\n phrase.gsub!(/soah\\b/i, 'sore') # wicked soah from gettin swole at the gym, bro\n phrase.gsub!(/\\b(s)o do(an|n'?t) i\\b/i, '\\1o do I') # So do(a)n't I!\n phrase.gsub!(/\\bsouthie\\b/i, 'South Boston') # Southie\n phrase.gsub!(/\\bspa\\b/i, 'convenience store (family-owned, usually)') # spa (let's go get an italian ice!)\n phrase.gsub!(/\\b(co|lode|mega|supah|)?stah\\b/i, 'star') # stah (ben affleck/matt damon, need I say moah?)\n phrase.gsub!(/\\bsuppah?\\b/i, 'dinner') # suppah\n phrase.gsub!(/\\bsweet caroline\\b/i, 'Sweet Caroline (BUM BUM BUM)') # GOOD TIMES NEVER SEEMED SO GOOOODD\n\n # T\n phrase.gsub!(/\\bthe T\\b/i, 'subway') # after this winter, it's a wonder I didn't replace this one with \"unusable death trap\"\n # \"theah\" is covered under \"h\" in the heah substitution\n phrase.gsub!(/\\btah\\b/i, 'to') # tah (ready tah go!)\n phrase.gsub!(/\\btawnic\\b/i, 'tonic (soda)') # get a tawnic outta the fridge foh ya fahtah\n phrase.gsub!(/\\btempasha(h)?\\b/i, 'temperature') # David Epstein says the tempasha should go back up tomarrah.\n phrase.gsub!(/\\b(t)ha\\b/i, '\\1he') # tha\n phrase.gsub!(/thah?\\b/i, 'ther') # brothah, fathah, mothah, etc. (matches on 92 english words ending in \"ther\")\n phrase.gsub!(/\\bthi(h)?d\\b/i, 'third') # stealin' thihd\n phrase.gsub!(/\\bthree deckah?\\b/i, 'three story house') # usually three units\n phrase.gsub!(/(pic|ven|lec|cap|adven|sculp|frac|scrip|punc|conjec|rap)sha/i, '\\1ture') # sha sound on end of certain \"ture\" ending words\n\n # U\n phrase.gsub!(/(u)ndah/i, '\\1nder') # undah (including all the words it is a prefix of like undahweah, undahcovah, undahahm, plus bonus containing words like thunder)\n phrase.gsub!(/\\b(u)ey\\b/i, '\\1-turn') # U-turn\n\n # V\n phrase.gsub!(/\\b(v)endah(s)\\b/i, '\\1endor') # vendah(s) (fenway franks, anybody?)\n phrase.gsub!(/\\bvin(yihd|yahd)\\b/i, 'Martha\\'s Vineyard') # mahtha's vinyihd\n phrase.gsub!(/\\b(fahv|fehv|flav|sav|surviv)ah\\b/i, '\\1or') # \"vah\" words that are \"vor\"\n\n # W\n phrase.gsub!(/\\b(w)atah\\b/i, '\\1ater') # watah (as in \"love that dirty\")\n phrase.gsub!(/\\bwah\\b/i, 'war') # wah\n phrase.gsub!(/\\bWal(ltham|thumb)\\b/i, 'Waltham') # home of Brandeis\n phrase.gsub!(/\\bwanna go\\?\\b/i, 'let\\'s fight outside') # wanna go?\n phrase.gsub!(/\\b(w)e(eahd|eid|ahd|eihd)\\b/i, '\\1eird') # weeid\n # wheah is covered under \"t\"...theah/wheah (as in, dude wheah's my car...oh, under a snowbank where I left it in January 2015!)\n phrase.gsub!(/\\bwhole nothah?\\b/i, 'a complete replacement') # I gotta whole notha cah\n phrase.gsub!(/\\bweah\\b/i, 'were') # wheah weah ya?\n phrase.gsub!(/\\b(w)eathah\\b/i, '\\1eather') # wetheah (some weah havin!)\n phrase.gsub!(/\\bwicked\\b/i, 'really') # wicked (wicked weeid kid)\n phrase.gsub!(/\\bwuhst(u|a)h\\b/i, 'Worcester') # Worcester\n\n # X\n\n # Y\n phrase.gsub!(/\\b(y)a\\b/i, '\\1ou') # ya goin to the game?\n phrase.gsub!(/\\b(y)ar(?=\\s?i)/i, '\\1eah ') # yarit's awesome -> yeah it's awesome\n phrase.gsub!(/\\b(y)oah\\b/i, '\\1our') # yoah\n\n # Z\n\n # Last, we're gonna do some broad pickoffs for general sounds common to the Boston accent.\n # This will help translate commonly used words and broadly applicable use-cases. They are\n # a little dangerous without the targeted gsubs above, but with them in place as a filter for\n # uncommon/edge cases, you should get good results.\n\n phrase.gsub!(/atah(s)?\\b/i, 'ator\\1') # \"atah\" (words ending in \"ator\"...decoratah, delegatah)\n phrase.gsub!(/(a)wl(l)?/i, '\\1l\\2') # \"awl\" (going to the mawll, fawllin' down, cawll ya mothah etc)\n phrase.gsub!(/bah(s)?\\b/i, 'ber\\1') # \"bah\" (words ending in bah...bahbah). Works b/c only 30ish words in English end in ber, & targeted gsubs are used above for them.\n phrase.gsub!(/cah(s)?\\b/i, 'cer\\1') # \"cah\" (words ending in cer are more common than car or cor, targeted gsubs for the latter two are above)\n phrase.gsub!(/dah(s)?\\b/i, 'der\\1') # \"dah\" (words ending in dah...chowdah?).\n phrase.gsub!(/eah(s)?\\b/i, 'ear\\1') # \"eah\" (words ending in eah...yeah, cleah)\n phrase.gsub!(/fah(s)?\\b/i, 'fer\\1') # \"fah\" (words ending in fer...offah?).\n phrase.gsub!(/gah(s)?\\b/i, 'ger\\1') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/ha(h)?(s)?\\b/i, 'her\\2') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/iah(d)?/i, 'ire\\1') # \"iahd\" (words ending in ire...tiahd, wiahd or ired...fiahd)\n phrase.gsub!(/in'(?=\\z|\\s)/i, 'ing') # \"in'\" (words ending in ing...bring back the g!).\n phrase.gsub!(/kah(s)?\\b/i, 'ker\\1') # \"kah\" (words ending in ker...smokah)\n phrase.gsub!(/lah(s)?\\b/i, 'lar\\1') # \"lah\" (words ending in lar...molah, pillah)\n phrase.gsub!(/mah(s)?\\b/i, 'mer\\1') # \"mah\" (words ending in mer...swimmah, homah)\n phrase.gsub!(/nah(s)?\\b/i, 'ner\\1') # \"nah\" (words ending in ner...gonah, runnah)\n phrase.gsub!(/layah(s)?\\b/i, 'lare\\1') # \"layah\" (words ending in lare..flayah, declayah)\n phrase.gsub!(/(o)ah(s)?/i, '\\1re\\2') # \"oah\" (stoah, moah)\n phrase.gsub!(/pah(s)?\\b/i, 'per\\1') # \"pah\" (words ending in \"pah\"...helpah, peppah, whispah, developah...which I am totally going to be after I win this contest and become...a launchah!)\n phrase.gsub!(/sah(s)?\\b/i, 'ser\\1') # \"sah\" (words ending in ser...think about ya usah in the browsah)\n phrase.gsub!(/tah(s)?\\b/i, 'ter\\1') # \"tah\" (words ending in ter...watah)\n phrase.gsub!(/uahd(s)?\\b/i, 'ured\\1') # \"uahd\" (words ending in ured...figuahd, injuahd)\n phrase.gsub!(/vah(s)?\\b/i, 'ver\\1') # \"vah\" (words ending in ver...ovah, rivah)\n phrase.gsub!(/wah(s)?\\b/i, 'wer\\1') # \"wah\" (words ending in wer...lawnmowah, towah)\n phrase.gsub!(/xah(s)?\\b/i, 'xer\\1') # \"xah\" (words ending in xer...boxah, mixah)\n phrase.gsub!(/yah(s)?\\b/i, 'yer\\1') # \"yah\" (words ending in yer...foyah, lawyah)\n phrase.gsub!(/zah(s)?\\b/i, 'zer\\1') # \"zah\" (words ending in zer...organizah, seltzah)\n\n phrase.gsub!(/aw/i, 'o') # this one is super broad...tawnic/gawd/etc\n phrase.gsub!(/ah(?!\\b)+/, 'ar') # this one should always run last because it's so broad, but it will clean and cover a ton more cases than can be thought up individually\n\n\n # Finally, there is some stuff we just will NOT abide by in the Beantown Translation Machine.\n\n phrase.gsub!(/\\b(A-Rod|Eli Manning|Peyton Manning|the Jets|Bill Buckner|snow|disabled train|severe delays in service|parking ban|commuter rail)\\b/i, '[REDACTED]') # Redact it like the FBI releasing an embarrassing document, okay?\n phrase.gsub!(/\\bYankees\\b/i, 'Yankees (suck!)') # Yankees suck okay?\n phrase.gsub!(/\\bJohnny Damon\\b/i, 'He who shall not be named') # Looks like Jesus, talks like Judas, throws like...someone who can't throw because that's just rude to Mary.\n\n puts \"They said: \" + phrase\n\n # Special \"How Boston Are YOU?\" Beantown Points score for experts! Only shows up for users who earn at least two points.\n\n if beantown_points >= 15\n \tputs \"How Boston Are YOU?: WICKED LEGIT! Ah you from Reveah, kid?! You're as Boston as baked beans and clam chowdah without tomatoes. Hit up that packie, it's time for a toast!\"\n elsif beantown_points < 15 && beantown_points >= 10\n \tputs \"How Boston Are YOU?: Solid work! You probably yell \\\"Yankees Suck\\\" at sporting events where the Yankees aren't even playing. You drink your watah from a bubblah. We salute you.\"\n elsif beantown_points < 10 && beantown_points >= 5\n \tputs \"How Boston Are YOU?: Alright, now we're getting somewhere. This is pretty Boston, we'll admit. Just don't try to pahk ya cah in Hahvahd Yahd, or you'll get towed, alright?\"\n elsif beantown_points >=2 && beantown_points < 5\n \tputs \"How Boston are YOU?: Solid effort, but you need to hit the Pike and go back wheah ya came from, kid.\"\n end\n\n play_again\n\nend", "def Text2Words(txt, len, where, offset)\n txt.each do |words|\n print \" { { \" \n words.each do |word|\n if word==\"ET\" then\n pos = where.index(\"TERTAUQ\")\n else\n pos = where.index(word.reverse) || where.index(word) \n end\n print \" { %3d, %2d }, \" % [pos+offset, word.length ]\n end\n (len - words.length).times do\n print \" { %3d, %2d }, \" % [0, 0 ]\n end\n puts \" } }, // \" + words.join(\" \")\n end\nend", "def sentence_maker(array)\n\tsentence = array[0].capitalize.to_s\n\ti = 1\n\twhile i < array.length\n\t\tsentence = sentence + \" \" + array[i].to_s\n\t\ti += 1\n\tend\n\tsentence = sentence + \".\"\n\tp sentence\n\nend", "def sentence_maker(array)\n\tlength = array.length\n\tsum = array[0].to_s.capitalize!\n\tfor i in 1...length\n\t\tsum = sum + \" \" + array[i].to_s\n\tend\n \tsum + \".\"\nend", "def make_a_sentence(words)\n words.join(' ') + \"!\"\nend", "def yell_sentence(sent)\n # yell = sent.split(\" \")\n # yell = yell.map { |char| char.upcase + \"!\" }\n # return yell.join(\" \")\n return sent.split.map { |char| char.upcase + \"!\" }.join(\" \")\nend", "def sentence_maker(array)\n\tanswer=\"\"\n\tarray[0]=array[0].capitalize\n\tarray.each do |x|\n\t\tx=x.to_s\n\t\tanswer+=x+\" \"\n\tend\t\n\tanswer=answer.chop+\".\"\n\treturn answer\nend", "def sentence_maker(variable)\n\treturn variable.inject{|sentence, x| sentence + \" \" + x.to_s}.lstrip.capitalize + \".\"\nend" ]
[ "0.8855691", "0.70719296", "0.70076495", "0.7005185", "0.6995376", "0.69695127", "0.68714696", "0.6835763", "0.68160456", "0.6799819", "0.6795405", "0.67920643", "0.6792004", "0.67893285", "0.6781017", "0.6771953", "0.6764923", "0.6727412", "0.6697308", "0.66861355", "0.6660415", "0.66382277", "0.6637059", "0.66330004", "0.66212237", "0.65919507", "0.6587043", "0.6548463", "0.6547344", "0.65398943", "0.6536017", "0.65244484", "0.65219206", "0.65207434", "0.6516131", "0.6480413", "0.6467052", "0.6467052", "0.6467052", "0.6462294", "0.64563125", "0.64398706", "0.6432844", "0.64319474", "0.6413039", "0.6410966", "0.6399995", "0.63895345", "0.6378322", "0.63729054", "0.6359145", "0.63562405", "0.6331684", "0.63075155", "0.6307008", "0.62956285", "0.62830794", "0.6283057", "0.62755716", "0.62739426", "0.62728673", "0.6269642", "0.6269308", "0.6266217", "0.62476957", "0.62428534", "0.6233818", "0.62254685", "0.6220346", "0.6218717", "0.6217782", "0.6216938", "0.62122846", "0.62080574", "0.6200567", "0.61990863", "0.61843455", "0.6182924", "0.61780304", "0.6176674", "0.61730844", "0.6172964", "0.61670184", "0.6164828", "0.6159197", "0.6157547", "0.6147281", "0.61441153", "0.61406255", "0.6139332", "0.61305916", "0.61275303", "0.6126807", "0.6119027", "0.61186314", "0.61165965", "0.6106927", "0.61018", "0.6100406", "0.609865", "0.6090864" ]
0.0
-1
Gets the page title.
def get_title @doc.css('title').text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_title\n page.title\n end", "def title\n @title_pages.each { |tp| tp.title and return tp.title }\n nil\n end", "def page_title\n @page_title ||= format_string(page[\"title\"]) || site_title\n end", "def title\n return @title if @title\n if matches = class_const(:TITLE_RE).match(page)\n @title = matches[1].to_s.strip\n title_processor\n @title = decode_entities(@title)\n end\n end", "def page_title\n @web_browser.page_title\n end", "def title\n @title ||= begin\n if site_title && page_title != site_title\n page_title + TITLE_SEPARATOR + site_title\n elsif site_description && site_title\n site_title + TITLE_SEPARATOR + site_title_extention_or_description\n else\n page_title || site_title\n end\n end\n\n return page_number + @title if page_number\n\n @title\n end", "def page_title\r\n @web_browser.page_title\r\n end", "def page_title\n @page_title || TaliaCore::SITE_NAME\n end", "def get_page_title(page_doc)\n\treturn page_doc.css('title').text.strip\nend", "def title\n @global_page.title\n end", "def get_page_title\n uri = request.request_uri\n section = uri.split(\"/\").last\n title = case section\n # these should be consistent now\n when \"questions\" then \"Key Questions\"\n when \"publications\" then \"Publication Information\"\n when \"arms\" then \"Study Arms\"\n when \"design\" then \"Study Design\"\n when \"baselines\" then \"Baseline Characteristics\"\n when \"outcomes\" then \"Outcome Setup\"\n when \"results\" then \"Results\"\n when \"adverse\" then \"Adverse Events\"\n when \"quality\" then \"Study Quality\"\n else \"\"\n end\n return title\n end", "def page_title\n klass = Module.const_get(self.page.split('_').first)\n return klass.find(self.page.split('_').last.to_i).name || klass.find(self.page.split('_').last.to_i).title\n rescue NameError\n return self.page\n end", "def title\n @title ||= hash.fetch('title') { |key|\n raise \"Page id=#{id} is missing #{key}\"\n }\n end", "def get_display_title(title)\n page_info_get_val(title, 'displaytitle', 'displaytitle')\n end", "def page_title title= nil\n\t\tif title\n\t\t\tcontent_for(:page_title) { \"#{title} - 2da.re\" }\n\t\t\treturn title\n\t\telse\n\t\t\tcontent_for?(:page_title) ? content_for(:page_title) : \"Ready 2da.re?\"\n\t\tend\n\tend", "def page_title\n if @title.present?\n I18n.t('page_title', :page_title => @title, :blog_title => blog_title)\n else\n I18n.t('home_title', :blog_title => blog_title)\n end\n end", "def pageTitle\n (self || Home.new).title\n end", "def title\n @title ||= parsed_document.css('title').inner_text rescue nil\n end", "def page_title(title)\n content_for_wrapper(:page_title, title)\n end", "def page_title\n return \"#{this_webapp.webapp_name} - #{@page_title}\" if @page_title\n return \"#{this_webapp.webapp_name}\"\n end", "def scrape_title( page )\n\t\tpage.title.split( ' - ' )[0]\n\tend", "def title\n @data.title ||= parsed_document.css('title').inner_html.gsub(/\\t|\\n|\\r/, '') rescue nil\n end", "def title\n @title ||= parsed.css('head title').inner_text rescue nil\n end", "def page_title\n title = t(\"#{controller_name}.#{action_name}.title\")\n html = <<-HTML\n <div class=\"page-header\">\n <h1>#{title}</h1>\n </div>\n HTML\n html.html_safe\n end", "def page_title(title = nil)\n if title\n content_for(:page_title) { title }\n else\n content_for?(:page_title) ? content_for(:page_title) : APP_CONFIG[:site_name] # or a hard-coded default\n end\n end", "def title_with_page_title_check\n return @page.title if @page && !@page.title.blank?\n title_without_page_title_check\n end", "def title\n evaluate(\"document.title\")\n end", "def page_title(page)\n return site_title if page.title.nil? || page.title.empty?\n\n title = t(\"titles.#{page.title}\",\n flavor: settings.site_name.capitalize,\n default: [\"docs.#{page.parent}.#{page.title}\".to_sym,\n page.title.to_s.titleize])\n\n if page.parent.nil?\n parent_title = site_title\n else\n parent_title = t(\"titles.#{page.parent}\",\n flavor: settings.site_name.capitalize,\n default: site_title)\n end\n\n \"#{title} | #{parent_title}\"\n end", "def title\n connection.write(\"get_title\", false)\n end", "def title\n connection.write(\"get_title\", false)\n end", "def title\n connection.write(\"get_title\", false)\n end", "def title\n page.title\n end", "def title\n base_title = \"CloudSpokes Coding Challenges\"\n if @page_title.nil?\n base_title\n else\n \"#{base_title} - #{@page_title}\"\n end\n end", "def page_title\n title = \"Amplify\"\n title.prepend(\"#{@page_title} | \") if @page_title\n title\n end", "def page_title\n title = content_for?(:title) ? \" - #{content_for(:title)}\" : \"\"\n \"Todobadour#{title}\"\n end", "def page_title\n nil\n end", "def get_title()\n return @title\n end", "def page_title\n layout = controller.send(:_layout)\n base_title = I18n.t(\"layouts.#{layout}.title\", default: :'layouts.application.title')\n\n i18n_scope = \"#{params[:controller].gsub('/', '.')}.#{action_name}\"\n i18n_parts = [\n content_for(:page_title),\n I18n.t(:page_title, default: \"\", scope: i18n_scope).presence,\n I18n.t(:title, default: \"\", scope: i18n_scope).presence\n ]\n title_content = i18n_parts.compact.first\n [base_title, title_content].compact.join(' - ')\n end", "def title(page_title)\n content_for(:title) { page_title }\n end", "def title(page_title)\n content_for(:title) { page_title }\n end", "def title(page_title)\n content_for(:title) { page_title }\n end", "def title(page_title)\n content_for(:title) { page_title }\n end", "def title\n @doc.xpath(\"/html/head/title\").first&.text\n end", "def page_title\n end", "def title\n @title ||= Utilities.longest_common_substring_in_array(titles.values) \n @title = titles[:og_title] unless title_ok?\n @title = titles[:html_title] unless title_ok?\n @title = titles[:from_doc] unless title_ok?\n\n @title\n end", "def get_title(page)\n page.css(WebScraper::JOB_INFO_SELECTOR)[WebScraper::JOB_TITLE_POS].content.strip\n end", "def title(page_title = nil)\n if page_title\n content_for(:title) do\n page_title\n end\n else\n content_for(:title) do\n \"DateIdeas.ca\"\n end\n end\n end", "def title(page_title)\n\t content_for(:title) { page_title }\n\tend", "def title\n _title = self[\"title\"]\n _title ? _title[\"$t\"] : nil\n end", "def page_title(page_title = nil)\n @page_title ||= page_title\n @page_title.nil? ? \"Carers: #{action_name}\" : \"#{@page_title} @ Lort Smith\"\n end", "def page_title\n h Array(@title).join(\" / \") + \" | integrity\"\n end", "def\n get_title()\n @title\n end", "def header_text(page_title)\n page_title || @@base_title\n end", "def page_title\n case\n when @post\n \"#{@post.title} - Ben Hoad\"\n when @tag\n \"Tagged with ##{@tag} - Ben Hoad\"\n else\n \"Ben Hoad\"\n end\n end", "def page_title\n if controller_name == 'pages'\n title = t \"#{action_name}_page\"\n \"#{app_name} | #{title}\" # e.g.: 'Ror4 | Home'\n else\n if @page_title.nil?\n \"#{app_name} | #{t controller_name}-#{t action_name}\" # e.g.: 'Ror4 | groups-index'\n else\n \"#{app_name} | #{t @page_title}\" # e.g.: 'Ror4 | Show group Manager'\n end\n end\n end", "def page_title\n \"#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}\"\n end", "def title\n @title ||= details.at(\"h1.header\").text.strip rescue nil\n end", "def title\n @title ||= (Nokogiri::HTML.parse(@html).title).to_s.gsub(/\\n|\\t|\\r/,\"\")\n end", "def name; (page.title rescue ''); end", "def name; (page.title rescue ''); end", "def get_title()\n @title\n end", "def get_title\n @title\n end", "def page_title\n \n page_title = @renderer.title title()\n \n puts \"[Cutlist.page_title]: #{page_title}\" if $cutlister_debug\n \n page_title\n \n end", "def page_title(page_title)\n content_for_layout :page_title, page_title\n end", "def title(page_title)\n content_for :title do\n page_title\n end\n end", "def page_title(options = {})\n return \"\" if @page.title.blank?\n\n options = {\n prefix: \"\",\n suffix: \"\",\n separator: \"\"\n }.update(options)\n title_parts = [options[:prefix]]\n title_parts << if response.status == 200\n @page.title\n else\n response.status\n end\n title_parts << options[:suffix]\n title_parts.reject(&:blank?).join(options[:separator]).html_safe\n end", "def _title\n @link['title']\n end", "def title(page_title = '')\n\t\tbase_title = \"AB Online Shop\"\n\t\tif page_title.empty?\n\t\t\tbase_title\n\t\telse\n\t\t\tpage_title + \" | \" + base_title\n\t\tend\n\tend", "def page_title() nil end", "def title\n doc.css(\"titleproper\").children.first.text.strip\n end", "def title(page_title)\n content_for :page_title, page_title.to_s.html_safe\n end", "def title(page_title)\n @title = page_title\n content_for(:title) { page_title }\n end", "def get_title\n base_title = get_name_or_logo\n @title.nil? ? base_title : \"#{base_title} | #{@title}\"\n end", "def page_title; end", "def title\n # strip some non-breaking space at the end\n @title ||= details.at(\"h1[itemprop='name']\").children.first.text.strip.gsub(' ', '') rescue nil\n end", "def title(page_title)\n content_for(:title) do\n \"#{page_title} - #{MySettings.company_full_name}\"\n end\n end", "def render_page_title\n @page_title ? \"#{@page_title}_#{SiteName}\" : SiteName rescue \"SITE_NAME\"\n end", "def page_title( this_title = nil )\n content_for( :title ) { \"#{ SITE_ID }: #{ this_title.nil? ? I18n.t( controller.controller_name + '.title' ) : this_title }\" }\n end", "def title\n @title ||= self.content.split(@@title_separator).first unless self.content.nil?\n end", "def page_title\n if content_for?(:page_title)\n \"#{content_for(:page_title)} - \"\n elsif !breadcrumb_names.empty?\n \"#{breadcrumb_names.reverse.join(' - ')} - \"\n else\n ''\n end +\n t('layout.coursemology')\n end", "def page_title\n title = @page_title ? \"/ #{@page_title}\" : ''\n content_tag(:title, 'GONDI.tv ' + title)\n end", "def title\n if @title.nil?\n BASE_TITLE\n else\n \"#{BASE_TITLE} | #{@title}\"\n end\n end", "def page_title\n active_div.div(:class=>\"s3d-contentpage-title\").text\n end", "def page_title\n active_div.div(:class=>\"s3d-contentpage-title\").text\n end", "def page_title\n active_div.div(:class=>\"s3d-contentpage-title\").text\n end", "def title\n return @title unless link\n\n # handle the most common cases next\n return \"#{@title}. \" unless @title.ends_with?('. ', '.')\n return \"#{@title} \" if @title.ends_with?('.')\n\n @title\n end", "def render_page_title\n (content_for(:page_title) if content_for?(:page_title)) || @page_title || application_name\n end", "def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | #{site_name}\"\n end\n end", "def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | #{site_name}\"\n end\n end", "def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | #{site_name}\"\n end\n end", "def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | #{site_name}\"\n end\n end", "def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | #{site_name}\"\n end\n end", "def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | #{site_name}\"\n end\n end", "def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | #{site_name}\"\n end\n end", "def title\n { title: @doc.xpath('//h1').first.content }\n end", "def title(page_title)\n content_for(:title) { page_title }\n\n end", "def page_title(title)\n \"gbchaosmaster#{\" | #{title}\" unless title.blank?}\"\n end", "def page_title\n self.div(:id=>\"s3d-page-container\").div(:class=>\"s3d-contentpage-title\").text\n end", "def page_title\n self.div(:id=>\"s3d-page-container\").div(:class=>\"s3d-contentpage-title\").text\n end", "def title\n (\"\\0\" * 256).tap do |buffer|\n WIN[:get_title].call(buffer, buffer.length - 1)\n end.gsub \"\\0\", ''\n end" ]
[ "0.8760101", "0.874269", "0.85930514", "0.83034664", "0.8273144", "0.8159025", "0.81513894", "0.81211287", "0.80738115", "0.8036475", "0.8028478", "0.8000366", "0.79160887", "0.7885949", "0.7882007", "0.78620744", "0.7858696", "0.78178066", "0.78006154", "0.77807015", "0.7773884", "0.7772272", "0.7739601", "0.7733069", "0.77221525", "0.77098453", "0.7706798", "0.7700958", "0.7697276", "0.7697276", "0.7697276", "0.7695293", "0.7688144", "0.7685635", "0.76846415", "0.7679914", "0.76602954", "0.7649447", "0.7630181", "0.7630181", "0.7630181", "0.7630181", "0.762458", "0.761674", "0.76120365", "0.7610583", "0.75809383", "0.75685436", "0.756542", "0.7564169", "0.75624645", "0.75561666", "0.75547624", "0.75539565", "0.7553544", "0.75524694", "0.7551817", "0.7528278", "0.7524118", "0.7524118", "0.7495669", "0.74919754", "0.74767786", "0.74723876", "0.74700004", "0.7469562", "0.74455696", "0.7441331", "0.74409175", "0.74404347", "0.7431307", "0.74120945", "0.7408674", "0.7401625", "0.74000025", "0.73931265", "0.7385567", "0.7383891", "0.73828095", "0.73706865", "0.73660225", "0.7361365", "0.73589885", "0.73589885", "0.73589885", "0.73576474", "0.7357458", "0.7345385", "0.7345385", "0.7345385", "0.7345385", "0.7345385", "0.7345385", "0.7345385", "0.7344387", "0.7336776", "0.7334999", "0.73310965", "0.73310965", "0.73160654" ]
0.7920321
12
Gets the post points.
def get_points @doc.css('.score').text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def points\n @obj['points']\n end", "def points()\n\t\t\tfilter()\n\t\t\treturn @points_floor + @points_ceil.reverse\n\t\tend", "def points #:nodoc:\n [self]\n end", "def points #:nodoc:\n [self]\n end", "def points\n db[:points]\n end", "def points\n []\n end", "def records\n @points\n end", "def getPosts()\n\t\tself.post\n\tend", "def points\n @data['points'].to_i\n end", "def points\n @results.inject(0.0) { |t, r| t += r.points }\n end", "def posts\n return @posts\n end", "def posts\n return @posts\n end", "def points; end", "def points\n [top_left, top_right, bottom_left, bottom_right]\n end", "def points\n self.votes.inject(0) { |points, vote| points + vote.value }\n end", "def points\n self.votes.inject(0) { |points, vote| points + vote.value }\n end", "def hit_points\n @hit_points\n end", "def points\n @puntos = 0\n students.each do |s| \n @puntos += s.points\n end\n @puntos += house_points\n end", "def points\n MSPhysics::Newton::CurvySlider.get_points(@address)\n end", "def points\n MSPhysics::Newton::CurvySlider.get_points(@address)\n end", "def get_measured_points\n measured_points.points\n end", "def posts\n @posts ||= retrieve_posts\n end", "def get_total_points\n @event_points + @performance_points + @enhance_points\n end", "def base_points\n points\n end", "def create\n @post = Post.new(post_params)\n @post.user_id=params[:post][:user_id]\n @post.save\n \n\n \n @point = ['0', '0', '0', '0', '0']\n \n for i in 0..4\n @point[i] = Point.new\n end\n \n \n for i in 0..4\n @latitude = \"latitude\" + i.to_s\n @longitude = \"longitude\" + i.to_s\n @point_title = \"point_title\" + i.to_s\n @content = \"content\" + i.to_s\n @cardimg = \"cardimg\" + i.to_s\n \n if(@longitude)\n \n @point[i].latitude = params[:post][@latitude]\n @point[i].longitude = params[:post][@longitude]\n @point[i].point_title = params[:post][@point_title]\n @point[i].content = params[:post][@content]\n @point[i].cardimg = params[:post][@cardimg]\n @point[i].post_id = @post.id\n @point[i].save\n \n else\n \n end\n \n end\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n \n \n end\n end\n end", "def points\n 1\n end", "def posts\n return [] unless valid?\n\n @posts ||=\n Course::Discussion::Post.forum_posts.from_course(@course).\n includes(topic: { actable: :forum }).\n calculated(:upvotes, :downvotes).\n where(created_at: start_time..end_time).\n where(creator_id: @user)\n end", "def points\n -1\n end", "def points_granted\n self.user ? POINTS_FOR_POSTING : 0\n end", "def points\n votes.sum(:value)\n end", "def points\n votes.sum(:value)\n end", "def points(name, since=nil)\n stats = query(name, since)\n datapoints = stats[:datapoints]\n\n points = []\n count = 1\n\n (datapoints.select { |el| not el[0].nil? }).each do |item|\n points << { x: count, y: get_value(item)}\n count += 1\n end\n\n return points\n end", "def get_points(count = 1)\n points = []\n count.times do\n points << get_point\n end\n\n points\n end", "def posts\n backend.wall_page(self).posts\n end", "def nodes\n state.post.post_nodes\n end", "def points\n @points ||= begin\n h = Hash.new\n Point::ABS_POINTS_DATA.each do |pt_name|\n h.merge!(pt_name => Point.new(film, pt_name))\n end\n h\n end\n end", "def points\n object.polygon.points\n end", "def post_votes\n []\n end", "def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end", "def map(points)\n points\n end", "def preview\n @user = current_user\n @postings = Posting.all.sort_by {|p| [p.created_at.to_date, p.vote_score]}.reverse.first(3)\n end", "def points\n self.answer_votes.sum(:value).to_i\n end", "def point_list\n @user_point = UserPoint.find_by_user_id(current_user.id)\n end", "def earned_points\n # FIXME: denormalize this and put points directly on recognition\n point_activities.first.amount if persisted? && (sender != User.system_user)\n end", "def all_points\n\t\tcase @orientation\n\t\twhen :vertical\n\t\t\tx = @points[0][:x]\n\t\t\tys = [@points[0][:y],@points[1][:y]]\n\t\t\t(ys.min..ys.max).map{|y| {:x => x, :y => y}}\n\t\twhen :horizontal\n\t\t\txs = [@points[0][:x],@points[1][:x]]\n\t\t\ty = @points[0][:y]\n\t\t\t(xs.min..xs.max).map{|x| {:x => x, :y => y}}\n\t\tend\n\tend", "def get_points_for(trip)\n points = Array.new\n trip.destinations.each do |d|\n if d.has_location?\n points << LatLonPoint.new([d.location.lat, d.location.lng])\n end\n end\n points\n end", "def monthlyPoints\n @obj['monthlyPoints']\n end", "def current_pts\n self.score\n end", "def set_post\n @post = @user.posts.find(params[:id])\n @post.locations.each {|location| location }\n end", "def view_posts\n self.user.posts.map do |post|\n post.reload.content\n end\n end", "def comment_points\n self.comments.map { |comment| comment.vote_count }.inject(:+)\n end", "def breakdown\n @points = current_user.points.limit(5)\n render json: @points, status: 200\n end", "def posts; end", "def get_raw_posts\n if @settings[:feed_url].present?\n return Feedzirra::Feed.fetch_and_parse(@settings[:feed_url]).entries\n end\n nil\n end", "def posts\n Posts.new(self)\n end", "def points\n\t\tpoints = 0\n\t\tassignments.each do |assignment|\n\t\t\tpoints += assignment.worth\n\t\tend\n\t\treturn points\n\tend", "def step_points\n points.select { |point| point.kind == \"Step\" }\n end", "def getPostedPerson\r\n\t\t\t\t\treturn @postedPerson\r\n\t\t\t\tend", "def getPostedPerson\r\n\t\t\t\t\treturn @postedPerson\r\n\t\t\t\tend", "def all_post\n end", "def points\n points_by_round = [nil, 3, 5, 8, 13, 21, 34]\n points_by_round[@game.round] + @winner.seed\n end", "def points\n ((2 * base_points) / (1 + Math.exp(2 * (correct_answer - answer.to_f).abs))).to_i\n end", "def index\n @point_submissions = PointSubmission.where(point_submission_query_params)\n end", "def absolute_points\n points.map do |cv_pt|\n make_absolute(cv_pt.point)\n end\n end", "def get_votes\n ids = @posts.map(&:id)\n votes = Vote.where(\"post_id in (:ids) and ((user_id IS NOT null and user_id = :user_id) or (ip_address = :ip))\", {:ids => ids, :user_id => current_user, :ip => request.remote_ip})\n votes.map{|vote| {:id => vote.post_id.to_s, :positive => (vote.rating > 0) ? true : false } }\n end", "def show\n preliminar_posts = CityPost.select(:post_id).where(city_id: @city.id).map(&:post_id)\n @pagy, @posts = pagy(Post.where(id: preliminar_posts))\n @comments = pagy(Commentary.joins(:user).where(post_id: preliminar_posts).order('created_at DESC'))\n @likes = Like.distinct.where(post_id: preliminar_posts).count\n @dislikes = Dislike.distinct.where(post_id: preliminar_posts).count\n @points = @likes - @dislikes\n\n @post = Post.new\n end", "def index\n @points = Point.all\n end", "def index\n @points = Point.all\n end", "def save_point\n @save_points\n end", "def serialize_as_points\n points = []\n @metrics.each do |metric_name, metric_value|\n points << {\n :measurement => metric_name,\n :tags => @tags,\n :fields => {\n :value => metric_value.to_f\n }\n }\n end\n\n return points\n end", "def posts\n Event.source(self).posts.order(created_at: :desc)\n end", "def points\n deal_points = tricks_points @tricks\n\n if not deal_points.inside? bid_said_by_team\n deal_points.add_points_to(bid_said_by_team, MatchPoints::VALAT_BONUS) if valat?\n\n if not @mode.is_a? DoubleMode\n @mode.match_points deal_points\n else\n Points.zeros[bid_said_by_team] = doubling_points deal_points, @mode\n end\n elsif deal_points.inside? bid_said_by_team\n deal_points.add_points_to(opposing_team, MatchPoints::VALAT_BONUS) if valat?\n\n Points.zeros[opposing_team] = doubling_points deal_points, @mode\n elsif deal_points.hanging?\n if not @mode.is_a? DoubleMode\n @mode.match_points deal_points\n else\n doubled_points = doubling_points deal_points, @mode\n\n result = Points.zeros\n result[bid_said_by_team] = doubled_points / 2\n resutl[opposing_team] = doubled_points / 2\n\n result\n end\n end\n end", "def post_scripts\n @post_scripts ||= user_data_as_array('post_script')\n @post_scripts\n end", "def posts\n Post.all_for_event(self.id)\n end", "def review_points\n self.reviews.map { |review| review.vote_count }.inject(:+)\n end", "def points=(points)\n @points = []\n points.each do |point|\n @points.push(x: point[0], y: point[1])\n end\n end", "def goal_points\n self[:goal]\n end", "def getPostDate\r\n\t\t\t\t\treturn @postDate\r\n\t\t\t\tend", "def getPostDate\r\n\t\t\t\t\treturn @postDate\r\n\t\t\t\tend", "def post_read\n \n mark = ViewCountPost.new\n mark.post_id = params[:id]\n mark.ip_adress = request.remote_ip\n mark.save\n \n @post = Post.find(params[:id])\n @intab = Intab.where(:id => @post.intab_id).take\n @tab = Tab.where(:id => @intab.tab_id).take\n \n posts_same_intab = @intab.posts.all\n @pg = posts_same_intab.count/15\n \n @ppp = []\n posts_same_intab.each do |x|\n @ppp << x.id\n end\n \n end", "def get_all_posts\n @posts = []\n Posts.all.each do |p|\n @location = Location.find_by_id(p.location_id)\n @posts << {:author_id => p.author_id, :author => p.name, :text => p.text, :created_at => p.created_at, :location => @location}\n end\n # Posts.find_by_sql(\"SELECT p.location_id FROM posts p\").each do |l_id|\n # Posts.find_by_sql(\"SELECT * FROM posts p\").each do |post|\n # @posts << {:author_id => post.author_id, :author => post.name, :text => post.text, :created_at => post.created_at, :location => Location.find(:id => l_id).to_hash}\n end", "def total_points\n Activity.points_for_person(id)\n end", "def post_params\n params[:post]\n end", "def index\n @turistic_spot_posts = TuristicSpotPost.all\n end", "def show\n @score = Evaluation.eval_post(@post)\n end", "def post_statistics\n print \"Post Title: \".colorize(:green)\n puts \"#{@post.title}\".colorize(:yellow)\n print \"Post URL: \".colorize(:green)\n puts \"#{@post.url}\".colorize(:yellow)\n print \"Post Points: \".colorize(:green)\n puts \"#{@post.points}\".colorize(:yellow)\n print \"Post ID: \".colorize(:green)\n puts \"#{@post.post_id}\".colorize(:yellow)\n print \"Number of comments: \".colorize(:green)\n puts \"#{@post.comments.size}\\n\".colorize(:yellow)\n puts \"Comments:\\n\".colorize(:green)\n @post.comments.each do |comment|\n puts \"#{comment.date} days ago, comment id #{comment.item_id} by #{comment.user}\".colorize(:green)\n puts \"#{comment.content}\\n\".colorize(:blue)\n end\n end", "def after_create post\n \n # update points\n PointManager::add_points post.user, 'ppx' \n\n # update buyer address info\n update_contact_info post\n \n UserMailer.send_pixipost_request(post).deliver_later if post.status == 'active'\n UserMailer.send_pixipost_request_internal(post).deliver_later if post.status == 'active'\n end", "def post\n array = []\n Post.post.each do |element|\n if element.user_id == self.user_id\n array << element\n end\n end\n array.each do |post|\n puts post.title\n end\n end", "def all_points\n\t\tcurrent_member = @current_member\n\t\t@semesters = Semester.order(:start_date)\n\t\t@semester_point_hash = Hash.new\n\t\t@semesters.each do |semester|\n\t\t\t@semester_point_hash[semester.id] = Member.current_members(semester).map{|m| {'name'=>m.name, 'id'=>m.id, 'points'=>m.total_points(semester)}}\n\t\t\t@semester_point_hash[semester.id].sort! { |a,b| a['points'] <=> b['points'] }.reverse!\n\t\tend\n\t\t@semester_point_json = @semester_point_hash.to_json\n\tend", "def post\n @post ||= Post[post_id]\n end", "def total_points\n stories.inject(0) do |accumulator, story|\n accumulator += story.points\n end\n end", "def details\n [\"Post title: #{@title}\".colorize(:yellow),\n \"URL: #{@url}\".colorize(:red),\n \"Points: #{@points}\".colorize(:blue),\n \"ID: #{@item_id}\".colorize(:green)]\n end", "def curve_points(points)\n cur_page.curve_points(points)\n end", "def get_post_from_comment\n @post = @comment.post\n end", "def to_array\n @points.collect { |p| [p.x, p.y] }\n end", "def x\n @point[0]\n end", "def points\n return 0 if event.trial? || event.trialed?\n\n points_if_not_trial\n end", "def index\n @points = Member.all.sort_by {\n |member| (member.points_to_add.present? ? member.points_to_add : 0)\n }.reverse\n end", "def export_post(post) end", "def coordinates\n @coordinates\n end" ]
[ "0.7306577", "0.69104683", "0.6677666", "0.6677666", "0.6671629", "0.66334087", "0.65488994", "0.64727044", "0.6442042", "0.63989353", "0.6338974", "0.6338974", "0.62635434", "0.624877", "0.6214281", "0.6214281", "0.6210413", "0.6129807", "0.604901", "0.604901", "0.6037846", "0.59727645", "0.5971896", "0.594776", "0.59066087", "0.5906375", "0.58784294", "0.586706", "0.5849923", "0.5844421", "0.5844421", "0.58177006", "0.58141446", "0.5811798", "0.57776755", "0.5768746", "0.5768668", "0.57195055", "0.5709671", "0.57025075", "0.5635654", "0.55627", "0.5552248", "0.5545233", "0.5501112", "0.548491", "0.54761803", "0.5467953", "0.54171157", "0.5393774", "0.5368793", "0.5360183", "0.535861", "0.5347673", "0.5340494", "0.53327185", "0.5331287", "0.53300554", "0.53300554", "0.5326518", "0.53233343", "0.53178203", "0.5300789", "0.52820367", "0.52725923", "0.52703536", "0.5267098", "0.5267098", "0.5257859", "0.52578485", "0.52519315", "0.5251853", "0.52512807", "0.52429724", "0.5240968", "0.5236805", "0.52323455", "0.52286386", "0.52286386", "0.5224479", "0.52224743", "0.5220448", "0.52198625", "0.52137", "0.5203941", "0.5196448", "0.519423", "0.51895195", "0.51857394", "0.5185503", "0.5173928", "0.51684445", "0.5157088", "0.5154023", "0.5149839", "0.51466274", "0.51311177", "0.51299256", "0.51272744", "0.51266253" ]
0.56769407
40
Gets the post item ID.
def get_item_id @doc.css('.subtext > .age > a:first-child').map{|ele| ele['href']}.map {|x| x[/\d+/]}.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_entry_id\n return @item_entry_id\n end", "def item_entry_id\n return @item_entry_id\n end", "def item_id\n id\n end", "def item_id\n item_hash.deep_find(:item_id)\n end", "def item_id\n params['item_number'] || params['custom']\n end", "def item_id\n params['item_number'] || params['custom']\n end", "def postid\n warn \"Post#postid is deprecated, use #id.\"\n @id\n end", "def item_id=(value)\n @item_id = value\n end", "def item_id=(value)\n @item_id = value\n end", "def item_id=(value)\n @item_id = value\n end", "def post_item_id(doc)\n href = doc.search('.subtext > a:nth-child(3)').map { |link| link['href'] }\n href[0].match(/\\d+/)\n end", "def item_id\n\tparams['item_number'] || params['custom']\n end", "def record_id\n attributes['item_id']\n end", "def app_item_id\n read_integer('app_item_id')\n end", "def app_item_id\n read('app_item_id')\n end", "def item_id\r\n params['Ref'] \r\n end", "def id\n raise \"Item.id not set\" unless @id\n $stderr.puts \"Item.id >#{@id}<\"\n @id\n end", "def id\n object.id.to_i\n end", "def get_id()\n return @id\n end", "def item_id(input_name:, op:)\n fv = op.input(input_name)\n fv.part.try(:id) || fv.item.id\n end", "def submission_id(item)\n # noinspection RubyMismatchedReturnType\n case item\n when Upload, AwsS3::Message::SubmissionRequest\n item.submission_id\n when Hash\n item[:submission_id] || item['submission_id']\n when String\n item\n else\n Log.warn { \"#{__method__}: unexpected: #{item.inspect}\" }\n end\n end", "def manifest_item_id(item)\n result = error = nil\n case item\n when ManifestItem then result = item.id\n when Hash then result = item[:manifest_item_id] || item[:id]\n when Integer then result = item.to_s\n when String then result = item\n else error = \"invalid item #{item.inspect}\"\n end\n result&.to_s&.presence || { error: (error || \"no ID for #{item.inspect}\") }\n end", "def uid\n read_attribute('uid').present? ? read_attribute('uid') : \"item_#{self.object_id}\"\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def get_id\n return @m_id\n end", "def id\n @permalink.to_i\n end", "def id\n ref = JSONModel::parse_reference(self.uri)\n\n if ref\n ref[:id]\n else\n nil\n end\n end", "def id\n object[\"id\"]\n end", "def get_item_id(index)\n return nil if index.blank?\n raise \"您填写的内容不像是个数字啊(#{index})!\" unless only_num?(index)\n index = index.to_i - 1\n raise \"您确定有这个选项吗(#{index})?\" unless (0..(self.issue[\"items\"].count)).include? index\n self.issue[\"items\"][index][\"id\"]\n end", "def item_id\n params['m_payment_id']\n end", "def id\n data[:id]\n end", "def id\n @entry_id || @url\n end", "def _id\n @attributes && @attributes[:_id]\n end", "def id(attachment, _style_name)\n attachment.instance.id\n end", "def line_item_id\n @row[\"売上詳細ID\"].to_s\n end", "def id\n return @args[:id]\n end", "def get_id()\n return @id\n end", "def last_post_identifier\n self.posts.\n find(:all, :order => 'published_at DESC, id DESC', :limit => 2).\n last.\n try(:identifier)\n end", "def web_order_line_item_id\n read('web_order_line_item_id')\n end", "def getPokemonId \n JSON.parse(@random_pokemon.body)[\"id\"]\n end", "def postId(value)\n merge(mppostId: value.to_s)\n end", "def id\n @entry_id ||= @url\n end", "def id\n raise Errno::ENOENT, \"This object has been deleted.\" if self.deleted?\n raise \"No ID on object.\" if !@id\n return @id\n end", "def id\n data[:id]\n end", "def item_id\n unescape params['x_invoice_num']\n end", "def id\n @attributes[:_id]\n end", "def item_number(item)\n return nil if item.nil?\n container = item_container(item.class)\n container ? container[item.id] || 0 : 0\n end", "def item_id\n unescape params['x_invoice_num']\n end", "def id\n self.event['id'].to_i\n end", "def get_id\n\t\treturn id\n\tend", "def id\n object.id.to_s\n end", "def id\n self[:identifier]\n end", "def id\n @document.fetch('id')\n end", "def id\n _id rescue nil\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def guid\n return '' if @item.guid.nil?\n @item.guid.content\n end", "def id\n @data['id'].to_i\n end", "def id\n @data['id'].to_i\n end", "def pageid\n\t\t\t@data[\"pageid\"]\n\t\tend", "def id\n @obj['id']\n end", "def id\n reply.documents[0][ID]\n end", "def id\n @data['id']\n end", "def id\n @attributes['id']\n end", "def get_pdf_list_item_id(pdf_upload_response)\n uri = pdf_upload_response.body['d']['ListItemAllFields']['__deferred']['uri']\n path = uri.slice(uri.index(base_path)..-1)\n\n with_monitoring do\n get_item_response = sharepoint_connection.get(path)\n\n list_item_id = get_item_response.body.dig('d', 'ID')\n raise ListItemNotFound if list_item_id.nil?\n\n list_item_id\n end\n end", "def post(postid)\n request(:id => postid).posts.first\n end", "def id\n fields['id']\n end", "def get_object_id object\n object.respond_to?(:id) ? object.id : object\n end", "def getId()\n\t\t\treturn @_id\n\t\tend", "def extract_item_id(request)\n query = URI.parse(request).query\n !query.nil? && !query.empty? && CGI.parse(query)['item']\nend", "def trackable_id\n params['id'] || first_item_on_page_id\n end", "def get_id(title)\n params = {\n action: 'query',\n prop: 'revisions',\n rvprop: 'content',\n titles: title\n }\n\n post(params)['query']['pages'].keys.find { |id| id != '-1' }&.to_i\n end", "def get_id()\n @id\n end", "def get_id()\n @id\n end", "def id\n read_attribute(self.class.primary_key)\n end", "def id\n read_attribute(self.class.primary_key)\n end", "def id\n self['id']\n end", "def id\n self['id']\n end", "def id\n raise MissingID if not defined?(@id)\n @id.to_i\n end", "def id\n object.object_id\n end", "def _id\n @id\n end", "def item_number\n self[:item_number]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n @attributes[:id]\n end", "def id\n doc['_id']\n end" ]
[ "0.74506044", "0.74506044", "0.74506044", "0.7161136", "0.7161136", "0.7051369", "0.68124604", "0.67881656", "0.67881656", "0.67212206", "0.6565051", "0.6565051", "0.6565051", "0.6548729", "0.6470138", "0.639543", "0.63820714", "0.62657505", "0.6227111", "0.62014073", "0.6129079", "0.60649955", "0.60273045", "0.6000588", "0.5988934", "0.5945232", "0.592671", "0.592671", "0.592671", "0.592671", "0.592671", "0.59124637", "0.58898205", "0.58761424", "0.5867368", "0.584997", "0.58452237", "0.57992685", "0.57881594", "0.57522655", "0.5743281", "0.57417375", "0.57373005", "0.57371575", "0.57277936", "0.5722987", "0.57170016", "0.5716165", "0.5705293", "0.570451", "0.56968796", "0.56781566", "0.5675271", "0.5660662", "0.565407", "0.5652827", "0.56205714", "0.56040025", "0.5593286", "0.5588318", "0.5579597", "0.5579538", "0.5579538", "0.55766714", "0.5571041", "0.5571041", "0.55704445", "0.55685484", "0.55676824", "0.5563254", "0.5562977", "0.5548699", "0.55429494", "0.5526244", "0.55244046", "0.5516167", "0.5514236", "0.55102885", "0.5489858", "0.5467181", "0.5467181", "0.5463475", "0.5463475", "0.5461696", "0.5461696", "0.545616", "0.5439027", "0.5436029", "0.5432028", "0.54225075", "0.54225075", "0.54225075", "0.54225075", "0.54225075", "0.54225075", "0.54225075", "0.54225075", "0.54225075", "0.54225075", "0.5404578" ]
0.5436884
87
Return an alignment which match columns. The originating sequences should have methods 'empty_copy' and '<<'
def columns_where &block seqs = [] rows.each do | seq | new_seq = seq.empty_copy seq.each_with_index do | e,i | new_seq << e if block.call(columns[i]) end seqs << new_seq end Alignment.new(seqs) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def align\n [:owner, :group, :size].each do |field|\n current = @alignment[field]\n @buffer.each do |line|\n new = line[field].length\n current = new if current < new\n end\n @alignment[field] = current\n end\n end", "def aligned_sequence \n peptide_member = Ensembl::Compara::Member.find_by_member_id(self.peptide_member_id)\n seq = peptide_member.sequence.sequence\n return nil if seq.nil?\n aln = Ensembl::Compara::AlignSeq.new(seq,self.cigar_line).align\n return Bio::FastaFormat.new(Bio::Sequence::NA.new(aln).to_fasta(\"#{self.member.stable_id}|#{peptide_member.stable_id}\")) \n end", "def align \n return @raw.align \n end", "def alignment_of(member)\n self.class.alignment_of(member)\n end", "def process_alignment\n # init vars\n @names = []\n @seqs = []\n \n @alignment = \"-B #{@basename}.aln\"\n\n # import alignment file\n @content = IO.readlines(@infile).map {|line| line.chomp}\n \n #check alignment for gap-only columns\n remove_inserts\n \n #write query-file\n File.open(@infile, \"w\") do |file|\n file.write(\">#{@names[0]}\\n\")\n file.write(\"#{@seqs[0]}\\n\")\n end\n \n #write aln-file\n File.open(@basename + \".aln\", \"w\") do |file|\n @names.each_index do |num|\n file.write(\"Sequence#{num} \")\n file.write(\" \") if (num < 10)\n file.write(\" \") if (num < 100)\n file.write(\"#{@seqs[num]}\\n\")\n end\n end\n end", "def query_align(seqs)\n seqtype = nil\n unless seqs.is_a?(Bio::Alignment)\n seqs = Bio::Alignment.new(seqs)\n end\n seqs.each do |s|\n if s.is_a?(Bio::Sequence::AA) then\n seqtype = 'PROTEIN'\n elsif s.is_a?(Bio::Sequence::NA) then\n seqtype = 'DNA'\n end\n break if seqtype\n end\n query_string(seqs.to_fasta(70, :avoid_same_name => true), seqtype)\n end", "def align\n i = @max_cell_row\n j = @max_cell_column\n @first_result = \"\" \n @second_result = \"\" \n gaps_in_first = 0 # count of gaps in each sequence\n gaps_in_second = 0\n\n while true\n\n # end local alignment at 0 cell\n if @traceback_matrix[i, j] == 0\n break\n end\n\n # match/mismatch\n if @traceback_matrix[i, j] == 1\n @first_result << @first_string[i-1]\n @second_result << @second_string[j-1]\n i -= 1\n j -= 1\n end\n\n # deletion -> gap in S1\n if @traceback_matrix[i, j] == 2\n @first_result << \"-\"\n @second_result << @second_string[j-1]\n j -= 1\n gaps_in_first += 1\n end\n\n # insertion -> gap in S2\n if @traceback_matrix[i, j] == 3\n @first_result << @first_string[i-1]\n @second_result << \"-\"\n i -= 1\n gaps_in_second += 1\n end\n\n end\n # set variables to make writing to file prettier\n set_variables(gaps_in_first, gaps_in_second)\n end", "def alignments\n map { |alignment| alignment }\n end", "def align; end", "def align; end", "def query_align(seqs, *arg)\n unless seqs.is_a?(Bio::Alignment)\n seqs = Bio::Alignment.new(seqs, *arg)\n end\n query_string(seqs.to_fasta(70))\n end", "def aligned_sequence(start=0,stop = nil,noindent=false) \n self._get_aligned_sequence_from_original_sequence_and_cigar_line\n #seq = AlignSeq.new(self.get_slice.seq,self.cigar_line,start,stop).align\n #return Bio::FastaFormat.new(Bio::Sequence::NA.new(seq).to_fasta(\"#{self.find_organism}\"))\n end", "def fetch_unaligned_sequences \n answer = Array.new \n self.genomic_aligns.each do |piece| \n sequence = piece.get_slice.seq\n fas = Bio::FastaFormat.new(Bio::Sequence::NA.new(sequence).to_fasta(piece.genomic_align_id))\n answer.push(fas) \n end \n return answer \n end", "def alignment_of(member)\n self::MEMBERS_HASH[member].alignment\n end", "def column_align colindex, lrc=:NONE\n if lrc == :NONE\n return get_column(colindex).align\n #return @calign[colindex]\n end\n raise ArgumentError, \"wrong alignment value sent\" if ![:right, :left, :center].include? lrc\n get_column(colindex).align = lrc\n self\n end", "def align\n unless defined?(@align); parse_align; end\n @align\n end", "def align\n unless defined?(@align); parse_align; end\n @align\n end", "def alignment_node(node); end", "def aligned?\n true\n end", "def align_pairwise(bioseqs, opt={})\n factory = Bio::ClustalW.new\n clustal_opts = hash_opts_to_clustalopts(opt)\n factory.options = clustal_opts\n template = bioseqs.shift\n start_length = []\n pairwise_aligns = bioseqs.map do |bseq|\n clust_al = clustal_align([template, bseq], factory)\n cl_cons = clust_al.consensus\n aligned_string = clust_al[1].to_s\n #(st, len) = find_good_section(aligned_string, opt[:fidelity_length])\n seq_to_use = \n if opt[:consensus_fidelity]\n cl_cons\n else\n aligned_string\n end\n (st, len) = find_good_section(seq_to_use, opt[:fidelity_length])\n if st\n pristine = aligned_string[st, len].gsub('-','') # pristine read (ends removed)\n clustal_align([template.to_s, Bio::Sequence::NA.new(pristine)], factory)\n else\n warn \"a sequence does not meeting min fidelity! using original alignment\" \n clust_al\n end\n\n end\n end", "def aligned?\n false\n end", "def aligned?\n false\n end", "def alignment_strings(start=0,stop=self.length,organisms=nil) \n answer = Array.new \n self.genomic_aligns.each do |contig|\n if organisms.nil? # if no organisms were specified to limit the results\n sequence = contig.aligned_sequence(start,stop)\n answer << Bio::FastaFormat.new(Bio::Sequence::NA.new(sequence).to_fasta(contig.find_organism.name)) unless sequence.nil?\n else\n if organisms.include?(contig.find_organism)\n sequence = contig.aligned_sequence(start,stop)\n answer << Bio::FastaFormat.new(Bio::Sequence::NA.new(sequence).to_fasta(contig.find_organism.name))\n end\n end \n end\n return answer \n end", "def alignments\n @alignment_table.indexes.keys\n end", "def align_column colindex, lrc\n raise ArgumentError, \"wrong alignment value sent\" if ![:right, :left, :center].include? lrc\n @calign[colindex] ||= lrc\n if @chash[colindex].nil?\n @chash[colindex] = ColumnInfo.new(\"\", nil, lrc)\n else\n @chash[colindex].align = lrc\n end\n @chash\n end", "def align_all_words\n 0.upto(word_list.length-1) do |i|\n 0.upto(i-1) do |j|\n w1 = self[i]\n w2 = self[j]\n if (w1.meaning & w2.meaning).empty?\n LOGGER.debug(\"Skipping alignment for\\n\" +\n \"#{w1}\\n#{w2}\\nbecause they share no meaning\")\n next\n end\n @alignment_table.add(Alignment.new(w1, w2), i, j)\n end\n end\n end", "def alignment\n fetch('dnd.alignments')\n end", "def align_column n, alignment\n r = rows\n column(n).each_with_index do |col, i|\n r[i][n] = { :value => col, :alignment => alignment } unless Hash === col\n end\n end", "def inferred_alignment(aligned_source)\n tokens.select(&:alignment_id).map do |token|\n token.alignment(aligned_source)\n end.flatten.compact.map(&:sentence).uniq\n end", "def matching_records_arel(table_name)\n s = Arel::Table.new(\"#{table_name}_view\")\n arel_columns = column_names.map { |c| Arel::Attribute.new(s, c) }\n first_column = arel_columns.shift\n second_column = arel_columns.shift\n s.project(s[Arel.star]).where(first_column.eq(second_column))\n end", "def align!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n type = ALIGN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 362:8: 'align'\n match( \"align\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n end", "def get_all_alignments_as_string\n @alignments.values.compact.collect{ |a| get_alignment_as_string(a) }.insert(0, alignment)\n end", "def align=(_arg0); end", "def align_column n, alignment\n r = rows\n column(n).each_with_index do |col, i|\n cell = r[i][n]\n cell.alignment = alignment unless cell.alignment?\n end\n end", "def get_4d_simplealign\n raise \"not implemented\"\n end", "def aligned_position \n \n cigar_line = \"#{self.cigar_line}\"\n \n x = cigar_line.slice!(/^[0-9]*/)\n char = cigar_line.slice!(/^[A-Z]/)\n \n x.nil? ? x = 1 : x = x.to_i\n char == \"X\" ? start = x : start = 0\n \n char = cigar_line.slice!(/[A-Z]$/)\n y = cigar_line.slice!(/[0-9]*$/)\n \n if y.nil?\n y = 1\n else\n y = y.to_i\n end\n \n if char == \"X\"\n stop = self.genomic_align_block.length - y\n else\n stop = self.genomic_align_block.length\n end\n answer = Array.new\n answer.push(start)\n answer.push(stop)\n return answer\n \n end", "def alignment= value\n raise unless ALIGNMENTS.any? {|a| a == value }\n @alignment = value\n end", "def calculate_column_justification\n transposed.map do |(key, values)|\n values.all? { |entry| entry.to_s.match(/\\d/) || entry.nil? } ? 'r' : 'l'\n end\n end", "def write\n\n # reverse alignments\n @first_result.reverse!\n @second_result.reverse!\n\n # Create middle section for matches/mismatches\n index = 0\n @first_result.length.times do\n if @first_result[index] == @second_result[index]\n @central_alignment << \"|\"\n else\n @central_alignment << \" \"\n end\n index += 1\n end\n\n offset = @start_first > @start_second ? @start_first.to_s.length : @start_second.to_s.length\n border = \"\"\n\n (offset+1).times do # lines up center with alignments\n border << \"=\"\n end\n\n # formats beginning and end of sequence output\n @first_result.insert(0, @start_first.to_s << \"=\")\n @first_result << \"=\" << @max_cell_row.to_s\n @second_result.insert(0, \"\" << @start_second.to_s << \"=\")\n @second_result << \"=\" << @max_cell_column.to_s\n @central_alignment.insert(0, border)\n @central_alignment << border\n\n # separate sequences and center into at most chunks of at most 60\n first_chunks = @first_result.scan(/.{1,60}/)\n central_chunks = @central_alignment.scan(/.{1,60}/)\n second_chunks = @second_result.scan(/.{1,60}/)\n\n length = first_chunks.length\n\n File.open(\"result.txt\", 'w') {|file| \n i = 0\n length.times do\n file.puts first_chunks[i]\n file.puts central_chunks[i]\n file.puts second_chunks[i]\n file.puts\n i += 1\n end\n }\n\n end", "def align_sequences_nm(sequence1, sequence2, scores)\n # Dynamic programming.\n dp = Array.new(sequence1.length + 1) { Array.new(sequence2.length + 1) }\n gap_score = scores['-']['-']\n dp[0][0] = [0, 0, 0, '|', '|']\n sequence1.chars.each_with_index do |c, i|\n dp[i + 1][0] = [(i + 1) * gap_score, 1, 0, c, '-']\n end\n sequence2.chars.each_with_index do |c, j|\n dp[0][j + 1] = [(j + 1) * gap_score, 0, 1, '-', c]\n end\n sequence1.chars.each_with_index do |base1, i|\n sequence2.chars.each_with_index do |base2, j|\n dp[i + 1][j + 1] = [[0, 1, '-', base2], [1, 0, '-', base1],\n [1, 1, base1, base2]].map { |i1, j1, match1, match2|\n [dp[i - i1 + 1][j - j1 + 1].first + scores[match1][match2],\n i1, j1, match1, match2]\n }.max\n end\n end\n \n # Solution reconstruction.\n i, j = *[sequence1, sequence2].map(&:length)\n match_score = dp[i][j].first\n align1, align2 = '', ''\n until i == 0 && j == 0\n score, i1, j1, base1, base2 = *dp[i][j]\n align1 << base1; i -= i1 \n align2 << base2; j -= j1\n end\n \n # Return values\n scores = dp.map { |line| line.map(&:first) }\n words = { [1, 0] => '$\\\\uparrow$', [0, 1] => '$\\\\leftarrow$',\n [1, 1] => '$\\\\nwarrow$', [0, 0] => '$\\\\cdot$'}\n parents = dp.map { |line| line.map { |item| words[item[1, 2]] } }\n { :scores => scores, :parents => parents, :match_score => match_score,\n :aligns => [align1, align2].map(&:reverse) }\nend", "def align_len\n (@midline and @seq1.seq and @seq2.seq) ? @midline.length : nil\n end", "def remove_inserts\n\n currseq = \"\"\n currname = \"\"\n # TODO: extract this from all methods to a helper class \n @content.each do |line|\n # if name anchor is found start a new bin\n if (line =~ /^>(.*)/)\n # check if we found next bin\n if (currseq.length > 0)\n # push name and sequence to containers\n @names << currname\n @seqs << currseq\n end\n # name is found next to anchor\n currname = $1\n # no sequence data yet\n currseq = \"\"\n else\n # append sequence data\n currseq += line\n end \n end \n # collect the data from the last bin\n if (currseq.length > 0)\n @names << currname\n @seqs << currseq\n end\n \n match_cols = []\n \n # Determine which columns have a gap in first sequence (match_cols = false)\n residues = @seqs[0].unpack(\"C*\")\n residues.each_index do |num|\n if (residues[num] == 45 || residues[num] == 46)\n match_cols[num] = false\n else\n match_cols[num] = true\n end\n end\n \n # Delete insert columns\n @names.each_index do |i|\n # Unpack C : 8-bit unsigned integer , push -> Array\n residues = @seqs[i].unpack(\"C*\")\n seq = \"\"\n # traverse over Integer Representation\n residues.each_index do |num|\n # If the base Sequence has no gap then check current sequence \n if (match_cols[num])\n if (residues[num] == 45 || residues[num] == 46)\n # Add gap to Sequence\n seq += \"-\"\n else\n # Add the Residue to Sequence\n seq += residues[num].chr\n end \n end \n end\n # Remove anchoring String Characters\n seq.tr!('^a-zA-Z-','')\n # Push an Upper Case representation to the @seqs array\n @seqs[i] = seq.upcase\n # Check whether all sequences have same length as parent\n if (@seqs[i].length != @seqs[0].length)\n logger.debug \"ERROR! Sequences in alignment do not all have equal length!\"\n end\n end\n end", "def align_right?(column)\n numeric_columns = [:Read_length, :Date, :Insert_length, :Distinct_peptides, :Peptide_diversity, :Selection_round, :Sequence_length, :Reads_sum, :Dominance_sum, :Rank, :Reads, :Dominance]\n numeric_columns.include?(column)\n end", "def align\n @options[:align]\n end", "def bucketized_alignment\n # split reads into buckets according to their size and err_rate\n @buckets = bucketize(@err_rate)\n\n # perform alignment on each bucket\n @buckets.reverse_each do |lower, upper, mismatches|\n @names.set_bucket(lower, upper)\n mapped, unmapped = align(\n @ref, @ref_base, @software,\n { annotation: @annotation,\n tophat_aligner: @tophat_aligner,\n mismatches: mismatches\n }\n )\n @mapped_bams << mapped\n @unmapped_bams << unmapped\n @max_mismatches = [@max_mismatches, mismatches].max\n end\n\n # merge alignments\n @names.unset_bucket\n unbucketize(@mapped_bams, @names.get('mapped_merged'))\n unbucketize(@unmapped_bams, @names.get('unmapped_merged'))\n end", "def left_aligned?\n value == :left\n end", "def align(addr, width)\n\treturn addr + pad_length(addr, width)\nend", "def alignment(name)\n {\n \"left\" => -1,\n \"center\" => 0,\n \"right\" => 1\n }[name.to_s]\n end", "def print_align(io, sequences, labels, opts={})\n opts = {:cutoff => 70, :start => 0, :chars => 20}.merge(opts)\n (start, length, chars) = opts.values_at(:start, :cutoff, :chars)\n spacer = \" \"\n\n if opts[:template]\n sequences.unshift(opts[:template])\n labels.unshift(opts[:template_label])\n end\n\n all_stats = Array.new(6,0)\n loop do\n fin = false\n\n max_length = 0\n lines = []\n consensus_line = \"\"\n fragments = sequences.map do |string|\n fin = (start >= string.length )\n break if fin\n\n string_frag = string[start, length]\n\n string_frag\n end ; break if fin\n\n doubles = fragments.zip(labels)\n\n doubles = doubles.select {|frag, _| (frag.size > 0) && (frag =~ /[^-]/) }\n\n max_length = doubles.map {|frag, _| frag.size }.max\n\n (cs, stats) = consensus_string_and_stats( doubles.map {|frag,_| frag } )\n all_stats = all_stats.zip(stats).map {|a,b| a + b }\n\n doubles.push( [cs, \"<CONSENSUS>\"] )\n\n lines = doubles.map {|frag, label| [exactly_chars(label, chars),spacer,frag].join }\n\n ## the counters at the top of the line\n start_s = start.to_s\n finish_s = (start + max_length).to_s\n count_line_gap = max_length - (start_s.size + finish_s.size)\n count_line = [start_s, spacer]\n unless count_line_gap < 1\n count_line << \" \" * count_line_gap\n end\n io.puts [exactly_chars(\"\", chars), spacer, count_line.join].join\n\n io.puts lines.join(\"\\n\")\n\n io.puts \" \" # separator between lines\n start += length\n end\n end", "def get_clustalw \n answer = []\n self.homology_members.each do |hm|\n answer.push(hm.aligned_sequence)\n end \n return Bio::Alignment::OriginalAlignment.new(answer) \n end", "def aligner(infile, justification = :Left)\n fieldsbyrow = infile.map {|line| line.strip.split('$')}\n # pad to same number of fields per record\n maxfields = fieldsbyrow.map(&:length).max\n fieldsbyrow.map! {|row| row + ['']*(maxfields - row.length)}\n # calculate max fieldwidth per column\n colwidths = fieldsbyrow.transpose.map {|column|\n column.map(&:length).max\n }\n # pad fields in columns to colwidth with spaces\n justifier = J2justifier[justification]\n fieldsbyrow.map {|row|\n row.zip(colwidths).map {|field, width|\n field.send(justifier, width)\n }.join(\" \")\n }.join(\"\\n\")\nend", "def horizontal_alignment\n return @horizontal_alignment\n end", "def get_alignment\n @halign = CP::CMS::DEFAULT_ALIGNMENT # Sets alignment to default\n @halign = 2 if @text.include?(\"\\\\alir\") # Sets alignment to right\n @halign = 2 if @text.include?(\"\\\\ar\")\n @halign = 1 if @text.include?(\"\\\\alic\") # Sets alignment to center\n @halign = 1 if @text.include?(\"\\\\ac\")\n @halign = 0 if @text.include?(\"\\\\alil\") # Sets alignment to left\n @halign = 0 if @text.include?(\"\\\\al\")\n @text.gsub!(/\\\\(?:alil|alic|alir|ar|ac|al)/){\"\"}# Clears alignment modifiers\n end", "def unbucketized_alignment\n align(\n @ref, @ref_base, @software,\n { annotation: @annotation,\n tophat_aligner: @tophat_aligner,\n mismatches: @mismatches\n }\n )\n mapped_all = @software == :star ? \\\n @names.get('mapped_all_star') : @names.get('mapped_all')\n run_cmd(\"cp #{mapped_all} #{@names.get('mapped_merged')}\")\n unless @software == :star\n run_cmd(\n \"cp #{@names.get('unmapped')} #{@names.get('unmapped_merged')}\"\n )\n end\n @max_mismatches = @mismatches\n end", "def left_align\n @align = nil\n end", "def warp_aligned\n \n align = params[:align]\n append = params[:append]\n destmap = Map.find(params[:destmap])\n\n if destmap.status.nil? or destmap.status == :unloaded or destmap.status == :loading\n flash.now[:notice] = t('.no_destination')\n redirect_to :action => \"show\", :id=> params[:destmap]\n elsif align != \"other\"\n\n if params[:align_type] == \"original\"\n destmap.align_with_original(params[:srcmap], align, append )\n else\n destmap.align_with_warped(params[:srcmap], align, append )\n end\n flash.now[:notice] = t('.success')\n redirect_to :action => \"warp\", :id => destmap.id\n else\n flash.now[:notice] = t('.unknown_alignment')\n redirect_to :action => \"align\", :id=> params[:srcmap]\n end\n end", "def warp_aligned\n\n align = params[:align]\n append = params[:append]\n destmap = Map.find(params[:destmap])\n\n if destmap.status.nil? or destmap.status == :unloaded or destmap.status == :loading\n flash.now[:notice] = \"Sorry the destination map is not available to be aligned.\"\n redirect_to action: \"show\", id: params[:destmap]\n elsif align != \"other\"\n\n if params[:align_type] == \"original\"\n destmap.align_with_original(params[:srcmap], align, append )\n else\n destmap.align_with_warped(params[:srcmap], align, append )\n end\n flash.now[:notice] = \"Map aligned. You can now rectify it!\"\n redirect_to action: \"warp\", id: destmap.id\n else\n flash.now[:notice] = \"Sorry, only horizontal and vertical alignment are available at the moment.\"\n redirect_to action: \"align\", id: params[:srcmap]\n end\n end", "def parse_alignment_options(options = {})\n return unless options[:alignment]\n\n CellAlignment.new options[:alignment]\n end", "def right_aligned?\n value == :right\n end", "def align_local(protein)\n # Vytvoreni tabulky\n x = protein.sequence.size\n y = @genome.sequence.size\n tab = Array.new(x+1) { Array.new(y+1) }\n\n # Vyplnime prvni radek a sloupec\n for i in 0..x\n tab[i][0] = 0\n end\n for j in 0..y\n tab[0][j] = 0\n end\n\n for i in 1..x\n for j in 1..y\n match = tab[i-1][j-1] + match(i, j, protein)\n delete = tab[i-1][j] + @@d\n insert = tab[i][j-1] + @@d\n\n tab[i][j] = [match, delete, insert, 0].max\n end\n end\n\n @table = tab\n value = 0\n @lok_max_coordinates = [0,0]\n for i in 1..x\n for j in 1..y\n if tab[i][j] >= value\n value = tab[i][j]\n @lok_max_coordinates = [i, j]\n end\n end\n end\n EvaluatedProtein.new(protein, value)\n end", "def ralign(a, b, length=CONSOLE_WIDTH)\n p = length-a.length-b.length\n a + (\" \"*p) + b\n end", "def align_len\n @qseq ? @qseq.size : nil\n end", "def right_justified_columns\n res = fields.map.with_index do |field, i|\n klass = String::Trait.trait_class(field) rescue nil\n justification = klass && klass.justification rescue :left\n [justification, i]\n end\n res = res.select {|justification, index| justification == :right}\n .map{|justification, index| index}\n res\n end", "def align=(align)\n set_align(align)\n generate_buffers\n end", "def vertical_alignment\n return @vertical_alignment\n end", "def find_alignment (alignment)\r\n total = 0\r\n weighted_alignment = alignment.each do |alignment|\r\n alignment.weight = alignment.weight + total\r\n total = alignment.weight\r\n alignment\r\n end\r\n percentage = rand(1..total)\r\n weighted_alignment.each do |alignment|\r\n return alignment.name if percentage <= alignment.weight\r\n end\r\nend", "def magic_alignement()\n\t\tdt = @buswi[0][0]\n\t\tokb = [@buswi[0]]\n\n\t\tremb = @buswi[1..].clone\n\t\tt=0\n\t\tloop do \n\t\t\tt = t + dt\n\t\t\tokb=[]\n\t\t\tremb.each do |p,i|\n\t\t\t\tif (t+i)%p == 0\n\t\t\t\t\tdt = dt.lcm(p)\n\t\t\t\t\tokb << [p,i]\n\t\t\t\tend\n\t\t\tend\n\t\t\tremb = remb - okb\n\t\t\tbreak if remb.empty?\n\t\tend\n\t\tt\n\tend", "def sub_alignment _value=0\n send_cmd(\"sub_alignment #{_value}\")\n end", "def align(align=nil)\n @options[:align] = align unless align.nil?\n @options[:align]\n end", "def call(field, row, col)\n align_field(field, col)\n end", "def call(field, row, col)\n align_field(field, col)\n end", "def aligned\n case align\n when :right then text.rjust(width, ' ')\n when :centre then text.center(width, ' ')\n else text.ljust(width, ' ')\n end\n end", "def convert_alignment(args={})\n i, o = args[:in], args[:out]\n \n ff = Bio::FlatFile.auto(i).to_a\n aln = Bio::Alignment.new(ff)\n File.open(o, 'w') do |o|\n o.write aln.output :phylip\n end\n \nend", "def matching_records_arel(table_name)\n s = Arel::Table.new(\"#{table_name}_view\")\n arel_columns = column_names.map{ |c| Arel::Attribute.new(s, c) }\n Trade::SandboxTemplate.select('*').from(\"#{table_name}_view\").where(\n arel_columns.shift.eq(arel_columns.shift)\n )\n end", "def match_same_name_attributes(*options)\n\n options = options.extract_options!\n same_name_attributes = @from_table.columns.map(&:name) & @to_table.columns.map(&:name)\n\n if same_name_attributes\n same_name_attributes = columns_from_options(same_name_attributes, options)\n same_name_attributes.each do |same_name_attribute|\n from same_name_attribute, :to => same_name_attribute\n end\n end\n end", "def dna_align_features(analysis_name = nil)\n \tif analysis_name.nil?\n return DnaAlignFeature.find_by_sql('SELECT * FROM dna_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s)\n else\n analysis = Analysis.find_by_logic_name(analysis_name)\n return DnaAlignFeature.find_by_sql('SELECT * FROM dna_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s + ' AND analysis_id = ' + analysis.id.to_s)\n end\n end", "def merge_pairwise(aligns)\n ps = aligns.map do |align| \n seqs = []\n align.each do |bioseq|\n seqs << bioseq.to_s\n end\n seqs\n end\n template = []\n #m,x,n\n x = 2\n ftemp = ps.first.first\n nmax = ps.map {|pair| pair.first.size }.max\n mmax = ps.size\n mar = (0...mmax).to_a\n others = mar.map { [] }\n ns = mar.map { 0 }\n tn = 0\n on = 0\n (0...nmax).each do |n|\n (t_dsh, t_no_dsh) = mar.partition do |m| \n # this is RUBY 1.8 ONLY!!\n ps[m][0][ns[m]] == 45 # '-' is ascii 45\n end\n\n # if a template has a dash, all other off-templates need a dash\n if t_dsh.size > 0\n template[tn] = 45\n t_no_dsh.each do |m|\n # don't update these guys counter\n others[m][tn] = 45\n end\n t_dsh.each do |m|\n others[m][tn] = ps[m][1][ns[m]]\n ns[m] += 1\n end\n else # no dashes in the template\n t_no_dsh.each do |m|\n others[m][tn] = ps[m][1][ns[m]]\n end\n template[tn] = ps[0][0][ns[0]]\n ns.map!{|v| v+1 } \n end\n tn += 1\n end\n [cs_to_s(template), others.map! {|ar| cs_to_s(ar) } ]\n end", "def option_align\n @align = true\n end", "def dna_align_features(analysis_name = nil)\r\n \tif analysis_name.nil?\r\n return DnaAlignFeature.find_by_sql('SELECT * FROM dna_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s)\r\n else\r\n analysis = Analysis.find_by_logic_name(analysis_name)\r\n return DnaAlignFeature.find_by_sql('SELECT * FROM dna_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s + ' AND analysis_id = ' + analysis.id.to_s)\r\n end\r\n end", "def generate_alignment\n raise ArgumentError, 'Missing genome FASTA file.' unless @genome_file\n raise ArgumentError, 'Missing transcripts FASTA file.' unless @transcripts_file\n \n # Prepare the BLAT alignment\n blat = Alignment::BLAT.new(@blat_options.merge({ out_format: :tab, database: @genome_file }))\n \n # Optionally set a permanent file to write the results to\n @alignment_file ||= \"#{@transcripts_file}.alignment\"\n blat.output_file = @alignment_file\n \n puts \"Running BLAT alignment...\" if @verbose\n \n # Run\n result_file = blat.run(@transcripts_file)\n result_file.path\n end", "def align_field(field, col)\n column_width = widths[col]\n direction = field.alignment || alignments[col] || DEFAULT\n Strings.align(field.content, column_width, direction: direction)\n end", "def build_lcs_length_table(str1, str2)\n p str1\n p str2\n lcs_length_table = []\n directional_table = nil\n #in both of the table the the first dimansion representing str2 and the second demansion representing str1\n (0..str2.size).each do |i|\n lcs_length_table[i] = [0]\n end\n \n (0..str1.size).each do |j|\n lcs_length_table[0][j] = 0\n end\n \n directional_table = deep_copy(lcs_length_table)\n\n (1..str2.size).each do |j|\n (1..str1.size).each do |i|\n devired_val = [ lcs_length_table[ j - 1 ][i], lcs_length_table[ j][ i -1 ]].max\n #determind the direction of the devired_val\n if lcs_length_table[ j - 1 ][i] == devired_val #prefre go up first when the two values are the same\n devired_from = \"^\"\n else\n devired_from = \"<\"\n end\n #puts \"#{\"\"<<str2[j - 1] } #{\"\"<<str1[i - 1]} #{j-1} #{i-1}\"\n if str2[j - 1] == str1[i - 1]\n lcs_length_table[j][i] = lcs_length_table[j-1][i-1] + 1\n directional_table[j][i] = \"=\"\n else\n lcs_length_table[j][i] = devired_val\n directional_table[j][i] = devired_from\n end\n end\n end\n\n\n lcs_length_table.each do |row|\n p row\n end\n\n directional_table.each do |row|\n p row\n end\n \n p get_common_sequence_from_directional_table(directional_table, str1.size, str2.size, str2)\n\n return lcs_length_table\nend", "def accept_table header, body, aligns\n widths = header.zip(body) do |h, b|\n [h.size, b.size].max\n end\n aligns = aligns.map do |a|\n case a\n when nil\n :center\n when :left\n :ljust\n when :right\n :rjust\n end\n end\n @res << header.zip(widths, aligns) do |h, w, a|\n h.__send__(a, w)\n end.join(\"|\").rstrip << \"\\n\"\n @res << widths.map {|w| \"-\" * w }.join(\"|\") << \"\\n\"\n body.each do |row|\n @res << row.zip(widths, aligns) do |t, w, a|\n t.__send__(a, w)\n end.join(\"|\").rstrip << \"\\n\"\n end\n end", "def ensure_sequence_setup(table_pair, increment, left_offset, right_offset)\n table_options = options(table_pair[:left])\n if table_options[:adjust_sequences]\n rep_prefix = table_options[:rep_prefix]\n left_sequence_values = session.left.sequence_values rep_prefix, table_pair[:left]\n right_sequence_values = session.right.sequence_values rep_prefix, table_pair[:right]\n [:left, :right].each do |database|\n offset = database == :left ? left_offset : right_offset\n session.send(database).update_sequences \\\n rep_prefix, table_pair[database], increment, offset,\n left_sequence_values, right_sequence_values, table_options[:sequence_adjustment_buffer]\n end\n end\n end", "def each\n @aln.each do | seq |\n yield seq[@col]\n end\n end", "def initialize(first_unaligned, second_unaligned, shift, orientation)\n @shift, @orientation = shift, orientation\n\n @first_length, @second_length = first_unaligned.length, second_unaligned.length\n @length = self.class.calculate_alignment_length(@first_length, @second_length, @shift)\n\n first, second = first_unaligned, second_unaligned\n second = second.reverse_complemented if revcomp?\n\n if shift > 0\n second = second.left_augmented(shift)\n else\n first = first.left_augmented(-shift)\n end\n\n @first = first.right_augmented(@length - first.length)\n @second = second.right_augmented(@length - second.length)\n end", "def columnate!(theWidth, thePad = ' ')\n\n # Setup the basic sizes.\n\n trLen = @theLines.length\n return self if trLen == 0\n thePad = '' if thePad.nil?\n pdWide = thePad.length\n trWide = self.width\n cols = 1\n\n # If there is just no room to break at all, return now.\n\n return self if 2*trWide + pdWide > theWidth\n\n # At least two columns will fit. See how many more will.\n\n 2.upto(theWidth) do |i|\n break if i*trWide + (i-1)*pdWide > theWidth\n cols = i\n end\n \n # Find the length of the basic columns. There may be some extra elements\n # beyond the allocation of the original. Pass them to the columns one by\n # one from left to right.\n\n baseLen = trLen.div(cols)\n theLens = Array.new(cols, baseLen)\n 0.upto(trLen-cols*baseLen-1) { |i| theLens[i] = theLens[i] + 1 }\n\n # Now create an array of lines for each column.\n\n colArrays = Array.new(cols, Array.new)\n colStart = 0\n 0.upto(cols-1) do |i|\n colArrays[i] = @theLines[colStart, theLens[i]]\n colStart += theLens[i]\n end\n\n # Readjust the current TR with the first column of lines.\n\n @theLines = colArrays[0]\n\n # Now for each of the other columns, join it to the existing TR using the\n # pad in between.\n\n 1.upto(cols-1) do |i|\n theCol = TextRect.new(colArrays[i])\n theCol.lPad!(thePad) if pdWide > 0\n self.join!(theCol)\n end\n\n return self\n\n end", "def aligns(map: @map, cursor: @cursor, width: @width)\n return 0 unless exit_allowed?\n tmp_cursor = cursor.copy\n tmp_cursor.forward!()\n tmp_cursor.shift!(:left)\n left_square = map.square(cursor.map_pos)\n tmp_cursor.shift!(:right, width + 1)\n right_square = map.square(cursor.map_pos)\n alignments = 0\n alignments += 1 if left_square.edges[cursor.facing(:right)] == :wall\n alignments += 1 if right_square.edges[cursor.facing(:left)] == :wall\n return alignments\n end", "def fetch_ancestral_sequence(start=0,stop=self.length)\n self.genomic_aligns.select{|c| c.find_organism == \"Ancestral sequences\"}.each do |contig|\n puts contig.find_organism\n #return contig.aligned_sequence[start..stop]\n end\n end", "def collaps_qnames(input_file, output_file)\n\t\n\t\tloci = {}\n\t\n\t\t# Read candidate loci and count reads/locus\n\t\tFile.open(input_file, 'r').readlines.each do |line|\n\t\t\tline = line.strip.split(\"\\t\")\n\t\t\tqname = line[0]\n\t\t\tbase = qname.gsub(/\\/[1,2]/, '')\n\t\t\tpos_a = line[1..3].join(':')\n\t\t\tpos_b = line[4..6].join(':')\n\t\t\tpos = [pos_a, pos_b].join(':')\n\n\t\t\talignment_length = line[-1]\n\t\n\t\t\tif !loci.has_key?(pos)\n\t\t\t\tloci[pos] = {:count => 1, :qnames => [qname], :l => alignment_length}\n\t\t\telse \n\t\t\t\tloci[pos][:qnames] << qname\n\t\t\t\tloci[pos][:count] += 1\n\t\t\tend\n\t\tend\n\n\t\t# Output\n\t\tFile.open(output_file, 'w') do |output|\n\t\t\tloci.each do |pos, v| \n\t\t\t\toutput.puts [pos.split(':'), v[:count], v[:l], v[:qnames].join(';')].join(\"\\t\") if v[:count] > 0\n\t\t\tend\n\t\tend\n\t\t$logfile.puts \"#{Time.new.strftime(\"%c\")}: Collapsed anchor pairs to single loci.\"\n\tend", "def padded_aligned_data(data)\n string_repr = @data_to_s.call(data)\n\n string_repr = case @alignment\n when :left\n string_repr.ljust(@width)\n when :center\n string_repr.center(@width)\n when :right\n string_repr.rjust(@width)\n else\n string_repr\n end\n\n @padding ? @padding + string_repr + @padding : string_repr\n end", "def align_center\n self.center(LENGTH)\n end", "def columns_search \n column = [] \n search = @@boards_templates[1].to_s.scan(/./).each_slice(5).to_a\n for h in 0..4\n for v in 0..7 \n column << search[v][h] \n end \n end \n vertical_words = []\n vertical = column.join\n @@boards_templates[0].each do |x| \n if vertical.include?(x)\n vertical_words << x\n elsif vertical.reverse.include?(x)\n vertical_words << x \n end \n end \n vertical_words\n end", "def align_global(protein)\n # Vytvoreni tabulky\n x = protein.sequence.size\n y = @genome.sequence.size\n tab = Array.new(x+1) { Array.new(y+1) }\n\n # Vyplnime prvni radek a sloupec\n for i in 0..x\n tab[i][0] = @@d * i\n end\n for j in 0..y\n tab[0][j] = @@d * j\n end\n\n for i in 1..x\n for j in 1..y\n match = tab[i-1][j-1] + match(i, j, protein)\n delete = tab[i-1][j] + @@d\n insert = tab[i][j-1] + @@d\n\n tab[i][j] = [match, delete, insert].max\n end\n end\n\n @table = tab\n value = tab[x][y]\n EvaluatedProtein.new(protein, value)\n end", "def alignment(aligned_source)\n alignment_id ? aligned_source.treebank.find_sentence(alignment_id) : nil\n end", "def alignment_node(node)\n ancestor_node = ancestor_node(node)\n\n return ancestor_node if ancestor_node.nil? ||\n ancestor_node.kwbegin_type?\n\n assignment_node = assignment_node(ancestor_node)\n return assignment_node if same_line?(ancestor_node, assignment_node)\n\n access_modifier_node = access_modifier_node(ancestor_node)\n return access_modifier_node unless access_modifier_node.nil?\n\n ancestor_node\n end", "def aligned_text_position\n end", "def align_field(field, col)\n column_width = widths[col]\n alignment = Alignment.new(field.align || self[col])\n field.value = alignment.format(field, column_width)\n end", "def matching_records_arel(table_name)\n s = Arel::Table.new(\"#{table_name}_view\")\n v = Arel::Table.new(valid_values_view)\n arel_nodes = column_names_for_matching.map do |c|\n if required_column_names.include? c\n v[c].eq(s[c])\n else\n # if optional, check if NULL is allowed for this particular combination\n # e.g. unit code can be blank only if paired with certain terms\n v[c].eq(s[c]).or(v[c].eq(nil).and(s[c].eq(nil)))\n end\n end\n valid_values = s.project(s['*']).join(v).on(arel_nodes.inject(&:and))\n scoped_records_arel(s).except(valid_values)\n end", "def column_for_position(position); end" ]
[ "0.62100065", "0.6182961", "0.605207", "0.6010754", "0.59405696", "0.58625257", "0.5855632", "0.5836319", "0.58100814", "0.58100814", "0.58078563", "0.5795865", "0.57522017", "0.5722302", "0.5717905", "0.5706427", "0.5706427", "0.5607617", "0.5606497", "0.54501295", "0.5397335", "0.5397335", "0.5385567", "0.5385015", "0.5373764", "0.5345399", "0.53398067", "0.5336655", "0.52782524", "0.52695334", "0.5238467", "0.52297544", "0.52030474", "0.51835215", "0.5176422", "0.51744676", "0.5164685", "0.516174", "0.5133705", "0.51058507", "0.50918305", "0.5034136", "0.50241387", "0.5024022", "0.50113463", "0.5008184", "0.5003941", "0.49829683", "0.49748158", "0.4966315", "0.49629402", "0.49545425", "0.49382424", "0.49357438", "0.4928396", "0.4917859", "0.49014017", "0.48876435", "0.48735937", "0.4854842", "0.48407122", "0.48361403", "0.48205793", "0.48190147", "0.48143753", "0.48012644", "0.47982794", "0.4794223", "0.4788325", "0.4761123", "0.4761123", "0.4743708", "0.47210163", "0.4714823", "0.47055987", "0.47003785", "0.46979266", "0.46919692", "0.4679358", "0.4679346", "0.46771392", "0.4674159", "0.46705493", "0.4667135", "0.46665433", "0.46614403", "0.4654537", "0.46190783", "0.4587096", "0.4586711", "0.4574936", "0.45639545", "0.4551949", "0.4543203", "0.4526752", "0.4525932", "0.45242432", "0.45228267", "0.4512505", "0.4508523" ]
0.6533839
0
update all elements in the column def update! new_column each_with_index do |e,i|
def each @aln.each do | seq | yield seq[@col] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n $all_columns.each do |col|\n col[0] = col[1].call unless col[1].nil?\n end\nend", "def update!(columns)\n update(nil, columns)\n end", "def update!(**args)\n @column_items = args[:column_items] if args.key?(:column_items)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n end", "def _update_columns(columns)\n _update(columns) unless columns.empty?\n end", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n end", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @columns = args[:columns] if args.key?(:columns)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @column_span = args[:column_span] if args.key?(:column_span)\n @row = args[:row] if args.key?(:row)\n @row_span = args[:row_span] if args.key?(:row_span)\n end", "def update_column(name, value)\n update_columns(name => value)\n end", "def update_column(name, value)\n update_columns(name => value)\n end", "def update_column(name, value)\n update_columns(name => value)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @max_count = args[:max_count] if args.key?(:max_count)\n @stride_length = args[:stride_length] if args.key?(:stride_length)\n end", "def update!(**args)\n @column_items = args[:column_items] if args.key?(:column_items)\n @wrap_style = args[:wrap_style] if args.key?(:wrap_style)\n end", "def update_all!\n each do |ir, ic, val|\n @cells[ir][ic] = yield val\n end\n end", "def update_index\n all.each do |n|\n n.update_index\n end\n end", "def update_table_column(column)\n changes_to_commit << ColumnChange::Update.from_column(column)\n end", "def update(index, value)\n index = input_to_index(index)\n @cells[index] = value.token\n end", "def _update(columns)\n model.cti_models.each do |m|\n h = {}\n m.cti_table_columns.each{|c| h[c] = columns[c] if columns.include?(c)}\n cti_this(m).update(h) unless h.empty?\n end\n end", "def _update_columns(columns)\n @columns_updated ||= DeprecatedColumnsUpdated.new(columns) # SEQUEL5: Remove\n _update(columns) unless columns.empty?\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update_content(data)\n data.values.each do |change|\n row = change[0].to_i\n col = change[1].to_i\n cell = self[row][col]\n cell.content = change.last\n cell.save\n end\n end", "def increase_columns(column)\n @sheet_data.each do |r|\n r.size.upto(column) do\n r << nil\n end\n end\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @default_value = args[:default_value] if args.key?(:default_value)\n @description = args[:description] if args.key?(:description)\n @gc_rule = args[:gc_rule] if args.key?(:gc_rule)\n @highest_indexing_type = args[:highest_indexing_type] if args.key?(:highest_indexing_type)\n @looker_column_spec = args[:looker_column_spec] if args.key?(:looker_column_spec)\n @mode = args[:mode] if args.key?(:mode)\n @ordinal_position = args[:ordinal_position] if args.key?(:ordinal_position)\n @subcolumns = args[:subcolumns] if args.key?(:subcolumns)\n @type = args[:type] if args.key?(:type)\n end", "def update!(row = @row, col = @col)\n @cells[row][col] = yield at(row, col)\n end", "def increment_column!(attribute, by = 1)\n # \"foo\"\n increment(attribute, by).update_column(attribute, self[attribute])\n end", "def update_cell(column, value)\n table_name = self.class.to_s.pluralize.underscore\n return CONNECTION.execute(\"UPDATE #{table_name} SET #{column} = '#{value}' WHERE id = #{@id}\")\n end", "def update(&block)\n self.each_with_index do |e,i|\n self[i] = block.call(e)\n end\nend", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n @rows = args[:rows] if args.key?(:rows)\n end", "def replace_column!(column, values)\n store_range_hashes\n column = validate_column(column)\n index = self.labels.index(column)\n @items.each_with_index do |item, i|\n item[index] = values[i]\n end\n \n # Make sure we recalculate things after changing a column\n self.items.taint\n @columns = nil\n self.columns\n restore_range_hashes\n \n # Return the items\n @items\n end", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n @columns_int16 = args[:columns_int16] if args.key?(:columns_int16)\n @columns_int32 = args[:columns_int32] if args.key?(:columns_int32)\n @columns_int64 = args[:columns_int64] if args.key?(:columns_int64)\n @columns_int8 = args[:columns_int8] if args.key?(:columns_int8)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @description = args[:description] if args.key?(:description)\n @mode = args[:mode] if args.key?(:mode)\n @subcolumns = args[:subcolumns] if args.key?(:subcolumns)\n @type = args[:type] if args.key?(:type)\n end", "def update!\n @model.columns.each do |column|\n if row = @attrs.find {|x| x[:name] == column.name}\n if row[:type] != type_str(column)\n puts \" M #{@model}##{column.name} [#{row[:type]} -> #{type_str(column)}]\"\n row[:type] = type_str(column)\n elsif row[:desc] == InitialDescription::DEFAULT_DESCRIPTION\n new_desc = InitialDescription.for(@model, column.name)\n if row[:desc] != new_desc\n puts \" M #{@model}##{column.name} description updated\"\n row[:desc] = new_desc\n end\n end\n else\n puts \" A #{@model}##{column.name} [#{type_str(column)}]\"\n @attrs << {\n :name => column.name,\n :type => type_str(column),\n :desc => InitialDescription.for(@model, column.name)\n }\n end\n end\n\n # find columns that no more exist in db\n orphans = @attrs.map{|x| x[:name]} - @model.columns.map(&:name)\n unless orphans.empty?\n orphans.each do |orphan|\n puts \" D #{@model}##{orphan}\"\n @attrs = @attrs.select {|x| x[:name] != orphan}\n end\n end\n\n @attrs\n end", "def update_columns=(column_names)\n @update_columns = Array(column_names)\n end", "def modify_columns(columns)\n columns\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @value = args[:value] if args.key?(:value)\n end", "def increment_position\n # return unless in_list?\n update_attribute position_column, self.send(position_column).to_i + 1\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @scaling_type = args[:scaling_type] if args.key?(:scaling_type)\n @size_range = args[:size_range] if args.key?(:size_range)\n @value_range = args[:value_range] if args.key?(:value_range)\n end", "def []=(i, v)\n values[column_index i] = v\n end", "def board_update\n matrix.each do |row|\n row.each do |cell|\n cell.board_updates\n end\n end\n end", "def update_avail_q_matrix_column(column_index, q_id)\n @avail_q_matrix.column(column_index).each do |item|\n item.delete(q_id)\n end\n # @avail_q_matrix.each_with_index do |elem, row, col|\n # if col == column_index && !(elem&[q_id]).empty?\n # @avail_q_matrix[row, col] -= [q_id]\n # end\n # end\n end", "def _update(columns)\n n = _update_without_checking(columns)\n raise(NoExistingObject, \"Attempt to update object did not result in a single row modification (SQL: #{_update_dataset.update_sql(columns)})\") if require_modification && n != 1\n n\n end", "def _update(columns)\n n = _update_without_checking(columns)\n raise(NoExistingObject, \"Attempt to update object did not result in a single row modification (SQL: #{_update_dataset.update_sql(columns)})\") if require_modification && n != 1\n n\n end", "def columns=(value)\n return if @columns == value\n @columns = value\n refresh\n end", "def column=(_); end", "def update!(**args)\n @custom_columns = args[:custom_columns] if args.key?(:custom_columns)\n end", "def update!(**args)\n @cols = args[:cols] if args.key?(:cols)\n @rows = args[:rows] if args.key?(:rows)\n end", "def update(row, col, val) \n diff = val - matrix[row][col]\n matrix[row][col] = val\n matrix_row = sum_matrix[row]\n col.upto(matrix_row.length - 1) do |idx|\n matrix_row[idx] += diff\n end\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @operator = args[:operator] if args.key?(:operator)\n @value = args[:value] if args.key?(:value)\n end", "def update_cell_value!(nrow, ncol_or_name, value)\r\n ncol = header_index(ncol_or_name)\r\n if (0..(row_count - 1)).include?(nrow) && \\\r\n (0..(col_count - 1)).include?(ncol)\r\n @data.fill((nrow * (col_count)) + ncol,1) {|i| value}\r\n end\r\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @invalid_values_allowed = args[:invalid_values_allowed] if args.key?(:invalid_values_allowed)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @invalid_values_allowed = args[:invalid_values_allowed] if args.key?(:invalid_values_allowed)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @data_type = args[:data_type] if args.key?(:data_type)\n @length = args[:length] if args.key?(:length)\n @nullable = args[:nullable] if args.key?(:nullable)\n @ordinal_position = args[:ordinal_position] if args.key?(:ordinal_position)\n @precision = args[:precision] if args.key?(:precision)\n @primary_key = args[:primary_key] if args.key?(:primary_key)\n @scale = args[:scale] if args.key?(:scale)\n end", "def update_array_at_with(array, index)\n board[index] = \"X\"\nend", "def update!(**args)\n @column_headers = args[:column_headers] if args.key?(:column_headers)\n @kind = args[:kind] if args.key?(:kind)\n @rows = args[:rows] if args.key?(:rows)\n end", "def increment_positions_on_all_items\n # acts_as_list_class.update_all(\"#{position_column} = (#{position_column} + 1)\", \"#{scope_condition}\")\n acts_as_list_class.with_acts_as_list_scope(scope_condition) do \n update_all(\"#{position_column} = (#{position_column} + 1)\")\n end \n end", "def _update_without_checking(columns)\n _update_dataset.update(columns)\n end", "def _update_without_checking(columns)\n _update_dataset.update(columns)\n end", "def update_index\n all.nodes.each do |n|\n n.reindex!\n end\n end", "def update!(**args)\n @cells = args[:cells] if args.key?(:cells)\n end", "def update!(**args)\n @cells = args[:cells] if args.key?(:cells)\n end", "def replace_column(header,val)\n headers.include?(header) or raise \"No such column as #{path}\"\n items.each do |i|\n i.replace_column(header,val)\n end\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def update!(**args)\n @index = args[:index] if args.key?(:index)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @data_type = args[:data_type] if args.key?(:data_type)\n @encoding = args[:encoding] if args.key?(:encoding)\n @length = args[:length] if args.key?(:length)\n @nullable = args[:nullable] if args.key?(:nullable)\n @ordinal_position = args[:ordinal_position] if args.key?(:ordinal_position)\n @precision = args[:precision] if args.key?(:precision)\n @primary_key = args[:primary_key] if args.key?(:primary_key)\n @scale = args[:scale] if args.key?(:scale)\n end", "def columns=(arr)\n @columns = arr\n update_height\n end", "def column!( column )\n columns && Mtx.synchronize { @columns << column }\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @column_number = args[:column_number] if args.key?(:column_number)\n @line_number = args[:line_number] if args.key?(:line_number)\n @message = args[:message] if args.key?(:message)\n @message_code = args[:message_code] if args.key?(:message_code)\n @severity = args[:severity] if args.key?(:severity)\n end", "def update!(**args)\n @field_name = args[:field_name] if args.key?(:field_name)\n @index = args[:index] if args.key?(:index)\n end", "def update_column\n do_update_column\n @column_span_id = params.delete(:editor_id) || params.delete(:editorId)\n end", "def update_array_at_with (array, i, char)\n array[i] = X\nend", "def update!(**args)\n @cols = args[:cols] if args.key?(:cols)\n @data = args[:data] if args.key?(:data)\n @rows = args[:rows] if args.key?(:rows)\n @type = args[:type] if args.key?(:type)\n end", "def reindex!\n find(:all).each { |r| r.update_index(true) }\n end", "def _update_without_checking(columns)\n ds = _update_dataset\n lc = model.lock_column\n rows = ds.clone(ds.send(:default_server_opts, :sql=>ds.output(nil, [Sequel[:inserted][lc]]).update_sql(columns))).all\n values[lc] = rows.first[lc] unless rows.empty?\n rows.length\n end", "def add_column(pos)\n start = pos[:at].to_i\n count = pos[:count].to_i\n columns.each do |column|\n column.position += count if column.position >= start\n end\n count.times { columns.new(position: pos[:at]) }\n saved = columns.collect {|column| column.save }\n saved.all?\n end", "def update_ion_indices\n ion = self.class.ion\n\n\n # Clear out previous indexes...\n ion.index_types.each { |i_type| i_type.deindex(self) }\n\n Ion.redis.multi\n # And add new ones\n ion.indices.each { |index| index.index(self) }\n Ion.redis.exec\n end", "def []=(column_index, value)\n @row[column_index] = value.part\n $dirty << [column_index, @row_index]\n $blocks_to_redraw << [column_index, @row_index]\n end", "def update_cells(value, key)\n rows = target_rows(key)\n rows.each do |row|\n @worksheet[row, @selected_browser_column] = value\n end\n @worksheet.save\n end", "def db_column_func(&block)\n new_structure = self.class.db_structure\n\n yield(new_structure)\n self.class.update_db(new_structure)\n new_structure\n end", "def matrix_replace(row, column, newvalue)\n self[row*9 + column] = newvalue\n end", "def insert_column(col_index=0)\n validate_workbook\n validate_nonnegative(col_index)\n increase_columns(col_index)\n\n old_index = col_index > 0 ? col_index-1 : col_index+1\n old_col = @cols[get_cols_index(old_index)]\n if old_index == 1\n old_col = nil\n end\n\n #go through each cell in column\n @sheet_data.each_with_index do |r,i|\n #insert \"column\" in each row\n r.insert(col_index, nil)\n\n #copy styles over to each cell\n old_cell = r[old_index]\n unless old_cell.nil?\n #only add cell if style exists, not copying content\n if old_cell.style_index != 0\n if !old_col.nil? && old_cell.style_index.to_s != old_col[:attributes][:style].to_s\n c = Cell.new(self,i,col_index)\n c.style_index = old_cell.style_index\n @sheet_data[i][col_index] = c\n end\n end\n end\n end\n\n #copy over column-level styles\n new_col = change_cols(get_cols_index(old_index),old_index)\n @cols[-1] = deep_copy(old_col)#-1 = last\n\n new_col = @cols.last\n if @cols.last.nil?\n @cols.pop\n end\n\n #shift col styles 'right'\n @cols.each do |col|\n if Integer(col[:attributes][:min]) > col_index\n col[:attributes][:min] = (1 + Integer(col[:attributes][:min])).to_s\n end\n if Integer(col[:attributes][:max]) > col_index\n col[:attributes][:max] = (1 + Integer(col[:attributes][:max])).to_s\n end\n end\n unless new_col.nil?\n new_col[:attributes][:min] = (1 + Integer(new_col[:attributes][:min])).to_s\n new_col[:attributes][:max] = (1 + Integer(new_col[:attributes][:max])).to_s\n end\n\n #update column numbers\n @sheet_data.each do |row|\n (col_index+1).upto(row.size) do |j|\n unless row[j].nil?\n row[j].column += 1\n end\n end\n end\n end", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n @shuffle_questions = args[:shuffle_questions] if args.key?(:shuffle_questions)\n end", "def test_update_out_of_range1;\n a=[[1,0,1],[0,1,0]]\n show(a)\n a[0][3]=0.5\n end" ]
[ "0.68217504", "0.6674451", "0.663382", "0.6479402", "0.6311979", "0.63091266", "0.63091266", "0.62969023", "0.62700415", "0.62667555", "0.62667555", "0.62667555", "0.6266312", "0.62300855", "0.6189491", "0.6120177", "0.60762954", "0.60250795", "0.59968764", "0.59918237", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.59807444", "0.5978973", "0.59781426", "0.5972589", "0.596024", "0.5935282", "0.5847423", "0.58465654", "0.5804143", "0.5797309", "0.57872653", "0.5785442", "0.578464", "0.5778963", "0.5741169", "0.5722516", "0.5653731", "0.5645605", "0.56409806", "0.5638064", "0.5631773", "0.5611016", "0.5611016", "0.56035286", "0.55959237", "0.5593087", "0.5581549", "0.5565673", "0.5559908", "0.55535173", "0.55392265", "0.55392265", "0.55338395", "0.5530703", "0.5523055", "0.55195177", "0.5505771", "0.5505771", "0.5472441", "0.54379493", "0.54379493", "0.5434669", "0.54297954", "0.54297954", "0.54297954", "0.54297954", "0.54244006", "0.54160964", "0.54126114", "0.5396191", "0.53950584", "0.5390232", "0.53877324", "0.5367716", "0.5363631", "0.5350966", "0.535036", "0.53478444", "0.5341176", "0.5336997", "0.5334092", "0.5323344", "0.53169066", "0.53151214", "0.5307891" ]
0.0
-1
make a hash add a new key to the hash if that key doesn't exist if a key does exist...stop/break/exit/ return true return false when...after the loop is done
def duplicates?(input_numbers) collection_of_numbers = {} input_numbers.each do |number| if collection_of_numbers[number] return true else collection_of_numbers[number] = true end end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_or_create_for!(hash, key)\n hash[key] = \"\" unless hash.include?(key)\n end", "def duplicate(arr)\n hsh = {}\n\n arr.each do |ele|\n return ele if hsh[ele]\n hsh[ele] = true\n end\n\n false\nend", "def add_key_value?(key, val)\n hash = load_hash\n return false if hash.key? key\n hash[key] = val\n store_hash hash\n true\n end", "def gen\n key = :exists\n @mutex.synchronize do\n key = rand(2*31) while @hash[key]\n @hash[key] = true\n end\n key\n end", "def add_key_value?(key, val)\n @store.transaction do\n return false if @store.to_h.key? key\n @store[key]=val\n end\n true\n end", "def duplicate_entry?(entry_hash)\n unless entry_hash.include? \"id\" # conditional for record updates\n formatted = format_hash(entry_hash)\n db_hash = get_entry(formatted[\"fname\"], formatted[\"lname\"])\n difference = (formatted.to_a - db_hash.to_a).flatten\n difference.size > 0 ? false : true\n else\n false\n end\nend", "def insert(item)\n return false unless has_space?\n\n fingerprint = fingerprint(item)\n first_index = hash(item)\n second_index = alt_index(first_index, fingerprint)\n\n if @buckets[first_index].insert(fingerprint) || @buckets[second_index].insert(fingerprint)\n increment_filled_count\n return true\n end\n\n index = [first_index, second_index].sample\n\n @max_kicks.times do\n fingerprint = @buckets[index].random_swap(fingerprint)\n index = alt_index(index, fingerprint)\n\n if @buckets[index].insert(fingerprint)\n increment_filled_count\n return true\n end\n end\n\n return false\n end", "def detect_cycle_with_hash(head)\n seen_nodes = {}\n\n current_node = head\n\n while current_node != nil\n if seen_nodes[current_node.object_id]\n return true\n end\n\n seen_nodes[current_node.object_id] = true\n current_node = current_node.next_node\n end\n\n return false\nend", "def add?(key)\n hashes = key_to_hashes(key).reject { |hash| filter.set?(hash) }\n hashes.each { |hash| filter.set!(hash) }\n hashes.any?\n end", "def check_key2\n while @key2 == @key1\n @key2 = 1 + rand(6)\n end\n end", "def unique(list)\n hash = {}\n list.select do |n|\n #if it exists in the hash already you don't want that element\n if hash[n]\n false\n puts hash\n puts \"false\"\n else\n #if it doesn't, you put it in the hash and also keep the element\n hash[n] = n\n true\n puts hash\n puts \"true\"\n end\n end\n end", "def add(key)\n @internal_hash[key] = true\n end", "def unique_hash_already_exists?\n return Entry.where(feed_id: self.feed_id, unique_hash: self.unique_hash).exists?\n end", "def add_game(collection, game)\n if collection.keys.length == 5 \n false\n else\n collection[game] = {}\n true\n end\nend", "def unique(mylist)\r\n\r\n counts = Hash.new(0)\r\n\r\n mylist.each { |item|\r\n # if item is Not in the hash\r\n puts \"looking in hash for #{item}\"\r\n if counts[item] == 0\r\n puts \"#{item} is not in hash. Adding it!\"\r\n counts[item] = 1\r\n end\r\n # counts[item] +=1\r\n # puts counts\r\n # if counts[item] > 1\r\n # end\r\n}\r\n\r\n # if element you are testing is the same\r\n # remove the element you are testing\r\n # else redo the loop\r\n \r\nend", "def check_key3\n while @key3 == @key1 || @key3 == @key2\n @key3 = 1 + rand(6)\n end\n end", "def put(key, value)\n \txk = key % 10001 \n xk = (xk + 1) % 10001 while @arr[xk].first != nil && @arr[xk].first != key \n @arr[xk] = [key, value] \n end", "def duplicate_character_string(string)\n puts \"Checking if '#{string}' has duplicate characters\"\n string.split('').each_with_object({}) do |character, hash|\n return puts 'Duplicate character keys!' if hash.has_key?(character)\n hash[character] = 1\n end\nend", "def add_an_item(list_hash,item_name)\n puts 'Adding the item: #{item_name}.'\n puts 'Specify a quantity or type \"default\".'\n quantity = gets.chomp.to_s\n\n if quantity.downcase == 'default'\n quantity = '1'\n end\n\n puts list_hash\n\n if !list_hash[item_name]\n puts 'Added the item: #{item_name}.'\n list_hash[item_name] = quantity\n else\n puts 'Item already exists.'\n end\n\n list_hash\n\nend", "def insert(val)\n return false if @hh.key?(val)\n @hh[val] = val\n return true\n end", "def once (key, store: \"/var/cache/blower.json\", quiet: false)\n return yield unless key\n log.info \"once: #{key}\", quiet: quiet do\n hash_map(hosts) do |host|\n done = begin\n JSON.parse(host.read(store, quiet: true))\n rescue => e\n {}\n end\n unless done[key]\n on [host] do\n yield\n end\n done[key] = true\n host.write(done.to_json, store, quiet: true)\n end\n end\n end\n end", "def keep_alive_key(key)\n return false unless @keys.key? key\n @mutex.synchronize do\n @keys[key][:st] = Time.now.to_i\n puts \"Keep Alive called for Key: #{key}\"\n end\n true\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 check_key4\n while @key4 == @key1 || @key4 == @key2 || @key4 == @key3\n @key4 = 1 + rand(6)\n end\n end", "def search_new_key(key)\n _key = key\n if get_file(key).present?\n (1..999).each do |i|\n _key = key.cama_add_postfix_file_name(\"_#{i}\")\n break unless get_file(_key).present?\n end\n end\n _key\n end", "def update(hash)\n # Try to find an existing entry in @data.\n ind = nil\n @data.each_with_index{ |v, i| ind = i if(v[:id] == hash[:id] || v[:command] == hash[:command]) }\n return false unless ind\n @data[ind].merge!(hash)\n return true\n end", "def write_entry(key, entry, options)\n if options && options[:unless_exist]\n @hash.add(key, entry)\n else\n @hash[key] = entry\n end\n end", "def add_if_not_exists()\n\tif record_exists()\n\t\tprintf(\"EXISTS %s\\n\",self.digest)\n\t\treturn 0\n\tend\n\tsave()\n\treturn 1\nend", "def hash_exists?(id)\n @hashes.has_key? id\n end", "def isUnique(string) \n if (string.length > 128) \n return false \n end\n hash = {}\n i = 0\n while (i < string.length)\n if(hash[string[i]] === true) \n return false\n else \n hash[string[i]] = true\n end\n i+=1\n end\n return true\nend", "def create_if_exists(hash, *args, name:)\n exists = false\n args.each do |key|\n exists = false\n break unless hash.is_a?(Hash)\n\n exists = hash.key?(key)\n break unless exists\n\n hash = hash[key]\n end\n return unless exists\n return if respond_to?(name) && !send(name).nil?\n\n self.class.send(:attr_accessor, name)\n send(\"#{name}=\", hash)\n end", "def contains_duplicate(nums)\n hash_table = {}\n (0..nums.length).each do |i|\n if hash_table.include? nums[i]\n return true\n else\n hash_table[nums[i]] = 1\n end\n end\n return false\nend", "def hash_record_low_mem! set, rec, duplicate_type\n key = make_key rec, duplicate_type\n\n set << key\nend", "def insert(value) # rubocop:disable Metrics/MethodLength\n puts \"I want to insert #{value}\"\n initial_value = value\n starting_bucket = bucket = compute_bucket(value)\n puts \"I want to put it in bucket #{bucket}\"\n\n loop do\n contents = table[bucket]\n\n if contents == initial_value # This value is already in the HashTable\n puts \"#{contents} is already in bucket #{bucket}: stopping\"\n break false\n elsif contents.blank? # This is an available spot.\n puts \"Looks like bucket #{bucket} is empty. Let's put it there.\"\n insert_into_bucket(value, bucket)\n break true\n else # We need to keep searching for a spot.\n puts \"Bucket #{bucket} has value #{contents}. Need to keep looking.\"\n value = swap_if_needed(value, bucket)\n\n bucket = increment_bucket(bucket)\n raise LOOPED_MESSAGE if bucket == starting_bucket\n end\n end\n end", "def in?(key)\n start_slot = hasher(key, @keys.size)\n position = start_slot\n found = false\n\n while @keys[position] != nil and !found\n if @keys[position] == key\n found = true\n else\n position = rehash(position, @keys.size)\n break if position == start_slot\n end\n end\n\n found\n end", "def is_unique_with_hash?(str)\n hash = {}\n str.each_char do |ch|\n if hash[ch]\n return false\n else \n hash[ch] = true\n end \n end \n true\nend", "def has_key?(name)\n hashed.has_key? name\n end", "def finished?\n @hash.has_value?(30)\n end", "def put (key, value)\n !table.include?(key)\n end", "def update_with_hash(index_hash)\n return true\n end", "def push(key)\n synchronize do\n top = @map[key]\n if !top || top.empty?\n return false\n end\n\n @queue.synchronize do\n enqueue(top)\n @queue << top\n @map.delete(key)\n end\n\n return true\n end # synchronize\n end", "def build_existinghash(data)\n existinghash = {}\n data.each do |key, value|\n existinghash[key.to_s] = value.to_s.tr(\"\\n\", ' ').strip\n end\n existinghash\n end", "def exist?(key)\n !@store.select { |i| i[:key] == build_key(key) }.empty?\n end", "def has_key?(key); end", "def has_key?(key); end", "def add_item(item_name, item_qty)\n# $list_items[item_name] = item_qty\n # my_hash[key] = value\n # This will create a NEW key value pair\n # OR update (aka replace) the value for an existing key.\n \n # my_hash[key] += value\n # will INCREASE the value for an existing key.\n if $list_items.include?(item_name)\n # Increase that item\n $list_items[item_name] += item_qty\n else\n # Create the new item\n $list_items[item_name] = item_qty\n end\nend", "def update\n return unless @hash\n begin\n lockf = File.open(@path+\".lock\", File::CREAT|File::RDWR, 0600)\n lockf.flock File::LOCK_EX\n f = File.open(@path+\".new\", File::CREAT|File::TRUNC|File::WRONLY, 0600)\n for k,v in @hash\n #f.printf \"%s=%s\\n\", CGI::escape(k), CGI::escape(String(Marshal.dump(v)))\n # Just supports bools and strings\n if v == true\n valueString = 'BT'\n elsif v == false\n valueString = 'BF'\n else\n valueString = 'S' + v.to_s\n end\n f.printf \"%s=%s\\n\", CGI::escape(k), CGI::escape(valueString)\n end\n f.close\n File.rename @path+\".new\", @path\n ensure\n f.close if f and !f.closed?\n lockf.close if lockf\n end\n end", "def update_hash\n nh = nil\n\n if is_branch != 0\n sha512 = OpenSSL::Digest::SHA512.new\n sha512 << HASH_+PREFIXES[:inner_node]\n hashes.each { |k,h|\n sha512 << v\n }\n nh = sha512.digest\n end\n\n return false if nh == self.hash\n self.hash = nh\n return true\n end", "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 is_pair_exist(key, value)\r\n ((@redis.get key).eql? value) ? true : false \r\n end", "def duplicate(new_key_label)\n connection.zunionstore(new_key_label, [key_label]) if exists?\n end", "def reserve_key(key); end", "def create_key\n self.key = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless Api.exists?(key: random_token)\n end\n end", "def exist?(key)\n\n end", "def update_counting_hash(hash, key)\n hash[key] ? hash[key] += 1 : hash[key] = 1\n hash\nend", "def include?(hash)\n self.key.each_pair do |key, value|\n unless value === hash[key]\n return false\n end\n end\n true\n end", "def create_if_not_exists(hash, key, val, name: key.to_sym)\n return if hash.key?(key)\n\n self.class.send(:attr_accessor, name)\n send(\"#{name}=\", val)\n end", "def generate_hash_string#:doc:\n return true unless self.hash_string.nil?\n begin\n self.hash_string = Digest::MD5.hexdigest(Time.now.to_f.to_s)\n end while self.class.find_by_hash_string(self.hash_string)\n end", "def add_item(list, list_item, item_quantity)\n if list.has_key?(list_item)\n puts \"Item is already in list\"\n else\n list[list_item] = item_quantity\n end\n p list\n list\nend", "def rehash() end", "def test_set_key_unless_it_exists\n # Given\n refute @redis.exists( @key )\n\n # When\n @redis.set @key, @val1, nx: true\n\n # Then \n assert_equal @val1, @redis.get( @key )\n\n # ...and...\n\n # When\n @redis.set @key, @val2, nx: true\n\n # Then \n refute_equal @val2, @redis.get( @key )\n assert_equal @val1, @redis.get( @key )\n end", "def has_cycle(head)\n curr = head\n seen_node = {}\n while(curr)\n if(seen_node.has_key?(curr))\n return true\n else \n seen_node[curr] = :true\n end\n curr = curr.next\n end\n false\nend", "def has_key?(key)\n @stored[key] && !@stored[key].empty? ? true : false\n end", "def replicate_data_before_registration\n sorted_hash_keys = @@dynamo_nodes.sort_by { |_k,v| v.first.second.to_i}.map {|_k,v| v.first.second}\n sorted_hash_keys << @@my_key\n sorted_hash_keys = sorted_hash_keys.sort\n\n hash = Hash[sorted_hash_keys.map.with_index.to_a]\n\n nodes_to_be_replicated = []\n nodes_to_be_replicated << sorted_hash_keys[(hash[@@my_key] + 1 ) % sorted_hash_keys.size]\n nodes_to_be_replicated << sorted_hash_keys[(hash[@@my_key] + 2 ) % sorted_hash_keys.size]\n\n @@dynamo_nodes.each do |ip, data|\n if data.first.second.in?(nodes_to_be_replicated)\n data = JSON.parse(HTTPService.get_request('http://' + ip.to_s + '/node/get_data').body)['response']\n data.each do |key, value|\n store_value_simply(key, value)\n end\n end\n end\n end", "def key?(key)\n timeout_retry(3, 3){\n write \"EXISTS #{key}\\r\\n\"\n integer_reply == 1\n }\n end", "def update_counting_hash(hash, key)\n if hash[key] \n hash[key] += 1\n else\n hash[key] = 1\n end\n hash\nend", "def hash(key); end", "def has_key?(key)\n @db.each_key do\n\t|k|\n\treturn true if k == key\n end\n end", "def set_unless_exists(key, val)\n val = redis_marshal(val)\n timeout_retry(3, 3){\n write \"SETNX #{key} #{val.to_s.size}\\r\\n#{val}\\r\\n\"\n integer_reply == 1\n }\n end", "def link_chain_hash_creator(title)\n\tlink_chain = {}\n\tbroken = nil\n\tcurrent_title = title\n\twhile broken != true\n\t\tnext_title = $links[current_title] #|| $links[current_title.downcase]\n\t\t\n\t\t#puts \"Link chain: #{link_chain}\"\n\t\t#puts \"Current title: #{current_title}\"\n\t\t#puts \"Next title: #{next_title}\"\n\t\tunless next_title\n\t\t\tnext_title = $links[current_title.capitalize] if current_title\n\t\tend\n\n\t\tif link_chain.keys.include? next_title\t\t\t\n\t\t\t#alphabet_array = link_chain.alphat\n\t\t\t#link_chain.unshift(\"loop is\")\n\t\t\tbroken = true\n\t\tend\n\t\tlink_chain[current_title] = next_title\n\t\tcurrent_title = next_title\n\tend\n\tlink_chain\nend", "def rec_exists?(file_name, unique_keys, data)\n json = File.read(file_name + \".json\")\n json = json.split(\",\\n\")\n data = data.to_s\n data = eval data.gsub(\"},\", \"}\")\n json.each do |h|\n h = eval h\n flag = true\n unique_keys.each do |k|\n if h[k.to_s].to_s != data[k.to_s].to_s\n flag = false\n end\n end # end unique keys loop\n if flag == true\n #p \"rec exists!!!!!!!\"\n return true\n end\n end # end json loop\n #p \"doesn't exist, safe to move on\"\n false\nend", "def update_url_hash(url_list)\n url_list.each do |url|\n unless @@url_hash.has_key?(url)\n @@url_hash[url.to_sym] = false\n end\n end\n @@url_hash.collect {|key,value| key.to_s if value == false}\n end", "def add(key, value)\n index = key_index(key)\n\n # Only happens if we didn't check the presence before calling this method\n return nil if index == -1\n\n rehash_step if rehashing?\n\n hash_table = rehashing? ? rehashing_table : main_table\n entry = hash_table.table[index]\n\n entry = entry.next while entry && entry.key != key\n\n if entry.nil?\n entry = DictEntry.new(key, value)\n entry.next = hash_table.table[index]\n hash_table.table[index] = entry\n hash_table.used += 1\n else\n raise \"Unexpectedly found an entry with same key when trying to add #{ key } / #{ value }\"\n end\n end", "def hash_chain_broken?\n @valid_chain === false\n end", "def detect_cycle(head)\n hash_map = {}\n\n while head\n if hash_map.keys.include?(head)\n return head\n end\n\n hash_map[head] = 0\n head = head.next\n end\n\n nil\nend", "def proctition_platinum(arr, *prcs)\n\n hash = Hash.new{|h,k| h[k] = []}\n i = 1\n while i < prcs.length\n prcs.each do |prc|\n arr.each do |ele|\n if !(hash.include?(ele)) && prc.call(ele)\n hash[i] << ele\n end\n end\n i += 1\n #i want it to check if the word has already beed added to a value in the has, if so, dont add it to the next one. \n end\n end\n hash\nend", "def checker\n @hash.each_pair do |key, value|\n @hash[key]=value+1\n if value>=@tresholds\n @hash.delete key\n @on_expire.call key\n end\n end\n end", "def generate_user_key\n\t\tself.key = loop do\n random_hex = SecureRandom.urlsafe_base64\n break random_hex unless self.class.exists?(key: random_hex)\n end\n\tend", "def add_item_to_grocery_hash(item_string, grocery_hash, quantity)\n if !grocery_hash.include?(item_string.to_sym) # item_string is not in grocery_hash\n grocery_hash[item_string.to_sym] = quantity\n print_grocery_hash(grocery_hash)\n else\n update_quantity_of_item(grocery_hash[item_string.to_sym] + quantity, item_string, grocery_hash)\n end\nend", "def create_key\n if @house.find_room(:garden).inventory.include?(\"shovel\") && (@level == 0)\n @house.create_item(\"key\", \"It's a key, but what's it for?\", 10)\n @house.find_room(:garden).inventory << \"key\"\n @house.last_move_message = \"You dug up a key in the garden! What's it for?\"\n @level+=1\n end\n end", "def first_duplicate2(a)\n found = {}\n a.each do |x|\n return x if found[x]\n found[x] = true\n end\n -1\nend", "def add(hash); end", "def add(keyvalue)\n if keyvalue.is_a? String\n @hash[keyvalue] = nil\n else\n keyvalue.each do |key, value|\n @hash[key] = value #create key-value pair in @hash\n end\n end\n end", "def test_many\n result_hash={}\n 1000.times do\n x = square_same_color?(random_chess_board_square, random_chess_board_square)\n result_hash[x] ? result_hash[x] += 1 : result_hash[x] = 1\n end\n p result_hash\nend", "def store_hash(key, process, options)\n has_keys?(key, options[:has_keys]) if(options.has_key?(:has_keys))\n contains?(filtered, datas[key].values, options[:contains]) if(options.has_key?(:contains))\n store(key, process, options)\n end", "def update\n return unless @hash\n begin\n lockf = File.open(@path+\".lock\", File::CREAT|File::RDWR, 0600)\n lockf.flock File::LOCK_EX\n f = File.open(@path+\".new\", File::CREAT|File::TRUNC|File::WRONLY, 0600)\n for k,v in @hash\n f.printf \"%s=%s\\n\", CGI.escape(k), CGI.escape(String(Marshal.dump(v)))\n end\n f.close\n File.rename @path+\".new\", @path\n ensure\n f&.close\n lockf&.close\n end\n end", "def testHash(a)\n\n\t\tunless @mem_hash.has_key?(a)\n\t\t\t@mem_hash[a] = @next_empty\n\t\t\t@next_empty += 1\n\t\tend\n\t\ttoBin15 @mem_hash[a].to_i\n\n\tend", "def test_set_key_if_it_exists\n # Given\n refute @redis.exists( @key )\n\n # When\n @redis.set @key, @val, xx: true\n\n # Then \n refute @redis.get( @key )\n\n # ...and...\n\n # Given\n @redis.set @key, \"\"\n assert @redis.exists( @key )\n\n # When\n @redis.set @key, @val, xx: true\n\n # Then \n assert_equal @val, @redis.get( @key )\n end", "def hasCycle(head,hash={})\n return false if head.nil? || head.next.nil?\n return true if hash.has_key?(head.next)\n hash[head] = 1\n head = head.next\n hasCycle(head,hash)\nend", "def create_if_not_exists\n args = [\n [available_list_key(), taken_hash_key(), created_at_key()],\n [@resource_count, @expiration, Time.now.to_f()]\n ]\n $redis.eval(create_script(), *args)\n end", "def hash_two_sum?(arr, target)\n hash_count = {}\n\n arr.each { |el| hash_count[el] = true }\n\n hash_count.each_key do |key|\n return true unless hash_count[target - key].nil?\n end\n\n false\n \nend", "def detect_loop(list)\n current = list.head\n visited = Set.new\n until current.nil?\n return current if visited.include? current.hash\n visited << current.hash\n current = current.next\n end\n nil\nend", "def set_if_nil(hash, key)\n hash[key] = true if hash[key].nil?\n end", "def add_hash(hash, key, value)\n return hash[key] = value\nend", "def hash_end(_key)\n save_batch\n end", "def has_key?(p0) end", "def create_key\n self.winner_id = loop do\n random_token = rand.to_s[2..6]\n break random_token unless Winner.exists?(winner_id: random_token)\n end\n end", "def exes_and_ohs(input)\n # Your code goes here\n new_array = input.chars\n index = 0\n new_hash = Hash.new(0)\n\n for char in new_array do\n # if the character is a key in the hash\n if new_hash.key?(char)\n # increment the key's value by one\n new_hash[char] += 1\n else\n new_hash[char]= 1\n end\n end\n \n # comparing the last value in the array with nil, returns false and drops out auto \n i = 0\n frequency_array = new_hash.values\n while i < frequency_array.length - 1 # off by one error\n if frequency_array[i] != frequency_array[i+1] \n return false # because return will stop the iteration \n end\n i += 1 # increment to escape infinite loop\n end\n\n # previous_item = 23\n # array.each |item| do\n # if item == previous_item\n # puts \"hello\"\n # else\n # puts \"yo\"\n # end\n # previous_item = item\n # end\n\n return true # run through the length of the values, if none are differnt then return true\nend", "def on_2(numbers)\n hash_table = {}\n\n numbers.each do |number|\n return true if hash_table.key?(number)\n hash_table[number] = nil\n end\n\n false\n end", "def checkNewAssoc(scheme, campusID, oapID, campusCache)\n if campusCache.empty?\n db_execute(\"SELECT campus_id FROM ids WHERE oap_id = ?\", [oapID]) { |row|\n foundScheme, foundID = row[0].split('::')\n campusCache[foundScheme] << foundID\n }\n end\n if campusCache[scheme].length > 0 && !campusCache[scheme].include?(campusID)\n puts \"Warning: possible dupe: campus ID #{scheme}::#{campusID} being added to oapID #{oapID} which already had #{campusCache[scheme].to_a.inspect}.\"\n end\nend" ]
[ "0.65478647", "0.6016107", "0.5882747", "0.5801963", "0.57729423", "0.57014585", "0.56792736", "0.5655869", "0.56421655", "0.5639002", "0.5619762", "0.5615099", "0.5605554", "0.55721843", "0.55349267", "0.5508785", "0.5497522", "0.5486017", "0.54846454", "0.5484425", "0.5484366", "0.5474503", "0.5471711", "0.5443351", "0.5427717", "0.54111034", "0.5404999", "0.54044265", "0.5399174", "0.5389527", "0.5372521", "0.5362534", "0.53540564", "0.53443605", "0.5340851", "0.5339611", "0.5339451", "0.5327187", "0.53188044", "0.5316964", "0.53088325", "0.5306372", "0.52983356", "0.52973783", "0.52973783", "0.5295685", "0.5276888", "0.5276006", "0.5275176", "0.52628934", "0.525645", "0.5247234", "0.52441734", "0.5241788", "0.5237729", "0.523585", "0.52351326", "0.523345", "0.5230852", "0.5230307", "0.5228741", "0.5222922", "0.5217838", "0.52152103", "0.51835835", "0.518141", "0.51810616", "0.5179063", "0.5178061", "0.517594", "0.5173974", "0.5166759", "0.51493514", "0.51464516", "0.51383764", "0.51362824", "0.5129616", "0.5125699", "0.5125175", "0.5119609", "0.511392", "0.51132476", "0.51129514", "0.51084703", "0.5095541", "0.5095342", "0.5094041", "0.5086423", "0.5085097", "0.5084122", "0.50825053", "0.5079151", "0.5076568", "0.50672615", "0.50647354", "0.50639755", "0.50622904", "0.5059535", "0.5053705", "0.5052706" ]
0.5395393
29
POST start new game Takes a body with comma separated string of names /new_game
def new_game params_check(params[:player_names]) { @game = Game.create params[:player_names].split(",").each do |player_name| player = Player.create(name: player_name, game: @game) 10.times do |i| i == 10 ? Frame.create!(game: @game, player: player, position: i, final_frame: true) : Frame.create!(game: @game, player: player, position: i + 1) end end players = @game.players.map{ |player| { "#{player.name}": player.id } } process_response(@game.present?, "Congratulations, you started a new game. Here's your game id: #{@game.id} and player data: #{players}", @game.id) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n positions = JSON.parse(params['positions'])\n\n # Fill in body to initialize the game and return a 200 response\n\n render plain: \"OK\"\n end", "def new_game\n\tresponse\n\tif params[\"difficulty\"]\n\t\tdifficulty = params[\"difficulty\"]\n\t\tsettings.game_data = Ben::Game.new( Integer difficulty )\n\t\tresponse = game_json\n\telse\n\t\tresponse = \"Server couldn't load new game.\"\n\tend\n\treturn response\nend", "def create\n @new_game = Game.create(game_params)\n render json: @new_game\n\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n @game.game_state = \"started\"\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :ok, location: game_url(@game, format: :json) }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = current_user.games.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to game_steps_path(game_id: @game.id), notice: 'La partie a bien été créée' }\n format.json { render :show, status: :created, location: games_path }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n new_game = helpers.generate_game(params[\"game_name\"])\n\n slack_id = params[\"slack_id\"]\n\n response_url = params[\"response_url\"]\n\n @game = Game.new(new_game.new_game_data)\n\n if @game.save\n player = Player.exists?(slack_id: \"#{slack_id}\")\n if player\n player_records = Player.find_by(slack_id: \"#{slack_id}\")\n Rails.logger.info player_records[\"id\"].inspect\n render :json => {game_id: \"#{@game.id}\", player: \"#{player}\", player_id: \"#{player_records[\"id\"]}\"}\n else\n render :json => {game_id: \"#{@game.id}\", player: \"#{player}\"}\n end\n else\n render json: @game.errors, status: :unprocessable_entity\n end\n\n word_blanks = new_game.display_word_state\n\n HTTParty.post(response_url, \n {\n body: {\"text\" => \"#{word_blanks}\",\"response_type\" => \"in_channel\"}.to_json,\n headers: {\n \"Content-Type\" => \"application/json\"\n }\n }\n )\n \n end", "def create\n @espn_game = EspnGame.new(espn_game_params)\n\n respond_to do |format|\n if @espn_game.save\n format.html { redirect_to @espn_game, notice: 'Espn game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @espn_game }\n else\n format.html { render action: 'new' }\n format.json { render json: @espn_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = current_or_guest_user.games.create\n render json: @game, status: 201\n end", "def create\n @game = Game.new(game_params)\n\n params[:players].each do |player_name|\n p = Player.new\n p.name = player_name\n p.game = @game\n p.save!\n end\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to games_path, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to games_url, notice: \"Game was successfully created.\" }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: \"Game was successfully created.\" }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_new_pg_game\n @log.debug \"bot create_new_pg_game on state #{@state_pg_create}, supported games num: #{@supported_games.size}\"\n if @state_pg_create != :submitted\n #p @supported_games\n @supported_games.each do |item|\n if item[:name] == nil\n @log.warn \"Ignore to send game creation without a name maybe it is disabled in game_info, item is #{ObjTos.stringify(item)}\"\n next\n end\n @log.debug \"Submit pg game on #{item[:name]}\"\n #msg_det = \"#{item[:name]},#{item[:stropt]}\"\n info = {\n :game => item[:name],\n :prive => {:val => false, :pin => '' },\n :class => @playfor_classment,\n :opt_game => item[:opt] \n }\n @log.debug \"auto_create_new_game, pg_create2: #{ObjTos.stringify(info)}\"\n @control_net_conn.send_create_pg2(info)\n end\n @state_pg_create = :submitted\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { render :edit, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_game \n\t\t@game = create_game message[:player], message[:ships]\n\t\tWebsocketRails[:updates].trigger(:created_game, @game)\n\tend", "def create\n @game = Game.new_with_defaults(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to(@game, :notice => 'Game was successfully created.') }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: game_params }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = GameBuilder.build(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'El juego se ha creado!.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n respond_to do |format|\n if @game.save\n format.html { redirect_to(@game, :notice => 'Game was successfully created.') }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game].merge({ :user_id => current_user.id }))\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to games_path, notice: 'Game was successfully added.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def start_new_game\n say \"\\nStarting a new game.\"\n @client.start_new_game\n end", "def create\n new_user_game = {}\n new_user_game[:game_id] = params[:game_id].to_i\n new_user_game[:user_id] = current_user.id\n @user_game = UserGame.new(new_user_game)\n\n respond_to do |format|\n if @user_game.save\n format.html { redirect_to user_games_url, notice: 'User game was join in game with success.' }\n format.json { render action: 'index', status: :created, location: @user_game }\n else\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n\n respond_to do |format|\n if @game.save\n flash[:notice] = 'Game was successfully created.'\n format.html { redirect_to(@game) }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n @game.user_id = params[:game][:user].first[:id]\n @game.item_id = params[:game][:item].first[:id]\n\n if @game.save\n render json: @game, status: :created, location: @game\n else\n render json: @game.errors, status: :unprocessable_entity\n end\n end", "def create\n p = game_params\n\n home_team_name = p.delete(:home_team_name)\n away_team_name = p.delete(:away_team_name)\n p[:home_team_id] = find_or_create_team(home_team_name).try(:id)\n p[:away_team_id] = find_or_create_team(away_team_name).try(:id)\n\n @game = Game.new(p)\n @game.user = current_user\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new, notice: 'Game was successfully created.' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n game = Game.new(game_attributes)\n if game.save\n game.randomize_list(10)\n flash[:notice] = \"Let's get started!\"\n redirect_to edit_game_url(game)\n else\n render :new, error: \"failed to start the game\"\n end\n end", "def create\n @player_game = PlayerGame.new(params[:player_game])\n\n respond_to do |format|\n if @player_game.save\n format.html { redirect_to @player_game, :notice => 'Player game was successfully created.' }\n format.json { render :json => @player_game, :status => :created, :location => @player_game }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @player_game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n @game = Game.new\n @game.save\n render :json => {}\n # render :json => {}\n # @game = Game.new(game_params)\n # new_game = false\n # if !params.has_key(:secret_id)\n # @game = Game.new\n # secret_id = @game.secret_id\n # new_game = true\n # else\n # secret_id = params[:game_id]\n # end\n # @game.save\n\n # if new_game\n # render :json => {:new_secret_id => @game.secret_id}\n # end\n\n # render :json => {}\n\n # respond_to do |format|\n # if @game.save\n # format.html { redirect_to game_path(:id => @game.secret_id), notice: 'Game was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @game }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @game.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @game = Game.new(params[:game])\n @game.user_id = current_user.id\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@game = Game.new(game_params)\n\n\t\trespond_to do |format|\n\t\t\tif @game.save\n\t\t\t\tformat.html { redirect_to @game, notice: 'Game was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @game }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\tformat.json { render json: @game.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n game = @current_user.games.create!(game_params)\n render json: { game: game }\n end", "def create\n gp = game_params\n gp['organizer_id'] = current_user.id\n @game = Game.new(gp)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to edit_game_path(@game), notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @old_game = OldGame.new(params[:old_game])\n\n respond_to do |format|\n if @old_game.save\n format.html { redirect_to @old_game, notice: 'Old game was successfully created.' }\n format.json { render json: @old_game, status: :created, location: @old_game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @old_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new\n #create the first player\n first_player = Player.new\n first_player.name = params[:first_player_name]\n first_player.game = @game\n\n #create the second player\n second_player = Player.new\n second_player.name = params[:second_player_name]\n second_player.game = @game\n\n # add first and second players to the game object\n @game.first_player = first_player\n @game.second_player = second_player\n\n respond_to do |format|\n if @game.save\n #create a new game round using a redirect to new_game_round_path\n format.html { redirect_to new_game_round_path(@game), notice: t(\"games.successfully_created\") }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game_instance = GameInstance.new(params[:game_instance])\n\n respond_to do |format|\n if @game_instance.save\n format.html { redirect_to @game_instance, notice: 'Game instance was successfully created.' }\n format.json { render json: @game_instance, status: :created, location: @game_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @qa_game = QaGame.new(qa_game_params)\n\n respond_to do |format|\n if @qa_game.save\n format.html { redirect_to @qa_game, notice: 'Qa game was successfully created.' }\n format.json { render :show, status: :created, location: @qa_game }\n else\n format.html { render :new }\n format.json { render json: @qa_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_game = UserGame.new(user_game_params)\n\n respond_to do |format|\n if @user_game.save\n format.html { redirect_to @user_game, notice: 'User game was successfully created.' }\n format.json { render :show, status: :created, location: @user_game }\n else\n format.html { render :new }\n format.json { render json: @user_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.find(params[:user_id])\n @game = @user.games.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to user_game_path(@user,@game), :notice => 'Game was successfully created.' }\n format.json { render :json => @game, :status => :created }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @game_game_instance = Game::GameInstance.new(params[:game_game_instance])\n\n respond_to do |format|\n if @game_game_instance.save\n format.html { redirect_to @game_game_instance, notice: 'Game instance was successfully created.' }\n format.json { render json: @game_game_instance, status: :created, location: @game_game_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_game_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts params\n game = CreateGame.new(\n max_rounds: params[:max_rounds],\n draw_time: params[:draw_time],\n ).perform\n player = CreatePlayer.new(\n username: params[:username],\n game: game,\n creator: true\n ).perform\n\n if game.persisted? && player.persisted?\n session[:uuid] = player.uuid\n redirect_to player_path\n else\n render json: { ok: 'gra nie zapisana :(' }\n end\n end", "def create\n @game = Game.create params[:id]\n end", "def create\n @game = Game.new(params[:game])\n\t\n #First update the players table to indicate who is playing this game\n set_player_availability(params)\n \n #Create a team to hold the home team players\n home_team = Team.new\n home_team.name = params[:home_team_name]\n home_team.save\n @game.home_team_id = home_team.id\n \n #Create a team to hold the away team players\n away_team = Team.new\n away_team.name = params[:away_team_name]\n away_team.save\n @game.away_team_id = away_team.id\n \n #Create home and away teams from available players\n build_teams(home_team, away_team)\n \n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n megam_rest.post_appdefn(to_hash)\n end", "def create\n current_user.create_game\n redirect_to game_path\n end", "def create\n @playedgame = Playedgame.new(playedgame_params)\n\n respond_to do |format|\n if @playedgame.save\n format.html { redirect_to @playedgame, notice: 'Playedgame was successfully created.' }\n format.json { render :show, status: :created, location: @playedgame }\n else\n format.html { render :new }\n format.json { render json: @playedgame.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gameplay = Gameplay.new(params[:gameplay])\n\n respond_to do |format|\n if @gameplay.save\n format.html { redirect_to @gameplay, notice: 'Gameplay was successfully created.' }\n format.json { render json: @gameplay, status: :created, location: @gameplay }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gameplay.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bestgame = Bestgame.new(params[:bestgame])\n\n respond_to do |format|\n if @bestgame.save\n format.html { redirect_to @bestgame, notice: 'Bestgame was successfully created.' }\n format.json { render json: @bestgame, status: :created, location: @bestgame }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bestgame.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n megam_rest.post_appreq(to_hash)\n end", "def create\n @game = Game.new(params[:game])\n @corporations = Corporation.order(:faction, :slogan)\n @runners = Runner.order(:faction, :name)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = current_user.games_as_player1.new(params[:game])\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n populate_players\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new\n parse_game_params\n\n @game.creator = current_creator\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n @game.creator.send_game_created_email(@game)\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n game = Game.new\n # Gemerate a random game ID\n game.idhash = SecureRandom.urlsafe_base64(10)\n game.move_number = 1\n if (game.save)\n render plain: \"GOOD\\n\" + game.idhash\n else\n render plain: \"ERROR CREATING\"\n end\n end", "def create\n @game = Game.new(game_params)\n @game.user = current_user\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(params[:game])\n @game.player_1_id = current_user.id\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_game = Game.new(admin_game_params)\n\n respond_to do |format|\n if @admin_game.save\n format.html { redirect_to @admin_game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @admin_game }\n else\n format.html { render :new }\n format.json { render json: @admin_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\tsession[:new_number] = play_roulette\n \tGame.new(:number => session[:new_number]).save\n\t \n\tredirect_to games_path\n end", "def create\n @puzzle_game = PuzzleGame.new(params[:puzzle_game])\n\n respond_to do |format|\n if @puzzle_game.save\n format.html { redirect_to(@puzzle_game, :notice => 'PuzzleGame was successfully created.') }\n format.xml { render :xml => @puzzle_game, :status => :created, :location => @puzzle_game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @puzzle_game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @mini_game = MiniGame.new(mini_game_params)\n if @mini_game.save\n render json: @mini_game, status: :ok\n else\n render json: @mini_game.errors, status: :unprocessable_entity\n end\n end", "def create\n if current_user.role == \"admin\" || current_user.role == \"god\"\n @game = Game.new(game_time: params[\"date\"] + \" \" + params[\"time\"])\n\n @game.game_teams.build(team_id: params[\"home_team_id\"], home_team: true)\n @game.game_teams.build(team_id: params[\"away_team_id\"], home_team: false)\n end\n\n respond_to do |format|\n if current_user.role == :admin || current_user.role == :god || @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: { message: \"Created Game\" } }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @league_game = LeagueGame.new(league_game_params)\n\n respond_to do |format|\n if @league_game.save\n format.html { redirect_to @league_game, notice: 'League game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @league_game }\n else\n format.html { render action: 'new' }\n format.json { render json: @league_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_game_code\n if params[:new_game] == true\n game = Game.new\n game.quiz_id = params[:quiz_id]\n game.save\n end\n end", "def create\n @game = Game.new(game_params)\n assign_for_user\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @game = Game.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @game }\n end\n end", "def create\n @mini_game = MiniGame.new(mini_game_params)\n\n respond_to do |format|\n if @mini_game.save\n format.html { redirect_to edit_mini_game_path(@mini_game), notice: 'Mini game was successfully created.' }\n format.json { render :show, status: :created, location: @mini_game }\n else\n format.html { render :new }\n format.json { render json: @mini_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_new_game\n create_new_party\n $pokemon_party.expand_global_var\n $trainer.redefine_var\n $scene = Scene_Map.new\n Yuki::TJN.force_update_tone\n @running = false\n end", "def create\n @board_game = BoardGame.new(board_game_params)\n\n respond_to do |format|\n if @board_game.save\n format.html { redirect_to @board_game, notice: \"Board game was successfully created.\" }\n format.json { render :show, status: :created, location: @board_game }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @board_game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_game(user1, game_id, players, type)\n game_factory = ConnectGameFactory.new(players.to_i, type.to_sym)\n @game_list[game_id] = GameInfo.new(game_factory.connect_game, game_factory.game_state, nil, user1, nil)\n ''\n end", "def create\n @user = User.find( params[:user_id] )\n @game = @user.build_game(game_params)\n if @game.save\n flash[:success] = \"Game Created!\"\n redirect_to user_path( params[:user_id] )\n else\n render action: :new\n end\n end", "def create\n @game = Game.create(params[:game])\n\t\t@game.rate_average = 0.0\n\t\t@game.rate_quantity = 0\t\n\t\t@game.tags = build_tags_from_params(params) if params[:commit] == 'Update Game' \n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game_server = Game::Server.new(params[:game_server])\n\n respond_to do |format|\n if @game_server.save\n format.html { redirect_to @game_server, notice: 'Server was successfully created.' }\n format.json { render json: @game_server, status: :created, location: @game_server }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_server.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # create game and save, then add Score connector\n @game = Game.new(params[:game])\n respond_to do |format|\n # creating new game, and new association between selected player and game\n if @game.save && @game.add_player(@player)\n flash[:notice] = 'Game was successfully created.'\n format.html { redirect_to(games_url) }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @game_title = GameTitle.new(\n title: params[\"game_title\"][\"title\"], \n default_point: params[\"game_title\"][\"default_point\"],\n back_point: params[\"game_title\"][\"back_point\"],\n user1: params[\"game_title\"][\"user1\"], \n user2: params[\"game_title\"][\"user2\"], \n user3:params[\"game_title\"][\"user3\"], \n user4: params[\"game_title\"][\"user4\"]\n )\n\n\n\n\n respond_to do |format|\n if @game_title.save\n format.html { redirect_to @game_title, notice: 'Game title was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game_title }\n else\n format.html { render action: 'new' }\n format.json { render json: @game_title.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # make sure user is signed in\n if !user_signed_in?\n flash[:error] = \"You need to log in first\"\n redirect_to new_game_path\n return\n end\n # make sure email address is filled in\n if params[:email].empty?\n flash[:error] = \"You need to specify an email address\"\n redirect_to new_game_path\n return\n end\n opponent = User.find_or_create_by_email(params[:email])\n game = Game.new\n game.turn = \"x\"\n if params[:i_play_first]\n game.first_user_id = current_user.id\n game.second_user_id = opponent.id\n else\n game.first_user_id = opponent.id\n game.second_user_id = current_user.id\n end\n if game.save\n redirect_to game, notice: 'Game invitation has been sent.'\n query_params = {}\n query_params.merge!(:login_token => opponent.login_token) if opponent.login_token\n Email.request_game(opponent.email, current_user.email, game_url(game, query_params)).deliver\n else\n render action: \"new\"\n end\n end", "def create\n @game = color_param == 'white' ? Game.new(white_player_id: user_param) : Game.new(black_player_id: user_param)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: { redirect: game_path(@game) } }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n authorize @game\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render :show, status: :created, location: @game }\n else\n format.html { render :new }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = @contest.games.new(game_params)\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to contest_games_path, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def new # the input\n @game = Game.new\n @game.new_game\n end", "def create\n @game_tournament = GameTournament.new(params[:game_tournament])\n\n respond_to do |format|\n if @game_tournament.save\n format.html { redirect_to @game_tournament, notice: 'Game tournament was successfully created.' }\n format.json { render json: @game_tournament, status: :created, location: @game_tournament }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_tournament.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @game = Game.new(game_params)\n\n respond_to do |format|\n if @game.valid?\n ActiveRecord::Base.connection.execute(\"\n INSERT INTO games (`gname`, `greleasedate`, `ginfo`, `gpictureurl`) \n VALUES ('#{null_or_not(params[:game][:gname])}', \n #{null_or_not(params[:game][:greleasedate])}, \n '#{null_or_not(params[:game][:ginfo])}',\n '#{null_or_not(params[:game][:gpictureurl])}');\")\n\n id = Game.last.id\n\n ActiveRecord::Base.connection.execute(\"UPDATE games SET gid = #{id} WHERE id = #{id}\")\n\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7047248", "0.67517865", "0.66579497", "0.66527337", "0.66527337", "0.66527337", "0.66527337", "0.66527337", "0.66468465", "0.6646828", "0.66052276", "0.6605084", "0.656704", "0.65412307", "0.65325063", "0.6528704", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.6513858", "0.65129787", "0.65122956", "0.6504986", "0.64902663", "0.6473584", "0.6441169", "0.64130133", "0.64096683", "0.64091307", "0.6406081", "0.6404092", "0.6386197", "0.63605785", "0.63599944", "0.6336768", "0.6329456", "0.63227004", "0.63199204", "0.63173664", "0.6313071", "0.6308743", "0.6295528", "0.62898666", "0.6285296", "0.62817484", "0.6279802", "0.6275948", "0.62699085", "0.62353724", "0.62351334", "0.62342453", "0.6217006", "0.62041104", "0.6203056", "0.6162788", "0.61619973", "0.61617696", "0.61606663", "0.61564064", "0.6154179", "0.6152899", "0.6146721", "0.6146279", "0.61299396", "0.61272717", "0.6120162", "0.6103787", "0.6093519", "0.60680133", "0.60626614", "0.6051699", "0.6046568", "0.60460496", "0.6045736", "0.60065454", "0.6002751", "0.60023856", "0.59938854", "0.5990954", "0.59663194", "0.5955699", "0.59439784", "0.5918705", "0.5904843", "0.59009635", "0.59005344", "0.58933383", "0.5893254", "0.5888991", "0.5881107", "0.5868515", "0.5867605", "0.586104" ]
0.6784502
1
GET game data /game_data?game_id=xxx
def game_data frame_data = [] params_check(params[:game_id]) { @game = Game.find(params[:game_id]) @game.players.each do |player| player_frame_data = { player.name => [] } player.frames.order(:position).each do |frame| current_frame = [[frame.first_roll, frame.second_roll], [frame.score]] current_frame.append(frame.third_roll) if frame.final_frame && current_frame.flatten.sum >= 10 player_frame_data["#{player.name}"] += current_frame end player_frame_data[:total] = player.frames.map(&:score).compact.sum frame_data << player_frame_data end process_response(!frame_data.empty?, frame_data) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n # puts \"PARAMSSSSS CONTROLLER #{params[:id]}\"\n url = \"https://api-2445582011268.apicast.io/games/#{params[:id]}\"\n response = HTTParty.get(url, headers: {\"user-key\" => Figaro.env.igdb_api_key, \"Accept\": \"application/json\"})\n @game_response = response.parsed_response\n end", "def show_game\n @game = Event.where(\n game_id: params[:game_id]\n ).order(:game_date, :id)\n\n render json: @game, status: 200\n end", "def get_game\n @game = Game.find(params[:game_id])\n end", "def get_game\n @game = Game.find(params[:game_id])\n end", "def show\n @game = Game.find(params[:id])\n render json: @game, status: 200\n end", "def getGameInfo\n if(request.post?)\n cGameID = self.findKeyInJSON(params[:params], \"GameID\", 2)\n \n # Get Game Information\n rData = Game.getGameDetail(cGameID)\n \n # Return JSON response\n cRequestID = self.findKeyInJSON(params[:params], \"RequestID\", 1)\n self.jsonRender(rData, 'Game Detail', cRequestID, '100')\n end\n end", "def get_bgg_game\n response = HTTParty.get('https://www.boardgamegeek.com/xmlapi2/thing?id='+ @gameid)\n end", "def show\n @game = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM games \n WHERE gid = #{params[:id]} \n LIMIT 1\").first\n\n @characters = ActiveRecord::Base.connection.execute(\"\n SELECT c.*\n FROM characters c\n JOIN game_characters g \n ON g.cid = c.cid\n WHERE gid = #{params[:id]}\")\n\n @items = ActiveRecord::Base.connection.execute(\"\n SELECT i.*\n FROM items i\n JOIN game_items g \n ON i.iid = g.iid\n WHERE gid = #{params[:id]}\")\n\n @tracks = ActiveRecord::Base.connection.execute(\"\n SELECT t.*\n FROM tracks t\n JOIN game_tracks gt \n ON t.tid = gt.tid\n WHERE gid = #{params[:id]}\")\n\n @karts = ActiveRecord::Base.connection.execute(\"\n SELECT k.*\n FROM karts k\n JOIN game_karts gk \n ON k.kid = gk.kid\n WHERE gid = #{params[:id]}\")\n\n @console = ActiveRecord::Base.connection.execute(\"\n SELECT gc.*\n FROM consoles gc\n JOIN console_games cg \n ON gc.gcid = cg.gcid\n WHERE gid = #{params[:id]}\n LIMIT 1\").first\n\n respond_to do |format|\n format.html\n format.json {render json: Game.find(@game[0])}\n end\n end", "def index\n game = Game.find(params[:game_id])\n @player_games = game.player_games\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @player_games }\n format.json { render :json => @player_games}\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @game }\n end\n end", "def show\n @game_stat = GameStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_stat }\n end\n end", "def show\n render json: Game.find(params[:id])\n end", "def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def show\n @user = User.find(params[:user_id]) \n @game = @user.games.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @game }\n end\n end", "def find(id)\n @client.get_game(id).attributes\n end", "def index\n @games = Game.find_all_by_meeting_id(@meeting.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def show\n @game_game_instance = Game::GameInstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_game_instance }\n end\n end", "def show\n render json: @game\n end", "def show\n @game = Game.find(params[:game_id])\n end", "def show\n @game = Game.find(params[:id])\n @home_team = Team.find(@game.home_team_id)\n @away_team = Team.find(@game.away_team_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def fetch_json(game)\n RestClient.post(\"#{ENV['BASE_URI']}\" + \"#{ENV['ENDPOINT']}\", game.to_json, content_type: :json)\n end", "def index\n @games = Game.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @games }\n format.text { render :text => @games.map { |g| \"#{g.gameid}\\n\" } }\n end\n end", "def show\n @holdgame = Holdgame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holdgame }\n end\n end", "def show\n @holdgame = Holdgame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holdgame }\n end\n end", "def index\n @games = Game.all\n render json: @games\n end", "def data \n @prefgame = Prefgame.find_by_id(params[:id])\n @prefgame.players.each_with_index do |x,i| \n gm = @prefgame.screen(@prefgame.players[i]).data\n user = User.find_by_id(@prefgame.players[i])\n if user == nil \n raise RuntimeError , \"There is no user with id #{@prefgame.players[i]} in game #{@prefgame.id}\"\n end\n # call private pub to dispach \n PrivatePub.publish_to(\"/game/#{@prefgame.id}/#{user.id}\", :gm => gm );\n end \n render :nothing => true\n end", "def show\n @game = Game.instance\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @games = Game.search params[:id], params[:region]\n end", "def show\n @player_game_stat = PlayerGameStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_game_stat }\n end\n end", "def get_match_data(match_id)\n # Given a matchId, make an API request for the match data.\n url = \"https://#{REGION}.api.riotgames.com/lol/match/v4/matches/#{match_id}?api_key=#{API_KEY}\"\n response_string = RestClient.get(url)\n sleep(1)\n match_data = JSON.parse(response_string)\nend", "def show\n @game = Game.find_by_id(params[:id])\n\n unless @game\n flash[:error] = \"Game not found.\"\n redirect_to games_path\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def get_games\n @games = Game.where(:user_id=>:id)\n end", "def game_main\n\n if params[:game_id].present?\n @game = Game.find(params[:game_id])\n @ticker_activities = @game.ticker_activities\n @player_home = @game.get_player_home()\n @player_away = @game.get_player_away()\n @game_stat = @game.get_game_stat()\n @game_possession = @game.get_game_possession()\n @game_lead = @game.get_game_lead()\n @game_history = @game.get_game_history(300, \"Statistic\")\n @game_penalty = @game.get_game_penalty()\n @ticker_events = @game.ticker_events\n end\n\n if params[:mode].present?\n @mode = params[:mode]\n end\n\n respond_to do |format|\n #format.html\n format.js\n format.json { render json: @game }\n end\n end", "def show\n @game_source = GameSource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_source }\n end\n end", "def show\n @game = Game.where(id: params[:id]).first\n end", "def show\n @howtoplaygame = Howtoplaygame.find_by_game_id(params[:id])\n end", "def show\n @player_game = PlayerGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @player_game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n if @game.nil? \n respond_to do |format|\n format.all { render :status => :not_found, :text => \"Game not found.\" }\n end\n else\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @game }\n format.json { render :json => @game }\n end\n end\n end", "def index # this is actually an edit permissions page\n @game = Game.find(params[:game_id])\n end", "def get_champion_data(patch_number)\n response_string = RestClient.get(\"http://ddragon.leagueoflegends.com/cdn/#{patch_number}/data/en_US/champion.json\")\n response_hash = JSON.parse(response_string)\n champion_data = response_hash[\"data\"]\nend", "def show\n @gameplay = Gameplay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gameplay }\n end\n end", "def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @games = Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @games = current_user.games\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @game_infos = GameInfo.all\n end", "def games_game_id_get_with_http_info(game_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.games_game_id_get ...\"\n end\n # verify the required parameter 'game_id' is set\n if @api_client.config.client_side_validation && game_id.nil?\n fail ArgumentError, \"Missing the required parameter 'game_id' when calling DefaultApi.games_game_id_get\"\n end\n # resource path\n local_var_path = \"/games/{gameId}\".sub('{' + 'gameId' + '}', game_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'InlineResponse2005')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#games_game_id_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @game = Game.find(params[:id])\n end", "def show\n @game = Game.find(params[:id])\n end", "def show\n @game = Game.find(params[:id])\n end", "def show\n @game = Game.find(params[:id])\n end", "def show\n id = User.find_by_fb_id(params[:id]).id\n @user_game = UserGame.find_by_user_id(id)\n\n respond_to do |format|\n format.json { render json: @user_game }\n end\n end", "def show\n @old_game = OldGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @old_game }\n end\n end", "def show\n @game_score = GameScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_score }\n end\n end", "def index\n @frames = Frame.all.where(:game_id => params[:game_id]).group_by(&:user_id)\n @game_id = params[:game_id]\n @game_turn = Game.find(@game_id).game_turn\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @game }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @game }\n end\n end", "def show\n @game_object_datum = GameObjectDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_object_datum }\n end\n end", "def game_details\n new_game = Game.last\n\n render :json => new_game.to_json( :include => :players )\n end", "def games_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.games_get ...\"\n end\n # resource path\n local_var_path = \"/games\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].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 # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#games_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def play\n data = self.get_api_response(\"https://opentdb.com/api.php?amount=3&category=11\")[\"results\"][0]\n return data\n end", "def show\n @bestgame = Bestgame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bestgame }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @game_system = GameSystem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_system }\n end\n end", "def index\n gon.yourID = current_user.id\n current_user.game == nil ? @games = Game.all : @games = Game.find(current_user.game.id)\n @team1 = @games.team1.users if @games.try :team1\n @team2 = @games.team2.users if @games.try :team2\n respond_to do |format|\n format.html\n format.json { render :json => { :games => @games.to_json(:include => [:users]),\n :user => current_user.game,\n :will => current_user.will,\n :team1 => @team1,\n :team2 => @team2 }\n }\n end\n end", "def show\n @game = Game.find(params[:id])\n @matches = @game.player_matchups\n @scores = @game.scores\n @match_points = @matches.collect { |mp| @game.match_scores(mp.first, mp.last) }\n @net_points = @game.net_points\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def show\n @video_game = VideoGame.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @video_game }\n end\n end", "def find_game\n @game = Game.find(params[:id])\n end", "def find_game\n @game = Game.find(params[:id])\n end", "def find_game\n @game = Game.find(params[:id])\n end", "def show\n @game_code = GameCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_code }\n end\n end", "def show\n game = Game.find(params[:game_id])\n @player_game = game.player_games.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to @player_game.game, :stab => 1 }\n format.json { render :json => @player_game}\n end\n\n end", "def get_games_url\n \"#{@user_url}/games/?tab=all\"\n end", "def search\n games_data = BoardGameAtlas::API.search(params[:name])\n render json: { games: games_data.map }\n end", "def show\n @game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @game.to_xml }\n end\n end", "def show\n render json: @games_leaderboard\n end", "def index\n game = Game.all\n\n render json: game, include: :teams\n end", "def load_game\n @game = Game.find params[:id]\n head :unprocessable_entity unless @game\n end", "def index\n if params[:players]\n respond_with PlayersGame.where(:game_id => params[:players])\n elsif params[:reserves]\n respond_with PlayersGame.where(:game_id => params[:reserves], :reserve => true)\n elsif params[:game_id] && params[:user_id]\n respond_with PlayersGame.where(:game_id => params[:game_id], :user_id => params[:user_id])\n else\n respond_with PlayersGame.all\n end\n end", "def show\n #@game = Game.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @game }\n end\n end", "def show\r\n @game_statistic = GameStatistic.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @game_statistic }\r\n end\r\n end", "def show\n @game_server = Game::Server.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_server }\n end\n end", "def show\n @game = Game.find(params[:id])\n @players = @game.players\n @comments = @game.comments\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @game }\n end\n end", "def game\n Game.find(self[:game_id])\n end", "def index\n @levels = Level.where(:game_id => params[:game_id])\n @game = Game.find(params[:game_id])\n end", "def show\n @item = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM items \n WHERE iid = #{params[:id]} \n LIMIT 1\").first\n\n @games = ActiveRecord::Base.connection.execute(\"\n SELECT g.*\n FROM games g\n JOIN game_items gi\n ON g.gid = gi.gid\n WHERE iid = #{params[:id]}\")\n\n respond_to do |format|\n format.html\n format.json {render json: Item.find(@item[0])}\n end\n end", "def show\n @user = User.find(params[:id])\n @games = @user.games\n\n end", "def show\n @game = Game.find(params[:id])\n @home = AnnualStat.where(:year => Date.new(@game.date.year), :team_id => @game.teams[:home].id).first\n @away = AnnualStat.where(:year => Date.new(@game.date.year), :team_id => @game.teams[:away].id).first\n \n @prev = Game.find(params[:id].to_i - 1)\n @next = Game.find(params[:id].to_i + 1)\n \n respond_to do |format|\n format.html { @game.ncaa_id.nil? ? render('preview') : render('show') }\n format.json { render json: @game }\n end\n end", "def show\n @game_watch = GameWatch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_watch }\n end\n end", "def show\n @game = Game.find(params[:id])\n\n # all users that haven't already been added to the game\n @users_not_added = User.all - User.in_game(@game.id)\n\n # new user_game for adding more\n @user_game = UserGame.new\n\n # current_user's data in this game\n @current_user_game = UserGame.find_by_user_id_and_game_id(current_user.id, @game.id)\n\n @transaction = Transaction.new\n @manager = User.find_by_id(@game.manager_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end", "def index\n @games = Game.get_all_active\n end", "def index\n @game_records = GameRecord.all\n end" ]
[ "0.7449157", "0.70001364", "0.6972407", "0.6972407", "0.69490165", "0.6894466", "0.6772907", "0.6688555", "0.66429186", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.66273814", "0.66224706", "0.6617202", "0.6593056", "0.6591032", "0.6587792", "0.6571652", "0.6551242", "0.6544496", "0.6530868", "0.6505862", "0.6479134", "0.646247", "0.6444946", "0.6444946", "0.64440066", "0.64388007", "0.64378065", "0.64039314", "0.6375142", "0.6368124", "0.6367661", "0.6358838", "0.6356083", "0.6340585", "0.63354146", "0.6329182", "0.632712", "0.6321274", "0.6318595", "0.6311928", "0.6300188", "0.6294659", "0.6294113", "0.6294113", "0.6294113", "0.62776244", "0.62667984", "0.62654567", "0.6262263", "0.6262263", "0.6262263", "0.6262263", "0.6251526", "0.6249581", "0.6248431", "0.62441456", "0.62367994", "0.62367994", "0.62304014", "0.62207663", "0.62206745", "0.62167525", "0.621512", "0.62107605", "0.6208964", "0.62081844", "0.6203667", "0.6199945", "0.6191206", "0.6190391", "0.6190391", "0.6187568", "0.61868024", "0.6180986", "0.6168571", "0.6168463", "0.6167212", "0.61658806", "0.61622936", "0.6146407", "0.614051", "0.6140148", "0.6115439", "0.6109869", "0.6106216", "0.6098453", "0.60788816", "0.6075986", "0.60740376", "0.6070766", "0.60681164", "0.60429895", "0.6036502" ]
0.6276856
53
GET /clubs/1 GET /clubs/1.json
def show @club = Club.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @club } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @club = Club.find(params[:id])\n\n render json: @club\n end", "def index\n @clubs = Club.all\n render json: @clubs\n end", "def show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @club }\n end\n end", "def index\n @clubs = Club.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clubs }\n end\n end", "def show\n\n #params[:id] = @current_user.club_id\n @club = Club.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n end", "def show\n\t\trender json: @club\n\tend", "def index\n\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend", "def show\n @club_path = ClubPath.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club_path }\n end\n end", "def index\n @clubs = Club.all\n end", "def index\n @clubs = Club.all\n end", "def index\n @clubs = Club.all\n end", "def clubs\n \t@title = \"My Clubs\"\n \t@clubs = Student.find(params[:id]).clubs\n \trender 'show_clubs'\n end", "def show\n @nightclub = Nightclub.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nightclub }\n end\n end", "def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club }\n end\n end", "def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end", "def show\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end", "def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @club }\n end\n end", "def index\n @club = Club.find_by_slug(params[:club_id])\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams }\n end\n end", "def index\n @club2s = Club2.all\n end", "def index\n authorize Club\n @clubs = Club.all\n end", "def all_clubs\n Club.all\nend", "def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end", "def index\n @clubs = Club.page(params[:page]).per(6)\n end", "def index\n @clubs = Club.all\n respond_with @clubs, :include => :id\n end", "def index\n @clubs = Club.all \n respond_to do |format|\n format.html { \n authorize! :index, @clubs\n }\n format.json { \n \n }\n end\n end", "def show\n @club = Club.find(params[:id])\n respond_with @club, :include => :id\n end", "def index\n begin\n conditions = [\"club_id = ?\",@club.id]\n @courses = Course.find(:all, :order => 'id', :conditions => conditions)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n\n @club = Club.find(params[:id])\n\n end", "def new\n @club_path = ClubPath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club_path }\n end\n end", "def club\n @user.club\n end", "def create\n\t\t@club = Club.new(club_params)\n\n\t\tif @club.save\n\t\t \trender json: @club, status: :created\n\t\telse\n\t\t \trender json: @club.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def clubs_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.clubs_get ...\"\n end\n # resource path\n local_var_path = \"/clubs\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].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 # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'InlineResponse200')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#clubs_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end", "def index\n @tennis_clubs = TennisClub.all\n end", "def index\n @clubs = Club.all\n # @small_genres = []\n end", "def display_resource(club)\n club.name\n end", "def index\n @clubusers = Clubusers.all\n end", "def club\n viewing.club\n end", "def set_club_info\n @club_info = ClubInfo.find(params[:id])\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def team\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html #team.html.erb\n end\n end", "def set_club\n\t\t\t@club = Club.find(params[:id])\n\t\tend", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n respond_to do |format|\n format.html { \n authorize! :index, @club\n }\n format.json { \n \n }\n end\n end", "def index\n @admin_clubs = Admin::Club.all\n end", "def index\n @clubs = Club.order(name: :asc)\n end", "def new\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @beer_club = BeerClub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end", "def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end", "def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end", "def index\n @club_types = ClubType.all\n end", "def new\n @beer_club = BeerClub.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end", "def show\n @club = Club.find(params[:id])\n authorize @club\n end", "def show_players_on_specific_club\n the_club = choose_club #user chooses club they want to see players for\n the_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n the_club.players.each do |player| #loops through instance of club and prints all players \n puts player.name\n end\nend", "def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def set_club\n @club = Club.find(params[:id])\n @place = Place.find(@club.place_id)\n #devolve-nos a relacao que contem todos os UserClubs correspondentes ao clube com id = @club.id\n @users_clubs = UserClub.where(\"club_id = #{params[:id]}\")\n end", "def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end", "def index\n @clubs = Club.joins(:place).all\n\n end", "def new\n @nightclub = Nightclub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nightclub }\n end\n end", "def create\n @club = Club.new(club_params)\n @club.save\n respond_with @club\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def index\n @stripclubs = Stripclub.all\n end", "def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end", "def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end", "def show\n @committeemember = Committeemember.find(params[:id])\n @club = Club.find(params[:club_id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @committeemember }\n end\n end", "def index\n @club_students = ClubStudent.all\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Circolo creato con successo.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @club = Club.find(params[:id])\n\n respond_to do |format|\n if @club.update_attributes(params[:club])\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club2\n @club2 = Club2.find(params[:id])\n end", "def show\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climb }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clonet }\n end\n end", "def new\n @club = Club.new(:city_id => params[:id])\n\n puts \"Klub: \" + @club.city_id.to_s();\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @club }\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: \"Club was successfully updated.\" }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @golf_cource }\n end\n end", "def update\n @club = Club.find(params[:id])\n @club.update_attributes(club_params)\n respond_with @club\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @tea_clubs = TeaClub.all\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def update\n @club = Club.find(params[:id])\n\n respond_to do |format|\n if @club.update_attributes(params[:club])\n format.html { redirect_to @club, :notice => 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @club.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.83942306", "0.81019014", "0.8078959", "0.7889925", "0.7877483", "0.786315", "0.78516775", "0.75047773", "0.74475837", "0.74475837", "0.74475837", "0.7375221", "0.72653127", "0.7220348", "0.72018844", "0.71983624", "0.7168892", "0.7067452", "0.70564526", "0.7014342", "0.69192976", "0.6912992", "0.689318", "0.68823195", "0.6857011", "0.68404716", "0.6832341", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68291575", "0.68019783", "0.67821735", "0.67746574", "0.67648447", "0.67645353", "0.67550117", "0.6713428", "0.67030036", "0.66829425", "0.66782135", "0.66682416", "0.6663717", "0.6637863", "0.6637863", "0.6627219", "0.6606342", "0.6596717", "0.65825856", "0.6560133", "0.65482324", "0.6541834", "0.65336514", "0.65094614", "0.648826", "0.648826", "0.6477625", "0.6476227", "0.64701915", "0.6448512", "0.64327157", "0.6428373", "0.6428373", "0.64266133", "0.6381129", "0.6376875", "0.6362256", "0.63607275", "0.63477427", "0.63178295", "0.630229", "0.630229", "0.62930137", "0.62843066", "0.6248078", "0.62445724", "0.6240604", "0.62403417", "0.6239332", "0.6232273", "0.622759", "0.620625", "0.6202636", "0.6201992", "0.6201568", "0.6201568", "0.6201568", "0.6201568", "0.6201568", "0.619432", "0.61883503", "0.61883503", "0.61800754" ]
0.82158464
1
PUT /clubs/1 PUT /clubs/1.json
def update @club = Club.find(params[:id]) respond_to do |format| if @club.update_attributes(params[:club]) format.html { redirect_to @club, notice: 'Club was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @club.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end", "def update\n @club = Club.find(params[:id])\n @club.update_attributes(club_params)\n respond_with @club\n end", "def update\n @club = Club.find(params[:id])\n\n respond_to do |format|\n if @club.update_attributes(params[:club])\n format.html { redirect_to @club, :notice => 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @club.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\tif @club.update(club_params)\n\t \t\thead :no_content\n\t \telse\n\t \trender json: @club.errors, status: :unprocessable_entity\n\t \tend\n\tend", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: \"Club was successfully updated.\" }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @club = Club.find(params[:id])\n authorize @club\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club\n\n @club = Club.find(params[:id])\n\n end", "def update\n\n #authorize!(:update, @club)\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to clubs_path, notice: 'Club was successfully updated.' }\n format.json { render :index, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @club = Club.find(params[:id])\n\n respond_to do |format|\n if @club.update_attributes(params[:club])\n format.html { redirect_to(@club, :notice => 'Club was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @club.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def set_club\n @club = Club.find(params[:id])\n end", "def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n redirect_to root_path, notice: t('club.update')\n else\n render :edit\n end\n end", "def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @club_update.update(club_update_params)\n format.html { redirect_to @club_update, notice: 'Club update was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_update }\n else\n format.html { render :edit }\n format.json { render json: @club_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club\n\t\t\t@club = Club.find(params[:id])\n\t\tend", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Circolo aggiornato con successo.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club2.update(club2_params)\n format.html { redirect_to @club2, notice: 'Club2 was successfully updated.' }\n format.json { render :show, status: :ok, location: @club2 }\n else\n format.html { render :edit }\n format.json { render json: @club2.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club_update\n @club_update = ClubUpdate.find(params[:id])\n end", "def update\n respond_to do |format|\n if @admin_update_club.update(admin_update_club_params)\n format.html { redirect_to @admin_update_club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_update_club }\n else\n format.html { render :edit }\n format.json { render json: @admin_update_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tennis_club.update(tennis_club_params)\n format.html { redirect_to @tennis_club, notice: 'Tennis club was successfully updated.' }\n format.json { render :show, status: :ok, location: @tennis_club }\n else\n format.html { render :edit }\n format.json { render json: @tennis_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club_info\n @club_info = ClubInfo.find(params[:id])\n end", "def show\n @club = Club.find(params[:id])\n\n render json: @club\n end", "def update\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to([@club, @team], :notice => 'Team was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @club_type.update(club_type_params)\n format.html { redirect_to @club_type, notice: 'Club type was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_type }\n else\n format.html { render :edit }\n format.json { render json: @club_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @club = Club.find(params[:id])\n\n params.each do |key, value|\n if (key.to_s[/adduser.*/])\n #if param[key].blank?\n # @object.errors.add_to_base(\"All new user fields are required.\")\n #end\n #debugger\n @user = User.new\n #clean_up_passwords @user\n @user.update_attribute(:email,params[key])\n @user.update_attribute(:club_id,params[:id])\n @user.save\n #@user.send_confirmation_instructions\n end\n end\n\n respond_to do |format|\n if @club.update_attributes(params[:club])\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @beer_club = BeerClub.find(params[:id])\n respond_to do |format|\n if @beer_club.update_attributes(params[:beer_club])\n format.html { redirect_to @beer_club, notice: 'Beer club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beer_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @beer_club = BeerClub.find(params[:id])\n\n respond_to do |format|\n if @beer_club.update_attributes(params[:beer_club])\n format.html { redirect_to @beer_club, notice: 'Beer club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beer_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_update_club = Admin::Update::Club.new(admin_update_club_params)\n\n respond_to do |format|\n if @admin_update_club.save\n format.html { redirect_to @admin_update_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_update_club }\n else\n format.html { render :new }\n format.json { render json: @admin_update_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n \n @club = Club.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n\n \n end", "def set_club\n @club = Club.find(params[:id])\n @place = Place.find(@club.place_id)\n #devolve-nos a relacao que contem todos os UserClubs correspondentes ao clube com id = @club.id\n @users_clubs = UserClub.where(\"club_id = #{params[:id]}\")\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @club_update = ClubUpdate.new(club_update_params)\n\n respond_to do |format|\n if @club_update.save\n format.html { redirect_to @club_update, notice: 'Club update was successfully created.' }\n format.json { render :show, status: :created, location: @club_update }\n else\n format.html { render :new }\n format.json { render json: @club_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @club_path = ClubPath.find(params[:id])\n\n respond_to do |format|\n if @club_path.update_attributes(params[:club_path])\n format.html { redirect_to @club_path, notice: 'Club path was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @club_path.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@club = Club.new(club_params)\n\n\t\tif @club.save\n\t\t \trender json: @club, status: :created\n\t\telse\n\t\t \trender json: @club.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @tea_club.update(tea_club_params)\n format.html { redirect_to @tea_club, notice: 'Tea club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tea_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @clubuser.update(clubuser_params)\n format.html { redirect_to @clubuser, notice: 'Clubuser was successfully updated.' }\n format.json { render :show, status: :ok, location: @clubuser }\n else\n format.html { render :edit }\n format.json { render json: @clubuser.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club2\n @club2 = Club2.find(params[:id])\n end", "def update\n @nightclub = Nightclub.find(params[:id])\n\n respond_to do |format|\n if @nightclub.update_attributes(params[:nightclub])\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wine_club.update(wine_club_params)\n format.html { redirect_to @wine_club, notice: 'Wine club was successfully updated.' }\n format.json { render :show, status: :ok, location: @wine_club }\n else\n format.html { render :edit }\n format.json { render json: @wine_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @club = Club.new(club_params)\n @club.save\n respond_with @club\n end", "def set_recipe_club\n @recipe_club = RecipeClub.find(params[:id])\n end", "def update\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to club_path(@club), notice: 'Mannschaft wurde aktualisiert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @club }\n end\n end", "def index\n @clubs = Club.all\n render json: @clubs\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def club_params\n params.require(:club).permit(:club_type, :name, :members, :description, :sport, :place_id)\n end", "def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Circolo creato con successo.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_clubuser\n @clubuser = Clubusers.find(params[:id])\n end", "def set_tennis_club\n @tennis_club = TennisClub.find(params[:id])\n end", "def update\n respond_to do |format|\n if @nightclub.update(nightclub_params)\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club_type\n @club_type = ClubType.find(params[:id])\n end", "def show\n\n #params[:id] = @current_user.club_id\n @club = Club.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def create\n @admin_club = Admin::Club.new(admin_club_params)\n\n respond_to do |format|\n if @admin_club.save\n format.html { redirect_to @admin_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_club }\n else\n format.html { render :new }\n format.json { render json: @admin_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize Club\n @club = Club.new(club_params)\n @club.owner = current_user\n @club.users << current_user\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_club_student\n @club_student = ClubStudent.find(params[:id])\n end", "def club_params\n params.require(:club).permit(:name, :contact_officer, :date_created)\n end", "def update\n respond_to do |format|\n if @club_student.update(club_student_params)\n format.html { redirect_to @club_student, notice: 'Club student was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_student }\n else\n format.html { render :edit }\n format.json { render json: @club_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_wine_club\n @wine_club = WineClub.find(params[:id])\n end", "def club_params\n # @user_id = current_user.id\n params.require(:club).permit(:club_name, :club_email, :club_brief, :found_time)\n end", "def club_params\n params.require(:club).permit(:name, :room_name)\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @stripclub.update(stripclub_params)\n format.html { redirect_to @stripclub, notice: 'Stripclub was successfully updated.' }\n format.json { render :show, status: :ok, location: @stripclub }\n else\n format.html { render :edit }\n format.json { render json: @stripclub.errors, status: :unprocessable_entity }\n end\n end\n end", "def club_params\n params.require(:club).permit(:name, :short_name, :address, :postal4, :postal3, :city, :phone, :email, :president, :url, :municipality_id)\n end", "def set_nightclub\n @nightclub = Nightclub.find(params[:id])\n end", "def create\n @club2 = Club2.new(club2_params)\n\n respond_to do |format|\n if @club2.save\n format.html { redirect_to @club2, notice: 'Club2 was successfully created.' }\n format.json { render :show, status: :created, location: @club2 }\n else\n format.html { render :new }\n format.json { render json: @club2.errors, status: :unprocessable_entity }\n end\n end\n end", "def club_update_params\n params.require(:club_update).permit(:content, :title)\n end", "def club_params\n\t\t\tparams.require(:club).permit(:name, :contact_officer, :date_created)\n\t\tend", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_with @club\n end", "def club_params\n params.require(:club).permit(\n :name, :short_name, :description,\n :cover_image, :remove_cover_image, :logo, :remove_logo, :recording_area\n )\n end", "def update\n \n if params[:destroy_logo] == \"1\"\n @admin_club.logo = nil\n end\n\n if params[:destroy_banner] == \"1\"\n @admin_club.banner = nil\n end\n\n\n respond_to do |format|\n if @admin_club.update(admin_club_params)\n format.html { redirect_to @admin_club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_club }\n else\n format.html { render :edit }\n format.json { render json: @admin_club.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @clubs = Club.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clubs }\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def clubs\n \t@title = \"My Clubs\"\n \t@clubs = Student.find(params[:id]).clubs\n \trender 'show_clubs'\n end", "def destroy\n\t\t@club = Club.find(params[:id])\n\t\t@club.destroy\n\n\t\trespond_to do |format|\n\t\t format.html { redirect_to(clubs_url) }\n\t\t format.xml { head :ok }\n\t\tend\n\tend", "def update\n club = ::Posts::Club.with_user(@user)\n authorize! :update, club\n if club.update_attributes(data_params)\n render_update_success club\n else\n render_failure club\n end\n end", "def set_admin_club\n @admin_club = Admin::Club.find(params[:id])\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n\n end" ]
[ "0.7922199", "0.7636222", "0.7607505", "0.74574715", "0.7454791", "0.7451092", "0.7451092", "0.7451092", "0.7451092", "0.7451092", "0.7314734", "0.7314734", "0.7270194", "0.72480816", "0.7220248", "0.72081", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.70552456", "0.7021457", "0.6988322", "0.6944569", "0.69393617", "0.6924945", "0.6906021", "0.6902272", "0.6845915", "0.6813648", "0.6744468", "0.67286354", "0.6685256", "0.66769636", "0.6676842", "0.66752744", "0.66706675", "0.6668723", "0.66662425", "0.66646713", "0.6654043", "0.6649138", "0.6649138", "0.66168267", "0.6601643", "0.66012514", "0.65942657", "0.65638757", "0.6561266", "0.655572", "0.6473657", "0.64695704", "0.6456225", "0.6454482", "0.64471644", "0.6425739", "0.6395481", "0.6395481", "0.6381773", "0.63531554", "0.63407177", "0.6312268", "0.63081324", "0.6302095", "0.62974596", "0.6297433", "0.62932223", "0.6274386", "0.6255486", "0.62525976", "0.6247001", "0.6245182", "0.62422144", "0.62316716", "0.6231588", "0.6205157", "0.620145", "0.6194681", "0.6179038", "0.6172396", "0.61576355", "0.61522394", "0.61428195", "0.61396277", "0.6138205", "0.6121579", "0.6111599", "0.6111599", "0.60971826", "0.60927844", "0.60788697", "0.60746884", "0.6067268" ]
0.7666208
1
Query yahoofinance information about quotes
def get_quote_info(quotes = '') ret = Hash.new YahooFinance::get_quotes(YahooFinance::StandardQuote, quotes) do |qt| ret[qt.symbol] = qt end return ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_historical_quotes(from, to)\n \tstocks = Stock.find(:all)\n \tfor stock in stocks\n \t\t\n market = (sec.market == 'sh' ? 'ss' : sec.market) \n sid = (sec.market == 'hk' ? sec.sid.slice(1,4) : sec.sid)\n \t\t\t\n \t\tYahooFinance::get_HistoricalQuotes( \"#{sid}.#{market}\", \n Date.parse(from),\n Date.parse(to) ) {|hq|\n \t\t\tquote = Quote.new\n \t\t\tquote.security = stock\n \t\t\tquote.sid = stock.sid\n \t\t\tquote.market = stock.market\n \t\t\tquote.name = stock.name\n quote.result_date = hq.date\n \t\t\tquote.open = hq.open\n \t\t\tquote.high = hq.high\n \t\t\tquote.low = hq.low\n \t\t\tquote.close = hq.close\n \t\t\tquote.adjClose = hq.adjClose\n \t\t\tquote.vol = hq.volume\n \t\t\tquote.save!\n \t\t}\n\t end\n end", "def quote_hash\n portfolio = YahooFinance::Client.new\n stock = [self.stock_symbol]\n\n returned_instance = portfolio.quotes(stock, [:name, :last_trade_date, :last_trade_time, :last_trade_price, :ask])\n returned_instance[0]\n end", "def get_quote(ticker, args = {})\n if args.is_a? Hash\n start_date = args[:start_date] if args[:start_date]\n start_date ||= args[:s] if args[:s]\n\n end_date = args[:end_date] if args[:end_date]\n end_date ||= args[:e] if args[:e]\n\n period = args[:period] if args[:period]\n period ||= args[:p] if args[:p]\n end\n\n csv = @yahoo_client.get_csv(ticker, start_date, end_date, period, 'quote')\n create_quotes_from_csv(csv)\n end", "def show\n\t\tyahoo_client = YahooFinance::Client.new\n\t\t@data = yahoo_client.quotes([\"AER\", \"AYR\", \"FLY\", \"AL\", \"ACY\", \"WLFC\"], [:symbol, :name, :ask, :change, :change_in_percent, :market_capitalization])\n\tend", "def stockquote(stock)\n url = URI(\"https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?region=US&symbols=#{@stock}\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n request = Net::HTTP::Get.new(url)\n request[\"x-rapidapi-key\"] = ENV['X_RAPIDAPI_KEY']\n request[\"x-rapidapi-host\"] = 'apidojo-yahoo-finance-v1.p.rapidapi.com'\n \n response = http.request(request)\n quoteResponse = JSON.parse(response.read_body)['quoteResponse']\n result = quoteResponse['result']\n @zero = result[0]\n puts \"Symbol = #{@zero['symbol']}, Exchange = #{@zero['fullExchangeName']}, Bid = #{@zero['bid']}, Ask = #{@zero['ask']}\"\n\n return \"<div class =col>\n <h2>Symbol=<a>#{@zero['symbol']}</a></h2>\n <h4>Exchange=<a>#{@zero['fullExchangeName']}</a></h4>\n <h4>Bid=<a>#{@zero['bid']}</a></h4>\n <h4>Ask=<a>#{@zero['ask']}</a></h4>\n </div>\"\n end", "def get_ticker_tape_info \n yahoo_client = YahooFinance::Client.new\n @ticker_data = yahoo_client.quotes([\"^GSPC\", \"^IXIC\", \"CL=F\", \"GC=F\", \"EURUSD=X\"], [:last_trade_price, :change, :change_in_percent])\n respond_to do |format|\n format.json { render json: @ticker_data, status: :ok }\n format.html { @ticker_data }\n end\n end", "def url\r\n \"http://quote.yahoo.com/d/quotes.csv?s=#{symbol}&f=#{tags.join(\"\")}&e=.csv\"\r\n end", "def get_value(symbol)\n \tyahoo_client = YahooFinance::Client.new\n \tdata = yahoo_client.quotes([symbol], [:ask])\n \tdata[0].ask\n end", "def get_stock(stock_ticker)\n stock = StockQuote::Stock.quote(stock_ticker)\n return stock\nend", "def stock_details_for_list(symbol_list)\n\t\t\tsymbol_list = symbol_list.collect { |symbol| sanitize_symbol(symbol) }\n\n return [] if symbol_list.blank?\n\n\t\t\tfield_mappings = {\n\t\t\t\tname: 'n',\n\t\t\t\tsymbol: 's',\n\t\t\t\task: 'a',\n\t\t\t\task_realtime: 'b2',\n\t\t\t\tbid: 'b',\n\t\t\t\tbid_realtime: 'b3',\n\t\t\t\tdays_range: 'm',\n\t\t\t\tyear_range: 'w',\n\t\t\t\topen: 'o',\n\t\t\t\tprevious_close: 'p',\n\t\t\t\tvolume: 'v',\n\t\t\t\tdividend_yield: 'y',\n\t\t\t\tearnings_share: 'e',\n\t\t\t\tstock_exchange: 'x',\n\t\t\t\tlast_trade_time: 't1',\n\t\t\t\teps_estimate_current_year: 'e7',\n\t\t\t\teps_estimate_next_year: 'e8',\n\t\t\t\teps_estimate_next_quarter: 'e9',\n\t\t\t\tpe_ratio: 'r',\n\t\t\t\ttwo_hundred_day_moving_average: 'm4',\n\t\t\t\tfifty_day_moving_average: 'm3',\n\t\t\t\tlast_trade_date: 'd1'\n\t\t\t}\n\n\t\t\tstart_time = Time.now.to_f\n\n csv = RestClient.get \"http://download.finance.yahoo.com/d/quotes.csv?s=#{symbol_list.join(',')}&f=#{field_mappings.values.join}\"\n\n\t\t\tall_details = CSV.parse(csv).collect do |row|\n\t\t\t\tdetails = Hash[field_mappings.keys.zip(row.collect { |v| v.to_s.strip.gsub(/['\"]/, '')} )]\n\n quote = create_openstruct(details)\n\n\t\t\t\tunless quote.name == quote.symbol\n\t\t\t\t\tquote.currently_trading = (Date.strptime(quote.last_trade_date, '%m/%d/%Y') == Date.today)\n\n quote.current_price = [quote.ask_realtime, quote.ask, quote.previous_close].detect do |value|\n\t\t\t\t\t\tvalue.to_f > 0.0\n end\n\n\t\t\t\t\tquote.current_bid = quote.bid_realtime || quote.bid\n\n\t\t\t\t\tquote.buy_price = quote.current_price.to_f + Order::TRANSACTION_FEE\n\n\t\t\t\t\tquote.statements_url = \"http://investing.money.msn.com/investments/sec-filings/?symbol=#{quote.symbol}\"\n\n # calculate stock trend\n close = quote.previous_close.to_f\n\n current = quote.current_price.to_f\n\n point_change = (current - close)\n\n quote.point_change = (point_change >= 0 ? '+' : '') + point_change.round(2).to_s\n\n\t\t\t\t\tquote.percent_change = ((point_change / close)*100).round(2)\n\n quote.trend_direction = quote.percent_change >= 0 ? 'up' : 'down'\n\n\t\t\t\t\tquote\n\t\t\t\telse\n\t\t\t\t\treturn nil\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t#Rails.logger.debug \" Yahoo (#{((Time.now.to_f-start_time)*1000.0).round} ms): #{symbol_list}\" unless Rails.env.production?\n\n return Hash[symbol_list.zip(all_details)]\n\n\t\tend", "def quote\n fetch('princess_bride.quotes')\n end", "def quotes_historical(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/historical\", options: params.compact).tap do |resp|\n resp.body = resp.body[:quotes]\n end\n end", "def quotes_historical(**args)\n valid_params?(args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/historical\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end", "def quotes_historical(**args)\n valid_params?(args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/historical\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end", "def quote\n fetch('hey_arnold.quotes')\n end", "def quotes(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/latest\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end", "def get_info_index\n @i = 0\n yahoo_client = YahooFinance::Client.new\n @tickers = Array.new\n @stocks.each do |stock|\n @tickers.push(stock.ticker_symbol)\n end\n #array of the amount change\n @index_data = yahoo_client.quotes([@tickers], [:change])\n end", "def quote\n fetch('dumb_and_dumber.quotes')\n end", "def quote\n fetch('rick_and_morty.quotes')\n end", "def livequote(ticker)\n\tfunction = 'TIME_SERIES_INTRADAY'\n\tsymbol = ticker\n\tinterval = '1min' \n\tapikey = '4528' #provided at registration\n\turl = \"http://www.alphavantage.co/query?function=#{function}&symbol=#{symbol}&interval=#{interval}&apikey=#{apikey}\"\n\turi = URI(url)\n\tresponse = Net::HTTP.get(uri)\n\tinfo = JSON.parse(response)\n\treturn info.values[1].values[0].values[3].to_f.round(2)\nend", "def find(symbol)\n response = Request.new(\"/stock/#{symbol}/quote\").get\n Models::Quote.new(response.body)\n end", "def query(yql_query, format='json', diagnostics='false')\n # TODO tried to make the necessary parameters more flexibel. failed for now :)\n # format = (hash.nil? or hash[:format.to_s].nil?) ? 'json' : hash[:format.to_s]\n # format = (hash && hash[:format]) || 'json'\n\n @log.info \"SimpleClient query()\"\n\n # try to run YQL query. If an error occures return an empty array\n begin\n\n #\n # Httparty version\n #\n options = {\n :query => {\n :env => SimpleClient.env, #\"store://datatables.org/alltableswithkeys\",\n :diagnostics => diagnostics,\n :format => format,\n :q => yql_query\n }\n }\n\n yahoo_response = self.class.get('/', options)\n\n #\n # Curl Version\n #\n\n # # put together request URL\n # full_request_url = \"#{@@yql_api_url}?diagnostics=#{diagnostics}\"\n # full_request_url += \"&#{@@env}\"\n # full_request_url += \"&format=#{format}\"\n # full_request_url += \"&q=#{CGI.escape(yql_query)}\"\n\n # request = Curl::Easy.http_get(full_request_url)\n # request.perform\n # # pp request.header_str\n # if format == 'json'\n # yahoo_response = JSON.parse(request.body_str)\n # elsif format == 'xml'\n # yahoo_response = Nokogiri::XML(request.body_str)\n # end\n\n rescue Exception => ex\n puts ex\n end\n\n return yahoo_response\n end", "def quotes\n fetch('community.quotes')\n end", "def stock_watchlist(ticker)\n YahooFinance::Client.new.quotes(ticker, watchlist_info)\n end", "def quote\n fetch('v_for_vendetta.quotes')\n end", "def get_data\n\t \thydra = Typhoeus::Hydra.hydra\n\n\t \tfirst_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tsecond_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.keystats%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tthird_url = \"http://www.quandl.com/api/v1/datasets/DMDRN/#{self.stock_ticker}_ALLFINANCIALRATIOS.csv?auth_token=#{ENV['QUANDL_API_TOKEN']}\"\n\t \tfourth_url = \"http://www.quandl.com/api/v1/datasets/PSYCH/#{self.stock_ticker}_I.json?&auth_token=auth_token=#{ENV['QUANDL_API_TOKEN']}&trim_start=#{Chronic.parse(\"last week\").strftime(\"%F\")}&trim_end=#{Chronic.parse(\"today\").strftime(\"%F\")}&sort_order=desc\"\n\n\t \t(((first_url) =~ URI::DEFAULT_PARSER.regexp[:ABS_URI]) == 0) ? first_request = Typhoeus::Request.new(first_url) : (return false)\n\t \tsecond_request = Typhoeus::Request.new(second_url) \n\t \tthird_request = Typhoeus::Request.new(third_url) \n\t \tfourth_request = Typhoeus::Request.new(fourth_url) \n\n\t \thydra.queue first_request\n\t \thydra.queue second_request\n\t \thydra.queue third_request\n\t \thydra.queue fourth_request\n\t \t\n\t \thydra.run\n\n\t\t\tfirst_request.response.options[:response_code] == 200 ? first_response = first_request.response : (return false )\n\t \tsecond_response = second_request.response\n\t \tthird_response = third_request.response \n\t \tfourth_response = fourth_request.response\n\n\t \t@quotes = JSON.parse(first_response.body) if !first_response.body.nil?\n\n\t \t@key_stats = JSON.parse(second_response.body) \n\n\t \tthird_request.response.options[:response_code] == 200 ? @quandl_data = CSV.parse(third_response.body) : @quandl_data = nil\n\n\t \tfourth_request.response.options[:response_code] == 200 ? @psych_data = JSON.parse(fourth_response.body) : @psych_data = nil\n\n\t \t@tradier = $tradier_client.quote(self.stock_ticker)\n\n\t \tmethod(:assign_yahooQuotes).call\n\t \tmethod(:assign_yahooKeyStats).call\n\t \tmethod(:assign_quandlStockData).call\n\t \tmethod(:assign_quandlPsychData).call\n\t \tmethod(:assign_databaseValues).call\n\t \tmethod(:assign_stockProfile).call\n\t \tmethod(:assign_tradierQuote).call\n\n\t end", "def quote\n fetch('the_office.quotes')\n end", "def get_historic_stock_data(ticker, date_from, date_to, frequency = \"1d\")\n url = \"https://query1.finance.yahoo.com/v7/finance/download/#{ticker}?period1=#{date_from.strftime(\"%s\")}&period2=#{date_to.strftime(\"%s\")}&interval=#{frequency}&events=history\"\n\n request = Typhoeus::Request.new(url)\n request.run\n result = request.response.body\n\n result.split(\"\\n\").drop(1).map { |row| YahooDataPoint.new(row) }\n end", "def usage\n \"?stock <symbol> - responds with the last quote <symbol> is trading at\"\n end", "def show\n @stock = Stock.find(params[:id])\n @quote = YahooFinance::get_standard_quotes(@stock.ticker)[@stock.ticker]\n @tweets = Twitter.search('$' + @stock.ticker).results\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end", "def stockname\n \"#{CSV.parse_line(YahooStock.find_by_symbol(symbol).parsed_response)[0]}\"\n end", "def quote\n fetch('brooklyn_nine_nine.quotes')\n end", "def quotes(args)\n if args.is_a?(Integer)\n get(\"/markets/quotes/#{args}\")['quotes']\n elsif args.is_a?(Array)\n get(\"/markets/quotes?ids=#{args.join(',')}\")['quotes']\n else\n fail \"Malformed argument: #{args}\"\n end\n end", "def real_time_quote\n response = Unirest.get(\"http://www.24hgold.com/english/gold_silver_prices_charts.aspx/GetLastValue?sCurrency=USD\", \n headers: { \"Content-Type\" => \"application/json\" }, \n parameters: { :age => 23, :foo => \"bar\" })\n \n response.code # Status code\n response.headers # Response headers\n response.body # Parsed body\n response.raw_body # Unparsed body\n gold_silver_price = JSON.parse(response.raw_body)\n #puts \"from service: \" + gold_silver_price.to_s\n gold_price = gold_silver_price[\"d\"][1][0] + gold_silver_price[\"d\"][1][2..7].gsub(\",\",\".\") \n silver_price = gold_silver_price[\"d\"][6].gsub(/\\s+/,\"\").gsub(\",\",\".\")\n puts gold_price\n #puts silver_price\n [::Forecasting::Quote::from_symbol_and_price(\"GOLD\",gold_price),::Forecasting::Quote::from_symbol_and_price(\"SILVER\",silver_price)]\n end", "def stock_historical_data(ticker)\n ############################################################################\n # Yahoo Finance historical quotes has been deprecated\n # YahooFinance::Client.new.historical_quotes(ticker, { start_date: Date.today - days, end_date: Date.today })\n ############################################################################\n i = 0\n history = { date: [], price: [] }\n\n url = \"https://finance.yahoo.com/quote/\" + ticker + \"/history?\"\n doc = Nokogiri::HTML(open(url))\n data = doc.at('table[data-test=\"historical-prices\"]')\n\n while i < data.children[1].children.length do\n check = data.children[1].children[i].text\n\n if (!check.include?('Dividend') && !check.include?('Split'))\n \thistory[:date] << data.children[1].children[i].children[0].text\n \thistory[:price] << data.children[1].children[i].children[5].text.to_f\n end\n\n i+=1\n end\n history\n end", "def show\n if Stock.check_valid(params[:symbol])\n if Stock.not_exists?(params[:symbol])\n create\n end\n $stock = Stock.find(params[:symbol])\n # Gather and check chart data\n @input = Stock.get_overview(params)\n if @input === 404\n not_found\n else\n @data = YahooFinance.quotes([params[:symbol]], [:name, :last_trade_price, :ask, :bid, :open, :close, :volume, :market_capitalization, :dividend_yield, :dividend_per_share, :change, :change_in_percent, :last_trade_date, :stock_exchange])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: $stock }\n end\n end\n else\n not_found\n end\n end", "def last_years_performance\n client = YahooFinance::Client.new\n quotes = client.historical_quotes(self.stock_symbol, {period: :monthly})\n last_years_quotes = quotes.select {|quote| quote.trade_date.include?(1.year.ago.year.to_s)}\n last_years_quotes.map {|quote| quote.close.to_f * quantity}.reverse\n end", "def assign_yahooQuotes\n\t \t@quotes[\"query\"][\"results\"][\"quote\"][\"ErrorIndicationreturnedforsymbolchangedinvalid\"].nil? ? @yahooQuote = @quotes[\"query\"][\"results\"][\"quote\"] : (return false)\n\t end", "def get_ticker(ticker, date_range)\n request = Quandl::Request.new(ticker, date_range)\n request.result\n end", "def get_url\n\t\t@url = \"http://finance.yahoo.com/q?s=#{@big_symbol}\"\n\tend", "def quote\n fetch('harry_potter.quotes')\n end", "def quote\n fetch('cowboy_bebop.quote')\n end", "def quotations\n response = self.class.get('/quotations', OPTIONS)\n\n if response.success?\n parse_quotations(response)\n else\n []\n end\n end", "def stock_by_price(db,price)\r\n info =db.execute(<<-SQL\r\n SELECT stocks2.stock_ticker, stocks2.stock_price FROM stocks2 Where stock_price >\"#{price}\";\r\n SQL\r\n )\r\n puts \"These follwing stocks are above $#{price}.\"\r\n puts \"===========================================\"\r\n info.each do |category|\r\n puts \" \r\n Stock Ticker : #{category['stock_ticker']}\r\n Stock Price : #{category['stock_price']}\"\r\n end\r\n puts \"===========================================\"\r\n\r\nend", "def initialize(options)\n if options.nil? || !options.is_a?(Hash)\n raise QuoteException, \"You must provide a hash of stock symbols to fetch data\"\n end\n if options[:stock_symbols].nil? || options[:stock_symbols].empty?\n raise QuoteException, \"You must provide atleast one stock symbol to fetch data\"\n end\n if !(options[:read_parameters] && options[:read_parameters].any?)\n options[:read_parameters] = [:last_trade_price_only, :last_trade_date]\n end\n options[:stock_symbols] = Array.new << options[:stock_symbols] unless options[:stock_symbols].is_a?(Array)\n @interface = YahooStock::Interface::Quote.new(options)\n end", "def quote\n fetch('ghostbusters.quotes')\n end", "def quote\n endpoint = 'https://www.alphavantage.co/'\n query = \"query?function=GLOBAL_QUOTE&symbol=#{@current_symbol}&apikey=#{@api}\"\n\n resp = JSON.parse(URI.open(\"#{endpoint}#{query}\").read)['Global Quote']\n\n if resp.nil?\n @value = Stock::NO_VALUE\n @movement = Stock::NO_CHANGE\n else\n @value = resp['05. price'].to_i\n change = resp['09. change'].to_i\n\n @movement = if change.positive?\n Stock::POS_CHANGE\n elsif change.negative?\n Stock::NEG_CHANGE\n elsif change.zero?\n Stock::NO_CHANGE\n else\n Stock::NO_CHANGE\n end\n end\n\n old_value = @cache[@current_symbol]\n @cache[@current_symbol] = \"#{@current_symbol} $#{@value} #{@movement}\"\n\n return unless @cache[@current_symbol] != old_value\n\n # TODO: DRY this up, make sure it isn't being called too much (see init_cache)\n # TODO: simple file operations like this are a good candidate for optimization/moving\n File.open(Stock::CACHE_FILENAME, 'w') do |file|\n file.write(@cache.to_json)\n end\n\n @cache[@current_symbol]\n end", "def get_quote(symbols)\n # TODO: add loop if symbols.size > 100\n raise \"Too many symbols provided for one request. Max is #{MAX_QUOTES_PER_REQUEST}\" if symbols.size > 100\n symbols = [symbols].flatten\n relative_time = ticks_since_timepoint\n retrieved_quotes = []\n\n symbols_to_request = outdated_symbols_amongst(symbols, relative_time) + not_saved_symbols(symbols)\n locally_saved_symbols = symbols - symbols_to_request\n locally_saved_quotes, integrity_broken_symbols = get_local_quotes(locally_saved_symbols)\n symbols_to_request += integrity_broken_symbols\n\n # if nothing needs to be requested - skip requesting additional things\n unless symbols_to_request.empty?\n symbols_to_request += outdated_symbols_except(symbols, relative_time) + soon_to_be_outdated_quotes(symbols, symbols_to_request, relative_time)\n retrieved_quotes = retrieve_quotes(symbols_to_request)\n save_quotes(retrieved_quotes)\n end\n\n exclude_not_relevant(symbols, retrieved_quotes) + locally_saved_quotes\n end", "def get_consumables company,remote = false\n\t\tto_be_returned = {}\n\t\tif @remote\n\t\t\tdata = YahooQuotes.get(company)\n\t\t\tto_be_returned['performing_quote'] = get_performing_quote_remote(data)\n\t\telse\n\t\t\t# the minute quote which has the highest high till the interval\n\t\t\tto_be_returned['performing_quote'] = get_performing_quote Quote.quote_types[:minute],@date.quote_date,company.id\n\t\tend\n\t\t# day quote\n\t\tto_be_returned['day_quote'] \t = Quote.get_previous_trading_day_quote @date.quote_date,company.id\n\t\treturn to_be_returned\n\tend", "def show\n @portfolio = Portfolio.find(params[:id])\n\n \n # @stocks = YahooFinance.quotes([@portfolio.stocks.group_by(&:stock_symbol)], [:ask, :bid], { raw: false } )\n # additional resources :\n # https://github.com/herval/yahoo-finance\n # https://github.com/rlazoti/yahoofinance-example/blob/master/view_stocks.rb\n\n @stocks = YahooFinance.quotes(@portfolio.stocks.group_by(&:stock_symbol), [:ask, :bid, :symbol, :last_trade_price], { raw: false } )\n \n\n @stock = Stock.new\n @stock.portfolio_id = @portfolio.id\n end", "def lookup_stock(name)\n return StockQuote::Stock.quote(name)\nend", "def index\n #@future_tickers = FutureTicker.all\n @future_tickers = $influxdb.query(\"select * from ticker where contract_type='#{params[:contract_type]}' and symbol='#{params[:symbol]}'\").first[\"values\"]\n end", "def get_value\n current_price = YahooFinance::get_quotes(YahooFinance::StandardQuote, @ticker.upcase)[@ticker.upcase].lastTrade\n current_price * @shares\n end", "def quote\n fetch('new_girl.quotes')\n end", "def quote\n fetch('stargate.quotes')\n end", "def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end", "def quote\n fetch('heroes_of_the_storm.quotes')\n end", "def quote\n fetch('simpsons.quotes')\n end", "def index\r\n @quote.get_a_quote\r\n @quotes = Quote.all\r\n end", "def stock_quote(stocks, bulb)\n\n quotes = YahooFinance::get_standard_quotes( stocks )\n quotes.each do |symbol, qt|\n\tchange_light(bulb, qt) # call change light function\n end\n\nend", "def stoxx\n puts \"\\n******* stoxx *******\"\n\n # == data format: yyyymmdd[hhmm[ss]]\n startDate = \"20170121\" + \"000000\"\n endDate = \"20170317\" + \"000000\"\n symbol = \"IBM\"\n remote_key = Rails.application.config.bar_chart_key\n\n remote_url = \"https://marketdata.websol.barchart.com\"\n remote_url += \"/getHistory.json?key=\" + remote_key + \"&symbol=\" + symbol\n remote_url += \"&type=daily&startDate=\" + startDate + \"&endDate=\" + endDate\n\n json_data = HTTParty.get(remote_url)\n puts \" ** json_data['results'].length: #{json_data['results'].length.inspect}\"\n @stock_data = json_data['results']\n\n end", "def quote\n fetch('games.street_fighter.quotes')\n end", "def get_basic_info\n yahoo_client = YahooFinance::Client.new\n @data = yahoo_client.quotes([@stock.ticker_symbol], [:open, :high, :low, :close, :last_trade_price, :change, :change_in_percent, :dividend_yield])\n respond_to do |format|\n format.json { render json: @data, status: :ok }\n format.html { @data }\n end\n url = \"https://www.quandl.com/api/v3/datasets/SF0/\" + @stock.ticker_symbol + \"_BVPS_MRY.json?api_key=rWvJtw9jPu2px-yskKZ4\"\n resp = HTTP.get(url)\n @history = JSON.parse(resp, symbolize_keys: true)\n\n end_date = Date.today\n start_date = Date.today.prev_month \n\n fred_url = \"https://api.stlouisfed.org/fred/series/observations?series_id=DGS5&api_key=d9f592689a18d841cab93825d4e060c7&file_type=json&observation_start=\" + start_date.strftime('%Y-%m-%e') + \"&observation_end=\" + end_date.strftime('%Y-%m-%e') + \"\"\n fred_resp = HTTP.get(fred_url)\n five_year_interest_rates = JSON.parse(fred_resp, symbolize_keys: true)\n interest_rate = five_year_interest_rates[\"observations\"].last[\"value\"].to_f\n\n if @history[\"dataset\"].nil?\n @derivative_fypm = \"N/A\"\n @linear_fypm = \"N/A\"\n @rate_fypm = \"N/A\"\n else\n book_values = @history[\"dataset\"][\"data\"]\n # derivative FYPM values\n v1 = book_values[3][1].to_f - book_values[4][1].to_f\n v2 = book_values[2][1].to_f - book_values[3][1].to_f\n v3 = book_values[1][1].to_f - book_values[2][1].to_f\n v4 = book_values[0][1].to_f - book_values[1][1].to_f\n @div = @data[0].dividend_yield.to_f\n price = @data[0].last_trade_price.to_f\n five_year_div_yield = ((((@div * 0.01) + 1.0) ** 5.0) - 1.0) * 100.0\n five_year_interest_rate_yield = 100 * ((((interest_rate/100) + 1) ** 5) - 1)\n # variables for derivative book value linear fit\n sigma_x = 6.0\n sigma_x_squared = 14.0\n sigma_y = v1 + v2 + v3 + v4\n sigma_xy = v2 + v3*2.0 + v4*3.0\n n = 4.0\n # derivative book value linear fit\n a = ((sigma_y*sigma_x_squared) - (sigma_x*sigma_xy))/((n*sigma_x_squared)-(sigma_x**2))\n b = ((n*sigma_xy) - (sigma_x*sigma_y))/((n*sigma_x_squared)-(sigma_x**2))\n five_year_book_value_added = (6.5*b + a)*5.0\n five_year_book_value_yield = (five_year_book_value_added/price)*100\n # derivative FYPM final calc\n @derivative_fypm = ((five_year_book_value_yield + five_year_div_yield)/five_year_interest_rate_yield)\n\n # non- derivative FYPM values\n v1 = book_values[4][1].to_f\n v2 = book_values[3][1].to_f\n v3 = book_values[2][1].to_f\n v4 = book_values[1][1].to_f\n v5 = book_values[0][1].to_f\n # variables for non-derivative book value linear fit\n sigma_x = 10.0\n sigma_x_squared = 30.0\n sigma_y = v1 + v2 + v3 + v4 + v5\n sigma_xy = v2 + v3*2.0 + v4*3.0 + v5*4.0\n n = 5.0\n # non-derivative book value linear fit\n a = ((sigma_y*sigma_x_squared) - (sigma_x*sigma_xy))/((n*sigma_x_squared)-(sigma_x**2))\n b = ((n*sigma_xy) - (sigma_x*sigma_y))/((n*sigma_x_squared)-(sigma_x**2))\n five_year_book_value_added_linear = (10.0*b + a) - v5\n five_year_book_value_added_rate = 5.0*b\n five_year_book_value_yield_linear = (five_year_book_value_added_linear/price)*100\n five_year_book_value_yield_rate = (five_year_book_value_added_rate/price)*100\n # non-derivative FYPM final calc\n @linear_fypm = ((five_year_book_value_yield_linear + five_year_div_yield)/five_year_interest_rate_yield)\n @rate_fypm = ((five_year_book_value_yield_rate + five_year_div_yield)/five_year_interest_rate_yield)\n\n # get change from previous day\n last_fypm = StockDatum.where(ticker_symbol: @stock.ticker_symbol).order(\"created_at DESC\").first\n if last_fypm.nil?\n @linear_change = nil\n @rate_change = nil\n @derivative_change = nil\n else\n @linear_change = ((@linear_fypm / last_fypm.linear_fypm ) - 1.0) * 100.0\n @rate_change = ((@rate_fypm / last_fypm.rate_fypm ) - 1) * 100\n @derivative_change = ((@derivative_fypm / last_fypm.derivative_fypm ) - 1) * 100\n end\n\n end\n end", "def print_data\n response = @quandl_client.get_stock\n abort 'Unable to find data for this search' if response['dataset'].nil? || response['dataset'].empty?\n\n prepare_result(response)\n display_result\n end", "def raw_stock_data_for_ticker(ticker)\n all_ticker_data = raw_stock_data.select { |r| r[0] == ticker }\n end", "def query(soql)\n response = api_get 'query', :q => soql\n mashify? ? response.body : response.body['records']\n end", "def get_float_from_yahoo\n url = \"http://finance.yahoo.com/q/ks?s=#{ticker}\"\n doc = open_url_or_nil(url)\n\n begin\n shares = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first.text.match(/Shares Outstanding/) }.xpath('./td').last.text\n puts shares\n shares = case shares.last\n when \"B\"\n sales.chop.to_f * BILLION\n when \"M\"\n sales.chop.to_f * MILLION\n else\n sales.chop.first.to_f * BILLION\n end\n\n rescue\n end\n shares.to_i\n end", "def fetch_quote\n uri = URI('http://www.iheartquotes.com/api/v1/random?format=text&max_lines=4&max_characters=320')\n #open(@url).read.to_s\n req = Net::HTTP.get(uri)\n #puts req\n end", "def buy_quote\n\t\tresult = money_quote('bid', btc_float2int(1.0))\n\t\treturn result['amount']\n\tend", "def make_request(symbol, start_date, end_date, callback)\n url = \"http://itable.finance.yahoo.com\" +\n \"/table.csv?s=#{ symbol }&g=d\" +\n \"&a=#{ start_date.month - 1 }&b=#{ start_date.mday }&c=#{ start_date.year }\" +\n \"&d=#{ end_date.month - 1 }&e=#{ end_date.mday }&f=#{ end_date.year.to_s }\"\n\n request = Typhoeus::Request.new(url, :method => :get)\n\n request.on_complete {|response|\n if response.code == 200\n if response.body[0..40] != \"Date,Open,High,Low,Close,Volume,Adj Close\"\n raise YahooFinanceException.new(\" * Error: Unknown response body from Yahoo - #{ response.body[0..40] } ...\")\n else\n # good response. go.\n callback.call(response.body)\n end\n elsif response.code == 404\n raise SymbolNotFoundException.new(symbol + \" not found at Yahoo\")\n else\n raise YahooFinanceException.new(\"Error communicating with Yahoo. Response code #{ response.code }. URL: \" +\n \"#{ url }. Response: #{ response.inspect }\")\n end\n }\n\n request\n end", "def specific_quote(id)\n quote = @db.get_first_value(\"SELECT quote FROM quotes WHERE id = ? LIMIT 1;\",id)\n return quote\n end", "def stock_price(ticker)\r\n\tstock_price = StockQuote::Stock.quote(ticker).last_trade_price_only\r\n\t\"The price of #{ticker} is $#{stock_price}\"\r\nend", "def quote\n fetch('final_space.quotes')\n end", "def get_stock_data(table, stockid)\n return $db.execute('SELECT * FROM ' + table + ' WHERE stockid = ?', stockid)\n end", "def sell_quote\n\t\tresult = money_quote('ask', btc_float2int(1.0))\n\t\treturn result['amount']\n\tend", "def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end", "def calculate_stocks\n stocks = stocks_owned\n .map { |stock| {ticker: stock[0], shares: stock[1]} }\n .sort_by { |stock| stock[:ticker] }\n\n # url = \"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=#pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=\"\n # stocks.each { |stock| url += \"#{stock[:ticker]},\"}\n # response = JSON.parse(open(url).read)\n\n stocks.each_with_index do |stock, idx| \n response = JSON.parse(open(\"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=#{stock[:ticker]}\").read)\n\n \n stock[:price] = response[stock[:ticker]]['quote']['latestPrice']\n stock[:intraday] = response[stock[:ticker]]['chart']\n end\n\n stocks\n end", "def grab_ytd_stock_performance\n ytd_stock_performance = @market_doc.css(\"ul.module-body.wsod.how-stocks-doing\")\n ytd_stock_performance.css(\"a.quote\").each do |x|\n name = x.css(\"span.column.quote-name\").text\n if x.css(\"span.column.quote-change.posData\").text != \"\"\n change = x.css(\"span.column.quote-change.posData\").text\n elsif x.css(\"span.column.quote-change.negData\").text != \"\"\n change = x.css(\"span.column.quote-change.negData\").text\n end\n @ytd_stock_performance << [name, change]\n end\n end", "def query_artist(artist_name = 'Dire+Straits')\n \"http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=#{artist_name}&api_key=1ca2cf614eeaa185c2b61753b434b599&format=json\"\n end", "def get_stocks\n @stocks = Stock.where(user_id: session[:current_user_id]).order(\"ticker_symbol ASC\")\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 search(opts={})\r\n opts[:output] = 'json'\r\n opts[:callback] = 'callback'\r\n Yahoo::Request.get(\"http://auctions.yahooapis.jp/AuctionWebService/V2/search\", Yahoo::Api.merge(opts))\r\n end", "def candles(id, interval)\n fail \"Interval #{interval} is unsupported\" unless CANDLESTICK_INTERVALS.includes?(interval)\n get(\"/markets/candles/#{id}?interval=#{CANDLESTICK_INTERVALS[interval]}\")['quotes']\n end", "def fetch_csv(ticker, start_date = nil, end_date = nil, period = 'd')\n connection = nil\n\n # retry 3-times in case it sends unauthorized\n 3.times do |_i|\n begin\n url = build_url(ticker, start_date, end_date, period)\n connection = open(url, 'Cookie' => @cookie)\n break\n rescue OpenURI::HTTPError => e\n fetch_credentials\n end\n end\n\n data = CSV.parse(connection.read, converters: :numeric)\n\n raise 'Yahoo.fetch_csv unable to fetch data' unless data.is_a? Array\n data\n end", "def show_q_and_a(opts={})\r\n opts[:output] = 'json'\r\n opts[:callback] = 'callback'\r\n Yahoo::Request.get(\"http://auctions.yahooapis.jp/AuctionWebService/V1/ShowQandA\", Yahoo::Api.merge(opts))\r\n end", "def get_current_stock_price(stock_symbol_name)\n quote_type = YahooFinance::StandardQuote\n quote_symbol = stock_symbol_name\n YahooFinance::get_quotes(quote_type,quote_symbol) do |qt|\n @current_stock_price = qt.lastTrade\n return @current_stock_price\n end\n end", "def stock_price(ticker)\n\tstock_price = StockQuote::Stock.quote(ticker).last_trade_price_only\n\t\"The price of #{ticker} is $#{stock_price}\"\nend", "def get_quote_list(portfolio = Array.new)\n\tquote_list = Array.new\n\tportfolio.each do |p|\n\t\tquote_list << p['stock']\n\tend\n\treturn quote_list.join(',')\nend", "def candles(sym='btcusd', options={})\n #Hashie::Mash.new(\n #self.class.get(\"/v1/candles/#{sym}\", options).parsed_response\n nil\n end", "def global_metrics_quotes_historical_get(opts = {})\n data, _status_code, _headers = global_metrics_quotes_historical_get_with_http_info(opts)\n data\n end", "def api\n url = \"http://ichart.yahoo.com/table.csv?s=#{ params[:s] }&g=d&\"\n end_month = Date.today.month - 1\n end_day = Date.today.day\n end_year = Date.today.year\n\n start_date_params = \"a=#{ end_month }&b=#{ end_day }&c=#{ end_year - 1 }\"\n end_date_params = \"d=#{ end_month }&e=#{ end_day }&f=#{ end_year }\"\n\n url += start_date_params + '&' + end_date_params\n\n puts url\n res = Net::HTTP.get(URI(url))\n render inline: res\n end", "def index\n @quote_values = QuoteValue.find(:all, :order=>\"quote_target_id ASC, data_time ASC\", :limit=>250)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quote_values }\n end\n end", "def particular_customer_quotes\n offset = 0\n filter = \"%\"\n if (params[:offset].class.to_s != \"NilClass\" && params[:offset].integer?)\n offset = params[:offset].to_i\n end\n if (params[:filter].class.to_s != \"NilClass\")\n filter = \"%\" + params[:filter] + \"%\"\n end\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # it should be this query which is written down\n lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(idClient: params[:no]).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(\"(note like ? OR status.name LIKE ? OR dispatcher.firstName LIKE ? OR dispatcher.lastName LIKE ? OR reference LIKE ? ) AND idClient = ?\", filter, filter, filter, filter, filter, params[:no]).order('DESC').offset(offset).limit(30)\n\n # lstQuotes.each do |quote|\n # # TODO! Format each quote before send it.\n # end\n return render_json_response(lstQuotes, :ok)\n end", "def scrapeForCurrentData()\n url = \"https://ca.finance.yahoo.com/quote/\" + @stockTicker + \"/key-statistics?\"\n result = {}\n page = Nokogiri::HTML(open(url))\n main_contents = page.css('tr td')\n main_contents.search('sup').remove\n main_contents.each_with_index do |content, index|\n if index%2 == 0\n result[content.text] = main_contents[index+1].text\n end\n end\n #puts result\n return result\n end", "def get_account_quotas()\n session_url = '/sessions?page=0&pageSize=1'\n response = self.class.get(session_url, @options)\n response.headers.select { |k, _v| k.to_s.start_with? 'nexosis-account' }\n end", "def parse_quotations(response)\n return [] unless response.key?('results')\n\n currencies = {}\n\n response['results']['currencies'].each do |acronym, value|\n next unless CURRENCIES.include?(acronym)\n\n currencies[acronym.to_sym] = { buy: value['buy'],\n sell: value['sell'],\n variation: value['variation'] }\n end\n\n currencies\n end", "def couch_read_quotes(limit = 5)\n server = Couch::Server.new(Couchdb_server, Couchdb_server_port, Couchdb_user, Couchdb_password)\n response = server.get(\"#{Couchdb_db_path}/_design/quotes/_view/sortedByDate?include_docs=true&descending=true&limit=#{limit}\")\n # response = server.get(\"#{Couchdb_db_path}/_all_docs?include_docs=true&limit=#{limit}\")\n response = JSON.parse(response.body)\n\n # read all documents and create a QuotedArticle for them\n docs = response[\"rows\"].map do |d|\n # d[\"doc\"]\n QuotedArticle.new(d[\"doc\"])\n end\n\n return docs\n end", "def raw_stock_data\n return @raw_stock_data unless @raw_stock_data.nil?\n\n raw_response = JSON.load(HTTParty.get(QUANDL_ENDPOINT).body)\n @raw_stock_data = raw_response['datatable']['data']\n end", "def quotes(symbols_array, columns_array = [:symbol, :last_trade_price, :last_trade_date, :change, :previous_close], options = {})\n # remove invalid keys\n columns_array.reject! { |c| !COLUMNS.key?(c) }\n columns_array << :symbol if columns_array.index(:symbol).nil?\n\n # \"N/A\" is never present if { raw = false }\n options[:na_as_nil] = true if options[:raw] == false\n\n ret = []\n symbols_array.each_slice(SYMBOLS_PER_REQUEST) do |symbols|\n read_quotes(symbols.join(\"+\"), columns_array).map do |row|\n data = row.to_hash\n if options[:na_as_nil]\n data.each { |key, value| data[key] = nil if value == 'N/A' }\n end\n if options[:raw] == false\n data.each { |key, value| data[key] = format(value, COLUMNS[key][1]) }\n end\n ret << OpenStruct.new(data)\n end\n end\n ret\n end", "def daily_all_stocks?\n Service[:daily_yahoo].runnable?(1.day)\n end" ]
[ "0.7222867", "0.72192204", "0.7176436", "0.71342504", "0.70563275", "0.70356554", "0.67459595", "0.66809464", "0.6655099", "0.65678495", "0.65178174", "0.6507909", "0.63884366", "0.63884366", "0.6333054", "0.63318944", "0.63249636", "0.6310393", "0.6304328", "0.63012224", "0.6272675", "0.6266315", "0.6243227", "0.62187886", "0.6217664", "0.6199571", "0.6195689", "0.61803156", "0.61504745", "0.6149776", "0.61433154", "0.6126244", "0.6108619", "0.6108109", "0.61044854", "0.6093968", "0.6077633", "0.6076756", "0.60101914", "0.60030735", "0.5999843", "0.5990798", "0.5964638", "0.59465575", "0.59419364", "0.5934687", "0.59312123", "0.5908352", "0.5905258", "0.589982", "0.58930373", "0.58855635", "0.58521116", "0.5849087", "0.58416826", "0.58400977", "0.5827971", "0.58145016", "0.5807853", "0.58017695", "0.5795745", "0.57694", "0.5764513", "0.5750348", "0.5740862", "0.5735942", "0.5725678", "0.57149726", "0.5713149", "0.56939644", "0.56454057", "0.56314945", "0.5617355", "0.56138676", "0.5608997", "0.56087464", "0.560469", "0.55905616", "0.55835927", "0.55714786", "0.5563945", "0.55555785", "0.55376655", "0.5517982", "0.5504462", "0.5499894", "0.54981714", "0.54933757", "0.5488355", "0.54777545", "0.54649675", "0.5452295", "0.54411846", "0.54366404", "0.5431058", "0.5417426", "0.5408351", "0.5392086", "0.53702", "0.5366695" ]
0.7063795
4
construct the quote list for querying the stock information
def get_quote_list(portfolio = Array.new) quote_list = Array.new portfolio.each do |p| quote_list << p['stock'] end return quote_list.join(',') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stock_details_for_list(symbol_list)\n\t\t\tsymbol_list = symbol_list.collect { |symbol| sanitize_symbol(symbol) }\n\n return [] if symbol_list.blank?\n\n\t\t\tfield_mappings = {\n\t\t\t\tname: 'n',\n\t\t\t\tsymbol: 's',\n\t\t\t\task: 'a',\n\t\t\t\task_realtime: 'b2',\n\t\t\t\tbid: 'b',\n\t\t\t\tbid_realtime: 'b3',\n\t\t\t\tdays_range: 'm',\n\t\t\t\tyear_range: 'w',\n\t\t\t\topen: 'o',\n\t\t\t\tprevious_close: 'p',\n\t\t\t\tvolume: 'v',\n\t\t\t\tdividend_yield: 'y',\n\t\t\t\tearnings_share: 'e',\n\t\t\t\tstock_exchange: 'x',\n\t\t\t\tlast_trade_time: 't1',\n\t\t\t\teps_estimate_current_year: 'e7',\n\t\t\t\teps_estimate_next_year: 'e8',\n\t\t\t\teps_estimate_next_quarter: 'e9',\n\t\t\t\tpe_ratio: 'r',\n\t\t\t\ttwo_hundred_day_moving_average: 'm4',\n\t\t\t\tfifty_day_moving_average: 'm3',\n\t\t\t\tlast_trade_date: 'd1'\n\t\t\t}\n\n\t\t\tstart_time = Time.now.to_f\n\n csv = RestClient.get \"http://download.finance.yahoo.com/d/quotes.csv?s=#{symbol_list.join(',')}&f=#{field_mappings.values.join}\"\n\n\t\t\tall_details = CSV.parse(csv).collect do |row|\n\t\t\t\tdetails = Hash[field_mappings.keys.zip(row.collect { |v| v.to_s.strip.gsub(/['\"]/, '')} )]\n\n quote = create_openstruct(details)\n\n\t\t\t\tunless quote.name == quote.symbol\n\t\t\t\t\tquote.currently_trading = (Date.strptime(quote.last_trade_date, '%m/%d/%Y') == Date.today)\n\n quote.current_price = [quote.ask_realtime, quote.ask, quote.previous_close].detect do |value|\n\t\t\t\t\t\tvalue.to_f > 0.0\n end\n\n\t\t\t\t\tquote.current_bid = quote.bid_realtime || quote.bid\n\n\t\t\t\t\tquote.buy_price = quote.current_price.to_f + Order::TRANSACTION_FEE\n\n\t\t\t\t\tquote.statements_url = \"http://investing.money.msn.com/investments/sec-filings/?symbol=#{quote.symbol}\"\n\n # calculate stock trend\n close = quote.previous_close.to_f\n\n current = quote.current_price.to_f\n\n point_change = (current - close)\n\n quote.point_change = (point_change >= 0 ? '+' : '') + point_change.round(2).to_s\n\n\t\t\t\t\tquote.percent_change = ((point_change / close)*100).round(2)\n\n quote.trend_direction = quote.percent_change >= 0 ? 'up' : 'down'\n\n\t\t\t\t\tquote\n\t\t\t\telse\n\t\t\t\t\treturn nil\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t#Rails.logger.debug \" Yahoo (#{((Time.now.to_f-start_time)*1000.0).round} ms): #{symbol_list}\" unless Rails.env.production?\n\n return Hash[symbol_list.zip(all_details)]\n\n\t\tend", "def get_quote_list(html)\n quote_list = Array.new\n\n html.css('div.item-listing').css('div.item').each do |item|\n quote = Quote.new\n quote.id = item[\"class\"].gsub(/[^\\d]/, '')\n quote.link = BASE_QUOTE_LINK.gsub(\"id\", quote.id)\n\n quote_item = item.children()[0].children()[0]\n\n quote_item.children().each do |i|\n if i[\"class\"] == \"decoration\"\n i.content = \"|newline|\" + i.content + \"|decorationclass|\"\n end\n end\n\n while quote_item\n str = HTMLEntities.new.decode quote_item.content.gsub(/\\|newline\\|/, \"\\n\")\n\n str.each_line do |line|\n unless line =~ /^[[:space:]]+$/\n first, second = line.split(/\\|decorationclass\\|/)\n quote.quote << [first.strip(), second ? second.strip() : second]\n end\n end\n\n quote_list << quote\n if (quote_item != nil)\n quote_item = quote_item.next()\n end\n end\n\n end\n\n quote_list\n end", "def get_historical_quotes(from, to)\n \tstocks = Stock.find(:all)\n \tfor stock in stocks\n \t\t\n market = (sec.market == 'sh' ? 'ss' : sec.market) \n sid = (sec.market == 'hk' ? sec.sid.slice(1,4) : sec.sid)\n \t\t\t\n \t\tYahooFinance::get_HistoricalQuotes( \"#{sid}.#{market}\", \n Date.parse(from),\n Date.parse(to) ) {|hq|\n \t\t\tquote = Quote.new\n \t\t\tquote.security = stock\n \t\t\tquote.sid = stock.sid\n \t\t\tquote.market = stock.market\n \t\t\tquote.name = stock.name\n quote.result_date = hq.date\n \t\t\tquote.open = hq.open\n \t\t\tquote.high = hq.high\n \t\t\tquote.low = hq.low\n \t\t\tquote.close = hq.close\n \t\t\tquote.adjClose = hq.adjClose\n \t\t\tquote.vol = hq.volume\n \t\t\tquote.save!\n \t\t}\n\t end\n end", "def quote_bag\n QuoteBag.new quotes\n end", "def get_quote(ticker, args = {})\n if args.is_a? Hash\n start_date = args[:start_date] if args[:start_date]\n start_date ||= args[:s] if args[:s]\n\n end_date = args[:end_date] if args[:end_date]\n end_date ||= args[:e] if args[:e]\n\n period = args[:period] if args[:period]\n period ||= args[:p] if args[:p]\n end\n\n csv = @yahoo_client.get_csv(ticker, start_date, end_date, period, 'quote')\n create_quotes_from_csv(csv)\n end", "def quote_hash\n portfolio = YahooFinance::Client.new\n stock = [self.stock_symbol]\n\n returned_instance = portfolio.quotes(stock, [:name, :last_trade_date, :last_trade_time, :last_trade_price, :ask])\n returned_instance[0]\n end", "def quote\n fetch('princess_bride.quotes')\n end", "def quotations\n response = self.class.get('/quotations', OPTIONS)\n\n if response.success?\n parse_quotations(response)\n else\n []\n end\n end", "def get_quote_info(quotes = '')\n\tret = Hash.new\n\tYahooFinance::get_quotes(YahooFinance::StandardQuote, quotes) do |qt|\n\t\tret[qt.symbol] = qt\n\tend\n\treturn ret\nend", "def quotes\n fetch('community.quotes')\n end", "def stockquote(stock)\n url = URI(\"https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?region=US&symbols=#{@stock}\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n request = Net::HTTP::Get.new(url)\n request[\"x-rapidapi-key\"] = ENV['X_RAPIDAPI_KEY']\n request[\"x-rapidapi-host\"] = 'apidojo-yahoo-finance-v1.p.rapidapi.com'\n \n response = http.request(request)\n quoteResponse = JSON.parse(response.read_body)['quoteResponse']\n result = quoteResponse['result']\n @zero = result[0]\n puts \"Symbol = #{@zero['symbol']}, Exchange = #{@zero['fullExchangeName']}, Bid = #{@zero['bid']}, Ask = #{@zero['ask']}\"\n\n return \"<div class =col>\n <h2>Symbol=<a>#{@zero['symbol']}</a></h2>\n <h4>Exchange=<a>#{@zero['fullExchangeName']}</a></h4>\n <h4>Bid=<a>#{@zero['bid']}</a></h4>\n <h4>Ask=<a>#{@zero['ask']}</a></h4>\n </div>\"\n end", "def quotes(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/latest\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end", "def index\r\n @quote.get_a_quote\r\n @quotes = Quote.all\r\n end", "def quote\n @quote ||= quote_hash\n end", "def quotes(args)\n if args.is_a?(Integer)\n get(\"/markets/quotes/#{args}\")['quotes']\n elsif args.is_a?(Array)\n get(\"/markets/quotes?ids=#{args.join(',')}\")['quotes']\n else\n fail \"Malformed argument: #{args}\"\n end\n end", "def get_quote(symbols)\n # TODO: add loop if symbols.size > 100\n raise \"Too many symbols provided for one request. Max is #{MAX_QUOTES_PER_REQUEST}\" if symbols.size > 100\n symbols = [symbols].flatten\n relative_time = ticks_since_timepoint\n retrieved_quotes = []\n\n symbols_to_request = outdated_symbols_amongst(symbols, relative_time) + not_saved_symbols(symbols)\n locally_saved_symbols = symbols - symbols_to_request\n locally_saved_quotes, integrity_broken_symbols = get_local_quotes(locally_saved_symbols)\n symbols_to_request += integrity_broken_symbols\n\n # if nothing needs to be requested - skip requesting additional things\n unless symbols_to_request.empty?\n symbols_to_request += outdated_symbols_except(symbols, relative_time) + soon_to_be_outdated_quotes(symbols, symbols_to_request, relative_time)\n retrieved_quotes = retrieve_quotes(symbols_to_request)\n save_quotes(retrieved_quotes)\n end\n\n exclude_not_relevant(symbols, retrieved_quotes) + locally_saved_quotes\n end", "def quote_names\n @feed_quote_map.values \n end", "def quote\n fetch('v_for_vendetta.quotes')\n end", "def quote\n fetch('brooklyn_nine_nine.quotes')\n end", "def quotes(symbols_array, columns_array = [\n :symbol, :last_trade_price, :last_trade_date,\n :change, :previous_close], options = {})\n\n options[:raw] ||= true\n ret = []\n symbols_array.each_slice(SYMBOLS_PER_REQUEST) do |symbols|\n read_quotes(symbols.join(\"+\"), columns_array).map do |row|\n ret << OpenStruct.new(row.to_hash)\n end\n end\n ret\n end", "def quote\n fetch('dumb_and_dumber.quotes')\n end", "def quotes_historical(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/historical\", options: params.compact).tap do |resp|\n resp.body = resp.body[:quotes]\n end\n end", "def quote\n fetch('rick_and_morty.quotes')\n end", "def index\n @quote_lines = QuoteLine.all\n end", "def save_quote\n event_id = params[\"event_id\"]\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if params[\"quoted_price-#{each.id}\"] == nil\n each.quoted_price = 0\n else\n each.quoted_price = (params[\"quoted_price-#{each.id}\"].gsub(\",\" , \"\").to_f * 100).round(2)\n end\n items_cost = params[\"per_item_cost-#{each.id}\"].to_f * 100.0\n each.per_item_cost = items_cost.round(2)\n each.per_item_list_price = (params[\"per_item_list_price-#{each.id}\"].to_f * 100).round(2)\n each.extended_list_price = (params[\"extended_list_price-#{each.id}\"].to_f * 100).round(2)\n each.save!\n end\n quote = Quote.where(event_id: event_id).first\n quote.quote_name = params[\"quote_name\"]\n quote.quote_style = params[\"quote_style\"]\n quoted_total_price = 0\n quoted_total_cost = 0\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if each.quoted_price == nil\n each.quoted_price = 0\n else # do nothing\n end\n quoted_total_price = quoted_total_price + each.quoted_price\n quoted_total_cost = quoted_total_cost + (((each.per_item_cost / 100.0) * (each.item_quantity / 100.0)).round(2) * 100.0).round(2)\n end \n quote.total_price = quoted_total_price\n quote.total_cost = quoted_total_cost\n if quoted_total_cost != 0\n quote.markup = (quoted_total_price / quoted_total_cost) * 100\n else # do nothing\n end\n quote.status = params[\"status\"]\n if params[\"status\"] != \"Completed\" && params[\"status\"] != \"Ordered\"\n quote.wholesale_order_date = nil\n else # do nothing\n end\n quote.save!\n event = Event.where(id: event_id).first\n event.event_status = params[\"status\"]\n event.quote_message = params[\"quote_message\"]\n event.save!\n redirect_to \"/generate_quote/#{event_id}\" and return\n end", "def quotes(symbols_array, columns_array = [:symbol, :last_trade_price, :last_trade_date, :change, :previous_close], options = {})\n # remove invalid keys\n columns_array.reject! { |c| !COLUMNS.key?(c) }\n columns_array << :symbol if columns_array.index(:symbol).nil?\n\n # \"N/A\" is never present if { raw = false }\n options[:na_as_nil] = true if options[:raw] == false\n\n ret = []\n symbols_array.each_slice(SYMBOLS_PER_REQUEST) do |symbols|\n read_quotes(symbols.join(\"+\"), columns_array).map do |row|\n data = row.to_hash\n if options[:na_as_nil]\n data.each { |key, value| data[key] = nil if value == 'N/A' }\n end\n if options[:raw] == false\n data.each { |key, value| data[key] = format(value, COLUMNS[key][1]) }\n end\n ret << OpenStruct.new(data)\n end\n end\n ret\n end", "def initialize(options)\n if options.nil? || !options.is_a?(Hash)\n raise QuoteException, \"You must provide a hash of stock symbols to fetch data\"\n end\n if options[:stock_symbols].nil? || options[:stock_symbols].empty?\n raise QuoteException, \"You must provide atleast one stock symbol to fetch data\"\n end\n if !(options[:read_parameters] && options[:read_parameters].any?)\n options[:read_parameters] = [:last_trade_price_only, :last_trade_date]\n end\n options[:stock_symbols] = Array.new << options[:stock_symbols] unless options[:stock_symbols].is_a?(Array)\n @interface = YahooStock::Interface::Quote.new(options)\n end", "def index\n @quote_list = QuoteList.find(params[:quote_list_id])\n @quotes = @quote_list.quotes.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quotes }\n end\n end", "def quote\n fetch('final_space.quotes')\n end", "def quote\n fetch('new_girl.quotes')\n end", "def quote\n fetch('the_office.quotes')\n end", "def display_quote_list(quote_list)\n quote_list.each do |quote|\n quote.display\n print \"\\n\\n\"\n end\n end", "def parse_quotations(response)\n return [] unless response.key?('results')\n\n currencies = {}\n\n response['results']['currencies'].each do |acronym, value|\n next unless CURRENCIES.include?(acronym)\n\n currencies[acronym.to_sym] = { buy: value['buy'],\n sell: value['sell'],\n variation: value['variation'] }\n end\n\n currencies\n end", "def url\r\n \"http://quote.yahoo.com/d/quotes.csv?s=#{symbol}&f=#{tags.join(\"\")}&e=.csv\"\r\n end", "def quotes; end", "def initialize(symbol)\n @stock = StockQuote::Stock.quote(symbol)\n @name = @stock.name\n @bid = @stock.bid\n @change = @stock.change\n @change_percent = @stock.change_percent_change\n @day_range = @stock.days_range\n end", "def quote\n fetch('stargate.quotes')\n end", "def stock\n sql = \"SELECT * FROM cars\n WHERE shop_id = $1\"\n value = [@id]\n cars = SqlRunner.run(sql, value)\n result = cars.map{|car| Car.new(car)}\n return result\n end", "def parse_quotes_tableful\n change_endpoint(:tableful)\n result = []\n table = browser.table\n update_action_log(:table, !table.nil? && table.respond_to?(:trs))\n table = table.trs[1...-1]\n update_action_log(:trs, !table.nil? && !table.empty?)\n\n page = 1\n loop do\n table.each_with_index do |tr, i|\n next if i.odd?\n quote, author = table[i].text.split(' Author: ')\n result.push({\n text: quote,\n author: author,\n tags: table[i + 1].text.split[1..-1]\n })\n end\n page += 1\n browser.goto(base_url + ENDPOINTS[:tableful] + \"/page/#{page}\")\n break if browser.text.include?('No quotes found')\n end\n result\n end", "def index\n @quote_items = QuoteItem.where(order_id: current_customer.order_id)\n end", "def quote\n fetch('simpsons.quotes')\n end", "def repo_list\n stocks = Price.where(:sec_type => 'Stock')\n @stocks = stocks.collect { |stock| [stock, stock.last_update] }\n @options = Price.where('sec_type != ?','Stock')\n @history = History.all\n end", "def index\n @quotes = Quote.all\n end", "def set_quotation_list\n @quotation_list = QuotationList.find(params[:quotation_list_id])\n end", "def quotes_historical(**args)\n valid_params?(args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/historical\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end", "def quotes_historical(**args)\n valid_params?(args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/historical\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end", "def initialize(*args)\n @stock = args.map{ |item| [item.code.to_sym, item] }.to_h\n end", "def index\n @quotes = Quote.all\n end", "def index\n @quotes = Quote.all\n end", "def index\n @quotes = Quote.all\n end", "def index\n @quotes = Quote.all\n end", "def get_stock(stock_ticker)\n stock = StockQuote::Stock.quote(stock_ticker)\n return stock\nend", "def create\n @client=Client.find_by_id(params['q_param']['client'])\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n list = [[\"\",\"\",\"1\",\"\"]]\n quote_p={:title=>title,:comment=>comment, :status=>1, :list=>list}\n @quote = @client.quotes.create(quote_p)\n render json: {:quote_id=>@quote.id}\n\n # respond_to do |format|\n # if @quote.save\n # format.html { redirect_to index, notice: 'Quote was successfully created.' }\n # # format.json { render action: 'show', status: :created, location: @quote }\n # else\n # format.html { render action: 'new' }\n # # format.json { render json: @quote.errors, status: :unprocessable_entity }\n # end\n # end\nend", "def quote\n fetch('ghostbusters.quotes')\n end", "def index\n @quote_request_items = QuoteRequestItem.all\n end", "def index\n @order=params[:order].to_i\n if @order==1\n @quotes=Quote.order(title: :asc).all\n elsif @order==2\n @quotes=Quote.order(title: :desc).all\n elsif @order==3\n @quotes=Quote.joins(\"left join clients on quotes.client_id = clients.id\").order(\"clients.last_name ASC\")\n elsif @order==4\n @quotes=Quote.joins(\"left join clients on quotes.client_id = clients.id\").order(\"clients.last_name DESC\")\n elsif @order==5\n @quotes=Quote.order(total: :asc).all\n elsif @order==6\n @quotes=Quote.order(total: :desc).all\n elsif @order==7\n @quotes=Quote.order(created_at: :desc).all\n elsif @order==8\n @quotes=Quote.order(created_at: :asc).all\n elsif @order==9\n @quotes=Quote.order(status: :desc).all\n elsif @order==10\n @quotes=Quote.order(status: :asc).all\n\n else\n @quotes = Quote.all\n end\n end", "def create\n @quoteable = find_quoteable\n @quote = @quoteable.quotes.build(params[:quote])\n\n respond_to do |format|\n if @quote.save\n format.html { redirect_to @quote, notice: 'Quote was successfully created.' }\n format.json { render json: @quote, status: :created, location: @quote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end", "def possible_quote_strings(commodity: nil)\n raise \"No commodity given\" if commodity.nil?\n # We get all quotes in USD\n [\"#{commodity}=X\", \"USD#{commodity}=X\", \"#{commodity}\"]\n end", "def set_quotations\n qid = PurchaseOrder.select(:quotation_id).map(&:quotation_id)\n @quotations = Quotation.where.not(id: qid)\n end", "def set_quote\n @quotes= Quote.find(params[:id])\n end", "def index\n @price_quotes = PriceQuote.all\n end", "def index\n @quote_lists = QuoteList.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quote_lists }\n end\n end", "def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end", "def quote\n fetch('hey_arnold.quotes')\n end", "def make_item_list\n @data = equips_for_enchant\n end", "def list\n Terminal::Table.new(title: \"Items in Stock\", headings: [ 'Code', 'Name', 'Price'], rows: to_a)\n end", "def initialize(ticker, from_date, to_date)\n @from_date = from_date\n @to_date = to_date\n # @raw_data = YahooFinance::get_historical_quotes(ticker, @from_date-Extra_Days, to_date).reverse\n quote = get_quote(ticker)\n @raw_data = transpose_reverse(quote)\n convert_raw_data_strings!\n # We will never have need of the extraneous dates so we trim here\n @dates = trim_dates\n end", "def particular_customer_quotes\n offset = 0\n filter = \"%\"\n if (params[:offset].class.to_s != \"NilClass\" && params[:offset].integer?)\n offset = params[:offset].to_i\n end\n if (params[:filter].class.to_s != \"NilClass\")\n filter = \"%\" + params[:filter] + \"%\"\n end\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # it should be this query which is written down\n lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(idClient: params[:no]).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(\"(note like ? OR status.name LIKE ? OR dispatcher.firstName LIKE ? OR dispatcher.lastName LIKE ? OR reference LIKE ? ) AND idClient = ?\", filter, filter, filter, filter, filter, params[:no]).order('DESC').offset(offset).limit(30)\n\n # lstQuotes.each do |quote|\n # # TODO! Format each quote before send it.\n # end\n return render_json_response(lstQuotes, :ok)\n end", "def quotes\n end", "def quote\n fetch('harry_potter.quotes')\n end", "def build_quote_array(page_array)\n all_quotes = []\n page_array.map do |page|\n page_quotes = page.search('div.quoteText').map do |x|\n x.text.gsub(/\\n/, '').gsub(/Dorothy.*/, '').gsub(/”.*|^.*“/, '')\n end\n all_quotes += page_quotes\n end\n all_quotes\nend", "def create\n @quote = Core::Quote.new(quote_params)\n @quote.save\n end", "def stock_quote(stocks, bulb)\n\n quotes = YahooFinance::get_standard_quotes( stocks )\n quotes.each do |symbol, qt|\n\tchange_light(bulb, qt) # call change light function\n end\n\nend", "def index\n @quotation = Quotation.where(client_id: current_client).limit(10).order(created_at: :desc)\n end", "def set_quot\n @quote = Quote.find(params[:id])\n end", "def calculate_stocks\n stocks = stocks_owned\n .map { |stock| {ticker: stock[0], shares: stock[1]} }\n .sort_by { |stock| stock[:ticker] }\n\n # url = \"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=#pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=\"\n # stocks.each { |stock| url += \"#{stock[:ticker]},\"}\n # response = JSON.parse(open(url).read)\n\n stocks.each_with_index do |stock, idx| \n response = JSON.parse(open(\"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=#{stock[:ticker]}\").read)\n\n \n stock[:price] = response[stock[:ticker]]['quote']['latestPrice']\n stock[:intraday] = response[stock[:ticker]]['chart']\n end\n\n stocks\n end", "def show\n\n @quote = Quote.find(params[:id])\n # @clients = Client\n # @alpha=('a'..'z').to_a + ('0'..'9').to_a\n @client= Client.find_by_id(@quote.client_id)\n if @quote.list==nil\n @lmax=0\n else\n @lmax=@quote.list.length\n end\n if @quote.total==nil\n @total=0\n else\n @total=@quote.total\n end\n @tax_rate=@quote.tax_rate\n if @tax_rate==nil\n @tax_rate=0\n end\n @hash=Hash.new\n i=0\n while i<@lmax do\n @hash.merge!({i => @quote.list[i]})\n i=i+1\n end\n if @lmax==0\n @hash={0=>[\"\", \"\", \"\", \"\"]}\n end\n end", "def quote\n fetch('heroes_of_the_storm.quotes')\n end", "def get_ticker_tape_info \n yahoo_client = YahooFinance::Client.new\n @ticker_data = yahoo_client.quotes([\"^GSPC\", \"^IXIC\", \"CL=F\", \"GC=F\", \"EURUSD=X\"], [:last_trade_price, :change, :change_in_percent])\n respond_to do |format|\n format.json { render json: @ticker_data, status: :ok }\n format.html { @ticker_data }\n end\n end", "def stocks\n\n end", "def generate_quote( qdb_access, tail = false )\n\t\t\t#return nil if (selector.nil? || @@selectors[selector.to_sym].nil?);\n\t\t\t#return get_base_url(@@selectors[selector.to_sym]) if (is.nil? || tags.empty?);\n\t\t\tbegin\n\t\t\t\toutput = []\n\t\t\t\toutput << \"#{qdb_access[:fullname]} quote ##{qdb_access[:id]} (#{qdb_access[:meta]}):\" unless tail\n\t\t\t\toutput << (!tail ? qdb_access[:quote].map {|e| \"- #{e}\" } : qdb_access[:quotetail].map {|e| \"- #{e}\" })\n\n\t\t\t\tfooter = [] \n\t\t\t\tfooter << (qdb_access[:quote].size < qdb_access[:fullquote].size && !tail ? \"#{qdb_access[:fullquote].size - qdb_access[:lines]} lines omitted.\" : nil)\n\t\t\t\tfooter << \"View\"\n\t\t\t\tfooter << (qdb_access[:quote].size < qdb_access[:fullquote].size && !tail ? \"more from\" : nil)\n\t\t\t\tfooter << \"this quote at #{qdb_access[:url]}\"\n\t\t\t\toutput << footer.reject(&:nil?).join(\" \")\n\t\t\t\t\t\n\t\t\t\toutput.reject(&:nil?).join(\"\\n\");\n\t\t\trescue\n\t\t\t\t\"Error: #{$!}\"\n\t\t\tend\n\t\tend", "def quote\n fetch('cowboy_bebop.quote')\n end", "def create\n @quote = Quote.new(quote_params)\n @quote.tag_list = params[:tags]\n\n respond_to do |format|\n if @quote.save\n format.json { render :show, status: :created, location: @quote }\n else\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n\t\tyahoo_client = YahooFinance::Client.new\n\t\t@data = yahoo_client.quotes([\"AER\", \"AYR\", \"FLY\", \"AL\", \"ACY\", \"WLFC\"], [:symbol, :name, :ask, :change, :change_in_percent, :market_capitalization])\n\tend", "def quote\n @quote ||= Quote.get(params[:id])\n end", "def stock_watchlist(ticker)\n YahooFinance::Client.new.quotes(ticker, watchlist_info)\n end", "def quote\n fetch('games.street_fighter.quotes')\n end", "def quote_params\n params.require(:quote).permit(:company_name, :quote_information, :quote_amount, :quote_due_date, :artwork_due_date, :artwork_proof_link, :production_notes, :quote_status, :quote_link, :order_ship_date, :order_installation_date)\n end", "def quote_params\r\n params.fetch(:quote, {})\r\n end", "def couch_read_quotes(limit = 5)\n server = Couch::Server.new(Couchdb_server, Couchdb_server_port, Couchdb_user, Couchdb_password)\n response = server.get(\"#{Couchdb_db_path}/_design/quotes/_view/sortedByDate?include_docs=true&descending=true&limit=#{limit}\")\n # response = server.get(\"#{Couchdb_db_path}/_all_docs?include_docs=true&limit=#{limit}\")\n response = JSON.parse(response.body)\n\n # read all documents and create a QuotedArticle for them\n docs = response[\"rows\"].map do |d|\n # d[\"doc\"]\n QuotedArticle.new(d[\"doc\"])\n end\n\n return docs\n end", "def real_time_quote\n response = Unirest.get(\"http://www.24hgold.com/english/gold_silver_prices_charts.aspx/GetLastValue?sCurrency=USD\", \n headers: { \"Content-Type\" => \"application/json\" }, \n parameters: { :age => 23, :foo => \"bar\" })\n \n response.code # Status code\n response.headers # Response headers\n response.body # Parsed body\n response.raw_body # Unparsed body\n gold_silver_price = JSON.parse(response.raw_body)\n #puts \"from service: \" + gold_silver_price.to_s\n gold_price = gold_silver_price[\"d\"][1][0] + gold_silver_price[\"d\"][1][2..7].gsub(\",\",\".\") \n silver_price = gold_silver_price[\"d\"][6].gsub(/\\s+/,\"\").gsub(\",\",\".\")\n puts gold_price\n #puts silver_price\n [::Forecasting::Quote::from_symbol_and_price(\"GOLD\",gold_price),::Forecasting::Quote::from_symbol_and_price(\"SILVER\",silver_price)]\n end", "def initialize(submitted_stock)\n @stock_ticker = submitted_stock\n \tend", "def show\n @quote_list = QuoteList.find(params[:quote_list_id])\n @quote = @quote_list.quotes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quote }\n end\n end", "def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end", "def quote\n endpoint = 'https://www.alphavantage.co/'\n query = \"query?function=GLOBAL_QUOTE&symbol=#{@current_symbol}&apikey=#{@api}\"\n\n resp = JSON.parse(URI.open(\"#{endpoint}#{query}\").read)['Global Quote']\n\n if resp.nil?\n @value = Stock::NO_VALUE\n @movement = Stock::NO_CHANGE\n else\n @value = resp['05. price'].to_i\n change = resp['09. change'].to_i\n\n @movement = if change.positive?\n Stock::POS_CHANGE\n elsif change.negative?\n Stock::NEG_CHANGE\n elsif change.zero?\n Stock::NO_CHANGE\n else\n Stock::NO_CHANGE\n end\n end\n\n old_value = @cache[@current_symbol]\n @cache[@current_symbol] = \"#{@current_symbol} $#{@value} #{@movement}\"\n\n return unless @cache[@current_symbol] != old_value\n\n # TODO: DRY this up, make sure it isn't being called too much (see init_cache)\n # TODO: simple file operations like this are a good candidate for optimization/moving\n File.open(Stock::CACHE_FILENAME, 'w') do |file|\n file.write(@cache.to_json)\n end\n\n @cache[@current_symbol]\n end", "def handle_list( m, params )\n if @stock.length == 0\n m.reply( \"Nothing available.\" ); return\n end\n\n m.reply \"Finite goods: #{@stock.keys.sort.join(', ')}\"\n end", "def build(params, mandatory_services, quote)\n quotation = ::Quotation.new(\n property_id: params[:property_id],\n check_in: params[:check_in].to_s,\n check_out: params[:check_out].to_s,\n guests: params[:guests],\n available: available?(quote),\n )\n if quotation.available\n return unexpected_quote_error unless quote.value['value']\n\n quotation.currency = CURRENCY\n quotation.total = calc_total(mandatory_services, quote)\n end\n Result.new(quotation)\n end", "def get_stocks\n @stocks = Stock.where(user_id: session[:current_user_id]).order(\"ticker_symbol ASC\")\n end", "def set_oldQuote \n\tif $counter == 0\n\t\t$oldQuote[0] = $quote\n\telsif $counter < 11 #If 11 quotes haven't been stored yet, just adds one to the start\n\t\t$oldQuote.unshift($quote)\n\telsif #If 11 quotes have been stored, deletes the oldest one and adds one to the start\n\t\tputs \"#{$oldQuote[10]} will be deleted from the list of Old Quotes\"\n\t\t$oldQuote.delete_at(10)\n\t\t$oldQuote.unshift($quote)\t\n\tend\nend", "def grats\n quants = [ 46043, 17140, 11105, 11956, 20928, ] \n\t # [ 80431, 31000, 18133, 20000, 28778 ]\n symbols = ['csco','crm','msft','intc','amat']\n costs = [ 1076070.00, 1108836.00, 406866.00, 283692.00, 233090.00 ]\n\t # [ 2104879.27, 2168140.00, 796038.70, 554400.00, 458721.32]\n @cash = 235782 # 155000\n @latest = [ ]\n prices = Options.stock_price(symbols)\n @total = 0\n prices.each do |s|\n symbol = s['Symbol']\n index = symbols.index(symbol)\n value = quants[index] * s['LastTrade'].to_d\n profit = (quants[index] * s['LastTrade'].to_d) - costs[index]\n change = (quants[index] * s['Change'].to_d)\n @total += profit \n @latest.push [ symbol.upcase, quants[index], change, profit, s['LastTrade'] ]\n end\n end" ]
[ "0.72118294", "0.67459303", "0.6700682", "0.6614101", "0.64037806", "0.6401939", "0.6378696", "0.6295769", "0.62820554", "0.6278724", "0.62717307", "0.61913687", "0.61412877", "0.61094344", "0.60995346", "0.6049173", "0.6044426", "0.6010329", "0.5967269", "0.59656614", "0.5948703", "0.5918508", "0.5911784", "0.59083545", "0.59057707", "0.59013885", "0.58962053", "0.589209", "0.5882078", "0.58813375", "0.5878", "0.5855977", "0.5826267", "0.5819668", "0.57944894", "0.57890236", "0.57861227", "0.57754123", "0.5774344", "0.57724583", "0.5769518", "0.5765086", "0.5759355", "0.57357097", "0.5727977", "0.5727977", "0.57259506", "0.57087463", "0.57087463", "0.57087463", "0.57087463", "0.57037896", "0.5689891", "0.5688849", "0.5656916", "0.5647629", "0.5644146", "0.5636986", "0.5620229", "0.5613668", "0.5613472", "0.56072557", "0.56048536", "0.5604403", "0.5586328", "0.55683327", "0.55370307", "0.5520786", "0.5520469", "0.55191267", "0.5509546", "0.55060005", "0.5505568", "0.5496856", "0.54960036", "0.54931986", "0.5490737", "0.54903716", "0.54773974", "0.5476172", "0.54535246", "0.5452056", "0.54464585", "0.54444206", "0.5436589", "0.5411385", "0.54080963", "0.540722", "0.53782386", "0.5377121", "0.5371539", "0.53653413", "0.53605056", "0.534805", "0.53442985", "0.5317915", "0.5305964", "0.5304881", "0.5299883", "0.5263285" ]
0.6761247
1
calculates profit for the given portfolio
def calculate_portfolio(portfolio = Array.new) qs = get_quote_info(get_quote_list(portfolio)) portfolio.each do |p| p['info'] = qs[p['stock']] value_orderd = p['amount']*p['price'] value_now = p['amount']*p['info'].lastTrade p['profit_amount'] = value_now - value_orderd end return portfolio end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profit\n revenue - total_costs\n end", "def profit\n profit = 0\n if self.is_open?\n if market_value != position_cost\n return (self.is_buy? ? 1 : -1) * (market_value - position_cost)\n else\n return 0\n end\n else\n self.open_trade_records.each do |open_trade_record|\n price_difference = self.traded_price - open_trade_record.open_trade.traded_price\n profit += (self.is_sell? ? 1 : -1) * price_difference * open_trade_record.close_volume * self.instrument_multiplier * self.instrument_currency_exchange_rate\n end\n end\n profit\n end", "def profit_calculation\r\n @total_profit = @cocktail_profit + @beer_profit + @water_profit\r\n end", "def get_usd_profit\n open_positions.sum(:amount) - close_positions.sum(:amount)\n end", "def calculate_profit(amount)\n @value * amount\n end", "def portfolio\n \n p = {}\n \n p[:cash_in] = self.cash_in\n p[:total_investment] = self.investment\n p[:total_profit] = self.profit\n p[:balance] = self.balance\n p[:total_stocks] = 0\n\n # copy cached ownership info into portfolio data structure\n p[:stocks] = {} \n Ownership.where(:user_id => self.id).each do |o|\n if o.amount.nil?\n o.amount = 0\n o.save\n end\n p[:stocks][o.stock_id] = {:amount => o.amount, :stock => o.stock, :investment => o.investment, :avg_price => o.avg_price, :profit => o.profit}\n p[:total_stocks] += o.amount\n end\n \n p[:total_value] = 0\n \n # calculate current value \n p[:stocks].each do |stock_id, data|\n # value: how much is the stock currently worth on the market\n data[:value] = data[:amount] * data[:stock].price\n p[:total_value] += data[:value] \n end\n\n # do some additional calculations\n p[:total_investment_rel] = ((self.investment / self.cash_in) * 100).round(2)\n p[:total_profit_rel] = StocksHelper.rel_percent p[:cash_in], p[:balance] \n p[:total_value_rel] = StocksHelper.rel_percent p[:total_investment], p[:total_value] \n\n return p\n\n end", "def get_usd_profit\n close_positions.sum(:amount) - open_positions.sum(:amount)\n end", "def profit\n total_before_tax - total_cost\n end", "def profit\n total_before_tax - total_cost\n end", "def estimate_fiat_profit\n open_positions.sum(:amount) - positions_balance_amount\n end", "def update_portfolio\n buys = self.buyer_transactions.where(\"transaction_type_id = 0\").select(\"stock_id, sum(amount) as total\").group(\"stock_id\")\n sells = self.seller_transactions.where(\"transaction_type_id = 0\").select(\"stock_id, sum(amount) as total\").group(\"stock_id\")\n \n self.cash_in = self.seller_transactions.where(\"transaction_type_id = 1\").sum('amount * price')\n self.investment = 0\n self.profit = 0\n self.balance = self.calculate_balance\n\n p = {}\n p[:stocks] = {}\n \n # go through transactions to get current portfolio \n buys.each do |buy|\n stock = Stock.find(buy.stock_id)\n # add stocks to portfolio according to buys\n p[:stocks][buy.stock_id] = {:amount => buy.total, :stock => stock}\n sells.each do |sell|\n if buy.stock_id == sell.stock_id\n # subtract stocks from portfolio according to sells\n p[:stocks][buy.stock_id][:amount] = buy.total - sell.total\n end\n end\n end\n \n p[:stocks].each do |stock_id, data|\n\n # save portfolio in ownerships\n ownership = Ownership.where(:user_id => self.id, :stock_id => stock_id).first_or_create\n ownership.amount = data[:amount]\n\n # investment: how much did the user pay for the stocks he bought last?\n buys = self.buyer_transactions.where(:stock_id => stock_id).order('created_at DESC') \n counter = data[:amount]\n investment = 0\n buys.each do |buy|\n if counter - buy.amount > 0\n investment += buy.price * buy.amount\n else\n investment += buy.price * counter\n break\n end\n counter -= buy.amount\n end\n ownership.investment = investment\n self.investment += investment\n\n # avg_price: how much did the user pay for the stocks he bought last on avg\n ownership.avg_price = (ownership.investment / ownership.amount).round(2)\n\n # profit: how much money did the user make trading this stock\n gains = self.seller_transactions.where(:stock_id => stock_id).sum('amount * price')\n losses = self.buyer_transactions.where(:stock_id => stock_id).sum('amount * price') \n ownership.profit = gains - losses \n self.profit += ownership.profit\n\n ownership.save\n \n end\n \n self.save\n \n end", "def estimate_fiat_profit\n positions_balance_amount - open_positions.sum(:amount)\n end", "def profit()\n profit = margin() * @quantity\n return profit\n end", "def get_btc_profit\n quantity - close_positions.sum(:quantity)\n end", "def add_profit(amount)\n amount * 1.005\n end", "def profit ()\n # set profit margin\n profit = (@selling_price - @cost_price)\n return profit.round(2)\n end", "def profit\n return 0.0 unless self.deliverables.size > 0\n \n # Covers fixed and percentage profit though the +profit+ method being overloaded on the Deliverable types\n return self.deliverables.collect(&:profit).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0\n end", "def get_portfolio\n return self.total_value_in_stocks + self.balance\n end", "def estimate_crypto_profit\n quantity - close_positions.sum(:quantity)\n end", "def profit(start_date, end_date)\n price(end_date) - price(start_date)\n end", "def get_btc_profit\n close_positions.sum(:quantity) - quantity\n end", "def calculate_profit(amount)\n if @value.positive?\n (amount/100.rationalize) * @value\n else\n -100/@value.rationalize * amount\n end\n end", "def estimate_crypto_profit\n close_positions.sum(:quantity) - quantity\n end", "def max_profit(prices)\n calculate(prices, 0)\nend", "def profit\n (self.price - self.product.cost) * self.quantity\n end", "def max_profit(prices)\n buy = nil\n profit = 0\n \n prices.each do |p|\n if buy.nil?\n buy = p\n elsif p < buy\n buy = p\n else\n profit = p - buy if p - buy > profit\n end\n end\n profit\nend", "def portfolio_cash_delta\n absolute_delta = quantity * price\n (trade_order.is_buy?) ? -absolute_delta : absolute_delta\n end", "def portfolio_value(fake_yahoo_api)\n # Go through our positions and add them up, then add in the cash balance\n @positions.map { |key, value| fake_yahoo_api.get_latest_price(key) * @positions[key] || 0 }\n .reduce(:+) || 0\n + account_balance\n end", "def profit(retailer)\n begin\n (self.line_items.collect {|line_item| line_item.profit(retailer) }).sum\n rescue\n 0\n end\n end", "def needed_amount_less_savings\n recommended_min_portfolio - portfolio_after_growth\n end", "def profit\n \tself.bid - self.payout\n end", "def profit_cal(items)\r\n profit = 0\r\n items.item.each do |h|\r\n profit += h[:num]*(h[:price] - h[:cost])\r\n end\r\n #profit = '%.2f' % profit\r\n puts \"The total profit is $#{'%.2f' % profit}\"\r\n return nil\r\nend", "def annualized_portfolio_amount_needed\n savings_portion_needed * 12.0\n end", "def usd_profit\n break_even(:usd).abs\n end", "def max_profit(prices)\n min_price = prices[0]\n best_profit = 0\n \n prices.each do |price|\n if price < min_price\n min_price = price\n else\n profit = price - min_price\n if profit > best_profit\n best_profit = profit\n end\n end\n end\n \n return best_profit\nend", "def investment\n if buy_price\n num_of_shares * buy_price\n end\n end", "def stock_profit(stocks)\n minimum = stocks[0]\n profit = stocks[1] - stocks[0]\n\n (1...stocks.size).each do |price|\n current_price = stocks[price]\n current_profit = current_price - minimum\n\n minimum = [minimum, current_price].min\n\n profit = [profit, current_profit].max\n end\n\n profit\nend", "def single_profit(prices)\n profit = 0\n i = 0\n while i < prices.length do\n remainder = prices.slice(i+1, prices.length-1)\n if remainder.length > 0\n value = remainder.max - prices[i]\n if value > profit\n profit = value\n end\n end\n i+=1\n end\n profit\n \nend", "def sum_produits_stock\n sum = 0\n self.protofactures.each { |p| sum += p.prix_unit * p.stock }\n sum\n end", "def btc_profit\n break_even.abs\n end", "def sell_stock(portfolio_name, ticker, number_of_shares_to_sell)\n total_value = number_of_shares_to_sell * ticker.price\n ###calls has_portfolio function\n if has_portfolio(portfolio_name)\n @portfolios.each do |item|\n if item.name == portfolio_name\n ###calls get_shares_of_stock function in portfolio class\n ###updates balance\n if item.get_shares_of_stock(ticker) >= number_of_shares_to_sell\n item.remove_stock(ticker, number_of_shares_to_sell)\n @balance += total_value\n else\n puts \"You do not have enough #{ticker.ticker.upcase} shares to sell #{number_of_shares_to_sell} shares.\"\n end\n end\n end\n else\n puts \"You currently do not have that portfolio. You need to create it first.\"\n end\n end", "def btc_profit_per_day\n return 0 if mining_rig.days_running <= 0\n (btc_profit / mining_rig.days_running).round(8)\n end", "def tot_deposits_made\n Rails.logger.debug(\"*** tot_deposits_made\")\n # note cannot use database sum because big_deposit is not native to database\n dep_result = 0.0\n EmployeeBenefit.where(\n \"employee_id = ? and eff_month = ? and eff_year = ? and deposited_at IS NOT NULL\",\n self.employee_id.to_s,\n self.eff_month.to_s,\n self.eff_year.to_s\n ).each do |eb|\n dep_result += round_money(eb.deposit)\n end\n Rails.logger.debug(\"*** dep_result: #{dep_result.inspect}\")\n return dep_result\n end", "def buy_stock(portfolio_name, ticker, number_of_shares_to_buy)\n current_price = YahooFinance::get_quotes(YahooFinance::StandardQuote, ticker.upcase)[ticker.upcase].lastTrade\n total_value = number_of_shares_to_buy * current_price\n if @balance >= total_value\n ###calls has_portfolio function\n if has_portfolio(portfolio_name)\n @portfolios.each do |item|\n ###calls add_stock function in portfolio class\n ###updates balance\n if item.name == portfolio_name\n item.add_stock(ticker, number_of_shares_to_buy)\n @balance -= total_value\n end\n end\n else\n puts \"You currently do not have that portfolio. You need to create it first.\"\n end\n else\n puts \"You do not have enough money ($#{@balance} vs $#{total_value}) to buy #{number_of_shares_to_buy} shares.\"\n end\n end", "def last_year_portfolio_performance\n last_year_performance_all_stocks = self.purchased_stocks.reduce([]) do |result, stock|\n result << stock.last_years_performance\n end\n sum_for_each_month(last_year_performance_all_stocks)\n end", "def recommended_min_portfolio\n annualized_portfolio_amount_needed / withdrawal_rate\n end", "def max_profit(prices)\n min_price = prices[0]\n max_pro = 0 \n price.each do |price|\n if price <= min_price\n min_price = price\n elsif price - min_price > max_pro\n max_pro = price - min_price\n end\n end\n max_pro\nend", "def computeBuySellToMaximizeProfit()\n currentStock = \"\"\n i = 0 # Loop counter\n while i < @days.size do # Traverse the data for each date to find price differences\n if i == @days.size - 1 # For the final week\n puts \"#{@days[i]} SELL #{currentStock}\"\n break\n end\n weeklyDifferences = [] # Stores the price differences between closing prices for all stocks in a particular week\n @data.each_with_index do |(key, value), index| # Traverse the data corresponding to current date for each key (stock)\n stockDifferences = {} # Stores the price difference between closing prices for a stock in a particular week\n stockDifferences[:stock] = key\n stockDifferences[:difference] = (value[i+1][:close].to_f - value[i][:close].to_f).round(5) # value[i+1] represents the next date for the stock data\n weeklyDifferences << stockDifferences\n end\n mostProfitableStock = getMostProfitableStock(weeklyDifferences)\n if i == 0 # For week 1\n puts \"#{@days[i]} BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock\n elsif mostProfitableStock == currentStock # If the stock already bought is more profitable\n puts \"#{@days[i]} HOLD #{mostProfitableStock}\"\n else\n puts \"#{@days[i]} SELL #{currentStock}, BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock \n end\n i = i + 1\n end\n end", "def profit(retailer)\n product_costs = variant.product_costs.where(:retailer_id => retailer.id)\n product_costs.empty? ? 0 : (price - product_costs.first.cost_price) * quantity\n\n end", "def get_max_profit_v3(yesterday_stock_prices)\n\n min_price = yesterday_stock_prices[0]\n max_profit = 0\n\n # go through every price on the list\n yesterday_stock_prices.each do |current_price|\n\n # ensure min price is lowest price we've seen so far\n min_price = [min_price, current_price].min\n\n # see what our profit woudl be if we bought at the\n # min price and sold at the current price\n potential_profit = current_price - min_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n\n end\n\n max_profit\n\n end", "def print_portfolio(portfolio = Array.new)\n\ttemplate=<<EOT\nSTOCK:\\tLASTTRADE €\n\\tAMOUNT @ PRICE € -> PROFIT €\nEOT\n\tmoney = portfolio.reduce(0) do |memo, p|\n\t\tt = template.dup\n\t\tt.sub!('STOCK', p['stock'])\n\t\tt.sub!('LASTTRADE', \"#{p['info'].lastTrade}\")\n\t\tt.sub!('AMOUNT', p['amount'].to_s)\n\t\tt.sub!('PRICE', p['price'].to_s)\n\t\tt.sub!('PROFIT', p['profit_amount'].to_s)\n\t\tputs t\n\t\tmemo += p['profit_amount']\n\tend\n\tputs \"-> #{money} €\"\nend", "def max_profit(stock_prices)\n\tmin_buying_point = stock_prices[0]\n\tmax_profit = 0;\n\n\tstock_prices.each do |price|\n\t\tmin_buying_point = [min_buying_point, price].min()\n\n\t\tcurrent_profit = price - min_buying_point \n\n\t\tmax_profit = [max_profit, current_profit].max()\n\tend\n\n\treturn max_profit\nend", "def invested(domain)\n get_total_funds = portfolio.map do |startup| \n if startup.domain == domain\n startup.total_funds\n end\n end\n final_fund = get_total_funds.compact\n final_fund.inject{|sum, el| sum + el}\n end", "def max_profit(prices)\n profit = 0\n 0.upto(prices.size - 2) do |current_pointer|\n next_pointer = current_pointer + 1\n diff = prices[next_pointer] - prices[current_pointer]\n profit += diff > 0 ? diff : 0\n end\n profit\nend", "def maximum_profit(prices)\n max_profit = 0\n (2..prices.length - 2).to_a.each do |idx|\n first_transaction = max_difference(prices.slice(0, idx))\n second_transaction = max_difference(prices.slice(idx, prices.length))\n profit = first_transaction + second_transaction\n max_profit = profit if profit > max_profit\n end\n max_profit\nend", "def fetch_growth(coins, coin_prices)\r\n\r\n if @debug then\r\n puts 'fetching growth ...'\r\n puts 'coin_prices: ' + coin_prices.inspect\r\n end\r\n \r\n coins.inject({}) do |r, coin| \r\n\r\n year_start_price = coin_prices[coin.name]\r\n \r\n if year_start_price then\r\n \r\n latest_day = coin.quote['USD']['price'].to_f\r\n puts \"latest_day: %s year_start: %s\" % \\\r\n [latest_day, year_start_price] if @debug\r\n r.merge({coin.name => (100.0 / (year_start_price / \r\n (latest_day - year_start_price))).round(2)})\r\n else\r\n r\r\n end\r\n \r\n end\r\n \r\n end", "def profitability\n # based on \n # @pools.map { |p| }.sum\n end", "def max_profit(prices)\n buy1 = Float::INFINITY\n buy2 = Float::INFINITY\n profit1 = 0\n prices.reduce(0) do |total_profit, price|\n buy1 = [buy1, price].min\n profit1 = [profit1, price - buy1].max\n buy2 = [buy2, price - profit1].min\n [total_profit, price - buy2].max\n end\nend", "def highest_possible_profit(prices)\n best_profit = 0\n # iterate over the dataset\n prices.each_with_index do |price, index|\n # in each hour compare with the future hours to find difference\n\n # check if difference is positive\n # check if difference is greater than current best\n # keep best difference\n # check next hour\n\n end\n # end return the best difference\n\nend", "def max_profit(prices)\n # Test for boundary conditions\n return 0 if prices.length <= 1\n profit = 0\n for i in 1..(prices.length-1) do\n if prices[i] > prices[i-1]\n profit = profit + (prices[i] - prices[i-1])\n end\n end\n return profit\nend", "def best_profit (stock_prices_yesterday)\n min_price = stock_prices_yesterday[0]\n max_profit = stock_prices_yesterday[1] - stock_prices_yesterday[0]\n\n stock_prices_yesterday.each do |stock_price|\n if stock_price <= min_price\n min_price = stock_price\n elsif (stock_price - min_price) > max_profit\n max_profit = stock_price - min_price\n end\n end\n max_profit\nend", "def max_profit(prices)\n max_profit = 0\n min_price = prices[0]\n \n prices.each do |price|\n min_price = [min_price, price].min\n max_profit = [max_profit, price - min_price].max\n end\n \n max_profit\nend", "def order_profit(items)\r\n order_profit = 0\r\n for item in items\r\n order_profit += item.profit\r\n end\r\n puts \"Order Profit: $#{'%.2f' % order_profit}\"\r\n end", "def max_profit(prices)\n total = 0\n (0...prices.size - 1).each do |i|\n total += prices[i + 1] - prices[i] if prices[i + 1] > prices[i]\n end\n total\nend", "def max_profit(prices)\n sum = max = 0\n (0...prices.size - 1).each do |i|\n sum = [0, sum += prices[i + 1] - prices[i]].max\n max = [max, sum].max\n end\n max\nend", "def best_profit (stock_prices_yesterday)\n possible_sale_combinations = stock_prices_yesterday.combination(2).to_a\n profits = []\n possible_sale_combinations.each do |pair|\n buy_price = pair[0]\n sell_price = pair[1]\n profit = sell_price - buy_price\n profits << profit\n end\n profits.sort!\n profits.count\n max_profit = profits[-1]\n if max_profit < 0\n return 0\n else\n return max_profit\n end\nend", "def usd_profit_per_day\n return 0 if mining_rig.days_running <= 0\n (usd_profit / mining_rig.days_running).round(2)\n end", "def max_profit(prices)\n return 0 if prices.empty?\n total_profit = 0\n idx = 1\n while idx < prices.length\n total_profit += (prices[idx] - prices[idx - 1]) if prices[idx] > prices[idx - 1]\n idx += 1\n end\n \n total_profit\nend", "def profit_per_mwh_electricity\n production_mwh = production(:mwh)\n return nil if production_mwh.zero?\n\n profit / production_mwh\n end", "def get_max_profit_v2(yesterday_stock_prices)\n\n max_profit = 0\n\n # go through every price (with its index as the time)\n yesterday_stock_prices.each_with_index do |earlier_price, earlier_time|\n\n # and go through all Later Prices\n (yesterday_stock_prices[+1..-1]).each do |later_price|\n\n # see what our profit will be if we bought at the\n # earlier price and sold at the later price\n potential_profit = later_price - earlier_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n\n end\n\n end\n\n max_profit\n end", "def get_value\n portfolio_value = 0\n @stocks.each do |stock|\n portfolio_value += stock.get_value\n end\n portfolio_value\n end", "def max_profit(prices)\n sell_one, sell_two = 0, 0\n buy_one, buy_two = Float::INFINITY, Float::INFINITY\n \n prices.each do |price|\n buy_one = [buy_one, price].min\n sell_one = [sell_one, price - buy_one].max\n buy_two = [buy_two, price - sell_one].min\n sell_two = [sell_two, price - buy_two].max\n end\n sell_two\nend", "def percentage_change\n return_sum / @money * 100\n end", "def profit_percent(current_price)\n price = self.price.present? ? self.price : 0.0\n (self.gain_price(current_price)*100/current_price).round(2)\n end", "def calc_sum_of_exp(expenses)\n prices = []\n expenses.each do |num|\n prices << num['price'].to_f\n end\n return prices.inject(0, :+)\nend", "def get_max_profit_3(array)\n\n min_price = array[0] #sets the minimum price starting at index 0\n max_price = 0\n\n max_profit = 0 #sets current max_profit to 0\n min_loss = 0\n\n\n array.each do |current_price| #simple iteration\n\n # ensure min_price is the lowest price we've seen so far\n min_price = [min_price, current_price].min\n max_price = [min_price, current_price].max\n\n # see what our profit would be if we bought at the\n # min price and sold at the current price\n potential_profit = current_price - min_price\n potential_loss = current_price - max_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n min_loss = [min_loss, potential_loss].min\n\n print \"current-price: #{current_price}\\n\"\n print \"min_price: #{min_price}\\n\"\n print \"max_price: #{max_price}\\n\"\n print \"-----------------------------\\n\"\n print \"potential_profit: #{potential_profit}\\n\"\n print \"potential_loss: #{potential_loss}\\n\"\n print \"-----------------------------\\n\"\n print \"max_profit: #{max_profit}\\n\"\n print \"min_loss: #{min_loss}\\n\"\n print \"\\n\"\n end\n\n return max_profit\nend", "def get_max_profit(prices)\n raise IndexError(\"Must be at least 2 prices\") if prices.length < 2\n #initialize a current_max_profit and current_min\n current_min = prices[0]\n current_max_profit = prices[1] - prices[0]\n\n prices.each do |price|\n #calculate the potential profit and check if it's larger than current max profit\n potential_profit = price - current_min\n current_max_profit = [potential_profit, current_max_profit].max\n #update current_min\n current_min = [current_min, price].min\n end\n current_max_profit\nend", "def on2(prices)\n max_profit = 0\n\n prices.each_with_index do |number, index|\n prices.each_with_index do |another_number, another_index|\n next if index >= another_index\n\n max_profit = [another_number - number, max_profit].max\n end\n end\n\n max_profit\n end", "def max_profit(prices)\n max_profit = 0\n min_price = 1_000_000\n\n 0.upto(prices.length - 1) do |i|\n if prices[i] < min_price\n min_price = prices[i]\n elsif prices[i] - min_price > max_profit\n max_profit = prices[i] - min_price\n end\n end\n\n max_profit\nend", "def get_max_profit(stock_prices_yesterday)\n # check for at least 2 prices\n if stock_prices_yesterday.length < 2\n raise IndexError, 'Need at least 2 prices to test.'\n end\n # initialize first price and the first possible profit\n min_price = stock_prices_yesterday[0]\n max_profit = stock_prices_yesterday[1] - stock_prices_yesterday[0]\n\n stock_prices_yesterday.each_with_index do |current_price, index|\n if index == 0 then next end\n # see what our profit would be if we bought at the\n # min price and sold at the current price\n potential_profit = current_price - min_price\n # update max_profit\n max_profit = [max_profit, potential_profit].max\n # update min_price\n min_price = [min_price, current_price].min\n end\n return max_profit\nend", "def profit(cal)\n day_rate = avg_rate_card_amount_cents.round(2)\n mins_tracked = Timing.minute_duration_submitted_for_period_and_client(id, cal.start_date, cal.end_date)\n invoiced_amount = Invoice.amount_cents_invoiced_for_period_and_client(id, cal.start_date, cal.end_date).round(2)\n days_tracked = (hours = mins_tracked.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n (invoiced_amount - (days_tracked * day_rate.to_s.to_d)).round(2)\n end", "def amount_spent_on(project)\n self.expenses.where(:project_id => project.id).sum(:amount)\n end", "def solve_for_bond_price(*cash_flows)\n n = cash_flows.size - 1\n first = cash_flows[0].round(3)\n coupon = cash_flows[1]\n fv = cash_flows.last - coupon\n guess = coupon / fv\n price = bond_price(coupon, guess, n, fv)\n until ( price + first ).abs < 0.001 do\n diff = (price + first).abs\n per = (diff / first.abs) * 0.1\n if ( price + first ) > 0\n guess = guess + per\n else\n guess = guess - per\n end\n price = bond_price(coupon, guess, n, fv)\n end\n guess\n end", "def float(company)\n par_price = initial_offering.get_par_price(company)\n bank.give company, par_price * 10\n market.add_company company, par_price\n end", "def report\n @portfolios = Portfolio.where(user_id: session[:user_id]).decorate\n Portfolio.transaction do\n Portfolio.refresh_costs(@portfolios, current_user)\n @portfolios.map(&:reload)\n end\n @portfolios.sort!{ |a,b| b.difference.to_i.abs <=> a.difference.to_i.abs }\n end", "def max_profit(prices)\n\treturn 0 if prices.nil? || prices.length < 2\n\t\n\tmin_price = prices[0]\n\tmax_profit = 0\n\t\n\tfor i in 1..prices.length - 1\n\t\tmax_profit = [prices[i] - min_price , max_profit].max\n\t\tmin_price = [prices[i], min_price].min\n\tend\n\treturn max_profit\nend", "def estimated_profit\n day_rate = avg_rate_card_amount_cents.round(2)\n mins_tracked = Timing.minute_duration_submitted_for_client(id)\n days_tracked = (mins_tracked.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n task_estimate_mins = Task.total_estimated_minutes_for_client(id)\n task_estimate_days = (task_estimate_mins.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n ((task_estimate_days * day_rate.to_s.to_d) - (days_tracked * day_rate.to_s.to_d)).round(2)\n end", "def nonprofit\n end", "def gross_profit_statement(profit)\r\n return \"The total profit you will make from your current order queue is $%.2f\" % profit\r\n end", "def get_max_profit(stocks)\n profit = 0\n transaction = Array.new(2)\n stocks.each_with_index do |buy, i|\n stocks[i+1..-1].each do |sell|\n potential_profit = sell - buy\n if potential_profit > profit\n profit = potential_profit \n transaction[0] = buy\n transaction[1] = sell\n end\n end\n end\n p \"Buy: #{transaction[0]}, Sell: #{transaction[1]} for Profit: #{profit}\"\nend", "def bestonetradeprofit(prices)\n # find highest difference between price and subsequent price\n # starting best is second - first\n max = prices[1] - prices[0]\n while prices.length > 1\n e = prices.shift\n prices.each {|v| \n if (v - e) > max \n max=(v-e)\n end\n }\n end\n return max\nend", "def income_estimation(*tags)\n\t #debugger\n\t softotal = 0\n @sourceoffunds.each do |sof|\n if (tags.flatten.count == 0)\n softotal += sof.dollars.to_i * (sof.likelyhood.to_f / 100)\n else\n tags.flatten.each do |tag|\n if (tags.count > 0 && self.findsoftag(sof.name, tag)) \n softotal += sof.dollars.to_i * (sof.likelyhood.to_f / 100)\n break # if the tag is included, count in the sum (once)\n end\n end\n end\n end\n softotal\n end", "def max_stock_profit(stock_prices)\n\tlocal_min = stock_prices[0]\n\tlocal_max = stock_prices[1]\n\tmax_profit_so_far = local_max - local_min\n\n\tstock_prices[2..-1].each do |price|\n\n\t\tif local_max == nil || price > local_max\n\t\t\tlocal_max = price\n\t\t\tprofit = local_max - local_min\n\t\t\tmax_profit_so_far = profit if profit > max_profit_so_far\n\n\t\t# must 'reset' the max when the min is reset\n\t\t# I set the max to nil because you can't buy and sell\n\t\t# at the same time\n\t\telsif price < local_min\n\t\t\tlocal_min = price\n\t\t\tlocal_max = nil \n\t\tend \n\t\t# log(local_min, local_max, max_profit_so_far)\n\tend\n\t\treturn max_profit_so_far\nend", "def depositProfit(deposit, rate, threshold)\n count = 0\n profit = deposit\n \n while profit < threshold do\n count += 1\n profit += ((profit*rate)/100).to_f\n end\n \n if rate == 1\n threshold - deposit\n else\n count\n end\nend", "def stock_picker(prices)\n acc_profit = 0\n acc_buy_date = 0\n acc_sell_date = 0\n \n profits = prices.map.with_index do |price, index|\n remaining_days = prices[index..-1] # to create an array that becomes smaller each iteration from index 0\n maximum = remaining_days.max # to identify the maximum number in that iteration's array\n highest_value = maximum - price # price is at index 0, so maximum minus minimum for each one will help identify the best buy/sell dates\n \n # create accumilator for index and value of highest profit\n if highest_value > acc_profit\n acc_profit = highest_value\n acc_buy_date = prices.index(price)\n acc_sell_date = prices.index(maximum)\n end\n\n end\n \n p \"Buy on day #{acc_buy_date} and sell on day #{acc_sell_date} for a profit of $#{acc_profit}.\"\n end", "def eth_portfolio\n return @@client.accounts[1].balance.amount.to_f\n end", "def max_profit(stocks)\n max = 0\n buy = stocks[0]\n\n stocks.each_with_index do |sell, index|\n # ignore the first index just because already set it above\n next if index == 0\n\n current_profit = sell - buy\n\n # if the current profit is less than 0, there is no way the\n # prices could possibly be used to generate the max profit\n # therefore start making new comparisons from this point\n # forward\n if current_profit < 0\n buy = sell\n end\n\n # evaluate the max everytime\n max = [max, current_profit].max\n end\n\n if max == 0\n return -1\n end\n\n return max\nend", "def paid_sum\n paid = Money.new(0, 'USD')\n paid += @paid_splits.inject(Money.new(0, 'USD')){ |memo, split| memo + split.sum } if @paid_splits.present?\n paid\n end", "def eth_value\n return eth_portfolio * eth_price\n end", "def calculator(list)\r\n profit = total_price(list) - total_cost(list) \r\n return profit\r\nend" ]
[ "0.7213182", "0.7061496", "0.701109", "0.6988421", "0.6951452", "0.69466364", "0.69259554", "0.6866281", "0.6866281", "0.6836347", "0.68163925", "0.6774613", "0.6749828", "0.6741579", "0.6726193", "0.67137694", "0.670878", "0.67030215", "0.667781", "0.6673643", "0.66636664", "0.6658753", "0.6568544", "0.6560474", "0.6550958", "0.64660364", "0.6465996", "0.6446325", "0.64362186", "0.6434822", "0.64225143", "0.6410101", "0.6387728", "0.63638747", "0.62852377", "0.6265213", "0.62406206", "0.62405026", "0.62345266", "0.6226775", "0.62008387", "0.6197176", "0.6193208", "0.6171319", "0.6132127", "0.6123676", "0.6101697", "0.60938823", "0.60762835", "0.6048978", "0.6043365", "0.60168064", "0.60006315", "0.5998928", "0.5993285", "0.59886354", "0.5985183", "0.5983726", "0.59788257", "0.59590805", "0.5949876", "0.59450305", "0.594018", "0.5936826", "0.5921471", "0.591724", "0.58995587", "0.58844745", "0.5882764", "0.5882597", "0.5881304", "0.5877936", "0.5861606", "0.5857107", "0.5856076", "0.5838985", "0.58309", "0.58256066", "0.5820915", "0.58181703", "0.580601", "0.5797582", "0.5789747", "0.5789642", "0.57880986", "0.5758377", "0.5743978", "0.5743012", "0.57421464", "0.5735395", "0.57326037", "0.57231504", "0.57186735", "0.5709404", "0.57085335", "0.5707802", "0.56825095", "0.5680669", "0.5678172", "0.56748796" ]
0.731144
0
printing the actual portfolio
def print_portfolio(portfolio = Array.new) template=<<EOT STOCK:\tLASTTRADE € \tAMOUNT @ PRICE € -> PROFIT € EOT money = portfolio.reduce(0) do |memo, p| t = template.dup t.sub!('STOCK', p['stock']) t.sub!('LASTTRADE', "#{p['info'].lastTrade}") t.sub!('AMOUNT', p['amount'].to_s) t.sub!('PRICE', p['price'].to_s) t.sub!('PROFIT', p['profit_amount'].to_s) puts t memo += p['profit_amount'] end puts "-> #{money} €" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def portfolios_listing\n portfolios.each_index do |index|\n puts \"Portfolio (#{index}) : #{portfolios.to_s}\"\n end\n end", "def report\n @portfolios = Portfolio.where(user_id: session[:user_id]).decorate\n Portfolio.transaction do\n Portfolio.refresh_costs(@portfolios, current_user)\n @portfolios.map(&:reload)\n end\n @portfolios.sort!{ |a,b| b.difference.to_i.abs <=> a.difference.to_i.abs }\n end", "def display\n puts \"Title: #{@title}\"\n puts \"Author: #{@author}\"\n puts \"Price: #{@price}\"\n end", "def show\n @portfolio = Portfolio.new\n end", "def portfolio\n nil\n end", "def print_investment\n puts \"\"\n puts \"Your Investment on #{@name} (#{@short_code})\"\n puts \"-------------------------------\"\n \n puts \"Total number of shares: #{total_number_of_shares}\"\n puts \"Value: #{total_value_of_shares.round(2)}\"\n puts \"Return: $#{return_sum.round(2)} / #{increment_status} #{percentage_change.round(2)}% \"\n puts \"\"\n\n puts \"Your Transactions\"\n puts \"-------------------------------\"\n\n @transactions.each do |t|\n t.print_transaction\n puts \"\"\n end\n\n puts \"\"\n end", "def show\n \n @portfolio = find_instance\n totVal = @portfolio.updateVals #important\n \n @portfolio.update_attribute(:value, totVal)# = totVal\n #@portfolio.save\n \n #rh = @portfolio.getRelWeights #returns rel weight\n \n #@charturl = generatePieChart(rh)\n #logger.info @charturl\n \n hobo_show\n \n end", "def index\n @port_items = Portfolio.by_position\n @page_title = \"Portfolio Projects\"\n end", "def display_port\n @port.each do |x|\n puts \"Company: #{x.name}\"\n puts \"Shares: #{x.shares}\"\n puts \"Price: #{x.price}#{x.currency}\"\n puts \"To USD: $#{sprintf('%.2f', x.con)}\"\n puts \"Total: #{x.total}#{x.currency}\"\n puts\n end\n end", "def display_planet_details\n puts \"Name: #{@name}, Primary Export: #{@primary_export}, Year-Length: #{@year_length}\"\n end", "def print_sales_rpt\n\treturn \"\n ____ _ ____ _ \n / ___| __ _| | ___ ___ | _ \\\\ ___ _ __ ___ _ __| |_ \n \\\\___ \\\\ / _` | |/ _ / __| | |_) / _ | '_ \\\\ / _ \\\\| '__| __|\n ___) | (_| | | __\\\\__ \\\\ | _ | __| |_) | (_) | | | |_ \n |____/ \\\\__,_|_|\\\\___|___/ |_| \\\\_\\\\___| .__/ \\\\___/|_| \\\\__|\n |_| \n===============================================================\\n\"\nend", "def to_print\n\t\tunless @stock_till_interval == nil \n\t\t\tprint \"The #{@adjective} performing stock for interval #{@date.quote_date} is #{@stock_till_interval.company_name} #{@verb} is #{@number_till_interval}\\n\"\n\t\t\tunless @stock == nil\n\t\t\t\tprint \"The stock permormance #{@date.quote_date} is #{@stock.company_name} #{@verb} is #{@number}\\n\\n\"\n\t\t\tend\n\t\telse\n\t\t \tprint \"NA\\n\"\n\t\tend\n\tend", "def index\n @portfolios = Portfolio.all\n end", "def index\n @portfolios = Portfolio.all\n end", "def print_products_report(toy_name,full_price,product_purchase_cnt,sales_sum,avg_price,avg_discount)\n $report_file.puts toy_name\n $report_file.puts \"*********************************\"\n $report_file.puts \"Retail price : #{full_price}\"\n $report_file.puts \"Product purchases: #{product_purchase_cnt}\"\n $report_file.puts \"Product Sales : #{sales_sum}\"\n $report_file.puts \"Average price : #{avg_price.round(2)}\"\n $report_file.puts \"Average Discount : $#{avg_discount.round(2)} \\n\\n\" \nend", "def display_each\n puts \" * #{self.experience} experience at #{self.company_name}\"\n end", "def print_planets\n puts \"\\n#{@name} has #{@planets.length} planets and was formed #{@formation_year} years ago.\"\n puts \"\\nHere are the planets in the #{@name} solar system:\\n\\n\"\n @planets.each do |planet|\n puts \"#{planet.print_planet_data}\"\n end\n puts \"\\n\"\n end", "def index\n @projectportfolios = Projectportfolio.all\n end", "def portfolio\n funding_rounds.map{|fr| fr.startup}.uniq\n #binding.pry\n end", "def overall_total\n puts \"Portfolio Total: $#{sprintf('%.2f', @all_totals)}\"\n end", "def show\n # find_portfolio method gets called here\n end", "def show\n @portfolio = Portfolio.find(params[:id])\n end", "def portfolio\n \n p = {}\n \n p[:cash_in] = self.cash_in\n p[:total_investment] = self.investment\n p[:total_profit] = self.profit\n p[:balance] = self.balance\n p[:total_stocks] = 0\n\n # copy cached ownership info into portfolio data structure\n p[:stocks] = {} \n Ownership.where(:user_id => self.id).each do |o|\n if o.amount.nil?\n o.amount = 0\n o.save\n end\n p[:stocks][o.stock_id] = {:amount => o.amount, :stock => o.stock, :investment => o.investment, :avg_price => o.avg_price, :profit => o.profit}\n p[:total_stocks] += o.amount\n end\n \n p[:total_value] = 0\n \n # calculate current value \n p[:stocks].each do |stock_id, data|\n # value: how much is the stock currently worth on the market\n data[:value] = data[:amount] * data[:stock].price\n p[:total_value] += data[:value] \n end\n\n # do some additional calculations\n p[:total_investment_rel] = ((self.investment / self.cash_in) * 100).round(2)\n p[:total_profit_rel] = StocksHelper.rel_percent p[:cash_in], p[:balance] \n p[:total_value_rel] = StocksHelper.rel_percent p[:total_investment], p[:total_value] \n\n return p\n\n end", "def index\n @dj_portfolios = DjPortfolio.all\n end", "def print_contents\n\t\tputs \"Artist: %s\" % [@artist]\n\t\tputs \"Album: %s\" % [@title]\n\t\tputs \"Released: %s\" % [@year]\n\n\t\tif @cd_count > 0\n\t\tputs \"CD(%d): %s\" % [@cd_count, @cd_id]\n\t\tend\n\n\t\tif @tape_count > 0\n\t\tputs \"Tape(%d): %s\" % [@tape_count, @tape_id]\n\t\tend\n\n\t\tif @vinyl_count > 0\n\t\tputs \"Vinyl(%d): %s\" % [@vinyl_count, @vinyl_id]\n\t\tend\n\n\tend", "def get_portfolio\n return self.total_value_in_stocks + self.balance\n end", "def display_object\n\tputs \"Name: #{name}\"\n\tpretty_price = format(\"%0.2f\", price)\n\tputs \"Price: $#{pretty_price}\"\n\tputs \"Size: #{size}\"\n end", "def index\n @portfolio_finances = PortfolioFinance.all\n end", "def print_year\n print_top_year\n print_body_rows\n end", "def show\n # @count = User.find(session[:id]).portfolios.count\n @portfolio = Portfolio.find(params[:id])\n @holdings = @portfolio.holdings\n\n end", "def show\n @portfolio = Portfolio.find_by(id: @rank_cart.portfolio_id)\n @sector = find_action(@portfolio)\n @rank_items = RankItem.where(\"rank_cart_id = #{@rank_cart.id}\")\n end", "def print_debug_info\n puts \"Project #{name}:\"\n puts \"\\tState: #{state}\"\n puts \"\\tMan-days total: #{man_days}\"\n puts \"\\tMan-days done: #{man_days_done}\"\n puts \"\\tPrice: #{price}\"\n end", "def index\n @positions = @portfolio.positions\n end", "def show\n @products = @portfolio.products.includes(:groups).order(\"products.name\", \"groups.name\").uniq.paginate(:page => params[:products_page], \n :per_page => session[:results_per_page])\n @total_allocation = @portfolio.get_total_allocation(@year, @allocation_precision)\n @groups = Group.includes(:product_group_portfolios => :product).where(:product_group_portfolios => {:portfolio_id => @portfolio.id}).order(\"groups.name\", \"products.name\").uniq\n end", "def print_output_head(index)\n puts \"\\nPrinting dataset for %.2f\" %\n (@meta_data.domain_z.lower + (index * @meta_data.domain_z.step))\n puts \"\\n\"\n end", "def print_sales_report_art\n $report_file.puts\"\\n********************************************************************************\" \n $report_file.puts\" ##### ###### \" \n $report_file.puts\" # # ## # ###### #### # # ###### ##### #### ##### ##### \"\n $report_file.puts\" # # # # # # # # # # # # # # # # \"\n $report_file.puts\" ##### # # # ##### #### ###### ##### # # # # # # # \"\n $report_file.puts\" # ###### # # # # # # ##### # # ##### # \"\n $report_file.puts\" # # # # # # # # # # # # # # # # # \"\n $report_file.puts\" ##### # # ###### ###### #### # # ###### # #### # # # \"\n $report_file.puts\"********************************************************************************\\n \" \nend", "def pnl(fake_yahoo_api)\n \"#{((portfolio_value(fake_yahoo_api) - @starting_balance) / @starting_balance * 100).round(2)}%\"\n end", "def print_expenses(expenses)\n puts \"Expenses: \"\n # Print all the expenses in chosen period\n expenses.each_with_index do |hash, index|\n puts Rainbow(\"#{index + 1}. On #{hash['date']} you spent $#{hash['price']}, Category: #{hash['category']}, Comment: #{hash['comment']}\").whitesmoke\n end\nend", "def index\n @portfolio_items = Portfolio.all\n end", "def show\n @portfolio = Portfolio.find(params[:id])\n\n \n # @stocks = YahooFinance.quotes([@portfolio.stocks.group_by(&:stock_symbol)], [:ask, :bid], { raw: false } )\n # additional resources :\n # https://github.com/herval/yahoo-finance\n # https://github.com/rlazoti/yahoofinance-example/blob/master/view_stocks.rb\n\n @stocks = YahooFinance.quotes(@portfolio.stocks.group_by(&:stock_symbol), [:ask, :bid, :symbol, :last_trade_price], { raw: false } )\n \n\n @stock = Stock.new\n @stock.portfolio_id = @portfolio.id\n end", "def index\n @portfolios = Portfolio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @portfolios }\n end\n end", "def print_debug_info\n puts \"Company #{name}, day #{days}:\"\n puts \"\\tState: #{state}\"\n puts \"\\tCurrent cash flow: #{budget}\"\n puts \"\\tDaily expenses: #{daily_expenses}\"\n puts \"\\tCapacity: #{capacity}\"\n puts \"\\tProgrammers: #{programmers.collect { |programmer| programmer.name + \" (\" + programmer.project_name + \")\" }.join(\", \")}\"\n puts \"\\tPROJECTS WAITING: #{projects_waiting.collect { |project| project.name }.join(\", \")}\"\n puts \"\\tPROJECTS CURRENT:\"\n projects_current.each { |project| project.print_debug_info }\n puts \"\\tPROJECTS DONE:\"\n projects_done.each { |project| project.print_debug_info }\n end", "def client_portfolios_list(client_name)\n @clients.each do |client|\n if client.name == client_name\n client_value = 0\n puts \"List of client portfolio for #{client.name}\"\n puts \"----------------------------------------------\"\n puts \"Account balance: #{client.balance}\"\n client.portfolios.each do |portfolio|\n portfolio_value = portfolio.get_value\n puts \"Portfolio: #{portfolio.name}, valued at $#{portfolio_value}\"\n client_value += portfolio_value\n end\n puts \"Total portfolio value: $#{client_value}\"\n end\n end\n end", "def index\n @portfolios = Portfolio.where(user_id: current_user.id)\n end", "def print_products\n$report_file.puts \"\n\n | | | |\n _ __ _ __ ___ __| |_ _ ___| |_ ___\n| '_ \\\\| '__/ _ \\\\ / _` | | | |/ __| __/ __|\n| |_) | | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\n| .__/|_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\n| |\n|_|\n\t \t\t\t\t\t\t\t\t\t\"\nend", "def show\n @portfolio_item = Portfolio.find(params[:id])\n end", "def print_report(products)\n \t\treport_string = \"\"\n \t\treport_string << \"Average Price: \" + average_price(products).to_s + \"$\\n\"\n\t\treport_string << \"Inventory by Brand:\\n\"\n\t\tbrands_hash = count_by_brand(products)\n\t\treport_string << print_hash(brands_hash)\n\t\treport_string << \"Inventory by Name:\\n\"\n\t\tnames_hash = count_by_name(products) \t\n\t\treport_string << print_hash(names_hash)\n\t\treport_string\n\tend", "def display_details()\r\n\t\tprintf(\"\\n**************************************************\")\r\n\t\tprintf(\"\\n***** MONTHLY PAY SLIP DETAILS *****\")\r\n\t\tprintf(\"\\n**************************************************\")\r\n\t\tprintf(\"\\nEmployee Name : %s\",@name)\r\n\t\t# Amounts are depicted with 2 decimal places.\r\n\t\tprintf(\"\\nGross Monthly Salary : $ %.2f\",@grossMonthlyIncome)\r\n\t\tprintf(\"\\nMonthly Tax : $ %.2f\",@monthlyIncomeTax)\r\n\t\tprintf(\"\\nNet Monthly Salary : $ %.2f\",@netMonthlyIncome)\r\n\t\tprintf(\"\\n**************************************************\")\r\n end", "def show\n @floors = [@bull_put_spread.floor1, @bull_put_spread.floor2, @bull_put_spread.strike]\n @floor_names = [\"Floor 1\", \"Floor 2\", \"Strike\"]\n @rut_price = 2257.46\n end", "def results\r\n print_books\r\n print_toys\r\n print_classes\r\n end", "def show\n @portfolio = Portfolio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @portfolio }\n end\n end", "def todays_rankings_output\n puts \"\"\n puts \"Nationwide AQI Rankings for #{self.todays_date.month}/#{self.todays_date.day}/#{self.todays_date.year}\"\n puts \"\"\n puts <<-DOC\n 1. #{self.first_city.location_name_full} - #{self.first_city.index} (#{self.first_city.message})\n 2. #{self.second_city.location_name_full} - #{self.second_city.index} (#{self.second_city.message})\n 3. #{self.third_city.location_name_full} - #{self.third_city.index} (#{self.third_city.message})\n 4. #{self.fourth_city.location_name_full} - #{self.fourth_city.index} (#{self.fourth_city.message})\n 5. #{self.fifth_city.location_name_full} - #{self.fifth_city.index} (#{self.fifth_city.message})\n DOC\n end", "def show\n @portfolio = Portfolio.find(params[:id])\n unless @portfolio.user.activate == 1 then\n \n @title = \"#{@portfolio.user.firstname.capitalize} #{@portfolio.user.lastname.capitalize}, #{@portfolio.city.capitalize}, #{@portfolio.country.capitalize}, #{@portfolio.specialization.capitalize}\"\n # @portfolio_previous_value = @portfolio\n # @portfolio_next_value = @portfolio.next\n else\n render :action => \"thankyou\", :id => @portfolio.id\n end\n end", "def show\n @grid = HoldingsGrid.new(holdings_grid_params) do |scope|\n scope.where(portfolio_id: @portfolio.id).page(params[:page])\n end\n @sector_counts = @portfolio.sector_list\n @industry_counts = @portfolio.industry_list\n end", "def print_sorted_prices\n sort_by_price_usd.each do |coin|\n unless coin.price_usd == 0\n table = terminal_table do |t|\n t.add_row [coin.name, \"$#{coin.price_usd}\"]\n t.style = { all_separators: true, width: 60 }\n end\n puts table\n end\n end\n end", "def index\n\t\t@portfolio_items = Portfolio::Item.all\n\tend", "def print_info\n puts \" Planet Summary\"\n puts \"=============================================================\"\n puts \"Planet Name: #{@name.capitalize}\"\n puts \"Mass: #{@mass} e+24 kg\"\n puts \"Diameter: #{@diameter} km\"\n puts \"Number of Moons: #{@number_of_moons}\"\n puts \"Average Distance From The Sun: #{@distance_from_the_sun} e+6 km\"\n puts \"Rate of Solar Rotation: #{@rate_of_solar_rotation} hours\"\n puts \"Orbital Period: #{@orbital_period} Earth days\\n\\n\"\n end", "def print\n @grid.each { |row| p row }\n end", "def print\n @grid.each { |row| p row }\n end", "def print\n @grid.each { |row| p row }\n end", "def print\n @grid.each { |row| p row }\n end", "def print\n @grid.each { |row| p row }\n end", "def print\n @grid.each { |row| p row }\n end", "def print_sales_report\n$report_file.puts \"\n ##### ######\n # # ## # ###### #### # # ###### ##### #### ##### #####\n # # # # # # # # # # # # # # # #\n ##### # # # ##### #### ###### ##### # # # # # # #\n # ###### # # # # # # ##### # # ##### #\n # # # # # # # # # # # # # # # # #\n ##### # # ###### ###### #### # # ###### # #### # # #\n********************************************************************************\n\"\nend", "def index\n @portfolio_items = PortfolioItem.all\n\n end", "def index\n @new_portfolio = Portfolio.new\n @portfolios = filter_portfolios(params[:search])\n @portfolios = sort_results(params, @portfolios) unless params[:order].blank?\n @portfolios = @portfolios.includes(:products, :products => :groups).order(\"portfolios.name, products.name, groups.name\").uniq\n @portfolios = @portfolios.paginate(:page => params[:page], \n :per_page => session[:results_per_page])\n end", "def print_menu\n MENU.each do |i| \n # in general, avoid printing things.\n # Return them instead and let the code that called it\n # to return it\n puts \"#{i[:name]} costs #{i[:price]}\"\n end\n end", "def show\n @sprint_sequence = @phase.sprints.to_a.index(@sprint) + 1\n add_breadcrumb \"Project: #{@project.name}\", project_path(@project)\n add_breadcrumb \"Phase #{@phase.sequence + 1}: #{@phase.name}\", project_phase_path(@project, @phase)\n add_breadcrumb \"Sprint #{@sprint_sequence}\"\n end", "def portfolio\n @portfolio = Portfolio.find(params[:id])\n end", "def print_item\n return \"Title: #{@title}; Description: #{@description}; Anniversary Date: #{@month}/#{@day}\"\n end", "def display_info\n \n puts \"\\nPlayer Name: #{self.name}\"\n puts \"Current Rank: #{self.rank}\"\n puts \"Position: #{self.position}\"\n puts \"School/Club: #{self.schoolclub}\"\n # binding.pry\n #if there is no class_year, nothing is displayed\n puts \"Year: #{self.class_year}\"\n #\n puts \"Height/Weight: #{self.height}, #{self.weight} \"\n puts \"Age: #{self.age}\"\n puts \"Last rank: #{self.last_rank}\"\n puts \"Scouting Report: #{self.blurb}\"\n puts \"------------------------------------\"\n end", "def wrt_brand_stk(stock, format = 6)\n $report_file.puts(\"Number of Products:\" + \"%#{format}s\" % stock.to_s)\nend", "def print_final_report\n puts; puts; puts \"=== FINAL DATABASE COUNTS ===\"\n puts; puts end_of_task_report\n puts; puts; puts \"=== BY SCHOOL ===\"\n puts by_school_report\n puts; AssessmentsReport.new.print_report\n end", "def client_portfolios_stocks_list(client_name, portfolio_name)\n @clients.each do |client|\n if client.name == client_name\n client.portfolio.each do |portfolio|\n if portfolio.name == portfolio_name\n puts \"List of stocks in portfolio: #{portfolio_name}\"\n puts \"----------------------------------------------\"\n portfolio.stocks.each do |stock|\n puts stock\n end\n end\n end\n end\n end\n end", "def print_results\n Report::print(@result_set)\n end", "def index\n @portfolio_items = Portfolio.by_position\n end", "def print_item\n return \"Title: #{@title}; Description: #{@description}; Is Done: #{@is_done}; Due Date: #{@due_date}\"\n end", "def print\n\t\t\tputs \"F: \" + toFahrenheit(@degrees, @scale).to_s + \" C: \" + toCelsius(@degrees, @scale).to_s + \" K: \" + toKelvin(@degrees, @scale).to_s\n\t\tend", "def print\r\n\t\t\tputs \"F: \" + toFahrenheit(@degrees, @scale).to_s + \" C: \" + toCelsius(@degrees, @scale).to_s + \" K: \" + toKelvin(@degrees, @scale).to_s\r\n\t\tend", "def portfolio()\n # uniq_funding = self.funding_rounds().uniq\n # uniq_funding.map {|funding| funding.startup}\n startups = self.funding_rounds().map { |funding| funding.startup}\n startups.uniq \n end", "def display_order_contents\n\t\t@orders.each {|item| print item, \" -- \"}\n\tend", "def details\n\n puts \"\"\n puts \"Todays crypto update:\"\n puts \"Volume is the amount of the coin that has been traded with in a certain time frame...fyi\"\n puts \"----------------------------------------------------------------------\"\n puts \"| Coin (Symbol) | Volume (1 day) | Volume (7 day) | Volume (30 day) |\"\n puts \"----------------------------------------------------------------------\"\n puts \"\"\n\n @coins = TheCryptoUpdate::Coin.all[0..99]\n\n @coins.find do |coin|\n puts \" #{coin.name} (#{coin.symbol}) | $#{coin.volume_1d} | $#{coin.volume_7d} | $#{coin.volume_30d} |\"\n end\n\n end", "def print_products_in_art\n $report_file.puts \" _ _ \"\n $report_file.puts \" | | | | \"\n $report_file.puts \" _ __ _ __ ___ __| |_ _ ___| |_ ___ \"\n $report_file.puts \"| '_ \\\\| '__/ _ \\\\ / _` | | | |/ __| __/ __|\"\n $report_file.puts \"| |_) | | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\"\n $report_file.puts \"| .__/|_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\"\n $report_file.puts \"| | \"\n $report_file.puts \"|_| \\n\\n\"\nend", "def show\n @portfolio = Portfolio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @portfolio }\n end\n end", "def wrt_retail_prc(price, options = {})\n format = options[:format] || 6\n $report_file.puts(\"Retail Price:\" + \"%#{format}s\" % \"$\" + price.to_s)\nend", "def index\n # TODO: ideally instead of eager loading sells, we could just include\n # quantity_sold in the eager_lod for lots.\n @portfolios = Portfolio.eager_graph(lots: :sells).eager_graph(allocations: {:asset_class => :funds}).all\n\n render json: @portfolios\n end", "def print_pay_stub\n print_name\n pay_for_period = hourly_wage * hours_per_week * 2\n formatted_pay = format(\"$%.2f\", pay_for_period)\n puts \"Pay This Period: #{formatted_pay}\"\n end", "def getFunderPortfolioObjName\r\n\t\t return \"mfiforce__funder_portfolio__c\"\r\n\t\tend", "def print_report\n # total_bikes = @fleet.count \n # broken_bikes = @fleet.count {|b| b.is_broken?}\n # working_bikes = total_bikes-broken_bikes\n total_people = @people.count\n total_stations = @stations.count\n # show_stations = @stations.each do {|name, capacity| puts \"#{name}, #{capacity}\"}\n #tell me its name and capcity\n # puts \"Total bikes: #{total_bikes}\"\n # puts \"Broken bikes: #{broken_bikes}\"\n # puts \"Working bikes: #{working_bikes}\"\n puts \"Total people: #{total_people}\"\n # puts \"People with bikes: #{people_with_bikes}\"\n puts \"People without bikes #{people_without_bikes.count}\" \n puts \"Number of stations: #{total_stations}\" \n puts \"Stations:\"\n @stations.each do |station|\n puts \"#{station.name}, #{station.capacity}, #{station.bikes.count}\"\n end\n # result = \"total bikes #{total_bikes}\\n\" + \"broken bikes #{broken_bikes}\\n\" + \"working bikes #{working_bikes}\\n\"\n # result + \"total people #{total_people}\\n\" + \"people with bikes #{people_with_bikes}\\n\" + \"people without bikes #{people_without_bikes}\\n\" + \"number of stations #{total_stations}\\n\" + \"stations #{show_stations}\"\n end", "def project_summary\n move_down 50\n summary = [[\"Project Summary\",\"\",\"\",\"\"],\n [\"Project Name\",\"Sales Person\",\"Project Status\",\"No. of Sites\"],\n [@project.project_name, \"#{@project.sales_person.sales_person_first_name} #{@project.sales_person.sales_person_last_name}\", @project.project_status.project_status_name ,@project.project_sites.count],\n [\"Project Setting\",\"Procurement Tool\",\"Deal Type\",\"Irrigation Responsibility\"],\n [@project.project_setting.project_setting_name,@project.procurement_tool.procurement_tool_name,@project.deal_type.deal_type_name,@project.irrigation_responsibility.irrigation_responsibility_name]\n ]\n table summary do\n rows(0..1).font_style = :bold\n row(3).font_style = :bold\n rows(0).background_color = \"a414e2\"\n rows(0).text_color = \"FFFFFF\"\n self.row_colors = [\"addbed\",\"25b2ea\"]\n column(0).width = 160\n column(1).width = 125\n column(2).width = 126\n column(3).width = 126\n columns(0..3).size = 10\n column(0).row(0).borders = :top, :left\n columns(1..2).row(0).borders = :top, :bottom\n column(3).row(0).borders = :top, :bottom, :right\n end\n end", "def print_order\n p \"@@@@@@@@@ Order id: ##{order.attrs['id']}\"\n p \"Name: #{order.attrs['name']} Email: #{order.attrs['email']}\"\n p \"Status: #{order.attrs['status']}\"\n\n conn = DatabaseConnector.new.connect\n rs = conn.exec \"select li.*, products.name from line_items as li INNER JOIN products on li.product_id = products.id where li.order_id = '#{order.attrs['id']}'\"\n\n char_len = 30\n rs.each do |row|\n prod_name = \"#{row['id']} : #{row['name']}\"\n\n p \"#{prod_name} #{'-'*(char_len - prod_name.length)}---> #{row['amount']} X #{row['quantity']} = #{row['amount'].to_f * row['quantity'].to_i}\"\n end\n p '-'*55\n if order.attrs['discont_desc'] != ''\n p \"Sub Total #{'-'*25} -> #{order.attrs['sub_total']}\"\n p \"Coupon #{'-'*25} -> #{order.attrs['discont_desc']}\"\n p \"You Saved #{'-'*25} -> #{order.attrs['amount'].to_i - order.attrs['sub_total'].to_i}\"\n p '-'*55\n end\n p \"Total #{'-'*25} -> #{order.attrs['amount']}\"\n end", "def print_owing(amount)\n print_banner\n puts \"name: #{@name}\"\n puts \"amount: #{amount}\"\nend", "def report\n puts \"Hello! My name is #{@name}, I've delivered #{@experience} papers\n today and I've earned $#{@earnings} so far!\"\n end", "def index\n @portfolios = Portfolio.where(user_id: session[:user_id])\n end", "def show\n @inform = @study.inform\n @all_cups_price = 0\n @inform.studies.each do |study|\n @all_cups_price += study.price * study.factor\n end\n end", "def print_output_head(index, meta_data)\n puts \"\\nPrinting autoscaled dataset for %.2f\" %\n (meta_data.domain_z.lower + (index * meta_data.domain_z.step))\n puts \"\\n\"\n end", "def index\n @portfoliologs = Portfoliolog.all.page(params[:page])\n end", "def show\n @portfolio = Portfolio.find(params[:id])\n session[:portfolio_id] = @portfolio.id if @portfolio.user.id == session[:user_id] #if the user owns this portfolio, set this to be the active portfolio\n\n @completed_bets, @in_progress_bets, @future_bets = [], [], [] #these three arrays will contain the three sets of bets the user has made\n\n @bets = @portfolio.bets.select {|bet| bet.line.team.league.abbrev == params[:league].upcase } if params[:league]\n @bets ||= @portfolio.bets\n\n# @portfolio.bets.each do |bet| #this assigns the user's bets to one of the three arrays\n @bets.each do |bet| #this assigns the user's bets to one of the three arrays\n event = bet.line.event\n if event.completed\n @completed_bets << bet\n elsif event.started?\n @in_progress_bets << bet\n else\n @future_bets << bet\n end\n \n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @portfolio }\n end\n end", "def get_portfolio\n @portfolio = Portfolio.find(params[:portfolio_id])\n end", "def show\n\t\t\n\t\t#Show total items and prices\n\t\tputs \"\\nShopping list: \"\n @list_products.each {|key, val| print val, \" \", key, \" \",productsMarket[key], \"$\\n\"} \n\tend" ]
[ "0.7330122", "0.6453931", "0.6446693", "0.6423939", "0.6417934", "0.63664246", "0.6340547", "0.6330982", "0.62902427", "0.62661624", "0.6234746", "0.61986446", "0.61781317", "0.61781317", "0.61764026", "0.6153178", "0.6116161", "0.60833263", "0.60818964", "0.60787785", "0.6016244", "0.59555495", "0.59404075", "0.58926576", "0.5874415", "0.58624554", "0.58581793", "0.58292276", "0.5824722", "0.58229715", "0.5818135", "0.58075404", "0.58019215", "0.5792779", "0.5792497", "0.57792354", "0.57790416", "0.5774965", "0.5771095", "0.5758833", "0.5732429", "0.57323116", "0.57256657", "0.57182807", "0.5717375", "0.5712706", "0.5708968", "0.5707543", "0.5698796", "0.56986135", "0.5694076", "0.5669179", "0.5667596", "0.566262", "0.56593317", "0.56572634", "0.5653381", "0.56371856", "0.56371856", "0.56371856", "0.56371856", "0.56371856", "0.56371856", "0.56354326", "0.5630436", "0.56253976", "0.5623573", "0.56074965", "0.5607396", "0.5606909", "0.55979735", "0.5585105", "0.5585084", "0.55752134", "0.55724186", "0.5556772", "0.55377674", "0.5530816", "0.552806", "0.55277246", "0.55182123", "0.5501764", "0.54970056", "0.54960334", "0.5494021", "0.54927397", "0.5492325", "0.54848945", "0.54789364", "0.54756993", "0.54754627", "0.5475422", "0.54744184", "0.54646885", "0.54581213", "0.5457826", "0.54570013", "0.5451767", "0.54493576", "0.54493177" ]
0.7698567
0
def encrypt(order) crypt = ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base)
def check_luxire_inventory order = Spree::Order.find(params[:order_id]) line_items = order.line_items line_items.each do |line_item| variant = Spree::Variant.find(line_item.variant_id) product = variant.product unless Spree::Product.non_depletable_product.include? product.name.downcase length_required_per_product = product.luxire_product.length_required quantity = line_item.quantity stock = product.luxire_stock unless stock.backorderable total_length_required = length_required_per_product * quantity if(stock.virtual_count_on_hands - total_length_required < 0) response = {msg: "#{product.name} is out of stock"} render json: response.to_json, status: 422 and return end end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cryptor\n key = Rails.application.secrets.secret_key_base.bytes[0..31].pack( \"c\" * 32 )\n ActiveSupport::MessageEncryptor.new(key)\n end", "def encryptor\n ActiveSupport::MessageEncryptor.new(ActiveSupport::KeyGenerator.new(\n ENV.fetch(\"SECRET_KEY_BASE\")\n ).generate_key(\n ENV.fetch(\"ENCRYPTION_SERVICE_SALT\"),\n ActiveSupport::MessageEncryptor.key_len\n ))\n end", "def encrypt; end", "def crypt\n @crypt ||= begin\n keygen = ActiveSupport::KeyGenerator.new(Rails.application.secret_key_base)\n key = keygen.generate_key('patron pin reset token', ActiveSupport::MessageEncryptor.key_len)\n ActiveSupport::MessageEncryptor.new(key)\n end\n end", "def encrypt_message plaintext\n key_pair.encrypt plaintext\n end", "def encrypt_secret\n return if @secret.to_s.empty?\n self.crypted_secret = Password.create(@secret)\n end", "def encrypt\n self\n end", "def encryption_client; end", "def lets_encrypt\n render plain: ACME_SECRET\n end", "def lets_encrypt\n render plain: ACME_SECRET\n end", "def encrypt\n self\n end", "def before_save\n encrypt_secret\n super\n end", "def encrypt(*args, &block)\n crypt :encrypt, *args, &block\n end", "def encrypt(password)\n self.class.encrypt(password, \"lottery-app\")\n end", "def _encrypt\n cryptor_files(@encrypting)\n end", "def secret\n decrypt_secret\n end", "def secret\n decrypt_secret\n end", "def encrypt()\n cipher_type = \"aes-128-ecb\"\n data = password;\n key = master_password;\n \n self.encrypted_password = aes_encrypt(data,key,nil,cipher_type).to_s\n end", "def encrypt(message)\n xcrypt(:encrypt, message)\n end", "def encrypt(password)\n self.class.encrypt(password, Time.now.to_s)\n end", "def encrypt string\n string\n end", "def letsencrypt\n render plain: ENV[\"LETS_ENCRYPT_KEY\"]\n end", "def encrypt(password)\n self.class.encrypt(password) #, salt)\n end", "def encrypt(plaintext)\n @cipher.encrypt(@secret_key, plaintext)\n end", "def encryption_server; end", "def encrypt_word\n @encrypted_word = \"_\".split(\"\") * @secret_word.length\n end", "def encrypt(plain_password)\n self.class.encrypt(plain_password)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end", "def encrypt(password)\n self.class.encrypt(password, salt)\n end" ]
[ "0.8049623", "0.7962808", "0.73545146", "0.73542374", "0.7090968", "0.6988849", "0.69872534", "0.68929464", "0.68464196", "0.68464196", "0.6833625", "0.6831857", "0.6796339", "0.67851853", "0.67801064", "0.6719976", "0.6719976", "0.6678443", "0.6659526", "0.66423213", "0.66271186", "0.66255516", "0.6595032", "0.6587609", "0.6542145", "0.64460784", "0.6435804", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756", "0.6413756" ]
0.0
-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 \t!deleted_at ? super : :deleted_account\n end", "def inactive_message\n \t!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 get_message().delete\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 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 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 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 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.7748454", "0.76111054", "0.7340721", "0.7340721", "0.7335309", "0.7303815", "0.72608256", "0.7252251", "0.72503877", "0.72373444", "0.72357714", "0.72048134", "0.69019526", "0.67021453", "0.6642065", "0.66013336", "0.6535773", "0.6467926", "0.6448776", "0.6448776", "0.6367995", "0.63673943", "0.6358363", "0.6307926", "0.6300036", "0.6255126", "0.6243579", "0.62362015", "0.62025976", "0.6162788", "0.61098135", "0.6106283", "0.60595125", "0.60506445", "0.60295844", "0.6027622", "0.5985033", "0.5983965", "0.59727645", "0.59608114", "0.5951808", "0.59305817", "0.5917218", "0.588347", "0.58232915", "0.5818782", "0.5813216", "0.57810664", "0.5773491", "0.5770699", "0.57674325", "0.57604635", "0.57527786", "0.57513976", "0.5742176", "0.5734147", "0.57261425", "0.57246405", "0.5721983", "0.57198846", "0.57098126", "0.5701057", "0.56980234", "0.5686234", "0.5684972", "0.5682391", "0.5682131", "0.5662421", "0.56620103", "0.5660111", "0.56546015", "0.5646471", "0.56443447", "0.56416565", "0.5639111", "0.5637827", "0.56280804", "0.5620692", "0.56193405", "0.5615966", "0.5600097", "0.55789196", "0.55769515", "0.5570888", "0.5566214" ]
0.73679733
14
GET /seasons GET /seasons.json
def index render json: {seasons: @serial.seasons, series: @serial} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end", "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def index\n @seasons = Season.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seasons }\n end\n end", "def index\n render json: {episodes: @season.episodes, season: @season}\n end", "def index\n @seasons = Season.all\n end", "def index\n @seasons = Season.all\n end", "def index\n @seasons = Season.all\n end", "def show\n @runway_season = Runway::Season.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runway_season }\n end\n end", "def season(series_id, season_id)\n get(\"/catalog/titles/series/#{series_id.to_s}/seasons/#{season_id.to_s}\")\n end", "def tournament_season(id, type = 'sr:tournament')\n get(\"sports/en/tournaments/#{type}:#{id}/seasons.xml\")\n end", "def index\n params[:season_url] ||= StepSeason.by_tournament(@tournament.id).last[:url]\n @season = StepSeason.by_tournament(@tournament.id).where(url: params[:season_url]).first\n\n # return error if no season with such url\n error!(\"Incorrect params\", 403) and return if @season.nil?\n\n @dates = Schedule.select(:match_on).joins(\n \"INNER JOIN steps_phases AS tours_phase ON (tours_phase.phase_id = schedules.tour_id) \" +\n \"INNER JOIN steps_phases AS seasons_phase ON (seasons_phase.phase_id = tours_phase.step_id) \"\n ).where(\"seasons_phase.step_id = ? \", @season.id).group(\"match_on\").order(\"match_on ASC\").collect{|item| item.match_on}\n\n respond_to do |format|\n format.json{ render json: {dates: @dates} }\n end\n end", "def set_seasons\n @seasons = Campground.find(params[:campground_id]).seasons\n end", "def show\n @batting_season = BattingSeason.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @batting_season }\n end\n end", "def show\n render json: {season: @season, series: @serial}\n end", "def sport_players(sport_id, season, **options) = get(\"/sports/#{sport_id}/players\", **options.merge(season:))", "def index\n @episodes = @season.episodes\n end", "def show\n render json: {episode: @episode, season: @season}\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def all_seasons_list\n Rails.cache.fetch(\"all_seasons_by_status_list\", :expires_in => 60.minutes) do\n get_all_seasons_by_status\n end\n end", "def index\n @admin_seasons = Season.order(:id).page params[:page]\n end", "def season\n season_id.nil? ? nil : organization_membership.seasons.find(season_id)\n end", "def show\n @season = Season.find(session[:season_id])\n\n @divisions = @season.divisions\n @teams = @season.divisions.collect { |div| div.teams.order(\"id desc\").sort_by { |team| team.team_total }.reverse }.flatten\n @weeks = @season.schedule.weeks.order(:date)\n @max_week = @weeks.last\n\n\n @season ||= Season.find(session[:season_id])\n @schedule = @season.schedule\n render 'teams/index', :layout => 'season'\n # respond_to do |format|\n # format.html # show.html.erb\n # format.json { render json: @season }\n # end\n end", "def list\n @studios = Studio.all;\n return render json: @studios.to_json, status: 200\n end", "def show\n @show = Show.find(params[:id])\n\n @seasons = {}\n @files = `ls \"public/tv/#{ @show.folder }\"`.split(\"\\n\")\n @files.each do |f|\n @seasons[f] = `find \"public/tv/#{ @show.folder }/#{ f }\" -type f`.split(\"\\n\").map { |ep| ep.gsub('public', '') }\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @show }\n end\n end", "def set_season\n @season = @serial.seasons.find_by(number: params[:id])\n end", "def index\n @weeks = Week.all.order(:season_id, :week_number)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weeks }\n end\n end", "def index\n @leagues = League.all\n if !League.first.nil?\n @last_season = League.first.seasons.last\n end\n respond_to do |format|\n format.html #index.html.erb\n end\n end", "def index\n if @logged_in\n @teams = @season.teams #Team.all\n else\n @teams = Team.where(:active => true, :season_id => @season.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams.to_xml(:include => :players)}\n format.json { render :json => @teams.to_json(:include => :players) }\n end\n end", "def index\n @games = @season.games #Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @games }\n end\n end", "def show\n #@season = Season.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @season }\n end\n end", "def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end", "def new\n @season = Season.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @season }\n end\n end", "def create\n @season = Season.new(season_params)\n\n if @season.save\n render :show, status: :created\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def update\n if @season.update(season_params)\n render :show, status: :ok\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def index\n @seasons = Season.all\n #@teams_sponsors = TeamsSponsor.all\n end", "def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end", "def retrieve_closed_seasons\n @season_type.seasons.where(['end_date < ?', Date.today])\n .sort_season_by_begin_date('DESC')\n end", "def new\n @runway_season = Runway::Season.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @runway_season }\n end\n end", "def get_schedule\n response = @client.full_game_schedule(@options[:season])\n parse_schedule_response(response)\n end", "def get_closed_seasons\n @closed_seasons ||= retrieve_closed_seasons\n end", "def load_season(year)\n puts \"Loading the #{year}-#{year.to_i+1} season...\"\n season = NbaAdvancedStats::Season.find_or_create_with_api(year)\n puts \"Data Ready.\"\n self.add_line_break\n self.main_menu(season)\n end", "def get_all_seasons_by_status\n dateNow = DateTime.now.end_of_day\n all_seasons = Hash.new\n all_seasons[:upcoming] = Array.new\n all_seasons[:current] = Array.new\n all_seasons[:past] = Array.new\n seasons = Season.all\n\n seasons.each do |season|\n if (season.is_active) # current or upcoming season\n # going to assume if today is part the season end date that the league owner intentionally wanted the season to be current\n if (season.date_start <= dateNow)\n all_seasons[:current].push(season)\n else\n all_seasons[:upcoming].push(season)\n end\n else # past season\n all_seasons[:past].push(season)\n end\n end\n all_seasons\n end", "def index\n if isAdmin\n @seasonals = Seasonal.all\n elsif isGeneral\n @seasonals = Seasonal.where('seasonYear >= ? OR seasonYear is null', DateTime.now.year)\n else\n redirect_to :controller => 'sessions', :action => 'new'\n end\n end", "def sport(sport_id, **options) = get(\"/sports/#{sport_id}\", **options)", "def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end", "def get_team_season_stats_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatsApi.get_team_season_stats ...'\n end\n # resource path\n local_var_path = '/stats/season'\n\n # query parameters\n query_params = {}\n query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil?\n query_params[:'team'] = opts[:'team'] if !opts[:'team'].nil?\n query_params[:'conference'] = opts[:'conference'] if !opts[:'conference'].nil?\n query_params[:'startWeek'] = opts[:'start_week'] if !opts[:'start_week'].nil?\n query_params[:'endWeek'] = opts[:'end_week'] if !opts[:'end_week'].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<TeamSeasonStat>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StatsApi#get_team_season_stats\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_searched_seasons\n current_seasons = if params['header_year'].present?\n Season.where( \"header_year LIKE '%#{ params['header_year'] }%'\" )\n else\n Season.is_not_ended\n end\n current_seasons.map{ |season| season.id }\n end", "def index\n @team = Team.find(params[:team_id])\n @sprints = @team.sprints.find(:all)\n\n respond_to do |format|\n format.html\n format.json\n end\n end", "def applied_season(season_id)\n seasons.where(org_season_id: BSON::ObjectId.from_string(season_id)).first\n end", "def index\n if @logged_in\n @seasons = Season.order('start_date desc')\n else\n @seasons = Season.where(\"active = ? or current = ?\", true, true).order('start_date desc')\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @seasons }\n end\n end", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render :show, status: :created, location: @season }\n else\n format.html { render :new }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def season\n Allocine::Season.new(document[\"parentSeason\"][\"code\"])\n end", "def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end", "def index\n @studios = Studio.page(params[:page]).per(1000)\n end", "def to_seasons(seasons)\n if seasons\n seasons.collect do |season|\n season = season.values[0]\n Season.new(\n Date.strptime(season['start'], '%m-%d'),\n Date.strptime(season['end'], '%m-%d'),\n season['rate'][1..-1].to_f\n )\n end\n end\n end", "def destroy\n if @season\n @season.destroy\n render json: {success: \"true\", message:\"Season was successfully deleted\", series: @serial}\n else\n render json: {success: \"false\", message:\"Season doesn't exists\", series: @serial}\n end\n end", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render json: @season, status: :created, location: @season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @season = Season.find(params[:id])\n @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :ok }\n end\n end", "def season_sponsors\n season_id = params[:season_id].to_i\n @season = Season.find_by(:id => season_id)\n season_teams = get_teams_by_given_season(season_id, true)\n # get the list of teams in ever division\n season_team_ids = Array.new\n \n season_teams.each do |team|\n season_team_ids.push(team.id)\n end\n \n teams_sponsors = TeamsSponsor.where(:team_id => season_team_ids)\n @team_sponsors = sponsors_by_team(teams_sponsors)\n end", "def index\n if params[:season] == \"both\"\n @sports = Sport.all\n elsif params[:season] == \"summer\"\n @sports = Sport.where(season: Season.find(1))\n elsif params[:season] == \"winter\"\n @sports = Sport.where(season: Season.find(2))\n elsif params[:season] == nil\n redirect_to '/'\n end\n puts \"GOT TO HERE\"\n \n\n # @sports = Sport.all\n\n # @winter_sports = []\n # @summer_sports = []\n \n\n # @sports.each do |sport| \n # if sport.season[:id] == 2\n # @winter_sports << sport\n # elsif\n # sport.season[:id] == 1\n # @summer_sports << sport\n # end\n # end \n #new variable (@season) when selected \n end", "def index\n # Get all the order seasons, active season first, then sort alphibetically\n @order_seasons = OrderSeason.all.order(current_season: :desc).order(:order_season_name)\n end", "def destroy\n @runway_season = Runway::Season.find(params[:id])\n @runway_season.destroy\n\n respond_to do |format|\n format.html { redirect_to runway_seasons_url }\n format.json { head :no_content }\n end\n end", "def all\n @week = Season.find(params[:season_id]).weeks.where(slug: params[:week_slug])[0] if params[:week_slug]\n if params[:league_id]\n if _is_commish_of?(@league)\n @teams = @league.teams.includes(:league, :coaches)\n else\n @teams = @league.teams.active.includes(:league, :coaches)\n end\n else\n @week ||= @season.current_week # if no week we need current week for 'My Teams'\n @teams = current_user.teams.joins(:league).where('season_id = ?', params[:season_id]).includes(league: [ :start_week, :season ]).includes(:coaches)\n end\n @teams = @teams.map { |team| TeamDecorator.decorate(team, @user, @week) }\n respond_with @teams # rendered via app/views/api/teams/all.json.rabl\n end", "def all_star_ballot(league_id, season = nil, **options)\n options[:season] = season || Time.now.year\n\n get \"/league/#{league_id}/allStarBallot\", **options\n end", "def index\n page_number = params[:page] ? params[:page][:number] : 1\n per_page = params[:per_page] ? params[:per_page] : 10\n\n @standings = Standing.paginate(page: page_number, per_page: per_page)\n\n render json: @standings\n end", "def index\n @episodes = @series.episodes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @episodes }\n end\n end", "def set_admin_season\n @admin_season = Season.find(params[:id])\n end", "def show\n @photos = @spot.photos.all\n @schools = @spot.schools.all\n gon.seasons = []\n @spot.seasons.each do |s|\n gon.seasons[s.sport.id] = s.get_months_array\n end\n\n\n if request.path != country_spot_path(@country, @spot)\n return redirect_to [@country, @spot], :status => :moved_permanently\n end\n \n end", "def show\n @photos = @spot.photos.all\n @schools = @spot.schools.all\n gon.seasons = []\n @spot.seasons.each do |s|\n gon.seasons[s.sport.id] = s.get_months_array\n end\n\n\n if request.path != country_spot_path(@country, @spot)\n return redirect_to [@country, @spot], :status => :moved_permanently\n end\n \n end", "def semesters\n uni_year = UniYear.find_by_id(params[:uni_year_id])\n @semesters = uni_year ? uni_year.semesters : []\n \n respond_to do |format|\n format.json { render json: @semesters }\n end\n end", "def index\n @club = Club.find_by_slug(params[:club_id])\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams }\n end\n end", "def index\n @sports = Sport.all.sort_by{|x| [x.season.start, x.start_date, x.name, x.group]}\n end", "def load_series! api\n @seasons = 1 # determined later\n @episodes = []\n current_season = 1\n begin\n season_url = url + '/episodes?season=%d' % current_season\n load_season!(api, season_url, current_season)\n current_season+=1\n end until current_season > @seasons\n\n # number all episodes\n num = 1\n @seasons.times do |season|\n sorted_episodes = get_season(season+1).sort_by {|epi| epi.episode}\n sorted_episodes.each do |epi|\n epi.number = num\n num += 1\n #debug '%s S%02dE%02d [%d] -- %s' % [title, epi.season, epi.episode, epi.number, epi.airdate]\n end\n end\n\n # remove pages:\n @episodes.each do |episode|\n episode.page = nil\n end\n\n @series_loaded = true\n end", "def index\n @game_studios = GameStudio.all\n end", "def set_seasonal\n @seasonal = Seasonal.find(params[:id])\n end", "def regular_season_rankings(season = nil)\n stats_request(\"regularSeasonStatRankings\", season).first\n end", "def get_teams_by_given_season(season_id, order_by = nil)\n divisions = Division.select('id').where(:season_id => params[:season_id])\n divisionIds = Array.new\n # get the divisions in this season\n divisions.each do |division|\n divisionIds.push(division.id)\n end\n if (order_by.nil?)\n teams = Team.select('id,name,division_id').where(:division_id => divisionIds)\n else\n teams = Team.select('id,name,division_id').where(:division_id => divisionIds)\n end\n teams\n end", "def create\n @serial = Serial.find(params[:serial_id])\n @season = Season.create(season_params)\n @season.serial_id = @serial.id\n @serial.seasons << @season\n if @season.id\n render json: {success: \"true\", message: \"Season has been created\", season: @season, series: @serial}\n else\n render json: {success: \"false\", message: \"Season was not created\"}\n end\n end", "def destroy\n # @season = Season.find(params[:id])\n # @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @season.update(season_params)\n format.html { redirect_to @season, notice: 'Season was successfully updated.' }\n format.json { render :show, status: :ok, location: @season }\n else\n format.html { render :edit }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_episodes( season )\n return @seasons[season][1].flatten\n end", "def index\n @episodes = Episode.all\n\n render json: @episodes\n end", "def index\n game = Game.all\n\n render json: game, include: :teams\n end", "def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def destroy\n @season.destroy\n respond_to do |format|\n format.html { redirect_to seasons_url, notice: 'Season was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def new\n @season = Season.new\n @seasons = Season.order('start_date desc')\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @season }\n end\n end", "def get_season_id\n season ? season.id : 0\n end", "def index\n\n params.permit(:search)\n\n if session.has_key?(:current_season)\n @current_season = Season.find(session[:current_season])\n else\n @current_season = Season.last\n end\n\n\n if params[:search]\n @practices = Kaminari.paginate_array(Practice.search(params[:search], @current_season)).page(params[:page]).per(30)\n else\n @practices = []\n @current_season.team_seasons.includes(:practices, :team).each do |team_season|\n team_season.practices.each do |practice|\n @practices << practice\n end\n end\n @practices = @practices.uniq\n @practices = @practices.sort_by { |k| k[:practice_date] }.reverse!\n @practices = Kaminari.paginate_array(@practices).page(params[:page]).per(30)\n end\n end", "def set_season\n id = season_params[:id]\n @season = ::Season.find(id)\n authorize_action_for @season\n end", "def season_params\n params.require(:season).permit(:campground_id, :name, :start_date, :end_date)\n end", "def update\n respond_with @season.update(season_params)\n end", "def by_season_team_parser\n by_season_team_data = []\n target_dir = by_season_team_dir\n Dir.foreach(target_dir) do |file|\n next if file == '.' or file == '..'\n json_file = File.open(target_dir + file)\n parsed_file = JSON.parse(File.read(json_file))\n player_values = parsed_file[\"api\"][\"players\"]\n\n player_values.each do |value|\n # Add team_id to parsed value\n value[:team_id] = file.split(\"_\")[0].to_i\n # Add season to parsed value\n value[:season] = file.split(\"_\")[1].to_i\n # Add coaches to parsed value\n value[:coaches] = parsed_file[\"api\"][\"coachs\"] # sic (as spelled in API)\n by_season_team_data.push(value.deep_symbolize_keys!)\n end\n end\n\n by_season_team_data\n end", "def get_league(id, sport)\n url_end = 'league/' + sport + '.l.' + id + '?format=json'\n data = RestClient.get @url + url_end, {:Authorization => 'Bearer ' + @access_token.to_s}\n puts data\n response = JSON.parse(data)\n end", "def get_races(seasonid, raceweek)\n res = $client.post('/memberstats/member/GetSeriesRaceResults',\n \"seasonid=#{seasonid}&raceweek=#{raceweek}&invokedBy=SeriesRaceResults\",\n $headers)\n JSON.parse res.body\nend", "def index\n @play_segments = PlaySegment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @play_segments }\n end\n end", "def teams\n render json: @team_query\n end", "def create_calendar\n League.current_seasons.each(&:start!)\n\n respond_to do |format|\n flash[:notice] = t('defaults.start_seasons_success')\n format.html{ redirect_to leagues_path}\n end\n end" ]
[ "0.8541434", "0.83396643", "0.7999041", "0.78044635", "0.7687866", "0.7687866", "0.7687866", "0.76114804", "0.75829875", "0.7446354", "0.7364968", "0.7205307", "0.71122336", "0.70955163", "0.6942995", "0.6942592", "0.69423854", "0.6874281", "0.6874281", "0.6874281", "0.6874281", "0.68711114", "0.6842547", "0.6824671", "0.6755496", "0.67434967", "0.66986406", "0.6667994", "0.66654944", "0.6658083", "0.6631135", "0.6617089", "0.6603001", "0.65666753", "0.6563286", "0.6535544", "0.65347457", "0.65288234", "0.6521481", "0.6503503", "0.6498777", "0.64964163", "0.6472489", "0.647198", "0.64505816", "0.63741046", "0.63585687", "0.6350563", "0.6346719", "0.6316318", "0.6306646", "0.6303838", "0.62926036", "0.62585866", "0.62520933", "0.6246336", "0.6221876", "0.6220399", "0.6199628", "0.6182805", "0.6173314", "0.6172825", "0.61586255", "0.61480296", "0.6143809", "0.61416036", "0.6139196", "0.6139138", "0.6106164", "0.6087949", "0.608596", "0.608596", "0.6082325", "0.6078299", "0.6077614", "0.6055466", "0.6041585", "0.6041352", "0.6039034", "0.6032228", "0.6030326", "0.6025541", "0.60217476", "0.60154265", "0.59913176", "0.5983104", "0.5982369", "0.59800154", "0.5978366", "0.59775954", "0.5971584", "0.59629065", "0.59558696", "0.5951969", "0.5930704", "0.59224206", "0.59221596", "0.59173757", "0.59143025", "0.59134954" ]
0.73479855
11
GET /seasons/1 GET /seasons/1.json
def show render json: {season: @season, series: @serial} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def show\n @runway_season = Runway::Season.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runway_season }\n end\n end", "def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end", "def index\n @seasons = Season.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seasons }\n end\n end", "def season(series_id, season_id)\n get(\"/catalog/titles/series/#{series_id.to_s}/seasons/#{season_id.to_s}\")\n end", "def index\n render json: {episodes: @season.episodes, season: @season}\n end", "def show\n @batting_season = BattingSeason.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @batting_season }\n end\n end", "def index\n @seasons = Season.all\n end", "def index\n @seasons = Season.all\n end", "def index\n @seasons = Season.all\n end", "def tournament_season(id, type = 'sr:tournament')\n get(\"sports/en/tournaments/#{type}:#{id}/seasons.xml\")\n end", "def index\n render json: {seasons: @serial.seasons, series: @serial}\n end", "def show\n render json: {episode: @episode, season: @season}\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def index\n params[:season_url] ||= StepSeason.by_tournament(@tournament.id).last[:url]\n @season = StepSeason.by_tournament(@tournament.id).where(url: params[:season_url]).first\n\n # return error if no season with such url\n error!(\"Incorrect params\", 403) and return if @season.nil?\n\n @dates = Schedule.select(:match_on).joins(\n \"INNER JOIN steps_phases AS tours_phase ON (tours_phase.phase_id = schedules.tour_id) \" +\n \"INNER JOIN steps_phases AS seasons_phase ON (seasons_phase.phase_id = tours_phase.step_id) \"\n ).where(\"seasons_phase.step_id = ? \", @season.id).group(\"match_on\").order(\"match_on ASC\").collect{|item| item.match_on}\n\n respond_to do |format|\n format.json{ render json: {dates: @dates} }\n end\n end", "def show\n #@season = Season.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @season }\n end\n end", "def new\n @season = Season.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @season }\n end\n end", "def season\n season_id.nil? ? nil : organization_membership.seasons.find(season_id)\n end", "def index\n @leagues = League.all\n if !League.first.nil?\n @last_season = League.first.seasons.last\n end\n respond_to do |format|\n format.html #index.html.erb\n end\n end", "def new\n @runway_season = Runway::Season.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @runway_season }\n end\n end", "def set_seasons\n @seasons = Campground.find(params[:campground_id]).seasons\n end", "def set_season\n @season = @serial.seasons.find_by(number: params[:id])\n end", "def show\n @season = Season.find(session[:season_id])\n\n @divisions = @season.divisions\n @teams = @season.divisions.collect { |div| div.teams.order(\"id desc\").sort_by { |team| team.team_total }.reverse }.flatten\n @weeks = @season.schedule.weeks.order(:date)\n @max_week = @weeks.last\n\n\n @season ||= Season.find(session[:season_id])\n @schedule = @season.schedule\n render 'teams/index', :layout => 'season'\n # respond_to do |format|\n # format.html # show.html.erb\n # format.json { render json: @season }\n # end\n end", "def show\n @show = Show.find(params[:id])\n\n @seasons = {}\n @files = `ls \"public/tv/#{ @show.folder }\"`.split(\"\\n\")\n @files.each do |f|\n @seasons[f] = `find \"public/tv/#{ @show.folder }/#{ f }\" -type f`.split(\"\\n\").map { |ep| ep.gsub('public', '') }\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @show }\n end\n end", "def index\n @episodes = @season.episodes\n end", "def update\n if @season.update(season_params)\n render :show, status: :ok\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def applied_season(season_id)\n seasons.where(org_season_id: BSON::ObjectId.from_string(season_id)).first\n end", "def index\n @admin_seasons = Season.order(:id).page params[:page]\n end", "def create\n @season = Season.new(season_params)\n\n if @season.save\n render :show, status: :created\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end", "def index\n @weeks = Week.all.order(:season_id, :week_number)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weeks }\n end\n end", "def load_season(year)\n puts \"Loading the #{year}-#{year.to_i+1} season...\"\n season = NbaAdvancedStats::Season.find_or_create_with_api(year)\n puts \"Data Ready.\"\n self.add_line_break\n self.main_menu(season)\n end", "def list\n @studios = Studio.all;\n return render json: @studios.to_json, status: 200\n end", "def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end", "def get_schedule\n response = @client.full_game_schedule(@options[:season])\n parse_schedule_response(response)\n end", "def sport_players(sport_id, season, **options) = get(\"/sports/#{sport_id}/players\", **options.merge(season:))", "def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end", "def index\n @games = @season.games #Game.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @games }\n end\n end", "def get_season_id\n season ? season.id : 0\n end", "def sport(sport_id, **options) = get(\"/sports/#{sport_id}\", **options)", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render :show, status: :created, location: @season }\n else\n format.html { render :new }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @studio = Studio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @studio }\n end\n end", "def season\n Allocine::Season.new(document[\"parentSeason\"][\"code\"])\n end", "def destroy\n @season = Season.find(params[:id])\n @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :ok }\n end\n end", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render json: @season, status: :created, location: @season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def all_seasons_list\n Rails.cache.fetch(\"all_seasons_by_status_list\", :expires_in => 60.minutes) do\n get_all_seasons_by_status\n end\n end", "def destroy\n @runway_season = Runway::Season.find(params[:id])\n @runway_season.destroy\n\n respond_to do |format|\n format.html { redirect_to runway_seasons_url }\n format.json { head :no_content }\n end\n end", "def set_admin_season\n @admin_season = Season.find(params[:id])\n end", "def index\n if @logged_in\n @teams = @season.teams #Team.all\n else\n @teams = Team.where(:active => true, :season_id => @season.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams.to_xml(:include => :players)}\n format.json { render :json => @teams.to_json(:include => :players) }\n end\n end", "def set_seasonal\n @seasonal = Seasonal.find(params[:id])\n end", "def current_season\n self.seasons.find(:first,\n :conditions => {:date => Season.maximum('date')})\n end", "def destroy\n if @season\n @season.destroy\n render json: {success: \"true\", message:\"Season was successfully deleted\", series: @serial}\n else\n render json: {success: \"false\", message:\"Season doesn't exists\", series: @serial}\n end\n end", "def index\n if isAdmin\n @seasonals = Seasonal.all\n elsif isGeneral\n @seasonals = Seasonal.where('seasonYear >= ? OR seasonYear is null', DateTime.now.year)\n else\n redirect_to :controller => 'sessions', :action => 'new'\n end\n end", "def show\n @season = Season.find(params[:season_id])\n @week = @season.weeks.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @week }\n end\n end", "def update\n respond_to do |format|\n if @season.update(season_params)\n format.html { redirect_to @season, notice: 'Season was successfully updated.' }\n format.json { render :show, status: :ok, location: @season }\n else\n format.html { render :edit }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @batting_season = BattingSeason.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @batting_season }\n end\n end", "def new\n @season = Season.new\n @seasons = Season.order('start_date desc')\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @season }\n end\n end", "def index\n @seasons = Season.all\n #@teams_sponsors = TeamsSponsor.all\n end", "def destroy\n # @season = Season.find(params[:id])\n # @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :no_content }\n end\n end", "def get_team_season_stats_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatsApi.get_team_season_stats ...'\n end\n # resource path\n local_var_path = '/stats/season'\n\n # query parameters\n query_params = {}\n query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil?\n query_params[:'team'] = opts[:'team'] if !opts[:'team'].nil?\n query_params[:'conference'] = opts[:'conference'] if !opts[:'conference'].nil?\n query_params[:'startWeek'] = opts[:'start_week'] if !opts[:'start_week'].nil?\n query_params[:'endWeek'] = opts[:'end_week'] if !opts[:'end_week'].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<TeamSeasonStat>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StatsApi#get_team_season_stats\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def stats(season = nil)\n stats_request(\"statsSingleSeason\", season).first\n end", "def show\n @rink_league = RinkLeague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rink_league }\n end\n end", "def get_closed_seasons\n @closed_seasons ||= retrieve_closed_seasons\n end", "def index\n @studios = Studio.page(params[:page]).per(1000)\n end", "def index\n if @logged_in\n @seasons = Season.order('start_date desc')\n else\n @seasons = Season.where(\"active = ? or current = ?\", true, true).order('start_date desc')\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @seasons }\n end\n end", "def index\n @team = Team.find(params[:team_id])\n @sprints = @team.sprints.find(:all)\n\n respond_to do |format|\n format.html\n format.json\n end\n end", "def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end", "def update\n respond_with @season.update(season_params)\n end", "def current_season\n curr_season = seasons.where(\"current_season = ?\", true).first\n\n if curr_season == nil\n curr_season = seasons.last\n end\n\n curr_season\n end", "def create\n @serial = Serial.find(params[:serial_id])\n @season = Season.create(season_params)\n @season.serial_id = @serial.id\n @serial.seasons << @season\n if @season.id\n render json: {success: \"true\", message: \"Season has been created\", season: @season, series: @serial}\n else\n render json: {success: \"false\", message: \"Season was not created\"}\n end\n end", "def new\n @guardseason = Guardseason.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @guardseason }\n end\n end", "def index\n @episodes = @series.episodes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @episodes }\n end\n end", "def show\n @skills = Announcament.find(params[:id]).skill\n @seasons = Announcament.find(params[:id]).season\n end", "def retrieve_closed_seasons\n @season_type.seasons.where(['end_date < ?', Date.today])\n .sort_season_by_begin_date('DESC')\n end", "def show\n @episode = @series.episodes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @episode }\n end\n end", "def get_searched_seasons\n current_seasons = if params['header_year'].present?\n Season.where( \"header_year LIKE '%#{ params['header_year'] }%'\" )\n else\n Season.is_not_ended\n end\n current_seasons.map{ |season| season.id }\n end", "def destroy\n @season.destroy\n respond_to do |format|\n format.html { redirect_to seasons_url, notice: 'Season was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def set_season\n id = season_params[:id]\n @season = ::Season.find(id)\n authorize_action_for @season\n end", "def create\n @admin_season = Season.new(admin_season_params)\n\n respond_to do |format|\n if @admin_season.save\n format.html { redirect_to @admin_season, success: 'Season was successfully created.' }\n format.json { render :show, status: :created, location: @admin_season }\n else\n format.html { render :new }\n format.json { render json: @admin_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @socio }\n end\n end", "def season_number\n @ole.SeasonNumber\n end", "def index\n @club = Club.find_by_slug(params[:club_id])\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams }\n end\n end", "def index\n @game_studios = GameStudio.all\n end", "def index\n if params[:season] == \"both\"\n @sports = Sport.all\n elsif params[:season] == \"summer\"\n @sports = Sport.where(season: Season.find(1))\n elsif params[:season] == \"winter\"\n @sports = Sport.where(season: Season.find(2))\n elsif params[:season] == nil\n redirect_to '/'\n end\n puts \"GOT TO HERE\"\n \n\n # @sports = Sport.all\n\n # @winter_sports = []\n # @summer_sports = []\n \n\n # @sports.each do |sport| \n # if sport.season[:id] == 2\n # @winter_sports << sport\n # elsif\n # sport.season[:id] == 1\n # @summer_sports << sport\n # end\n # end \n #new variable (@season) when selected \n end", "def show\n @photos = @spot.photos.all\n @schools = @spot.schools.all\n gon.seasons = []\n @spot.seasons.each do |s|\n gon.seasons[s.sport.id] = s.get_months_array\n end\n\n\n if request.path != country_spot_path(@country, @spot)\n return redirect_to [@country, @spot], :status => :moved_permanently\n end\n \n end", "def show\n @photos = @spot.photos.all\n @schools = @spot.schools.all\n gon.seasons = []\n @spot.seasons.each do |s|\n gon.seasons[s.sport.id] = s.get_months_array\n end\n\n\n if request.path != country_spot_path(@country, @spot)\n return redirect_to [@country, @spot], :status => :moved_permanently\n end\n \n end", "def show\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @socio }\n end\n end", "def show\n @player = Player.find(params[:id])\n if @player.games.count >= 1\n @last_team_name = @player.games.find(:last).team_name\n @year = @player.games.first.date.year\n @newest_year = @player.games.last.date.year\n else\n @last_team_name = \"Your team name\"\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end", "def show\n @socioeconomic_study = SocioeconomicStudy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n\n\n format.json { render json: @socioeconomic_study }\n end\n end", "def show\n @game_tournament = GameTournament.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_tournament }\n end\n end", "def update\n respond_to do |format|\n if @admin_season.update(admin_season_params)\n format.html { redirect_to @admin_season, success: 'Season was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_season }\n else\n format.html { render :edit }\n format.json { render json: @admin_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @runway_season = Runway::Season.new(params[:runway_season])\n\n respond_to do |format|\n if @runway_season.save\n format.html { redirect_to @runway_season, notice: 'Season was successfully created.' }\n format.json { render json: @runway_season, status: :created, location: @runway_season }\n else\n format.html { render action: \"new\", layout: \"forms\" }\n format.json { render json: @runway_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n render json: @league, status: :ok\n end", "def show\n @tournament = Tournament.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tournament }\n end\n end", "def semesters\n uni_year = UniYear.find_by_id(params[:uni_year_id])\n @semesters = uni_year ? uni_year.semesters : []\n \n respond_to do |format|\n format.json { render json: @semesters }\n end\n end", "def index\n @episodes = Episode.all\n\n render json: @episodes\n end", "def show\n @sproject = current_user.sprojects.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sproject }\n end\n end" ]
[ "0.83198774", "0.8067729", "0.79634094", "0.7904455", "0.7782969", "0.76482874", "0.7560294", "0.75439924", "0.75439924", "0.75439924", "0.75148576", "0.7256124", "0.7221905", "0.7195488", "0.7195488", "0.7195488", "0.7195488", "0.71601826", "0.70462865", "0.70281816", "0.70091087", "0.6969267", "0.6963841", "0.6959822", "0.6914745", "0.6884154", "0.688129", "0.68668425", "0.6786919", "0.6727995", "0.67085713", "0.67057645", "0.6705135", "0.6671876", "0.6635913", "0.6578239", "0.65390617", "0.65380704", "0.6531394", "0.65129477", "0.6502864", "0.64895546", "0.6463694", "0.6458348", "0.6441829", "0.64251685", "0.6401113", "0.6397533", "0.6396928", "0.6389751", "0.63828444", "0.6343078", "0.6339505", "0.6326255", "0.6314274", "0.6313052", "0.6294853", "0.62843066", "0.62754256", "0.6249129", "0.6238397", "0.62167823", "0.62156767", "0.620009", "0.6196086", "0.6193018", "0.6166947", "0.6162307", "0.61574733", "0.61540943", "0.6146573", "0.61429346", "0.6135847", "0.61321455", "0.6125652", "0.6124847", "0.6118706", "0.6103298", "0.61000484", "0.6081578", "0.6080975", "0.6080095", "0.60792136", "0.6058201", "0.6052392", "0.6049079", "0.60466856", "0.6045992", "0.6045992", "0.6036635", "0.6030134", "0.602788", "0.6026079", "0.6017269", "0.601183", "0.60065955", "0.6004611", "0.60035986", "0.59904855", "0.59877187" ]
0.73392946
11
POST /seasons POST /seasons.json
def create @serial = Serial.find(params[:serial_id]) @season = Season.create(season_params) @season.serial_id = @serial.id @serial.seasons << @season if @season.id render json: {success: "true", message: "Season has been created", season: @season, series: @serial} else render json: {success: "false", message: "Season was not created"} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @season = Season.new(season_params)\n\n if @season.save\n render :show, status: :created\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render :show, status: :created, location: @season }\n else\n format.html { render :new }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render json: @season, status: :created, location: @season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @runway_season = Runway::Season.new(params[:runway_season])\n\n respond_to do |format|\n if @runway_season.save\n format.html { redirect_to @runway_season, notice: 'Season was successfully created.' }\n format.json { render json: @runway_season, status: :created, location: @runway_season }\n else\n format.html { render action: \"new\", layout: \"forms\" }\n format.json { render json: @runway_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_season = Season.new(admin_season_params)\n\n respond_to do |format|\n if @admin_season.save\n format.html { redirect_to @admin_season, success: 'Season was successfully created.' }\n format.json { render :show, status: :created, location: @admin_season }\n else\n format.html { render :new }\n format.json { render json: @admin_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:season][:start_date] = Date.strptime(params[:season][:start_date], \"%m/%d/%Y\")\n params[:season][:end_date] = Date.strptime(params[:season][:end_date], \"%m/%d/%Y\")\n params[:season][:handicapping_method_attributes] = params[:handicapping_method]\n params[:season].delete(:wday)\n params[:season].delete('tee_time_start(5i)')\n\n @season = Season.new(params[:season])\n\n\n #Create divisions if any are added, else default to the below.\n\n respond_to do |format|\n if @season.save\n @season.reload\n session[:season_id]=@season.id\n set_session\n format.html { redirect_to @season, notice: 'Season was successfully created.' }\n format.json { render json: @season, status: :created, location: @season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end", "def season_params\n params.require(:season).permit(:campground_id, :name, :start_date, :end_date)\n end", "def season_params\n params.require(:season).permit(:description, :date, :number, :serial_id)\n end", "def create\n @batting_season = BattingSeason.new(params[:batting_season])\n\n respond_to do |format|\n if @batting_season.save\n format.html { redirect_to @batting_season, notice: 'Batting season was successfully created.' }\n format.json { render json: @batting_season, status: :created, location: @batting_season }\n else\n format.html { render action: \"new\" }\n format.json { render json: @batting_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def seasonal_params\n params.require(:seasonal).permit(:season, :seasonYear, :piecePay, :employee_id, :verified, :seasonals_id)\n end", "def set_seasons\n @seasons = Campground.find(params[:campground_id]).seasons\n end", "def season_params\n params.require(:season).permit(:id, :name, :current, :active, :start_date, :game_duration)\n end", "def index\n @seasons = Season.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seasons }\n end\n end", "def create\n @guardseason = Guardseason.new(params[:guardseason])\n\n respond_to do |format|\n if @guardseason.save\n format.html { redirect_to @guardseason, notice: 'Vartiokausi luotu.' }\n format.json { render json: @guardseason, status: :created, location: @guardseason }\n else\n format.html { render action: \"new\" }\n format.json { render json: @guardseason.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @season = Season.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @season }\n end\n end", "def index\n render json: {episodes: @season.episodes, season: @season}\n end", "def season_params\n params.require(:season).permit(:title, :plot, :hd_price, :sd_price)\n end", "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def new\n @runway_season = Runway::Season.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @runway_season }\n end\n end", "def create_calendar\n League.current_seasons.each(&:start!)\n\n respond_to do |format|\n flash[:notice] = t('defaults.start_seasons_success')\n format.html{ redirect_to leagues_path}\n end\n end", "def admin_season_params\n params.require(:season).permit(:id, :league_id, :year, :day, :start_date, :number_of_weeks, :roll_off_weeks, :dates_off, :handicap_base, :handicap_percent, :location, :practice_length, :starts_at)\n end", "def index\n @seasons = Season.all\n end", "def index\n @seasons = Season.all\n end", "def index\n @seasons = Season.all\n end", "def season_params\n params.permit(:year_start, :year_end, :team_id)\n end", "def test_create_new_season\n login(:admin)\n now = Time.now\n post :edit_season, :season => {:tournament_starts_at => now, :buy_in => 10, :max_num_brackets => 1}\n season = Season.find_by_year(now.year)\n assert_not_nil season\n assert_redirected_to :action => :select_team_bids, :id => season.id\n end", "def update\n if @season.update(season_params)\n render :show, status: :ok\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\t# league admin can add\n\t\t# anyone can add (own team) as pending iff league is addable\n\t\tds = DivisionSeason.find params[:division_season_id]\n\t\tteam = Team.find team[:team_id]\n\n\t\tif can? :manage_teams, ds\n\t\t\tTeamDSService.add_team(ds, team)\n\t\telse\n\t\t\tauthorize! :add_team, ds\n\t\t\tTeamDSService.add_pending_team(ds, team)\n\t\tend\n\n\t\trespond_with tdsr\n\tend", "def season_params\n params.require(:season).permit(:name, :beginning_date, :ending_date, memberships_attributes: [:id, :month_id, :member_id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def add_season(season)\r\n seasons << season\r\n end", "def index\n render json: {seasons: @serial.seasons, series: @serial}\n end", "def index\n params[:season_url] ||= StepSeason.by_tournament(@tournament.id).last[:url]\n @season = StepSeason.by_tournament(@tournament.id).where(url: params[:season_url]).first\n\n # return error if no season with such url\n error!(\"Incorrect params\", 403) and return if @season.nil?\n\n @dates = Schedule.select(:match_on).joins(\n \"INNER JOIN steps_phases AS tours_phase ON (tours_phase.phase_id = schedules.tour_id) \" +\n \"INNER JOIN steps_phases AS seasons_phase ON (seasons_phase.phase_id = tours_phase.step_id) \"\n ).where(\"seasons_phase.step_id = ? \", @season.id).group(\"match_on\").order(\"match_on ASC\").collect{|item| item.match_on}\n\n respond_to do |format|\n format.json{ render json: {dates: @dates} }\n end\n end", "def season_params\n params.permit(:id, :format, :game_id, :filters => [:season_id, :game_id])\n end", "def create\n # Stores all the parameters entered in for the order season\n @order_season = OrderSeason.new(order_season_params)\n\n # If user is saved, redirect to order season index page\n # with a message, if there is errors, redirect them back\n # to the same view with the errors listed\n if @order_season.save\n season_id = @order_season.order_season_id\n\n # Create the array for date range\n date_range = Array.new\n # Put the date range values in from start and end date\n date_range = (Date.parse(@order_season.pickup_date_start)..Date.parse(@order_season.pickup_date_end)).to_a\n\n # Loop through each date and add it to the database\n date_range.each do |date|\n @date = PickupDate.new(:order_season_id => season_id, :pickup_date => date)\n @date.save\n end\n\n # If current season was checked, unset any other active seasons\n if @order_season.current_season?\n set_active_order_season\n end\n\n # Send message to the user and redirect to the\n # season listing\n flash[:success] = \"Order Season: #{@order_season.order_season_name}\n has been added!\"\n redirect_to edit_order_season_url(@order_season)\n\n else\n render 'new'\n end\n end", "def create\n @episode = Episode.new(params[:episode])\n @episode.season_id = params[:season_id] \n \n respond_to do |format|\n if @episode.save\n format.html { redirect_to(series_season_episode_url(@episode.season.series.id, @episode.season.id, @episode.id), :notice => 'Episode was successfully created.') }\n format.xml { render :xml => @episode, :status => :created, :location => @episode }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @episode.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_season\n @season = @serial.seasons.find_by(number: params[:id])\n end", "def update\n respond_with @season.update(season_params)\n end", "def destroy\n if @season\n @season.destroy\n render json: {success: \"true\", message:\"Season was successfully deleted\", series: @serial}\n else\n render json: {success: \"false\", message:\"Season doesn't exists\", series: @serial}\n end\n end", "def create_period(season, options = {})\n post(\"seasons/#{season}/periods\", periods: [options]).pop\n end", "def create\n #@game = Game.new(params[:game])\n @game = Game.new(game_params)\n @game.season_id = params[:season_id]\n @games = Game.where(:season_id => @game.season_id)\n\n respond_to do |format|\n if @logged_in.update_site? and @game.save\n format.html { redirect_to(season_game_path(@game.season_id, @game), :notice => 'Game was successfully created.') }\n format.xml { render :xml => @game, :status => :created, :location => @game }\n format.js\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @sport_odd = SportOdd.new(sport_odd_params)\n\n respond_to do |format|\n if @sport_odd.save\n format.html { redirect_to @sport_odd, notice: 'Sport odd was successfully created.' }\n format.json { render :show, status: :created, location: @sport_odd }\n else\n format.html { render :new }\n format.json { render json: @sport_odd.errors, status: :unprocessable_entity }\n end\n end\n end", "def order_season_params\n params.require(:order_season).permit(:order_season_id, :order_season_name,\n :current_season, :pickup_date_start, :pickup_date_end,\n pickup_dates_attributes: [:pickup_date_id, :pickup_date ])\n end", "def tournament_season(id, type = 'sr:tournament')\n get(\"sports/en/tournaments/#{type}:#{id}/seasons.xml\")\n end", "def show\n @runway_season = Runway::Season.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runway_season }\n end\n end", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\n @season.model_after(params[:model_after])\n format.html { redirect_to(@season, :notice => 'Season was successfully created.') }\n format.xml { render :xml => @season, :status => :created, :location => @season }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @season.errors, :status => :unprocessable_entity }\n end\n end\n end", "def to_seasons(seasons)\n if seasons\n seasons.collect do |season|\n season = season.values[0]\n Season.new(\n Date.strptime(season['start'], '%m-%d'),\n Date.strptime(season['end'], '%m-%d'),\n season['rate'][1..-1].to_f\n )\n end\n end\n end", "def season_finalize\n Params.inc_season\n end", "def index\n @episodes = @season.episodes\n end", "def set_season\n id = season_params[:id]\n @season = ::Season.find(id)\n authorize_action_for @season\n end", "def new\n if params[:course_id]\n @season = Season.new(params[:season])\n @show_the_js_link = true\n respond_to do |format|\n format.js {}\n end\n else\n session[:league_id]=params[:id] if params[:id]\n @season = Season.new(:league_id => session[:league_id], :start_date => 0.days.ago, :end_date => 0.days.ago)\n old_season = League.find(session[:league_id]).seasons.last\n hc = old_season.handicapping_method if old_season\n hc ||= HandicappingMethod.find(2)\n @season.handicapping_method= hc.dup\n @season.divisions = [Division.new(), Division.new(), Division.new()]\n @week=Week.new()\n @season.scoring_methods = ScoringMethod.where('season_id is null').order(:type).collect { |sm| sm.dup }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @season }\n end\n end\n\n\n end", "def create_standings\n season.standings.create(result: self)\n end", "def destroy\n @runway_season = Runway::Season.find(params[:id])\n @runway_season.destroy\n\n respond_to do |format|\n format.html { redirect_to runway_seasons_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @season.update(season_params)\n format.html { redirect_to @season, notice: 'Season was successfully updated.' }\n format.json { render :show, status: :ok, location: @season }\n else\n format.html { render :edit }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @season = Season.find(params[:season_id])\n @week = @season.weeks.new(params[:week])\n\n respond_to do |format|\n if @week.save\n format.html { redirect_to season_week_url(@season, @week) }\n format.xml { render :xml => @week, :status => :created, :location => @week }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @week.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @season.destroy\n respond_to do |format|\n format.html { redirect_to seasons_url, notice: 'Season was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def new\n @batting_season = BattingSeason.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @batting_season }\n end\n end", "def create\n @practice = Practice.new(practice_params)\n\n\n respond_to do |format|\n if @practice.save\n\n @practice.team_season.players.each do |pp|\n player_practice = PlayerPractice.new\n player_practice.player = pp\n player_practice.practice = @practice\n player_practice.save\n end\n\n format.html { redirect_to @practice, 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 destroy\n @season = Season.find(params[:id])\n @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :ok }\n end\n end", "def new\n @season = Season.new\n @seasons = Season.order('start_date desc')\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @season }\n end\n end", "def create\n @serial = Serial.find_by(id: params[:serial_id])\n @season = @serial.seasons.find_by(number: params[:season_id])\n @episode = Episode.create(episode_params)\n @episode.season_id = @season.id\n @season.episodes << @episode\n if @episode.id\n render json: {success: \"true\", message: \"Episode has been created\", episode: @episode, season: @season}\n else\n render json: {success: \"false\", message: \"Episode couldn't be created\", episode: @episode, season: @season, serial: @serial}\n end\n end", "def create\n @studio = Studio.new(studio_params)\n\n if @studio.save\n return render json: @studio.to_json, status: 200\n else\n return render json: {\n error: \"could not create studio\"\n }, status: 400\n end\n\n end", "def acommodate_seasons\n new_year_season = @seasons.select{|season| season.end < season.start}.first\n\n first_seasion = Season.new(new_year_season)\n new_year_season.end = SeasonDate.last_day_of_year\n\n @seasons.push(first_seasion)\n end", "def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to(season_team_path(@team.season_id, @team), :notice => 'Team was successfully created.') }\n format.xml { render :xml => @team, :status => :created, :location => @team }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def season(series_id, season_id)\n get(\"/catalog/titles/series/#{series_id.to_s}/seasons/#{season_id.to_s}\")\n end", "def show\n @season.create_unfilled_memberships\n end", "def sport_params\n params.require(:sport).permit(:name, :season_id, :gender)\n end", "def create\n @sport = Sport.new(sport_params)\n\n respond_to do |format|\n if @sport.save\n format.html { redirect_to @sport, notice: 'Sport was successfully created.' }\n format.json { render :show, status: :created, location: @sport }\n else\n format.html { render :new }\n format.json { render json: @sport.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @guardseason = Guardseason.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @guardseason }\n end\n end", "def league_params\n params.require(:league).permit(:name, :season_id)\n end", "def new_episodes( season )\n return @seasons[season][1].flatten\n end", "def create\n @nautical_sport = NauticalSport.new(nautical_sport_params)\n\n respond_to do |format|\n if @nautical_sport.save\n format.html { redirect_to @nautical_sport, notice: 'Nautical sport was successfully created.' }\n format.json { render :show, status: :created, location: @nautical_sport }\n else\n format.html { render :new }\n format.json { render json: @nautical_sport.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n # @season = Season.find(params[:id])\n # @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :no_content }\n end\n end", "def show\n render json: {season: @season, series: @serial}\n end", "def create\n @game_studio = GameStudio.new(game_studio_params)\n\n respond_to do |format|\n if @game_studio.save\n format.html { redirect_to @game_studio, notice: 'Game studio was successfully created.' }\n format.json { render :show, status: :created, location: @game_studio }\n else\n format.html { render :new }\n format.json { render json: @game_studio.errors, status: :unprocessable_entity }\n end\n end\n end", "def competition_params\n params.require(:competition).permit(:nr_teams, :knockout, :name, :season_id, team_season_ids: [])\n end", "def new\n @season = Season.find(params[:season_id])\n @week = @season.weeks.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @week }\n end\n end", "def show\n render json: {episode: @episode, season: @season}\n end", "def update\n respond_to do |format|\n if @admin_season.update(admin_season_params)\n format.html { redirect_to @admin_season, success: 'Season was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_season }\n else\n format.html { render :edit }\n format.json { render json: @admin_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.find(params[:event_id])\n @serie = Serie.new(serie_params)\n @serie.event = @event\n @series = Serie.all\n\n respond_to do |format|\n if @serie.save\n @match = Match.new(court_number: 1, serie_id: @serie.id, player1: 0, player2: 1, player3: 2)\n @match.save!\n format.html { redirect_to club_event_series_index_path, notice: \"La mêlée du #{Series.date} a été créée.\" }\n # format.json { render :show, status: :created, location: @serie }\n else\n format.html { render :new, status: :unprocessable_entity }\n # format.json { render json: @serie.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @weeks = Week.all.order(:season_id, :week_number)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weeks }\n end\n end", "def destroy\n @season.destroy\n end", "def generate_games(season)\n unless season.blank?\n player_ids = season.approved_players.map(&:id).uniq\n player_ids.each do |player_id|\n opponent_ids = player_ids - [ player_id ]\n opponent_ids.each do |opponent_id|\n # Runner\n runner_game = {\n league_id: season.league_id,\n season_id: season.id,\n runner_player_id: player_id,\n corp_player_id: opponent_id\n }\n Game.create(runner_game) unless Game.where(runner_game).any?\n\n # Corp\n corp_game = {\n league_id: season.league_id,\n season_id: season.id,\n runner_player_id: opponent_id,\n corp_player_id: player_id\n }\n Game.create(corp_game) unless Game.where(corp_game).any?\n end\n end\n\n season.update_table!\n end\n end", "def create\n @series = Series.find(params[:series_id].to_i)\n @episode = @series.episodes.new(episode_params)\n\n respond_to do |format|\n if @episode.save\n format.html { redirect_to series_episode_path(@series, @episode), notice: 'Episode was successfully created.' }\n format.json { render action: 'show', status: :created, location: series_episode_path(@series, @episode) }\n else\n format.html { render action: 'new' }\n format.json { render json: @episode.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_new_episodes( season, *episodes)\n @seasons[season][1].concat(episodes)\n @seasons[season].flatten\n end", "def download_season(season_number)\n season = seasons.find_or_create_by!(number: season_number)\n season.update download_requested: true\n trakt_episodes = Broad::ServiceRegistry.trakt_shows.episodes(imdb_id).select{|episode| episode.season == season_number}\n season_releases = btn_service.season(tvdb_id, season_number)\n season_releases.each do |release|\n trakt_episodes.each do |episode|\n hash_release = release.to_hash\n hash_release[:episode] = episode.number\n hash_release[:name] = episode.title\n episode = create_episode_from_entry(hash_release)\n episode.save!\n end\n end\n\n download_season_episodes(season_number) if season_releases.count.zero?\n self\n end", "def destroy\n @seasonal.destroy\n respond_to do |format|\n format.html { redirect_to seasonals_url, notice: 'Seasonal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end", "def index\n if params[:season] == \"both\"\n @sports = Sport.all\n elsif params[:season] == \"summer\"\n @sports = Sport.where(season: Season.find(1))\n elsif params[:season] == \"winter\"\n @sports = Sport.where(season: Season.find(2))\n elsif params[:season] == nil\n redirect_to '/'\n end\n puts \"GOT TO HERE\"\n \n\n # @sports = Sport.all\n\n # @winter_sports = []\n # @summer_sports = []\n \n\n # @sports.each do |sport| \n # if sport.season[:id] == 2\n # @winter_sports << sport\n # elsif\n # sport.season[:id] == 1\n # @summer_sports << sport\n # end\n # end \n #new variable (@season) when selected \n end", "def update\n @runway_season = Runway::Season.find(params[:id])\n\n respond_to do |format|\n if @runway_season.update_attributes(params[:runway_season])\n format.html { redirect_to @runway_season, notice: 'Season was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\", layout: \"forms\" }\n format.json { render json: @runway_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @batting_season = BattingSeason.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @batting_season }\n end\n end", "def index\n @admin_seasons = Season.order(:id).page params[:page]\n end", "def season_sponsors\n season_id = params[:season_id].to_i\n @season = Season.find_by(:id => season_id)\n season_teams = get_teams_by_given_season(season_id, true)\n # get the list of teams in ever division\n season_team_ids = Array.new\n \n season_teams.each do |team|\n season_team_ids.push(team.id)\n end\n \n teams_sponsors = TeamsSponsor.where(:team_id => season_team_ids)\n @team_sponsors = sponsors_by_team(teams_sponsors)\n end", "def season\n Allocine::Season.new(document[\"parentSeason\"][\"code\"])\n end", "def destroy\n @batting_season = BattingSeason.find(params[:id])\n @batting_season.destroy\n\n respond_to do |format|\n format.html { redirect_to batting_seasons_url }\n format.json { head :no_content }\n end\n end", "def set_seasonal\n @seasonal = Seasonal.find(params[:id])\n end" ]
[ "0.78587097", "0.7680651", "0.7648404", "0.7357849", "0.7304112", "0.7230402", "0.72032005", "0.70242685", "0.69525826", "0.6861392", "0.6844209", "0.6836399", "0.6831166", "0.682942", "0.68144256", "0.67909384", "0.6712306", "0.6693715", "0.6685788", "0.66826665", "0.6662538", "0.6577016", "0.6567315", "0.6567315", "0.6567315", "0.6547563", "0.6539952", "0.6531479", "0.6523377", "0.6501946", "0.64834785", "0.64834785", "0.64834785", "0.64834785", "0.6461279", "0.6310467", "0.6306247", "0.6294033", "0.6277534", "0.6266333", "0.62371254", "0.62278855", "0.6218294", "0.62066644", "0.61769474", "0.6160537", "0.6152603", "0.6112048", "0.6106575", "0.6081844", "0.6066756", "0.6063027", "0.60594684", "0.605811", "0.60532695", "0.60480237", "0.6043533", "0.6032644", "0.6030878", "0.6026346", "0.6018046", "0.60169315", "0.6010995", "0.60068965", "0.6001778", "0.60016865", "0.5999196", "0.5997397", "0.598231", "0.59638083", "0.5949081", "0.59397", "0.59297025", "0.5907156", "0.5888316", "0.58871186", "0.5878499", "0.5874987", "0.5843515", "0.5839602", "0.5811128", "0.57989264", "0.57823884", "0.57710826", "0.5760204", "0.57517695", "0.57416314", "0.5719047", "0.57175964", "0.5707134", "0.5702756", "0.5697131", "0.569413", "0.5693347", "0.5692333", "0.5690512", "0.5676315", "0.5661795", "0.56531817", "0.56518877" ]
0.7496587
3
PATCH/PUT /seasons/1 PATCH/PUT /seasons/1.json
def update respond_with @season.update(season_params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @season.update(season_params)\n render :show, status: :ok\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @season.update(season_params)\n format.html { redirect_to @season, notice: 'Season was successfully updated.' }\n format.json { render :show, status: :ok, location: @season }\n else\n format.html { render :edit }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @runway_season = Runway::Season.find(params[:id])\n\n respond_to do |format|\n if @runway_season.update_attributes(params[:runway_season])\n format.html { redirect_to @runway_season, notice: 'Season was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\", layout: \"forms\" }\n format.json { render json: @runway_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_season.update(admin_season_params)\n format.html { redirect_to @admin_season, success: 'Season was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_season }\n else\n format.html { render :edit }\n format.json { render json: @admin_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@season = Season.find(params[:id])\n\n respond_to do |format|\n #if @season.update_attributes(params[:season])\n if @season.update_attributes(season_params)\n format.html { redirect_to(@season, :notice => 'Season was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @season.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @batting_season = BattingSeason.find(params[:id])\n\n respond_to do |format|\n if @batting_season.update_attributes(params[:batting_season])\n format.html { redirect_to @batting_season, notice: 'Batting season was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @batting_season.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @guardseason = Guardseason.find(params[:id])\n\n respond_to do |format|\n if @guardseason.update_attributes(params[:guardseason])\n format.html { redirect_to @guardseason, notice: 'Vartiokausi päivitetty.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @guardseason.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @season = Season.find(params[:id])\n params[:season][:start_date] = Date.strptime(params[:season][:start_date], \"%m/%d/%Y\")\n params[:season][:end_date] = Date.strptime(params[:season][:end_date], \"%m/%d/%Y\")\n params[:season].delete(:wday)\n params[:season].delete('tee_time_start(5i)')\n\n\n respond_to do |format|\n if @season.update_attributes(params[:season])\n @season.handicapping_method.update_attributes(params[:handicapping_method])\n format.html { redirect_to @season, notice: 'Season was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @season.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def set_season\n @season = Season.find(params[:id])\n end", "def update\n respond_to do |format|\n if @sport_odd.update(sport_odd_params)\n format.html { redirect_to @sport_odd, notice: 'Sport odd was successfully updated.' }\n format.json { render :show, status: :ok, location: @sport_odd }\n else\n format.html { render :edit }\n format.json { render json: @sport_odd.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_seasons\n @seasons = Campground.find(params[:campground_id]).seasons\n end", "def update\n @studio = Studio.find(params[:id])\n\n respond_to do |format|\n if @studio.update_attributes(params[:studio])\n format.html { redirect_to studios_path, :notice => 'Studio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @studio.errors, :event => :unprocessable_entity }\n end\n end\n end", "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def update\n @team = Team.find(params[:team_id])\n @sprint = @team.sprints.find(params[:id])\n\n respond_to do |format|\n if @sprint.update_attributes(params[:sprint])\n format.html { redirect_to [@sprint.team, @sprint], notice: 'Sprint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sprint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sprint.update!(sprint_params)\n json_response(@sprint)\n end", "def update\n @season = Season.find(params[:season_id])\n @week = Week.find(params[:id])\n\n respond_to do |format|\n if @week.update_attributes(params[:week])\n format.html { redirect_to(@week, :notice => 'Week was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @week.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lab_seminar.update(lab_seminar_params)\n format.html { redirect_to @lab_seminar, notice: 'Seminar was successfully updated.' }\n format.json { render :show, status: :ok, location: @lab_seminar }\n else\n format.html { render :edit }\n format.json { render json: @lab_seminar.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@game = Game.find(params[:id])\n\n respond_to do |format|\n #if @game.update_attributes(params[:game])\n if @game.update_attributes(game_params)\n format.html { redirect_to(season_game_path(@game.season_id, @game), :notice => 'Game was successfully updated.') }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @game.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_season\n @season = @serial.seasons.find_by(number: params[:id])\n end", "def update\n @order_season = OrderSeason.find(params[:id]) # Get the order season\n @pickup_dates = PickupDate.where(:order_season_id => @order_season.order_season_id) # Get the pickup dates in the order season\n @pickup_date = PickupDate.new # For adding a new pickup date\n\n # Updates the order season if values are correct\n # Returns errors if the values are incorrect\n if @order_season.update_attributes(order_season_params)\n # If current season was checked, unset any other active seasons\n if @order_season.current_season?\n set_active_order_season\n end\n\n # Redirect to index with success message\n flash[:success] = \"#{@order_season.order_season_name} has been updated!\"\n redirect_to order_seasons_url\n else\n render 'edit'\n end\n end", "def update\n respond_to do |format|\n if @game_studio.update(game_studio_params)\n format.html { redirect_to @game_studio, notice: 'Game studio was successfully updated.' }\n format.json { render :show, status: :ok, location: @game_studio }\n else\n format.html { render :edit }\n format.json { render json: @game_studio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @srticle.update(srticle_params)\n format.html { redirect_to @srticle, notice: 'Srticle was successfully updated.' }\n format.json { render :show, status: :ok, location: @srticle }\n else\n format.html { render :edit }\n format.json { render json: @srticle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sports_team.update(sports_team_params)\n format.html { redirect_to @sports_team, notice: 'Sports team was successfully updated.' }\n format.json { render :show, status: :ok, location: @sports_team }\n else\n format.html { render :edit }\n format.json { render json: @sports_team.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @swatch.update(swatch_params)\n format.html { redirect_to @swatch, notice: 'Swatch was successfully updated.' }\n format.json { render :show, status: :ok, location: @swatch }\n else\n format.html { render :edit }\n format.json { render json: @swatch.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_season\n @season = Season.find(params[:id])\n unless @logged_in.update_site?\n @season.readonly!\n end\n end", "def update\n respond_to do |format|\n if @sproject.update(sproject_params)\n format.html { redirect_to @sproject, notice: 'Sproject was successfully updated.' }\n format.json { render :show, status: :ok, location: @sproject }\n else\n format.html { render :edit }\n format.json { render json: @sproject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @snowfall.update(snowfall_params)\n format.html { redirect_to @snowfall, notice: 'Snowfall was successfully updated.' }\n format.json { render :show, status: :ok, location: @snowfall }\n else\n format.html { render :edit }\n format.json { render json: @snowfall.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stage = Stage.find(params[:id])\n\n if @stage.update_attributes(params[:stage])\n head :no_content\n else\n format.json { render json: @stage.errors, status: :unprocessable_entity }\n end\n end", "def update\n respond_to do |format|\n if @nautical_sport.update(nautical_sport_params)\n format.html { redirect_to @nautical_sport, notice: 'Nautical sport was successfully updated.' }\n format.json { render :show, status: :ok, location: @nautical_sport }\n else\n format.html { render :edit }\n format.json { render json: @nautical_sport.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_season\n id = season_params[:id]\n @season = ::Season.find(id)\n authorize_action_for @season\n end", "def update\n respond_to do |format|\n if @sprint.update(sprint_params)\n format.html {redirect_to sprints_path, notice: 'Sprint was successfully updated.'}\n format.json {render :show, status: :ok, location: @sprint}\n else\n format.html {render :edit}\n format.json {render json: @sprint.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end", "def update\n respond_to do |format|\n if @team_year.update(team_year_params)\n format.html { redirect_to @team_year, notice: 'Team year was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @team_year.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @socio_serasa.update(socio_serasa_params)\n format.html { redirect_to @socio_serasa, notice: 'Socio serasa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_serasa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sproject = current_user.sprojects.find(params[:id])\n\n respond_to do |format|\n if @sproject.update_attributes(params[:sproject])\n format.html { redirect_to @sproject, notice: 'Sproject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sproject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stable = Stable.find(params[:id])\n\n respond_to do |format|\n if @stable.update_attributes(params[:stable])\n format.html { redirect_to @stable, notice: 'Stable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solidarity.update(solidarity_params)\n format.html { redirect_to @solidarity, notice: 'Solidarity was successfully updated.' }\n format.json { render :show, status: :ok, location: @solidarity }\n else\n format.html { render :edit }\n format.json { render json: @solidarity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @nightclub.update(nightclub_params)\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @round = @season.rounds.find(params[:id])\n\n respond_to do |format|\n if @round.update_attributes(params[:round])\n flash[:notice] = 'Round was successfully updated.'\n format.html { redirect_to season_round_path(@round.season, @round) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @round.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stage.update(stage_params)\n format.html { redirect_to @stage, notice: 'Stage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to club_path(@club), notice: 'Mannschaft wurde aktualisiert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sprint = Sprint.find(params[:id])\n respond_to do |format|\n if @sprint.update_attributes(params[:sprint])\n format.html { redirect_to @sprint, notice: 'Sprint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sprint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n team_name = params[:name]\n team_description = params[:description]\n team_id = params[:id]\n\n respond_to do |format|\n if OkrTeam.where(id: team_id).update_all(name: team_name, description: team_description)\n format.json { render json: 'Team is updated successfully!', status: :ok }\n else\n format.json { render json: 'Error!', status: :unprocessable_entity }\n end\n end\n end", "def update\n streak, success = jsonapi_update.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\n end\n end", "def update\r\n @stage = Stage.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @stage.update_attributes(params.required(:stage).permit!)\r\n format.html {redirect_to @stage, :notice => 'Stage was successfully updated.'}\r\n format.json {head :no_content}\r\n else\r\n format.html {render :action => \"edit\"}\r\n format.json {render :json => @stage.errors, :status => :unprocessable_entity}\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @games_team.update(games_team_params)\n format.html { redirect_to @games_team, notice: 'Games team was successfully updated.' }\n format.json { render :show, status: :ok, location: @games_team }\n else\n format.html { render :edit }\n format.json { render json: @games_team.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @statusproject = Statusproject.find(params[:id])\n\n respond_to do |format|\n if @statusproject.update_attributes(params[:statusproject])\n flash[:notice] = 'Statusproject was successfully updated.'\n format.html { redirect_to(@statusproject) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @statusproject.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @socio.update(socio_params)\n format.html { redirect_to @socio, notice: 'Socio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stage.update(stage_params)\n format.html { redirect_to @stage, notice: 'Stage was successfully updated.' }\n format.json { render :show, status: :ok, location: @stage }\n else\n format.html { render :edit }\n format.json { render json: @stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:id])\n\n if @team.update_attributes(params[:team])\n head :no_content\n else\n render json: @team.errors, status: :unprocessable_entity\n end\n end", "def update\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to([@club, @team], :notice => 'Team was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @episode.update(episode_params)\n format.html { redirect_to series_path(@series), notice: 'Episode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @episode.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update_attributes(event_params)\n format.html { redirect_to [@organization, @season, @event], notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def season_params\n params.require(:season).permit(:id, :name, :current, :active, :start_date, :game_duration)\n end", "def update # rubocop:disable Metrics/AbcSize\n respond_to do |format|\n if @studio.update(studio_params)\n format.html { redirect_to admin_studios_path, notice: 'Studio was successfully updated.' }\n format.json { render :show, status: :ok, location: @studio }\n else\n format.html { render :edit }\n format.json { render json: @studio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sport_event.update(sport_event_params)\n format.html { redirect_to @sport_event, notice: 'Sport event was successfully updated.' }\n format.json { render :show, status: :ok, location: @sport_event }\n else\n format.html { render :edit }\n format.json { render json: @sport_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sportsfield = Sportsfield.find(params[:id])\n\n respond_to do |format|\n if @sportsfield.update_attributes(params[:sportsfield])\n format.html { redirect_to @sportsfield, notice: 'Sportsfield was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sportsfield.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @science.update(science_params)\n format.html { redirect_to @science, notice: 'Science was successfully updated.' }\n format.json { render :show, status: :ok, location: @science }\n else\n format.html { render :edit }\n format.json { render json: @science.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n if @sprint.update_attributes(params[:sprint])\n format.html { redirect_to [:admin, @sprint], notice: 'Sprint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sprint.errors, status: :unprocessable_entity }\n end\n end\n end", "def season_update_league_teams(leagueId)\n LeaguesHelper::update_teams(League.find(leagueId), Params.season+1)\n return true\n end", "def update\n respond_to do |format|\n if @game.update(game_params)\n @games = current_club_player.games\n format.html { redirect_to dashboard_path, notice: 'Game was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @episode = @series.episodes.find(params[:id])\n\n respond_to do |format|\n if @episode.update_attributes(params[:episode])\n format.html { redirect_to [@series, @episode], notice: 'Episode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @episode.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sprint.update(sprint_params)\n format.html { redirect_to project_phase_path(@project.id, @phase.id), notice: 'Sprint was successfully updated.' }\n format.json { render :show, status: :ok, location: @sprint }\n else\n format.html { render :edit }\n format.json { render json: @sprint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if :opr == 'edit'\n update\n else\n @team = Team.find_by_id(params[:id])\n @team.update_attributes({:id => params[:id], :name => params[:name], :status => params[:status]})\n\n if request.xhr?\n render :json => @team\n end\n end\n end", "def update\n respond_to do |format|\n if @current_stage.update_attributes(params[:stage])\n format.html { redirect_to @current_stage, notice: 'Stage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @current_stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sprint.update_attributes(params[:sprint])\n\n respond_with(@sprint)\n end", "def update\n respond_to do |format|\n if @team_year.update(team_year_params)\n format.html { redirect_to @team_year, notice: 'Team year was successfully updated.' }\n format.json { render :show, status: :ok, location: @team_year }\n else\n format.html { render :edit }\n format.json { render json: @team_year.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n official = Official.find(params[:id])\n if official.update(official_params)\n render json: official, status: 200, location: [:api, official]\n else\n failed_to_update(official, \"official\")\n end\n end", "def update\n @rink_league = RinkLeague.find(params[:id])\n\n respond_to do |format|\n if @rink_league.update_attributes(params[:rink_league])\n format.html { redirect_to @rink_league, notice: 'Rink league was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rink_league.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sour.update(sour_params)\n format.html { redirect_to swits_path, notice: 'sour <3.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sour.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stage_drymass = StageDrymass.find(params[:id])\n\n respond_to do |format|\n if @stage_drymass.update_attributes(params[:stage_drymass])\n format.html { redirect_to @stage_drymass, notice: 'Stage drymass was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stage_drymass.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @runway_season = Runway::Season.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runway_season }\n end\n end", "def update\n respond_to do |format|\n if @sprint.update(sprint_params)\n format.html { redirect_to project_phase_sprint_path(@project.id, @phase.id, @sprint), notice: 'Sprint was successfully updated.' }\n format.json { render :show, status: :ok, location: @sprint }\n else\n format.html { render :edit }\n format.json { render json: @sprint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n Rails.logger.info params\n \n # @league = League.find(params[:name])\n respond_to do |format|\n if @league.update(league_params)\n format.html { redirect_to @league, notice: 'League was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @league.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n if @specie.update_attributes(params[:specie])\n format.html { redirect_to @specie, notice: 'Specie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specie.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_admin_season\n @admin_season = Season.find(params[:id])\n end", "def update\n respond_to do |format|\n if @socio.update(socio_params)\n format.html { redirect_to @socio, notice: 'Socio modificado com sucesso.' }\n format.json { render :show, status: :ok, location: @socio }\n else\n format.html { render :edit }\n format.json { render json: @socio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n if @socio.update_attributes(params[:socio])\n format.html { redirect_to @socio, :notice => 'Socio atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @socio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def seasonal_params\n params.require(:seasonal).permit(:season, :seasonYear, :piecePay, :employee_id, :verified, :seasonals_id)\n end", "def update\n respond_to do |format|\n if @league.update(league_params)\n format.html { redirect_to @league, notice: 'League was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @league.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @science_instance.update(science_instance_params)\n format.html { redirect_to @science_instance, notice: 'Science instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @science_instance }\n else\n format.html { render :edit }\n format.json { render json: @science_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sticker = Sticker.find(params[:id])\n \n respond_to do |format|\n if @sticker.update_attributes(params[:sticker])\n format.html { redirect_to(@sticker, :notice => 'Sticker was successfully updated.') }\n format.json { render :json => @sticker.to_json }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sticker.errors.to_json }\n format.xml { render :xml => @sticker.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @floor_stage.update(floor_stage_params)\n format.html { redirect_to @floor_stage, notice: 'Stage was successfully updated.' }\n format.json { render :show, status: :ok, location: @floor_stage }\n else\n format.html { render :edit }\n format.json { render json: @floor_stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def season_params\n params.require(:season).permit(:description, :date, :number, :serial_id)\n end", "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end", "def update\n respond_to do |format|\n if @bracket_golfer.update(bracket_golfer_params)\n format.html { redirect_to @bracket_golfer, notice: 'Bracket golfer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bracket_golfer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_outcome.update(api_v1_outcome_params)\n format.html { redirect_to @api_v1_outcome, notice: 'Outcome was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_outcome }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_outcome.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sick.update(sick_params)\n format.html { redirect_to @sick, notice: 'Sick was successfully updated.' }\n format.json { render :show, status: :ok, location: @sick }\n else\n format.html { render :edit }\n format.json { render json: @sick.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @series = Series.find(params[:id])\n\n respond_to do |format|\n if @series.update_attributes(params[:series])\n format.html { redirect_to @series, notice: 'Series se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @series.errors, status: :unprocessable_entity }\n end\n end\n end", "def season_params\n params.permit(:id, :format, :game_id, :filters => [:season_id, :game_id])\n end", "def update\n @swim_team = SwimTeam.find(params[:id])\n\n respond_to do |format|\n if @swim_team.update_attributes(params[:swim_team])\n format.html { redirect_to swim_teams_path(), notice: 'Swim team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @swim_team.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @games_of_week.update(games_of_week_params)\n format.html { redirect_to @games_of_week, notice: 'Games of week was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @games_of_week.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @scool.update(scool_params)\n format.html { redirect_to @scool, notice: 'Scool was successfully updated.' }\n format.json { render :show, status: :ok, location: @scool }\n else\n format.html { render :edit }\n format.json { render json: @scool.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7574825", "0.7466397", "0.73731536", "0.7247074", "0.72115296", "0.7066464", "0.6906128", "0.67000747", "0.6453101", "0.6453101", "0.6453101", "0.6453101", "0.63932765", "0.6279933", "0.6277337", "0.6263373", "0.625206", "0.62090826", "0.62006545", "0.6170269", "0.61466616", "0.6141965", "0.6139904", "0.6135079", "0.61301756", "0.61292505", "0.612153", "0.6102923", "0.6102318", "0.60988194", "0.6059312", "0.60406554", "0.60298824", "0.60266024", "0.6024376", "0.6010858", "0.6007859", "0.6003166", "0.59821564", "0.5976168", "0.5972762", "0.5971719", "0.5969809", "0.59697676", "0.596157", "0.5958314", "0.59562963", "0.59300596", "0.59294", "0.59237736", "0.5921789", "0.5918346", "0.59157366", "0.59157366", "0.59140825", "0.59138757", "0.59117633", "0.5907224", "0.59042925", "0.59005255", "0.5900399", "0.5895524", "0.589429", "0.589169", "0.58884615", "0.5882357", "0.58809", "0.58791107", "0.58783615", "0.5877406", "0.58729404", "0.5871757", "0.5869543", "0.58690566", "0.58676213", "0.5864891", "0.5864017", "0.58631235", "0.58630526", "0.58617866", "0.5856803", "0.5850715", "0.58462447", "0.5845872", "0.5845674", "0.58434963", "0.5838068", "0.58356166", "0.5834983", "0.583277", "0.5828518", "0.5826406", "0.58241975", "0.5823457", "0.5822948", "0.5822091", "0.5821595", "0.58215004", "0.582069", "0.5819181" ]
0.753143
1
DELETE /seasons/1 DELETE /seasons/1.json
def destroy if @season @season.destroy render json: {success: "true", message:"Season was successfully deleted", series: @serial} else render json: {success: "false", message:"Season doesn't exists", series: @serial} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @season = Season.find(params[:id])\n @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @season = Season.find(params[:id])\n # @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @runway_season = Runway::Season.find(params[:id])\n @runway_season.destroy\n\n respond_to do |format|\n format.html { redirect_to runway_seasons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @season.destroy\n respond_to do |format|\n format.html { redirect_to seasons_url, notice: 'Season was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @guardseason = Guardseason.find(params[:id])\n @guardseason.destroy\n\n respond_to do |format|\n format.html { redirect_to guardseasons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @batting_season = BattingSeason.find(params[:id])\n @batting_season.destroy\n\n respond_to do |format|\n format.html { redirect_to batting_seasons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seasonal.destroy\n respond_to do |format|\n format.html { redirect_to seasonals_url, notice: 'Seasonal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@season = Season.find(params[:id])\n @season.destroy\n\n respond_to do |format|\n format.html { redirect_to(seasons_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @admin_season.destroy\n respond_to do |format|\n format.html { redirect_to admin_seasons_url, success: 'Season was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @season.destroy\n end", "def destroy\n #@game = Game.find(params[:id])\n @game.destroy\n\n respond_to do |format|\n format.html { redirect_to(season_games_path(params[:season_id])) }\n format.xml { head :ok }\n end\n end", "def destroy\n #@team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(season_teams_path(params[:season_id])) }\n format.xml { head :ok }\n end\n end", "def destroy\n @episode.destroy\n respond_to do |format|\n format.html { redirect_to serial_season_episodes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nightclub.destroy\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sport_odd.destroy\n respond_to do |format|\n format.html { redirect_to sport_odds_url, notice: 'Sport odd was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @statusproject = Statusproject.find(params[:id])\n @statusproject.destroy\n\n respond_to do |format|\n format.html { redirect_to(statusprojects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @game_studio.destroy\n respond_to do |format|\n format.html { redirect_to game_studios_url, notice: 'Game studio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @season = Season.find(params[:season_id])\n @week = Week.find(params[:id])\n @week.destroy\n\n respond_to do |format|\n format.html { redirect_to season_weeks_path(@season) }\n format.xml { head :ok }\n end\n end", "def destroy\n @my_studio_client = MyStudio::Client.find(params[:id])\n @my_studio_client.destroy\n\n respond_to do |format|\n format.html { redirect_to my_studio_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @stage_drymass = StageDrymass.find(params[:id])\n @stage_drymass.destroy\n\n respond_to do |format|\n format.html { redirect_to stage_drymasses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chapter_view.destroy\n respond_to do |format|\n format.html { redirect_to :controller => 'seasons', :action => 'show', :id => Season.find(Chapter.find(@chapter_view.chapter_id).season_id)}\n format.json { head :no_content }\n end\n end", "def destroy\n @nightclub = Nightclub.find(params[:id])\n @nightclub.destroy\n\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @games_of_week.destroy\n respond_to do |format|\n format.html { redirect_to games_of_weeks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @club_path = ClubPath.find(params[:id])\n @club_path.destroy\n\n respond_to do |format|\n format.html { redirect_to club_paths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @studio = Studio.find(params[:id])\n @studio.destroy\n\n respond_to do |format|\n format.html { redirect_to session.delete(:return_to) }\n format.json { head :no_content }\n end\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bracket_golfer.destroy\n respond_to do |format|\n format.html { redirect_to bracket_golfers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @game_title.destroy\n respond_to do |format|\n format.html { redirect_to game_titles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @socioeconomic_study = SocioeconomicStudy.find(params[:id])\n @socioeconomic_study.destroy\n\n respond_to do |format|\n format.html { redirect_to socioeconomic_studies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sproject.destroy\n respond_to do |format|\n format.html { redirect_to sprojects_url, notice: 'Sproject was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n puts @game.date.to_s\n @game.destroy\n respond_to do |format|\n format.html { redirect_to games_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seo_datum = SeoDatum.find(params[:id])\n @seo_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to seo_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @station = Station.find(params[:id])\n @station.destroy\n\n respond_to do |format|\n format.html { redirect_to stations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @studio.destroy\n respond_to do |format|\n format.html { redirect_to admin_studios_path, notice: 'Studio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @studio_client.destroy\n respond_to do |format|\n format.html { redirect_to studio_clients_url, notice: 'Studio client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gamesofweek.destroy\n respond_to do |format|\n format.html { redirect_to gamesofweeks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sport_link.destroy\n respond_to do |format|\n format.html { redirect_to sport_links_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hwm_studio = HwmStudio.find(params[:id])\n @hwm_studio.destroy\n\n respond_to do |format|\n format.html { redirect_to hwm_studios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shelf.destroy\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @srticle.destroy\n respond_to do |format|\n format.html { redirect_to srticles_url, notice: 'Srticle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @c_rodinny_stav.destroy\n respond_to do |format|\n format.html { redirect_to c_rodinny_stavs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @station.destroy\n respond_to do |format|\n format.html { redirect_to stations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @go_slim = GoSlim.find(params[:id])\n @go_slim.destroy\n\n respond_to do |format|\n format.html { redirect_to go_slims_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @line_station = LineStation.find(params[:id])\n @line_station.destroy\n\n respond_to do |format|\n format.html { redirect_to line_stations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @study = Study.find(params[:id])\n @study.destroy\n\n respond_to do |format|\n format.html { redirect_to studies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nautical_sport.destroy\n respond_to do |format|\n format.html { redirect_to nautical_sports_url, notice: 'Nautical sport was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dailyStanding = DailyStanding.find(params[:id])\n @dailyStanding.destroy\n\n respond_to do |format|\n format.html { redirect_to dailyStanding_url }\n format.json { head :ok }\n end\n end", "def destroy\n @socio_serasa.destroy\n respond_to do |format|\n format.html { redirect_to socio_serasas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stable = Stable.find(params[:id])\n @stable.destroy\n\n respond_to do |format|\n format.html { redirect_to stables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sproject = current_user.sprojects.find(params[:id])\n @sproject.destroy\n\n respond_to do |format|\n format.html { redirect_to sprojects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lab_seminar.destroy\n respond_to do |format|\n format.html { redirect_to lab_seminars_url, notice: 'Seminar was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @episode.destroy\n respond_to do |format|\n format.html { redirect_to series_episodes_url(@series) }\n format.json { head :no_content }\n end\n end", "def destroy\n @series_statement.destroy\n\n respond_to do |format|\n format.html { redirect_to series_statements_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @slab = Slab.find(params[:id])\n @slab.destroy\n\n respond_to do |format|\n format.html { redirect_to slabs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rink_league = RinkLeague.find(params[:id])\n @rink_league.destroy\n\n respond_to do |format|\n format.html { redirect_to rink_leagues_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tea_club.destroy\n respond_to do |format|\n format.html { redirect_to tea_clubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @division = Division.find(params[:id])\n @division.destroy\n\n respond_to do |format|\n format.html { redirect_to league_divisions_url(params[:league_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @snowfall.destroy\n respond_to do |format|\n format.html { redirect_to snowfalls_url, notice: 'Snowfall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @community_health_station = CommunityHealthStation.find(params[:id])\n @community_health_station.destroy\n\n respond_to do |format|\n format.html { redirect_to community_health_stations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @theory_day.destroy\n respond_to do |format|\n format.html { redirect_to theory_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @socio_rg.destroy\n respond_to do |format|\n format.html { redirect_to socio_rgs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @team_has_d.destroy\n respond_to do |format|\n format.html { redirect_to team_has_ds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @team = @club.teams.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to club_teams_url(@club.id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @soda.destroy\n respond_to do |format|\n format.html { redirect_to sodas_url, notice: 'Soda was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sportsfield = Sportsfield.find(params[:id])\n @sportsfield.destroy\n\n respond_to do |format|\n format.html { redirect_to sportsfields_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @strosek.destroy\n respond_to do |format|\n format.html { redirect_to stroseks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tv_series.destroy\n respond_to do |format|\n format.html { redirect_to tv_series_url, notice: \"Tv serie was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @albumseven.destroy\n respond_to do |format|\n format.html { redirect_to albumsevens_url, notice: 'Albumseven was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @game.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @harvest = Harvest.find(params[:id])\n @harvest.destroy\n\n respond_to do |format|\n format.html { redirect_to harvests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @harvest = Harvest.find(params[:id])\n @harvest.destroy\n\n respond_to do |format|\n format.html { redirect_to harvests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @socio = Socio.find(params[:id])\n @socio.destroy\n\n respond_to do |format|\n format.html { redirect_to socios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @socio = Socio.find(params[:id])\n @socio.destroy\n\n respond_to do |format|\n format.html { redirect_to socios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @team_division = TeamDivision.find(params[:id])\n @team_division.destroy\n\n respond_to do |format|\n format.html { redirect_to team_divisions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @scene.destroy\n respond_to do |format|\n format.html { redirect_to scenes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @design_version.destroy\n respond_to do |format|\n format.html { redirect_to design_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @episode_status = EpisodeStatus.find(params[:id])\n @episode_status.destroy\n\n respond_to do |format|\n format.html { redirect_to episode_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to contest_games_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @science.destroy\n respond_to do |format|\n format.html { redirect_to sciences_url, notice: 'Science was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end", "def destroy\n @study_site.destroy\n respond_to do |format|\n format.html { redirect_to study_sites_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @team_year.destroy\n respond_to do |format|\n format.html { redirect_to team_years_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @game_tournament = GameTournament.find(params[:id])\n @game_tournament.destroy\n\n respond_to do |format|\n format.html { redirect_to game_tournaments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @specie = Specie.find(params[:id])\n @specie.destroy\n\n respond_to do |format|\n format.html { redirect_to species_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baz35.destroy\n respond_to do |format|\n format.html { redirect_to baz35s_url, notice: \"Baz35 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @episode.destroy\n respond_to do |format|\n format.html { redirect_to episodes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: \"Club was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @game_set.destroy\n respond_to do |format|\n format.html { redirect_to game_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stuff = Stuff.find(params[:id])\n @stuff.destroy\n\n respond_to do |format|\n format.html { redirect_to stuffs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @exercice = Exercice.find(params[:id])\n @exercice.destroy\n\n respond_to do |format|\n format.html { redirect_to exercices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stance.destroy\n respond_to do |format|\n format.html { redirect_to stances_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stance.destroy\n respond_to do |format|\n format.html { redirect_to stances_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tv_series.destroy\n respond_to do |format|\n format.html { redirect_to tv_series_index_url, notice: 'Сериал удален!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.8161093", "0.81420696", "0.8104751", "0.79520655", "0.79472625", "0.7888057", "0.7822919", "0.78088355", "0.7733747", "0.75669867", "0.73643905", "0.72225726", "0.71602285", "0.71379143", "0.7083086", "0.7067304", "0.7053561", "0.69905496", "0.6983579", "0.6983485", "0.6972395", "0.69518715", "0.6902155", "0.690007", "0.6880346", "0.68756545", "0.687068", "0.687068", "0.6869721", "0.6866942", "0.68662566", "0.68646985", "0.6841069", "0.68409497", "0.6838647", "0.68381435", "0.6825552", "0.68245673", "0.6824392", "0.6819819", "0.6817312", "0.6816278", "0.68136126", "0.6813552", "0.6806588", "0.67938083", "0.6791034", "0.6788389", "0.6788389", "0.6771212", "0.67621964", "0.67619103", "0.6759921", "0.6757856", "0.6755574", "0.67550284", "0.6754034", "0.6753491", "0.675033", "0.67498064", "0.6744425", "0.6744368", "0.67378753", "0.67100817", "0.6709735", "0.67070085", "0.67057294", "0.67042035", "0.6701926", "0.67008257", "0.6699563", "0.6693465", "0.6693206", "0.66903037", "0.66811967", "0.667429", "0.667429", "0.6673015", "0.6673015", "0.6670578", "0.66696745", "0.6667407", "0.66662425", "0.6664983", "0.6664075", "0.66640294", "0.66624516", "0.6660435", "0.6660165", "0.6660045", "0.6659121", "0.6658908", "0.66576636", "0.66563547", "0.66563225", "0.6654497", "0.665308", "0.665308", "0.66514826", "0.6649233" ]
0.7468185
10
Use callbacks to share common setup or constraints between actions.
def set_season @season = @serial.seasons.find_by(number: params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def season_params params.require(:season).permit(:description, :date, :number, :serial_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "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 filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def 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.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004", "0.6290563", "0.6284484", "0.62436926", "0.6239928", "0.62184125", "0.62158304", "0.6210187", "0.6194002", "0.61786795", "0.61759156", "0.617342", "0.6162248", "0.61528504", "0.61527", "0.6146735", "0.6122714", "0.61169004", "0.61082125", "0.61052656", "0.6091036", "0.60807735", "0.6070328", "0.60634184", "0.60213035", "0.6017676", "0.6013606", "0.601112", "0.6007318", "0.6007318", "0.6001461", "0.6001135", "0.59966296", "0.5992013", "0.59919006", "0.599182", "0.5980991", "0.59676576", "0.5960269", "0.59588194", "0.59585214", "0.59578323", "0.5953503", "0.5952524", "0.59432703", "0.5939858", "0.59388995", "0.59388995", "0.5933866", "0.5930038", "0.5925672", "0.5924214", "0.59169805", "0.59106255", "0.5910254", "0.59086037", "0.5906149", "0.5898294", "0.58981514", "0.5896171", "0.58944154", "0.58943397", "0.5892325", "0.5887239", "0.58842856", "0.5880209", "0.5874584", "0.58694917", "0.5868719", "0.58669394", "0.5866552", "0.58662945", "0.5864085", "0.58623236", "0.5862258", "0.58597904", "0.58579135", "0.58542645", "0.5853335", "0.58517563", "0.5850614" ]
0.0
-1
GET /user_logins GET /user_logins.json
def index @user_logins = UserLogin.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n @users = User.all\n render json: User.all\n end", "def index\n @log_ins = LogIn.all\n end", "def index\n @logins = Login.all\n end", "def auto_login\n render json: logged_in_user\n end", "def index\n # @logins = Login.all\n end", "def index\n @users = User.all\n\n @user = User.find_by_id(session[:user_id])\n @logged_in = true if @user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def get_user_logins_with_http_info(user_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserApi.get_user_logins ...'\n end\n # verify the required parameter 'user_id' is set\n if @api_client.config.client_side_validation && user_id.nil?\n fail ArgumentError, \"Missing the required parameter 'user_id' when calling UserApi.get_user_logins\"\n end\n # resource path\n local_var_path = '/user/users/{user_id}/logins'.sub('{' + 'user_id' + '}', user_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\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 => 'UserLoginsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserApi#get_user_logins\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n if not check_logged_in then\n return\n end\n @users = User.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n @logins = Login.all\n #cookies[:current_user] = \"user\"\n login_user = Login.find_by_id(session[:login_id])\n end", "def index\n @account_logins = AccountLogin.all\n end", "def index\n r = @api.get_users\n response = JSON.parse(r.body)\n if r.code == 200\n @users = response\n else\n redirect_to login_sign_in_admin_path, alert: response['message']\n end\n end", "def index\n if current_user.try(:admin?)\n @checkins = Checkin.all\n @checkins_for_json = current_user.checkins\n elsif user_signed_in?\n @checkins = current_user.checkins\n @checkins_for_json = @checkins\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @checkins_for_json }\n end\n end", "def process_login\n user = User.where(login: params[:user][:login], password: params[:user][:password]).first\n respond_with :api, json:!user.nil?\n end", "def show\n # while accesing a customer a user we'll be able to see the page with logins associated to \n # that concrete customer\n api = SaltEdge.new(ENV[\"salt_edge_app_id\"], ENV[\"salt_edge_secret\"], \"private.pem\")\n r = api.simple_request(\"GET\", \"https://www.saltedge.com/api/v4/logins/\")\n cust_id = current_user.customers.first.cust_id\n r[\"data\"].each do |login|\n if cust_id == login[\"customer_id\"]\n Login.where(log_id: login[\"id\"]).first_or_create do |log|\n log.provider_name = login[\"provider_name\"]\n log.customer_id = current_user.customers.first.id\n end\n end\n end \n @logins = @customer.logins\n end", "def index\n @users = []\n User.all.each do |u|\n if u.online?\n @users.append({user: u, sign_in_at: u.attributes['current_sign_in_at']})\n end\n end\n\n render json: @users.to_json\n end", "def users(args = {})\n get(\"/users.json\",args)\n end", "def list_users\n self.class.get('/users')\n end", "def user_list\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/users/\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"Here is a list of users...\"\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend", "def index\n @users = LDAP::User.all.sort_by(&:login)\n render json: @users\n end", "def get_current_logged_in_user \n get(\"/users.json/current\")\nend", "def get_current_logged_in_user \n get(\"/users.json/current\")\nend", "def index\n @session_logins = SessionLogin.all\n end", "def list\r\n users = User.all\r\n render json: users\r\n end", "def login \n render json: User.first\n end", "def get_user_entries\n user_entry = Entry.where(user_id: params[:user])\n render json: EntrySerializer.new(user_entry).to_serialized_json\n end", "def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end", "def index\n @users = User.order(\"login ASC\")\n @users = @users.paginate :page => params[:page], :per_page => users_per_page\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def autologin\n token = request.headers['Authorization']\n user_id = JWT.decode(token, 'secret')[0][\"userId\"]\n user = User.find(user_id)\n render json: user.user_information\n end", "def index\n @user_session = user_session\n @users = User.all \n respond_to do |format|\n format.html\n format.json { render json: @users}\n end\n end", "def get_user_logins(user_id, opts = {})\n data, _status_code, _headers = get_user_logins_with_http_info(user_id, opts)\n data\n end", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def following_logins\n return [] if oauth_token.blank?\n\n response = api(url: \"/users/#{login}/following\")\n\n if response.success?\n response.data.map { |d| d[\"login\"] }\n else\n update_attributes(oauth_token: nil) and []\n end\n end", "def index\n users = User.all\n json_response(users)\n end", "def login\n @user = User.authenticate credentials[:email], credentials[:password]\n if @user # serializer makes it easier to return json, in this case the token\n render json: @user, serializer: LoginUserSerializer, root: 'user'\n else\n head :unauthorized # if authentication case this is executed\n end\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def index\n @users = User.all\n authorize @users\n\n render json: @users\n end", "def list\n render json: User.all\n end", "def login\n user = User.find_by(username: user_params[:username])\n if user && user.authenticate(user_params[:password])\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: \"Wrong Username or Password!\"}\n end\n end", "def index\r\n users = User.all\r\n render json: users\r\n end", "def index\n @myusers = Myuser.all\n\n render json: @myusers\n end", "def login\n user = User.find_by(username: params[\"username\"])\n if user && user.authenticate(params[\"password\"])\n session[:current_user_id] = user.id\n render json: User.to_hash(user)\n else\n render json: nil\n end\n end", "def index \n #Show all users \n @users = User.all\n render json: @users.as_json(only: [:id, :first_name, :last_name, :email, :business_name, :business_verticals, :business_neighborhood, :created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at])\n end", "def login\n\n if params[:username] && params[:token]\n @user = token_based_login\n end\n\n if @user\n set_session_headers\n render json: { username: @user.username, auth_token: get_md5_digest(params[:username]), logged_in: true }\n else\n render json: { logged_in: false }, status: 401\n end\n end", "def index\n @users = User.all\n render json: @users, status: :ok\n end", "def index\n @users = User.all\n logger.debug(\"user index\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\r\n user = authenticate\r\n if user\r\n clients = Client.where('clientof = ?', user.id)\r\n render json: {clients: clients, message: 'Success', status: :ok}\r\n else\r\n render json: {message: 'Invalid token', status: :unauthorized}\r\n end\r\n end", "def show_user\n usernames = params.require(:usernames)\n\n identities = Hash[User.where(username: usernames).map { |u| [u.username, u.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]] }]\n\n render json: identities\n end", "def logged_in\n return bad_request unless request.format.json? or request.format.js?\n @response = {:logged_in => logged_in?}\n json_response\n end", "def index\n users = User.all\n render json: { users: users }, status: :ok\n end", "def index\n @users = @users.order('created_at DESC').page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @users, :except => [:perishable_token, :persistence_token, :email, :single_access_token, :last_login_ip, :current_login_ip, :crypted_password, :password_salt] }\n end\n end", "def get_users(request); end", "def index\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['index']) do\n if params[:ids]\n ids = params[:ids].split(\",\")\n if ids.length <= 10\n @users = User.find(ids)\n @status = 200\n else\n render_error(400, \"too many ids included (max 10)\")\n end\n elsif user_signed_in?\n @status = 200\n @user = current_user\n @user_personal_roll_subdomain = (@user.public_roll and @user.public_roll.subdomain)\n render 'v1/user/show'\n else\n render_error(401, \"current user not authenticated\")\n end\n end\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def index\n @users = User.all\n\n render json: @users\n end", "def list_users(user_id)\n self.class.get(\"/users/#{user_id}\")\n end", "def logged_in\n #checks to see if a current user is available \n \n if @current_user\n render json: {\n logged_in: true,\n user: @current_user\n }\n else \n render json: {\n logged_in: false\n }\n end \n\n end", "def index\n if (!@isLogin)\n return\n end\n @users = User.all\n end", "def index\n respond_to do |format|\n if authorized?\n format.json { render json: User.all }\n else\n format.json { render json: unauthorized, status: :forbidden }\n end\n end\n end", "def user(user_id = nil)\n user_id = username if user_id.nil? || user_id == \"\"\n if user_id.to_i.to_s == user_id.to_s\n users = connection.get(connection.build_url('users', :userids => user_id)).body\n else\n users = connection.get(connection.build_url('users', :logins => user_id)).body\n end\n users.map!{|hash| hash.values.first}\n users.first\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def index\n users = User.all\n render json: users\n end", "def index_invites\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.invited_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end", "def checkins(id = 'self', options = {})\n get(\"users/#{id}/checkins\").checkins\n end", "def index\n validate_login\n @users = User.all\n end", "def index\n if session[:id]\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n else\n flash[:error] = \"You will need to Sign In to view this page.\"\n redirect_to :controller => 'system', :action => 'index'\n end\n end", "def index\n @users = User.all\n render json: @users, status: :ok\n end", "def index\n json_response(User.all) \n end", "def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @users.map(&:as_json) }\n\t\tend\n\tend", "def users(params = {})\n make_get_request('/account/users', params)\n end", "def user_checkins user_id=\"self\", options={}\n response = get(\"/users/#{user_id}/checkins\",options)[\"response\"][\"checkins\"]\n response[\"items\"].map!{|checkin| Foursquared::Response::Checkin.new(self, checkin)} if response[\"items\"]\n response\n end", "def index\n users = User.all \n render json: users \n end", "def index\n if current_user\n @users = User.all\n render \"index_users.json.jb\"\n else\n render json: []\n end\n end", "def recent_login(users)\n\tputs 'starting recent_login, length is ' + users.length.to_s\n\tres = Array.new\n\tlast_month_unform = (Time.current - 30.days).to_s.split(\" \")\n\ttoday_unform = Time.current.to_s.split(\" \")\n\tlast_month = last_month_unform[0] + 'T' + last_month_unform[1]\n\ttoday = today_unform[0] + 'T' + today_unform[1]\n\tusers.each do |person|\n\t\ttmp = person['id'].to_s\n\t\tresponse = TOKEN.get(\"/v2/users/\" + tmp + \"/locations?range[begin_at]=#{last_month},#{today}\").parsed\n\t\tif response.length > 0\n\t\t\tres.push(person)\n\t\tend\n\tend\n\treturn res\nend", "def index\n users = User.all\n render json: users \n end", "def logged_in\n if @current_user\n #this does not return a http status because this is a get request not a post. \n render json:{\n logged_in: true, \n user: @current_user\n }\n else \n render json: {\n logged_in: false\n }\n end\n end", "def list\n get('users')['users']\n end", "def index\n email = AuthenticationHelper::Auth.instance.getEmailFromJWT( request )\n if ( email == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n user = User.find_by(email: email)\n if ( user )\n accounts = Account.where(user_id: user[\"id\"])\n render json: accounts, status: :ok\n else\n render json: :nothing, status: :unprocessable_entity\n end\n end", "def index\n render json: User.all\n end", "def index\n render json: current_org.users\n end", "def login\n if session[:user] != nil then\n logged_in_home_page = home_index_path\n respond_to do |format|\n format.html { redirect_to logged_in_home_page}\n format.json { head :no_content }\n end\n return\n end\n\n @user = User.new\n \n respond_to do |format|\n format.html # login.html.erb\n format.json { render json: @user }\n end\n end", "def login\n\t \t@userr = User.where([\"name = ? and password = ?\", params[:name],params[:password]]).first\n\n\t \tif not @userr.nil?\n\n\t \t\tif not (@userr.roles & Role.find([1, 2])).empty?\n\t \t\t\t@token = @userr.tokens.last\n\t \t\t\t@result = [@userr, @token]\n\t \t\t\trender :json => @result\n\t \t\t\t\n\t \t\telsif not @userr.events.select{ |ev| not ev.Completed and ev.EventDate.to_date + 2 >= Date.today}.empty?\n\t \t\t\t@token = @userr.tokens.last\n\t \t\t\t@result = [@userr, @token]\n\t \t\t\trender :json => @result\n\t \t\telse\n\t \t\t\trender :json => {error:\"There are no events currently active for this user.\"}, :status => :unauthorized\n\t \t\tend\n \t\telse\n\n \t\t\trespond_to do |format|\n \t\t\tformat.html { redirect_to '/login/index' }\n \t\t\tformat.json { render :json => {error:\"Invalid username or password please try again.\"}, :status => :unprocessable_entity }\n \t\tend\n\t\tend\n\tend", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def index\n @users = User.all\n render json: @users\n end", "def user1\n if user = User.where(\"lower(users.login) = ?\", params[:login].downcase).first\n result = {\n :id => user.id,\n :username => user.login,\n :name => user.name,\n :avatar_url => user.avatar_url,\n :location => user.location\n }\n render json: result\n else\n head :not_found\n end\n end", "def index\n @tbl_logins = TblLogin.all\n end" ]
[ "0.6986181", "0.67032623", "0.6487264", "0.64824224", "0.64675814", "0.6439693", "0.6426158", "0.64258075", "0.6420787", "0.6420787", "0.63225", "0.6283208", "0.6228691", "0.616576", "0.615551", "0.6132131", "0.6101082", "0.60807973", "0.60769", "0.6069716", "0.6058729", "0.60409164", "0.60366535", "0.6030892", "0.6030892", "0.6010596", "0.6000077", "0.59942514", "0.59813017", "0.5965841", "0.59563756", "0.5940135", "0.5938798", "0.5934756", "0.592211", "0.592211", "0.5920343", "0.58699995", "0.58379763", "0.5834027", "0.58255994", "0.58164454", "0.5806695", "0.5805398", "0.58000374", "0.5799378", "0.5796449", "0.57864153", "0.5783638", "0.57818216", "0.577651", "0.5764422", "0.5762804", "0.57572675", "0.5751874", "0.57510656", "0.574127", "0.5736888", "0.5733707", "0.5728722", "0.57268375", "0.5724672", "0.5721329", "0.5720695", "0.5716975", "0.5716975", "0.5716975", "0.5716975", "0.5709469", "0.57046884", "0.5704571", "0.5698646", "0.56939924", "0.56929874", "0.56877536", "0.56754196", "0.56738776", "0.5673294", "0.56731397", "0.56726223", "0.5668825", "0.56687933", "0.5667717", "0.5662714", "0.5648105", "0.56471163", "0.5636206", "0.56325185", "0.5627732", "0.5627732", "0.5627732", "0.5627732", "0.5627732", "0.5627732", "0.5627732", "0.5627732", "0.5627732", "0.5627732", "0.56204075", "0.56153584" ]
0.69305927
1
GET /user_logins/1 GET /user_logins/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n @users = User.all\n render json: User.all\n end", "def index\n @user_logins = UserLogin.all\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: logged_in_user\n end", "def login \n render json: User.first\n end", "def get_user_logins_with_http_info(user_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserApi.get_user_logins ...'\n end\n # verify the required parameter 'user_id' is set\n if @api_client.config.client_side_validation && user_id.nil?\n fail ArgumentError, \"Missing the required parameter 'user_id' when calling UserApi.get_user_logins\"\n end\n # resource path\n local_var_path = '/user/users/{user_id}/logins'.sub('{' + 'user_id' + '}', user_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\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 => 'UserLoginsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserApi#get_user_logins\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @log_ins = LogIn.all\n end", "def index\n @logins = Login.all\n #cookies[:current_user] = \"user\"\n login_user = Login.find_by_id(session[:login_id])\n end", "def process_login\n user = User.where(login: params[:user][:login], password: params[:user][:password]).first\n respond_with :api, json:!user.nil?\n end", "def index\n @users = User.all\n\n @user = User.find_by_id(session[:user_id])\n @logged_in = true if @user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def autologin\n token = request.headers['Authorization']\n user_id = JWT.decode(token, 'secret')[0][\"userId\"]\n user = User.find(user_id)\n render json: user.user_information\n end", "def index\n # @logins = Login.all\n end", "def index\n @logins = Login.all\n end", "def get_current_logged_in_user \n get(\"/users.json/current\")\nend", "def get_current_logged_in_user \n get(\"/users.json/current\")\nend", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def user1\n if user = User.where(\"lower(users.login) = ?\", params[:login].downcase).first\n result = {\n :id => user.id,\n :username => user.login,\n :name => user.name,\n :avatar_url => user.avatar_url,\n :location => user.location\n }\n render json: result\n else\n head :not_found\n end\n end", "def user(user_id = nil)\n user_id = username if user_id.nil? || user_id == \"\"\n if user_id.to_i.to_s == user_id.to_s\n users = connection.get(connection.build_url('users', :userids => user_id)).body\n else\n users = connection.get(connection.build_url('users', :logins => user_id)).body\n end\n users.map!{|hash| hash.values.first}\n users.first\n end", "def show\n # while accesing a customer a user we'll be able to see the page with logins associated to \n # that concrete customer\n api = SaltEdge.new(ENV[\"salt_edge_app_id\"], ENV[\"salt_edge_secret\"], \"private.pem\")\n r = api.simple_request(\"GET\", \"https://www.saltedge.com/api/v4/logins/\")\n cust_id = current_user.customers.first.cust_id\n r[\"data\"].each do |login|\n if cust_id == login[\"customer_id\"]\n Login.where(log_id: login[\"id\"]).first_or_create do |log|\n log.provider_name = login[\"provider_name\"]\n log.customer_id = current_user.customers.first.id\n end\n end\n end \n @logins = @customer.logins\n end", "def index\n if not check_logged_in then\n return\n end\n @users = User.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def login\n user = User.find_by(username: params[\"username\"])\n if user && user.authenticate(params[\"password\"])\n session[:current_user_id] = user.id\n render json: User.to_hash(user)\n else\n render json: nil\n end\n end", "def index\n @users = LDAP::User.all.sort_by(&:login)\n render json: @users\n end", "def show\n @user_log = UserLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_log }\n end\n end", "def index\n @account_logins = AccountLogin.all\n end", "def get_user_record\n netid = params['netid']\n url = ENV['OKAPI_URL']\n tenant = ENV['OKAPI_TENANT']\n user = CUL::FOLIO::Edge.patron_record(url, tenant, folio_token, netid)\n Rails.logger.debug(\"mjc12test6: Got FOLIO user #{user.inspect}\")\n render json: user\n end", "def login\n user = User.find_by(username: user_params[:username])\n if user && user.authenticate(user_params[:password])\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: \"Wrong Username or Password!\"}\n end\n end", "def show\n @login = Login.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @login }\n end\n end", "def login\n\t @user = current_user\n\t respond_to do |format|\n\t format.html {render :text => \"#{@user.id}\"}\n\t #format.xml {render :text => \"#{@user.id}\" }\n\t format.json {render :json => \"#{@user.id}\"}\n\t end\n\tend", "def index\n @users = []\n User.all.each do |u|\n if u.online?\n @users.append({user: u, sign_in_at: u.attributes['current_sign_in_at']})\n end\n end\n\n render json: @users.to_json\n end", "def index\n @users = User.order(\"login ASC\")\n @users = @users.paginate :page => params[:page], :per_page => users_per_page\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n r = @api.get_users\n response = JSON.parse(r.body)\n if r.code == 200\n @users = response\n else\n redirect_to login_sign_in_admin_path, alert: response['message']\n end\n end", "def login\n\n if params[:username] && params[:token]\n @user = token_based_login\n end\n\n if @user\n set_session_headers\n render json: { username: @user.username, auth_token: get_md5_digest(params[:username]), logged_in: true }\n else\n render json: { logged_in: false }, status: 401\n end\n end", "def user_list\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/users/\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"Here is a list of users...\"\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend", "def index\n @session_logins = SessionLogin.all\n end", "def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end", "def auto_login\n @token = params[:token]\n # byebug\n user = User.find(JWT.decode(@token, \"put your secret password here\", true, algorithm: 'HS256')[0][\"user_id\"])\n render json: user\n end", "def get_cur_user\n @user = nil\n if is_logged_in session\n @user = User.find_by_sunet(session[:user_hash][\"username\"])\n end\n render json: @user\n end", "def get_cur_user\n @user = nil\n if is_logged_in session\n @user = User.find_by_sunet(session[:user_hash][\"username\"])\n end\n render json: @user\n end", "def index\n @user_session = user_session\n @users = User.all \n respond_to do |format|\n format.html\n format.json { render json: @users}\n end\n end", "def index\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['index']) do\n if params[:ids]\n ids = params[:ids].split(\",\")\n if ids.length <= 10\n @users = User.find(ids)\n @status = 200\n else\n render_error(400, \"too many ids included (max 10)\")\n end\n elsif user_signed_in?\n @status = 200\n @user = current_user\n @user_personal_roll_subdomain = (@user.public_roll and @user.public_roll.subdomain)\n render 'v1/user/show'\n else\n render_error(401, \"current user not authenticated\")\n end\n end\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def loggin\n @user = User.find_by(username: params[:username])\n end", "def login\n\t \t@userr = User.where([\"name = ? and password = ?\", params[:name],params[:password]]).first\n\n\t \tif not @userr.nil?\n\n\t \t\tif not (@userr.roles & Role.find([1, 2])).empty?\n\t \t\t\t@token = @userr.tokens.last\n\t \t\t\t@result = [@userr, @token]\n\t \t\t\trender :json => @result\n\t \t\t\t\n\t \t\telsif not @userr.events.select{ |ev| not ev.Completed and ev.EventDate.to_date + 2 >= Date.today}.empty?\n\t \t\t\t@token = @userr.tokens.last\n\t \t\t\t@result = [@userr, @token]\n\t \t\t\trender :json => @result\n\t \t\telse\n\t \t\t\trender :json => {error:\"There are no events currently active for this user.\"}, :status => :unauthorized\n\t \t\tend\n \t\telse\n\n \t\t\trespond_to do |format|\n \t\t\tformat.html { redirect_to '/login/index' }\n \t\t\tformat.json { render :json => {error:\"Invalid username or password please try again.\"}, :status => :unprocessable_entity }\n \t\tend\n\t\tend\n\tend", "def login\n @user = User.authenticate credentials[:email], credentials[:password]\n if @user # serializer makes it easier to return json, in this case the token\n render json: @user, serializer: LoginUserSerializer, root: 'user'\n else\n head :unauthorized # if authentication case this is executed\n end\n end", "def list_users\n self.class.get('/users')\n end", "def index\n \n @user = User.find(current_user.id) \n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end", "def user_repos1\n addons = Addon.joins(:user).where(\"lower(users.login) = ?\", params[:login].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end", "def logged_in\n #checks to see if a current user is available \n \n if @current_user\n render json: {\n logged_in: true,\n user: @current_user\n }\n else \n render json: {\n logged_in: false\n }\n end \n\n end", "def login\n @user = User.find_by_username(params[:username])\n if @user&.authenticate(params[:password])\n token = JsonWebToken.encode(id: @user.id)\n time = Time.now #+ 24.hours.to_i\n render json: { token: token, last_login_time: time.strftime(\"%m-%d-%Y %H:%M\"),\n user: @user}, status: :ok\n # comment: @user.comment şu şekilde diğerleride çağrılabilir.\n else\n render json: { error: 'Login Unsuccessfull(Invalid username / password)' }, status: :unauthorized\n end\n end", "def users(args = {})\n get(\"/users.json\",args)\n end", "def recent_login(users)\n\tputs 'starting recent_login, length is ' + users.length.to_s\n\tres = Array.new\n\tlast_month_unform = (Time.current - 30.days).to_s.split(\" \")\n\ttoday_unform = Time.current.to_s.split(\" \")\n\tlast_month = last_month_unform[0] + 'T' + last_month_unform[1]\n\ttoday = today_unform[0] + 'T' + today_unform[1]\n\tusers.each do |person|\n\t\ttmp = person['id'].to_s\n\t\tresponse = TOKEN.get(\"/v2/users/\" + tmp + \"/locations?range[begin_at]=#{last_month},#{today}\").parsed\n\t\tif response.length > 0\n\t\t\tres.push(person)\n\t\tend\n\tend\n\treturn res\nend", "def login(username, pwd)\n user = @server.proxy('User')\n logged_in_user_response = user.login({'login' => username, 'password' => pwd})\n #puts \"\\nlogged in user id = \" + logged_in_user_response['id'].to_s\n end", "def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end", "def login\n if session[:user] != nil then\n logged_in_home_page = home_index_path\n respond_to do |format|\n format.html { redirect_to logged_in_home_page}\n format.json { head :no_content }\n end\n return\n end\n\n @user = User.new\n \n respond_to do |format|\n format.html # login.html.erb\n format.json { render json: @user }\n end\n end", "def index\n render json: current_org.users\n end", "def login\n @user = users(:user1)\n post user_session_path, params: { 'user[email]' => @user.email, 'user[password]' => 'password' }\n end", "def index\n @user_logs = UserLog.paginate(:page => params[:page], :per_page => 30).order('created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_logs }\n end\n end", "def perform\n request \"/users/self\" do |json|\n user = json[\"user\"]\n checkin_count = user[\"checkins\"][\"count\"].to_i\n load_checkins(checkin_count)\n end\n end", "def logged_in\n if @current_user\n #this does not return a http status because this is a get request not a post. \n render json:{\n logged_in: true, \n user: @current_user\n }\n else \n render json: {\n logged_in: false\n }\n end\n end", "def log_entries\n @user = User.find(params[:id])\n @log_entries = LogEntry.where(:user_id => @user.id).page(params[:page] || 1)\n end", "def index\n if current_user.try(:admin?)\n @checkins = Checkin.all\n @checkins_for_json = current_user.checkins\n elsif user_signed_in?\n @checkins = current_user.checkins\n @checkins_for_json = @checkins\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @checkins_for_json }\n end\n end", "def index\n @myusers = Myuser.all\n\n render json: @myusers\n end", "def show_user\n usernames = params.require(:usernames)\n\n identities = Hash[User.where(username: usernames).map { |u| [u.username, u.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]] }]\n\n render json: identities\n end", "def url\n '/users/show/' + login\n end", "def following_logins\n return [] if oauth_token.blank?\n\n response = api(url: \"/users/#{login}/following\")\n\n if response.success?\n response.data.map { |d| d[\"login\"] }\n else\n update_attributes(oauth_token: nil) and []\n end\n end", "def login\n\n=begin\n :: Expected Params ::\n\n Constants::REQUEST_PARAM_USERNAME => Username\n Constants::REQUEST_PARAM_USERPASSWORD => UserPassword\n\n=end\n\n # Look up for User in database\n find_user\n\n if @user\n @user.signin!(request)\n\n render json: {status: status_code(:ok), message: '', data: @user.as_signin_json}\n \n end\n\n end", "def index\n @users = @users.order('created_at DESC').page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @users, :except => [:perishable_token, :persistence_token, :email, :single_access_token, :last_login_ip, :current_login_ip, :crypted_password, :password_salt] }\n end\n end", "def user\n render :json=> User.find(params[:id])\n end", "def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end", "def index\n json_response(User.all) \n end", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend", "def login\n p '~~~login~~~'\n @user = User.find_by(name: user_params[:name])\n\n if @user\n @users = User.friends_by_name(user_params[:name])\n render json: {me: @user, users: @users, rooms: @user.rooms}, status: :ok\n else\n render json: {error: \"User does not exist\"}, status: :unprocessable_entity\n end\n end", "def user_log_in(user)\n session[:user_id] = user.id\n end", "def get_login_by_user_id(user_id)\n\t@user = User.find(:first ,:select=>\"login\",:conditions=>[\"id=#{user_id}\"])\n return @user.login\n end", "def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end", "def show\n @user = User.find(params[:id])\n\t\t@loan_histories = LoanHistory.joins(:medium).where(\"user_id = ?\", params[:id]).order(\"rent_start\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def index\n if (!@isLogin)\n return\n end\n @users = User.all\n end", "def index\n users = User.all\n json_response(users)\n end", "def logged_in\n return bad_request unless request.format.json? or request.format.js?\n @response = {:logged_in => logged_in?}\n json_response\n end", "def get_user_entries\n user_entry = Entry.where(user_id: params[:user])\n render json: EntrySerializer.new(user_entry).to_serialized_json\n end", "def index \n #Show all users \n @users = User.all\n render json: @users.as_json(only: [:id, :first_name, :last_name, :email, :business_name, :business_verticals, :business_neighborhood, :created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at])\n end", "def list\r\n users = User.all\r\n render json: users\r\n end", "def index\n if session[:id]\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n else\n flash[:error] = \"You will need to Sign In to view this page.\"\n redirect_to :controller => 'system', :action => 'index'\n end\n end", "def index\n @tbl_logins = TblLogin.all\n end", "def index\n users = User.all\n render json: { users: users }, status: :ok\n end", "def index\n @users = User.all\n logger.debug(\"user index\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def user_login\n @raw['user']['login']\n end", "def get \n render :json => User.find(params[:id])\n end", "def index\n @user_logs_all = UserLog.fetch_data(current_user)\n @user_logs = @user_logs_all.paginate(page: params[:page], per_page: 15)\n end", "def index\n validate_login\n @users = User.all\n end", "def show\n @signout_log = SignoutLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @signout_log }\n end\n end", "def check_login\n login = params[\"login\"]\n @unique = (User.find_by_username login)? false : true\n respond_to do |format|\n format.json { render :json => @unique }\n end\n end", "def index\r\n users = User.all\r\n render json: users\r\n end", "def index\n\t\t@user = User.all\n\t\tCUSTOM_LOGGER.info(\"Start to return users #{@user.to_yaml}\")\n\tend", "def login #i guess with an iPhone app you never really have to log in because your app \n\t\t\t #maintains state and logins in at every call\n\t\t#@user = \"if you can see this you called the login action\"\n\t\t#render :json => @user\n\t\trender \"login\"\n\tend", "def index\n @login_id = current_user.login_id\n end" ]
[ "0.6867485", "0.67673355", "0.6716744", "0.66988355", "0.66878766", "0.66878766", "0.666011", "0.647998", "0.6437776", "0.643684", "0.64342386", "0.6410321", "0.6401466", "0.63548857", "0.6339591", "0.6323323", "0.6316888", "0.6316888", "0.6296454", "0.6255197", "0.6249281", "0.6135789", "0.6075631", "0.6064333", "0.60482", "0.60256475", "0.5998133", "0.59879404", "0.59622777", "0.5962054", "0.5959095", "0.59383345", "0.5930707", "0.5928933", "0.5886309", "0.58777606", "0.58754534", "0.58713454", "0.5863868", "0.58531076", "0.58531076", "0.5851543", "0.5850676", "0.5834534", "0.58257824", "0.5813514", "0.58032376", "0.58029306", "0.5801879", "0.5800344", "0.5794675", "0.57907575", "0.57886195", "0.5783469", "0.5782713", "0.5781824", "0.57668334", "0.5764172", "0.57629466", "0.5756138", "0.575591", "0.575038", "0.574864", "0.57457364", "0.57450336", "0.5738064", "0.57295024", "0.5716394", "0.5712989", "0.571214", "0.5711626", "0.57079464", "0.5702334", "0.5701767", "0.5697206", "0.5697206", "0.5692411", "0.56914395", "0.56889725", "0.5685973", "0.56818897", "0.56767964", "0.5665869", "0.56644547", "0.5653324", "0.56532604", "0.56532055", "0.5651574", "0.56506896", "0.5648582", "0.5645817", "0.5633801", "0.56323427", "0.56303453", "0.56298584", "0.56297123", "0.5626128", "0.56232154", "0.5617305", "0.56148094", "0.56052923" ]
0.0
-1
POST /user_logins POST /user_logins.json
def create @user_login = UserLogin.new(user_login_params) respond_to do |format| if @user_login.save format.html { redirect_to @user_login, notice: 'User login was successfully created.' } format.json { render :show, status: :created, location: @user_login } else format.html { render :new } format.json { render json: @user_login.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @user = User.new(user_params)\n\n if @user.save\n #If successful, login as new registered user\n log_in @user\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def login\n @users = User.all\n render json: User.all\n end", "def create_user_and_login \n\t\tinsert_into :users, {\n\t\t\tid: 1 ,\n\t\t\tfirst_name: 'First',\n\t\t\tlast_name: 'Last',\n\t\t\tlogin: 'login',\n\t\t\tpassword: 'password',\n\t\t\trole_id: 1,\n\t\t\tuid: \"a\"\n\t\t}\n\n\t\tproxy.post( 'http://my.ownet/api/session',{\n\t\t\tlogin: 'login',\n\t\t\tpassword: 'password'\n\t\t}.to_json)\n\tend", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def create_user_login(account_id,user__id__,login__unique_id__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :user__id__,\n :login__unique_id__,\n :login__password__,\n :login__sis_user_id__,\n \n ]\n\n # verify existence of params\n raise \"account_id is required\" if account_id.nil?\n raise \"user__id__ is required\" if user__id__.nil?\n raise \"login__unique_id__ is required\" if login__unique_id__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :account_id => account_id,\n :user__id__ => user__id__,\n :login__unique_id__ => login__unique_id__\n )\n\n # resource path\n path = path_replace(\"/v1/accounts/{account_id}/logins\",\n :account_id => account_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def auto_login\n render json: logged_in_user\n end", "def login\n @user = users(:user1)\n post user_session_path, params: { 'user[email]' => @user.email, 'user[password]' => 'password' }\n end", "def auto_login\n render json: @user\n end", "def sign_in(user)\n post user_session_path \\\n 'user[email]'=> user.email,\n 'user[password]'=> user.password\n end", "def create\n @user = User.new(user_params)\n # binding.pry\n respond_to do |format|\n if @user.save\n log_in @user\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n log_in @user\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_params\n params.require(:user).permit(:name, :password, :logins)\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n log_in @user\n format.html { redirect_to @user,\n notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @user_logins = UserLogin.all\n end", "def login_user(user)\n post sessions_path, params: { email: user.email, password: user.password }\n end", "def process_login\n user = User.where(login: params[:user][:login], password: params[:user][:password]).first\n respond_with :api, json:!user.nil?\n end", "def create\n if @user = login(params[:email], params[:password], params[:remember])\n render json: {:ok => true, :user => {:id => @user.id, :username => @user.username, :email => @user.email}}\n else\n render json: {:ok => false}, status: :unprocessable_entity\n end\n end", "def login(email, password)\n post api_v1_user_session_path, \n headers: { 'CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json' },\n params: { email: email, password: password }.to_json\nend", "def create\n user = User.find_by(email: login_params[:email])\n if user && user.authenticate(login_params[:password])\n session[:user_id] = user.id\n render json: { logged_in: true, user: UserSerializer.new(user) }, status: 200\n else\n \n render json: {errors: ['invalid email or password']}, status: 401\n end\n end", "def create\n @log_in = LogIn.new(log_in_params)\n\n respond_to do |format|\n if @log_in.save\n format.html { redirect_to @log_in, notice: 'Log in was successfully created.' }\n format.json { render :show, status: :created, location: @log_in }\n else\n format.html { render :new }\n format.json { render json: @log_in.errors, status: :unprocessable_entity }\n end\n end\n end", "def login\n\n=begin\n :: Expected Params ::\n\n Constants::REQUEST_PARAM_USERNAME => Username\n Constants::REQUEST_PARAM_USERPASSWORD => UserPassword\n\n=end\n\n # Look up for User in database\n find_user\n\n if @user\n @user.signin!(request)\n\n render json: {status: status_code(:ok), message: '', data: @user.as_signin_json}\n \n end\n\n end", "def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n format.html { log_in(@user,notice: \"User was created successfully\")}\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def request_spec_login(user)\n login_params = {user: {email: user.email, password: user.password}}\n post \"/users/sign_in\", login_params\n end", "def request_spec_login(user)\n login_params = {user: {email: user.email, password: user.password}}\n post \"/users/sign_in\", login_params\n end", "def user_login_params\n params.require(:user_login).permit(:timestamp, :user_id)\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n log_in @user\n notice = t(:create_success, model_name: User.model_name.human)\n format.html { redirect_to homepage_path, notice: notice }\n format.json { render json: @user, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def sign_in(user:, password:)\n post user_session_path \\\n \"user[email]\" => user.email,\n \"user[password]\" => password\n end", "def login_post\n @user = User.find_by_username(params[:user][:username])\n \n if @user == nil or not @user.password_valid?(params[:user][:password]) then\n respond_to do |format|\n format.html { redirect_to login_users_path, notice: \"Either the username or password is invalid. Please try again.\"}\n format.json { head :no_content }\n end\n return\n else\n session[:user] = @user\n\n if session[:previous_page] then\n respond_to do |format| \n session[:no_back] = true\n format.html { redirect_to session[:previous_page] }\n format.json { head :no_content }\n end\n\n session[:previous_page] = nil\n return\n end\n \n logged_in_home_page = users_path + '/' + session[:user][:id].to_s\n respond_to do |format|\n format.html { redirect_to gardens_path}\n format.json { head :no_content }\n end\n return\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n login!\n #send this data back Home.jsx's post request\n render json: {\n status: :created,\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: @user.errors.full_messages\n }\n end\n end", "def sign_in(user)\n post sessions_path, params: { email: user.email, password: 'mypass' }\n end", "def login\n user = User.find_by(username: params[\"username\"])\n if user && user.authenticate(params[\"password\"])\n session[:current_user_id] = user.id\n render json: User.to_hash(user)\n else\n render json: nil\n end\n end", "def create\n @session_login = current_user.session_logins.build(session_login_params)\n respond_to do |format|\n if @session_login.save\n format.html { redirect_to @session_login, notice: \"Session login was successfully created.\" }\n format.json { render :show, status: :created, location: @session_login }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @session_login.errors, status: :unprocessable_entity }\n end\n end\n end", "def login\n @user = User.authenticate credentials[:email], credentials[:password]\n if @user # serializer makes it easier to return json, in this case the token\n render json: @user, serializer: LoginUserSerializer, root: 'user'\n else\n head :unauthorized # if authentication case this is executed\n end\n end", "def login\n\n if params[:username] && params[:token]\n @user = token_based_login\n end\n\n if @user\n set_session_headers\n render json: { username: @user.username, auth_token: get_md5_digest(params[:username]), logged_in: true }\n else\n render json: { logged_in: false }, status: 401\n end\n end", "def login\n user = User.find_by(email: user_login_params[:email])\n\n if user && user.authenticate(user_login_params[:password])\n token = create_token(user.id)\n render json: {\n user: user.attributes.except(\"password_digest\"),\n token: token,\n }, status: :ok\n else\n render json: {error: \"unauthorized\"}, status: :unauthorized\n end\n end", "def login\n user = User.find_by(email: user_login_params[:email])\n\n if user && user.authenticate(user_login_params[:password])\n token = create_token(user.id)\n render json: {\n user: user.attributes.except(\"password_digest\"),\n token: token,\n }, status: :ok\n else\n render json: {error: \"unauthorized\"}, status: :unauthorized\n end\n end", "def login\n user = User.find_by(username: user_params[:username])\n if user && user.authenticate(user_params[:password])\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: \"Wrong Username or Password!\"}\n end\n end", "def login\n \n user = User.find_by(username: params[:username])\n if user\n if user.authenticate(params[:password])\n render json: user.to_json(serialized_data)\n else\n render json: {\n error: true,\n message: \"Incorrect User or password!\"\n }, status: :unauthorized\n end\n else\n render json: {\n error: true,\n message: \"Incorrect User or password!\"\n }, status: :payment_required\n end\n end", "def login\n user = User.find_by(username: params[:user][:username])\n # authenticate method from has_secure_password in user model\n if user && user.authenticate(params[:user][:password])\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n else\n render json: {status: 401, message: \"Unauthorized\"}\n end\n end", "def index\n @log_ins = LogIn.all\n end", "def create\n @loginuser = Loginuser.new(params[:loginuser])\n\n respond_to do |format|\n if @loginuser.save\n format.html { redirect_to @loginuser, notice: 'Loginuser was successfully created.' }\n format.json { render json: @loginuser, status: :created, location: @loginuser }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loginuser.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n log_in @user\n flash[:success] = \"Successfully created!\"\n format.html { redirect_to @user}\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def login\n @user = User.find_by(username: params[:username])\n # Make sure user exists and password is correct\n if @user && @user.authenticate(params[:password])\n new_access_token = create_access_token(@user.id)\n new_refresh_token = create_refresh_token(@user.id)\n render json: {user: @user, auth: {accessToken: new_access_token.jwt, accessTokenExpiration: new_access_token.expiration, refreshToken: new_refresh_token.jwt, refreshTokenExpiration: new_refresh_token.expiration }}\n else # User didn't exist or password was incorrect\n render json: {error: \"Invalid username or password\"}\n end\n end", "def login\n user = User.find_by(username: user_params[:username])\n if user && user.authenticate(user_params[:password])\n\n render json: {user: UserSerializer.new(user), token: encode_token(user.id)}\n else\n render json: {errors: 'Please enter the correct username and/or password'}, status: :unauthorized\n end\n end", "def login(user)\n post '/api/v1/login', params: {email: user.email, password: user.password}\n return json['auth_token']\n end", "def create\n @user = User.new(user_params)\n if @user.save\n login(@user)\n render :show\n else\n render json: @user.errors.full_messages, status: 422\n end\n\n end", "def login\n user = User.find_by(username: auth_params[:username])\n if user && user.authenticate(auth_params[:password])\n payload = {user_id: user.id}\n token = encode_token(payload)\n render json: {jwt: token, userid: user.id, admin: user.admin}\n else\n render json: {failure: \"login failed\"}\n end\n end", "def login\n puts '--- LOGIN ---'\n puts username: params[:user][:username]\n puts password: params[:user][:password]\n # = 'escape'\n user = User.find_by(username: params[:user][:username])\n if user && user.authenticate(params[:user][:password])\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n else\n render json: {status: 401, message: \"Unauthorized - Login\"}\n end\n end", "def create\n verify_post_request\n access_denied unless has_role?(:admin)\n require_parameters :login, :password, :password_confirmation\n\n user = User.find_by_login(params[:login])\n\n if user && user.active\n render_bad_request('An active user with this login already exists')\n else\n if user\n user.reactivate!(java_facade.getSettings().getString('sonar.defaultGroup'))\n user.notify_creation_handlers\n else\n user = prepare_user\n user.save!\n user.notify_creation_handlers\n end\n hash = user.to_hash\n respond_to do |format|\n format.json { render :json => jsonp(hash) }\n format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'users') }\n end\n end\n end", "def create \n user = User.find_by(username: params[\"user\"][\"username\"]).try(:authenticate, params[\"user\"][\"password\"])\n\n if user \n session[:user_id] = user.id\n render json: {\n status: :created,\n logged_in: :true,\n user: user\n }\n else\n render json: { status: 401 }\n end\n\n end", "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def log_in_as(user)\n post '/login', params: { 'session' => { 'name' => user.username } }\n end", "def create\n if current_user\n # render json: { status: 200, msg: \"Logged-in as #{current_user.name}\" }\n @userin = UserInvestor.new(userin_params)\n if @userin.save\n render json: { status: 'OK', results: @userin, errors: nil },\n status: :created\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'failed to create user' },\n status: :unprocesable_entity\n end\n end\n end", "def autologin\n token = request.headers['Authorization']\n user_id = JWT.decode(token, 'secret')[0][\"userId\"]\n user = User.find(user_id)\n render json: user.user_information\n end", "def create\n if (!@isLogin)\n return\n end\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n session[:user_id] = @user.id\n format.html { redirect_to @user, notice: \"User was successfully created.\" }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_user_logins_with_http_info(user_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserApi.get_user_logins ...'\n end\n # verify the required parameter 'user_id' is set\n if @api_client.config.client_side_validation && user_id.nil?\n fail ArgumentError, \"Missing the required parameter 'user_id' when calling UserApi.get_user_logins\"\n end\n # resource path\n local_var_path = '/user/users/{user_id}/logins'.sub('{' + 'user_id' + '}', user_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\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 => 'UserLoginsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserApi#get_user_logins\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @user = User.new(params[:user])\n respond_to do |format|\n if @user.save\n sign_in @user\n format.html { redirect_to @user, notice: 'Account created - welcome to StoryStore!' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def login\n if @user\n render_json 'Signed in Successfully', true, @user, :ok, [:api_v1, user]\n else\n render_json 'Unable to Signed in: wrong email or password', false, {}, :unauthorized\n end\n end", "def login_user\n do_request builder.build_login_user\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n auto_login(@user)\n format.html { redirect_to :users, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def sign_in_as(user)\n post \"/login\", params: {\n login: {\n email: user.email,\n password: 'testpassword'\n }\n }\n end", "def login\n if session[:user] != nil then\n logged_in_home_page = home_index_path\n respond_to do |format|\n format.html { redirect_to logged_in_home_page}\n format.json { head :no_content }\n end\n return\n end\n\n @user = User.new\n \n respond_to do |format|\n format.html # login.html.erb\n format.json { render json: @user }\n end\n end", "def index\n # @logins = Login.all\n end", "def login\n @user = User.find_by_username(params[:username])\n if @user&.authenticate(params[:password])\n token = JsonWebToken.encode(id: @user.id)\n time = Time.now #+ 24.hours.to_i\n render json: { token: token, last_login_time: time.strftime(\"%m-%d-%Y %H:%M\"),\n user: @user}, status: :ok\n # comment: @user.comment şu şekilde diğerleride çağrılabilir.\n else\n render json: { error: 'Login Unsuccessfull(Invalid username / password)' }, status: :unauthorized\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save \n Individual.create({:login => @user.login, :name => @user.name}).save \n log_in @user\n flash[:notice] = \"#{@user.name}, welcome to Objective Hiring\"\n redirect_to user_path @user\n else\n flash[:warning] = @user.errors.full_messages\n render 'new'\n end\n\n end", "def login \n render json: User.first\n end", "def create\n @user = User.new(user_params)\n respond_to do |format|\n \n if @user.save\n \n if logged_in?\n\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n\n format.html { redirect_to home_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n sign_in(@user)\n end\n\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @logins = Login.all\n end", "def sync_user_logins(user)\n canvas_user = find_user(user.email)\n if canvas_user.nil?\n create_user(user)\n else\n user.canvas_user_id = canvas_user['id']\n end\n\n user\n end", "def create\n # Find the user by the params sent in through the login fetch params \n @user = User.find_by(username: user_login_params[:username])\n \n # User authenticate is a built in method that comes from BCrypt.\n # This next line checks if the user exists, and also if the password given allows access\n if @user && @user.authenticate(user_login_params[:password])\n # encode_token method comes from ApplicationController (which we are inheriting from on line 1).\n #this creates a variable with the value of our token \n @token = encode_token({ user_id: @user.id })\n \n # UserSerializer is a serializer in the serializers folder. To use this the active_model_serializers gem is needed.\n # This helps clean the data that is sent out to limited attributes you want listed\n render json: { user: UserSerializer.new(@user), jwt: @token }, status: :accepted\n \n # Without a serializer or status the following line would suffice\n # render json: { user: @user, jwt: @token}\n \n else\n # Vague error message for user security (never tell someone they got a specific input incorrect), adding a status code \n render json: { message: 'Invalid username or password' }, status: :unauthorized\n end\n end", "def create\n user = User.find_by_username(params[:username])\n if user && user.authenticate(params[:password])\n session[:user_id] = user.id\n response.status=(200)\n render json: {status: \"Success\", message: [\"Log in Successful!\"], userid: user.id, username: user.username}\n else \n # Error handling\n response.status=(401)\n render json: {status: \"Error\", message: [\"Username or password invalid\"]}\n end\n end", "def login(user)\n @request.env['devise.mapping'] = Devise.mappings[:user]\n sign_in(user)\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n sign_in @user\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user, status: :unprocessable_entity }\n end\n end\n end", "def following_logins\n return [] if oauth_token.blank?\n\n response = api(url: \"/users/#{login}/following\")\n\n if response.success?\n response.data.map { |d| d[\"login\"] }\n else\n update_attributes(oauth_token: nil) and []\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n log_in @user\n flash.now[:notice] = 'Welcome!'\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n flash.now[:alert] = 'Something went wrong during registration process'\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def login\n user = User.find_by_email(params[:username])\n if user.nil? || (user && user.authenticate(params[:password]) == false) || user.deleted\n render status: 400, json: nil \n else\n session[:user_id] = user.id\n session[:username] = user.username\n session[:email] = user.email\n session[:verified] = user.verified\n user.last_ip_login = request.remote_ip\n user.save\n render status: 200, json: session\n end\n end", "def post_authenticate(hash)\n HttpClient::Preconditions.assert_class('hash', hash, Hash)\n @client.request(\"/users/authenticate\").with_json(hash.to_json).post { |hash| Apidoc::Models::User.new(hash) }\n end", "def sign_in\n login = params['login']\n password = params['password']\n type = (params['type'] || 'standard').to_sym\n\n if login.nil? || password.nil?\n render :json => {error:'please enter params'}\n return\n end\n\n if type == :standard\n user = User.where(login:login,password:password,user_type:type).first\n if user.nil?\n render :json => { login:false , error: 'Invalid credentials' }\n return\n else\n raw_token = {login: user.login , password: password , type:user.user_type }\n token = JsonWebToken.encode(raw_token)\n render :json => { login:true , token: token , admin:user.admin , user: {login:user.login, type:user.user_type, id: user.id} }\n return\n end\n end\n if type == :ldap\n sing_in_ldap({login:login, password:password})\n\n end\n end", "def login_request(username, password)\n post(data['hosts']['auth'] + '/login', {\n headers: {\n 'Content-Type' => 'application/json'\n },\n body: {\n username: username,\n password: password\n }\n })\nend", "def user_log_in(user)\n session[:user_id] = user.id\n end", "def log_in\n end", "def create\n if params[:via_linkedin] == false\n # create the new user instance with params from sign up form\n user = User.create(user_params)\n else\n params[:user][:password] = SecureRandom.hex\n\n # find or create the new user instance via linkedin\n user = User.where(provider: user_params[:provider], uid: user_params[:uid])\n .first_or_create(user_params)\n end\n # check the user save ok\n if user.persisted?\n # use the Knock AuthToken model to create a token for us\n render json: { jwt: auth_token(user).token, user: UserSerializer.new(user) }, status: 200\n else\n # bad request\n render json: user, status: 400\n end\n end", "def user_login_params\n params.permit(:username, :password)\n end", "def login\n user = User.find_by(email: params[:email])\n return render json: { message: ['Email does not exist'] }, status: 422 unless user\n return render json: { message: ['Password not valid'] }, status: 422 unless user.valid_password?(params[:password])\n\n token = user.tokens.create\n render json: { auth_token: token.auth_token }, status: :ok\n end", "def api_user_login(email, password)\n url = user_session_url\n params = {\n email: email,\n password: password\n }\n page.driver.submit :post, url, params\n @api_user_headers = page.response_headers\n end", "def logged_in\n return bad_request unless request.format.json? or request.format.js?\n @response = {:logged_in => logged_in?}\n json_response\n end", "def create\n @user = User.new(user_params)\n puts \"We are now in create...................\"\n puts \"@user is \"+@user.to_s\n\n respond_to do |format|\n if @user.save\n log_in @user\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n # respond_to do |format|\n if @user.save\n log_in @user\n flash[:success] = \"Welcome to the Sample App!\"\n # format.html { redirect_to @user, notice: 'User was successfully created.' }\n # format.json { render :show, status: :created, location: @user }\n\n redirect_to @user\n else\n # format.html { render :new }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n render 'new'\n end\n # end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n session[:user_id] = @user.id\n\n format.html { redirect_to '/', notice: 'User created.' }\n format.json { redirect_to '/', status: :created }\n\n elsif self.request.format.json? \n\n @data = File.read('/home/daniel/puppy/public/login.json')\n @data = @data.gsub(/ROOT/, root_url)\n render :json => @data\n \n\n else\n format.html { redirect_to '/signup', error: \"Something Went Wrong.\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def sign_in\n @user = User.find_by_email(params[:auth][:email])\n if @user && @user.authenticate(params[:auth][:password])\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token, moderator: !!@user.moderator }, status: 200\n else \n render json: { error: 'incorrect details entered' }, status: 404\n end\nend", "def login(username, pwd)\n user = @server.proxy('User')\n logged_in_user_response = user.login({'login' => username, 'password' => pwd})\n #puts \"\\nlogged in user id = \" + logged_in_user_response['id'].to_s\n end", "def sign_in(user, password)\n post login_path, params: {session: {email: user.email, password: password}}\n end", "def user_login\n @user = User.find_by_email(params[:email])\n\n if @user.present?\n # response -- User Found and this is his ID\n response = { \"code\" => 1, \"user_id\" => @user.id, \"msg\" => \"User Found\" }\n else\n new_user = User.new(:email => params[:email], :first_name => params[:first_name], \n :last_name => params[:last_name], :user_avatar => params[:user_avatar])\n\n if new_user.save\n # User Not found, will create one and this is his ID\n response = { \"code\" => 1, \"user_id\" => new_user.id, \"msg\" => \"New User Created\" }\n else\n # response -- with 0, Failed to create new user\n response = { \"code\" => 0, \"msg\" => \"User Can't be created\" }\n end\n end\n\n # Send the response in JSON\n render json: response\n end", "def login_for_test\n create_user_for_test\n post \"/api/v1/auth/login\",\n { username: \"TestUser\",\n email: \"test@gmail.com\",\n password: \"password\" }.to_json,\n \"Accept\" => Mime::JSON, \n \"Content-Type\" => Mime::JSON.to_s\n token = JSON.parse(response.body)\n token[\"auth_token\"]\n end", "def create\n @response = DigitalTownService.new.loginUser(params[:user].slice(:email, :password)) \n if @response[\"error\"].blank?\n @user = User.find_by_email(params[:user][:email])\n setUserSession\n flash[:success] = 'Signed in Successfully'\n redirect_to dashboard_index_path\n # super\n else\n flash[:error] = @response[\"message\"]\n end\n end", "def index\n @logins = Login.all\n #cookies[:current_user] = \"user\"\n login_user = Login.find_by_id(session[:login_id])\n end", "def show\n # while accesing a customer a user we'll be able to see the page with logins associated to \n # that concrete customer\n api = SaltEdge.new(ENV[\"salt_edge_app_id\"], ENV[\"salt_edge_secret\"], \"private.pem\")\n r = api.simple_request(\"GET\", \"https://www.saltedge.com/api/v4/logins/\")\n cust_id = current_user.customers.first.cust_id\n r[\"data\"].each do |login|\n if cust_id == login[\"customer_id\"]\n Login.where(log_id: login[\"id\"]).first_or_create do |log|\n log.provider_name = login[\"provider_name\"]\n log.customer_id = current_user.customers.first.id\n end\n end\n end \n @logins = @customer.logins\n end", "def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n end" ]
[ "0.65117955", "0.63206667", "0.6253498", "0.6233153", "0.6233153", "0.6209189", "0.61464363", "0.6140639", "0.6138607", "0.61351067", "0.598204", "0.5976892", "0.5970828", "0.5919757", "0.5904961", "0.59008706", "0.58969796", "0.58714414", "0.58533", "0.5851868", "0.584327", "0.584079", "0.58324707", "0.581724", "0.57894087", "0.57894087", "0.5761225", "0.5748368", "0.5722265", "0.572002", "0.5718377", "0.5698521", "0.5688853", "0.56851447", "0.5661339", "0.56541514", "0.56443954", "0.56443954", "0.5642995", "0.5639577", "0.5634277", "0.56215304", "0.56210905", "0.56198865", "0.56173354", "0.5610672", "0.56029326", "0.5585332", "0.5581976", "0.5575272", "0.557249", "0.55703217", "0.55654985", "0.55609953", "0.55535257", "0.5542464", "0.5535965", "0.5523466", "0.5517649", "0.54984796", "0.5489185", "0.5473796", "0.54667914", "0.54654866", "0.545811", "0.545797", "0.54402965", "0.54339385", "0.5432338", "0.5427533", "0.54271203", "0.5426554", "0.54257506", "0.54122937", "0.5408098", "0.54051614", "0.5404269", "0.5400721", "0.53906566", "0.53879344", "0.5383779", "0.5382066", "0.53797454", "0.5377284", "0.53760403", "0.53717846", "0.53646773", "0.53614736", "0.5357177", "0.53545254", "0.5352668", "0.53504217", "0.53454727", "0.5345026", "0.53399515", "0.53398603", "0.53388613", "0.5330388", "0.532894", "0.5327894" ]
0.5899419
16
PATCH/PUT /user_logins/1 PATCH/PUT /user_logins/1.json
def update respond_to do |format| if @user_login.update(user_login_params) format.html { redirect_to @user_login, notice: 'User login was successfully updated.' } format.json { render :show, status: :ok, location: @user_login } else format.html { render :edit } format.json { render json: @user_login.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def update\n # @user = User.find(params[:id])\n @user = current_user # makes our views \"cleaner\" and more consistent\n params[:user][:existing_identity_attrs] ||= {}\n unless configatron.user_can_change_login\n params[:user].delete(:login)\n @user_login_is_readonly = true\n end\n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = \"Account updated!\"\n format.html { redirect_to account_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n verify_post_request\n access_denied unless has_role?(:admin)\n require_parameters :login\n\n user = User.find_active_by_login(params[:login])\n\n if user.nil?\n render_bad_request(\"Could not find user with login #{params[:login]}\")\n elsif user.update_attributes!(params)\n hash = user.to_hash\n respond_to do |format|\n format.json { render :json => jsonp(hash) }\n format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'users') }\n end\n end\n end", "def update_current_logged_in_user(args = {}) \n id = args['id']\n temp_path = \"/users.json/current\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update\n login = user_params[:login]\n\n raise \"not authorized\" unless is_admin || is_me(login)\n\n LDAP::User.update(login, user_params)\n render json: LDAP::User.find(login)\n rescue => e\n render_failure(e.message)\n end", "def update_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def edit_user_login(account_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :login__unique_id__,\n :login__password__,\n :login__sis_user_id__,\n \n ]\n\n # verify existence of params\n raise \"account_id is required\" if account_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :account_id => account_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/accounts/{account_id}/logins/{id}\",\n :account_id => account_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end", "def update\n respond_to do |format|\n if @log_in.update(log_in_params)\n format.html { redirect_to @log_in, notice: 'Log in was successfully updated.' }\n format.json { render :show, status: :ok, location: @log_in }\n else\n format.html { render :edit }\n format.json { render json: @log_in.errors, status: :unprocessable_entity }\n end\n end\n end", "def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end", "def update\n respond_to do |format|\n if params[:user][:password].present? ? @user.update_attributes(params[:user]) : @user.update_without_password(params[:user])\n flash[:notice] = 'User was successfully updated.'\n @changed << @user.id\n \n sign_in @user, bypass: true if current_user.id == @user.id\n\n format.html { redirect_to :back }\n format.js { render 'shared/index'; flash.discard }\n format.json { head :no_content }\n else\n @edited << @user.id\n @expanded << @user.id\n\n format.html { render action: 'edit', template: 'shared/edit' }\n format.js { render 'user' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @loginuser = Loginuser.find(params[:id])\n\n respond_to do |format|\n if @loginuser.update_attributes(params[:loginuser])\n format.html { redirect_to @loginuser, notice: 'Loginuser was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @loginuser.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n sign_in @user\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n change = false\n user = User.find(params[:id])\n if not params[\"first_name\"].nil? and !params[\"first_name\"].blank?\n change = true\n user.login.update(first_name: params[\"first_name\"])\n end\n if not params[\"last_name\"].nil? and !params[\"last_name\"].blank?\n change = true\n user.login.update(last_name: params[\"last_name\"])\n end\n if not params[\"password\"].nil? and !params[\"password\"].blank?\n change = true\n user.login.update(password: params[\"password\"])\n end\n if not params[\"middle_initial\"].nil? and !params[\"middle_initial\"].blank?\n change = true\n user.login.update(middle_initial: params[\"middle_initial\"])\n end\n if not params[\"login_type\"].nil? and !params[\"login_type\"].blank?\n change = true\n user.login.update(login_type: params[\"login_type\"].to_i)\n end\n if not params[\"username\"].nil? and !params[\"username\"].blank?\n change = true\n user.login.update(username: params[\"username\"])\n end\n if not params[\"email\"].nil? and !params[\"email\"].blank?\n change = true\n user.login.update(email: params[\"email\"])\n end\n if not params[\"login_type\"].nil? and !params[\"login_type\"].blank?\n change = true\n user.login.update(login_type: params[\"login_type\"])\n end\n #@user.login.update(updated_at: DateTime.now)\n\n if not params[\"program\"].nil? and !params[\"program\"].blank?\n change = true\n user.update(program: params[\"program\"])\n end\n if not params[\"status\"].nil? and !params[\"status\"].blank?\n change = true\n user.update(status: params[\"status\"])\n end\n if change\n respond_to do |format|\n format.html { redirect_to user, notice: 'User was updated successfully.' }\n end\n end\n end", "def update\n@user = User.find(params[:id])\n respond_to do |format|\n if @user.update(user_params)\n sign_in @user\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update_user\n end", "def update \n @current_user.update(user_params)\n render json: @current_user\n end", "def update!(**args)\n @login_user = args[:login_user] if args.key?(:login_user)\n end", "def update!(**args)\n @login_user = args[:login_user] if args.key?(:login_user)\n end", "def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end", "def update_user(options)\n patch(\"/user\", options, 3)\n end", "def modify_user(user)\n query_api_object User, \"/rest/user\", user.dump(), \"PUT\"\n end", "def update\n @user = get_user(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to root_url, notice: \"User #{@user.login_name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user.password_changed?\n sign_in(@user, :bypass => true)\n else\n if @user.update(user_params)\n format.html { redirect_to \"/\", notice: t('success_update') }\n format.json { render :show, status: :ok, location: \"/\" }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\nend", "def update\n @user = User.find(params[:id])\n @user.update(user_params)\n render json: @current_user\n end", "def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end", "def update\n\n @user = self.current_user\n @user.update_attributes(params)\n \n rescue => ex\n @user.reload\n handle_exception(ex)\n ensure\n respond_to do |format|\n format.json \n end\n end", "def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def update\n @user = User.find(params[:id])\n params[:user].delete(:id)\n if params[:user][:password].blank? or params[:user][:password_confirmation].blank?\n sign_in_user = true\n else\n sign_in_user = false\n end\n params[:user].delete(:password) if params[:user][:password].blank?\n params[:user].delete(:password_confirmation) if params[:user][:password_confirmation].blank?\n params[:user].delete(:avatar) if params[:user][:avatar].blank?\n if can? :update, Userrole\n params[:foo] = params[:user][:userrole_ids]\n params[:user][:userrole_ids].each do |new_userrole_id|\n unless new_userrole_id.blank?\n new_userrole = Userrole.find(new_userrole_id)\n @user.userroles << new_userrole unless @user.userroles.include?(new_userrole)\n end\n end\n @user.save\n params[:user].delete(:userrole_ids)\n end\n respond_to do |format|\n if @user.update_attributes(params[:user])\n pronoun = ' ' + @user.username\n pronoun_possessive = @user.username + \"'s'\"\n redirect_notice = ' will need to log in again.'\n if current_user?(@user)\n pronoun = ' You'\n pronoun_possessive = \"Your\"\n end\n if sign_in_user\n sign_in @user if current_user?(@user)\n pronoun = ''\n redirect_notice = ''\n end\n format.html { redirect_to(@user, :notice => pronoun_possessive + ' information has been updated.' + pronoun + redirect_notice) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n user = find_user\n user.update!(user_params)\n render json: user\n end", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end", "def update\n puts \"current user\"\n puts @user.id\n puts current_user.id\n if current_user.admin || @user.id == current_user.id\n if user_params['is_disabled']\n @user.tokens = nil\n end\n if @user.update(user_params)\n render json: @user\n else\n puts @user.errors.full_messages\n render json: @user.errors, status: :unprocessable_entity\n end\n else\n render json: @user.errors, status: :bad_request\n end\n end", "def update\n @user_log = UserLog.find(params[:id])\n\n respond_to do |format|\n if @user_log.update_attributes(params[:user_log])\n format.html { redirect_to @user_log, notice: 'User log was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_log.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: {error: \"Could not update user\"}\n end\n end", "def update\n\t\tget_current_user\n\t\t@user = User.find(params[:id])\n\n\t\treturn (render json: {errors: [\"Je bent niet geauthoriseerd om dit te doen\"]}, status: :unprocessable_entity) unless (@current_user.isAdmin || @current_user.id == @user.id)\n\n\t respond_to do |format|\n\t if @user.update_attributes(params[:user])\n\t \tnew_remember_token(@user) if @current_user.isStudent\n\t format.json { head :no_content }\n\t else\n\t format.json { render json: {errors: @user.errors.full_messages}, status: :unprocessable_entity }\n\t end\n\t end\n\tend", "def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n #raise @user.inspect\n if @user.update_attributes(params[:user])\n #set_flash_message :notice, :updated\n # Sign in the user bypassing validation in case his password changed\n @user_c= User.find(current_user.id)\n sign_in @user_c, :bypass => true \n respond_to do |format| \n format.html { redirect_to edit_admin_user_path , notice: \"User (#{@user.email}) password was successfully updated.\" }\n format.json\n end \n else\nrespond_to do |format|\nformat.html { render action: \"edit\" , notice: \"User was successfully deleted.\"}\nformat.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n\nend", "def update\n if @user.update(user_params)\n render json: {user: @user, token: @token}\n else\n frender json: @user.errors, status: :unprocessable_entity \n end\n end", "def update\n if not check_logged_in then\n return\n end\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:user_id])\n @log = @user.logs.find(params[:id])\n respond_to do |format|\n if @log.update(log_params)\n format.html { redirect_to user_logs_url, notice: 'Log was successfully updated.' }\n format.json { render :show, status: :ok, location: @log }\n else\n format.html { render :edit }\n format.json { render json: @log.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n force_log_out = false\n should_go_to_root = false\n admin_count = User.where(\"role = ?\", \"admin\").count\n if @user.role == \"admin\" && params[:user][:role] != \"admin\"\n if admin_count <= 1\n redirect_to :back, notice: 'user.no_admins'\n return\n else\n force_log_out = true if @user.id == current_user.id\n end\n end\n\n # current admin changed its password, need to logout and should go to root.\n if @user.id == current_user.id and !params[:user][:password].empty?\n should_go_to_root = true\n end\n\n # don't change password if it is empty\n params[:user].delete :password if params[:user][:password].empty?\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n if force_log_out\n sign_out current_user\n format.html { redirect_to root_path, notice: 'user.no_longer_admin' }\n else\n if should_go_to_root\n format.html { redirect_to root_path, notice: 'user.updated' }\n else\n format.html { redirect_to @user, notice: 'user.updated' }\n end\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if user.update(user_params)\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end", "def update\n unless create_user\n respond_to do |format|\n format.json { render json: { error: 'User is not logged in!' }, status: :unprocessable_entity }\n end\n return\n end\n logger.debug '@user is found in db!'\n\n respond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user, status: :ok, location: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update_attributes(user_params)\n render json: @user\n else\n log_modal_errors @user\n render json: @user.errors.full_messages, status: :bad_request\n end\n end", "def update\n # @user is already set by correct_user\n # @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n # Handle a successful update.\n flash[:success] = \"Profile updated\"\n # log_in here makes sure token in cookie gets updated\n # If someone is using hijacked cookie, token gets updated and results in stole token not working\n log_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end", "def update\n authorize! :update, @user\n respond_to do |format|\n if @user.update(user_params)\n sign_in(@user == current_user ? @user : current_user, :bypass => true)\n format.html { redirect_to @user, notice: 'Your profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n user = User.find_by(id: params[:id])\n user.update(user_params)\n render json: user\n end", "def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end", "def login=(new_login)\n @json['user']['content']['login'] = new_login\n end", "def update\n respond_to do |format|\n if @openstack_user.update(openstack_user_params)\n format.html { redirect_to @openstack_user, notice: 'Openstack user was successfully updated.' }\n format.json { render :show, status: :ok, location: @openstack_user }\n else\n format.html { render :edit }\n format.json { render json: @openstack_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if (!@isLogin || !@isValidUser)\n return\n end\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: \"User was successfully updated.\" }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n respond_to do |format|\n if @trail_user.update(trail_user_params)\n format.html { redirect_to @trail_user, notice: 'Trail user was successfully updated.' }\n format.json { render :show, status: :ok, location: @trail_user }\n else\n format.html { render :edit }\n format.json { render json: @trail_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @api_v1_user.update(api_v1_user_params)\n head :no_content\n else\n render json: @api_v1_user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(session[:uid])\n @user.update_attribute :auth_token, session[:auth_token]\n @user.update_attribute :auth_secret, session[:auth_secret]\n @user.save!\n\n redirect_to home_index_url\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch_user(user_id, body)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?\n path = \"#{users_path}/#{user_id}\"\n patch(path, body)\n end", "def update\n respond_to do |format|\n if @rcadmin_login_log.update(rcadmin_login_log_params)\n format.html { redirect_to @rcadmin_login_log, notice: 'Login log was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rcadmin_login_log.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\tif @user.update(user_params)\n\t\t\trender json: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def update\n user = User.find(params[:id])\n\n # Use update with user_params to do a mass-assignment update and save. \n if user.update_attributes(user_params)\n render json: user\n else \n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(current_identity.user_id)\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @login = Login.find(params[:id])\n\n respond_to do |format|\n if @login.update_attributes(params[:login])\n format.html { redirect_to @login, notice: 'Login alterado com sucesso!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @login.errors, status: :unprocessable_entity }\n end\n end\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def update\n @user = current_api_user\n unless @user.update(user_params)\n render json: { error: @user.errors.full_messages.to_sentence }, status: :not_found\n end\n end", "def update\n @user = current_user\n @user.role = 'client'\n \n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, flash[:success] => \"User was successfully updated\" }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user.update_with_password(user_params)\n sign_in @user, :bypass => true\n format.html { redirect_to edit_user_path(current_user), notice: 'Profile updated successfully.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: current_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_user\n if (@user = find_user(params[:id]))\n @all_roles = Role.find_all.select { |r| r.name != UserEngine.config(:guest_role_name) }\n case request.method\n when :get\n when :post\n @user.attributes = params[:user].delete_if { |k,v| not LoginEngine.config(:changeable_fields).include?(k) }\n if @user.save\n flash.now[:notice] = \"Details for user '#{@user.login}' have been updated\"\n else\n flash.now[:warning] = \"Details could not be updated!\"\n end\n end\n else\n redirect_back_or_default :action => 'list'\n end\n end", "def update\n if check_user_write_access\n respond_to do |format|\n if user.update_attributes(params[:user])\n format.html { redirect_to user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if current_user.update(user_params)\n format.json {\n render json: {\n status: 'success',\n data: current_user\n },\n status: :ok\n }\n else\n format.json { render json: current_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n group_ids = params[:group_id]\n org_id = params[:organization_id]\n @user = User.find_by_id(params[:user_id])\n current_group_ids = @user.user_group_ids\n\n respond_to do |format|\n if @user.update_attributes(full_name: params[:full_name], abbreviation: params[:abbreviation], email: params[:email], status: params[:status], staff_number: params[:employee_id], career_path: params[:career_path])\n\n is_logged = !@user.previous_changes.blank?\n if current_group_ids != group_ids\n @user.user_group_ids = group_ids\n format.json { render json: @user }\n end\n else\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n sign_in @user\n flash[:success]= \"Profile Updated\"\n redirect_to @user\n else\n render 'edit'\n end\n end", "def update\n @userin = UserInvestor.find(params[:id])\n update_userin = @userin.update(userin_params)\n if update_userin\n render json: { status: 'OK', results: update_userin, errors: nil },\n status: :ok\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'update user failed' },\n status: :unprocesable_entity\n end\n end", "def update\n @user = User.find(params[:id]).decorate\n return if unauthorized_user!\n @user.update_attributes(params[:user])\n respond_with @user\n end", "def update\n @user = User.find(params[:id])\n if params[:user][:password].blank?\n params[:user].delete(:password)\n end\n \n respond_to do |format|\n if @user.update_attributes(user_params)\n sign_in @user, :bypass => true #should be if password is updated\n format.html { render :action => 'show', :notice => 'Din profil blev opdateret og vi har gemt dine ændringer' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update \n user = User.where(:id => current_user.user)\n if user.update(user_params)\n render :json => {:user => user }\n else\n render :json => {:error => user.errors.full_messages.first}\n end\nend", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.save\n render json:@user\n end", "def auto_login\n render json: @user\n end", "def update\n load_user\n build_user\n respond_to do |format|\n if user.save\n format.html { redirect_to user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @ser }\n else\n format.html { render :edit }\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user.update(user_params_update)\n json_response(@user)\n end", "def update\n @user = current_user\n if @user.update(update_user_params)\n render 'api/v1/users/show'\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def sync_user_logins(user)\n canvas_user = find_user(user.email)\n if canvas_user.nil?\n create_user(user)\n else\n user.canvas_user_id = canvas_user['id']\n end\n\n user\n end", "def update\n respond_to do |format|\n if @user.update(form_params)\n format.json { render json: { users: @user }, status: :ok, location: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_user(id, accountId, model) path = \"/api/v2/accounts/#{accountId}/users/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end", "def update\n @user = current_user\n\n ## Update other fields\n %w(billing_cycle billing_cycle_start_date is_profile_complete is_verified_email approval_status).each do |f|\n params[:user].delete(f)\n end\n\n @user.is_profile_complete = 'yes'\n if @user.update_attributes(params[:user])\n sign_in @user, :bypass => true\n respond_to do |format|\n format.json { render :json => {\"user\" => @user.as_json}, :status => :created }\n end\n else ## error when save\n respond_to do |format|\n format.json { render json: @user.errors.full_messages, :status => :bad_request }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n render json:@user\n else\n render json: { error: {code: 404, message: 'Invalid user' }}, status: :not_found\n end\n end", "def update\n @user = User.find(params[:id])\n respond_to do |format|\n if params[:user][:change_password] == false\n @user.attributes = params[:user].except(:password, :password_confirmation, :change_password)\n else\n @user.attributes = params[:user].except(:change_password)\n end\n if @user.save(validate: false)\n sign_in @user\n format.html { redirect_to @user, notice: 'Your account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if user.update(user_params)\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n update_method = user_update_params[:current_password] ? 'update_with_password' : 'update_without_password'\n\n if @user.method(update_method).call(user_update_params)\n sign_out_current_user\n render json: @user, status: :ok\n else\n render json: format_errors(@user.errors), status: :unprocessable_entity\n end\n end", "def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update_user\n user = current_user\n if user.update(update_params)\n render json: { status: { updated: \"Ok\" } }\n else\n render json: user.errors.full_messages\n end\n end", "def update\n begin\n user = User.find(params[:user_id])\n if user.update(user_params)\n render json: { users: user }, status: :ok\n else\n render json: { errors: user.errors.messages }, status: 422\n end\n rescue => e\n render json: { errors: e.message }, status: 404\n end\n end", "def update\n user = User.find(params[:id])\n user.update(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors\n end\n end" ]
[ "0.70472056", "0.67074186", "0.6451869", "0.6396069", "0.6355226", "0.62967", "0.62967", "0.62227327", "0.6195104", "0.6102748", "0.60949606", "0.6081385", "0.60531896", "0.6014166", "0.5966181", "0.5965591", "0.59617895", "0.5949332", "0.59406674", "0.5915215", "0.5904972", "0.5904972", "0.5902905", "0.5890921", "0.5890555", "0.5888833", "0.58773655", "0.58483475", "0.58398473", "0.5824851", "0.5819512", "0.57829285", "0.5774449", "0.5771823", "0.577043", "0.57646537", "0.576315", "0.5753268", "0.57444423", "0.5743096", "0.57312965", "0.57312965", "0.5730237", "0.57280296", "0.5726462", "0.5713818", "0.57106525", "0.5703756", "0.57020533", "0.568392", "0.5682934", "0.56681997", "0.5664994", "0.5659456", "0.5653286", "0.5649159", "0.5643356", "0.56354725", "0.5634264", "0.5630548", "0.56274307", "0.5626205", "0.56245226", "0.5621509", "0.5620441", "0.561598", "0.56158304", "0.5605193", "0.5596401", "0.5596401", "0.55862474", "0.5584878", "0.5560226", "0.55592555", "0.5556211", "0.55547184", "0.55526394", "0.5550351", "0.55465597", "0.55461335", "0.5545098", "0.5536239", "0.55346125", "0.5531823", "0.55315864", "0.5524969", "0.5520483", "0.5515955", "0.55132794", "0.55122733", "0.5511355", "0.55084175", "0.5508034", "0.5505311", "0.55050796", "0.5503967", "0.5501409", "0.5499426", "0.5498957", "0.54955655" ]
0.60081524
14
DELETE /user_logins/1 DELETE /user_logins/1.json
def destroy @user_login.destroy respond_to do |format| format.html { redirect_to user_logins_url, notice: 'User login was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deleteLogin( login_id)\n params = Hash.new\n params['login_id'] = login_id\n return doCurl(\"delete\",\"/login\",params)\n end", "def destroy\n @user_log = UserLog.find(params[:id])\n @user_log.destroy\n\n respond_to do |format|\n format.html { redirect_to user_logs_url }\n format.json { head :no_content }\n end\n end", "def delete_user_login(user_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"user_id is required\" if user_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :user_id => user_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/users/{user_id}/logins/{id}\",\n :user_id => user_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end", "def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend", "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def destroy\n @loginuser = Loginuser.find(params[:id])\n @loginuser.destroy\n\n respond_to do |format|\n format.html { redirect_to loginusers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rcadmin_login_log.destroy\n respond_to do |format|\n format.html { redirect_to rcadmin_login_logs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @user = User.find(params[:user_id])\n # @log = @user.logs.find(params[:id])\n @log.destroy\n respond_to do |format|\n format.html { redirect_to user_logs_url, notice: 'Log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @signout_log = SignoutLog.find(params[:id])\n @signout_log.destroy\n\n respond_to do |format|\n format.html { redirect_to signout_logs_url }\n format.json { head :no_content }\n end\n end", "def user_delete(user_id)\n\t\tdelete_call = Curl::Easy.http_delete(\"#{@ip_address}:#{@port_2}/v2.0/users/#{user_id}\"\n\t\t) do |curl|\n\t\t\tcurl.headers['x-auth-token'] = @token\n\t\t\tcurl.headers['userId'] = user_id\n\t\tend\n\t\n\tend", "def delete\n render json: User.delete(params[\"id\"])\n end", "def user_management_delete_user id\n # the base uri for api requests\n query_builder = Configuration.BASE_URI.dup\n\n # prepare query string for API call\n query_builder << \"/v1/users\"\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\n \"id\" => id,\n \"client_id\" => @client_id,\n \"client_secret\" => @client_secret,\n }\n\n # validate and preprocess url\n query_url = APIHelper.clean_url query_builder\n\n # prepare headers\n headers = {\n \"user-agent\" => \"IAMDATA V1\",\n \"accept\" => \"application/json\"\n }\n\n # invoke the API call request to fetch the response\n response = Unirest.delete query_url, headers:headers\n\n # Error handling using HTTP status codes\n if response.code == 404\n raise APIException.new \"Not found\", 404, response.raw_body\n elsif response.code == 401\n raise APIException.new \"Unauthorized\", 401, response.raw_body\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\n end\n\n response.body\n end", "def destroy\n #@user = User.find_by_login(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @log_in.destroy\n respond_to do |format|\n format.html { redirect_to log_ins_url, notice: 'Log in was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_user_route(user)\n self.client.delete(\"gh.storage.user.#{user}\")\n end", "def destroy\r\n\r\n @user.destroy\r\n\r\n save_users_log(current_user.email, 'user_deleted',@user.to_json)\r\n\r\n respond_to do |format|\r\n format.html { redirect_to users_url, notice: 'User was successfully deleted.' }\r\n end\r\n end", "def destroy\n # Validations\n if request.format != :json\n render( status: 406, json: { success: false, message: I18n.t(\"api.errors.request_must_be_json\") } )\n return\n end\n\n # Fetch params\n user = User.find_for_database_authentication( authentication_token: params[:user_token] )\n\n if user.nil?\n render( status: 404, json: { success: false, message: I18n.t(\"api.errors.invalid_token\") } )\n else\n user.reload\n user.authentication_token = nil\n user.save!\n render( status: :ok, json: { success: true, message: I18n.t(\"api.errors.log_out_successful\") } )\n end\n end", "def remove_user\n query_api '/rest/user', nil, 'DELETE'\n end", "def delete\n render json: Users.delete(params[\"id\"])\n end", "def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end", "def delete_user(id)\n elektron_identity.delete(\"users/#{id}\")\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted user #{@user.name}\")\n end", "def delete_user\n @user = User.find(params[:id])\n if @user.destroy\n render :json => @user\n else\n render :json => @user.errors.full_messages\n end\n end", "def destroy\n if not check_logged_in then\n return\n end\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def delete_user\n end", "def destroy\n @login = Login.find(params[:id])\n @login.destroy\n\n respond_to do |format|\n format.html { redirect_to login_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def delete_user(uid)\n begin\n RestClient.delete construct_url(\"user/#{uid}\")\n true\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end \n end", "def delete_users\n delete(users_path)\n end", "def call(id)\n client.delete(\"/api/rest/v1/users/#{id}.json\")\n true\n end", "def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end", "def destroy\n if check_user_write_access\n user.destroy\n\n respond_to do |format|\n format.html { redirect_to :root }\n format.json { head :no_content }\n end\n end\n end", "def delete_user\n client.delete(user)\n end", "def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end", "def delete user_id, options={}, headers={}\n @connection.delete \"users/#{user_id}.json\", options, headers\n end", "def destroy\n @user = User.find_by_id_or_username params[:id]\n @user.destroy\n render api_delete @user\n end", "def destroy\n HerosUsers.destroy_all(:user_id => @user.id)\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n log_out\n @user.destroy\n flash[:success] = \"User was successfully deleted\"\n respond_to do |format|\n format.html { redirect_to users_url}\n format.json { head :no_content }\n end\n end", "def delete_user(user)\n delete user_path(user)\n end", "def destroy\n @user = User.find(params[:user_uuid])\n @user.destroy\n head :ok\n end", "def destroy\n @api_user.destroy\n\n head :no_content\n end", "def destroy\n @smalluser = Smalluser.find(params[:id])\n @smalluser.destroy\n\n respond_to do |format|\n format.html { redirect_to smallusers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to dm_core.admin_users_url }\n format.json { head :no_content }\n end\n end", "def user_delete(user_id)\n res = http_delete(:uri=>\"/users/#{user_id}\", :fields=>x_cookie)\n return res.code\n end", "def destroy\n @user = User.find(session[:user_id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to user_index_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user.destroy\n format.json { head :no_content }\n end", "def destroy\n @trail_user.destroy\n respond_to do |format|\n format.html { redirect_to trail_users_url, notice: 'Trail user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @login.destroy\n respond_to do |format|\n format.html { redirect_to logins_url, notice: 'Login was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @login.destroy\n respond_to do |format|\n format.html { redirect_to logins_url, notice: 'Login was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @login.destroy\n respond_to do |format|\n format.html { redirect_to logins_url, notice: 'Login was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'DELETE',\n path: path,\n headers: headers,\n params: params,\n )\n end", "def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :ok }\n end\n end", "def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n logout\n render json: {:ok => true}\n end", "def destroy\n current_user.destroy\n head 204\n end", "def destroy\n @user = user.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def delete\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n @person.destroy\n @application_session.destroy\n session[:cos_session_id] = nil\n render_json :status => :ok\n end", "def destroy\n @user = current_org.users.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @big_auth_user = BigAuth::User.find(params[:id])\n @big_auth_user.destroy\n\n respond_to do |format|\n format.html { redirect_to(big_auth_users_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @user = current_user;\n @toeic_log = ToeicLog.find(params[:id])\n @toeic_log.destroy\n\n respond_to do |format|\n format.html { redirect_to toeic_logs_url }\n format.json { head :no_content }\n end\n end", "def delete_by_id(user_id)\n Iterable.request(conf, \"/users/byUserId/#{user_id}\").delete\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy_user(id)\n #TODO:\n # ADD SOME USER LEVEL TO AVOID THESE\n end", "def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = current_user\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def test_admin_can_delete_user\n george = setup_dummy_user(\"george\")\n \n # first log in\n get '/login' # need to do this to set up the form container.\n post '/login', { :username => GOOD_USERNAME, :password => GOOD_PASSWORD }\n\n user_id = User.find_by_username(\"george\").id\n\n post \"/user/delete/#{user_id}\"\n assert last_response.ok?\n assert last_response.body.include?(\"has been deleted\")\n assert User.find_by_username(\"george\") == nil\n\n # Try that again and we should get a 'user unknown' error\n post \"/user/delete/#{user_id}\"\n assert last_response.ok?\n assert last_response.body.include?(\"The user id supplied was not recognised\")\n end", "def delete\n @user = User.find(params[:id])\n @user.delete\n redirect_to root_path\n end", "def destroy\n # Make sure the request came from an admin\n unless session[:admin_id]\n redirect_to_home\n return\n end\n \n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def delete\n @linked_user.delete(@uri)\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @login_key = LoginKey.find(params[:id])\n @login_key.destroy\n\n respond_to do |format|\n format.html { redirect_to login_keys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n user_session.log_out\n redirect_to root_url\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n\n if(params[:token].nil?)\n response.status = 400\n render json: {msg: \"Token is not defined\"}\n return\n end\n\n session = validate_session(params[:token])\n\n if session.nil?\n response.status = 401\n render json: {}\n return\n end\n\n begin\n obj = User.find(params[:id])\n\n unless session.user.id == obj.id\n response.status = 403\n render json: {}\n return\n end\n\n # This is what slows down the response.\n # Big DB transactions that delete by foreign key.\n obj.time_sessions.destroy_all\n obj.login_sessions.destroy_all\n\n obj.destroy\n response.status = 20\n render json: {msg: obj.time_sessions.methods}\n rescue ActiveRecord::RecordNotFound => e\n response.status = 404\n render json: {}\n rescue Exception => e\n response.status = 500\n render json: {msg: e}\n end\n\n end", "def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n user = User.find(params[:id])\n if user.destroy\n render json: user\n else\n render json: user.errors\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end", "def delete(user_id)\n self.class.delete(\"/#{@api_ver}/users/#{user_id}\", default_options_to_merge_with)\n end", "def destroy\n destroy = REDIS_LOGIN.del(\"token:#{headers[\"Access-Token\"]}\")\n if destroy == 1\n render json: { status: \"Logged out\" }, status: 200\n else\n render json: { error: \"Trouble logging out. Make sure the user isn't already logged out\" }, status: 200\n end\n end", "def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = get_user(params[:id])\n begin\n @user.destroy\n flash[:notice] = \"User #{@user.login_name} deleted\"\n rescue Exception => e\n flash[:notice] = e.message\n end\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end" ]
[ "0.6999632", "0.69250566", "0.6878558", "0.6854509", "0.6829974", "0.67081314", "0.6701252", "0.66864187", "0.6664197", "0.66506034", "0.6647517", "0.66420484", "0.66255945", "0.6601341", "0.65587085", "0.64986545", "0.64662224", "0.6465173", "0.64557976", "0.64553356", "0.6439063", "0.64084667", "0.6405755", "0.6403466", "0.6402663", "0.6394531", "0.63817215", "0.6380609", "0.6345874", "0.6345874", "0.63448673", "0.6336269", "0.63343674", "0.63245696", "0.6321567", "0.63104767", "0.63088894", "0.62997425", "0.6283804", "0.62795734", "0.6277797", "0.6270264", "0.62701714", "0.6263465", "0.6262382", "0.62621564", "0.62528837", "0.6249204", "0.6247227", "0.6247102", "0.6246581", "0.6238794", "0.6238794", "0.6238794", "0.6233515", "0.6233108", "0.62319696", "0.6228654", "0.62248266", "0.62206596", "0.62189275", "0.621657", "0.62161124", "0.6214797", "0.6213511", "0.6208871", "0.62071866", "0.62053585", "0.62044233", "0.62027276", "0.6202536", "0.62023574", "0.62022823", "0.6200667", "0.6195376", "0.6193057", "0.6190416", "0.61891073", "0.61863047", "0.6180614", "0.6179182", "0.6172033", "0.61712795", "0.6170639", "0.6167019", "0.61666167", "0.61654496", "0.6163847", "0.6159216", "0.6155956", "0.615438", "0.6150805", "0.61489224", "0.61489224", "0.61489224", "0.61489224", "0.61489224", "0.61489224", "0.61489224", "0.61489224" ]
0.66821927
8
Use callbacks to share common setup or constraints between actions.
def set_user_login @user_login = UserLogin.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def user_login_params params.require(:user_login).permit(:timestamp, :user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_entry @entry = params[:id] ? Entry.includes(legislators: :elections).find(params[:id]) : Entry.new(entry_params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def entry_params if user_signed_in? and current_user.admin? if @entry.blank? or @entry.new_record? params.require(:entry).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []}, :user_id, :date, :source_name, :source_url, :published) else params.require(:entry).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []}, :date, :source_name, :source_url, :published) end else params.require(:entry).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []}, :user_id, :date, :source_name, :source_url) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
GET /sign_ups GET /sign_ups.json
def index @sign_ups = SignUp.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @signups = Signup.all\n end", "def index\n @signups = Signup.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @sign_ups = SignUp.all\n\t@referer = request.env['HTTP_REFERER']\n end", "def index\n @pushups = current_user.pushups.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pushups }\n end\n end", "def show\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @signup }\n end\n end", "def show\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @signup }\n end\n end", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end", "def index\n @sign_up_users = SignUpUser.all\n end", "def create\n @signup = Signup.new(signup_params)\n @shift_type = Shift.find(@signup.shift_id).shift_type\n @shifts = Array(Shift.find(@signup.shift_id))\n\n respond_to do |format|\n if @signup.save\n flash.now[:notice] = 'Successfully signed up'\n format.html { render :index }\n # format.html { redirect_to :back, notice: 'Successfully signed up' }\n # format.json { render :show, status: :created, location: @signup }\n format.js\n else\n format.html { render :index }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def index\n @signups = Signup.find(:all, :conditions => ['email = ?', current_user.email])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @signups }\n end\n end", "def create\n @signup = Signup.new(params[:signup])\n \n respond_to do |format|\n if @signup.save\n format.html { redirect_to(root_url, :notice => 'Signup was successfully created.') }\n format.xml { render :xml => @signup, :status => :created, :location => @signup }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @signup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(signup_params)\n if @user.save\n sign_in @user\n respond_to do |format|\n \tformat.json { render json: @user }\n end\n else\n # render :new\n end\n end", "def signup\n end", "def signup\n end", "def index\n redirect_to signup_path\n end", "def sign_up\n NexaasID::Resources::SignUp.new(api_token, config)\n end", "def sign_up\n @user = User.new(user_params)\n if @user.save\n sign_in(@user)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def create\n @sign_up = SignUp.new(sign_up_params)\n\n respond_to do |format|\n if @sign_up.save\n # format.html { redirect_to @sign_up, notice: 'Sign up was successfully created.' }\n format.html { redirect_to panel_path(1)}\n else\n format.html { render :new }\n format.json { render json: @sign_up.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def signups\n Signup.all.select {|signup| signup.opportunity_id == self.id}\n end", "def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n render json: response, status: :internal_server_error\n end\n end", "def signup\n sign_out\n puts '----signup called.----'\n redirect_to '/users/sign_up'\n end", "def sign_up\n user = User.new(user_params); user.id = SecureRandom.uuid # genrating secure uuid token\n if user.save\n image_url = \"\"\n image_url = url_for(user.profile_photo) if user.profile_photo.attached?\n render json: { email: user.email, first_name: user.first_name, last_name: user.last_name, profile_photo: image_url, \"UUID\" => user.id, \"Authentication\" => user.authentication_token }, status: 200\n else\n render json: user.errors.messages, status: 400\n end\n rescue StandardError => e # rescue if any exception occurr\n render json: { message: \"Error: Something went wrong... #{e}\" }, status: 400\n end", "def create\n @pushup = Pushup.new(params[:pushup])\n\n respond_to do |format|\n if @pushup.save\n format.html { redirect_to @pushup, notice: 'Pushup was successfully created.' }\n format.json { render json: @pushup, status: :created, location: @pushup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pushup.errors, status: :unprocessable_entity }\n end\n end \n end", "def create\n @sign_up = SignUp.new(sign_up_params)\n #@sign_up[:user_name] = @sign_up[:first_name][0,3]+@sign_up[:last_name][0,3]+SecureRandom.hex(2)\n respond_to do |format|\n if @sign_up.valid?\n #if @sign_up.save\n #require 'json'\n require 'open-uri'\n require 'net/http'\n #uri = URI.parse('localhost:3000')\n #http = Net::HTTP.new(uri.host, uri.port)\n #req = Net::HTTP::Post.new(uri.path, {'Content-Type' => 'application/json'})\n #req.body = @sign_up.to_json\n #puts \"response #{res.body}\"\n #puts JSON.parse(res.body)\n #request = Net::HTTP::Post.new(url.path)\n #response = Net::HTTP.start(url.host,url.port){|http| http.request(request)}\n #req.form_data = data\n #req.basic_auth url.user, url.password if url.user\n #con =Net::HTTP.new(url.host, url.port)\n #con.use_SSL = true\n #con.start {|http| http.request(req)}\n format.html { redirect_to sign_ups_url, notice: \"Congratulations on successfully signing up for E-tickets!\" }\n format.json { render :show, status: :created, location: @sign_up }\n else\n format.html { render :new }\n format.json { render json: @sign_up.errors, status: :unprocessable_entity }\n end \n end\n end", "def show\n @sign_up = SignUp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sign_up }\n end\n end", "def sign_up(user = {})\n if @api_host.present? && user.present?\n begin\n request_url = @api_host + \"/api/v1/sign_up\"\n payload = Hash.new\n payload[:user] = user\n request_headers = { \"Content-Type\" => \"application/json\" }\n response = RestClient.post(request_url, payload.to_json, request_headers)\n result = JSON.parse(response.body)\n Rails.logger.info \"===== sign up result ===== #{result} =====\"\n result\n rescue RestClient::ExceptionWithResponse => e\n error = JSON.parse(e.response)\n Rails.logger.warn \"===== sign up errors ===== #{error} =====\"\n error\n end\n end\n end", "def new\n @sign_up = SignUp.new\n end", "def signup(params={})\n begin\n JSON.parse(RestClient.put construct_url(\"user\"), params)\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end", "def show\n @beta_sign_up = BetaSignUp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beta_sign_up }\n end\n end", "def signup\n puts 'signup is happening here'\n permitted = params.require('signup').permit(['email', 'password', 'password_confirmation'])\n @newUser = User.new(permitted)\n if @newUser.save\n head :ok\n else\n render json:{\"reason\": \"could not create user\"}, status: 422\n end\n end", "def signup_info\n end", "def create\n @sign_up_user = SignUpUser.new(sign_up_user_params)\n # @sign_up_user = SignUpUser.new(user_params)\n\n respond_to do |format|\n if @sign_up_user.save\n format.html { redirect_to @sign_up_user, notice: 'Sign up user was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sign_up_user }\n else\n format.html { render action: 'new' }\n format.json { render json: @sign_up_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @sep_signup = SepSignup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sep_signup }\n end\n end", "def show\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def show\n @pushup = Pushup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pushup }\n end\n end", "def sign_up\n if @worksession.free == false\n respond_to do |format|\n format.html {\n flash[:notice] = 'Worksession is unavailable. Please choose another'\n redirect_to available_path\n }\n end\n else\n if !params[:notes].nil?\n @worksession.notes = params[:notes]\n end\n booking = Booking.create(user_id: @user.id, worksession_id: @worksession.id, notes: params[:notes])\n\n if Rails.env.production?\n url = URI.parse('http://worksessions-notifier.pierobotics.org/api/v0/signup/')\n else\n url = URI.parse('http://worksessions-notifier-staging.pierobotics.org/api/v0/signup/')\n end\n Net::HTTP.post_form(url, {\n 'notes' => booking.notes,\n 'date' => @worksession.date.strftime(\"%m/%d/%Y\"),\n 'start_time' => @worksession.begin_at.strftime(\"%I:%M %P\"),\n 'end_time' => @worksession.end_at.strftime(\"%I:%M %P\"),\n 'school' => @user.team_name,\n })\n\n # @worksession.users << @user\n if (@worksession.date.wday.between?(0, 1) and @worksession.users.size >= 8) or (@worksession.date.wday.between?(5, 6) and @worksession.users.size >= 4)\n @worksession.free = false\n @worksession.save\n end\n redirect_to available_path\n end\n\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def all\n path = \"/signers\"\n\n response, status = BeyondApi::Request.get(@session,\n path)\n\n handle_response(response, status)\n end", "def create\n path = \"/signers\"\n\n response, status = BeyondApi::Request.post(@session,\n path)\n\n handle_response(response, status)\n end", "def create\n build_resource(sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n render json: resource # , location: after_sign_up_path_for(resource)\n else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end", "def new\n @pushup = Pushup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pushup }\n end\n end", "def sign_up_users(first_name, last_name, email, password)\n find_by_id('com.yelp.android:id/first_name').send_key first_name\n find_by_id('com.yelp.android:id/last_name').send_key last_name\n find_by_id('com.yelp.android:id/email_address').send_key email\n find_by_id('com.yelp.android:id/password').send_key password\n find_name('Gender')\n find_name('Male')\n end", "def create\n\n @seminar = Seminar.find(params[:seminar_id])\n\n @signup = Signup.new(signup_params)\n\n respond_to do |format|\n if @signup.save\n format.html { redirect_to @seminar, notice: \"Signup was successfully created.\" }\n format.json { render :show, status: :created, location: @seminar }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @beta_sign_up = BetaSignUp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beta_sign_up }\n end\n end", "def index\n @registrations = Registration.all\n \n render json: @registrations\n end", "def index\n @cat_gifs = CatGif.all\n @signup = Signup.new\n end", "def list\r\n\t\t@current_area = 'newsletter_signups'\r\n\t\t@current_menu = 'newsletter_signups'\r\n\r\n\t\tsort_order ||= get_sort_order(\"s-name\", [\"first_name\", \"last_name\"])\r\n\t\tsort_order ||= get_sort_order(\"s-email\", \"email\")\r\n\t\tsort_order ||= \"id ASC\"\r\n\r\n\t\tpage = params[:page] ? params[:page].to_i : 1\r\n\t\titems_per_page = 30\r\n\t\toffset = (page - 1) * items_per_page\r\n\r\n\t\tif params[:delete] and params[:select]\r\n\t\t\tc = params[:select].keys.collect do |cur_key|\r\n\t\t\t\tNewsletterSignup.delete(cur_key.to_i)\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\t@signup_count = NewsletterSignup.count\r\n\r\n\t\t@pages = Paginator.new(self, @signup_count, items_per_page, page)\r\n\r\n\t\t@signups = NewsletterSignup.find(:all, :order => sort_order)\r\n\tend", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def sign_up\n\t\tif params[:uuid].present?\n\t\t\t@existing_member = Com::Nbos::User.where(uuid: params[:uuid])\n\t\t\tif @existing_member.present?\n\t\t\t\trender :json => @existing_member.first\n\t\t\telse\n\t\t\t\t@member = build_user(params)\n\t\t\t\tif @member && @member.save\n\t\t\t\t\trender :json => @member\n\t\t\t\telse\n\t\t\t\t\trender :json => {status: 500, message: @member.errors.messages}, status: 500\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\trender :json => {status: 400, message: \"Bad Request\"}, status: 400\n\t\tend\t\n\tend", "def new\n session[:signup_params] ||= {}\n @user = User.new(session[:signup_params])\n @user.signup_current_step = session[:signup_step]\t\n# @company = @user.build_company\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @sep_signup = SepSignup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sep_signup }\n end\n end", "def create\n @sign_up = SignUp.new(params[:sign_up])\n\t@referer ||= request.env['HTTP_REFERER']\n\t@sign_up.ip_address = request.remote_ip\n @sign_up.user_agent = request.env['HTTP_USER_AGENT']\n @sign_up.referer = @referer\n\n respond_to do |format|\n if @sign_up.save\n format.html { render :action => \"thanks\", :notice => 'Sign up was successful.' }\n #redirect_to :thanks\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sign_up.errors, :status => :unprocessable_entity }\n end\n end\n end", "def signups\n sign_up = []\n lists = self.listings.map {|listing| listing.id}\n PlayerSignup.all.select do |signup|\n if lists.any?(signup.listing_id)\n sign_up << signup\n end\n end\n sign_up\n end", "def users(args = {})\n get(\"/users.json\",args)\n end", "def destroy\n @sign_up.destroy\n respond_to do |format|\n format.html { redirect_to sign_ups_url, notice: 'Sign up was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sign_up.destroy\n respond_to do |format|\n format.html { redirect_to sign_ups_url, notice: 'Sign up was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def user_signup_freq\r\n users = User.find_by_sql(\"select count(*) count, date(created_at) created_at from users group by date(created_at)\")\r\n respond_with users.to_json :methods => :count\r\n end", "def new\n @user = User.new\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @user }\n # end\n render :users => \"signup\"\n end", "def users\n signups.map do |signup|\n user_id = signup.user_id\n User.all.find {|user| user.id == user_id}\n end\n end", "def create\n @sep_signup = SepSignup.new(params[:sep_signup])\n\n respond_to do |format|\n if @sep_signup.save\n format.html { redirect_to @sep_signup, notice: 'Sep signup was successfully created.' }\n format.json { render json: @sep_signup, status: :created, location: @sep_signup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sep_signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n build_resource(configure_sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n render json: resource # , location: after_sign_up_path_for(resource)\n else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n render json: { error_messages: resource.errors.full_messages.join(', ') }, status: 422\n end\n end", "def index\n @accounts = current_user.person.gmail_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n # @signs = Sign.all\n end", "def index \n #Show all users \n @users = User.all\n render json: @users.as_json(only: [:id, :first_name, :last_name, :email, :business_name, :business_verticals, :business_neighborhood, :created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at])\n end", "def new\n @title = \"sign up\"\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def index\n @registration_requests = RegistrationRequest.all\n\n render json: @registration_requests\n end", "def new\n @title = \"Signup\"\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def sign_up(resource_name, resource)\n redirect_to users_url\n end", "def create\n \thashPassword= Digest::MD5.hexdigest(params[:signup][:password])\n\t\tnewParams={\"name\" => params[:signup][:name], \"email\" => params[:signup][:email], \"password\" => hashPassword, \"phone\" => params[:signup][:phone] }\n\t\t@signup = Signup.new(newParams)\n respond_to do |format|\n if @signup.save\n\t\t\t\t@first = \"first\"\n\t\t\t\tformat.html { render action: \"login\" }\n #format.html { redirect_to @signup, notice: hashPassword }\n format.json { render json: @signup, status: :created, location: @signup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n users = User.all\n json_response(users)\n end", "def create\n p 'hello world'\n @user = User.create(sign_up_params)\n if @user\n create_jwt_with({ user_id: @user.id })\n render json: { user: { username: @user.email } }, status: :created\n else\n render json: { errors: user.errors }, status: :unprocessable_entity\n end\n end", "def index\n @devises = Devise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @devises }\n end\n end", "def index\r\n if user_signed_in?\r\n redirect_to(user_root_url)\r\n else\r\n @signupEmail = SignupEmail.new\r\n @signupEmail.email = 'Email Address'\r\n respond_to do |format|\r\n format.html #signup.html.erb\r\n end\r\n end\r\n end", "def create\n build_resource(configure_sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n respond_to do |format|\n format.json { \n render json: resource # , location: after_sign_up_path_for(resource)\n }\n format.html {respond_with resource, location: after_sign_up_path_for(resource)}\n end\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_to do |format|\n format.json { \n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n }\n format.html {respond_with resource, location: after_inactive_sign_up_path_for(resource)}\n end\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_to do |format|\n format.json { render json: { error_messages: resource.errors.full_messages.join(', ') }, status: 422 }\n format.html {respond_with resource}\n end\n end\n end", "def signup\n @user = User.new(params[:user])\n if @user.save\n redirect_to :controller => 'sessions', :action => 'new'\n else\n render'index'\n flash.now[:error]= \"Sign up failure, please try again.\"\n end\n end", "def get_signup(req)\n render template_path()\n end", "def index\n email = AuthenticationHelper::Auth.instance.getEmailFromJWT( request )\n if ( email == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n user = User.find_by(email: email)\n if ( user )\n accounts = Account.where(user_id: user[\"id\"])\n render json: accounts, status: :ok\n else\n render json: :nothing, status: :unprocessable_entity\n end\n end", "def create\n @alphasignup = Alphasignup.new(params[:alphasignup])\n\n respond_to do |format|\n if @alphasignup.save\n format.html { redirect_to(@alphasignup, :notice => 'Thank you for signing up.') }\n format.xml { render :xml => @alphasignup, :status => :created, :location => @alphasignup }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @alphasignup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n users = User.all\n # cheer_ups = CheerUp.all\n render json: users\n end", "def sign_up\n service_response = UserManagement::SignUp.new(\n params.merge({\n is_client_manager: 1,\n client_creation_needed: 1,\n browser_user_agent: http_user_agent\n })\n ).perform\n\n if service_response.success?\n # NOTE: delete cookie value from data\n cookie_value = service_response.data.delete(:cookie_value)\n set_cookie(\n GlobalConstant::Cookie.user_cookie_name,\n cookie_value,\n GlobalConstant::Cookie.user_expiry.from_now\n )\n end\n\n render_api_response(service_response)\n end", "def index\n @signupsurveys = Signupsurvey.all\n end", "def index\n @sermon_sign_ins = SermonSignIn.all\n end", "def list\r\n users = User.all\r\n render json: users\r\n end", "def create\n @user = User.new(filter_sign_up_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user.profile, :notice => \"Welcome #{@user.name}!\" }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n errors = @user.errors.full_messages\n format.html { redirect_to signup_path({errors: errors}), flash: {error: 'Invalid email or password.'}}\n format.json { render :json => {errors: @user.errors, type: 'register'}, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @form = Users::SignUpForm.from_params(params)\n\n Users::SignUp.call(@form) do\n on(:ok) { redirect_to dashboard_index_path }\n on(:invalid) { render :new}\n on(:race_non_unique_email) do\n flash.now[:alert] = t(:email_taken)\n render :new\n end\n end\n end", "def index\n json_response(User.all) \n end", "def show\n @users = User.all\n json_response(@users)\n end", "def index\r\n users = User.all\r\n render json: users\r\n end", "def show\n render json: @registration_request\n end", "def client_sign_up\n\n end", "def index\n @users = User.all\n render json: @users, status: :ok\n end", "def index\n # page = params[:page] || 1\n # per_page = params[:per_page] || 6\n # @signs = Sign.all.paginate(page: page, per_page: per_page)\n @signs = Sign.all.page(params[:page]).per(5)\n respond_with(@signs)\n end", "def create\n @user = User.new(params[:user])\n if @user.save \n sign_in @user\n Notifier.welcome(@user.name, @user.email).deliver\n flash[:success] = \"welcome to sample app\"\n redirect_to cookies[:come_from] || user_path(@user)\n else\n @title = \"Signup\" \n render action: \"new\" \n #format.json { render json: @user }\n end\n end" ]
[ "0.7269794", "0.66862106", "0.66491365", "0.65528953", "0.64501303", "0.64501303", "0.6369708", "0.6369708", "0.6357562", "0.6316043", "0.62663263", "0.6149291", "0.6113419", "0.60685915", "0.60685915", "0.60259974", "0.5973351", "0.5962522", "0.5952868", "0.592961", "0.5884364", "0.5884364", "0.5868161", "0.58602613", "0.5845452", "0.5815692", "0.5803537", "0.5802722", "0.5794032", "0.5781657", "0.5776009", "0.5766845", "0.5757008", "0.5747435", "0.57110673", "0.5709566", "0.56983644", "0.5692975", "0.5689924", "0.56829804", "0.5658366", "0.5658366", "0.5658366", "0.56575346", "0.5639319", "0.56239986", "0.5620026", "0.56193405", "0.5605179", "0.5598636", "0.5595441", "0.5593059", "0.5592668", "0.5589692", "0.558571", "0.5584115", "0.5582154", "0.5562582", "0.5562441", "0.55576557", "0.55361325", "0.55361325", "0.5530769", "0.5528928", "0.5513527", "0.5492707", "0.546919", "0.54639494", "0.54636216", "0.54490364", "0.5447356", "0.54419947", "0.5437831", "0.5432287", "0.54219306", "0.5420351", "0.54108286", "0.5410804", "0.5405196", "0.54025453", "0.5397804", "0.539741", "0.53766435", "0.5373498", "0.5367272", "0.5365217", "0.53614026", "0.53566", "0.5355251", "0.53450036", "0.5344409", "0.53342116", "0.5320165", "0.53131455", "0.5308284", "0.5306572", "0.53014785", "0.53000855", "0.529724" ]
0.73521084
0
GET /sign_ups/1 GET /sign_ups/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @sign_ups = SignUp.all\n end", "def index\n @sign_ups = SignUp.all\n end", "def index\n @signups = Signup.all\n end", "def show\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @signup }\n end\n end", "def show\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @signup }\n end\n end", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end", "def index\n @signups = Signup.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @pushups = current_user.pushups.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pushups }\n end\n end", "def index\n @sign_ups = SignUp.all\n\t@referer = request.env['HTTP_REFERER']\n end", "def show\n @pushup = Pushup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pushup }\n end\n end", "def show\n @sep_signup = SepSignup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sep_signup }\n end\n end", "def show\n @sign_up = SignUp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sign_up }\n end\n end", "def show\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def create\n @user = User.new(signup_params)\n if @user.save\n sign_in @user\n respond_to do |format|\n \tformat.json { render json: @user }\n end\n else\n # render :new\n end\n end", "def create\n @signup = Signup.new(signup_params)\n @shift_type = Shift.find(@signup.shift_id).shift_type\n @shifts = Array(Shift.find(@signup.shift_id))\n\n respond_to do |format|\n if @signup.save\n flash.now[:notice] = 'Successfully signed up'\n format.html { render :index }\n # format.html { redirect_to :back, notice: 'Successfully signed up' }\n # format.json { render :show, status: :created, location: @signup }\n format.js\n else\n format.html { render :index }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def show\n @beta_sign_up = BetaSignUp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beta_sign_up }\n end\n end", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def index\n @signups = Signup.find(:all, :conditions => ['email = ?', current_user.email])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @signups }\n end\n end", "def new\n @pushup = Pushup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pushup }\n end\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n render json: response, status: :internal_server_error\n end\n end", "def index\n @sign_up_users = SignUpUser.all\n end", "def create\n @signup = Signup.new(params[:signup])\n \n respond_to do |format|\n if @signup.save\n format.html { redirect_to(root_url, :notice => 'Signup was successfully created.') }\n format.xml { render :xml => @signup, :status => :created, :location => @signup }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @signup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @sign_up = SignUp.new\n end", "def sign_up\n NexaasID::Resources::SignUp.new(api_token, config)\n end", "def sign_up\n user = User.new(user_params); user.id = SecureRandom.uuid # genrating secure uuid token\n if user.save\n image_url = \"\"\n image_url = url_for(user.profile_photo) if user.profile_photo.attached?\n render json: { email: user.email, first_name: user.first_name, last_name: user.last_name, profile_photo: image_url, \"UUID\" => user.id, \"Authentication\" => user.authentication_token }, status: 200\n else\n render json: user.errors.messages, status: 400\n end\n rescue StandardError => e # rescue if any exception occurr\n render json: { message: \"Error: Something went wrong... #{e}\" }, status: 400\n end", "def new\n @sep_signup = SepSignup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sep_signup }\n end\n end", "def sign_up(user = {})\n if @api_host.present? && user.present?\n begin\n request_url = @api_host + \"/api/v1/sign_up\"\n payload = Hash.new\n payload[:user] = user\n request_headers = { \"Content-Type\" => \"application/json\" }\n response = RestClient.post(request_url, payload.to_json, request_headers)\n result = JSON.parse(response.body)\n Rails.logger.info \"===== sign up result ===== #{result} =====\"\n result\n rescue RestClient::ExceptionWithResponse => e\n error = JSON.parse(e.response)\n Rails.logger.warn \"===== sign up errors ===== #{error} =====\"\n error\n end\n end\n end", "def create\n @sign_up = SignUp.new(sign_up_params)\n #@sign_up[:user_name] = @sign_up[:first_name][0,3]+@sign_up[:last_name][0,3]+SecureRandom.hex(2)\n respond_to do |format|\n if @sign_up.valid?\n #if @sign_up.save\n #require 'json'\n require 'open-uri'\n require 'net/http'\n #uri = URI.parse('localhost:3000')\n #http = Net::HTTP.new(uri.host, uri.port)\n #req = Net::HTTP::Post.new(uri.path, {'Content-Type' => 'application/json'})\n #req.body = @sign_up.to_json\n #puts \"response #{res.body}\"\n #puts JSON.parse(res.body)\n #request = Net::HTTP::Post.new(url.path)\n #response = Net::HTTP.start(url.host,url.port){|http| http.request(request)}\n #req.form_data = data\n #req.basic_auth url.user, url.password if url.user\n #con =Net::HTTP.new(url.host, url.port)\n #con.use_SSL = true\n #con.start {|http| http.request(req)}\n format.html { redirect_to sign_ups_url, notice: \"Congratulations on successfully signing up for E-tickets!\" }\n format.json { render :show, status: :created, location: @sign_up }\n else\n format.html { render :new }\n format.json { render json: @sign_up.errors, status: :unprocessable_entity }\n end \n end\n end", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @title = \"Signup\"\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def sign_up\n @user = User.new(user_params)\n if @user.save\n sign_in(@user)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @sign_up = SignUp.new(sign_up_params)\n\n respond_to do |format|\n if @sign_up.save\n # format.html { redirect_to @sign_up, notice: 'Sign up was successfully created.' }\n format.html { redirect_to panel_path(1)}\n else\n format.html { render :new }\n format.json { render json: @sign_up.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @beta_sign_up = BetaSignUp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beta_sign_up }\n end\n end", "def get_profile\n path = self.api_root + '/register/profile'\n process_firecloud_request(:get, path)\n end", "def new\n session[:signup_params] ||= {}\n @user = User.new(session[:signup_params])\n @user.signup_current_step = session[:signup_step]\t\n# @company = @user.build_company\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def signup\n end", "def signup\n end", "def new\n @title = \"sign up\"\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def create\n @pushup = Pushup.new(params[:pushup])\n\n respond_to do |format|\n if @pushup.save\n format.html { redirect_to @pushup, notice: 'Pushup was successfully created.' }\n format.json { render json: @pushup, status: :created, location: @pushup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pushup.errors, status: :unprocessable_entity }\n end\n end \n end", "def sign_up\n\t\tif params[:uuid].present?\n\t\t\t@existing_member = Com::Nbos::User.where(uuid: params[:uuid])\n\t\t\tif @existing_member.present?\n\t\t\t\trender :json => @existing_member.first\n\t\t\telse\n\t\t\t\t@member = build_user(params)\n\t\t\t\tif @member && @member.save\n\t\t\t\t\trender :json => @member\n\t\t\t\telse\n\t\t\t\t\trender :json => {status: 500, message: @member.errors.messages}, status: 500\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\trender :json => {status: 400, message: \"Bad Request\"}, status: 400\n\t\tend\t\n\tend", "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def signup(params={})\n begin\n JSON.parse(RestClient.put construct_url(\"user\"), params)\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end", "def new\n @user = User.new\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @user }\n # end\n render :users => \"signup\"\n end", "def signups\n Signup.all.select {|signup| signup.opportunity_id == self.id}\n end", "def index\n redirect_to signup_path\n end", "def create\n \thashPassword= Digest::MD5.hexdigest(params[:signup][:password])\n\t\tnewParams={\"name\" => params[:signup][:name], \"email\" => params[:signup][:email], \"password\" => hashPassword, \"phone\" => params[:signup][:phone] }\n\t\t@signup = Signup.new(newParams)\n respond_to do |format|\n if @signup.save\n\t\t\t\t@first = \"first\"\n\t\t\t\tformat.html { render action: \"login\" }\n #format.html { redirect_to @signup, notice: hashPassword }\n format.json { render json: @signup, status: :created, location: @signup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sign_up_user = SignUpUser.new(sign_up_user_params)\n # @sign_up_user = SignUpUser.new(user_params)\n\n respond_to do |format|\n if @sign_up_user.save\n format.html { redirect_to @sign_up_user, notice: 'Sign up user was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sign_up_user }\n else\n format.html { render action: 'new' }\n format.json { render json: @sign_up_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def signup\n puts 'signup is happening here'\n permitted = params.require('signup').permit(['email', 'password', 'password_confirmation'])\n @newUser = User.new(permitted)\n if @newUser.save\n head :ok\n else\n render json:{\"reason\": \"could not create user\"}, status: 422\n end\n end", "def signup_info\n end", "def destroy\n @sign_up.destroy\n respond_to do |format|\n format.html { redirect_to sign_ups_url, notice: 'Sign up was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sign_up.destroy\n respond_to do |format|\n format.html { redirect_to sign_ups_url, notice: 'Sign up was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @meetup_profile = MeetupProfile.find(params[:id])\n @meetup=Meetup.new\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meetup_profile }\n end\n end", "def show\n @user = User.where('email = ?',params[:email]).take\n render json: @user\n end", "def index\n @accounts = current_user.person.gmail_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def show\n render json: @registration_request\n end", "def destroy\n @signup = Signup.find(params[:id])\n @signup.destroy\n\n respond_to do |format|\n format.html { redirect_to signups_url }\n format.json { head :ok }\n end\n end", "def index\n @cat_gifs = CatGif.all\n @signup = Signup.new\n end", "def show\n \n @meetup = Meetup.find(params[:id])\n render json: {\n meetup: MeetupSerializer.new(@meetup)\n }\n end", "def create\n\n @seminar = Seminar.find(params[:seminar_id])\n\n @signup = Signup.new(signup_params)\n\n respond_to do |format|\n if @signup.save\n format.html { redirect_to @seminar, notice: \"Signup was successfully created.\" }\n format.json { render :show, status: :created, location: @seminar }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @registrations = Registration.all\n \n render json: @registrations\n end", "def show\n @badge = Badge.find(params[:id])\n @users = @badge.users\n respond_with @badge\n end", "def signup\n sign_out\n puts '----signup called.----'\n redirect_to '/users/sign_up'\n end", "def get_default_profile \n get(\"/profiles.json/default\")\nend", "def create\n p 'hello world'\n @user = User.create(sign_up_params)\n if @user\n create_jwt_with({ user_id: @user.id })\n render json: { user: { username: @user.email } }, status: :created\n else\n render json: { errors: user.errors }, status: :unprocessable_entity\n end\n end", "def new\n @title = \"Sign Up\"\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def show\n @signout_log = SignoutLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @signout_log }\n end\n end", "def destroy\n @signup = Signup.find(params[:id])\n @signup.destroy\n\n respond_to do |format|\n format.html { redirect_to signups_url }\n format.json { head :no_content }\n end\n end", "def index\n # @signs = Sign.all\n end", "def profile\n p @user.as_json\n render json: @user.as_json\n end", "def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def create\n @sign_up = SignUp.new(params[:sign_up])\n\t@referer ||= request.env['HTTP_REFERER']\n\t@sign_up.ip_address = request.remote_ip\n @sign_up.user_agent = request.env['HTTP_USER_AGENT']\n @sign_up.referer = @referer\n\n respond_to do |format|\n if @sign_up.save\n format.html { render :action => \"thanks\", :notice => 'Sign up was successful.' }\n #redirect_to :thanks\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sign_up.errors, :status => :unprocessable_entity }\n end\n end\n end", "def user_signup_freq\r\n users = User.find_by_sql(\"select count(*) count, date(created_at) created_at from users group by date(created_at)\")\r\n respond_with users.to_json :methods => :count\r\n end", "def show\n json_response(@user_subscription)\n end", "def index\n @registration_requests = RegistrationRequest.all\n\n render json: @registration_requests\n end", "def get_registration\n path = self.api_root + '/register'\n process_firecloud_request(:get, path)\n end", "def get_signup(req)\n render template_path()\n end", "def api_sign_in\n user = users(:one)\n post '/auth/sign_in', params: { email: user.uid, password: \"secret123\" }\n\n return { \n \"uid\" => response.headers[\"uid\"],\n \"access-token\" => response.headers[\"access-token\"],\n \"client\" => response.headers[\"client\"] }\n end", "def user\n render :json=> User.find(params[:id])\n end", "def index\n json_response(User.all) \n end", "def user\n hash = {\n provider: 'josh_id',\n id: current_user.id.to_s,\n info: {\n email: current_user.email,\n username: current_user.username,\n #first_name: current_user.first_name,\n }\n }\n\n render json: hash.to_json\n end", "def show\n json_response(@user)\n end", "def index\n email = AuthenticationHelper::Auth.instance.getEmailFromJWT( request )\n if ( email == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n user = User.find_by(email: email)\n if ( user )\n accounts = Account.where(user_id: user[\"id\"])\n render json: accounts, status: :ok\n else\n render json: :nothing, status: :unprocessable_entity\n end\n end", "def show\n @users = User.all\n json_response(@users)\n end", "def index\n @user = current_user\n render 'signup/step2'\n end", "def users\n signups.map do |signup|\n user_id = signup.user_id\n User.all.find {|user| user.id == user_id}\n end\n end", "def show\n render json: User.find(params[\"id\"])\n end", "def index\n users = User.all\n json_response(users)\n end", "def create\n build_resource(sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n render json: resource # , location: after_sign_up_path_for(resource)\n else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end", "def new\n @user = User.new\n @button_text = \"Sign up!\"\n @show_tos = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @user }\n end\n end", "def new\n @meetup_profile = MeetupProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meetup_profile }\n end\n end", "def show\n @profile = Profile.find(params[:id])\n @checkin = CheckIn.find_last_by_user_id(@profile.user_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile }\n end\n end", "def show\n @profile = Profile.find(params[:id])\n @checkin = CheckIn.find_last_by_user_id(@profile.user_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile }\n end\n end", "def show\n @account = current_user.person.gmail_accounts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @account }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pushup_reminder }\n end\n end", "def index\n users = User.all\n # cheer_ups = CheerUp.all\n render json: users\n end" ]
[ "0.69810617", "0.69810617", "0.69421405", "0.6882965", "0.6882965", "0.6611339", "0.6611339", "0.6487169", "0.64816374", "0.62820333", "0.6174569", "0.60812324", "0.6080178", "0.60731083", "0.60451823", "0.6044911", "0.6018202", "0.59914106", "0.59914106", "0.5987988", "0.59347224", "0.5928106", "0.5928106", "0.5928106", "0.59086305", "0.58876896", "0.586539", "0.5839363", "0.5838551", "0.5820742", "0.5792484", "0.57819366", "0.57697827", "0.57495767", "0.5745345", "0.5744125", "0.57001233", "0.5689746", "0.5688012", "0.56874126", "0.56857854", "0.56857854", "0.56786275", "0.5663878", "0.56504476", "0.5612132", "0.56053066", "0.5577415", "0.5575704", "0.55745536", "0.5540599", "0.55367035", "0.55151004", "0.5512439", "0.549068", "0.549068", "0.54736197", "0.54705817", "0.54551023", "0.54485", "0.5438092", "0.54297817", "0.5428482", "0.5428047", "0.540554", "0.53938705", "0.5385529", "0.53766716", "0.5375631", "0.5374785", "0.53642684", "0.5363211", "0.53594923", "0.535845", "0.5353043", "0.5350306", "0.5327088", "0.5321069", "0.53105927", "0.5305422", "0.53051883", "0.53042597", "0.52915674", "0.5286414", "0.5280054", "0.5273583", "0.52732164", "0.5268969", "0.5266142", "0.5260079", "0.52591836", "0.5253767", "0.5253074", "0.5248315", "0.52452636", "0.52412695", "0.52363294", "0.52363294", "0.523438", "0.52328414", "0.5232413" ]
0.0
-1
POST /sign_ups POST /sign_ups.json
def create @sign_up = SignUp.new(sign_up_params) respond_to do |format| if @sign_up.save # format.html { redirect_to @sign_up, notice: 'Sign up was successfully created.' } format.html { redirect_to panel_path(1)} else format.html { render :new } format.json { render json: @sign_up.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def signup(params={})\n begin\n JSON.parse(RestClient.put construct_url(\"user\"), params)\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end", "def create\n @signup = Signup.new(params[:signup])\n \n respond_to do |format|\n if @signup.save\n format.html { redirect_to(root_url, :notice => 'Signup was successfully created.') }\n format.xml { render :xml => @signup, :status => :created, :location => @signup }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @signup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def signup\n puts 'signup is happening here'\n permitted = params.require('signup').permit(['email', 'password', 'password_confirmation'])\n @newUser = User.new(permitted)\n if @newUser.save\n head :ok\n else\n render json:{\"reason\": \"could not create user\"}, status: 422\n end\n end", "def signup\n end", "def signup\n end", "def create\n @user = User.new(signup_params)\n if @user.save\n sign_in @user\n respond_to do |format|\n \tformat.json { render json: @user }\n end\n else\n # render :new\n end\n end", "def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n render json: response, status: :internal_server_error\n end\n end", "def create\n @signup = Signup.new(signup_params)\n @shift_type = Shift.find(@signup.shift_id).shift_type\n @shifts = Array(Shift.find(@signup.shift_id))\n\n respond_to do |format|\n if @signup.save\n flash.now[:notice] = 'Successfully signed up'\n format.html { render :index }\n # format.html { redirect_to :back, notice: 'Successfully signed up' }\n # format.json { render :show, status: :created, location: @signup }\n format.js\n else\n format.html { render :index }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def sign_up\n @user = User.new(user_params)\n if @user.save\n sign_in(@user)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def sign_up\n NexaasID::Resources::SignUp.new(api_token, config)\n end", "def create\n @sign_up_user = SignUpUser.new(sign_up_user_params)\n # @sign_up_user = SignUpUser.new(user_params)\n\n respond_to do |format|\n if @sign_up_user.save\n format.html { redirect_to @sign_up_user, notice: 'Sign up user was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sign_up_user }\n else\n format.html { render action: 'new' }\n format.json { render json: @sign_up_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pushup = Pushup.new(params[:pushup])\n\n respond_to do |format|\n if @pushup.save\n format.html { redirect_to @pushup, notice: 'Pushup was successfully created.' }\n format.json { render json: @pushup, status: :created, location: @pushup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pushup.errors, status: :unprocessable_entity }\n end\n end \n end", "def create\n @sign_up = SignUp.new(sign_up_params)\n #@sign_up[:user_name] = @sign_up[:first_name][0,3]+@sign_up[:last_name][0,3]+SecureRandom.hex(2)\n respond_to do |format|\n if @sign_up.valid?\n #if @sign_up.save\n #require 'json'\n require 'open-uri'\n require 'net/http'\n #uri = URI.parse('localhost:3000')\n #http = Net::HTTP.new(uri.host, uri.port)\n #req = Net::HTTP::Post.new(uri.path, {'Content-Type' => 'application/json'})\n #req.body = @sign_up.to_json\n #puts \"response #{res.body}\"\n #puts JSON.parse(res.body)\n #request = Net::HTTP::Post.new(url.path)\n #response = Net::HTTP.start(url.host,url.port){|http| http.request(request)}\n #req.form_data = data\n #req.basic_auth url.user, url.password if url.user\n #con =Net::HTTP.new(url.host, url.port)\n #con.use_SSL = true\n #con.start {|http| http.request(req)}\n format.html { redirect_to sign_ups_url, notice: \"Congratulations on successfully signing up for E-tickets!\" }\n format.json { render :show, status: :created, location: @sign_up }\n else\n format.html { render :new }\n format.json { render json: @sign_up.errors, status: :unprocessable_entity }\n end \n end\n end", "def create\n\n @seminar = Seminar.find(params[:seminar_id])\n\n @signup = Signup.new(signup_params)\n\n respond_to do |format|\n if @signup.save\n format.html { redirect_to @seminar, notice: \"Signup was successfully created.\" }\n format.json { render :show, status: :created, location: @seminar }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sep_signup = SepSignup.new(params[:sep_signup])\n\n respond_to do |format|\n if @sep_signup.save\n format.html { redirect_to @sep_signup, notice: 'Sep signup was successfully created.' }\n format.json { render json: @sep_signup, status: :created, location: @sep_signup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sep_signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sign_up = SignUp.new(params[:sign_up])\n\t@referer ||= request.env['HTTP_REFERER']\n\t@sign_up.ip_address = request.remote_ip\n @sign_up.user_agent = request.env['HTTP_USER_AGENT']\n @sign_up.referer = @referer\n\n respond_to do |format|\n if @sign_up.save\n format.html { render :action => \"thanks\", :notice => 'Sign up was successful.' }\n #redirect_to :thanks\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sign_up.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n path = \"/signers\"\n\n response, status = BeyondApi::Request.post(@session,\n path)\n\n handle_response(response, status)\n end", "def sign_up(user = {})\n if @api_host.present? && user.present?\n begin\n request_url = @api_host + \"/api/v1/sign_up\"\n payload = Hash.new\n payload[:user] = user\n request_headers = { \"Content-Type\" => \"application/json\" }\n response = RestClient.post(request_url, payload.to_json, request_headers)\n result = JSON.parse(response.body)\n Rails.logger.info \"===== sign up result ===== #{result} =====\"\n result\n rescue RestClient::ExceptionWithResponse => e\n error = JSON.parse(e.response)\n Rails.logger.warn \"===== sign up errors ===== #{error} =====\"\n error\n end\n end\n end", "def create\n @form = Users::SignUpForm.from_params(params)\n\n Users::SignUp.call(@form) do\n on(:ok) { redirect_to dashboard_index_path }\n on(:invalid) { render :new}\n on(:race_non_unique_email) do\n flash.now[:alert] = t(:email_taken)\n render :new\n end\n end\n end", "def sign_up\n user = User.new(user_params); user.id = SecureRandom.uuid # genrating secure uuid token\n if user.save\n image_url = \"\"\n image_url = url_for(user.profile_photo) if user.profile_photo.attached?\n render json: { email: user.email, first_name: user.first_name, last_name: user.last_name, profile_photo: image_url, \"UUID\" => user.id, \"Authentication\" => user.authentication_token }, status: 200\n else\n render json: user.errors.messages, status: 400\n end\n rescue StandardError => e # rescue if any exception occurr\n render json: { message: \"Error: Something went wrong... #{e}\" }, status: 400\n end", "def create\n p 'hello world'\n @user = User.create(sign_up_params)\n if @user\n create_jwt_with({ user_id: @user.id })\n render json: { user: { username: @user.email } }, status: :created\n else\n render json: { errors: user.errors }, status: :unprocessable_entity\n end\n end", "def sign_up\n if @worksession.free == false\n respond_to do |format|\n format.html {\n flash[:notice] = 'Worksession is unavailable. Please choose another'\n redirect_to available_path\n }\n end\n else\n if !params[:notes].nil?\n @worksession.notes = params[:notes]\n end\n booking = Booking.create(user_id: @user.id, worksession_id: @worksession.id, notes: params[:notes])\n\n if Rails.env.production?\n url = URI.parse('http://worksessions-notifier.pierobotics.org/api/v0/signup/')\n else\n url = URI.parse('http://worksessions-notifier-staging.pierobotics.org/api/v0/signup/')\n end\n Net::HTTP.post_form(url, {\n 'notes' => booking.notes,\n 'date' => @worksession.date.strftime(\"%m/%d/%Y\"),\n 'start_time' => @worksession.begin_at.strftime(\"%I:%M %P\"),\n 'end_time' => @worksession.end_at.strftime(\"%I:%M %P\"),\n 'school' => @user.team_name,\n })\n\n # @worksession.users << @user\n if (@worksession.date.wday.between?(0, 1) and @worksession.users.size >= 8) or (@worksession.date.wday.between?(5, 6) and @worksession.users.size >= 4)\n @worksession.free = false\n @worksession.save\n end\n redirect_to available_path\n end\n\n end", "def create\n build_resource(sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n render json: resource # , location: after_sign_up_path_for(resource)\n else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end", "def create\n # @tossup = tossup.new(tossup_params)\n #\n # if @tossup.save\n # render :show, status: :created, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end", "def create\n p \"-------user signup------\"\n user = User.new(user_params)\n user.skip_confirmation!\n if user.save\n data = { success: true, message: \"Your account registered.\" }\n else\n key, val = user.errors.messages.first\n data = { success: false, message: user.errors.full_messages.first }\n end\n render json: data\n end", "def create\n # @tossup = tossup.new(tossup_params)\n #\n # if @tossup.save\n # render :show, status: :created, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end", "def create\n \thashPassword= Digest::MD5.hexdigest(params[:signup][:password])\n\t\tnewParams={\"name\" => params[:signup][:name], \"email\" => params[:signup][:email], \"password\" => hashPassword, \"phone\" => params[:signup][:phone] }\n\t\t@signup = Signup.new(newParams)\n respond_to do |format|\n if @signup.save\n\t\t\t\t@first = \"first\"\n\t\t\t\tformat.html { render action: \"login\" }\n #format.html { redirect_to @signup, notice: hashPassword }\n format.json { render json: @signup, status: :created, location: @signup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def signup\n sign_out\n puts '----signup called.----'\n redirect_to '/users/sign_up'\n end", "def create\n user = new_user\n\n authorize! :create, user\n\n user.unflattened_attributes = flat_params\n user.signup_type = :api\n\n user.save\n\n respond_with(user)\n end", "def create\n build_resource(configure_sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n render json: resource # , location: after_sign_up_path_for(resource)\n else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n render json: { error_messages: resource.errors.full_messages.join(', ') }, status: 422\n end\n end", "def signup_params\n params.require(:signup).permit(:name, :email, :phone_number, :shift_id, :team_affiliation)\n end", "def create\n @alphasignup = Alphasignup.new(params[:alphasignup])\n\n respond_to do |format|\n if @alphasignup.save\n format.html { redirect_to(@alphasignup, :notice => 'Thank you for signing up.') }\n format.xml { render :xml => @alphasignup, :status => :created, :location => @alphasignup }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @alphasignup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_signup(attrs = {})\n Signup.create!(attrs.reverse_merge({\n access_token: 'access-token',\n instagram_username: 'jillsmith',\n instagram_id: '123456'\n }))\n end", "def create\n @beta_sign_up = BetaSignUp.new(params[:beta_sign_up])\n\n respond_to do |format|\n if @beta_sign_up.save\n format.html { redirect_to @beta_sign_up, notice: 'Beta sign up was successfully created.' }\n format.json { render json: @beta_sign_up, status: :created, location: @beta_sign_up }\n else\n format.html { render action: \"new\" }\n format.json { render json: @beta_sign_up.errors, status: :unprocessable_entity }\n end\n end\n end", "def sign_up(user)\n visit '/users/new'\n # expect(page.status_code).to eq 200\n fill_in :email, with: user.email\n fill_in :username, with: user.username\n fill_in :password, with: user.password\n fill_in :password_confirmation, with: user.password_confirmation\n click_button 'Sign up'\n end", "def save_registration(params)\r\n random_pass = 4.times.map { (0..9).to_a.sample }.join\r\n stgu = Hash.new\r\n stgu['__c'] = 'stgu'\r\n stgu['__p'] = [\r\n nil,\r\n nil,\r\n nil, \r\n 1,\r\n params[:email],\r\n random_pass,\r\n nil,\r\n params[:first_name],\r\n params[:middle_name],\r\n params[:last_name],\r\n params[:phone],\r\n nil,\r\n Settings.register_location,\r\n params[:birth_date]\r\n ]\r\n\r\n address = [\r\n nil,\r\n nil,\r\n nil,\r\n params[:street_address],\r\n nil,\r\n params[:city],\r\n nil,\r\n params[:state],\r\n 'US',\r\n params[:zip_code]\r\n ]\r\n\r\n stgma = Hash.new\r\n stgma['__c'] = 'stgma'\r\n stgma['__p'] = address\r\n\r\n stgba = Hash.new\r\n stgba['__c'] = 'stgba'\r\n stgba['__p'] = address\r\n\r\n stgu_json = stgu.to_json\r\n stgma_json = stgma.to_json\r\n stgba_json = stgba.to_json\r\n\r\n register_path = 'https://catalog.tadl.org/osrf-gateway-v1?service=open-ils.actor&method=open-ils.actor.user.stage.create&param='\r\n register_path << stgu_json.to_s\r\n register_path << '&param=' + stgma_json.to_s\r\n register_path << '&param=' + stgba_json.to_s\r\n\r\n if Settings.register_newsletter == true && params[:enews] == 'true'\r\n uri = URI(Settings.register_listapi_url)\r\n\r\n params = {\r\n 'check' => ENV[\"LISTAPI_KEY\"],\r\n 'email' => params[:email],\r\n 'firstname' => params[:first_name],\r\n 'lastname' => params[:last_name],\r\n 'city' => params[:city],\r\n 'state' => params[:state],\r\n 'zip' => params[:zip_code],\r\n }\r\n\r\n res = Net::HTTP.post_form(uri, params);\r\n # puts res.body if res.is_a?(Net::HTTPSuccess) # Uncomment for DEBUG\r\n\r\n end\r\n\r\n uri = URI.parse(register_path)\r\n response = Net::HTTP.get_response(uri)\r\n if response.code == '200'\r\n return JSON.parse(response.body)\r\n else\r\n return 'error'\r\n end\r\n\r\n end", "def create\n build_resource(sign_up_params)\n\n resource.save\n render_resource(resource)\n end", "def sign_up\n service_response = UserManagement::SignUp.new(\n params.merge({\n is_client_manager: 1,\n client_creation_needed: 1,\n browser_user_agent: http_user_agent\n })\n ).perform\n\n if service_response.success?\n # NOTE: delete cookie value from data\n cookie_value = service_response.data.delete(:cookie_value)\n set_cookie(\n GlobalConstant::Cookie.user_cookie_name,\n cookie_value,\n GlobalConstant::Cookie.user_expiry.from_now\n )\n end\n\n render_api_response(service_response)\n end", "def create\n @user = current_user\n @makeup = @user.makeups.new(makeup_params)\n\n respond_to do |format|\n if @makeup.save\n format.html { redirect_to @makeup, notice: \"You successfully register to your makeup class, please contact your program manager if you have any questions, click on 'Product School' to go back to the Home page\" }\n format.json { render :show, status: :created, location: @makeup }\n else\n format.html { render :new }\n format.json { render json: @makeup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n megam_rest.post_accounts(to_hash)\n end", "def signup_params\n params.require(:signup).permit(:full_name, :attending, :user_id, :seminar_id)\n end", "def create\n build_resource(configure_sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n respond_to do |format|\n format.json { \n render json: resource # , location: after_sign_up_path_for(resource)\n }\n format.html {respond_with resource, location: after_sign_up_path_for(resource)}\n end\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_to do |format|\n format.json { \n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n }\n format.html {respond_with resource, location: after_inactive_sign_up_path_for(resource)}\n end\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_to do |format|\n format.json { render json: { error_messages: resource.errors.full_messages.join(', ') }, status: 422 }\n format.html {respond_with resource}\n end\n end\n end", "def create\n @user = User.new(params[:user])\n\n Notifier.signup_email(@user).deliver\n\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, :notice => 'User was successfully created.' }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def signup\n @user = User.new(params[:user])\n return unless request.post?\n if @user.save\n flash[:notice] = \"New user added!\"\n redirect_to :action=>'show', :id=>@user\n end\n end", "def client_sign_up\n\n end", "def create\n @user = User.new(filter_sign_up_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user.profile, :notice => \"Welcome #{@user.name}!\" }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n errors = @user.errors.full_messages\n format.html { redirect_to signup_path({errors: errors}), flash: {error: 'Invalid email or password.'}}\n format.json { render :json => {errors: @user.errors, type: 'register'}, :status => :unprocessable_entity }\n end\n end\n end", "def sign_up\n\t\tif params[:uuid].present?\n\t\t\t@existing_member = Com::Nbos::User.where(uuid: params[:uuid])\n\t\t\tif @existing_member.present?\n\t\t\t\trender :json => @existing_member.first\n\t\t\telse\n\t\t\t\t@member = build_user(params)\n\t\t\t\tif @member && @member.save\n\t\t\t\t\trender :json => @member\n\t\t\t\telse\n\t\t\t\t\trender :json => {status: 500, message: @member.errors.messages}, status: 500\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\trender :json => {status: 400, message: \"Bad Request\"}, status: 400\n\t\tend\t\n\tend", "def create\n @user = User.new(params[:user])\n if @user.save \n sign_in @user\n Notifier.welcome(@user.name, @user.email).deliver\n flash[:success] = \"welcome to sample app\"\n redirect_to cookies[:come_from] || user_path(@user)\n else\n @title = \"Signup\" \n render action: \"new\" \n #format.json { render json: @user }\n end\n end", "def create\n @user_push_key = UserPushKey.new(user_push_key_params)\n\n respond_to do |format|\n if @user_push_key.save\n format.html { redirect_to @user_push_key, notice: 'User push key was successfully created.' }\n format.json { render :show, status: :created, location: @user_push_key }\n else\n format.html { render :new }\n format.json { render json: @user_push_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_user\n fake_password = Faker::Internet.password\n params = {\n user: {\n username: Faker::Internet.user_name,\n email: Faker::Internet.email,\n password: fake_password,\n password_confirmation: fake_password\n }\n }\n post signup_post_url, { params: params }\n params[:user]\n end", "def create\n if Feedbunch::Application.config.signups_enabled\n super\n else\n Rails.logger.warn \"Creation of new user attempted, but signups are disabled\"\n redirect_to root_path\n end\n end", "def create\n @user = User.new(user_params)\n # return msg: render json: @user, status: :created\n if @user.save\n reset_session\n log_in @user\n flash[:success] = \"Signup Success, Welcome to Fyber Connect!\"\n redirect_to @user\n else\n render 'new'\n end\n end", "def add_cheer_up\n new_cheer_up = current_user.cheer_ups.new(cheer_up_params)\n if new_cheer_up.save\n render json:\n {\n status: 200,\n user: current_user,\n cheer_up: current_user.cheer_ups\n }\n else\n render json:\n {\n status: 400,\n user: current_user,\n cheer_up: cheer_up.errors\n }\n end\n end", "def create\n @signup = Signup.new(params[:signup])\n @signup.ip_address = request.remote_ip\n respond_to do |format|\n if @signup.save\n flash[:notice] = t('signups.saved')\n format.html { redirect_to(@signup) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def index\n @sign_ups = SignUp.all\n end", "def index\n @sign_ups = SignUp.all\n end", "def create\n r = @api.create_user(user_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to users_url, alert: response['message']}\n end\n end\n end", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end", "def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end", "def signup_info\n end", "def create\n build_resource(sign_up_params)\n\n respond_to do |format|\n if resource.save\n format.html { redirect_to admin_root_path, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end \n\n if resource.save\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_navigational_format?\n sign_up(resource_name, resource)\n respond_with resource, :location => after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_navigational_format?\n expire_session_data_after_sign_in!\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n respond_with resource\n end\n end", "def new\n @sign_up = SignUp.new\n end", "def sign_up(resource_name, resource)\n redirect_to users_url\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n SignupMailer.signup_mail(@user).deliver_later\n format.html { redirect_to root_path, notice: 'User was successfully created.' }\n format.json { render root_path, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def signup_params\n params.require(:signup).permit(:event_id, :guest_id)\n end", "def create\n respond_to do |format|\n # Check if user ticked T&C\n if (signup_params[:tos].to_i == 0)\n format.html{ redirect_to request.referrer, notice: \"You must accept the Terms & Conditions to register.\" }\n format.json { head :no_content }\n else\n # Check if username taken\n if username_exist(signup_params[:name])\n format.html{ redirect_to request.referrer, notice: \"Username already taken.\" }\n format.json { head :no_content }\n # check if email taken\n elsif email_exist(signup_params[:email])\n format.html{ redirect_to request.referrer, notice: \"Email already taken.\" }\n format.json { head :no_content }\n # check if password valid\n elsif !password_valid(signup_params[:password])\n format.html{ redirect_to request.referrer, notice: \"Password must be between 8-20 characters!.\" }\n format.json { head :no_content }\n else\n # check if email valid\n if email_valid(signup_params[:email])\n @user = User.create(signup_params) \n session[:user_id] = @user.id\n \n # User successfully creates account if save is called\n if @user.save\n UserMailer.newsletter_confirmation(@user).deliver_now\n format.html{ redirect_to root_path, notice: \"Account created!\" }\n format.json { head :no_content }\n # if save failed means the password and confirm password params are not the same\n else\n format.html{ redirect_to request.referrer, notice: \"Password not the same!\" }\n format.json { head :no_content }\n end\n else \n format.html{ redirect_to request.referrer, notice: \"Please enter a valid email!\" }\n format.json { head :no_content }\n end\n end\n end\n end\n end", "def create\n @stackup = Stackup.new(stackup_params)\n\n respond_to do |format|\n if @stackup.save\n format.html { redirect_to @stackup, notice: 'Stackup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @stackup }\n else\n format.html { render action: 'new' }\n format.json { render json: @stackup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @beta_signup = BetaSignup.new(params[:beta_signup])\n\n respond_to do |format|\n if @beta_signup.save\n logger.info \"NEW BETA SIGNUP #{@beta_signup.to_yaml}\"\n flash[:notice] = 'You\\'ve successfully signed up for the Beta! We\\'ll surely be in touch.'\n flash[:error] = nil\n format.html { render \"/home/index\" }\n # pass ?check_out = events if we want tos how them current events link\n format.xml { render :xml => @beta_signup, :status => :created, :location => @beta_signup }\n else\n flash[:error] = \"There was an error.\"\n format.html { render \"/home/index\" }\n format.xml { render :xml => @beta_signup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n if params[:user][:email].nil?\n render :status => 400,\n :json => {:message => 'User request must contain the user email.'}\n return\n elsif params[:user][:password].nil?\n render :status => 400,\n :json => {:message => 'User request must contain the user password.'}\n return\n end\n\n if params[:user][:email]\n duplicate_user = User.find_by_email(params[:user][:email])\n unless duplicate_user.nil?\n render :status => 409,\n :json => {:message => 'Duplicate email. A user already exists with that email address.'}\n return\n end\n end\n\n @user = User.create(sign_up_params)\n\n if @user.save\n render(status: 200, json: {message: \"User Successfully Created\"})\n else\n render :status => 400,\n :json => {:message => @user.errors.full_messages}\n end\n end", "def create\n user_details = params.permit(:first_name, :last_name, :email)\n success = User.create(user_details)\n\n render json: { success: success }\n end", "def create\n user = User.create(user_params) \n render json: user, status: :created\n end", "def create\n @test_user = TestUser.new(params[:test_user])\n\n respond_to do |format|\n if @test_user.save\n format.html { redirect_to pages_thank_you_path(test_user_id: @test_user.id), notice: 'Thanks for signing up!' }\n format.json { render json: @test_user, status: :created, location: @test_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if @user.presence\n @pushup_reminder = @user.pushup_reminders.create(params[:pushup_reminder])\n else\n @pushup_reminder = PushupReminder.create(params[:pushup_reminder])\n end\n\n respond_to do |format|\n if @pushup_reminder.save\n format.html { redirect_to [@user, @pushup_reminder], notice: 'Pushup reminder was successfully created.' }\n format.json { render json: @pushup_reminder, status: :created, location: @pushup_reminder }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pushup_reminder.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n build_resource(sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n flash[:notice] = 'Registration Successful.'\n render json: { after_sign_in_path: after_sign_in_path_for(User) }\n else\n expire_data_after_sign_in!\n render json: { error: 'Something went wrong' }, status: 422\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n render json: { error: resource.errors.full_messages.join('<br>') }, status: 422\n end\n end", "def api_register\n creator = Creator.new(submits: 0, name: request.headers['name'],password: request.headers['password'],password_confirmation: request.headers['password'])\n if creator.save\n encode = encodeJWT(creator)\n selected_format({jwt: encode,creator_id: creator.id,name: creator.name,submits:creator.submits},:ok)\n else\n error = create_error_message\n error[:developerMessage] = creator.errors\n selected_format(error, :bad_request)\n end\n end", "def create\n @signup = Signup.new(ip: request.remote_ip)\n\n respond_to do |format|\n @signup.save\n format.html { redirect_to \"/\", \n notice: [\"Thank you for your interest!\", \"pairBUG is under development but will be in open beta soon.\"]\n }\n end\n end", "def create\n @signupsurvey = Signupsurvey.new(signupsurvey_params)\n\n respond_to do |format|\n if @signupsurvey.save\n format.html { redirect_to @signupsurvey, notice: 'Signupsurvey was successfully created.' }\n format.json { render action: 'show', status: :created, location: @signupsurvey }\n else\n format.html { render action: 'new' }\n format.json { render json: @signupsurvey.errors, status: :unprocessable_entity }\n end\n end\n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def create\n @user = User.new(user_params)\n if @user.save\n render json: { user: @user, success: 'User registration successful' }\n else\n render json: { error: 'User registration unsuccessful' }\n end\n end", "def create\n result = access_token.post('/api/v1/users/create', {:email=>params[:email],:psw=>params[:password],:psw_conf=>params[:password_conf],:inbox=>params[:inbox]})\n display_api_response result\n respond_with(\"\",:location => :back)\n end", "def create\n Sign.create(\n name: params[:name],\n date: params[:date],\n house: params[:house],\n info: params[:info]\n )\n\n # Create actions have no template of their own, and we also\n # want to avoid accidental form resubmission; so we redirect\n redirect_to( signs_path ) # /signs\n end", "def users_post\n params = Rack::Request.new(@env).POST\n phone = params['phone']\n key = params['key']\n\n if phone_valid?(phone) && uuid_valid?(key)\n # Validate picture_id, first_name, last_name, and email\n picture_id = params['picture_id']\n error = picture_id_invalid_response!(picture_id)\n return error if error\n\n first_name = params['first_name']\n error = name_invalid_response!('First', first_name)\n return error if error\n\n last_name = params['last_name']\n error = name_invalid_response!('Last', last_name)\n return error if error\n\n email = params['email']\n error = email_invalid_response!(email)\n return error if error\n\n $pg.with do |pg|\n pg.exec_params('SELECT * FROM users_post($1, $2, $3, $4, $5)', [phone, key, first_name, last_name, email]) do |r|\n if r.num_tuples == 1\n user_id = r.getvalue(0, 0)\n body = {access_token: build_access_token(user_id, key)}\n if picture_id\n fields = Aws::S3::Resource.new.bucket('acani-chats').presigned_post({\n acl: 'public-read',\n content_length_range: 0..3145728,\n content_type: 'image/jpeg',\n key: \"users/#{user_id}/#{picture_id}.jpg\"\n }).fields\n body[:fields] = fields\n end\n return [201, body.to_json]\n end\n end\n end\n end\n set_www_authenticate_header\n [401, '{\"message\":\"Incorrect phone or key.\"}']\n end", "def post_signup(req)\n # Create account\n identity = Lynr::Model::Identity.new(@posted['email'], @posted['email'])\n # Create and Save dealership\n dealer = create_dealership(identity, nil)\n notify('dealership.created.demo', req, dealer)\n # Send to admin pages?\n send_to_next(req) || send_to_admin(req, dealer)\n rescue Lynr::Persist::MongoUniqueError\n attempt_signin(req)\n end", "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def record_signup identifier,session_id,options={ },parent_user_id=nil\n options.merge! :signup => { :parent_user_id => parent_user_id} if parent_user_id\n options.merge! :user_profile => { :session_id => session_id , :user_id => identifier}\n record :signup,@iteration_number,identifier,options\n end", "def sign_up_users(first_name, last_name, email, password)\n find_by_id('com.yelp.android:id/first_name').send_key first_name\n find_by_id('com.yelp.android:id/last_name').send_key last_name\n find_by_id('com.yelp.android:id/email_address').send_key email\n find_by_id('com.yelp.android:id/password').send_key password\n find_name('Gender')\n find_name('Male')\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n #Sends email to user when user is created.\n UserNotifier.send_signup_email(@user).deliver_now\n format.html { redirect_to @user }\n flash[:success] = 'Usuário criado com sucesso, os dados foram enviados para o email informado.'\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = build_resource\n\n if user.save\n set_flash_message :notice, :signed_up\n sign_in('user', user)\n respond_with user, :location => after_sign_up_path_for(user)\n else\n clean_up_passwords user\n respond_with user\n end\n end", "def create\n @devise = Devise.new(params[:devise])\n\n respond_to do |format|\n if @devise.save\n #API CALL GOES HERE\n format.html { redirect_to @devise, notice: 'Devise was successfully created.' }\n format.json { render json: @devise, status: :created, location: @devise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @devise.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @signups = Signup.all\n end", "def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n end", "def create\n build_resource sign_up_params\n\n if resource.save\n Notifier.notify_superusers_of_access_request(resource).deliver\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_navigational_format?\n sign_in(resource_name, resource)\n respond_with resource, :location => after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_navigational_format?\n expire_session_data_after_sign_in!\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n respond_with resource\n end\n end", "def create\n @user = User.new(sign_up_params)\n\t\t@user.permission = 0\n respond_to do |format|\n if @user.save\n format.html { redirect_to url_for({controller: :users, action: :sign_in, id: 0}), notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def signup\n case request.method\n when :post\n @user = User.new(params['user'])\n \n if @user.save \n session['user'] = User.authenticate(@user.login, params['user']['password'])\n flash['notice'] = _(\"Signup successful\")\n redirect_back_or_default :action => \"welcome\" \n end\n end \n end", "def newsignup(email)\n @greeting = \"Hi\"\n @email = email['email']\n mail(to: @email, subject: \"You've signed up\")\n end", "def create\n @upwork = Upwork.new(upwork_params)\n\n respond_to do |format|\n if @upwork.save\n format.html { redirect_to @upwork, notice: 'Upwork was successfully created.' }\n format.json { render :show, status: :created, location: @upwork }\n else\n format.html { render :new }\n format.json { render json: @upwork.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6931392", "0.68494356", "0.68124014", "0.6787426", "0.6749384", "0.6749384", "0.6720914", "0.67167884", "0.67003345", "0.6620111", "0.661046", "0.6606147", "0.6598769", "0.6569537", "0.6512339", "0.6498201", "0.6472596", "0.6464664", "0.6425708", "0.63870496", "0.63757044", "0.6342808", "0.63138336", "0.62592036", "0.6242092", "0.6241084", "0.62403953", "0.62344474", "0.622962", "0.62249804", "0.6222736", "0.6221705", "0.62129796", "0.6209994", "0.6191815", "0.61758554", "0.61729234", "0.6166652", "0.6160634", "0.6134565", "0.6095908", "0.60852593", "0.6061227", "0.6044866", "0.60445803", "0.6032846", "0.6011611", "0.6003746", "0.59936845", "0.59876907", "0.5987143", "0.598572", "0.5985503", "0.5979773", "0.59789246", "0.5977272", "0.5977272", "0.59753966", "0.59697527", "0.59697527", "0.5966376", "0.59635156", "0.5963394", "0.59578663", "0.5957665", "0.59522367", "0.5948375", "0.5947637", "0.59415406", "0.5929067", "0.5927806", "0.59222215", "0.5914994", "0.59119934", "0.5904019", "0.5900746", "0.5899419", "0.5888866", "0.5887117", "0.5887117", "0.5876009", "0.58759016", "0.58754396", "0.58660156", "0.5858339", "0.5851641", "0.5845436", "0.5845436", "0.5841202", "0.58407754", "0.58372575", "0.5834423", "0.5821078", "0.582005", "0.5819031", "0.5818217", "0.5817362", "0.5811196", "0.5807424", "0.58023846" ]
0.68171585
2
PATCH/PUT /sign_ups/1 PATCH/PUT /sign_ups/1.json
def update respond_to do |format| if @sign_up.update(sign_up_params) format.html { redirect_to @sign_up, notice: 'Sign up was successfully updated.' } format.json { render :show, status: :ok, location: @sign_up } else format.html { render :edit } format.json { render json: @sign_up.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n if @signup.update_attributes(params[:signup])\n format.html { redirect_to @signup, notice: 'Signup was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n if @signup.update_attributes(params[:signup])\n format.html { redirect_to @signup, notice: 'Signup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @signup.update(signup_params)\n format.html { redirect_to @signup, notice: 'Signup was successfully updated.' }\n format.json { render :show, status: :ok, location: @signup }\n else\n format.html { render :edit }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @signup.update(signup_params)\n format.html { redirect_to @signup, notice: \"Signup was successfully updated.\" }\n format.json { render :show, status: :ok, location: @signup }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n if @signup.update_attributes(params[:signup])\n flash[:notice] = t('signups.saved')\n format.html { redirect_to(@signup) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n @pushup = Pushup.find(params[:id])\n\n respond_to do |format|\n if @pushup.update_attributes(params[:pushup])\n format.html { redirect_to @pushup, notice: 'Pushup was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pushup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sign_up_user.update(sign_up_user_params)\n format.html { redirect_to @sign_up_user, notice: 'Sign up user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sign_up_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update\n @sign_up = SignUp.find(params[:id])\n @raid = Raid.find(params[:raid_id])\n\n respond_to do |format|\n if @sign_up.update_attributes(params[:sign_up])\n flash[:notice] = 'SignUp was successfully updated.'\n format.html { redirect_to(raid_sign_up_path(@raid, @sign_up)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sign_up.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sign.update(sign_params)\n @sign.create_activity(:update, owner: current_user, parameters: { name: @sign.name })\n format.html { redirect_to @sign; flash[:notice] = 'Sign was successfully updated.' }\n format.json { render :show, status: :ok, location: @sign }\n else\n format.html { render :edit }\n format.json { render json: @sign.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:meetup])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sep_signup = SepSignup.find(params[:id])\n\n respond_to do |format|\n if @sep_signup.update_attributes(params[:sep_signup])\n format.html { redirect_to @sep_signup, notice: 'Sep signup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sep_signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if user.update(user_params)\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end", "def update\n respond_to do |format|\n @user = User.find(params[:id])\n @user = @user.update(signup_params)\n if @user\n format.html{ redirect_to profile_path, notice: \"User details successfully updated!\" }\n format.json { head :no_content }\n else\n format.html{ redirect_to request.referrer, notice: \"Password is not the same!\" }\n format.json { head :no_content }\n end\n end\n end", "def update\n @beta_sign_up = BetaSignUp.find(params[:id])\n\n respond_to do |format|\n if @beta_sign_up.update_attributes(params[:beta_sign_up])\n format.html { redirect_to @beta_sign_up, notice: 'Beta sign up was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beta_sign_up.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def set_sign_up\n @sign_up = SignUp.find(params[:id])\n end", "def update\n respond_to do |format|\n if @pushup_reminder.update_attributes(params[:pushup_reminder])\n format.html { redirect_to [@user, @pushup_reminder], notice: 'Pushup reminder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pushup_reminder.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = current_user\n\n ## Update other fields\n %w(billing_cycle billing_cycle_start_date is_profile_complete is_verified_email approval_status).each do |f|\n params[:user].delete(f)\n end\n\n @user.is_profile_complete = 'yes'\n if @user.update_attributes(params[:user])\n sign_in @user, :bypass => true\n respond_to do |format|\n format.json { render :json => {\"user\" => @user.as_json}, :status => :created }\n end\n else ## error when save\n respond_to do |format|\n format.json { render json: @user.errors.full_messages, :status => :bad_request }\n end\n end\n end", "def update\n if @api_v1_user.update(api_v1_user_params)\n head :no_content\n else\n render json: @api_v1_user.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @stackup.update(stackup_params)\n format.html { redirect_to @stackup, notice: 'Stackup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stackup.errors, status: :unprocessable_entity }\n end\n end\n end", "def signup(params={})\n begin\n JSON.parse(RestClient.put construct_url(\"user\"), params)\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end", "def update\n @alphasignup = Alphasignup.find(params[:id])\n\n respond_to do |format|\n if @alphasignup.update_attributes(params[:alphasignup])\n format.html { redirect_to(@alphasignup, :notice => 'Alphasignup was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @alphasignup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def user_update_me(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: UserApi#user_update_me ... opts: #{opts}\"\n end\n\n # resource path\n path = \"/user\".sub('{format}','json')\n\n # query parameters\n query_params = {}\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 form_params[\"firstname\"] = opts[:'firstname'] if opts[:'firstname']\n form_params[\"lastname\"] = opts[:'lastname'] if opts[:'lastname']\n form_params[\"oldPassword\"] = opts[:'old_password'] if opts[:'old_password']\n form_params[\"newPassword\"] = opts[:'new_password'] if opts[:'new_password']\n form_params[\"newPasswordConfirm\"] = opts[:'new_password_confirm'] if opts[:'new_password_confirm']\n form_params[\"country\"] = opts[:'country'] if opts[:'country']\n form_params[\"pgpPubKey\"] = opts[:'pgp_pub_key'] if opts[:'pgp_pub_key']\n\n # http body (model)\n post_body = nil\n\n\n auth_names = []\n result = @api_client.call_api(:PUT, 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 => 'User')\n if Configuration.debugging\n Configuration.logger.debug \"API called: UserApi#user_update_me. Result: #{result.inspect}\"\n end\n return result\n end", "def update\n # if @tossup.update(tossup_params)\n # render :show, status: :ok, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end", "def update\n # if @tossup.update(tossup_params)\n # render :show, status: :ok, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def update\n respond_to do |format|\n if @user_push_key.update(user_push_key_params)\n format.html { redirect_to @user_push_key, notice: 'User push key was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_push_key }\n else\n format.html { render :edit }\n format.json { render json: @user_push_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_cheer_up\n user = User.find(params[:id])\n updating_cheer_up = CheerUp.find(params[:cheer_up_id])\n updating_cheer_up.update(cheer_up_params)\n render json:\n {\n status: 200,\n user: user,\n cheer_ups: user.cheer_ups,\n updated_cheer_up: updating_cheer_up\n } # end render json\n end", "def update_profile(body={})\n perform_post(\"/account/update_profile.json\", :body => body)\nend", "def update_profile! (data = {})\n check_auth :update\n \n response = connection.put do |req|\n req.url '/user/update'\n req.body = { :format => @format }.merge(data)\n end\n response\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end", "def update\n authorize @meetup\n respond_to do |format|\n if @meetup.update(meetup_params)\n notify_collaborators\n format.html { redirect_to meetup_path(@meetup) }\n format.json { render :show, status: :ok, location: @meetup }\n else\n format.html { render :edit }\n format.json do\n render json: @meetup.errors,\n status: :unprocessable_entity\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @user\n @user.active = false\n @user.pending = false\n @user.save\n end\n format.json { render json: {:status => :ok}}\n end\n end", "def update\n user = User.find_by(id: params[:id])\n user.update(user_params)\n render json: user\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def set_signup\n @signup = Signup.find(params[:id])\n end", "def update\n @meetup = Meetup.find(params[:id])\n\n respond_to do |format|\n if @meetup.update_attributes(params[:meetup])\n format.html { redirect_to @meetup, notice: 'Meetup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n current_user.phone = params['phone']\n current_user.save()\n\n render :nothing => true, :status => 204\n end", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.save\n render json:@user\n end", "def clear_default_profile \n put(\"/profiles.json/default/clear\")\nend", "def update\n @sprint.update!(sprint_params)\n json_response(@sprint)\n end", "def update\n @meetup_profile = MeetupProfile.find(params[:id])\n\n respond_to do |format|\n if @meetup_profile.update_attributes(params[:meetup_profile])\n format.html { redirect_to meetup_profile_path(@meetup_profile.id), notice: 'Meetup profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meetup_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n sign = Sign.find params[:id]\n\n sign.update(\n name: params[:name],\n image: params[:image],\n date: params[:date],\n house: params[:house],\n info: params[:info]\n )\n\n redirect_to sign_path(sign.id)\n end", "def update \n @current_user.update(user_params)\n render json: @current_user\n end", "def update\n user = find_user\n user.update!(user_params)\n render json: user\n end", "def update\n respond_to do |format|\n if @meetup.update(meetup_params)\n format.html { redirect_to @meetup, notice: \"Meetup was successfully updated.\" }\n format.json { render :show, status: :ok, location: @meetup }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @squishee_cup = SquisheeCup.find(params[:id])\n puts params.to_json\n respond_to do |format|\n if @squishee_cup.update_attributes(params[:squishee_cup])\n format.html { redirect_to @squishee_cup, notice: 'Squishee cup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squishee_cup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pickup = Pickup.find(params[:id])\n\n respond_to do |format|\n if @pickup.update_attributes(params[:pickup])\n format.html { redirect_to @pickup, notice: 'Pickup was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pickup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: 200\n else\n render json: @user.errors, status: 422\n end\n end", "def update\n @call = Call.find(params[:id])\n @call.update_attributes(params[:call])\n respond_to do |format|\n format.html\n format.json { render :json => @call.to_json(:include => [ :user ]) }\n format.js\n end\n end", "def update\n respond_to do |format|\n if @meetup.update(meetup_params)\n format.html { redirect_to @meetup, notice: 'Meetup was successfully updated.' }\n format.json { render :show, status: :ok, location: @meetup }\n else\n format.html { render :edit }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n user = User.find(params[:id])\n if user.update(params_user)\n render json: user, status: 200\n else\n render json: user.errors, status: 422\n end\n\n end", "def update_profile(params)\n post 'account/update_profile', :post => params\n end", "def update_user(options)\n patch(\"/user\", options, 3)\n end", "def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end", "def put!\n request! :put\n end", "def update!(**args)\n @api_signatures = args[:api_signatures] if args.key?(:api_signatures)\n @unique_apis = args[:unique_apis] if args.key?(:unique_apis)\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: {error: \"Could not update user\"}\n end\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 update(args)\n builder.update_rest(type, ref, args, username, password)\n self.elements(true)\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @devise = Devise.find(params[:id])\n\n respond_to do |format|\n if @devise.update_attributes(params[:devise])\n #API CALL GOES HERE\n format.html { redirect_to @devise, notice: 'Devise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @devise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @v1_user.update(v1_user_params)\n format.html { redirect_to @v1_user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @v1_user }\n else\n format.html { render :edit }\n format.json { render json: @v1_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @upwork.update(upwork_params)\n format.html { redirect_to @upwork, notice: 'Upwork was successfully updated.' }\n format.json { render :show, status: :ok, location: @upwork }\n else\n format.html { render :edit }\n format.json { render json: @upwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_or_update_profile_configuration(args = {}) \n id = args['profileId']\n temp_path = \"/profiles.json/{profileId}/configuration\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"profileId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end", "def update\n respond_to do |format|\n if @punch.update(punch_params)\n format.html { redirect_to @punch, notice: 'Punch was successfully updated.' }\n format.json { render :show, status: :ok, location: @punch }\n else\n format.html { render :edit }\n format.json { render json: @punch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end", "def update_signage\n @nugget = Nugget.find(params[:id])\n @nugget.unset_editable_time\n\n respond_to do |format|\n if @nugget.update_attributes(params[:nugget])\n @nugget.signage_review!\n\n # JAH - Jan 7 2014\n # There used to be a state here to \"review\" signage that isn't\n # necessary. Ergo we're going to transition the nugget immediately\n # from signage_review to signage_approve to move it further along.\n @nugget.signage_approve!\n\n format.html { redirect_to jobboard_path, notice: 'Read Signage Job completed.' }\n format.json { head :no_content }\n else\n format.html { redirect_to jobboard_path, error: 'Something went wrong. Job not completed.' }\n format.json { render json: @nugget.errors, status: :unprocessable_entity }\n end\n end\n end", "def assign_default_profile(args = {}) \n put(\"/profiles.json/#{args[:profileId]}/default\", args)\nend", "def update\n @punch = Punch.find(params[:id])\n\n respond_to do |format|\n if @punch.update_attributes(params[:punch])\n format.html { redirect_to @punch, notice: 'Punch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @punch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n user = User.find(params[:id])\n user.update(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors\n end\n end", "def update\n respond_to do |format|\n if User.update(current_user.id, :game_id => params[:id])\n format.json { head :no_content }\n end\n end\n end", "def update\n respond_to do |format|\n if @attorney.update(attorney_params)\n current_user.email = (attorney_params)[:email]\n current_user.password = (attorney_params)[:password] if (attorney_params)[:password]\n current_user.image = (attorney_params)[:profile_image]\n current_user.first_name = (attorney_params)[:first_name]+\" \"+(attorney_params)[:middle_name]+\" \"+(attorney_params)[:last_name]\n current_user.save\n sign_in(current_user, :bypass => true)\n format.html { redirect_to @attorney, notice: 'Attorney was successfully updated.' }\n format.json { render :show, status: :ok, location: @attorney }\n else\n format.html { render :edit }\n format.json { render json: @attorney.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user.update(user_params_update)\n json_response(@user)\n end", "def update\n respond_to do |format|\n if @topup.update(topup_params)\n format.html { redirect_to @topup, notice: 'Topup was successfully updated.' }\n format.json { render :show, status: :ok, location: @topup }\n else\n format.html { render :edit }\n format.json { render json: @topup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_current_logged_in_user(args = {}) \n id = args['id']\n temp_path = \"/users.json/current\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def patch!\n request! :patch\n end", "def update!(**args)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @sign_in_required = args[:sign_in_required] if args.key?(:sign_in_required)\n end", "def update\n user = User.find(params[:id])\n render json: { status: 200, msg: 'User details have been updated.' } if user.update(user_params)\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n if params.include?(:phone_number) and params.include?(:name) and params.include?(:address) and params.include?(:email) and params.include?(:description)\n phone_number = params[:phone_number]\n name = params[:name]\n address = params[:address]\n email = params[:email]\n description = params[:description]\n render json: update_user(phone_number, email, address, name, description)\n else\n result = {:success => false, :message => 'please check the paramaters'}\n render json: result\n end\n end", "def update\n respond_to do |format|\n if @userspec.update(userspec_params)\n format.html { redirect_to root_path, notice: 'Userspec was successfully updated.' }\n format.json { render :show, status: :ok, location: @userspec }\n else\n format.html { render :edit }\n format.json { render json: @userspec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @distinctive_sign.update(distinctive_sign_params)\n format.html { redirect_to @distinctive_sign, notice: 'Distinctive sign was successfully updated.' }\n format.json { render :show, status: :ok, location: @distinctive_sign }\n else\n format.html { render :edit }\n format.json { render json: @distinctive_sign.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n user = User.find(params[:id])\n\n # Use update with user_params to do a mass-assignment update and save. \n if user.update_attributes(user_params)\n render json: user\n else \n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @user_buys_promise.update(user_buys_promise_params)\n format.html { redirect_to @user_buys_promise, notice: 'User buys promise was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_buys_promise }\n else\n format.html { render :edit }\n format.json { render json: @user_buys_promise.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6717594", "0.6712098", "0.6578821", "0.6571195", "0.6253229", "0.6137943", "0.6118633", "0.6080012", "0.5967603", "0.59138864", "0.5900262", "0.5900262", "0.58991283", "0.58550197", "0.5825879", "0.5817204", "0.5772862", "0.57609135", "0.5756075", "0.575318", "0.575318", "0.5744178", "0.5744178", "0.5726221", "0.5723965", "0.5716588", "0.57127", "0.571229", "0.5708311", "0.5685056", "0.56759673", "0.56759673", "0.56657195", "0.56593347", "0.56549734", "0.56416637", "0.56381935", "0.5636706", "0.56023085", "0.5596309", "0.55939984", "0.55902153", "0.5573239", "0.5573239", "0.5573239", "0.5549619", "0.5545426", "0.5532457", "0.552933", "0.55259496", "0.55257684", "0.5521135", "0.5515393", "0.5511982", "0.5499241", "0.548692", "0.54816854", "0.5478997", "0.54753876", "0.547337", "0.5463211", "0.5461116", "0.54451895", "0.544408", "0.54427075", "0.5442508", "0.5441282", "0.54411703", "0.5436146", "0.5429428", "0.5427685", "0.5423938", "0.5423938", "0.5422786", "0.5422194", "0.54209304", "0.5420158", "0.5416223", "0.5407983", "0.54064256", "0.54055923", "0.53974783", "0.53845376", "0.53843933", "0.53795564", "0.5378922", "0.53759545", "0.5365801", "0.5359749", "0.5355011", "0.53518933", "0.5351892", "0.5347407", "0.5345508", "0.53432655", "0.53420186", "0.5335908", "0.533503", "0.5333691" ]
0.66088855
3
DELETE /sign_ups/1 DELETE /sign_ups/1.json
def destroy @sign_up.destroy respond_to do |format| format.html { redirect_to sign_ups_url, notice: 'Sign up was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @signup = Signup.find(params[:id])\n @signup.destroy\n\n respond_to do |format|\n format.html { redirect_to signups_url }\n format.json { head :ok }\n end\n end", "def destroy\n @signup = Signup.find(params[:id])\n @signup.destroy\n\n respond_to do |format|\n format.html { redirect_to signups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sign_up = SignUp.find(params[:id])\n @sign_up.destroy\n\n respond_to do |format|\n format.html { redirect_to(sign_ups_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @signup = Signup.find(params[:id])\n @signup.destroy\n\n respond_to do |format|\n format.html { redirect_to(signups_url) }\n end\n end", "def destroy\n @signup.destroy\n respond_to do |format|\n format.html { redirect_to signups_url, notice: 'Signup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @signup.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: \"Signup was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @sep_signup = SepSignup.find(params[:id])\n @sep_signup.destroy\n\n respond_to do |format|\n format.html { redirect_to sep_signups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sign_up = SignUp.find(params[:id])\n @raid = @sign_up.raid\n @sign_up.destroy\n\n respond_to do |format|\n format.html { redirect_to(raid_sign_ups_path(@raid), :method => :get) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pushup = Pushup.find(params[:id])\n @pushup.destroy\n\n respond_to do |format|\n format.html { redirect_to pushups_url }\n format.json { head :ok }\n end\n end", "def destroy\n @sign_up_user.destroy\n respond_to do |format|\n format.html { redirect_to sign_up_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alphasignup = Alphasignup.find(params[:id])\n @alphasignup.destroy\n\n respond_to do |format|\n format.html { redirect_to(alphasignups_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @beta_sign_up = BetaSignUp.find(params[:id])\n @beta_sign_up.destroy\n\n respond_to do |format|\n format.html { redirect_to beta_sign_ups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_push_key.destroy\n respond_to do |format|\n format.html { redirect_to user_push_keys_url, notice: 'User push key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sign.create_activity(:destroy, owner: current_user, parameters: { name: @sign.name })\n @sign.destroy\n respond_to do |format|\n format.html { redirect_to signs_url, notice: 'Sign was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pushup_reminder.destroy\n\n respond_to do |format|\n format.html { redirect_to pushup_reminders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @distinctive_sign.destroy\n respond_to do |format|\n format.html { redirect_to distinctive_signs_url, notice: 'Distinctive sign was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = Meetup.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to meetups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @beta_signup = BetaSignup.find(params[:id])\n @beta_signup.destroy\n\n respond_to do |format|\n format.html { redirect_to(beta_signups_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @api_user.destroy\n\n head :no_content\n end", "def destroy\n @signupsurvey.destroy\n respond_to do |format|\n format.html { redirect_to signupsurveys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @users_visit.destroy\n respond_to do |format|\n format.html { redirect_to users_visits_url, notice: 'Visit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @stackup.destroy\n respond_to do |format|\n format.html { redirect_to stackups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @instathreat_user.destroy\n respond_to do |format|\n format.html { redirect_to instathreat_users_url, notice: 'Instathreat user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def destroy\n @meetup = Meetup.find(params[:id])\n @meetup.destroy\n\n respond_to do |format|\n format.html { redirect_to meetups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @uasg.destroy\n respond_to do |format|\n format.html { redirect_to uasgs_url, notice: 'Uasg was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup_profile = MeetupProfile.find(params[:id])\n @meetup_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @signout_log = SignoutLog.find(params[:id])\n @signout_log.destroy\n\n respond_to do |format|\n format.html { redirect_to signout_logs_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @asterisk_user.destroy\n respond_to do |format|\n format.html { redirect_to asterisk_users_url, notice: 'Asterisk user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_signature.destroy\n respond_to do |format|\n format.html { redirect_to user_signatures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @six.destroy\n respond_to do |format|\n format.html { redirect_to sixes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end", "def destroy\n @meetup.destroy\n respond_to do |format|\n format.html { redirect_to meetups_url, notice: 'Meetup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup.destroy\n respond_to do |format|\n format.html { redirect_to meetups_url, notice: \"Meetup was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def destroy\n @rate_up.destroy\n respond_to do |format|\n format.html { redirect_to rate_ups_url, notice: 'Rate up was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @supaagent.destroy\n respond_to do |format|\n format.html { redirect_to supaagents_url, notice: 'Supaagent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @devise = Devise.find(params[:id])\n @devise.destroy\n #API CALL GOES HERE\n\n respond_to do |format|\n format.html { redirect_to devises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @member = Member.find(params[:member_id])\n @sign = Sign.find(params[:id])\n @sign.destroy\n respond_to do |format|\n format.html { redirect_to member_signs_url( @member ) }\n format.json { head :no_content }\n end\n end", "def destroy\n @ussd.destroy\n respond_to do |format|\n format.html { redirect_to ussds_url, notice: 'Ussd was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @smalluser = Smalluser.find(params[:id])\n @smalluser.destroy\n\n respond_to do |format|\n format.html { redirect_to smallusers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @suplente = Suplente.find(params[:id])\n @suplente.destroy\n\n respond_to do |format|\n format.html { redirect_to suplentes_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @vital_sign = VitalSign.find(params[:id])\n @vital_sign.destroy\n\n respond_to do |format|\n format.html { redirect_to vital_signs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @makeup.destroy\n respond_to do |format|\n format.html { redirect_to makeups_url, notice: 'Makeup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @makeup.destroy\n respond_to do |format|\n format.html { redirect_to makeups_url, notice: 'Makeup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @pg_first.destroy\n respond_to do |format|\n format.html { redirect_to pg_firsts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sigurance.destroy\n respond_to do |format|\n format.html { redirect_to sigurances_url, notice: 'Sigurance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n format.json { head :no_content }\n end", "def destroy\n @signalement.destroy\n respond_to do |format|\n format.html { redirect_to signalements_url, notice: \"Signalement détruit avec succès !\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @paycheck.destroy\n respond_to do |format|\n format.html { redirect_to paychecks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Users.delete(params[\"id\"])\n end", "def destroy\n @users_db.destroy\n respond_to do |format|\n format.html { redirect_to users_dbs_url, notice: 'Users db was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:user_uuid])\n @user.destroy\n head :ok\n end", "def destroy\n @sermon_sign_in.destroy\n respond_to do |format|\n format.html { redirect_to sermon_sign_ins_url, notice: 'Sermon sign in was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @check_register = CheckRegister.find(params[:id])\n @check_register.destroy\n\n respond_to do |format|\n format.html { redirect_to check_registers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @registration_request.destroy\n\n head :no_content\n end", "def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend", "def destroy\n @user_prof.destroy\n respond_to do |format|\n format.html { redirect_to user_profs_url, notice: 'User prof was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @squishee_cup = SquisheeCup.find(params[:id])\n @squishee_cup.destroy\n\n respond_to do |format|\n format.html { redirect_to squishee_cups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def destroy\n @star_sign.destroy\n respond_to do |format|\n format.html { redirect_to star_signs_url, notice: 'Star sign was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @userauth.destroy\n respond_to do |format|\n format.html { redirect_to userauths_url, notice: 'Userauth was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @insta_account.destroy\n respond_to do |format|\n format.html { redirect_to insta_accounts_url, notice: 'Insta account was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @upsc.destroy\n respond_to do |format|\n format.html { redirect_to upscs_url, notice: 'Upsc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @usuarios_email.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_emails_url }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @topup.destroy\n respond_to do |format|\n format.html { redirect_to topups_url, notice: 'Topup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @top_up = TopUp.find(params[:id])\n @top_up.destroy\n\n respond_to do |format|\n format.html { redirect_to top_ups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shouldersbiceps1.destroy\n respond_to do |format|\n format.html { redirect_to shouldersbiceps1s_url, notice: 'Shouldersbiceps1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @incidentfollowup.destroy\n respond_to do |format|\n format.html { redirect_to incidentfollowups_url, notice: 'Incidentfollowup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @snail.destroy\n respond_to do |format|\n format.html { redirect_to snails_url, notice: 'Snail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @snail.destroy\n respond_to do |format|\n format.html { redirect_to snails_url, notice: 'Snail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @followup = Followup.find(params[:id])\n @followup.destroy\n\n respond_to do |format|\n format.html { redirect_to followups_url }\n format.json { head :ok }\n end\n end", "def destroy\n @retailer_profile.destroy\n respond_to do |format|\n format.html { redirect_to retailer_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n current_user.destroy\n head 204\n end", "def destroy\n @user_vacancy.destroy\n respond_to do |format|\n format.html { redirect_to user_vacancies_url, notice: 'Aplicación eliminada correctamente' }\n format.json { head :no_content }\n end\n end", "def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end", "def destroy\n @event_sign_in.destroy\n respond_to do |format|\n format.html { redirect_to event_sign_ins_url, notice: 'Event sign in was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @push_notification = PushNotification.find(params[:id])\n @push_notification.destroy\n\n respond_to do |format|\n format.html { redirect_to push_notifications_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :ok }\n end\n end", "def remove_cheer_up\n user = User.find(params[:id])\n cheer_up = CheerUp.find(params[:cheer_up_id])\n cheer_up.destroy\n render json:\n {\n status: 204,\n user: user,\n cheer_ups: user.cheer_ups,\n deleted_cheer_up: cheer_up\n } # end render json\n end", "def destroy\n @surgical_profile.destroy\n respond_to do |format|\n format.html { redirect_to patient_surgical_profiles_path(@patient) }\n format.json { head :no_content }\n end\n end", "def destroy\n @meetup = Meetup.find_by(id: params[:id])\n @meetup.destroy\n \n redirect_to user_meetups_url(current_user)\n end", "def destroy\n @inst.destroy\n respond_to do |format|\n format.html { redirect_to insts_url, notice: 'Inst was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @uploadprof = Uploadprof.find(params[:id])\n @uploadprof.destroy\n\n respond_to do |format|\n format.html { redirect_to uploadprofs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @registration.destroy\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end" ]
[ "0.7684268", "0.76483166", "0.743182", "0.74019444", "0.73246545", "0.726921", "0.7264645", "0.7101625", "0.70832616", "0.7027095", "0.69707465", "0.68272233", "0.6644239", "0.66427404", "0.66323274", "0.6629361", "0.6619113", "0.6605127", "0.650977", "0.649681", "0.6481382", "0.6460094", "0.644629", "0.6443893", "0.6419573", "0.64072436", "0.64055324", "0.64017844", "0.6381276", "0.6376206", "0.636445", "0.63511515", "0.6343912", "0.63423157", "0.63404644", "0.63329905", "0.6327999", "0.63265383", "0.6323749", "0.6322578", "0.631989", "0.63005733", "0.6297124", "0.62861097", "0.628266", "0.627726", "0.627726", "0.627726", "0.627726", "0.6274303", "0.6265906", "0.6265906", "0.6265642", "0.6262463", "0.6246153", "0.6245711", "0.62446773", "0.62370753", "0.62352985", "0.6232295", "0.62244207", "0.6223772", "0.6221849", "0.6218804", "0.6218631", "0.62151104", "0.62064", "0.6205281", "0.6200847", "0.62006545", "0.62006545", "0.6200354", "0.6199495", "0.61968005", "0.61931455", "0.6192612", "0.61917734", "0.61866957", "0.61845064", "0.61826897", "0.61805266", "0.6177643", "0.6174091", "0.6174091", "0.6172026", "0.61621433", "0.6161916", "0.61618996", "0.6157193", "0.61569095", "0.6154321", "0.6153003", "0.6150887", "0.61487514", "0.61486644", "0.6147786", "0.61477494", "0.6145469", "0.61448157" ]
0.74351937
2
Use callbacks to share common setup or constraints between actions.
def set_sign_up @sign_up = SignUp.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Only allow a list of trusted parameters through.
def sign_up_params params.require(:sign_up).permit(:fullname, :store_location) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end", "def whitelisted_args\n args.select &:allowed\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def filtered_parameters; end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "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 param_whitelist\n [:rating, :review]\n end", "def check_params; true; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\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 permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end", "def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end", "def valid_params_request?; end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def safelists; end", "def authorize_own_lists\n authorize_lists current_user.lists\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def check_params\n true\n end", "def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end", "def filter_parameters; end", "def filter_parameters; end", "def whitelist; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.permit(:name)\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def permitted_params\n []\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def params(list)\n @declared_params = list\n end", "def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end", "def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end", "def allow(ids); end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end", "def safelist; end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def valid_for_params_auth?; end", "def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def permitters\n @_parametrizr_permitters || {}\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end", "def url_allowlist; end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end", "def quote_params\n params.permit!\n end" ]
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.6326454", "0.63140553", "0.6299814", "0.62642586", "0.626006", "0.62578833", "0.6236823", "0.6227561", "0.6221758", "0.62200165", "0.620879", "0.61983657", "0.6195055", "0.6172993", "0.6156856", "0.61558664", "0.61521494", "0.6135789", "0.6121145", "0.61118174", "0.60736513", "0.6071645", "0.60632104", "0.60549796", "0.6043906", "0.6034662", "0.60207325", "0.6018568", "0.6016575", "0.60103434", "0.60084206", "0.600763", "0.6007443", "0.6003619", "0.6003619", "0.5995791", "0.5993301", "0.5993231", "0.5984926", "0.597122", "0.5968121", "0.5965808", "0.59640145", "0.59632224", "0.59602356", "0.59332967", "0.5927556", "0.5922805", "0.5909745", "0.5905083", "0.5904304", "0.5893434", "0.58888215", "0.58823985", "0.58823985", "0.58823985", "0.5873434", "0.58619875", "0.58533794", "0.5845531", "0.58426666", "0.58360124", "0.583218", "0.5828041", "0.5827927", "0.5816121", "0.5814705", "0.5812719", "0.581121", "0.5803423", "0.5803423", "0.57995003", "0.5794207", "0.5784923", "0.5781365", "0.5776385", "0.5774859", "0.57671493", "0.5766998", "0.57618684", "0.5758038" ]
0.0
-1
Check for a collection method defined on the resource
def method_missing symbol, *args if @klass.collection_methods[symbol] instance_exec *args, &@klass.collection_methods[symbol] else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collection_resource?\n @resource_arity.to_s == 'collection'\n end", "def collection?\n @resource.collection?\n end", "def ar_collection?(instance, method)\n defined?(ActiveRecord) &&\n instance.respond_to?(method) &&\n instance.send(method).is_a?(ActiveRecord::Relation)\n end", "def is_collection\n return self.resource_type == Resource::LEARNING_COLLECTION;\n end", "def detect_collection_methods; end", "def collection?\n raise NotImplementedError\n end", "def is_collection_object\n return self.resource_type == Resource::COLLECTION_OBJECT;\n end", "def respond_to_missing?(method_name, _include_private = false)\n @collection.include?(method_name.to_s)\n end", "def collection?\n true\n end", "def collection?\n NotImplemented\n end", "def collection?\n NotImplemented\n end", "def collection? \n true\n end", "def resource_type\n :collection if collection?\n end", "def resource_type\n :collection if collection?\n end", "def collection_action?\n collection_actions.include?(action)\n end", "def is_collection?\n @is_collection\n end", "def collection_method name, &block\n collection_methods[name] = block\n end", "def method_missing(method_name, *_args, &_block)\n @collection.fetch(method_name.to_s) do\n raise \"Could not find `#{method_name}` in #{self.class.name}\"\n end\n end", "def resource_collection\n run_context && run_context.resource_collection\n end", "def collection?\n false\n end", "def method_missing(method_name, *args, &proc)\n collection.send(method_name, *args, &proc)\n end", "def collection? \n false\n end", "def collection?\n false\n end", "def collection?\n false\n end", "def collection?\n false\n end", "def is_resource_like\n return (self.is_resource || self.is_collection_object)\n end", "def collection?\n shipping_method == ShippingClass::COLLECTION\n end", "def has_collection?(name)\n has_coll name\n end", "def is_collection_like\n return (self.is_collection || self.is_exhibition)\n end", "def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end", "def method_missing(method, *args, &block)\n @collection_desc = ActiveSupport::Inflector.humanize(method).downcase\n\n @collection_desc = ActiveSupport::Inflector.singularize(\n @collection_desc) if @expected == 1\n\n unless method == :characters and ''.respond_to?(:characters)\n @collection_name, @plural_collection_name =\n method, ActiveSupport::Inflector.pluralize(method.to_s).to_sym\n end\n\n self\n end", "def is_collection?\n contexts.flag11 == 1\n end", "def collection_methods\n (@_collection_methods ||= {})\n end", "def collection?(x)\n self.class.collection?(qualified_name(x))\n end", "def collection?(qualified_name)\n @collections.include?(qualified_name)\n end", "def collection(collection, options = {})\n respond_with_object_and_type collection, options, :collection, false\n end", "def detect_collection_methods(collection, options)\n sample = collection.first || collection.last\n case sample\n when Array\n label, value = :first, :last\n when Integer\n label, value = :to_s, :to_i\n when String, NilClass\n label, value = :to_s, :to_s\n end\n\n options[:label_method] ||= label || SimpleForm.collection_label_methods.find { |m| sample.respond_to?(m) }\n options[:value_method] ||= value || SimpleForm.collection_value_methods.find { |m| sample.respond_to?(m) }\n end", "def collection?(name)\n @data.key?(name)\n end", "def applies_collection?(scope, collection)\n !scope.key?(\"collection\") || scope[\"collection\"].eql?(collection.to_s)\n end", "def method_for_association_chain #:nodoc:\n resource_collection_name\n end", "def method_missing(method, *args)\n if Array.method_defined?(method) && !Object.method_defined?(method)\n if block_given?\n collection.send(method, *args) { |*block_args| yield(*block_args) }\n else\n collection.send(method, *args)\n end\n else\n super\n #message = \"undefined method `#{method.to_s}' for \\\"#{collection}\\\":#{collection.class.to_s}\"\n #raise NoMethodError, message\n end\n end", "def present_collection(collection = resource); nil; end", "def method?(meth)\n get_method(meth)\n end", "def check_exists(collection, data)\n halt 404 unless data.collection?(collection)\n end", "def collection_action(action)\n define_method(action) do\n if params[:ids].present?\n self.resources ||= resource_scope.where(id: params[:ids])\n end\n\n if effective_resource.scope?(action)\n self.resources ||= resource_scope.public_send(action)\n end\n\n self.resources ||= resource_scope.all\n\n EffectiveResources.authorize!(self, action, resource_klass)\n\n @page_title ||= \"#{action.to_s.titleize} #{resource_plural_name.titleize}\"\n\n collection_post_action(action) unless request.get?\n end\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 collection\n resource_class.all\n end", "def detect_label_method(collection) #:nodoc:\n HumpyardForm::config.collection_label_methods.detect { |m| collection.first.respond_to?(m) }\n end", "def collection_action(name, method, request_type)\n self.actions[name.to_sym] = Action.new(self.entity, name.to_sym, :collection, :method => method, :request_type => request_type)\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 check_instance_method_existance!(method_name)\n raise NoMethodError.new(\"undefined method `#{method_name}' for #{to_s}\") unless crud_instance_methods.include?(method_name.to_sym)\n end", "def authorize_collection! action, collection\n collection.map do |model|\n authorize! action, model\n end\n end", "def collection_representer_klass\n resource_module::Representer::Collection\n end", "def detect_label_method(collection) #:nodoc:\n @@collection_label_methods.detect { |m| collection.first.respond_to?(m) }\n end", "def collection_policy_permits?(included_collection_name)\n Pundit.policy(current_user, included_collection_name.to_s.classify.constantize).index?\n end", "def valid_method(method)\n _method = method.split('_').first.pluralize\n raise Uatu::Error.new('InvalidMethod') unless Uatu::Base::RESOURCES.map(&:pluralize).include?(_method)\n _method\n end", "def respond_to?(method)\n return super unless part(method)\n part(method)\n end", "def respond_to?(api_method) # :nodoc:\n @client.wsdl.soap_actions.include?(api_method.to_sym)\n end", "def has_many(resource_name, options = {}, block = nil)\n meta_def resource_name do |*params|\n path = (path_with_slash + (options[:path] || resource_name.to_s))\n filter = params.first || {}\n collection = @client.resource(:path => path, :parent => self, :block => block, :filter => filter, :extend => options[:extend])\n collection.extend(CollectionMethods) # unless?\n collection.extend(options[:extend]::CollectionMethods) if options[:extend] # unless?\n collection\n end\n end", "def collection_roles\n # Can create, read, edit/update, destroy, and change visibility (discovery) of all Collections\n models = [Hyrax::PcdmCollection, Hyrax.config.collection_class].uniq\n if collection_manager?\n models.each do |collection_model|\n # Permit all actions (same collection permissions as admin users)\n can :manage, collection_model\n can :manage, ::SolrDocument, &:collection?\n can :manage, ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n can :create_collection_type, CollectionType\n end\n # Can create, read, and edit/update all Collections\n elsif collection_editor?\n models.each { |collection_model| can %i[edit update create create_any], collection_model }\n can %i[edit update], ::SolrDocument, &:collection?\n can %i[edit update], ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n models.each { |collection_model| can %i[read read_any view_admin_show view_admin_show_any], collection_model }\n can %i[read read_any view_admin_show view_admin_show_any], ::SolrDocument, &:collection?\n can %i[read read_any view_admin_show view_admin_show_any], ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n can :create_collection_type, CollectionType\n\n # Can read all Collections\n elsif collection_reader?\n models.each { |collection_model| can %i[read read_any view_admin_show view_admin_show_any], collection_model }\n can %i[read read_any view_admin_show view_admin_show_any], ::SolrDocument, &:collection?\n can %i[read read_any view_admin_show view_admin_show_any], ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n end\n end", "def supported?(method)\n !@operations.include?(MAP.fetch(method))\n end", "def collection?\n @object.is_a?(Enumerable) && !@object.is_a?(Struct)\n end", "def resource_named_route_helper_method?(resource_method, raise_error = false)\n if resource_method.to_s =~ /_(path|url)$/ && resource_method.to_s =~ /(^|^.*_)enclosing_resource(s)?_/\n _, route_method = *route_and_method_from_enclosing_resource_method_and_name_prefix(resource_method, name_prefix)\n elsif resource_method.to_s =~ /_(path|url)$/ && resource_method.to_s =~ /(^|^.*_)resource(s)?_/\n _, route_method = *route_and_method_from_resource_method_and_name_prefix(resource_method, name_prefix)\n else\n return false\n end\n respond_to_without_named_route_helper?(route_method) || (raise_error && raise_resource_url_mapping_error(resource_method, route_method))\n end", "def get_collection_ivar #:nodoc:\n if instance_variable_defined?(:\"@#{resource_collection_name}\")\n instance_variable_get(\"@#{resource_collection_name}\")\n else\n nil\n end\n end", "def multiple?(method_name)\n return false if association(method_name).nil?\n\n name = association(method_name).respond_to?(:many?) ? :many? : :collection?\n association(method_name).send(name)\n end", "def only_collections?\n true\n end", "def respond_to?(method)\n @data_source.respond_to?(\"get_#{method}_info\") || super\n end", "def method?\n type == TYPE_METHOD\n end", "def method?\n type == TYPE_METHOD\n end", "def show\n authorize! :read, @collection\n end", "def access_to_resources?(record)\n @normalized_resources.include?(record.resource)\n end", "def respond_to?(method, include_private = false)\n (actions(current_api).include? method) ? true : super\n end", "def collection_key?(collection, key)\n collection?(collection) && @data[collection].key?(key)\n end", "def item_respond_to?(item, key)\n method = method_name?(key) || :[]\n item.respond_to?(method)\n end", "def is_collection?\n collection_data = RGeo::GeoJSON.decode(params.to_json)\n if collection_data.blank? || !defined?(collection_data.size) || collection_data.size.blank?\n json_response(nil, :unprocessable_entity, :incompatible_geomtry)\n end\n end", "def method_missing(*args)\n method_name = args.first.to_s\n if method_name=~/is_.*[?]/\n roles = method_name.gsub(/is_(.*)[?]/, \"\\\\1\")\n roles.split(\"_or_\").each do |role|\n return name.underscore==role\n end\n elsif method_name=~/has_.*[?]/\n controller = args.second\n action = method_name.gsub(/has_(.*)[?]/, \"\\\\1\")\n return has_permission(controller, action)\n else\n super(*args)\n end\n end", "def has_collection(name, options = {})\n Utils.check_options_validity( self.class.name, name, options)\n name = name.to_sym\n options[:item_klass] = options[:klass] if options[:klass]\n options[:klass] = :collection\n options[:default] ||= []\n options[:extend] = [options[:extend]].flatten.compact\n\n _attributes[name] = options \n \n create_accessor_for(name, options[:extend])\n create_setter_for(name, allow_blank: false)\n\n sudo_alias options[:alias], name if options[:alias]\n sudo_alias \"#{options[:alias]}=\", \"#{name}=\" if options[:alias]\n end", "def collection\n action_name == 'show' ? @presenter : @collection\n end", "def respond_to_missing?(method, _include_private = false)\n if @key && _resource.respond_to?(@key) && (delegate = _resource.send(@key)) && delegate.respond_to?(method.to_s)\n true\n else\n _resource.respond_to?(method.to_s)\n end\n end", "def respond_to?(method)\n @data_source.respond_to? \"get_#{method}_info\" || super\n end", "def collection_checks(method, collection, value_method, text_method, options = {}, &block)\n check_boxes = []\n collection.each do |choice|\n text = choice.send(text_method)\n value = choice.send(value_method)\n check = MetaSearch::Check.new\n check.box = @template.check_box_tag(\n \"#{@object_name}[#{method}][]\",\n value,\n [@object.send(method)].flatten.include?(value),\n options.merge(:id => [@object_name, method.to_s, value.to_s.underscore].join('_'))\n )\n check.label = @template.label_tag([@object_name, method.to_s, value.to_s.underscore].join('_'),\n text)\n if block_given?\n yield check\n else\n check_boxes << check\n end\n end\n check_boxes unless block_given?\n end", "def check_resource(node)\n _check(node, resource_methods)\n end", "def collection?(args, collection_option = nil)\n raise(ArgumentError, \"#{name}: Unknown collection option value: #{collection_option}\") unless [true, false, nil].include? collection_option\n\n return collection_option unless collection_option.nil?\n\n args.respond_to?(:size) && !args.respond_to?(:each_pair)\n end", "def collection(http_verb, action = nil, body = nil, options)\n actual_client(options).send(http_verb, path(action), body, options)\n end", "def present\n resource.is_a?(Mongoid::Criteria) || resource.is_a?(Array) ? present_collection : present_singular\n end", "def curation_concerns_collections\n resources :collections, only: :show do\n member do\n get 'page/:page', action: :index\n get 'facet/:id', action: :facet, as: :dashboard_facet\n end\n collection do\n put '', action: :update\n put :remove_member\n end\n end\n end", "def type\n \"collection\"\n end", "def resource_type\n if collection?\n Nokogiri::XML::fragment('<D:collection xmlns:D=\"DAV:\"/>').children.first\n end\n end", "def can_collection_query?\n org = active_org\n if org\n org.full_member?\n else\n single_user_access?\n end\n end", "def respond_to?(method)\n @data.key?(method.to_s) || super\n end", "def set_collection\n @collection = Collection.find(params[:id])\n\n unless @collection.available?(@current_user)\n respond_to do |format|\n format.html { redirect_back fallback_location: collections_path, error: \"Cannot access the document\"}\n format.json { render json: {msg: 'Cannot access document'}, status: 401 }\n end \n return false\n end\n end", "def identify(_collection)\n raise NotImplementedError\n end", "def method_missing(name, *args, &block)\n if @collection.respond_to? name\n @collection.send(name, *args, &block)\n else\n @collection[:all].send(name, *args, &block)\n end\n end", "def collections_created?\n true\n end", "def collection_handle_exists?(handle:)\n variables = FastLand::Shopify::Variables.collection_by_handle(handle: handle)\n collection = ShopifyAPIRetry.retry(2) { get_collection_by_handle(variables: variables, with_products: false) }\n collection.present?\n end", "def check_collection_loaded!\n raise \"Collection wasn't loaded?\" if @collection.is_a?(ActiveRecord::Relation) && !@collection.loaded?\n end", "def route? method\n if @tracker.routes[:allow_all_actions] or @tracker.options[:assume_all_routes]\n true\n else\n routes = @tracker.routes[@current_class]\n routes and (routes.include? :allow_all_actions or routes.include? method)\n end\n end", "def resource_has_extension_method?(name,base=base_resource)\n base && base.__extension_module__.method_defined?(name)\n end", "def load_collection\n current_ability.scope_for(authorization_action, resource_class) do\n resource_base.accessible_by(current_ability, authorization_action)\n end\n end", "def collection\n klass.collection\n end", "def resource_collection\n client.run_status.run_context.resource_collection\n end" ]
[ "0.76937175", "0.72691405", "0.69958586", "0.69706374", "0.6855924", "0.6787132", "0.67831594", "0.6669297", "0.6522809", "0.6514251", "0.6514251", "0.6481664", "0.6465054", "0.6465054", "0.6430237", "0.63833594", "0.6330788", "0.6306696", "0.6284662", "0.6283709", "0.62833905", "0.6265422", "0.6263479", "0.6263479", "0.6263479", "0.6261774", "0.6246701", "0.6241741", "0.6209699", "0.6170372", "0.6152271", "0.6091167", "0.60865325", "0.60760987", "0.60623264", "0.60505784", "0.6046054", "0.6041161", "0.6033618", "0.5974117", "0.59723616", "0.5923618", "0.5917649", "0.59142536", "0.5868481", "0.5861136", "0.585684", "0.5836298", "0.5831721", "0.58232194", "0.5803937", "0.5785383", "0.5752498", "0.5749118", "0.5738248", "0.5716268", "0.5708892", "0.57054615", "0.56954587", "0.5694201", "0.56915313", "0.56886345", "0.56864756", "0.5651309", "0.56440866", "0.56368566", "0.5636274", "0.5633879", "0.5633879", "0.5626935", "0.5624181", "0.5623451", "0.56140864", "0.56083715", "0.5597607", "0.55964893", "0.5591087", "0.5590843", "0.558347", "0.5559551", "0.5546811", "0.5546289", "0.5544903", "0.55418676", "0.5539472", "0.5535208", "0.55234444", "0.55228347", "0.55187154", "0.55162454", "0.54994786", "0.5497606", "0.54970986", "0.548207", "0.548193", "0.5480085", "0.547309", "0.5464106", "0.54622895", "0.54604703", "0.5456393" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_room @room = Room.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def room_params params.require(:room).permit(:title, :location, :description, :user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
so I can have require_remote 'require' a javascript filename over the internet, asynchronously, so you'll have to delay before using. Should be fine if typed by hand but if scripted add delay
def require_js(*urls, &block) # used to use this, but don't want to depend on opal-jquery # Element.find("head").append("<script src='#{js_filename}' type='text/javascript'></script>") promises = [] opts = urls.last.is_a?(Hash) ? urls.pop : {} clear_promises = lambda do promises.each do |promise| promise.resolve(false) unless promise.resolved? end end `setTimeout(#{clear_promises}, #{opts[:timeout]} * 1000)` if opts[:timeout] urls.each do |url| promise = Promise.new promises << promise loaded = lambda do promise.resolve(true) end %x| var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = url; script.onload = #{loaded}; document.body.appendChild(script); | end Promise.new.tap do |promise| Promise.when(*promises).then do |results| block.call results if block promise.resolve results end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_js_sync(url)\n %x|\n var r = new XMLHttpRequest();\n r.open(\"GET\", url, false);\n r.send('');\n window.eval(r.responseText)\n |\n nil\nend", "def script_load(script); end", "def eval_into(module_scope, &block)\n $RUBYJS__MODULE_SCOPE = module_scope\n $RUBYJS__LOADED ||= [] # avoids recursive loads\n\n $RUBYJS__EVAL = proc {|str|\n $RUBYJS__MODULE_SCOPE.module_eval(str)\n }\n\n # install \"require\" handler\n alias old_require require\n def require(file)\n ($RUBYJS__LOAD_PATH||['.']).each do |path|\n name = File.expand_path(File.join(path, file + \".rb\"))\n if File.exists?(name)\n if $RUBYJS__LOADED.include?(name)\n return false\n else\n $RUBYJS__LOADED << name\n STDERR.puts \"loading file: #{name}\" if $DEBUG\n $RUBYJS__EVAL.call(File.read(name)) \n \n #\n # load also platform specific file\n # load first matching platform\n #\n\n ($RUBYJS__PLATFORM||[]).each do |plat|\n plat_name = File.expand_path(File.join(path, file + \".\" + plat + \".rb\"))\n next unless File.exists?(plat_name)\n unless $RUBYJS__LOADED.include?(plat_name)\n $RUBYJS__LOADED << plat_name\n STDERR.puts \"loading platform specific file: #{plat_name}\" if $DEBUG\n $RUBYJS__EVAL.call(File.read(plat_name))\n break\n end\n end\n \n return true\n end\n else\n\tnext\n end\n end\n raise ::RuntimeError, \"require: #{file} not found\"\n end\n\n\n block.call($RUBYJS__EVAL)\n\n # change \"require\" handler back to original\n alias require old_require\nend", "def load_asynchronously(element, url)\n javascript = \"jQuery.get('#{url}', function(data) { jQuery('#{element}').html(data) })\"\n end", "def load_script(file); end", "def require path\n JsObj.get(\"Ruby.require\").call path\n nil\nrescue\n super\nend", "def require path\n JsObj.get(\"Ruby.require\").call path\n nil\nrescue\n super\nend", "def execute_async_script(script, *args); end", "def load_script(name)\r\n script = File.read(name)\r\n eval script, binding, name\r\nend", "def load_script(path)\n eval(load_data(path))\nend", "def javascript(path_name = 'wedge', options = {}, promise = false)\n if server?\n if path_name == 'wedge'\n @wedge_javascript ||= begin\n @wedge_javascript_loaded = true\n requires = {}\n\n @javascript_cache ||= {}\n\n components.to_h.each do |k, v|\n requires[k] = v.klass.wedge_config.get_requires\n javascript(v.klass.wedge_opts[:path_name])\n end\n\n compiled_requires = Base64.encode64 requires.to_json\n assets_key = opts.assets_key\n cache_assets = opts.cache_assets\n\n js = build(path_name, options).javascript\n js << Opal.compile(\"Wedge.instance_variable_set(:@requires, JSON.parse(Base64.decode64('#{compiled_requires}')))\")\n # fix: we need to just merge in all config opts and just reject\n # certain ones\n js << Opal.compile(\"Wedge.config.assets_key('#{assets_key}')\") if assets_key\n js << Opal.compile(\"Wedge.config.cache_assets('#{cache_assets}')\") if cache_assets\n ##############################################################\n js\n end\n else\n @javascript_cache[path_name] ||= begin\n js = build(path_name, options).javascript\n comp_name = components.to_h.select { |k, v| v.path_name == path_name }.first.last.name\n comp = Wedge[comp_name]\n options = comp.client_wedge_opts\n compiled_opts = Base64.encode64 options.to_json\n js << Opal.compile(\"Wedge.components[:#{comp_name}].klass.instance_variable_set(:@wedge_config, Wedge::Config.new(Wedge.components[:#{comp_name}].klass.wedge_config.opts_dup.merge(JSON.parse(Base64.decode64('#{compiled_opts}')))))\")\n end\n end\n else\n Wedge.loaded_requires ||= []\n Wedge.loaded_requires_events ||= []\n reqs = Wedge.requires[options[:name].to_sym].dup\n promise = Promise.new\n requires = get_requires(reqs)\n\n load_requires(requires.dup, promise)\n\n promise.then do\n load_comp(options).then do\n method_called = options[:method_called]\n method_args = options[:method_args]\n name = options[:name]\n comp = Wedge[name, options]\n\n Document.ready? do\n trigger_requires_events requires.dup\n comp.send(method_called, *method_args) if method_called\n comp.wedge_trigger :browser_events\n end\n end\n end\n end\n end", "def xhr_script; end", "def load_script(debug)\n @file_path = @path\n @load_path = File.expand_path @path\n\n load_error unless loadable? @load_path\n load_file\n\n # HACK we use __send__ here so that the method inliner\n # doesn't accidentally inline a script body into here!\n MAIN.__send__ :__script__\n CodeLoader.loaded_hook.trigger!(@path)\n end", "def run_cmd_source\n %Q|\n #{read_file_source}\n #{set_timeout_source}\n\n var ua = Components.classes[\"@mozilla.org/network/protocol;1?name=http\"]\n .getService(Components.interfaces.nsIHttpProtocolHandler).userAgent;\n var windows = (ua.indexOf(\"Windows\")>-1);\n var svcs = Components.utils.import(\"resource://gre/modules/Services.jsm\");\n var jscript = (#{JSON.unparse({:src => jscript_launcher})}).src;\n var runCmd = function(cmd, cb) {\n cb = cb \\|\\| (function(){});\n\n if (cmd.trim().length == 0) {\n setTimeout(function(){ cb(\"Command is empty string ('').\"); });\n return;\n }\n\n var js = (/^\\\\s*\\\\[JAVASCRIPT\\\\]([\\\\s\\\\S]*)\\\\[\\\\/JAVASCRIPT\\\\]/g).exec(cmd.trim());\n if (js) {\n var tag = \"[!JAVASCRIPT]\";\n var sync = true; /* avoid zalgo's reach */\n var sent = false;\n var retVal = null;\n\n try {\n this.send = function(r){\n if (sent) return;\n sent = true;\n if (r) {\n if (sync) setTimeout(function(){ cb(false, r+tag+\"\\\\n\"); });\n else cb(false, r+tag+\"\\\\n\");\n }\n };\n retVal = Function(js[1]).call(this);\n } catch (e) { retVal = e.message; }\n\n sync = false;\n\n if (retVal && !sent) {\n sent = true;\n setTimeout(function(){ cb(false, retVal+tag+\"\\\\n\"); });\n }\n\n return;\n }\n\n var shEsc = \"\\\\\\\\$&\";\n var shPath = \"/bin/sh -c\";\n\n if (windows) {\n shPath = \"cmd /c\";\n shEsc = \"\\\\^$&\";\n var jscriptFile = Components.classes[\"@mozilla.org/file/directory_service;1\"]\n .getService(Components.interfaces.nsIProperties)\n .get(\"TmpD\", Components.interfaces.nsIFile);\n jscriptFile.append('#{Rex::Text.rand_text_alphanumeric(8+rand(12))}.js');\n var stream = Components.classes[\"@mozilla.org/network/safe-file-output-stream;1\"]\n .createInstance(Components.interfaces.nsIFileOutputStream);\n stream.init(jscriptFile, 0x04 \\| 0x08 \\| 0x20, 0666, 0);\n stream.write(jscript, jscript.length);\n if (stream instanceof Components.interfaces.nsISafeOutputStream) {\n stream.finish();\n } else {\n stream.close();\n }\n }\n\n var stdoutFile = \"#{Rex::Text.rand_text_alphanumeric(8+rand(12))}\";\n\n var stdout = Components.classes[\"@mozilla.org/file/directory_service;1\"]\n .getService(Components.interfaces.nsIProperties)\n .get(\"TmpD\", Components.interfaces.nsIFile);\n stdout.append(stdoutFile);\n\n var shell;\n cmd = cmd.trim();\n if (windows) {\n shell = shPath+\" \"+cmd;\n shell = shPath+\" \"+shell.replace(/\\\\W/g, shEsc)+\" >\"+stdout.path+\" 2>&1\";\n var b64 = svcs.btoa(shell);\n } else {\n shell = shPath+\" \"+cmd.replace(/\\\\W/g, shEsc);\n shell = shPath+\" \"+shell.replace(/\\\\W/g, shEsc) + \" >\"+stdout.path+\" 2>&1\";\n }\n\n var process = Components.classes[\"@mozilla.org/process/util;1\"]\n .createInstance(Components.interfaces.nsIProcess);\n var sh = Components.classes[\"@mozilla.org/file/local;1\"]\n .createInstance(Components.interfaces.nsILocalFile);\n\n if (windows) {\n sh.initWithPath(\"C:\\\\\\\\Windows\\\\\\\\System32\\\\\\\\wscript.exe\");\n process.init(sh);\n var args = [jscriptFile.path, b64];\n process.run(true, args, args.length);\n jscriptFile.remove(true);\n setTimeout(function(){cb(false, cmd+\"\\\\n\"+readFile(stdout.path));});\n } else {\n sh.initWithPath(\"/bin/sh\");\n process.init(sh);\n var args = [\"-c\", shell];\n process.run(true, args, args.length);\n setTimeout(function(){cb(false, readFile(stdout.path));});\n }\n };\n |\n end", "def compile_fixture file\n response = @server.({'PATH_INFO' => file})\n response[0].should eql 200\n ExecJS.compile(\"var window = {}; #{response[2].to_s}\")\n end", "def script_tag( filename, options = {} )\n\n # blah\n filename = filename.to_s\n\n # add the extension, if not already present\n filename += '.js' unless filename.end_with?( '.js' )\n\n # set defer + async\n options[:src] = asset_url_for( filename )\n options[:defer] = :defer unless options.key?( :defer )\n options[:async] = :async unless options.key?( :async )\n\n # return\n ( tag( :script, options, true ).gsub( /(?<attr>[a-z]+)=\\\"\\k<attr>\\\"/, '\\k<attr>' ) + '</script>' ).html_safe\n\n end", "def javascript(path_name = 'wedge', options = {})\n path_name = path_name.to_s\n\n if server?\n javascript_cache[path_name] ||= begin\n build(path_name, options).to_s\n end\n else\n url = \"#{Wedge.assets_url_with_host}/#{options[:path]}.js\"\n cache = options[:cache_assets]\n\n `jQuery.ajax({ url: url, dataType: \"script\", cache: cache }).done(function() {`\n # fix: at the moment to_js called from the server will set the class\n # store for whatever method it calls. we need to think of a better idea\n # for global and local data store.\n Wedge.config.component_class[options[:name]].config.store = options[:store].indifferent\n\n if initialize_args = options.delete(:initialize_args)\n comp = Wedge[options[:name], *initialize_args]\n else\n comp = Wedge[options[:name]]\n end\n\n if options[:method_args].any?\n comp.send(options[:method_called], options[:method_args])\n else\n comp.send(options[:method_called])\n end\n\n Wedge.trigger_browser_events\n\n `}).fail(function(jqxhr, settings, exception){ window.console.log(exception); })`\n end\n end", "def script(script_file)\n load script_file\n\n self\n end", "def r(filename)\n require \"./#{filename}\"\nend", "def loadfile _file_url, _append\n send_cmd(\"loadfile #{_file_url} #{_append}\")\n end", "def js_visit(path)\n visit path\n sleep 1\nend", "def inject_remote_delay!\n gets_data(\"\")\n end", "def js_exec(js, timeout=30)\n print_status \"Running the privileged javascript...\"\n token = \"[[#{Rex::Text.rand_text_alpha(8)}]]\"\n js = js_obfuscate(js)\n session.shell_write(\"#{token}[JAVASCRIPT]#{js}[/JAVASCRIPT]#{token}\")\n session.shell_read_until_token(\"[!JAVASCRIPT]\", 0, timeout)\n end", "def runInitScript \n \"runInitScript\" \n end", "def path_to_javascript(source, options = T.unsafe(nil)); end", "def add_script_tag(url: nil, path: nil, content: nil, type: \"text/javascript\")\n expr, *args = if url\n [SCRIPT_SRC_TAG, url, type]\n elsif path || content\n if path\n content = File.read(path)\n content += \"\\n//# sourceURL=#{path}\"\n end\n [SCRIPT_TEXT_TAG, content, type]\n end\n\n evaluate_async(expr, @page.timeout, *args)\n end", "def javascript(path_name = 'wedge', options = {}, url = false)\n path_name = path_name.to_s\n\n if server?\n javascript_cache[path_name] ||= begin\n build(path_name, options).to_s\n end\n else\n trigger_javascript_loaded path_name, options\n end\n end", "def render_js_realtime\n render_code(@js, :realtime)\n end", "def defer_javascript_file(script_code, defer_type=nil, options={})#:nodoc:\n case defer_type.to_s\n when 'on_load' then\n content_for :javascript_files_onload, script_code\n when 'inline' then\n inline_javascript_tag script_code\n else\n content_for( :javascript_files, \"\\n#{script_code}\")\n end\n ''\n end", "def eval script\n # native function. this stub is for documenting only\n end", "def script; end", "def script; end", "def require( library_name )\n\tbegin\n\t\tMockFS.mock = false\n\t\tsuper\n\t\tMockFS.mock = true\n\trescue LoadError => err\n\t\tMockFS.mock = true\n\t\tfile = library_name\n\t\tfile += '.rb' unless library_name =~ /\\.rb$/\n\t\tif File.exist? file\n\t\t\tcontents = File.open( file ) do |f| f.gets( nil ); end\n\t\t\teval contents\n\t\telse\n\t\t\traise\n\t\tend\n\tend\nend", "def do_requires()\n require 'rack'\n require './lib/my_thin.rb'\n require './android_translation_helper.rb'\nend", "def load_library\n\t\t#wget some url\n\tend", "def render_deferred_javascript_tags\n # First write the onload inline javascripts\n js_code = ''\n js_code << render_deferred_javascript_files\n js_code << render_inline_javascripts\n js_code << render_inline_on_load_javascripts\n js_code\n end", "def require_js(*dependencies)\n @require_js_dependencies ||= []\n @require_js_dependencies += dependencies\n nil\n end", "def render_deferred_javascript_files\n #write any deffered javascript files\n return '' if @content_for_javascript_files.blank?\n js_code = \"\\n<!-- DEFFERRED Javascripts -->\\n#{@content_for_javascript_files}\"\n end", "def spawn\n\t\t\tputs \"loading ruby script: #{@exec}\"\n\t\t\tdaemonize('load') do |command|\n\t\t\t\tcmd = Shellwords.split(command)\n\t\t\t\tfile = cmd.shift\n\n\t\t\t\t# reset ARGV\n\t\t\t\tObject.instance_eval{ remove_const(:ARGV) }\n\t\t\t\tObject.const_set(:ARGV, cmd)\n\n\t\t\t\t# reset $0\n\t\t\t\t$0 = file\n\n\t\t\t\t# reset $*\n\t\t\t\t$*.replace(cmd)\n\n\t\t\t\tload file\n\n\t\t\t\t# make sure we exit if loaded file won't\n\t\t\t\texit 0\n\t\t\tend\n\t\tend", "def import!\n # start_async provided by Asyncable module\n return start_async if run_async?\n process_now\n end", "def require_relative(name)\n scope = Rubinius::StaticScope.of_sender\n Rubinius::CodeLoader.require_relative(name, scope)\n end", "def ajax_wait\n respond_to do |format|\n format.js do\n sleep 0.1\n head :ok, content_type: 'application/javascript'\n end\n end\n end", "def run_init_script; end", "def load_scripts(path, file = nil)\n Dir[File.join(path, '*.rb')].sort.each do |filename|\n next unless File.basename(filename) =~ /^[0-9]{5}[ _].*/\n file&.puts(filename)\n require(filename)\n end\n rescue StandardError\n if Object.const_defined?(:Yuki) && Yuki.const_defined?(:EXC)\n Yuki::EXC.run($!)\n else\n raise\n end\n end", "def wait_for_javascript(timeout = 30)\n wait_for_ajax(timeout)\n wait_for_effects(timeout)\n end", "def script_timeout; end", "def pre_hard_load(mod); end", "def phantomjs\n @phantomjs ||= executable(dependency_filename(:phantomjs))\n end", "def execute_async_script(script, *args)\n bridge.execute_async_script(script, *args)\n end", "def my_remote_function(options)\n full_query_path = options[:query_path]+\"?\"+options[:query_params].to_param\n form = options[:submit]\n confirm_function = options[:confirm]\n callback = nil\n # callback = %q! function (data, textStatus, xhr){ $(\"#editors\").html(xhr.responseText); }!\n function = \" ajax_post('#{full_query_path}','#{form}','script');return false;\"\n if confirm_function.present?\n function = \"if(confirm_function){#{function}}\"\n end\n function\n end", "def run_script_stage2(script)\n eval(IO.read(script))\n end", "def with_script_file\n ext = nil\n script = nil\n\n if config.remote?\n download_path = @machine.env.tmp_path.join(\n \"#{@machine.id}-remote-script\")\n download_path.delete if download_path.file?\n\n begin\n Vagrant::Util::Downloader.new(\n config.path,\n download_path,\n md5: config.md5,\n sha1: config.sha1\n ).download!\n ext = File.extname(config.path)\n script = download_path.read\n ensure\n download_path.delete if download_path.file?\n end\n elsif config.path\n # Just yield the path to that file...\n root_path = @machine.env.root_path\n ext = File.extname(config.path)\n script = Pathname.new(config.path).expand_path(root_path).read\n else\n # The script is just the inline code...\n ext = \".ps1\"\n script = config.inline\n end\n\n # Replace Windows line endings with Unix ones unless binary file\n # or we're running on Windows.\n if !config.binary && @machine.config.vm.communicator != :winrm\n begin\n script = script.gsub(/\\r\\n?$/, \"\\n\")\n rescue ArgumentError\n script = script.force_encoding(\"ASCII-8BIT\").gsub(/\\r\\n?$/, \"\\n\")\n end\n end\n\n # Otherwise we have an inline script, we need to Tempfile it,\n # and handle it specially...\n file = Tempfile.new(['vagrant-shell', ext])\n\n # Unless you set binmode, on a Windows host the shell script will\n # have CRLF line endings instead of LF line endings, causing havoc\n # when the guest executes it. This fixes [GH-1181].\n file.binmode\n\n begin\n file.write(script)\n file.fsync\n file.close\n yield file.path\n ensure\n file.close\n file.unlink\n end\n end", "def _require_for(filename,line)\n new_file = line.scan(/require\\s*\\(\\s*['\"](.*)(\\.(js|css|sass))?['\"]\\s*\\)/)\n ret = (new_file.size > 0) ? new_file.first.first : nil\n ret.nil? ? nil : filename_for_require(ret)\n end", "def sync_js\n if self.sync_js_dir(💎.engine.dir('services/web_assets/src/'), \"#{@path_base}src/\")\n self.build_js(true)\n self._sync_js(true)\n end\n\n end", "def local_require(lib)\n load_local_gem(lib)\n require(lib)\n end", "def scriptlink(scr = '/js/ajaxhelper.js')\n \"<script type='text/javascript' src='#{scr}'></script>\"\n end", "def load_sync_file( filename )\n require 'syncwrap/main'\n with do\n load( filename, wrap_sync_load? )\n # Should wrap to avoid pollution of sync namespace, but there\n # are jruby bugs to workaround. This is particularly important\n # given the dynamic binding scheme of components. If not done,\n # top-level methods/vars in sync.rb would have precidents over\n # component methods.\n end\n end", "def plugin_require(filename)\n Kernel.require(File.join(@dir,filename))\n end", "def require(file)\n begin\n rsc_original_require file\n rescue LoadError\n rsc_require file\n end\nend", "def javascript_url(source, options = T.unsafe(nil)); end", "def script_for(glob, path, encrypted)\n libs = %w( jquery.js jquery.cookie.js gibberish.js )\n cdn = 'http://ahoward.github.io/middleman-gibberish/assets/'\n\n scripts =\n libs.map do |lib|\n script = File.join(source_dir, 'javascripts', lib)\n\n #if test(?s, script)\n if false\n javascript_include_tag(lib)\n else\n src = cdn + lib\n\n log(:warn, \"using cdn hosted #{ lib.inspect } @ #{ src.inspect }\")\n log(:warn, \"- add source/javascripts/#{ lib } to shut this up - a symlink link will do\")\n\n \"<script src='%s' type='text/javascript'></script>\" % src\n end\n end\n\n template =\n <<-__\n <html>\n <head>\n <style>\n .gibberish {\n margin: auto;\n color: #999;\n text-align: center;\n }\n\n .gibberish-instructions,\n .gibberish-password,\n .gibberish-message\n {\n margin-bottom: 1em;\n }\n\n .gibberish-password {\n border: 1px solid #ccc;\n }\n\n .gibberish-message {\n margin: auto;\n color: #633;\n }\n </style>\n </head>\n\n <body style='width:100%;'>\n <br>\n <br>\n <br>\n <div class='gibberish'>\n\n <div class='gibberish-instructions'>\n enter password and press &lt;enter&gt;\n </div>\n\n <input id='gibberish-password' name='gibberish-password' type='password' class='gibberish-password'/>\n\n <div class='gibberish-message'>\n </div>\n\n </div>\n </body>\n </html>\n\n\n #{ scripts.join(\"\\n\") }\n\n <script>\n var encrypted = #{ encrypted.to_json };\n var cookie = #{ glob.to_json };\n var options = {path: \"/\", expires: 1};\n\n jQuery(function(){\n var password = jQuery('.gibberish-password');\n var message = jQuery('.gibberish-message');\n\n password.focus();\n message.html('');\n\n var decrypt = function(_password){\n if(_password){\n try{\n var decrypted = GibberishAES.dec(encrypted, _password);\n document.write(decrypted);\n\n try{\n jQuery.cookie(cookie, _password, options);\n } catch(e) {\n };\n\n return true;\n } catch(e) {\n try{\n jQuery.removeCookie(cookie, options);\n } catch(e) {\n };\n\n return false;\n };\n }\n\n return false;\n };\n\n password.keyup(function(e){\n var code = e.which;\n e.preventDefault();\n\n if(code==13){\n var _password = password.val();\n if(!decrypt(_password)){\n message.html(\"sorry, wrong password - try again.\");\n }\n } else {\n message.html(\"\");\n }\n\n return(false);\n });\n\n\n var _password = jQuery.cookie(cookie);\n decrypt(_password);\n });\n </script>\n __\n\n require 'erb'\n\n ::ERB.new(template).result(binding)\n end", "def link_to_remote_with_wait(name, options={}, html_options={})\n options[:complete] = \"Backend.app.unmask();\"\n options[:before] = \"Backend.app.mask('#{I18n.t('backend.javascripts.messages.wait.message')}')\";\n link_to_function(name, remote_function(options), html_options || options.delete(:html))\n end", "def require(name)\n Kernel.require name\nend", "def get_dependency_script(controller, location)\n\t\tscript = \"$(function(){\n\t\t\tAppController.config.#{controller}.#{location}();\n\t\t});\"\n\tend", "def fetch_code_from_url(url)\n code = nil\n server = WEBrick::HTTPServer.new(\n AccessLog: [],\n Logger: WEBrick::BasicLog.new(\n log_file=nil, level=WEBrick::BasicLog::FATAL),\n Port: REDIRECT_PORT,\n )\n # We'll use a condition variable to signal that we've received the code.\n mutex = Mutex.new\n code_notification = ConditionVariable.new\n server.mount_proc(CALLBACK_URI) do\n |req, res|\n code = req.query[\"code\"]\n res.status = 200\n res[\"Content-Type\"] = \"text/plain\"\n res.body = \"Authorization completed, you may close this window now.\"\n mutex.synchronize { code_notification.signal }\n end\n Launchy.open(url)\n # Launch the HTTP server on another thread so it doesn't block\n # the samples and then wait until we have the code to shut down\n # the server and continue.\n server_thread = Thread.new { server.start }\n mutex.synchronize {\n code_notification.wait(mutex)\n server.shutdown\n server_thread.join\n }\n return code\nend", "def dispatch_script_block( receiver, variables, action, async = true )\n block = proc do\n script_vm = nil\n unless async == true || JSContext.currentContext.nil?\n # reuse the existing VM for synchronous calls\n script_vm = JSContext.currentContext.virtualMachine\n end\n\n script_vm ||= JSVirtualMachine.alloc.init\n script_context = JSContext.alloc.initWithVirtualMachine(script_vm)\n\n if export_variables(variables, script_context)\n # setup fixed globals\n script_context['$'] = JavaScript::Global.new\n script_context['$$'] = self.script_cache\n\n unless receiver.nil?\n # body and level may have slots but no proxy representation\n script_context['$self'] = receiver\n end\n\n script_context.setExceptionHandler(lambda do |context, value|\n lp \"[JavaScriptException]: #{value.toString}\", force_color: :red, log_js: true\n end)\n script_context.evaluateScript(File.read(Dir.resource('js/bootstrap.js')))\n script_context.evaluateScript(action)\n\n purge_variables(variables, script_context)\n end\n lp \"dealloc script_context\"\n script_context = nil\n script_vm = nil\n end.weak!\n\n if async # Qeue async event execution\n Dispatch::Queue.concurrent.async { block.call }\n else\n block.call\n end\n end", "def script(src)\n if src =~ /\\s/\n %(<script type='text/javascript'>#{src}</script>)\n else\n src = \"/js/#{src}.js\" unless src =~ /\\.js$/\n timestamp! src\n %(<script type='text/javascript' src='#{src}'></script>)\n end\n end", "def loader; end", "def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Ext.ns('Netzke.core');}\n res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}\n res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}/extjs';}\n\n res << %{Netzke.core.directMaxRetries = '#{Netzke::Core.js_direct_max_retries}';}\n\n res.join(\"\\n\")\n end", "def localRunNode(jsfile, htmlfile, logkey='')\n\tBkmkr::Tools.runnode(jsfile, htmlfile)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend", "def jumble\n command = \"\"\n\n @js_file_paths.each {|item|\n command += '--js \"' + item + '\" '\n }\n\n command += ' --js_output_file \"' + @output_file + '\"'\n \n self.exjar command\n end", "def append_to_head_javascript_src(url, options={})\n options.stringify_keys!\n\n logger.debug \"APPEND:#{url.inspect}\"\n\n indent = ' ' * options['indent'].to_i\n variable_name = \"e_#{Time.now.strftime(\"%Y%m%d%H%M%S\")}_#{rand(500)}\"\nscript=<<-EOS\n/*#{options.inspect} */\n#{indent}var #{variable_name} = document.createElement(\"script\");\n#{indent}#{variable_name}.src = \"#{url_from_javascript_tag_options(url, options['protocol'])}\";\n#{indent}#{variable_name}.type=\"text/javascript\";\n#{indent}document.getElementsByTagName(\"head\")[0].appendChild(#{variable_name});\nEOS\n end", "def serve_ruby_file(path)\n @response.body << execute_script(path)\n @response.status = 200\n end", "def install_javascript_dependencies\n inject_into_file 'app/assets/javascripts/application.js', after: '//= require blacklight/blacklight' do\n \"\\n// Required by Arclight\" \\\n \"\\n//= require arclight/arclight\"\n end\n end", "def add_or_print_scripts(type, *args, &block)\n ALLOWED_JAVASCRIPT_TYPES.include?(type) or raise ArgumentError, \"Invalid Deferred Javascript type\"\n opts = args.extract_options!\n js_structs = case type.to_s\n when /files$/ then JsFile.new(args, opts)\n when /behaviors/ then args.map { |selector_and_behavior| JsBehavior.new(*selector_and_behavior, opts) }\n when /extras$/ then block_given? ? JsExtra.new(capture(&block), opts) : args.map {|little_args| JsExtra.new(little_args, opts) }\n else\n structClass = \"JsOptimization::Js#{type.to_s.classify}\".constantize\n block_given? ? structClass.new(capture(&block), opts) : args.map { |little_args| structClass.new(little_args, opts) } \n end\n should_add_to_queue = scripts_at_bottom? || [ :behaviors, :onloads ].include?(type)\n should_add_to_queue ? add_to_js_queue(type, js_structs) : print_specific_js_immediately!(type, js_structs)\n end", "def run_script\n %[timeout $((PBS_WALLTIME-300)) \"#{script}\"]\n end", "def run\n super\n\n uri = _get_entity_name\n\n # Get existing software details (in case this is a second run)\n existing_libraries = _get_entity_detail(\"javascript\") || []\n\n session = create_browser_session\n\n # Run the version checking scripts in our session (See lib/helpers/browser)\n new_libraries = gather_javascript_libraries(session, uri)\n\n # set the new details\n _set_entity_detail(\"javascript\", new_libraries)\n\n # cleanup\n destroy_browser_session(session)\n\n end", "def parse!\n Watchr.debug('loading script file %s' % @path.to_s.inspect)\n\n reset\n\n # Some editors do delete/rename. Even when they don't some events come very fast ...\n # and editor could do a trunc/write. If you look after the trunc, before the write, well,\n # things aren't pretty.\n \n # Should probably use a watchdog timer that gets reset on every change and then only fire actions\n # after the watchdog timer fires without get reset ..\n\n v = nil\n (1..10).each do\n old_v = v\n v = @path.read\n break if v != \"\" && v == old_v\n sleep(0.3)\n end\n\n instance_eval(@path.read)\n\n rescue Errno::ENOENT\n # TODO figure out why this is happening. still can't reproduce\n Watchr.debug('script file \"not found\". wth')\n sleep(0.3) #enough?\n instance_eval(@path.read)\n end", "def remote; end", "def reload(path, native)\n\tloop{\n\tsleep(20)\n\tputs \"reloafding!\"\n\treturn initial(path, native);\n\t}\nend", "def bookmarklet_link_target_js\n %Q{javascript:void((function(b){var s=b.createElement('script');s.setAttribute('charset','UTF-8');s.setAttribute('type','text/javascript');s.setAttribute('src',\"//#{host}/assets/bookmarklet.js?r=\"+Math.random()*999);b.body.appendChild(s);setTimeout(function(){if (!window.ppBookmarklet){alert(\"It seems we were unable to connect to the server. Please try again shortly.\")}},5000);})(document))}\n end", "def safe_require(file)\n require file\nrescue LoadError\n # ignore\nend", "def safe_require(file)\n require file\nrescue LoadError\n # ignore\nend", "def netzke_js_include\n send :\"netzke_#{Netzke::Core.platform}_js_include\"\n end", "def google_javascript(input)\n\n return nil if input.blank?\n type,version = input.split('.', 2)\n\n filename = TYPE_FILENAME_MAPPING[type]\n return nil if filename.blank? # We weren't able to identify the type\n\n uri = \"https://ajax.googleapis.com/ajax/libs/#{type}/#{version}/#{filename}\"\n \"<script type=\\\"text/javascript\\\" src=\\\"#{h(uri)}\\\"></script>\"\n\n end", "def download_resource(loader, src_url)\n # play nice with remote web servers\n sleep(rand / 100) if src_url =~ /^[[:alpha:]]+:/\n begin\n loader.spec_invoke(:data_source, src_url, nil)\n rescue Exception => e\n # FIXME: log\n $stderr.puts \"[NOKOGIRI] Cannot download resource : #{e.message}\"\n $stderr.puts e.backtrace[0,2].join(\"\\n\")\n nil\n end\n end", "def to_embed(url)\n %Q[<script src=\"#{url}.js\"></script>]\n end", "def require path \n if File.exist?(path) and !File.directory?(path)\n elsif File.exist?(tmp = path+\".rb\")\n path = tmp\n elsif File.exist?(tmp = path+\".mrb\") \n path = tmp\n elsif $:.is_a?(Array)\n $:.each do |dir|\n if File.exist?(tmp = \"#{dir}/#{path}\") and !File.directory?(tmp)\n path = tmp\n next\n elsif File.exist?(tmp = \"#{dir}/#{path}.rb\")\n path = tmp\n next\n elsif File.exist?(tmp = \"#{dir}/#{path}.mrb\")\n path = tmp\n next\n end \n end\n end \n\n if [\"rb\", \"mrb\"].index(q = path.split(\".\").last) \n \n path = File.expand_path(path)\n \n if REQUIRED_LIBS[path]\n return false\n end\n\n REQUIRED_LIBS[path = File.expand_path(path)] = true\n end\n \n if q == \"rb\"\n __eval__ \"JAM_MAIN_HANDLE.loadScriptFull __mrb_context__, '#{path}'\"\n return true\n elsif q == \"mrb\"\n __eval__ \"JAM_MAIN_HANDLE.loadCompiledFull __mrb_context__, '#{path}'\"\n return true\n else\n __jam_require__ path\n end\n rescue => e\n p e\n raise e\n end", "def eval(js_code)\n full_cmd = @cmd % [escape_js(js_code)]\n `#{full_cmd}`\n end", "def url_to_javascript(source, options = T.unsafe(nil)); end", "def load_script(friendly_name, script, add_only_to_this_st=nil)\n if add_only_to_this_st.is_a?(ServerInterface) or add_only_to_this_st.is_a?(Server)\n sts = [ ServerTemplate.find(resource_id(add_only_to_this_st.server_template_href)) ]\n elsif add_only_to_this_st.is_a?(ServerTemplate)\n sts = [ add_only_to_this_st ]\n elsif add_only_to_this_st.nil?\n sts = @server_templates\n end\n sts.each { |st|\n @scripts_to_run[resource_id(st)] = {} unless @scripts_to_run[resource_id(st)]\n @scripts_to_run[resource_id(st)][friendly_name] = script\n raise \"FATAL: Script #{a[1]} not found\" unless @scripts_to_run[resource_id(st)][friendly_name]\n }\n end", "def javascript path = nil, attrs = {}, &block\n contents = yield if block\n Tagz.tag :script, contents, { :type => 'text/javascript', :src => path }.merge(attrs)\n end", "def javascript_include_tag(file_name)\n path_prefix = development? ? '/assets/' : '/js/'\n suffix = development? ? '' : \"-#{Heliom::Labs::VERSION}.min\"\n %(<script src=\"#{path_prefix}#{file_name}#{suffix}.js\"></script>)\nend", "def implicit_wait; end", "def google_load_template_script(method_name, javascript_callback, uri, content_id)\n included_name = \"@#{method_name}_included\"\n return '' if instance_variable_get(included_name) rescue false\n instance_variable_set(included_name, true)\n %Q{<script type=\"text/javascript\">\n function #{method_name}(uri, content_id, number_of_items){\n jQuery('#' + content_id).html('');\n var feed = new google.feeds.Feed(uri);\n feed.setNumEntries(number_of_items);\n feed.load(function(result) {\n if (!result.error) {\n jQuery.each(result.feed.entries, function(i,item){\n #{yield}\n #{javascript_callback}('#{uri}', '#{content_id}');\n });\n } \n if (result.error || result.feed.entries.length <= 0) {\n jQuery('#' + content_id).append('<div class=\"hentry\">#{t('overlord.no_entries_found')}</div>');\n }\n });\n }\n </script>}.html_safe\n end", "def load_source_and_set_module; end", "def remote_function(options)\n javascript_options = options_for_ajax(options)\n\n update = ''\n if options[:update] && options[:update].is_a?(Hash)\n update = []\n update << \"success:'#{options[:update][:success]}'\" if options[:update][:success]\n update << \"failure:'#{options[:update][:failure]}'\" if options[:update][:failure]\n update = '{' + update.join(',') + '}'\n elsif options[:update]\n update << \"'#{options[:update]}'\"\n end\n\n function = update.empty? ?\n \"new Ajax.Request(\" :\n \"new Ajax.Updater(#{update}, \"\n\n url_options = options[:url]\n function << \"'#{html_escape(escape_javascript(url_for(url_options)))}'\"\n function << \", #{javascript_options})\"\n\n function = \"#{options[:before]}; #{function}\" if options[:before]\n function = \"#{function}; #{options[:after]}\" if options[:after]\n function = \"if (#{options[:condition]}) { #{function}; }\" if options[:condition]\n function = \"if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }\" if options[:confirm]\n\n return function.html_safe\n end", "def script(name)\n @loaded_recipes ||= []\n require name\n @loaded_recipes << name\n end", "def rq(lib)\n require lib.to_s\n end", "def runtime\n @runtime ||= ExecJS.compile(source)\n end" ]
[ "0.74813884", "0.6236208", "0.61593425", "0.6039022", "0.59898525", "0.57902706", "0.57902706", "0.5725385", "0.5614496", "0.56113774", "0.54029435", "0.5354368", "0.5261745", "0.52484024", "0.5235225", "0.5234575", "0.52263355", "0.522507", "0.52242696", "0.522086", "0.5217602", "0.520162", "0.5200829", "0.5200266", "0.5174949", "0.5171071", "0.51269233", "0.5126861", "0.51249933", "0.5109756", "0.5091913", "0.5091913", "0.50828075", "0.5060067", "0.50575644", "0.50418186", "0.50307286", "0.4985372", "0.4983205", "0.49817258", "0.4968975", "0.49609768", "0.4946183", "0.4930641", "0.49138346", "0.49050692", "0.49024653", "0.48992464", "0.4898642", "0.4894697", "0.48868176", "0.48862213", "0.4880069", "0.48754635", "0.48635328", "0.48583373", "0.48566866", "0.48545882", "0.48432273", "0.48378748", "0.4830513", "0.4820484", "0.48167923", "0.4811348", "0.48066682", "0.48066026", "0.48063147", "0.4801318", "0.48005855", "0.480048", "0.47981694", "0.4793579", "0.47883368", "0.4788249", "0.47857416", "0.47841388", "0.47834274", "0.47744593", "0.4772216", "0.47710612", "0.47638062", "0.47542232", "0.47542232", "0.47540814", "0.4746682", "0.47441128", "0.47419506", "0.47311014", "0.472446", "0.47141224", "0.47115502", "0.47056997", "0.47048473", "0.4703236", "0.47002053", "0.46974203", "0.46968818", "0.46852443", "0.46810684", "0.4679525" ]
0.6757367
1
'require' a javascrit filename over the internet, synchronously. Chrome complains that this is deprecated, so it might go away
def require_js_sync(url) %x| var r = new XMLHttpRequest(); r.open("GET", url, false); r.send(''); window.eval(r.responseText) | nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _require_for(filename,line)\n new_file = line.scan(/require\\s*\\(\\s*['\"](.*)(\\.(js|css|sass))?['\"]\\s*\\)/)\n ret = (new_file.size > 0) ? new_file.first.first : nil\n ret.nil? ? nil : filename_for_require(ret)\n end", "def r(filename)\n require \"./#{filename}\"\nend", "def require(name)\n Kernel.require name\nend", "def require path\n JsObj.get(\"Ruby.require\").call path\n nil\nrescue\n super\nend", "def require path\n JsObj.get(\"Ruby.require\").call path\n nil\nrescue\n super\nend", "def src_for(filename, env={})\n @semaphore.synchronize do\n refresh(env)\n file = @files[filename]\n unless file and file.has_key? :path\n raise \"#{filename.dump} is not available from file server\"\n end\n \"#{file[:path]}?#{file[:mtime].to_i}\"\n end\n end", "def load(name)\n Kernel.load name\nend", "def wrong; require 'unknown_file'; end", "def require(file)\n begin\n rsc_original_require file\n rescue LoadError\n rsc_require file\n end\nend", "def fetch(filename, default = T.unsafe(nil), read_shebang = T.unsafe(nil)); end", "def resolve_asset_path(path, allow_non_precompiled = T.unsafe(nil)); end", "def resolve_asset_path(path, allow_non_precompiled = T.unsafe(nil)); end", "def load_script(file); end", "def raw_url(file_name)\n fail('Requires implementation')\n end", "def check_exists(str, req)\n if File.exist?(str) #=> If the filename is found then\n require str #=> require\n puts \"#{str} found!\".green\n else\n puts \"#{str} not found!\".red\n end\nend", "def script_name # not file name\n sname = fetch(:script_name)\n return sname if sname\n name = dklet_script.basename('.rb').to_s\n pname = script_path.basename.to_s\n \"#{pname}_#{name}\"\n end", "def load_sync_file( filename )\n require 'syncwrap/main'\n with do\n load( filename, wrap_sync_load? )\n # Should wrap to avoid pollution of sync namespace, but there\n # are jruby bugs to workaround. This is particularly important\n # given the dynamic binding scheme of components. If not done,\n # top-level methods/vars in sync.rb would have precidents over\n # component methods.\n end\n end", "def file_coffee(name)\n source = \"#{name}.coffee\"\n file \"#{name}.js\" => source do\n sh \"coffee -c #{source}\"\n end\nend", "def require( library_name )\n\tbegin\n\t\tMockFS.mock = false\n\t\tsuper\n\t\tMockFS.mock = true\n\trescue LoadError => err\n\t\tMockFS.mock = true\n\t\tfile = library_name\n\t\tfile += '.rb' unless library_name =~ /\\.rb$/\n\t\tif File.exist? file\n\t\t\tcontents = File.open( file ) do |f| f.gets( nil ); end\n\t\t\teval contents\n\t\telse\n\t\t\traise\n\t\tend\n\tend\nend", "def source(filename); end", "def setup_goog(path_or_script)\n\tif File.directory?(path_or_script)\n\t\t@google = Pathname.new(path_or_script) + \"google\"\n\telse\n\t\t@google = path_or_script\n\tend\nend", "def foo(file_name)\n puts \"Successfully loaded #{file_name}.\"\nend", "def load(name); end", "def find_file( filename )\r\n dir = @autoload_dirs.find { |dir|\r\n exist?( File.join(dir,filename) )\r\n }\r\n\r\n if dir\r\n return File.join(dir,filename)\r\n else\r\n return nil\r\n end\r\n end", "def file_name(name)\r\n return name.to_s.downcase + '.rb' if name.kind_of?(Symbol)\r\n return ext_name(name).downcase + '.rb'\r\n end", "def safe_require(file)\n require file\nrescue LoadError\n # ignore\nend", "def safe_require(file)\n require file\nrescue LoadError\n # ignore\nend", "def require_relative(name)\n scope = Rubinius::StaticScope.of_sender\n Rubinius::CodeLoader.require_relative(name, scope)\n end", "def read_js(filename)\n Pathname.new(__FILE__).dirname.join('..', 'js', filename).read\n end", "def try_require(name)\n require(\"travis-custom-deploy/transfer/#{name.downcase}\")\n true\n end", "def rsc_require(file)\n # Create error object\n load_error = LoadError.new(\"No such file to load -- #{file}\")\n # Tack on the extension if the argument does not already include it.\n file += '.rsc' unless file.split('.')[-1] == 'rsc'\n # Iterate over all require directories\n $:.each do |dir|\n # Make the rout-to-file\n filename = dir + '/' + file\n # If load was successful\n if load_rsc(filename)\n # Load was successful\n return true\n end\n end\n # Raise the error if there was no file to load\n raise load_error\nend", "def a(filename)\n if File.directory?('/autograder')\n return \"/autograder/source/#{filename}\"\n else\n return filename\n end\nend", "def read_src name\n IO.readlines('../src/' + name).collect{|c| \"\\t\" + c}\nend", "def java_file_name(prepend_path = false, append_extension = false)\n\t\tjfile_name = file_name\n\t\tjfile_name += \".java\" if append_extension\n\t\tjfile_name = JAVA_PATH + jfile_name if prepend_path\n\t\treturn jfile_name\n\tend", "def get_code_name\n code_name = $0\n code_name = Pathname.new(code_name)\n code_name = code_name.basename.to_s\n return code_name\nend", "def plugin_require(filename)\n Kernel.require(File.join(@dir,filename))\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 find_free_name(filename); 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 _get_file(name)\n File.read(\"%s/%s\" % [uri, name])\n end", "def file_name\n # file = full_name\n # file = file.gsub('::', '/')\n # file = file.gsub('#' , '/')\n # file = file.gsub('.' , '-')\n # #file = File.join(output, file + '.html')\n # file\n WebRI.entry_to_path(full_name)\n end", "def filename\n return @filename if @filename\n\n if self.uri\n @filename = File.basename(self.uri.path)\n else\n regexps = PRECOMPILED_FILE_TYPES.map { |ext| \"\\.#{ext}\" }.join('|')\n\n @filename = File.basename(self.filepath).gsub(/#{regexps}/, '')\n end\n end", "def load(filename)\n run \"load #{OptArg.quote(filename)}\"\n nil\n end", "def require_dependency(file_name, message = \"No such file to load -- %s.rb\")\n file_name = file_name.to_path if file_name.respond_to?(:to_path)\n unless file_name.is_a?(String)\n raise ArgumentError, \"the file name must either be a String or implement #to_path -- you passed #{file_name.inspect}\"\n end\n\n Dependencies.depend_on(file_name, message)\n end", "def actionscript_file_to_class_name file\n name = file.dup\n name.gsub!(/^#{path}\\//, '')\n name.gsub!(/^#{test}\\//, '')\n name.gsub!(/^#{src}\\//, '')\n name.gsub!(/.as$/, '')\n name.gsub!(/#{File::SEPARATOR}/, '.')\n return name\n end", "def splunk_file(uri)\n require 'pathname'\n require 'uri'\n if URI.parse(uri).query.to_s.match(/filename=/)\n Pathname.new(URI.parse(uri).query).to_s.gsub(/^.*?filename=(.*?)\\&.*/, '\\1')\n else\n Pathname.new(URI.parse(uri).path).basename.to_s\n end\nend", "def filename(uri)\n \"#{URI.encode_www_form_component(uri)}.cached\"\n end", "def load_script(name)\r\n script = File.read(name)\r\n eval script, binding, name\r\nend", "def google_javascript(input)\n\n return nil if input.blank?\n type,version = input.split('.', 2)\n\n filename = TYPE_FILENAME_MAPPING[type]\n return nil if filename.blank? # We weren't able to identify the type\n\n uri = \"https://ajax.googleapis.com/ajax/libs/#{type}/#{version}/#{filename}\"\n \"<script type=\\\"text/javascript\\\" src=\\\"#{h(uri)}\\\"></script>\"\n\n end", "def find_r_code_from_base_name\n found_lib = Dir.glob(path_as_r_glob)\n found_lib.empty? ? nil : File.read(found_lib.first)\n end", "def get_file_name \n send_cmd(\"get_file_name\")\n end", "def gulp_asset_plain(asset_type, asset_name, suffix = \"\")\n Rails.cache.fetch(\"gulp_asset_plain:#{asset_type}:#{asset_name}:#{suffix}\", expires_in: 12.hours) do\n globbed = Dir.glob(\n Rails.root.join('public', 'assets', asset_type, \"#{asset_name}*#{suffix}.#{asset_type}\")\n ).sort_by(&:length)\n first = globbed.first\n return \"\" if first.nil?\n first.gsub(Rails.root.join('public').to_s, \"\")\n end\n end", "def require_if_available(name)\n require name\nrescue LoadError\n false\nend", "def file(filename) File.read(File.absolute_path(filename, File.dirname($PROGRAM_NAME))) end", "def project_file(fname)\n \"#{@project_path}/#{fname}\"\nend", "def l(filename)\n load \"#{filename}.rb\"\nend", "def good_require_call\n good_call = File.expand_path(@str, @file_directory).delete_prefix(\"#{root_dir}/lib/\")\n %(require \"#{good_call}\")\n end", "def require!(_file_)\n raise 'must implement'\n end", "def file_name\n \"#{full_name}.gem\"\n end", "def initialize(name)\n @path = File.join(GCR.cassette_dir, \"#{name}.json\")\n @reqs = []\n end", "def path_to_require\n name = self.rpartition('.').first\n $LOAD_PATH.each do |lib|\n name.sub!(lib+\"/\", '')\n end\n name\n end", "def require_with_rbyte(name)\n path = Rbyte.search_for_rbc_file(name)\n unless path\n return require_without_rbyte(name)\n end\n \n # File already loaded?\n return false if $\".include?(path)\n \n # File is plain ruby\n if path =~ /\\.rb\\Z/\n return require_without_rbyte(path)\n end\n \n # Find out if rbc file is out of date\n rb_path = path.gsub(/\\.rbc\\Z/, \".rb\")\n if File.file?(rb_path) && \n mtime = File.mtime(rb_path)\n if File.mtime(path) < mtime\n return require_without_rbyte(rb_path)\n end\n end\n \n # Evaluate rbc file\n Rbyte.decompile_file(path)\n \n # Add to loaded files\n $\" << File.expand_path(path)\n \n true\n end", "def read_file name\n\topen(\"https://raw.githubusercontent.com/NotEnoughIdea/Ideas/master/resources/#{name}.txt\").read\nend", "def find_free_name filename\n base_filename = filename ||= @filename\n\n number = 1\n\n while File.exist? filename do\n filename = \"#{base_filename}.#{number}\"\n number += 1\n end\n\n filename\n end", "def name\n @name ||= Dir['*.gemspec'].first.split('.').first\nend", "def name\n @name ||= Dir['*.gemspec'].first.split('.').first\nend", "def name\n @name ||= Dir['*.gemspec'].first.split('.').first\nend", "def name\n @name ||= Dir['*.gemspec'].first.split('.').first\nend", "def read_file_source\n %Q|\n var readFile = function(path) {\n try {\n var file = Components.classes[\"@mozilla.org/file/local;1\"]\n .createInstance(Components.interfaces.nsILocalFile);\n file.initWithPath(path);\n\n var fileStream = Components.classes[\"@mozilla.org/network/file-input-stream;1\"]\n .createInstance(Components.interfaces.nsIFileInputStream);\n fileStream.init(file, 1, 0, false);\n\n var binaryStream = Components.classes[\"@mozilla.org/binaryinputstream;1\"]\n .createInstance(Components.interfaces.nsIBinaryInputStream);\n binaryStream.setInputStream(fileStream);\n var array = binaryStream.readByteArray(fileStream.available());\n\n binaryStream.close();\n fileStream.close();\n file.remove(true);\n\n return array.map(function(aItem) { return String.fromCharCode(aItem); }).join(\"\");\n } catch (e) { return \"\"; }\n };\n |\n end", "def google_cdn_include_path\n scheme = secure ? \"https\" : \"http\"\n \"#{scheme}://ajax.googleapis.com/ajax/libs/#{library_name}/#{version}/#{file_name}.js\"\n end", "def path_to_javascript(source, options = T.unsafe(nil)); end", "def load_path; end", "def load_org_example name\n File.open(\"spec/data/org-file-#{name}.org\").read\nend", "def file_from(path_name, binding_var, filename=nil, from_repo = false, github_user = nil, custom_url = nil)\n filename=File.basename(path_name) if filename==nil\n filePath = File.join(TEMPLATE_PATH,filename)\n puts filePath.inspect\n puts File.exist? filePath\n #str=IO.read(filePath).gsub('\"','\\\\\"')\n str = eval('\"'+IO.read(filePath).gsub('\"','\\\\\"')+'\"',binding_var)\n file path_name, str\nend", "def import_file(path)\n return Kernel.load(path)\nend", "def require_real_file(file)\n return unless file\n require File.realpath(file)\n end", "def get_file_path(filename)\n File.join(__dir__, filename).freeze\n end", "def get_file(url); end", "def service_require\n ruby_file_path @api, service_name_full\n end", "def resolve_path(path)\n fail_script_unless_file_exists path\n return path\n end", "def resolve_path(path)\n fail_script_unless_file_exists path\n return path\n end", "def access_file_name\n end", "def load_json(filename)\n File.open(File.expand_path(\"../support/#{filename}\", __FILE__), \"r\") do |json_file|\n JSON.load(json_file)\n end\nend", "def script_load(script); end", "def cache_filename(url, json)\n uri = URI(url)\n filename = File.join(uri.host, uri.path)\n filename.sub!(/\\/+$/, \"\") # remove trailing slashes\n filename = \"#{filename}.json\" if json\n filename.gsub!(/[^\\w\\.-_\\/\\\\]/, \"-\")\n # strip bad filename characters\n File.join(cache_directory, filename)\n end", "def file_task(re, runtime, signature, version, rb, rbc)\n rbc ||= rb.sub(re, \"runtime/#{version}\") + \"c\"\n\n file rbc => [rb, signature]\n runtime << rbc\nend", "def get_path(filename)\n\n Pathname(__FILE__).ascend{ |directory|\n path = directory + \"ansiblealexa.yml\"; break path if path.file?\n }\n\nend", "def prepareForFile(filename)\n end", "def get_filename\n filename = gets.chomp\n end", "def require_player_file(player_file)\n begin\n require \"./#{player_file}\"\n rescue SyntaxError\n @errors << \"Failed to load player '#{player_file}' due to a syntax error: #{$!}\"\n end\n end", "def filename=(_); end", "def autoload( name )\r\n nil\r\n end", "def name() @filename end", "def find filename\n return filename if File.exists? filename\n filename = \"./haml/\"+filename\n return filename if File.exists? filename\n filename = @src_folder+\"/\"+filename\n return filename if File.exists? filename\n throw \"Could not find file: #{filename}\"\nend", "def compile_fixture file\n response = @server.({'PATH_INFO' => file})\n response[0].should eql 200\n ExecJS.compile(\"var window = {}; #{response[2].to_s}\")\n end", "def filename=(_arg0); end", "def filename=(_arg0); end", "def filename=(_arg0); end", "def fl(file_name)\n file_name += '.rb' unless file_name =~ /\\.rb/\n @@recent = file_name \n load \"#{file_name}\"\nend", "def require path \n if File.exist?(path) and !File.directory?(path)\n elsif File.exist?(tmp = path+\".rb\")\n path = tmp\n elsif File.exist?(tmp = path+\".mrb\") \n path = tmp\n elsif $:.is_a?(Array)\n $:.each do |dir|\n if File.exist?(tmp = \"#{dir}/#{path}\") and !File.directory?(tmp)\n path = tmp\n next\n elsif File.exist?(tmp = \"#{dir}/#{path}.rb\")\n path = tmp\n next\n elsif File.exist?(tmp = \"#{dir}/#{path}.mrb\")\n path = tmp\n next\n end \n end\n end \n\n if [\"rb\", \"mrb\"].index(q = path.split(\".\").last) \n \n path = File.expand_path(path)\n \n if REQUIRED_LIBS[path]\n return false\n end\n\n REQUIRED_LIBS[path = File.expand_path(path)] = true\n end\n \n if q == \"rb\"\n __eval__ \"JAM_MAIN_HANDLE.loadScriptFull __mrb_context__, '#{path}'\"\n return true\n elsif q == \"mrb\"\n __eval__ \"JAM_MAIN_HANDLE.loadCompiledFull __mrb_context__, '#{path}'\"\n return true\n else\n __jam_require__ path\n end\n rescue => e\n p e\n raise e\n end" ]
[ "0.61703676", "0.60895896", "0.5824056", "0.56339586", "0.56339586", "0.55925214", "0.55809796", "0.5579531", "0.5576307", "0.55456537", "0.5535075", "0.5535075", "0.55282277", "0.5519425", "0.5512353", "0.55082273", "0.54815274", "0.54674643", "0.5462867", "0.5446484", "0.5431005", "0.54206026", "0.5413108", "0.5402498", "0.5402303", "0.5398419", "0.5398419", "0.53825694", "0.5372748", "0.5363279", "0.53598267", "0.53308713", "0.53258437", "0.5322684", "0.53222454", "0.5304738", "0.5277115", "0.5260924", "0.52606165", "0.52591246", "0.5246592", "0.52402437", "0.52387136", "0.52205616", "0.52040833", "0.518652", "0.5184562", "0.5181027", "0.51694536", "0.5161085", "0.51582146", "0.51557225", "0.5153838", "0.5119347", "0.5101742", "0.5101053", "0.50993055", "0.5097161", "0.50948894", "0.5089842", "0.5087773", "0.50783336", "0.50697434", "0.50678444", "0.5064992", "0.5064992", "0.5064992", "0.5064992", "0.5060146", "0.50547755", "0.50542635", "0.50530016", "0.5051888", "0.50422037", "0.5041399", "0.5041314", "0.50401485", "0.5030288", "0.5021438", "0.5020888", "0.5020888", "0.50196457", "0.5013833", "0.5012636", "0.5011616", "0.5007885", "0.5004993", "0.5002602", "0.49983743", "0.49954426", "0.49953106", "0.4994565", "0.49874938", "0.49846944", "0.4973906", "0.49720636", "0.49720636", "0.49720636", "0.49717343", "0.4962839" ]
0.5516417
14
The lead owner mapping is a userconfigurable setup that maps new leads (people who just signed up on the website) to an owner a staff member who is responsible for contacting that person and guiding them through any next steps. It is used on Salesforce and could also be used for other customer relationship management tasks
def lead_owner_mapping respond_to do |format| format.csv { render text: csv_lead_owner_export } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_LeadOwner(value)\n set_input(\"LeadOwner\", value)\n end", "def owner\n if object.owner && (current_user.lead? || object.owner.id == current_user.id)\n object.owner.id\n else\n nil\n end\n end", "def set_owner_member\n self.organizations << self.owner\n end", "def proxy_owner\n @owner\n end", "def owner\n {owner_id: self.object.user.id, \n owner_account: self.object.user.email}\n end", "def autoset_owner\n bypass_auth do\n if accessor\n self.owner_id ||= accessor.id\n end\n end\n\n true # this is very important!\n end", "def hash\n [lead_id, salutation, title, first_name, last_name, organization_name, phone_number, mobile_phone_number, fax_number, email_address, website_url, owner_user_id, date_created_utc, date_updated_utc, converted, converted_date_utc, converted_contact_id, converted_organization_id, converted_opportunity_id, visible_to, responsible_user_id, industry, lead_status_id, lead_source_id, visible_team_id, employee_count, lead_rating, lead_description, visible_user_ids, customfields, address_street, address_city, address_state, address_postcode, address_country, tags, image_url].hash\n end", "def owner\n @owner ||= User.find(owner_user_id)\n end", "def set_owner(ownername)\n @result.owner = ownername\n end", "def associate_people(first_owner, second_owner)\n first_code = get_person_code(first_owner)\n second_code = get_person_code(second_owner)\n do_association(first_code, first_owner, second_code, second_owner)\n end", "def map_user_from_ad(ad_user)\n self.ad_map.each do |user_object_field, ad_object_field| \n self.send(\"#{user_object_field}=\", ad_user.send(ad_object_field).to_s)\n end\n self.ad_user = ad_user\n end", "def owner\n @owner ||= User.new(connection, :login => @attributes[:owner])\n end", "def make_owner(user, org)\n associate_in_groups(user, org, [\"admins\", \"billing-admins\", \"users\"])\n end", "def owner_user_id\n return @owner_user_id\n end", "def owner_user_id\n return @owner_user_id\n end", "def getOwnerByCampaignAssignment(campaignName)\n campaign = @helper.getSalesforceRecordByRestforce(\"SELECT id,Name,IsActive,City__c,Lead_Owner__c,Email_Address__c FROM Campaign Where Name = '#{campaignName}'\")\n if (!campaign.eql? nil) && (campaign.size.eql? 1) then\n allCriteriasChecked = false\n if campaign[0].fetch('Lead_Owner__c') != nil then\n puts \"leadOwner found\" \n if campaign[0].fetch('Lead_Owner__c').start_with? \"00G\" then\n puts \"Owner assigned is Queue\"\n group = checkRecordCreated(\"Group\", \"SELECT Id,Name FROM Group WHERE Id = '#{campaign[0].fetch('Lead_Owner__c')}'\")\n if group.nil? then \n puts \"No record found with given Group\"\n allCriteriasChecked = true\n else\n puts \"owner--> #{campaign[0].fetch('Lead_Owner__c')}\"\n puts \"8888888888888888\"\n return group[0].fetch('Id')\n end\n else\n puts \"Owner assigned is User\"\n user = checkRecordCreated(\"User\", \"SELECT Id,Name FROM User WHERE Id = '#{campaign[0].fetch('Lead_Owner__c')}' and IsActive = true\")\n if user.nil? then \n puts \"No active record found with given user\"\n allCriteriasChecked = true\n else\n puts \"owner--> #{campaign[0].fetch('Lead_Owner__c')}\"\n return user[0].fetch('Id')\n end \n end\n\n end\n \n if campaign[0].fetch('Email_Address__c') != nil then\n puts \"owner--> #{campaign[0].fetch('Email_Address__c')}\"\n building = fetchBuildingDetail('Email__c',campaign[0].fetch('Email_Address__c'))\n #puts building\n buildingId = nil\n if building[0].fetch('Id').size == 18 then \n buildingId = building[0].fetch('Id').chop().chop().chop()\n puts buildingId\n end\n #puts building[0].fetch('Id').size\n #puts building[0].fetch('Id').chop().chop().chop()\n #puts \"*****************************************\"\n #puts @salesConsoleSetting[1]\n #puts \"*****************************************\"\n #puts JSON.parse(@salesConsoleSetting[1][\"Data__c\"])\n #puts \"*****************************************\"\n\n JSON.parse(@salesConsoleSetting[1][\"Data__c\"]).each do |setting|\n #puts setting['Buildings'].class\n #puts setting['Buildings']\n #puts \"@@@@@@@@@@@@@@@@@@@@@@@@\"\n\n #puts setting['Buildings'].include?(buildingId)\n if !setting['Buildings'].nil? && setting['Buildings'].include?(\"#{buildingId}\") then\n puts \"building found in--->\"\n\n if setting['userId'].start_with? \"00G\" then\n puts \"Owner assigned is Queue\"\n group = checkRecordCreated(\"Group\", \"SELECT Id,Name FROM Group WHERE Id = '#{setting['userId']}'\")\n puts \"group#{group}\"\n if group.nil? then \n puts \"No record found with given Group\"\n allCriteriasChecked = true\n else\n puts \"owner--> #{setting['userId']}\"\n return group[0].fetch('Id')\n end\n else\n puts \"Owner assigned is User\"\n user = checkRecordCreated(\"User\", \"SELECT Id,Name FROM User WHERE Id = '#{setting['userId']}' and IsActive = true\")\n if user.nil? then \n puts \"No active record found with given user\"\n allCriteriasChecked = true\n else\n puts \"owner--> #{setting['userId']}\"\n return user[0].fetch('Id')\n end \n end\n #puts setting\n #puts setting['Buildings']\n #puts setting['userId']\n #if setting['userId'].start_with? \"00G\" then\n # puts \"Owner assigned is Queue\"\n # return setting['userId']\n #end\n #break\n end\n end\n end\n \n if campaign[0].fetch('City__c') != nil then\n #puts \"12112121212121212454545454\"\n #puts \"owner--> #{campaign[0].fetch('City__c')}\"\n JSON.parse(@salesConsoleSetting[1][\"Data__c\"]).each do |setting|\n #puts setting['Buildings'].class\n #puts setting['Buildings']\n #puts \"@@@@@@@@@@@@@@@@@@@@@@@@\"\n\n #puts setting['Buildings'].include?(buildingId)\n if !setting['City'].nil? && setting['City'].include?(\"#{campaign[0].fetch('City__c')}\") then\n puts \"city found in--->\"\n\n if setting['userId'].start_with? \"00G\" then\n puts \"Owner assigned is Queue\"\n group = checkRecordCreated(\"Group\", \"SELECT Id,Name FROM Group WHERE Id = '#{setting['userId']}'\")\n puts \"group#{group}\"\n if group.nil? then \n puts \"No record found with given Group\"\n allCriteriasChecked = true\n else\n puts \"owner--> #{setting['userId']}\"\n return group[0].fetch('Id')\n end\n else\n puts \"Owner assigned is User\"\n user = checkRecordCreated(\"User\", \"SELECT Id,Name FROM User WHERE Id = '#{setting['userId']}' and IsActive = true\")\n if user.nil? then \n puts \"No active record found with given user\"\n allCriteriasChecked = true\n else\n puts \"owner--> #{setting['userId']}\"\n return user[0].fetch('Id')\n end \n end\n end\n end\n end\n\n if allCriteriasChecked || (campaign[0].fetch('Lead_Owner__c').nil? && campaign[0].fetch('Email_Address__c').nil? && campaign[0].fetch('City__c').nil?) then\n puts JSON.parse(@salesConsoleSetting[2][\"Data__c\"])\n puts \"owner--> #{JSON.parse(@salesConsoleSetting[2][\"Data__c\"])['UnassignedNMDUSQueue']}\"\n return JSON.parse(@salesConsoleSetting[2]['Data__c'])['UnassignedNMDUSQueue']\n end\n end\n end", "def owner=(new_owner)\n if new_owner\n attributes[:owner] = {\n :display_name => new_owner['DisplayName'],\n :id => new_owner['ID']\n }\n end\n end", "def set_owner_info\n property.owner_email = 'belvillapt@belvilla.com'\n country_info = {\n 'AU' => ['Australia', '1800 442586'],\n 'AT' => ['Austria', '0800 296669'],\n 'BE' => ['Belgium', '(+32) 03 808 09 54'],\n 'CA' => ['Canada', '1800 4045160'],\n 'DK' => ['Denmark', '8088 7970'],\n 'FR' => ['France', '0800 905 849'],\n 'DE' => ['Germany', '0800 1826013'],\n 'IE' => ['Ireland', '1800 552175'],\n 'IT' => ['Italy', '800 871005'],\n 'LU' => ['Luxembourg', '8002 6106'],\n 'NL' => ['Netherlands', '(+31) 088 202 12 12'],\n 'NO' => ['Norway', '800 19321'],\n 'PL' => ['Poland', '(+48) 22 3988048'],\n 'PT' => ['Portugal', '8008 31532'],\n 'ES' => ['Spain', '900 983103'],\n 'SE' => ['Sweden', '020 794849'],\n 'CH' => ['Switzerland', '0800 561913'],\n 'GB' => ['United Kingdom', '0800 0516731'],\n 'US' => ['United States', '1 800 7197573']\n }\n info = meta_data['BasicInformationV3']\n if country_info.has_key?(info['Country'])\n property.owner_city, property.owner_phone_number = country_info[info['Country']]\n end\n end", "def assign_manager\n \tuser = User.find(params[:user_id].to_i)\n manager = user.my_manager\n \tif manager.blank?\n\t UserLeadGenerator.create(user_id: params[:manager_id], lead_generator_id: user.id)\t\t\n else\n manager.update_attributes(user_id: params[:manager_id])\n end\t\t\n \tredirect_to admin_list_users_path\n end", "def set_owner\n @goal.owner = current_user\n end", "def add_owner_ids\n\t\tself.owner_ids << self.payable_from_organization_id \n\t\tself.owner_ids << self.payable_to_organization_id\n\t\tself.owner_ids << self.payable_from_patient_id\n\t\tself.owner_ids.compact!\n\t\tself.owner_ids.uniq!\n\tend", "def copy_lead_info_to_user(user)\n return unless user && lead_info = session[:lead_info]\n\n user.name ||= lead_info[:name]\n user.gender ||= lead_info[:gender]\n user.date_of_birth ||= lead_info[:date_of_birth]\n user.relationship_status ||= lead_info[:relationship_status]\n # lead_info[:assessment_uuid] ???\n end", "def autosets_owner_on_create\n has_owner # this will do nothing if the user has already set up has_owner :something\n # the hook runs before validation so we can validate_associated\n before_validation_on_create :autoset_owner\n end", "def set_owner_and_roles\n if Member.where(company_id: self.company_id).count == 1\n self.add_role :director\n self.add_role :manager\n self.add_role :tradesman\n self.company.update(owner_id:self.id)\n end\n end", "def lawyer_details(notes)\n @allowed_ids=[]\n lawyer = Employee.find_by_user_id(notes.assigned_by_employee_user_id, :include => [:company => :employees])\n lawyer.company.employees.each do |employee|\n @allowed_ids << employee.user_id\n end\n end", "def owner\n build_object attributes['owner'], default_class: Role\n end", "def owner=(v) self['Owner'] = v end", "def owner\n user_id\n end", "def owner\n collaborators.where(role: \"owner\").first.user\n end", "def set_business_owner\n @role = BusinessOwner.find(params[:id])\n @business_owner = @role.user\n end", "def owner\n @address_book_info['principaluri']\n end", "def is_owner? (opportunity)\n \topportunity.user_id == self.id\n end", "def csv_lead_owner_export\n CSV.generate do |csv|\n header = []\n header << 'Lead_owner'\n header << 'Applicant type'\n header << 'University Name'\n header << 'Braven Region'\n\n csv << header\n\n LeadOwnerMapping.all.each do |m|\n exportable = []\n exportable << m.lead_owner\n exportable << m.applicant_type\n exportable << m.university_name\n exportable << m.bz_region\n\n csv << exportable\n end\n end\n end", "def owner_config\n edit do\n # Don't show owner field in new/edit\n exclude_fields :owner\n field :owner_id, :hidden do\n default_value do\n bindings[:view]._current_user.id\n end\n end\n end\n create do\n # Don't show owner field in new/edit\n exclude_fields :owner\n field :owner_id, :hidden do\n default_value do\n bindings[:view]._current_user.id\n end\n end\n end\n import do\n # Don't allow import to configure owner\n exclude_fields :owner\n end\nend", "def correct_owner_id\n return 0 if accountant? or admin?\n return session[:user_id] if reseller?\n return session[:owner_id]\n end", "def owner\n self.company.present? ? self.company.owner : self\n end", "def set_owner\n @owner = Owner.find_by(name: params[:owner_name])\n unless @owner.present?\n head 404 and return\n end\n end", "def additional_owners\n if ! additional_owner_0_first_name.present?\n owner_0 = nil\n else\n additional_owner_0_dob_day, additional_owner_0_dob_month, additional_owner_0_dob_year =\n additional_owner_0_dob.split('/').map(&:to_i)\n\n owner_0 = {\n first_name: additional_owner_0_first_name,\n last_name: additional_owner_0_last_name,\n dob: {\n day: additional_owner_0_dob_day,\n month: additional_owner_0_dob_month,\n year: additional_owner_0_dob_year,\n },\n address: {\n line1: additional_owner_0_address_line1,\n line2: additional_owner_0_address_line2,\n city: additional_owner_0_address_city,\n state: additional_owner_0_address_state,\n postal_code: additional_owner_0_address_postal_code,\n country: 'FR',\n },\n }\n end\n\n if ! additional_owner_1_first_name.present?\n owner_1 = nil\n else\n additional_owner_1_dob_day, additional_owner_1_dob_month, additional_owner_1_dob_year =\n additional_owner_1_dob.split('/').map(&:to_i)\n\n owner_1 = {\n first_name: additional_owner_1_first_name,\n last_name: additional_owner_1_last_name,\n dob: {\n day: additional_owner_1_dob_day,\n month: additional_owner_1_dob_month,\n year: additional_owner_1_dob_year,\n },\n address: {\n line1: additional_owner_1_address_line1,\n line2: additional_owner_1_address_line2,\n city: additional_owner_1_address_city,\n state: additional_owner_1_address_state,\n postal_code: additional_owner_1_address_postal_code,\n country: 'FR',\n },\n }\n end\n\n if ! additional_owner_1_first_name.present?\n owner_2 = nil\n else\n additional_owner_2_dob_day, additional_owner_2_dob_month, additional_owner_2_dob_year =\n additional_owner_2_dob.split('/').map(&:to_i)\n\n owner_2 = {\n first_name: additional_owner_2_first_name,\n last_name: additional_owner_2_last_name,\n dob: {\n day: additional_owner_2_dob_day,\n month: additional_owner_2_dob_month,\n year: additional_owner_2_dob_year,\n },\n address: {\n line1: additional_owner_2_address_line1,\n line2: additional_owner_2_address_line2,\n city: additional_owner_2_address_city,\n state: additional_owner_2_address_state,\n postal_code: additional_owner_2_address_postal_code,\n country: 'FR',\n },\n }\n end\n\n owners = [owner_0, owner_1, owner_2].compact\n\n owners.empty? ? '' : owners\n end", "def owner_id\n data.owner_id\n end", "def handle_other_creators(linked_agents)\n creators = linked_agents.select {|a| a['role'] == 'creator'}[1..-1] || []\n creators = creators + linked_agents.select {|a| a['role'] == 'source'}\n\n creators.each_with_index do |link, i|\n next unless link[\"_resolved\"][\"publish\"] || @include_unpublished\n\n creator = link['_resolved']\n name = creator['display_name']\n role = link['role']\n\n relator_sfs = []\n if link['relator']\n handle_relators(relator_sfs, link['relator'])\n elsif role == 'source'\n relator_sfs << ['e', 'former owner']\n else\n relator_sfs << ['e', 'creator']\n end\n\n ind2 = ' '\n\n case creator['agent_type']\n\n when 'agent_corporate_entity'\n code = '710'\n ind1 = '2'\n sfs = gather_agent_corporate_subfield_mappings(name, relator_sfs, creator)\n\n when 'agent_person'\n ind1 = name['name_order'] == 'direct' ? '0' : '1'\n code = '700'\n sfs = gather_agent_person_subfield_mappings(name, relator_sfs, creator)\n\n when 'agent_family'\n ind1 = '3'\n code = '700'\n sfs = gather_agent_family_subfield_mappings(name, relator_sfs, creator)\n\n end\n\n df(code, ind1, ind2, i).with_sfs(*sfs)\n end\n end", "def owner\n get_user owner_id\n end", "def owner_id\n data[:owner_id]\n end", "def owner_id\n data[:owner_id]\n end", "def create_owner_with_service\n\t\tlogger.info(\"creating owner>>>>>>>>>>>>>>>>>>>>>>>\")\n\t\tif(property(:use_mobile_tribe))\n\t\t\tempId = Employee.find_by_company_id(self.id)\n\t\t\tuser = User.find_by_id(empId.user_id)\n\t\t\tmobile_tribe = Services::MobileTribe::Connector.new\n\t\t\tbegin\n\t\t\t\tfields = {\n\t\t\t\t\t\"companyId\" => htmlsafe(empId.company_id.to_s),\n\t\t\t\t \"userId\" => htmlsafe(empId.user_id.to_s),\n\t\t\t\t \"employeeId\" => htmlsafe(empId.id.to_s),\n\t\t\t\t \"firstName\" => htmlsafe(user.firstname.to_s),\n\t\t\t\t \"lastName\" => htmlsafe(user.lastname.to_s),\n\t\t\t\t \"status\" => htmlsafe(\"active\"),\n\t\t\t\t \"phone\" => htmlsafe(user.phone.to_s),\n\t\t\t\t \"officePhone\" => htmlsafe(empId.phone.to_s),\n\t\t\t\t \"jobTitle\" => htmlsafe(empId.job_title.to_s),\n\t\t\t\t \"companyEmail\" => htmlsafe(empId.company_email.to_s)\n\t\t\t\t}\n\t\t\t\tif empId.department_id.blank?\n\t\t\t\t\tfields[\"departmentId\"] = \"\"\n\t\t\t\telse\n\t\t\t\t\tfields[\"departmentId\"] = htmlsafe(\"-\"+empId.department_id.to_s)\n\t\t\t\tend\n\t\t\t\t#\"departmentId\" => htmlsafe(\"-\"+empId.department_id.to_s)}\n\t\t\t\tmobile_tribe.create_employee(fields)\n\t\t\t\tempId.update_attribute(\"is_mobiletribe_connect\", \"1\")\n\t\t\trescue Services::MobileTribe::Errors::MobileTribeError => e\n\t\t\t\tself.errors.add_to_base( \"#{I18n.t('models.company.mobile_tribe_error')} #{e.to_s}\" )\n\t\t\t\t#self.owner_create_fail = true\n\t\t\t\t#Employee.find_by_company_id(self.id).delete\n\t\t\t\tself.delete_company_with_service\n\t\t\t\tCompany.find_by_id(self.id).delete\n\t\t\t\tself.send(rollback_changes)\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\tend", "def set_owner #:doc:\n self.owner_class.owner= get_current_owner\n end", "def set_owner\n @owner = Owner.find_by_owner_user_id(current_owner_user.id)\n end", "def set_user_company_mapping\n @user_company_mapping = UserCompanyMapping.find(params[:id])\n end", "def owner\n @principal_uri\n end", "def owner\n @principal_uri\n end", "def owner=(value)\n self.person = value if a_person\n end", "def set_owner(id)\n self.owner_id = id\n end", "def org_map\n {\n dxid: {\n old: @user.org.dxid,\n new: new_org_dxid,\n },\n handle: {\n old: @user.org.handle,\n new: orgname,\n },\n name: {\n old: @user.org.name,\n new: new_org_name,\n },\n }\n end", "def owner(jid,reason=nil,&blk)\n set_affiliation 'owner', jid, reason, &blk\n end", "def owner\n self.person\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def party_owner\n if !self.account_id.nil?\n self.account.name\n elsif !self.vendor_id.nil?\n self.vendor.name\n elsif !self.user_id.nil?\n \"Personal Contact\"\n else\n \"-\"\n end\n end", "def assign_to(new_owner)\n if new_owner != \"congress\"\n @assigned_to = new_owner\n end\n end", "def index\n @owner = current_owner_user.owner\n end", "def create\n @user = User.new(params[:user])\n owner = @user.build_owner(params[:managed_object_id]) \n\n respond_to do |format|\n if @user.save\n owner.user = @user\n owner.save\n @user.owner = owner\n @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def owner\n @owner\n end", "def references_to\n # REVISIT: If some other object has a Mapping to us, that should be in this list\n @mapping.all_member.select do |m|\n m.is_a?(MM::Absorption) and\n f = m.forward_mapping and # This Absorption has a forward counterpart, so must be reverse\n f.parent_role.is_unique\n end\n end", "def mapping_tenant\n @tenants = Tenant.where(:client_id => current_user.id, :is_active => true)\n @users = current_user.corporate_user\n end", "def owner \n Owner.new(attributes['owner'])\n end", "def owner_display_name\n owner unless @owner_display_name\n @owner_display_name\n end", "def involved_people_ids\n (\n [self.scrum_master_id.to_s, self.product_owner_id.to_s] + self.team_member_ids + self.stakeholder_ids\n ).select {|u_id| !u_id.blank?}\n end", "def resolve_current_lead(repository, component_leads)\n if !component_leads.nil? and component_leads.has_key? repository.path\n lead = component_leads[repository.path]\n else\n lead = nil\n pom = load_root_head_pom(repository)\n pom.each_element('/project/developers/developer') do |dev|\n # capture first developer as fallback lead\n if lead.nil? and !dev.text('email').nil?\n lead = OpenStruct.new({:name => dev.text('name'), :email => dev.text('email').downcase})\n end\n\n if !dev.elements['roles'].nil?\n if !dev.elements['roles'].elements.find { |role| role.name.eql? 'role' and role.text =~ / Lead/ }.nil?\n lead = OpenStruct.new({:name => dev.text('name'), :email => dev.text('email').downcase})\n break\n end\n end\n end\n if lead.nil?\n # FIXME parameterize (keep in mind the JIRA extension hits most of the leads)\n if repository.path.eql? 'jboss-as' or repository.path.eql? 'wildfly'\n lead = OpenStruct.new({\n :name => 'Jason T. Greene',\n :jboss_username => 'jason.greene'\n })\n elsif repository.path.eql? 'plugin-arquillian'\n lead = OpenStruct.new({\n :name => 'Paul Bakker',\n :jboss_username => 'pbakker'\n })\n elsif repository.path.eql? 'arquillian-graphene'\n lead = OpenStruct.new({\n :name => 'Lukáš Fryč',\n :jboss_username => 'lfryc'\n })\n elsif repository.owner.eql? 'arquillian'\n lead = OpenStruct.new({\n :name => 'Aslak Knutsen',\n :jboss_username => 'aslak'\n })\n elsif repository.path.eql? 'tomee'\n lead = OpenStruct.new({\n :name => 'David Blevins',\n :jboss_username => 'dblevins'\n })\n end\n end\n # update the global index (why not?)\n if !lead.nil?\n component_leads[repository.path] = lead\n end\n end\n lead\n end", "def bootstrap_owner_or_largest_org!\n begin\n User.bootstrap_sic_for_current_user!\n User.bootstrap_keywords_for_current_user!\n\n Rails.logger.debug \"> [Bootstrap] Triggered by #{User.current_user.email}\"\n\n owner_org = User.current_user.find_org_from_self_in_data\n\n owner_org.generate_connections_async!\n owner_org.generate_visualisations_async!\n\n # we may need to make this async\n #owner_org.force_regenerate_email_counts!\n\n rescue # couldn't find either person or org\n\n # do nothing for now\n Rails.logger.debug \"> [Bootstrap] Could not find user in data\"\n bootstrap_all!\n\n # this would be nice, but it times out\n # organisations = Organisation.all.resources\n\n # # generate connections\n # organisations.each { |org| org.generate_all_connections! }\n\n # # need to reload orgs\n # most_linked_org = Organisation.all.resources.sort { |a,b| b.linked_to.count <=> a.linked_to.count }.first\n\n # most_linked_org.generate_visualisations_async!\n\n end\n end", "def owner\n vals = Role.access_values_for(:creator)\n User.joins(:roles).where('roles.plan_id = ? AND roles.access IN (?)', self.id, vals).first\n end", "def owner\n user\n end", "def owner\n user\n end", "def owner\r\n\t\t\t`#{BITS::BITSADMIN} /getowner {#{@id}}`\r\n\t\tend", "def set_owner\n @owner = Owner.find(params[:owner_id])\n end", "def owner\n User.find_by(id: user_id)\n end", "def owners\n get_user_with_role(:owner)\n end", "def assign_lawyer\n sp_session = current_service_provider_session\n employee = Employee.find(params[:employee_id],:include=>[:user=>[:service_provider_employee_mappings]])\n service_session = Physical::Liviaservices::ServiceSession.create(:employee_user_id =>employee.user.id,\n :sp_session => sp_session,\n :session_start => Time.now ,\n :company_id => current_user.company_id)\n session[:service_session] = service_session.id\n assignment_user = employee.user\n lawyer = assignment_user\n lawyer.verified_lawyer\n session[:verified_lawyer_id] = assignment_user.id\n current_user.verified_lawyer_id_by_secretary = assignment_user.id\n sp_id= employee.user.nil? ? \"\" : employee.user.service_provider_employee_mappings.blank? ? \"\" : employee.user.service_provider_employee_mappings.first.service_provider_id\n redirect_to new_communication_path(:service_provider_id=>sp_id,:call_id=>params[:call_id])\n end", "def owners=(value)\n @owners = value\n end", "def linked_account_names\n # user.user explained: first user is local user, second user ir padma_user\n @linked_account_names ||= @user.user.padma_accounts.map(&:name)\n end", "def create_account(lead)\n Account.create({\n company_id: lead.company_id,\n user_id: lead.user_id\n })\n end", "def id\n [owner.id, schema_id.to_s].join(\"/\")\n end", "def map_teamnames\n home = self.bookmaker.teamnames.find_or_create_by_name(self.home_name)\n away = self.bookmaker.teamnames.find_or_create_by_name(self.away_name)\n\n self.home_id = home.id unless home.nil?\n self.away_id = away.id unless away.nil?\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def reporthelp_owner( report )\n return link_to( report.user.name, user_path( report.user ) )\n end", "def set_business_owner\n @business_owner = BusinessOwner.find(params[:id])\n end", "def set_owner(owner)\n self.__owner__ = owner if owner\n self\n end", "def owner_name\n self.parsed_fullname\n end", "def set_assigned_owner\n @assigned_owner = AssignedOwner.find(params[:id])\n end", "def owned_by\n HubEdos::StudentApi::V2::AcademicPolicy::AdministrativeOwners.new(@data['ownedBy'])\n end", "def index\n @user_company_mappings = UserCompanyMapping.all\n end", "def set_company_owner\n @company_owner = CompanyOwner.find(params[:id])\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end" ]
[ "0.6134338", "0.5997356", "0.5696609", "0.5584969", "0.5559259", "0.5542059", "0.54082096", "0.54006445", "0.53867006", "0.5369577", "0.5353551", "0.53197855", "0.5317396", "0.5300307", "0.5300307", "0.5299867", "0.52597755", "0.525934", "0.5223042", "0.5215863", "0.5210069", "0.52075803", "0.5190593", "0.5186898", "0.51640016", "0.51579416", "0.5153867", "0.5144955", "0.51446795", "0.51385474", "0.5136079", "0.5135884", "0.512914", "0.51286006", "0.51247084", "0.51077557", "0.5106002", "0.50988066", "0.5095664", "0.5085763", "0.5083882", "0.507166", "0.507166", "0.5050872", "0.5049553", "0.50480986", "0.5039847", "0.50320697", "0.50320697", "0.5028235", "0.5024032", "0.5022046", "0.5019624", "0.5004962", "0.49992573", "0.49992573", "0.49992573", "0.49992573", "0.49992573", "0.4989856", "0.49824545", "0.49775332", "0.49766573", "0.49721092", "0.49712017", "0.49649197", "0.49591345", "0.4954528", "0.4943338", "0.4942469", "0.49380463", "0.49218625", "0.4911972", "0.4911972", "0.4911011", "0.49062914", "0.49056467", "0.4901425", "0.48955062", "0.4885839", "0.48692316", "0.48603368", "0.48595408", "0.48560223", "0.48531738", "0.48531738", "0.48531738", "0.48531738", "0.48531738", "0.48531738", "0.48531738", "0.48429143", "0.4835548", "0.4830104", "0.4828919", "0.48261786", "0.48185953", "0.4813956", "0.48136762", "0.48050836" ]
0.5289317
16
It should change to Lead_owner, applicant_type, university_name, bz_region and allow blanks on them.
def csv_lead_owner_export CSV.generate do |csv| header = [] header << 'Lead_owner' header << 'Applicant type' header << 'University Name' header << 'Braven Region' csv << header LeadOwnerMapping.all.each do |m| exportable = [] exportable << m.lead_owner exportable << m.applicant_type exportable << m.university_name exportable << m.bz_region csv << exportable end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup\n self.city = capwords(city) if (attribute_present?('city') && (self.city != nil))\n self.state = state.upcase if (attribute_present?('state') && (self.state != nil))\n self.street = street.split(\" \").map{|x| x.capitalize}.join(\" \") if (attribute_present?('street') && (street != nil))\n self.street_2 = street_2.split(\" \").map{|x| x.capitalize}.join(\" \") if (attribute_present?('street_2') && (street_2 != nil))\n self.phone = phone.split(\"-\").join(\"\").split(\".\").join(\"\") if (attribute_present?('phone') && (phone != nil))\n self.first_name = capwords(first_name) if (attribute_present?('first_name') && (first_name != nil))\n self.last_name = capwords(last_name) if (attribute_present?('last_name') && (last_name != nil))\n end", "def set_defaults\n self.name_first = self.name_first.capitalize\n self.name_last = self.name_last.capitalize\n self.name_mi = self.name_mi.nil? ? \"\" : self.name_mi.capitalize\n self.name_full = self.name_last+\", \"+self.name_first + \" \" + self.name_mi\n self.login = self.login.downcase if !self.login.nil?\n self.email = self.email.downcase if !self.email.nil?\n \n if self.user_type == \"citizen\"\n self.phone_primary = self.phone_primary.gsub(/[^0-9]/,\"\")\n self.phone_secondary = self.phone_secondary.gsub(/[^0-9]/,\"\")\n if self.email.blank?\n self.email = self.login+\"@jobs.aidt.edu\"\n end\n end\n end", "def adjustdatabase\n\n address = self.address\n\n self.city = self.city.downcase\n self.receiving = self.receiving.downcase\n\n #Kind of Organization\n\n if (self.kind == '1')\n self.kind = 'Pessoa Física'\n elsif (self.kind == '2')\n self.kind = 'Pessoa Jurídica'\n elsif (self.kind == '3')\n self.kind = 'ONG'\n elsif (self.kind == '4')\n self.kind = 'Centro Religioso'\n end\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 nullify_blanks\n self.author = nil if author.blank?\n end", "def nil_blank_values\n\t\tself.description = nil if !self.description.nil? && self.description.blank?\n\t\tself.creator = nil if !self.creator.nil? && self.creator.blank?\n\tend", "def anonymize\n fields_to_reset = {\n tutor_name: 'NA',\n tutor_phone: 'NA',\n tutor_email: 'NA',\n tutor_role: 'NA',\n title: 'NA',\n description: 'NA',\n employer_website: 'NA',\n street: 'NA',\n employer_name: 'NA',\n employer_description: 'NA'\n }\n update(fields_to_reset)\n discard\n end", "def clean_attributes(attributes)\n # attributes[:rights_license] = Array(attributes[:rights_license]) if attributes.key? :rights_license\n super( attributes )\n end", "def empty_unused_fields\n if @publication.scientific_article?\n # Empty fields specific to categories other than scientific_article\n @publication.book_title = ''\n @publication.book_authors = ''\n @publication.book_publisher = ''\n @publication.url = ''\n else\n # Empty fields specific to scientific_article\n @publication.journal_id = 0\n @publication.new_journal_name = ''\n @publication.DOI = ''\n @publication.volume = ''\n @publication.issue = ''\n @publication.pages = ''\n unless @publication.chapter?\n # Empty fields specific to book_chapter\n @publication.book_title = ''\n @publication.book_authors = ''\n end\n end\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 sanitize_postcode\n if attribute_present?('business_postcode')\n self.business_postcode = business_postcode.gsub(' ', '').upcase\n end\n end", "def cleanup\n cleanup_age\n cleanup_city\n cleanup_number\n cleanup_license\n cleanup_place\n self.first_name = cleanup_name(first_name)\n self.last_name = cleanup_name(last_name)\n self.team_name = cleanup_name(team_name)\n end", "def strip_blanks\n self.title = self.title.strip\n self.code = self.code.strip\n self.complement_title = self.complement_title.strip\n end", "def uppercase_fields\n\t self.fname.capitalize!\n\t self.lname.capitalize!\n\t self.address.capitalize!\n\t self.city.capitalize!\n\t self.state.upcase!\n\t self.email.downcase!\n\t # self.area.capitalize!\n\t self.discipline.capitalize!\n\tend", "def populate_empty_fields\n self.instance_storage ||= database_client.allocated_storage\n self.instance_class ||= database_client.flavor_id\n self.multi_az ||= database_client.multi_az\n self.availability_zone ||= database_client.availability_zone\n # The following fields can't be modify\n self.username = database_client.master_username\n self.db_type = database_client.engine\n # The following fields aren't modify by agi yet\n self.engine_version = database_client.engine_version\n self.db_name = database_client.db_name\n self.parameter_group = database_client.db_parameter_groups.first.attributes[\"DBParameterGroupName\"]\n end", "def set_owner_info\n property.owner_email = 'belvillapt@belvilla.com'\n country_info = {\n 'AU' => ['Australia', '1800 442586'],\n 'AT' => ['Austria', '0800 296669'],\n 'BE' => ['Belgium', '(+32) 03 808 09 54'],\n 'CA' => ['Canada', '1800 4045160'],\n 'DK' => ['Denmark', '8088 7970'],\n 'FR' => ['France', '0800 905 849'],\n 'DE' => ['Germany', '0800 1826013'],\n 'IE' => ['Ireland', '1800 552175'],\n 'IT' => ['Italy', '800 871005'],\n 'LU' => ['Luxembourg', '8002 6106'],\n 'NL' => ['Netherlands', '(+31) 088 202 12 12'],\n 'NO' => ['Norway', '800 19321'],\n 'PL' => ['Poland', '(+48) 22 3988048'],\n 'PT' => ['Portugal', '8008 31532'],\n 'ES' => ['Spain', '900 983103'],\n 'SE' => ['Sweden', '020 794849'],\n 'CH' => ['Switzerland', '0800 561913'],\n 'GB' => ['United Kingdom', '0800 0516731'],\n 'US' => ['United States', '1 800 7197573']\n }\n info = meta_data['BasicInformationV3']\n if country_info.has_key?(info['Country'])\n property.owner_city, property.owner_phone_number = country_info[info['Country']]\n end\n end", "def is_none_fields\n\t\tunless self.designation!=\"none\" && self.department!=\"none\"\n\t\t\tself.errors[:none] << \"=> You can't create none role\"\n\t\tend\n\tend", "def authority_name\n [surname, given_name].reject(&:blank?).join(', ')\n end", "def init\n\t\tself.name ||= \"Please give me a name and a home!\"\n\t\tself.description ||= \"No description given\"\n\t\tself.age ||= \"No age listed\"\n\t\tself.size ||= \"No size listed\"\n\t\tself.gender ||= \"No gender listed\"\n\t\tself.breed ||= \"No breed listed\"\n\t\tself.special_needs ||= \"No records of any special needs\"\n\t\tself.contact_city ||= \"No contact city on record\"\n\t\tself.contact_state ||= \"No contact state on record\"\n\t\tself.contact_zip ||= \"No contact zip code on record\"\n\t\tself.contact_address ||= \"No contact address on record\"\n\t\tself.contact_email ||= (find_email(self.description) || \"No contact email address on record\")\n\t\tself.contact_phone ||= (find_phone_number(self.description) || \"No contact phone number on record\")\n\tend", "def nillify_fields\n if self.rate_type == \"Per night\"\n self.number_of_guests = self.max_number_of_guests = nil\n end\n\n if self.rate == \"Rate Amount\"\n self.discount_type = self.discount_amount = nil\n elsif self.rate == \"Discount\"\n self.net_rate = self.commission_percent = nil\n end\n\n super\n end", "def correct_abbreviations_attributes; end", "def lower_fields\n\t\tif self.designation and self.department\n\t\t\tself.designation.downcase!\n\t\t\tself.department.downcase!\n\t\tend\n\tend", "def process_before_save\n zipcode = organization_zipcode.split('')[0..1].join('') if organization_zipcode.present?\n teriitory = Territory.find_by_territory_identifier(zipcode)\n unless teriitory\n teriitory = Territory.new(territory_identifier: zipcode)\n teriitory.save\n end\n self.territory = teriitory\n\n if CommonActions.nil_or_blank(organization_name) ||\n CommonActions.nil_or_blank(organization_short_name) ||\n CommonActions.nil_or_blank(organization_description) ||\n CommonActions.nil_or_blank(organization_address_1) ||\n CommonActions.nil_or_blank(organization_city) ||\n CommonActions.nil_or_blank(organization_state) ||\n CommonActions.nil_or_blank(organization_zipcode) ||\n CommonActions.nil_or_blank(organization_telephone) ||\n CommonActions.nil_or_blank(organization_website) ||\n (contact_type.type_value == 'fax' ? CommonActions.nil_or_blank(organization_fax) : CommonActions.nil_or_blank(organization_email)) ||\n (organization_type.type_value == 'customer' ? (customer_quality.nil? || min_vendor_quality.nil?) : false) ||\n (organization_type.type_value == 'vendor' ? vendor_quality.nil? : false)\n self.organization_complete = false\n else\n self.organization_complete = true\n end\n true\n end", "def normalize_fields\n\t\tself.email.downcase!\n\tend", "def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end", "def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end", "def model_params \t \n\t params.require(:university).permit( :name, :phone, :address, :city, :state, :zip, :status, :billing_address )\n\tend", "def normalize_attributes\n self.address.downcase!\n self.state.upcase!\n self.city = self.city.downcase.titleize\n self.country = self.country.downcase.titleize\n end", "def sanitize_params\n if valid_lease?\n sanitize_lease_params\n elsif valid_embargo?\n sanitize_embargo_params\n elsif !wants_lease? && !wants_embargo?\n sanitize_unrestricted_params\n else\n @attributes\n end\n end", "def nullify_insurance_fields_if_necessary\n return if self[:insured]\n self[:insurance_state_id] = nil\n self[:insurance_valid_from] = nil\n self[:insurance_valid_until] = nil\n self.insurance_certificate = nil\n return true\n end", "def nullify_fields\n user_fields = %W(\n comment\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 update!(**args)\n @address_line = args[:address_line] if args.key?(:address_line)\n @administrative_area_name = args[:administrative_area_name] if args.key?(:administrative_area_name)\n @country_name = args[:country_name] if args.key?(:country_name)\n @country_name_code = args[:country_name_code] if args.key?(:country_name_code)\n @dependent_locality_name = args[:dependent_locality_name] if args.key?(:dependent_locality_name)\n @dependent_thoroughfare_name = args[:dependent_thoroughfare_name] if args.key?(:dependent_thoroughfare_name)\n @firm_name = args[:firm_name] if args.key?(:firm_name)\n @is_disputed = args[:is_disputed] if args.key?(:is_disputed)\n @language_code = args[:language_code] if args.key?(:language_code)\n @locality_name = args[:locality_name] if args.key?(:locality_name)\n @post_box_number = args[:post_box_number] if args.key?(:post_box_number)\n @postal_code_number = args[:postal_code_number] if args.key?(:postal_code_number)\n @postal_code_number_extension = args[:postal_code_number_extension] if args.key?(:postal_code_number_extension)\n @premise_name = args[:premise_name] if args.key?(:premise_name)\n @recipient_name = args[:recipient_name] if args.key?(:recipient_name)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n @sub_administrative_area_name = args[:sub_administrative_area_name] if args.key?(:sub_administrative_area_name)\n @sub_premise_name = args[:sub_premise_name] if args.key?(:sub_premise_name)\n @thoroughfare_name = args[:thoroughfare_name] if args.key?(:thoroughfare_name)\n @thoroughfare_number = args[:thoroughfare_number] if args.key?(:thoroughfare_number)\n end", "def setup_full_name\n self.full_name = \"#{country.name}, #{city}, \" <<\n \"#{street_address1}#{', ' << street_address2 if !(street_address2.nil? or street_address2.blank?)}\" <<\n \"#{', ' << zip if !(zip.nil? or zip.blank?)}, \" <<\n \"#{phone} #{' / ' << extra_phone if !(extra_phone.nil? or extra_phone.blank?)}\"\n end", "def model_attributes(params)\n clean_params = super #hydra-editor/app/forms/hydra_editor/form.rb:54\n # model expects these as multi-value; cast them back\n clean_params[:rights] = Array(params[:rights]) if params[:rights]\n clean_params[:title] = Array(params[:title]) if params[:title]\n if params[:description]\n clean_params[:description] = Array(params[:description])\n clean_params[:description].map! do |description|\n ::DescriptionSanitizer.new.sanitize(description)\n end\n end\n # Model expects provenance as single-value.\n if params[:provenance]\n clean_params[:provenance] = ::DescriptionSanitizer.\n new.sanitize(params[:provenance])\n end\n\n # Oops; we're blanking out these values when changing permissions and probably versions, too\n # -- they don't have these fields in the form at all so they don't get repopulated.\n clean_params = encode_physical_container(params, clean_params)\n clean_params = encode_external_id(params, clean_params)\n\n clean_params.keys.each do |key|\n # strip ALL the things!\n if clean_params[key].is_a?(Array)\n clean_params[key].map!(&:strip)\n elsif clean_params[key].is_a?(String)\n clean_params[key] = clean_params[key].strip\n end\n end\n\n clean_params\n end", "def clean_attributes(attributes)\n attributes[:license] = Array(attributes[:license]) if attributes.key? :license\n attributes[:rights_statement] = Array(attributes[:rights_statement]) if attributes.key? :rights_statement\n remove_blank_attributes!(attributes)\n end", "def neutral_first_name; end", "def nil_address\n self.address_line1 = nil\n self.address_line2 = nil\n self.locality = nil\n self.county = nil\n self.country = nil\n self.postcode = nil\n end", "def prep_merge_fields(merge_fields)\n # Upper-case all the keys as this is how MC expect them.\n merge_fields.map { |k, v| [k.upcase, v] }.to_h\n end", "def fully_specified\r\n !address.nil? && !address.empty? &&\r\n !city.nil? && !city.empty? &&\r\n !state.nil? && !state.empty? &&\r\n !zip.nil? && !zip.empty?\r\n end", "def final_setup_update\n @company = @company\n if !params[:business_type].blank? && !params[:industry].blank? && !params[:total_employees].blank? && !params[:annual_turnover].blank?\n @company.update_as_final_setup(params)\n flash[:success]=\"Thanks for completing the setup.\"\n redirect_to dashboard_index_path\n else\n flash[:error]=\"Fields with * are mandatory\"\n redirect_to :back\n end\n end", "def set_name\n unless self.surname.blank?\n unless self.given_name.blank?\n self.name = self.surname + \", \" + self.given_name\n else\n self.name = self.surname\n end\n else \n if ![nil,\"\"].include?( self.given_name )\n self.name = self.given_name\n end\n end\n end", "def stupid_way_to_ensure_at_least_one_org_unit(record)\n if !current_user.is_superuser?\n #logger.debug(\"sw #{record.organizational_units.empty?} #{!current_user.organizational_units.empty?} #{current_user.name} #{current_user.organizational_units}\")\n raise \"Organizational units can't be blank\" if record.organizational_units.empty? #&& !current_user.organizational_units.empty? # 2. half is not working because org_unit gets update even before my condition test\n end\n end", "def set_defaults\n\t\tself.outside_agency_staff\t= DEFAULT_FIELD_TEXT\t\t\tif outside_agency_staff.nil?\n\t\tself.overview \t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif overview.nil?\n\t\tself.ratio \t\t\t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif ratio.nil?\n\t\tself.trainings_needed \t\t= DEFAULT_FIELD_TEXT\t\t \tif trainings_needed.nil?\n\t\tself.medication_times \t\t= DEFAULT_FIELD_TEXT\t\t \tif medication_times.nil?\n\t\tself.waivers \t\t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif waivers.nil?\n\t\tself.keys \t\t\t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif keys.nil?\n\t\tself.schedule_info \t\t\t\t= DEFAULT_FIELD_TEXT \t\t\tif schedule_info.nil?\n\t\tself.phone_numbers \t\t\t\t= DEFAULT_FIELD_TEXT \t\t\tif phone_numbers.nil?\n\t\tself.behavior_plans \t\t\t= DEFAULT_FIELD_TEXT \t\t\tif behavior_plans.nil?\n\t\tself.name\t\t\t\t\t\t\t\t\t= \"Untitled\"\t\t\t\t \t\t\tif name.nil?\n self.address_street\t\t\t\t= DEFAULT_ADDRESS_STREET \tif address_street.nil?\n self.address_city\t\t\t\t\t= DEFAULT_ADDRESS_CITY \t\tif address_city.nil?\n self.address_state\t\t\t\t= DEFAULT_ADDRESS_STATE \tif address_state.nil?\n self.address_zip\t\t\t\t\t= DEFAULT_ADDRESS_ZIP \t\tif address_zip.nil?\n self.phone_1\t\t\t\t\t\t\t= DEFAULT_PHONE_1 \t\t\t\tif phone_1.nil?\n self.phone_2\t\t\t\t\t\t\t= DEFAULT_PHONE_2 \t\t\t\tif phone_2.nil?\n self.fax\t\t\t\t\t\t\t\t\t= DEFAULT_FAX \t\t\t\t\t\tif fax.nil?\n self.bu_code\t\t\t\t\t\t\t= DEFAULT_BU_CODE\t\t \t\t\tif bu_code.nil?\n\tend", "def fill_names_if_nil\n if en_name.blank? && jp_name.blank?\n self.en_name = author.en_name\n self.jp_name = author.jp_name\n end\n end", "def normalize_fields\n self.email.downcase!\n end", "def uppercase_text\n if self.desc.present?\n self.desc.upcase! \n self.desc.strip!\n end\n self.part_code.upcase! if self.part_code.present?\n self.tarif_code.upcase! if self.tarif_code.present?\n self.origin.upcase! if self.origin.present?\n self.brand.upcase! if self.brand.present?\n self.grade.upcase! if self.grade.present?\n self.packing_method.upcase! if self.packing_method.present?\n self.container_no.upcase! if self.container_no.present?\n self.seal_no.upcase! if self.seal_no.present?\n self.despatch_advise.upcase! if self.despatch_advise.present?\n self.size.upcase! if self.size.present?\n self.model_no.upcase! if self.model_no.present?\n self.reorder_no.upcase! if self.reorder_no.present?\n self.art_no.upcase! if self.art_no.present?\n self.ref_no.upcase! if self.ref_no.present?\n self.work_order_no.upcase! if self.work_order_no.present?\n self.film_no.upcase! if self.film_no.present?\n self.bar_code.upcase! if self.bar_code.present?\n self.lot_no.upcase! if self.lot_no.present?\n self.item_code.upcase! if self.item_code.present?\n self.pantone_code.upcase! if self.pantone_code.present?\n self.color.upcase! if self.color.present?\n self.serial_no.upcase! if self.serial_no.present?\n self.warranty.upcase! if self.warranty.present?\n self.capacity.upcase! if self.capacity.present?\n self.consignee.upcase! if self.consignee.present?\n self.destination.upcase! if self.destination.present?\n self.process.upcase! if self.process.present?\n self.mould_no.upcase! if self.mould_no.present?\n self.category.upcase! if self.category.present?\n self.revision.upcase! if self.revision.present?\n self.window_code.upcase! if self.window_code.present?\n end", "def realtor_params\n params.require(:realtor).permit(:full_name, :phone, :user, :real_estate_company_id, :user_id)\n end", "def validate_name\n errors.add(:abstract, \"person_name or company_name must be present\") unless (person_name || company_name)\n end", "def keep_sponsor_name_error\n keep_interesting_errors(\n [I18n.t('errors.format_blank', attribute: I18n.t('activerecord.attributes.sponsor_covenant.sponsor_name'))]\n )\n end", "def initialize_fields\n publisher.build if publisher.empty?\n contributor.build if contributor.empty?\n creator.build if creator.empty?\n identifier.build if identifier.empty?\n description.build if description.empty?\n super\n end", "def home_owner_params\n params.require(:home_owner).permit(:firstname, :lastname, :email, :phone)\n end", "def amplify\n unless self.edited_by_user\n update_record_via_era_commons_username_map\n if [\"staging\", \"production\"].include?(Rails.env)\n update_record_via_bcsec\n end\n set_department_and_school\n end\n self\n end", "def set_LeadOwner(value)\n set_input(\"LeadOwner\", value)\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 leave_blank_name\n fill_in('name', :with => '')\nend", "def replace_nil_to_blank(data)\n data[data.index(nil)] = BLANK_CUSTOMER_OR_PACK_SIZE_NAME if data.index(nil)\n data[data.index('')] = BLANK_CUSTOMER_OR_PACK_SIZE_NAME if data.index('')\n data\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 cleanse_data!\n self.tag = tag.to_s&.strip&.upcase\n self.shl_case_number = shl_case_number.to_s&.strip&.upcase\n end", "def apartment_params\n params.require(:apartment).permit(:name, :address, :city, :state, :zip, :confirm_code, :landlord_email, :landlord_name, :lease_start, :lease_end, :description, :user_id)\n end", "def required_fields\n if self.controller_name == \"registrations\"\n param_name = \"user\"\n elsif self.controller_name == \"merchants\"\n param_name = \"merchant\"\n else\n return\n end\n empty_fields = Array.new\n empty = false\n params[param_name].each_pair do |k, v|\n if v == \"\"\n empty_fields << k.gsub(\"_\", \" \")\n empty = true\n end\n end\n if empty == true\n (0..empty_fields.length - 3).each do |i|\n empty_fields[i] << \",\"\n end\n empty_fields.insert(-2, \"and\") unless empty_fields.length < 2\n field_list = empty_fields.join(\" \")\n message = \"You cannot leave empty fields. The field\" \n if empty_fields.length > 1\n message << \"s \"\n else\n message << \" \"\n end\n message << field_list \n if empty_fields.length > 1\n message << \" were left blank.\"\n else\n message << \" was left blank.\"\n end\n flash[:notice] = message\n redirect_to request.referrer\n else\n return\n end\n end", "def set_defaults\n super\n self.organization_type ||= OrganizationType.find_by_class_name(self.name).first\n self.license_holder = self.license_holder.nil? ? false : self.license_holder\n end", "def business_owner_params\n params.require(:business_owner).permit(:user_name, :password, :business_name, :email)\n end", "def config_to_allow_offenses=(_arg0); end", "def upcase_save\n self.name = name.upcase rescue nil\n self.term_condition = term_condition.upcase rescue nil\n end", "def owner_params\n params.require(:owner).permit(:first_name, :last_name, :street, :city, :state, :zip, :phone, :email, :active)\n end", "def skip_include_blank?; end", "def affiliate_params\n params.require(:affiliate).permit(:name, :name_addon, :lastname, :firstname, :street, :zip, :city, :country, :email)\n end", "def validate\n errors.add(:post_office, \"- must be filled for postalcode #{self.postal_code}\") if self.post_office.blank? && !self.postal_code.blank?\n errors.add(:postal_code, \"- must be filled for #{self.post_office}\") if self.postal_code.blank? && !self.post_office.blank? \n errors.add_to_base(\"- Person must have at least one phonenumber\") if (self.phone_home.blank? && self.phone_cell.blank? && self.phone_work.blank?) \n end", "def remove_blank_contacts\n self.details = details.select { |cd| !cd.value.blank? }\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def remove_whitespace\n self.first_name = self.first_name.strip\n self.last_name = self.last_name.strip\n self.biography = self.biography.strip\n end", "def before_approve\n validate_associated_fields\n if organizations.where(approved: false).count > 0\n fail_validation :organizations, 'only_approved_organizations',\n list: organizations.approved.pluck(:name).join(', ')\n end\n fail_validation :area, 'needs_area_when_remote' if !personal? && !area\n end", "def additional_owners\n if ! additional_owner_0_first_name.present?\n owner_0 = nil\n else\n additional_owner_0_dob_day, additional_owner_0_dob_month, additional_owner_0_dob_year =\n additional_owner_0_dob.split('/').map(&:to_i)\n\n owner_0 = {\n first_name: additional_owner_0_first_name,\n last_name: additional_owner_0_last_name,\n dob: {\n day: additional_owner_0_dob_day,\n month: additional_owner_0_dob_month,\n year: additional_owner_0_dob_year,\n },\n address: {\n line1: additional_owner_0_address_line1,\n line2: additional_owner_0_address_line2,\n city: additional_owner_0_address_city,\n state: additional_owner_0_address_state,\n postal_code: additional_owner_0_address_postal_code,\n country: 'FR',\n },\n }\n end\n\n if ! additional_owner_1_first_name.present?\n owner_1 = nil\n else\n additional_owner_1_dob_day, additional_owner_1_dob_month, additional_owner_1_dob_year =\n additional_owner_1_dob.split('/').map(&:to_i)\n\n owner_1 = {\n first_name: additional_owner_1_first_name,\n last_name: additional_owner_1_last_name,\n dob: {\n day: additional_owner_1_dob_day,\n month: additional_owner_1_dob_month,\n year: additional_owner_1_dob_year,\n },\n address: {\n line1: additional_owner_1_address_line1,\n line2: additional_owner_1_address_line2,\n city: additional_owner_1_address_city,\n state: additional_owner_1_address_state,\n postal_code: additional_owner_1_address_postal_code,\n country: 'FR',\n },\n }\n end\n\n if ! additional_owner_1_first_name.present?\n owner_2 = nil\n else\n additional_owner_2_dob_day, additional_owner_2_dob_month, additional_owner_2_dob_year =\n additional_owner_2_dob.split('/').map(&:to_i)\n\n owner_2 = {\n first_name: additional_owner_2_first_name,\n last_name: additional_owner_2_last_name,\n dob: {\n day: additional_owner_2_dob_day,\n month: additional_owner_2_dob_month,\n year: additional_owner_2_dob_year,\n },\n address: {\n line1: additional_owner_2_address_line1,\n line2: additional_owner_2_address_line2,\n city: additional_owner_2_address_city,\n state: additional_owner_2_address_state,\n postal_code: additional_owner_2_address_postal_code,\n country: 'FR',\n },\n }\n end\n\n owners = [owner_0, owner_1, owner_2].compact\n\n owners.empty? ? '' : owners\n end", "def discard_blank_addresses\n return unless self.state == 'address' || self.state == 'cart'\n\n if bill_address && bill_address.invalid? && bill_address.blank?\n self.bill_address = nil\n end\n if ship_address && ship_address.invalid? && ship_address.blank?\n self.ship_address = nil\n end\n end", "def appeal_params\n params.require(:appeal).permit(:full_name, :dob_dd, :dob_mm, :dob_yyyy, :solicitor_name, :provider_acct_num)\n end", "def company=(v) Axlsx.validate_string v; @company = v; end", "def set_defaults\n super\n self.organization_type ||= OrganizationType.find_by_class_name(self.name).first\n self.license_holder = self.license_holder.nil? ? true : self.license_holder\n end", "def party_owner\n if !self.account_id.nil?\n self.account.name\n elsif !self.vendor_id.nil?\n self.vendor.name\n elsif !self.user_id.nil?\n \"Personal Contact\"\n else\n \"-\"\n end\n end", "def regional_params\n params.require(:regional).permit(:regional_name, :regional_code, :office_id, contact_attributes:[:landline,:extension,:mobilenumber1,:mobilenumber2,:email],address_attributes:[:address1,:address2,:city,:state,:country])\n end", "def data_research_application\n params.require(:ResearchApplication).permit(:title, :fname, :midinit, :lname, :owner)\n end", "def strip_blanks\n self.title = self.title.strip\n self.code = self.code.strip\n end", "def normalize_blank_values\n attributes.each do |column, value|\n self[column].present? || self[column] = nil\n end\n end", "def normalize_data(input)\n year = input[:year].to_i\n return input unless validate_year(input, year)\n input[:year] = year\n\n make = validate_make(input[:make])\n input[:make] = make\n\n model_array = input[:model].split\n model = model_array[0].downcase.capitalize\n input[:model] = model\n input[:trim] = model_array[1].upcase if model_array.size > 1\n\n trim = input[:trim].upcase\n trim == \"BLANK\" || trim == '' ? input[:trim] = nil : input[:trim] = trim\n input\n end", "def landmaster_params\n params.require(:landmaster).permit(:land_type,:district_id,:district_name,:taluka_id, :taluka_name,:village,:survey_number, :survey_area, :FP_number, :TP_number, :FP_area, :FP_shape, :details, :remark, :is_land_allocated, :is_active, :is_deleted)\n end", "def data_co_researcher\n params.require(:CoResearcher).permit(:research_application_id, :fname, :midinit, :lname, :address, :city, :state, :zipcode, :hphone, :mphone, :email_addr)\n end", "def reset_unnecessary_fields\n self.department_id = nil\n self.media = nil\n self.telephone = nil\n self.organization = nil\n self.stream_flow_ids = []\n self.public_role_es = nil\n self.public_role_eu = nil\n self.public_role_en = nil\n self.gc_id = nil\n self.description_es = nil\n self.description_eu = nil\n self.description_en = nil\n self.politician_has_agenda = nil\n end", "def init_with_empty\n new({\"name\" => \"\", \"dob\" => \"\", \"maritalStatus\" => \"\", \"mobileNumber\" => \"\", \"email\" => \"\"})\n end", "def leave_blank_website\n fill_in('website', :with => '')\nend", "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 setName\n self.name.nil? ? \"invalid\" : self.name.upcase\n self.second_name.nil? ? \"\" : self.second_name.titleize\n # self.name = self.name.upcase if not self.name.nil?\n # self.second_name = self.second_name.titleize if not self.second_name.nil?\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 borrower_params\n params.require(:borrower).permit(:borrower_id, :borrower_type, :first_name, :last_name, :social_security_number, :home_phone, :dob, :years_school, :marriage_status, :number_of_dependents, :home_address_line_1, :home_address_line_2, :own_or_rent, :years_of_residence, :mailing_address_line_1, :mailing_address_line_2)\n end", "def types_not_permitted\n %w(City Region Country Activity Restaurant Hotel) - [@type]\n end", "def fill_missing_fields\n unless self.title.blank?\n self.menu_name = self.title if self.menu_name.blank?\n self.shortcut = self.title.parameterize.html_safe if self.shortcut.blank?\n else\n unless self.menu_name.blank?\n self.title = self.menu_name if self.title.blank?\n self.shortcut = self.menu_name.parameterize.html_safe if self.shortcut.blank?\n end\n end\n end", "def organization_params\n params.require(:organization).permit(:org_name, :org_idetifier, address_attributes: [:line1, :line2, :city, :state, :country, :zip], profile_attributes: [:first_name, :last_name])\n end", "def reservation_owner_params\n params.require(:reservation_owner).permit(:firstname, :lastname, :email)\n end" ]
[ "0.60276127", "0.59083176", "0.5824052", "0.5728588", "0.5707643", "0.56918484", "0.5637235", "0.55982757", "0.55612475", "0.5551075", "0.5536769", "0.5499743", "0.5495096", "0.5483904", "0.5439449", "0.5433899", "0.5399516", "0.53979033", "0.5383222", "0.5338831", "0.5338678", "0.53232074", "0.5318123", "0.53147995", "0.53111917", "0.53111917", "0.5303374", "0.52842015", "0.5278497", "0.52701706", "0.52681243", "0.52657884", "0.52614576", "0.5261419", "0.52584064", "0.52504826", "0.5249224", "0.523611", "0.5227486", "0.5224062", "0.521377", "0.5194693", "0.51923335", "0.51836246", "0.5174302", "0.51660275", "0.5165849", "0.516234", "0.5151485", "0.51493025", "0.5146402", "0.5142715", "0.51399726", "0.5136977", "0.5136218", "0.5133067", "0.51297015", "0.51112944", "0.51005393", "0.5088846", "0.5087992", "0.50832504", "0.50736284", "0.5067921", "0.5066593", "0.5065195", "0.50572526", "0.50525707", "0.5051831", "0.5049589", "0.5048307", "0.50482625", "0.5041188", "0.5039918", "0.50382036", "0.5034859", "0.5032538", "0.50316805", "0.5024998", "0.5023578", "0.5015971", "0.5013811", "0.501086", "0.5009591", "0.50075847", "0.5003435", "0.49996915", "0.49922845", "0.4990622", "0.4990622", "0.4990622", "0.4990622", "0.4990622", "0.4990622", "0.49903595", "0.49878797", "0.49871996", "0.49845988", "0.49827087", "0.4978715", "0.49763238" ]
0.0
-1
this little spreadsheet has user_id, exclude_from_reporting, relationship_manager, program only rows present in the spreadsheet are modified when imported
def do_user_status_csv_import if params[:import].nil? flash[:message] = 'Please upload a csv file' redirect_to admin_user_status_csv_import_path return end file = CSV.parse(params[:import][:csv].read) @failures = [] file.each do |row| user_id = row[0] # If the user id isn't actually a number, skip this row # because that means it is probably a header or a blank line # http://stackoverflow.com/questions/10577783/ruby-checking-if-a-string-can-be-converted-to-an-integer begin user_id = Integer user_id rescue next end begin user = User.find(user_id) user.exclude_from_reporting = row[1] user.relationship_manager = row[2] user.associated_program = row[3] user.active_status = row[4] user.save! rescue @failures << user_id end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadstudentsUpdates\n @flagDbUpdateRun = false\n if params.has_key?('flagDbUpdate')\n if params['flagDbUpdate'] == 'run'\n @flagDbUpdateRun = true\n end\n end\n logger.debug \"@flagDbUpdateRun: \" + @flagDbUpdateRun.inspect\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n sheet_name = current_user[:sstab]\n\n #---------------------- Read the spreadsheet --------------------\n logger.debug 'about to read spreadsheet'\n startrow = 1\n # first get the 3 columns - Student's Name + Year, Focus, study percentages\n #This is now all that we get\n range = sheet_name + \"!A#{startrow}:U\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n @students_raw = Array.new(response.values.length){Array.new(11)}\n #logger.debug \"students: \" + @students_raw.inspect\n basecolumncount = 1 #index for loading array - 0 contains spreadsheet row number\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n @students_raw[rowcount][0] = rowcount + startrow\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students_raw[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n #------------------------ Verify spreadsheet --------------------\n sheetheader = @students_raw[0]\n flagHeaderOK = true\n expectedheader = [1, \"ID\", \"Given Name\", \"Family Name\", \"MERGE\",\n \"Preferred Name\", \"UPDATE NAME\", \"Initials\", \"Sex\", \"UPDATE SEX\",\n \"Comment\", \"UPDATE COMMENT\", \"Status\", \"UPDATE STATUS\",\n \"Year\", \"UPDATE YEAR\", \"Study Percentages\",\n \"UPDATE STUDY PERCENTAGES\", \"Email\", \"Phone\",\n \"Inv Code\", \"Day Code\"]\n \n headermessage = \"Failed headers: \"\n expectedheader.each_with_index do |o, i|\n if o != sheetheader[i]\n flagHeaderOK = false \n headermessage += \"#{i.to_s} => expected (#{o}) got (#{sheetheader[i]}) \"\n end\n end\n if flagHeaderOK == false\n @students = Array.new\n @students[0] = Hash.new\n @students[0]['message'] = \"spreadsheet error - header is not correct. \" +\n \"You have selected the wrong spreadsheet or \" +\n \"you have not set it up correctly.\"\n @students[1] = Hash.new\n @students[1]['message'] = \"Correct headers are: \" + expectedheader.inspect \n @students[2] = Hash.new\n @students[2]['message'] = headermessage \n return\n end\n #---------------------- Scan spreadsheet rows --------------------\n # now build a student hash of field names with field values\n @students = Array.new\n @studentsIndexById = Hash.new\n @students_raw.each_with_index do |s, j|\n #logger.debug \"j:: \" + j.inspect\n next if j == 0 # don't want the header\n #break if j > 4 # DEBUG ONLY\n i = j-1\n @students[i] = Hash.new\n @students[i]['row'] = s[0]\n if s[1] == \"\" # no record in the db according to the spreadsheet\n # Will need to be created. Need main values as opposed to\n # update primary values (ignore spreadsheet 'update' values).\n @students[i]['pname'] = s[5]\n @students[i]['sex'] = s[8]\n @students[i]['comment'] = s[10]\n @students[i]['status'] = s[12]\n @students[i]['year'] = s[14]\n @students[i]['study'] = s[16]\n else # we only want to update the database\n # this loads the update columns only and only if spreadsheet has content.\n @students[i]['id'] = s[1].to_i # already know it is there\n @students[i]['oldpname'] = s[5] if s[5] && s[5].match(/\\w+/)\n @students[i]['pname'] = s[6] if s[6] && s[6].match(/\\w+/) \n @students[i]['sex'] = s[9] if s[9] && s[9].match(/\\w+/) \n @students[i]['comment'] = s[11] if s[11] && s[11].match(/\\w+/) \n @students[i]['status'] = s[13] if s[13] && s[13].match(/\\w+/) \n @students[i]['year'] = s[15] if s[15] && s[15].match(/\\w+/)\n @students[i]['study'] = s[17] if s[17] && s[17].match(/\\w+/)\n # possibly a merge is required\n @students[i]['merge'] = s[4] if s[4].match(/\\w+/)\n end\n # need to store message for display to the user.\n @students[i]['message'] = \"\"\n # Build index to be used for finding merged entries.\n @studentsIndexById[@students[i]['id']] = @students[i] if @students[i].has_key?('id') \n end\n #logger.debug \"students: \" + @students.inspect\n # --------------- Check ids match pnames in dbvs spreadsheet -------------\n @allDbStudents = Student.all\n @allDbStudentsIndex = Hash.new\n @allDbStudents.each do |a|\n @allDbStudentsIndex[a.id] = a\n end\n idErrors = \"\"\n flagIdOK = true\n @students.each do |s|\n if s.has_key?('id') && s.has_key?('oldpname')\n unless @allDbStudentsIndex.has_key?(s['id']) # this spreadsheet id not in the database\n flagIdOK = false\n idErrors += \"Failed spreadsheet id not in database row #{s['row']} - #{s['id']} \"\n next\n end\n if s['oldpname'] != @allDbStudentsIndex[s['id']].pname # Still possibly OK\n # May have already been updated with new pname on previous run\n if s.has_key?('pname') # potentially still OK - check updated pname\n if s['pname'] != @allDbStudentsIndex[s['id']].pname # not OK unless merged \n flagIdOK = false\n idErrors += \"Failed id check row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - update pname #{s['pname']}\"\n end\n elsif s.has_key?('merge') # potentially still OK - check if merged\n m = s['merge'].match(/^Merge.+?(\\d+)$/)\n if m[1] # ensure relevenant info\n merge_into_id = m[1].to_i\n unless @studentsIndexById.has_key?(merge_into_id) # merge in entry not present\n flagIdOK = false\n idErrors += \"Failed id check - merged_into row not present row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} -> merged \"\n else\n mergedPname = \"zzzMERGED \" + @studentsIndexById[merge_into_id]['oldpname']\n if mergedPname != @allDbStudentsIndex[s['id']].pname # not OK unless merged \n flagIdOK = false\n idErrors += \"Failed id check - not previously merged either row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} -> merged \"\n end\n end\n else\n flagIdOK = false\n idErrors += \"Failed id check row on merged pname not present #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} \"\n end\n else\n flagIdOK = false\n idErrors += \"Failed id check row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} \"\n end\n end\n end\n end\n if flagIdOK == false\n @students = Array.new\n @students[0] = Hash.new\n @students[0]['message'] = \"spreadsheet error - ids do not match with pnames. \" +\n \"You have selected the wrong spreadsheet or \" +\n \"you have downloaded the wrong database.\"\n @students[1] = Hash.new\n @students[1]['message'] = idErrors \n return\n end\n #\n # --------------- Now to work through database creation or update -------------\n #@students is a hash of all records from the spreadsheets\n @students.each_with_index do |s, i|\n #logger.debug \"i: \" + i.inspect + \" s[id]: \" + s['id'].inspect\n #break if i > 1 # DEBUGGING ONLY\n # --------------- create record -------------\n if s['id'] == nil || s['id'] == \"\" # not yet created according to the spreadsheet\n logger.debug \"creating a record\"\n # better check to see if it has been created in a previous run\n if @students[i].has_key?('pname') # pname field is mandatory\n @checkstudents = Student.where(pname: @students[i]['pname'])\n if @checkstudents.count == 0 # confirmed not in database as spreadsheet expects\n # simply do nothing and let update proceed.\n else\n @students[i]['message'] += \"ERROR - record already in the database - row #{(i+1).to_s}\" \n next # ERROR - record already in the database\n end\n else # no pname value - ABORT this record!!!\n @students[i]['message'] += \"no pname provided to allow db record creation - row #{(i+1).to_s}\" \n next # ERROR in spreadsheet - cannot do any more with this\n end\n # All OK for record creation\n @student = Student.new(pname: @students[i]['pname'])\n @student.comment = @students[i]['comment'] if @students[i].has_key?('comment')\n @student.status = @students[i]['status'] if @students[i].has_key?('status')\n @student.year = @students[i]['year'] if @students[i].has_key?('year')\n @student.study = @students[i]['study'] if @students[i].has_key?('study')\n @student.sex = @students[i]['sex'] if @students[i].has_key?('sex')\n #logger.debug \"create student #{i.to_s}: \" + @student.inspect\n if @flagDbUpdateRun\n logger.debug \"update option selected - creating record\"\n if @student.save\n @students[i]['message'] = \"OK - Record created - row #{i.to_s}\" + @students[i]['message']\n logger.debug \"saved changes to \" + @students[i]['message']\n else\n @students[i]['message'] += \"ERROR - row #{i.to_s} - problem saving changes to db for \" + @students[i]['message']\n logger.debug \"problem saving changes to db for \" + @students[i]['message']\n end\n else\n @students[i]['message'] = \"OK - Record created - row #{i.to_s}\" + @students[i]['message']\n end\n else # spreadsheet says record should be in th database\n # --------------- update record -------------\n #logger.debug \"updating the database\"\n @student = Student.find(s['id']) # get the record & update\n if @student # record exists - now to update\n if s['pname'] && @student.pname != s['pname']\n @students[i]['message'] += \"#update pname:\" + @student.pname.inspect + \"=>\" + s['pname']\n @student.pname = s['pname']\n end\n if s['comment'] && @student.comment != s['comment']\n @students[i]['message'] += \"#update comment:\" + @student.comment.inspect + \"=>\" + s['comment']\n @student.comment = s['comment']\n end\n if s['status'] && @student.status != s['status']\n @students[i]['message'] += \"#update status:\" + @student.status.inspect + \"=>\" + s['status']\n @student.status = s['status']\n end\n if s['year'] && @student.year != s['year']\n @students[i]['message'] += \"#update year:\" + @student.year.inspect + \"=>\" + s['year']\n @student.year = s['year']\n end\n if s['study'] && @student.study != s['study']\n @students[i]['message'] += \"#update study:\" + @student.study.inspect + \"=>\" + s['study']\n @student.study = s['study']\n end\n if s['sex'] && @student.sex != s['sex']\n @students[i]['message'] += \"#update sex:\" + @student.sex.inspect + \"=>\" + s['sex']\n @student.sex = s['sex']\n end\n if @students[i]['message'].length > 0\n #logger.debug \"saved changes row #{(i+1).to_s} \" + @students[i]['message']\n logger.debug \"update student #{i.to_s}: \" + @student.inspect\n if @flagDbUpdateRun\n logger.debug \"update option selected - updating record\"\n if @student.save\n #logger.debug \"OK - saved changes to \" + @students[i]['message']\n @students[i]['message'] = \"OK record updated - row #{i.to_s} \" + @students[i]['message']\n else\n logger.debug \"ERROR - row #{i.to_s} - problem saving changes to db for \" + @students[i]['message']\n end\n end\n else\n @students[i]['message'] = \"INFO no updates required as record is already correct - row #{i.to_s}\" + @students[i]['message']\n end\n else # record not in database - which was expected.\n @students[i]['message'] += \"ERROR - no record found for this entry - row #{(i+1).to_s}\" \n # ABORT this record.\n end\n end\n end\n #--------------------------------------merge------------------------------\n # Merge requires:\n # 1. check both records exist\n # 2. find all roles for the student record being merged\n # 3. Update the student numbers in these to reference the merged_into student\n # 4. Set status of merged student to \"inactive\"\n # 5. Prepend comment to this student \"MERGED into student id xxx pname yyy\"\n # 6. Set pname to \"zzzMERGED \" + pname.\n #---------------------------------------------------------------------=--\n count_merges = 0\n @students.each_with_index do |s, i|\n #logger.debug \"i: \" + i.to_s + \" => \" + s.inspect\n if s.has_key?('merge') # merge requested\n count_merges += 1 # count the number of merges encounted in the spreadsheet\n #break if count_merges > 1 # DEBUGGING ONLY\n next if s['id'] == 0 # Not a record in the database accordingto the spreadsheet. \n merge_id = s['id'] # record to be merged\n #logger.debug \"merge_id: \" + merge_id.inspect + s['merge'].inspect\n m = s['merge'].match(/^Merge.+?(\\d+)$/)\n if m[1] # ensure relevenant info\n merge_into_id = m[1]\n else\n @students[i]['message'] += \" \\nError - requesting merge but merge info invalid\"\n return\n end\n # now check both records exist\n @student_merge = Student.find(merge_id)\n @students[i]['message'] += \"Error - merge record not in db\" unless @student_merge\n @student_merge_into = Student.find(merge_into_id)\n @students[i]['message'] += \"Error - merge_into record not in db\" unless @student_merge_into\n # find all the relevant roles\n @roles = Role.where(student_id: @student_merge)\n # Now check to see if the merge has already been done\n if @student_merge.pname.match(/^zzzMERGED/)\n @students[i]['message'] = \"INFO - already merged.\" + @students[i]['message'] + \" \"\n next\n end\n logger.debug \"Number of roles found for \" + @student_merge.pname + \" :\" + @roles.count.to_s\n # update the student_id in these roles to now reference merge_into\n @roles.each{|o| o.student_id = @student_merge_into.id}\n # Set merged student with status, comment and pname\n @student_merge.status = \"inactive\"\n @student_merge.comment = \"MERGED into student (#{@student_merge_into.id.to_s})\" +\n \" #{@student_merge_into.pname} \" + \n @student_merge_into.comment \n @student_merge.pname = \"zzzMERGED \" + @student_merge_into.pname\n # ensure each student stuff is done as a set.\n if @flagDbUpdateRun\n logger.debug \"update option selected - merging record\"\n begin\n Role.transaction do\n @roles.each do |myrole|\n myrole.save!\n end\n @student_merge.save!\n end\n rescue ActiveRecord::RecordInvalid => exception\n logger.debug \"Transaction failed row #{i._to_s} rollback exception: \" + exception.inspect\n @students[i]['message'] = \"ERROR - Transaction failed!!!\" + exception.inspect + @students[i]['message'] + \" \"\n next\n end\n end\n @students[i]['message'] = \" OK Record Merged. \" + @students[i]['message'] + \" \"\n end\n end\n end", "def data_responsible_person_sheet\r\n @book.worksheet(WBF[:people_sheet])\r\n end", "def spreadsheet_row\n fields = []\n fields << self.block.shop_order\n if self.block.shop_order == 111\n 5.times do\n fields << \"\"\n end\n else\n fields << self.block.customer_code\n fields << self.block.process_code\n fields << self.block.part_number\n fields << self.block.part_sub\n fields << self.block.part_name.join(\"\\n\")\n end\n fields << self.block.load\n fields << self.block.is_rework\n fields << self.block.is_early\n fields << self.block.is_strip\n fields << self.block.xray_id\n fields << self.block.application\n fields << self.block.directory\n fields << self.block.product\n fields << self.block.number\n if self.block.user\n fields << self.block.user.employee_number\n fields << self.block.user.name\n else\n fields << \"\"\n fields << \"\"\n end\n fields << self.reading_at.strftime(\"%m/%d/%Y\")\n fields << self.reading_at.strftime(\"%H:%M:%S\")\n fields << self.thickness\n if self.alloy.blank?\n fields << \"\"\n else\n fields << self.alloy\n end\n fields << self.x_coordinate\n fields << self.y_coordinate\n fields << self.z_coordinate\n return fields\n end", "def export_my_absence\n workbook = Spreadsheet::Workbook.new\n data_sheet = workbook.create_worksheet :name => \"absensi harian #{@current_person.full_name}\"\n format = Spreadsheet::Format.new :weight => :bold\n data_sheet.row(0).default_format = format\n data_sheet.row(0).replace ['Jam Masuk','Jam Keluar','Lama Kerja']\n data_sheet = set_data_export_my_absence(data_sheet)\n spreadsheet = StringIO.new\n workbook.write spreadsheet\n send_data spreadsheet.string, :filename => \"absent_harian_#{@current_person.full_name}.xls\", :type => \"application/vnd.ms-excel\"\n end", "def loadtutors\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n logger.debug 'about to read spreadsheet - service ' + service.inspect\n # Need some new code to cater for variation in the spreadsheet columns.\n # Will build an array with 'column names' = 'column numbers'\n # This can then be used to identify columns by name rather than numbers.\n #\n #this function converts spreadsheet indices to column name\n # examples: e[0] => A; e[30] => AE \n e=->n{a=?A;n.times{a.next!};a} \n columnmap = Hash.new # {'column name' => 'column number'}\n range = \"TUTORS!A3:LU3\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n headerrow = response.values[0]\n logger.debug \"response: \" + headerrow.inspect\n headerrow.each_with_index do |value, index| \n columnmap[value] = index\n end\n logger.debug \"columnmap: \" + columnmap.inspect\n #readcolumns = Array.new\n\n # pname: t[1],\n # subjects: t[2],\n # phone: t[3],\n # email: t[4],\n # sname: t[5],\n # comment: t[6],\n \n # Derived fields\n # status: \"active\" unless prefixed with zz..\n # firstaid: \"yes\" if name has suffix +\n # firstsesson: \"yes\" if name has suffix *\n\n readcolumns = [ 'NAME + INITIAL',\n 'SUBJECTS',\n 'MOBILE',\n 'EMAIL',\n 'SURNAME',\n 'NOTES'\n ]\n colerrors = \"\"\n readcolumns.each_with_index do |k, index|\n unless columnmap[k] \n colerrors += k + ':'\n end \n end\n # ensure we can read all the required spreadsheet column\n # if not, terminate and provide a user message\n unless colerrors.length == 0 # anything put into error string\n colerrors = \"Load Tutors - not all columns are findable: \" + colerrors\n redirect_to load_path, notice: colerrors\n return\n end\n # have everything we need, load the tutors from the spreadsheet\n # placing info into @tutors.\n startrow = 4 # row where the loaded data starts \n flagFirstPass = 1\n readcolumns.each_with_index do |k, index|\n columnid = e[columnmap[k]]\n range = \"TUTORS!#{columnid}#{startrow}:#{columnid}\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n if flagFirstPass == 1\n @tutors = Array.new(response.values.length){Array.new(9)}\n for rowcount in 0..response.values.count-1 \n \t @tutors[rowcount][0] = rowcount + startrow\n end\n flagFirstPass = 0\n end\n #rowcount = 0\n #response.values.each do |r|\n #for rowcount in 0..response.values.count \n response.values.each_with_index do |c, rowindex|\n \t @tutors[rowindex ][index + 1] = c[0]\n \t #bc = v.effective_format.background_color\n \t #logger.debug \"background color: red=\" + bc.red.to_s +\n \t # \" green=\" + bc.green.to_s +\n \t\t # \" blue=\" + bc.blue.to_s\n end \n end\n\n #logger.debug \"tutors: \" + @tutors.inspect\n # Now to update the database\n loopcount = 0\n @tutors.each do |t| # step through all tutors from the spreadsheet\n t[7] = \"\"\n pname = t[1]\n logger.debug \"pname: \" + pname.inspect\n if pname == \"\" || pname == nil\n t[7] = t[7] + \"invalid pname - do nothing\"\n next\n end\n # determine status from name content - been marked by leading z...\n thisstatus = \"active\"\n if m = pname.match(/(^z+)(.+)$/) # removing leading z.. (inactive entries)\n pname = m[2].strip\n thisstatus = \"inactive\"\n #t[1] = pname\n end\n # look for + (firstaid:) * (firstsession) at end of pname \n # (first aid trained or first session trained)\n thisfirstaid = 'no'\n thisfirstlesson = 'no'\n if m = pname.match(/([+* ]+)$/)\n thisfirstaid = (m[1].include?('+') ? 'yes' : 'no')\n thisfirstlesson = (m[1].include?('*') ? 'yes' : 'no')\n pname = pname.gsub($1, '') unless $1.strip.length == 0\n end\n pname = pname.strip\n \n db_tutor = Tutor.find_by pname: pname\n if(db_tutor) # already in the database\n flagupdate = 0 # detect if any fields change\n updatetext = \"\"\n if db_tutor.comment != t[6]\n db_tutor.comment = t[6]\n flagupdate = 1\n updatetext = updatetext + \" - comment\" \n end\n if db_tutor.sname != t[5]\n db_tutor.sname = t[5]\n flagupdate = 1\n updatetext = updatetext + \" - sname\" \n end\n if db_tutor.email != t[4]\n db_tutor.email = t[4]\n flagupdate = 1\n updatetext = updatetext + \" - email\" \n end\n if db_tutor.phone != t[3]\n db_tutor.phone = t[3]\n flagupdate = 1\n updatetext = updatetext + \" - phone\" \n end\n if db_tutor.subjects != t[2]\n db_tutor.subjects = t[2]\n flagupdate = 1\n updatetext = updatetext + \" - subjects\" \n end\n if db_tutor.status != thisstatus \n db_tutor.status = thisstatus\n flagupdate = 1\n updatetext = updatetext + \" - status\" \n end\n if db_tutor.firstaid != thisfirstaid \n db_tutor.firstaid = thisfirstaid\n flagupdate = 1\n updatetext = updatetext + \" - firstaid\" \n end\n if db_tutor.firstlesson != thisfirstlesson\n db_tutor.firstlesson = thisfirstlesson\n flagupdate = 1\n updatetext = updatetext + \" - firstlesson\" \n end\n logger.debug \"flagupdate: \" + flagupdate.inspect + \" db_tutor: \" + db_tutor.inspect\n if flagupdate == 1 # something changed - need to save\n if db_tutor.save\n logger.debug \"db_tutor saved changes successfully\"\n t[7] = t[7] + \"updated\" + updatetext \n else\n logger.debug \"db_tutor saving failed - \" + @db_tutor.errors\n t[7] = t[7] + \"failed to create\"\n end\n else\n t[7] = t[7] + \"no changes\"\n end\n else\n # This tutor is not in the database - so need to add it.\n @db_tutor = Tutor.new(\n pname: pname,\n subjects: t[2],\n phone: t[3],\n email: t[4],\n sname: t[5],\n comment: t[6],\n status: thisstatus,\n firstlesson: thisfirstlesson,\n firstaid: thisfirstaid\n )\n #if pname =~ /^zz/ # the way they show inactive tutors\n #if t[1] =~ /^zz/ # the way they show inactive tutors\n # @db_tutor.status = \"inactive\"\n #end\n logger.debug \"new - db_tutor: \" + @db_tutor.inspect\n if @db_tutor.save\n logger.debug \"db_tutor saved successfully\"\n t[7] = t[7] + \"created\" \n else\n logger.debug \"db_tutor saving failed - \" + @db_tutor.errors.inspect\n t[7] = t[7] + \"failed to create\"\n end\n end\n #exit\n if loopcount > 5\n #break\n end\n loopcount += 1\n end\n #exit\n end", "def add_rows(sheet)\n # Do nothing\n end", "def import_master\n begin\n if request.post?\n raise \"Please attach an excel file for import master tables\" if params[:import_file].blank? \n status = \"\"\n set_original_path(params[:import_file]) \n data = Roo::Spreadsheet.open(@original_path) \n data.each_with_pagename do |name, sheet|\n table_name = name.downcase\n case table_name\n when \"bill_footer_setting\" \n status = FooterSetting.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"bill_group\" \n status = BillGroup.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"combooffer\" \n status = ComboOffer.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"creditcard_master\" \n status = CreditCard.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"cust_detail\"\n status = Customer.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"item_groups\" \n status = ItemGroup.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"item_groups_kot_print\" \n status = ItemGroupsKotPrint.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"item_sub_group\" \n status = ItemSubGroup.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"items\" \n status = Item.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"table_master\"\n status = Table.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"settings\" \n status = Setting.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"remarksmaster\"\n status = RemarkMaster.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"table_section\" \n status = TableSection.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"tax\"\n status = Tax.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"user_validation\" \n status = StaffSubMenuSetting.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"usermainmenu\" \n status = StaffMenuSetting.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"waiter\" \n status = Waiter.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"outlet_master\" \n status = Outlet.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"combopackage\" \n status = ComboPackage.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"user_master\" \n status = Staff.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"strtable\" \n status = Company.checked_attributes(sheet)\n raise status[1] if status [0] == false \n when \"happyhour\" \n status = HappyHour.checked_attributes(sheet)\n raise status[1] if status [0] == false \n end \n end \n \n begin\n data.default_sheet = \"Outlet_Master\"\n status = Outlet.import(data, current_location)\n rescue Exception => e \n end \n raise status[1] if status [0] == false\n begin\n data.default_sheet = \"ComboPackage\"\n status = ComboPackage.import(data, current_location)\n rescue Exception => e \n end \n raise status[1] if status [0] == false \n begin\n data.default_sheet = \"Table_Section\"\n status = TableSection.import(data, current_location)\n rescue Exception => e \n end \n raise status[1] if status [0] == false \n begin\n data.default_sheet = \"User_Master\"\n status = Staff.import(data, current_location)\n rescue Exception => e \n end \n raise status[1] if status [0] == false\n \n data.each_with_pagename do |name, sheet|\n table_name = name.downcase\n case table_name\n when \"bill_footer_setting\"\n status = FooterSetting.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"bill_group\" \n status = BillGroup.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"combooffer\"\n status = ComboOffer.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"creditcard_master\"\n status = CreditCard.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"cust_detail\"\n status = Customer.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"item_groups\"\n status = ItemGroup.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"item_groups_kot_print\"\n status = ItemGroupsKotPrint.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"item_sub_group\" \n status = ItemSubGroup.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"items\"\n status = Item.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"table_master\"\n status = Table.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"settings\"\n status = Setting.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"remarksmaster\"\n status = RemarkMaster.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false\n when \"tax\"\n status = Tax.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"user_validation\" \n status = StaffSubMenuSetting.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"usermainmenu\" \n status = StaffMenuSetting.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"waiter\" \n status = Waiter.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"strtable\" \n status = Company.import(sheet, current_client) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n when \"happyhour\" \n status = HappyHour.import(sheet, current_location) unless sheet.last_row <= 1\n raise status[1] if status [0] == false \n end \n end\n flash[:notice] = \"Master data is imported successfully.\"\n redirect_to client_path\n end\n rescue Exception => e\n flash.now[:info] = e.message\n render :import_master\n end\n end", "def import_students(file, header_map, header_row_exists)\n ext = File.extname(file.original_filename)\n spreadsheet = Roo::Spreadsheet.open(file, extension: ext)\n \n # get index for each param\n id_index = header_map.index(\"student_id\")\n email_index = header_map.index(\"email\")\n first_name_index = header_map.index(\"first_name\")\n last_name_index = header_map.index(\"last_name\")\n full_name_index = header_map.index(\"full_name\")\n\n # start at row 1 if header row exists (via checkbox)\n ((header_row_exists ? 2 : 1 )..spreadsheet.last_row).each do |i|\n\n spreadsheet_row = spreadsheet.row(i)\n\n row = {} # build dynaimically based on choices\n\n row[\"student_id\"] = spreadsheet_row[id_index]\n row[\"email\"] = spreadsheet_row[email_index]\n\n if first_name_index\n row[\"first_name\"] = spreadsheet_row[first_name_index]\n row[\"last_name\"] = spreadsheet_row[last_name_index]\n else\n name_arr = spreadsheet_row[full_name_index].split(\" \") # this seems prone to bugs because last names are weird\n row[\"first_name\"] = name_arr[0]\n row[\"last_name\"] = name_arr[1]\n end\n\n next if row.values.all?(&:nil?) # skip empty rows\n\n # check if there is an existing student in the course or create a new one\n student = roster_students.find_by(perm: row[\"student_id\"]) ||\n roster_students.new\n \n student.perm = row[\"student_id\"]\n student.first_name = row[\"first_name\"]\n student.last_name = row[\"last_name\"]\n student.email = row[\"email\"]\n student.save\n end\n end", "def readWorkbook\n # open the speadsheet\n workbook = Roo::Spreadsheet.open(params[:file], extension: :xlsx)\n\n workbook.default_sheet = 'Rating'\n\n @policy.name= workbook.cell('C',3)\n @policy.quoted_by= workbook.cell('B',1)\n #@policy.date= workbook.cell('B',2)\n @policy.effective_date= workbook.cell('F',7)\n @policy.expiration_date= workbook.cell('J',7)\n\n @policy.dba= workbook.cell('B',4),\n @policy.business_type= workbook.cell('L',5)\n @policy.mortgagee= workbook.cell('S',3)\n\n @policy.street= workbook.cell('C',5)\n @policy.city= workbook.cell('B',6)\n @policy.state= workbook.cell('G',6)\n @policy.zip= workbook.cell('K',6).to_i.to_s\n\n # Property\n @policy.property.schedule_rating_pct= workbook.cell('J',36)\n @policy.property.premium_subtotal= workbook.cell('J',35)\n @policy.property.premium_total= workbook.cell('M',41)\n\n @policy.property.locations.destroy_all # no duplicates\n # First location (locations.first)\n #locationFields = {\n @policy.property.locations.create!(\n number: 1, premium: workbook.cell('N',33),\n co_ins: workbook.cell('L',14), co_ins_factor: workbook.cell('L',15),\n ded: workbook.cell('B',15), ded_factor: workbook.cell('G',15),\n\n street: workbook.cell('C',10), city: workbook.cell('B',11),\n state: workbook.cell('G',11), zip: workbook.cell('K',11).to_i.to_s,\n\n business_type: workbook.cell('L',10), coverage_type: workbook.cell('D',12),\n protection_class: workbook.cell('L',12), updates: workbook.cell('K',13),\n year_built: workbook.cell('B',13).to_i.to_s, construction_type: workbook.cell('H',13),\n stories: workbook.cell('E',13).to_i, square_feet: workbook.cell('B',14).to_i,\n parking_lot: workbook.cell('H',14).to_i,\n\n #food_limit: workbook.cell('F',17),\n food_rate: workbook.cell('H',17),\n food_premium: workbook.cell('J',17),\n\n theft_limit: workbook.cell('F',18),\n #theft_rate: workbook.cell('H',18),\n theft_premium: workbook.cell('J',18),\n\n #enhc_limit: workbook.cell('F',19),\n enhc_rate: workbook.cell('H',19),\n enhc_premium: workbook.cell('J',19),\n\n #mech_limit: workbook.cell('F',20),\n #mech_rate: workbook.cell('H',20),\n mech_premium: workbook.cell('J',20)\n )\n #if (!@policy.property.locations.where(number:1).exists?)\n #@policy.property.locations.create!(locationFields)\n\n for i in 23..29 do\n @policy.property.locations.first.exposures.create!(\n name: (workbook.cell('A',i) || \"\"),\n valuation: (workbook.cell('D',i) || \"\"),\n limit: (workbook.cell('F',i) || 0),\n rate: (workbook.cell('H',i) || 0),\n ded_factor: (workbook.cell('J',i) || 0),\n co_ins_factor: (workbook.cell('L',i) || 0),\n premium: (workbook.cell('O',i) || 0)\n )\n end\n #else\n #@policy.property.locations.first.update(locationFields)\n #end\n\n # Earnings should have all 0s\n @policy.property.locations.first.exposures.third.update(valuation: 0,\n ded_factor: 0, co_ins_factor: 0 )\n\n # Second location (locations.second) (optional)\n if (workbook.cell('T',10) != nil)\n @policy.property.locations.create!(\n number: 2, premium: workbook.cell('AE',33), co_ins: workbook.cell('AC',14),\n co_ins_factor: workbook.cell('AC',15), ded: workbook.cell('S',15),\n ded_factor: workbook.cell('X',15),\n\n street: workbook.cell('T',10), city: workbook.cell('S',11),\n state: workbook.cell('X',11), zip: workbook.cell('AB',11).to_i.to_s,\n\n business_type: workbook.cell('AC',10), coverage_type: workbook.cell('U',12),\n protection_class: workbook.cell('AC',12), updates: workbook.cell('AB',13),\n year_built: workbook.cell('S',13), construction_type: workbook.cell('Y',13),\n stories: workbook.cell('V',13).to_i, square_feet: workbook.cell('S',14).to_i,\n parking_lot: workbook.cell('Y',14).to_i,\n\n #food_limit: workbook.cell('W',17),\n food_rate: workbook.cell('Y',17),\n food_premium: workbook.cell('AA',17),\n\n theft_limit: workbook.cell('W',18),\n #theft_rate: workbook.cell('Y',18),\n theft_premium: workbook.cell('AA',18),\n\n #enhc_limit: workbook.cell('W',19),\n enhc_rate: workbook.cell('Y',19),\n enhc_premium: workbook.cell('AA',19),\n\n #mech_limit: workbook.cell('W',20),\n #mech_rate: workbook.cell('Y',20),\n mech_premium: workbook.cell('AA',20)\n )\n\n for i in 23..29 do\n @policy.property.locations.second.exposures.create!(\n name: (workbook.cell('R',i) || \"\"),\n valuation: (workbook.cell('U',i) || \"\"),\n limit: (workbook.cell('W',i) || 0),\n rate: (workbook.cell('Y',i) || 0),\n ded_factor: (workbook.cell('AA',i) || 0),\n co_ins_factor: (workbook.cell('AC',i) || 0),\n premium: (workbook.cell('AF',i) || 0)\n )\n end\n\n # Earnings should have all 0s\n @policy.property.locations.second.exposures.third.update(valuation: 0,\n ded_factor: 0, co_ins_factor: 0 )\n end\n\n # Crime\n @policy.crime.premium_total= workbook.cell('M',62)\n @policy.crime.premium_subtotal= workbook.cell('J',56)\n @policy.crime.schedule_rating= workbook.cell('J',57)\n @policy.crime.burglar_alarm= workbook.cell('F',44)\n @policy.crime.exclude_safe= workbook.cell('F',45)\n @policy.crime.ded= workbook.cell('K',44)\n\n @policy.crime.exposures.destroy_all # no duplications\n\n for i in 47..51 do\n @policy.crime.exposures.create!(\n name: workbook.cell('A',i), limit: workbook.cell('F',i),\n premium: workbook.cell('K',i)\n )\n end\n\n @policy.gl.exposure_gls.destroy_all # no duplications\n\n for i in 76..84 do\n if (workbook.cell('A',i) != nil)\n @policy.gl.exposure_gls.create!(\n name: \"exposure_#{i-75}\",\n loc_number: workbook.cell('A',i),\n description: workbook.cell('C',i),\n cov: workbook.cell('B',i),\n code: workbook.cell('H',i),\n premium_basis: workbook.cell('I',i),\n sales_type: workbook.cell('K',i),\n base_rate: workbook.cell('M',i),\n ilf: workbook.cell('O',i),\n premium: workbook.cell('Q',i)\n )\n end\n end\n\n @policy.gl.gas_premium= workbook.cell('M',88)\n @policy.gl.rate= workbook.cell('J',88)\n @policy.gl.water_gas_tank= workbook.cell('F',88)\n @policy.gl.add_ins_number= workbook.cell('F',87)\n @policy.gl.territory= workbook.cell('B',65).to_i\n @policy.gl.comments= (workbook.cell('B',99) || \"none\")\n\n @policy.gl.gen_agg= workbook.cell('F',67)\n @policy.gl.products_completed_operations= workbook.cell('F',68)\n @policy.gl.personal_advertising_injury= workbook.cell('F',69)\n @policy.gl.each_occurence= workbook.cell('F',70)\n @policy.gl.fire_damage= workbook.cell('F',71)\n @policy.gl.medical_expense= workbook.cell('F',72)\n\n if (workbook.cell('A',89) == nil)\n # General Liability\n @policy.gl.premium_total= workbook.cell('N',99)\n @policy.gl.premium_subtotal= workbook.cell('Q',89)\n @policy.gl.schedule_rating= workbook.cell('Q',91)\n @policy.gl.multi_loc_factor= workbook.cell('Q',90)\n\n # Commerical Auto\n @policy.auto.premium_total= workbook.cell('N',107)\n @policy.auto.locations= workbook.cell('K',102)\n @policy.auto.hired_auto= workbook.cell('F',103)\n @policy.auto.hired_auto_premium= workbook.cell('Q',103)\n\n @policy.package_premium_total= workbook.cell('N',109)\n else\n # General Liability\n @policy.gl.premium_total= workbook.cell('N',101)\n @policy.gl.premium_subtotal= workbook.cell('Q',91)\n @policy.gl.schedule_rating= workbook.cell('Q',93)\n @policy.gl.multi_loc_factor= workbook.cell('Q',92)\n\n # Commerical Auto\n @policy.auto.premium_total= workbook.cell('N',109)\n @policy.auto.locations= workbook.cell('K',104)\n @policy.auto.hired_auto= workbook.cell('F',105)\n @policy.auto.hired_auto_premium= workbook.cell('Q',105)\n\n @policy.package_premium_total= workbook.cell('N',111)\n end\n end", "def import_package_learners_from_csv\n assessment_id = params[:user][:package_id]\n unless params[:import][:excel].nil? or params[:import][:excel].blank? then\n @import = Import.new(params[:import])\n mime = (MIME::Types.type_for(@import.excel.path)[0])\n unless mime.nil? or mime.blank? then\n mime_obj = mime.extensions[0]\n #dont process further if the uploaded file is other than xls,xls,csv\n if (!mime_obj.nil? and !mime_obj.blank?) and (mime_obj.include? \"xls\" or mime_obj.include? \"xlsx\" or mime_obj.include? \"ods\" or mime_obj.include? \"csv\" ) then\n if @import.save!\n #check for virus\n if no_virus(@import.excel.path) then\n #If mime_obj is not csv only then create roo_instace\n unless mime_obj.include? \"csv\" then\n @roo = create_roo_instance(@import.excel.path,mime_obj)\n else\n #so, its a csv format\n @roo = \"csv format\"\n end\n #if the uploaded\n unless @roo == \"Upload correct excel format.\" then\n if @roo == \"csv format\" then\n lines = parse_csv_file(@import.excel.path)\n else\n lines = parse_excel_file_roo(@roo)\n end\n\n if lines.size > 0\n @import.processed = lines.size\n i = 1\n failed_to_upload = Array.new\n lines.each do |line|\n if valid_assign(params[:id])\n if valid_learners_excel_upload(line)\n else\n failed_to_upload << i\n end\n else\n flash[:learner_limit_exceeds] = \"You cannot assign more learners\"\n end\n i = i + 1\n end\n @import.save\n\n delete_csv(@import.excel.path)\n\n @import.destroy\n if params.include? 'from_assign_learners_page' then\n redirect_to(\"/packages/assign_learners/\" + assessment_id.to_s)\n else\n total_failed_to_upload = failed_to_upload.join(\",\")\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}?failed_to_upload=#{total_failed_to_upload}\")\n end\n else\n flash[:error] = \"CSV data processing failed.\"\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:virus_error] = \"The file is Infected with virus.\"\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:error] = 'CSV data import failed.'\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n end", "def import_one_row_data(line)\n return if @file.nil? && @file.cell(line, 1).blank?\n company = import_company(line)\n unless company.new_record? || company.owner\n import_company_owner(company, line) \n end\n end", "def import_learners_from_csv\n assessment_id = params[:user][:assessment_id]\n unless params[:import][:excel].nil? or params[:import][:excel].blank? then\n @import = Import.new(params[:import])\n mime = (MIME::Types.type_for(@import.excel.path)[0])\n unless mime.nil? or mime.blank? then\n mime_obj = mime.extensions[0]\n #dont process further if the uploaded file is other than xls,xls,csv\n if (!mime_obj.nil? and !mime_obj.blank?) and (mime_obj.include? \"xls\" or mime_obj.include? \"xlsx\" or mime_obj.include? \"ods\" or mime_obj.include? \"csv\" ) then\n if @import.save!\n #check for virus\n if no_virus(@import.excel.path) then\n #If mime_obj is not csv only then create roo_instace\n unless mime_obj.include? \"csv\" then\n @roo = create_roo_instance(@import.excel.path,mime_obj)\n else\n #so, its a csv format\n @roo = \"csv format\"\n end\n #if the uploaded\n unless @roo == \"Upload correct excel format.\" then\n if @roo == \"csv format\" then\n lines = parse_csv_file(@import.excel.path)\n else\n lines = parse_excel_file_roo(@roo)\n end\n \n if lines.size > 0\n @import.processed = lines.size\n i = 1\n failed_to_upload = Array.new\n lines.each do |line|\n if valid_assign(params[:id])\n if valid_learners_excel_upload(line)\n else\n failed_to_upload << i\n end\n else\n flash[:learner_limit_exceeds] = \"You cannot assign more learners\"\n end\n i = i + 1\n end\n @import.save\n\n delete_csv(@import.excel.path)\n\n @import.destroy\n if params.include? 'from_assign_learners_page' then\n redirect_to(\"/assessments/assign_learners/\" + assessment_id.to_s)\n else\n total_failed_to_upload = failed_to_upload.join(\",\")\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}?failed_to_upload=#{total_failed_to_upload}\")\n end\n else\n flash[:error] = \"CSV data processing failed.\"\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:virus_error] = \"The file is Infected with virus.\"\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:error] = 'CSV data import failed.'\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n end", "def save_from_on_GoogleDrive\n session = GoogleDrive::Session.from_config(\"config.json\")\n# ws = session.spreadsheet_by_key(\"1PzbUao-3UscYOWh48FL061r5yYcH2TBl1oWXtmaW1cw\").worksheets[0] #cle a changer en fonction du lien url du fichier google drive\n ws = session.spreadsheet_by_key(\"1PzbUao-3UscYOWh48FL061r5yYcH2TBl1oWXtmaW1cw\").worksheets[1] #cle a changer en fonction du lien url du fichier google drive\n table_of_mails=[]\n # for i in 1..table_data.length\n # ws[i, 1] = table_data[i-1][:nom]\n # ws[i, 2] = table_data[i-1][:url]\n # ws[i, 3] = table_data[i-1][:email]\n # end\n puts ws.num_rows\n (1..(ws.num_rows + 1)).each do |row|\n puts ws[row + 1, 2]\n table_of_mails << ws[row + 1, 2]\n end\n Operation_on_gmail(table_of_mails)\n ws.save\n ws.reload\nend", "def import_user_data\n @page_title = _('Import_user_data')\n @page_icon = 'excel.png'\n @users = User.find(:all, :conditions => \"temporary_id >= 0\")\n @devices = Device.find(:all, :conditions => \"temporary_id >= 0 AND name not like 'mor_server_%'\")\n end", "def importation\n Dir.mkdir(importation_route) unless File.exists?(importation_route)\n spreadsheet = Dir.glob(\"#{importation_route}/*\")[0]\n xlsx = Roo::Spreadsheet.open(spreadsheet)\n\n xlsx.each_with_pagename do |name, sheet|\n unless name.include?('Nota')\n state = State.find_by_name(name)\n unless state\n state = State.create(name: name)\n end\n sheet.each_with_index(D_mnpio: 'mnpio', d_asenta: 'asenta',\n d_codigo: 'codigo') do |attributes, index|\n unless index == 0\n city = City.find_by(name: attributes[:D_mnpio], state_id: state&.id)\n unless city\n city = City.create(name: attributes[:D_mnpio], state_id: state&.id)\n end\n colony = Colony.find_by(name: attributes[:d_asenta], postcode: attributes[:d_codigo], city_id: city&.id)\n unless colony\n Colony.create(name: attributes[:d_asenta], postcode: attributes[:d_codigo], city_id: city&.id)\n end\n end\n end\n end\n end\n end", "def get_user_recommendations\n recommendations = []\n csv = open( CONFIG['SPREADSHEET_URL'] ).read\n CSV.parse( csv ).each_with_index do |line,i|\n next if i == 0 # Skip header\n date, title, category, url, note, person = *line\n next if category.match(/^Other/) # Looking at specific categories - Other is too broad\n if matches = url.match(%r{/(?:dp|product|ASIN)/([^/]*)})\n recommendations << {\n :id => matches[1],\n :category => category\n }\n end\n end\n recommendations\n end", "def importx(file, name, attr=nil)\n\n case File.extname(file)\n when '.csv' then spreadsheet = Roo::Csv.new(file) #, nil, :ignore)\n when '.xls' then spreadsheet = Roo::Excel.new(file, nil, :ignore)\n when '.xlsx' then spreadsheet = Roo::Excelx.new(file) #, nil, :ignore)\n else raise \"Unknown file type: #{file}\"\n end\n\n if name != 'ApplicationRecord'\n begin\n spreadsheet.default_sheet = name\n rescue\n raise \"ya, you're gonna need a spreadsheet tab labeled '#{name}' for this to work\\r\\n\"\n end\n end\n model = name.constantize\n header = spreadsheet.row(1)\n types = spreadsheet.row(2)\n\n #print \"file=#{file}, model=#{model} name=#{name} header=#{header} def=#{spreadsheet.default_sheet}\\n\"\n\n # @todo WISE!! restrict accessible columns for import\n attr = attr.map { |str| str.to_s} if !attr.nil?\n (3..spreadsheet.last_row).each do |i|\n row = Hash[[header, spreadsheet.row(i)].transpose]\n begin\n item = model.find_by_id(row['id']) || model.new\n rescue\n print \"ya, you're gonna need a dB table '#{model.name.downcase.pluralize}' for this to work\\r\\n\"\n exit\n end\n\n item.attributes = attr.nil? ? row : row.to_hash.slice(*attr)\n item.attributes['password'] = item.attributes['password'].to_s if spreadsheet.default_sheet == 'User'\n item.save!\n end\n\n begin\n name = model.name.underscore.pluralize\n result = model.maximum(:id).next\n cmd = \"ALTER SEQUENCE #{name}_id_seq RESTART WITH #{result}\"\n ActiveRecord::Base.connection.execute(cmd)\n puts \"#{spreadsheet.last_row-2} records imported into #{model.name}, #{name}_id_seq=#{result}\"\n rescue\n puts \"Warning: not procesing table #{name.name}. Id is missing?\"\n end\n\n spreadsheet.last_row-2 # this is how many rows we imported\n end", "def transferrable_to_users\n collaborator_users.where.not(id: user_id)\n end", "def skip_leading_rows\n @gapi.google_sheets_options.skip_leading_rows\n end", "def skip_leading_rows= row_count\n frozen_check!\n @gapi.google_sheets_options.skip_leading_rows = row_count\n end", "def skipped_records\n [\n \"1160682\", # Example for custom titles/authors\n \"345682\", # Example for custom rights.\n \"10068705\", # Example for 'parts' in 740 field.\n \"2068747\" # Example for Cicognara CSV ingest - has since changed from cico: to dcl: since it's done in production.\n ]\nend", "def import_course_learners_from_csv\n assessment_id = params[:user][:course_id]\n unless params[:import][:excel].nil? or params[:import][:excel].blank? then\n @import = Import.new(params[:import])\n mime = (MIME::Types.type_for(@import.excel.path)[0])\n unless mime.nil? or mime.blank? then\n mime_obj = mime.extensions[0]\n #dont process further if the uploaded file is other than xls,xls,csv\n if (!mime_obj.nil? and !mime_obj.blank?) and (mime_obj.include? \"xls\" or mime_obj.include? \"xlsx\" or mime_obj.include? \"ods\" or mime_obj.include? \"csv\" ) then\n if @import.save!\n #check for virus\n if no_virus(@import.excel.path) then\n #If mime_obj is not csv only then create roo_instace\n unless mime_obj.include? \"csv\" then\n @roo = create_roo_instance(@import.excel.path,mime_obj)\n else\n #so, its a csv format\n @roo = \"csv format\"\n end\n #if the uploaded\n unless @roo == \"Upload correct excel format.\" then\n if @roo == \"csv format\" then\n lines = parse_csv_file(@import.excel.path)\n else\n lines = parse_excel_file_roo(@roo)\n end\n\n if lines.size > 0\n @import.processed = lines.size\n i = 1\n failed_to_upload = Array.new\n lines.each do |line|\n if valid_assign(params[:id])\n if valid_learners_excel_upload(line)\n else\n failed_to_upload << i\n end\n else\n flash[:learner_limit_exceeds] = \"You cannot assign more learners\"\n end\n i = i + 1\n end\n @import.save\n\n delete_csv(@import.excel.path)\n\n @import.destroy\n if params.include? 'from_assign_learners_page' then\n redirect_to(\"/courses/assign_learners/\" + assessment_id.to_s)\n else\n total_failed_to_upload = failed_to_upload.join(\",\")\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}?failed_to_upload=#{total_failed_to_upload}\")\n end\n else\n flash[:error] = \"CSV data processing failed.\"\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:virus_error] = \"The file is Infected with virus.\"\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:error] = 'CSV data import failed.'\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n end", "def import_students_and_tas(file)\n spreadsheet = open_spreadsheet(file)\n header = spreadsheet.row(1)\n (2..spreadsheet.last_row).each do |i|\n row = Hash[[header, spreadsheet.row(i)].transpose]\n user = User.find_by_email(row[\"email\"].downcase)\n # Create random password, requires members to respond to email before using the system.\n unless user\n o =[('a'..'z'),('A'..'Z'),('0'..'9')].map{|i| i.to_a}.flatten\n token = (0...12).map{ o[rand(o.length)] }.join\n user = User.new(:password => token, :password_confirmation => token)\n user.reset_password_token = token\n user.reset_password_sent_at = Time.now\n user.attributes = row.to_hash.slice(*User.accessible_attributes)\n user.role = 'student'\n user.save!\n Emailer.delay.signup_confirmation(user)\n end\n\n if row[\"role\"].downcase == 'student'\n StudentInCourse.create(:user_id => user.id, :course_id => id)\n\t\t\t\t\tgroup = row['group']\n\t\t\t\t\tunless(group.nil?)\n\t\t\t\t\t\tCourseGroup.create(:user_id => user.id, :course_id => id, :group => group)\n\t\t\t\t\tend\n elsif row[\"role\"].downcase == 'ta'\n TaForCourse.create(:user_id => user.id, :course_id => id)\n end\n end\n end", "def import_metadata_attributes\n if PerDistrict.new.does_students_export_include_rows_for_inactive_students?\n {}\n else\n { missing_from_last_export: false }\n end\n end", "def getValidListingsFromExcel\n # get all values the rows below the attribute row\n parse_args = {}\n @excel_attributes_raw.each{ |x_attr| parse_args[x_attr.to_sym] = x_attr }\n @listing_data = @import_file.parse(parse_args)\n\n # transform excel data\n data = []\n @listing_data.each_with_index do |row, j| \n data << {}\n\n row.each do |field|\n if j == 0\n data[j][field[0].to_s.downcase.gsub(\" \", \"_\").to_sym] = field[1].downcase.gsub(\" \", \"_\")\n else\n if field[1].class.to_s == \"String\"\n da = field[1].gsub(\"<html>\", \"\").gsub(\"</html>\", \"\")\n else\n da = field[1]\n end\n data[j][field[0].to_s.downcase.gsub(\" \", \"_\").to_sym] = da\n end\n end\n end\n @listing_data = data\n\n # delete columns which are not valid\n @listing_data[0].each_with_index do |header_row_element, index|\n unless @valid_attributes.map{|el| el[:name]}.include?(header_row_element[1])\n @listing_data.each_with_index do |data_rows, ii|\n data_rows.delete(header_row_element[0]) if ii > 0\n end\n @listing_data[0].delete(header_row_element[0])\n end\n end\n end", "def sheet_params\n params[:sheet].permit(:user_id)\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 editable_by user\n recordings.each do |recording|\n return true if recording.update_common_work_ids.include? user.id\n end\n return false\n end", "def check_unused_android(worksheet, from_row, to_row, target_directory, mark)\n puts \"\\nUNUSED ANDROID KEYS:\"\n for row in from_row..to_row\n key = worksheet[row, 1]\n unless key.blank?\n term = Term.new(key)\n if term.restriction == 'a' || term.restriction == nil\n if !term.is_comment?\n result = find_text_on_android_files(target_directory,term.keyword_android)\n if(result.length == 0)\n puts term.keyword_android\n if(mark)\n #modifiying key on spreadsheet by prepending [u] to mark key as unused\n worksheet[row, 1] = '[u]'+key\n end\n end\n else\n puts \"\\n==> Group:\"\n end\n end\n end\n end\n if(mark)\n worksheet.save()\n end\nend", "def before_merge_rpx_data( from_user, to_user )\n\t\t\t\n\t\t\tend", "def temporary_fetch\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=2114410807&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 1)\n\n # Assessment 2\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=1657164873&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 2)\n\n # Assessment 3\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=1278939598&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 3)\n\n # Assessment 4\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=397189839&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 4)\n\n # Assessment 5\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=13824931&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 5)\n\n return Item.list\nend", "def include_csv_in_email; include_csv_in_email? rescue include_csv_in_email; end", "def import_data_points(shared, row, tuples)\n rows = []\n tuples.each do |tuple|\n grade, assessment_period, assessment_key, row_key = tuple\n data_point = row[row_key]\n if data_point.nil? || ['?', 'n/a', 'absent'].include?(data_point.downcase)\n @missing_data_point +=1\n next\n end\n\n # TODO(kr) remove?\n if data_point.starts_with?('@') || data_point.downcase.include?('move')\n @missing_data_point_because_student_moved_school +=1\n next\n end\n\n @valid_data_points += 1\n rows << shared.merge({\n grade: grade,\n assessment_period: assessment_period,\n assessment_key: assessment_key,\n data_point: data_point\n })\n end\n rows\n end", "def update\n fname = @import.filename\n bs, _, ext = fname.rpartition(\".\")\n outfname = \"#{bs}-out.#{ext}\"\n\n book = RubyXL::Parser.parse(fname)\n master = book[\"Master\"]\n\n # Write out the meeting names unconditionally into Excel row 2 of the Master tab\n meetnamerow = master[1]\n col = 6\n Meeting.order(:date).each do |mtg|\n if master[2].nil? || master[2][col].nil? || master[2][col].value.blank?\n flash[:error] =\n \"Missing prepared column in Master sheet, row 3, column #{col + 1}\"\n end\n # Overwrite existing information with the information from the database\n fmt = if mtg.date.day == 1\n \"%B %Y \"\n else\n \"%-d %B %Y \"\n end\n master.add_or_chg(1, col, \"#{mtg.date.strftime(fmt)}#{mtg.meetingtype} Meeting\")\n meetnamerow[col].style_index = meetnamerow[col - 1].style_index if col > 6 # copy previous cell's style\n col += 1\n end\n\n # Go through the database Items in numerical order:\n # 1. In a row on the Master sheet, write out the item's properties and then its per-meeting statuses.\n # Handle missing meeting statuses including at the end of the line.\n # NOTE: With the current release of RubyXL (3.3.12), there's nothing we can do about the hyperlinks.\n # They are properties of the sheet, not the cell.\n # RubyXL::Reference.ref2ind(master.hyperlinks.first.ref.to_s)\n # master.relationship_container.find_by_rid(master.hyperlinks.first.r_id)\n # 2. Write three rows on the Minutes sheet.\n rowno = 2\n Item.order(:number).each do |item|\n # Change_contents spoils the shared string thing, so don't write unless you have to.\n # Anyhow, when writing, rows and columns might not exist.\n master.add_or_chg(rowno, 0, item.number.to_s) # Use this method to ensure that the row exists\n master.add_or_chg(rowno, 1, item.date.strftime(\"%d-%b-%Y\"))\n master.add_or_chg(rowno, 2, item.standard)\n master.add_or_chg(rowno, 3, item.clause)\n master.add_or_chg(rowno, 4, item.subject)\n master.add_or_chg(rowno, 5, item.draft)\n # There may not be a minutes entry corresponding to each meeting (=column), so keep a track of the item's current\n # status and use that where no minutes entry exists.\n current_sts = \"-\"\n colno = 6\n Meeting.order(:date).each do |mtg|\n min = item.minutes.where(\"minutes.meeting_id = ?\", mtg.id).first\n current_sts = min.minst.code if min&.minst\n if master[rowno][colno].nil? || master[rowno][colno].blank?\n flash[:error] =\n \"Missing prepared column in Master sheet, row #{rowno + 1}, column #{colno + 1}\"\n end\n master.add_or_chg(rowno, colno, current_sts)\n colno += 1\n end\n # Write hash signs on the remaining cells in the row, adding new cells to the right if necessary.\n # Issue #29: master[rowno].cells.count comes out as a big number (16384) for unused rows.\n # Calculate the last column number instead.\n # Also, if there are more meetings than the input spreadsheet allowed for, there won't be cells for each meeting.\n lastcolno = Meeting.count + 6\n (colno..lastcolno).each do |colcolno|\n if master[rowno][colcolno].nil?\n master.add_cell(rowno, colcolno, \"#\")\n else\n master[rowno][colcolno].chg_cell(\"#\")\n end\n end\n # Add a hash at the end of the row if there isn't one\n unless master[rowno][lastcolno + 1] && master[rowno][lastcolno + 1].value == \"#\"\n master.add_cell(rowno, lastcolno + 1, \"#\")\n end\n rowno += 1\n end\n # Fill the rest of the rows with hash signs. Make sure there's at least one row of hashes.\n make_master_hash_row(master, rowno) unless master[rowno] && master[rowno][1] && master[rowno][1].value == \"#\"\n ((rowno + 1)..(master.count - 1)).each do |r|\n make_master_hash_row(master, r)\n end\n\n minutes = book[\"Minutes\"]\n rowno = 1\n Item.order(:number).each do |item|\n minutes.add_or_chg(rowno, 1, item.number.to_s)\n colno = 3\n Meeting.order(:date).each do |mtg|\n min = item.minutes.where(\"minutes.meeting_id = ?\", mtg.id).first\n if min && !min.date.blank?\n datestr = min.date.strftime(\"%-d-%b-%Y\")\n minutes.add_or_chg(rowno, colno, datestr)\n else\n minutes.delete_cell(rowno, colno)\n end\n if min && !min.text.blank?\n minutes.add_or_chg(rowno + 1, colno, min.text)\n else\n minutes.delete_cell(rowno + 1, colno)\n end\n if min && (!min.date.blank? || !min.text.blank?)\n minutes.add_or_chg(rowno + 2, colno, \"#\")\n else\n minutes.delete_cell(rowno + 2, colno)\n end\n colno += 1\n end\n rowno += 3\n end\n # Delete the rest of the rows, making sure the last row has a single '#' in the number column.\n # Note that delete_row pushes cells up, so we delete the same numbered row repeatedly.\n (rowno..(minutes.count - 1)).each { |_r| minutes.delete_row(rowno) }\n minutes.add_cell(rowno, 0, \"\")\n minutes.add_cell(rowno, 1, \"#\")\n\n book.write(outfname)\n\n respond_to do |format|\n format.html do\n response.headers[\"Content-Length\"] = File.size(outfname).to_s\n send_file(outfname, type: @import.content_type, x_sendfile: true)\n return\n end\n format.json { render :show, status: :ok, location: @import }\n end\n end", "def create_games_excel\r\n\r\n if (params[:msg].nil?)\r\n\r\n @student_group = StudentGroup.find(params[:id])\r\n #@book = Spreadsheet.open 'C:/Users/Rushabh Hathi/Desktop/Dialogue1.0/public/Files/abc.txt'\r\n @book = Spreadsheet::Workbook.new\r\n sheet1 = @book.create_worksheet\r\n @rolelist=Role.all(:conditions=>['case_study_id=?', @student_group.case_study_id])\r\n i=1\r\n\r\n# #here role name is added for the list to be populated\r\n# @rolelist.each do |r|\r\n# sheet1[0, i]=r.name\r\n# i=i+1\r\n# end\r\n\r\n @studentgroupuserlist=StudentGroupUser.all(:conditions=>['student_group_id=?', params[:id]])\r\n @studentlist= Array.new\r\n @unallocated_student= Array.new\r\n @studentgroupuserlist.each do |s|\r\n @studentlist << User.find(s.user_id)\r\n end\r\n\r\n #here the dynamic data from student group gets populated\r\n i=1\r\n sheet1[0, 0]=\"Student ID\"\r\n sheet1[0, 1]=\"Student Name\"\r\n sheet1[0, 2]=\"Role Name\"\r\n\r\n\r\n @studentlist.each do |s|\r\n\r\n sheet1[i, 0]=s.id\r\n sheet1[i, 1]=s.first_name+s.last_name\r\n sheet1[i, 2]= \" \"\r\n i=i+1\r\n @book.write \"#{Rails.root}/public/Files/Game_Creation.xls\"\r\n\r\n\r\n end\r\n\r\n end\r\n end", "def perform(user_id, legacy_sheet_user_id)\n user = User.find(user_id)\n legacy_sheet_user = LegacySheetUser.find(legacy_sheet_user_id)\n user.legacy_sheet_user = legacy_sheet_user\n if user.save\n legacy_sheet_user.check_ins.where(legacy: true).update_all(user_id: user.id)\n backfill_awarded_badges(user)\n end\n end", "def process_data()\n \tSpreadsheet.client_encoding='UTF-8'\n\tbook=Spreadsheet::Workbook.new\n\tsheet = book.create_worksheet\n\tsheet.row(0).push 'Link Text','Link Url','Description' #For including headers to the spreadsheet.\n\n\tmain_content=Array.new\n\ts=''\n\ts1=''\n\tvalue=0\n\trow_count=1\n\titerate=@range1.to_i\n\twhile iterate <= @range2.to_i\n \t\tif iterate==1\n \t\t\turl='http://www.google.co.in/search?q='+@query_string.to_s\n \t\t\tlink_count=11\n \t\telsif iterate>1\n \t\t\tvalue=(iterate-1)*10\n \t\t\tlink_count=10\n \t\t\turl='http://www.google.co.in/search?q='+@query_string.to_s+'&start='+value.to_s\n \t\tend\n \t\tdoc = Pismo::Document.new(url)\n \t\tcontent=doc.body.to_s\n \t\tmain_content=content.split('*',11)\n \t\ttmp=1\n \t\twhile tmp <= link_count\n \t\t\ts=main_content[tmp]\n \t\t\ts1=s.lines.map(&:chomp) #s1=s.split(/[\\n]+/)\n \t\t\t#print \"Link #{j} : \" + s1[1].to_s + \"\\nUrl #{j} : \" + s1[2].to_s + \"\\nDesc #{j} : \" + s1[3].to_s + \"\\n\"\n \t\t\tsheet.row(row_count).push s1[1].to_s,s1[2].to_s,s1[3].to_s\n \t\t\tbook.write('/home/chandrasekar/training-ruby/shekar/18_September/website_link.xls')\n \t\t\trow_count+=1\n \t\t\ttmp+=1\n \t\tend\n \t\titerate+=1\n\tend\n end", "def import_from_excel\n file = params[:file] \n begin\n # Retreive the extension of the file\n file_ext = File.extname(file.original_filename) \n raise \"Unknown file type: #{file.original_filename}\" unless [\".xls\", \".xlsx\"].include?(file_ext)\n spreadsheet = (file_ext == \".xls\") ? Roo::Excel.new(file.path) : Roo::Excelx.new(file.path)\n header = spreadsheet.row(1)\n \n (2..spreadsheet.last_row).each do |i|\n \n ci = spreadsheet.row(i)[0].to_i \n \n usu = Usuario.find_by(ci: ci)\n \n if usu != nil\n usu.salario = spreadsheet.row(i)[1]\n usu.save\n end\n end\n flash[:notice] = \"Salarios importados correctamente\"\n redirect_to usuarios_path \n rescue Exception => e\n flash[:notice] = \"No se ha podido importar el archivo, por favor verifique el formato del mismo y vuelva a intentarlo\"\n redirect_to usuarios_path \n end\n end", "def import_users\n @file = params[:upload]\n return render_error :upload unless @file && @file.try(:content_type)\n\n if @file.content_type =~ /^text\\/csv|^application\\/vnd.ms-excel/\n importer = Importing::Importer.new(@file.read)\n\n if importer.failed?\n # if failed\n Rails.logger.warn \"*** Import failed: #{importer.error.message}\\nBacktrace: #{importer.error.backtrace[0,5].join(\"\\n\")}\"\n render_error :import\n else\n # \"full_name\", \"abbreviation\", \"email\", \"status\", \"staff_number\", \"group\"\n @records = importer.results\n # puts @records.inspect\n\n @records.reject! { |c| c.blank? }\n\n count = 0\n\n require_headers = [\"full_name\", \"abbreviation\", \"email\", \"status\", \"staff_number\", \"group\"]\n\n headers = importer.headers\n\n if @records.length > 0\n headers = @records.first.keys\n end\n\n if headers.nil?\n render_error :header\n return\n end\n\n # headers.each do |e|\n # unless require_headers.index(e)\n # render_error :header\n # return\n # end\n # end\n\n result = true\n headers.each do |h|\n result = require_headers.include?(h.to_s)\n unless result\n render_error :header\n return\n end\n end\n\n @records.each do |user|\n next if user.blank?\n\n puts user.inspect\n\n created_user = User.new({\n full_name: user[:full_name],\n abbreviation: user[:abbreviation],\n email: user[:email],\n username: user[:abbreviation],\n password: \"1qazxsw2\",\n password_confirmation: \"1qazxsw2\",\n status: user[:status],\n staff_number: user[:staff_number],\n organization_id: current_user.organization_id\n })\n group_name = user[:group].downcase\n group_id = UserGroup.find_by_sql(\"Select * from user_groups where lower(name) ='#{group_name}'\")[0].id\n \n\n created_user.user_group_ids = group_id\n\n # created_user.skip_confirmation!\n count += 1 if created_user.save\n puts created_user.errors.inspect\n end\n \n flash[:notice] = \"There are #{count} users have been created.\"\n redirect_to organization_users_path(current_user.organization_id)\n end\n else\n render_error :content_type, :type => @file.content_type\n end\n end", "def updateColumns ws,srcColumn,srcHash,destColumn,writeNew = false\r\n row = 1\r\n keys = srcHash.keys\r\n #as long as the cell content is not nill\r\n while value = ws.cells(row,srcColumn).value\r\n #check if the contents of the srcColumn is present in the given hash\r\n if keys.include? value\r\n ws.cells(row,destColumn).value = srcHash[value]\r\n\t\t\t#Delete the entry , after writing into the excel\r\n\t\t\tsrcHash.delete value\r\n end\r\n\t\trow = row + 1\r\n end \r\n\t#check if new values should be written\r\n\tsrcHash.clear unless writeNew\r\n\r\n\t#Write the remaining entries in the excel sheet\r\n\tsrcHash.each do |key, value|\r\n\t\t#Since the key dint exist originally, write that as well\r\n\t\tws.cells(row,srcColumn).value = key\r\n\t\tws.cells(row,destColumn).value = srcHash[key]\r\n\t\trow = row + 1\r\n\tend\r\n \r\nend", "def process_updated_users\n CSV.foreach(get_canvas_user_report_file, :headers => :first_row) do |canvas_user|\n uid = canvas_user['login_id']\n\n # process only if found in campus data\n if @active_sis_users[uid]\n active_campus_user = canvas_user_from_campus_row(@active_sis_users[uid])\n\n # if SIS User ID has changed\n if canvas_user['user_id'] != active_campus_user['user_id']\n @sis_user_id_updates[\"sis_login_id:#{canvas_user['login_id']}\"] = active_campus_user['user_id']\n end\n\n unless Canvas::MaintainUsers.provisioned_account_eq_sis_account?(canvas_user, active_campus_user)\n logger.debug(\"Updating user #{canvas_user} with #{active_campus_user}\")\n add_user_to_import(active_campus_user)\n end\n @active_sis_users.delete(uid)\n end\n end\n end", "def filter_data_columns_excel(iterator, options = {})\n retval = false\n\n if iterator == nil\n return []\n end\n\n if !options.include?(:document)\n puts \"WARN: filter_data_columns_excel() needs a document in the option param.\"\n return []\n end\n\n document = options[:document]\n i = 1\n iterator.each do |sheet|\n message, data = filter_data_columns_csv(sheet)\n primary_keys = get_data_colnames(data) #For search\n\n if (data != nil and !data.empty?) #create a document for each sheet\n new_doc = Document.new(:name => \"#{document.name}_sheet_#{i.to_s}\")\n new_doc.collection = document.collection\n new_doc.user = user\n new_doc.stuffing_data = data #save data to couch\n new_doc.stuffing_primary_keys = primary_keys\n new_doc.stuffing_metadata = [{\"HatchFilter\" => \"Excel (pre-defined)\"}]\n new_doc.validated = true\n new_doc.save\n retval = true #We parsed a sheet successfully.\n end\n\n i += 1\n end\n message = \"Excel validation finished.\"\n\n return [message, retval]\n end", "def loadtest2\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n#-----------------------------------------------------------------\n# Create a new spreadsheet -works and tested\n #request_body = Google::Apis::SheetsV4::Spreadsheet.new\n #response = service.create_spreadsheet(request_body)\n #ss = response\n #spreadsheet_id = ss.spreadsheet_id\n#-----------------------------------------------------------------\n\n\n#-----------------------------------------------------------------\n# Use an existing previously created spreadsheet\n# Only need the id to make use of this.\n spreadsheet_id = '1VHNfTl0Qxok1ZgBD2Rwby-dqxihgSspA0InqS5dTXNI'\n#-----------------------------------------------------------------\n sheet_name = \"Sheet1\"\n\n# ************ update spreadsheet title ************************\n# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate \n spreadsheet_title = \"Testing Updates from BIT Server\"\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myussp = {\"properties\": {\"title\": spreadsheet_title}, \"fields\": \"*\" }\n request_body.requests = [{\"update_spreadsheet_properties\": myussp }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n\n\n\n\n# ************ delete all cells (rows) in a sheet ****************************\n# https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/SheetsV4/Request#delete_range-instance_method \n \tgridrange = {\n \t sheet_id: 0,\n \t start_row_index: 0,\n# \t end_row_index: 1,\n \t start_column_index: 0,\n# \t end_column_index: 2\n \t }\n requests = []\n requests.push(\n {\n delete_range:{\n range: gridrange,\n shift_dimension: \"ROWS\"\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n# ************ update values using update_spreadsheet_value ****************************\n# doco: https://www.rubydoc.info/github/google/google-api-ruby-client/Google%2FApis%2FSheetsV4%2FSheetsService%3Aupdate_spreadsheet_value \n range = \"#{sheet_name}!A1:B1\"\n request_body = Google::Apis::SheetsV4::ValueRange.new\n request_body.values = [[\"update_spreadsheet_value\",\"test data - this row will get a background colour\"]]\n request_body.major_dimension = \"ROWS\"\n result = service.update_spreadsheet_value(spreadsheet_id, range, request_body, \n {value_input_option: 'USER_ENTERED'})\n logger.debug \"update_spreadsheet_value completed\"\n\n# ************ update values using update_spreadsheet_value ****************************\n range = \"#{sheet_name}!A2:B3\"\n mydata = [\n {\n range: range,\n majorDimension: 'ROWS',\n values: [\n [\"spreadsheet_values_batchUpdate\", \"test data\"],\n [\"spreadsheet_values_batchUpdate\", \"third row\"]\n ]\n }\n ]\n request_body = Google::Apis::SheetsV4::BatchUpdateValuesRequest.new\n request_body.value_input_option = 'USER_ENTERED'\n request_body.data = mydata\n result = service.batch_update_values(spreadsheet_id, request_body, {})\n\n# ******** update background colours using batch_update_spreadsheet ********\n \tgridrange = {\n \t sheet_id: 0,\n \t start_row_index: 0,\n \t end_row_index: 1,\n \t start_column_index: 0,\n \t end_column_index: 2\n \t }\n requests = []\n requests.push(\n {\n repeat_cell: {\n \t range: gridrange,\n cell:\n {\n \t user_entered_format:\n \t {\n \t\t text_format: {bold: true},\n \t\t background_color:\n \t\t {\n \t\t\t red: 0.0,\n \t\t\t green: 1.0,\n \t\t\t blue: 0.0\n \t\t }\n \t }\n \t },\n fields: \"user_entered_format(background_color, text_format.bold)\"\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n# ******** autorezise columns using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n requests = []\n requests.push(\n {\n auto_resize_dimensions: {\n dimensions:\n {\n \t dimension: \"COLUMNS\",\n \t sheet_id: 0,\n end_index: 2,\n \t start_index: 0\n \t },\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n# ******** adjust columns width using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n requests = []\n requests.push(\n {\n update_dimension_properties: {\n range:\n {\n \t dimension: \"COLUMNS\",\n \t sheet_id: 0,\n end_index: 2,\n \t start_index: 0\n \t },\n \t properties: {\n \t pixel_size: 160\n \t },\n \t fields: \"pixelSize\"\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n end", "def googleroster\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n#-----------------------------------------------------------------\n# Create a new spreadsheet -works and tested\n #request_body = Google::Apis::SheetsV4::Spreadsheet.new\n #response = service.create_spreadsheet(request_body)\n #ss = response\n #spreadsheet_id = ss.spreadsheet_id\n#-----------------------------------------------------------------\n\n#-----------------------------------------------------------------\n# Use an existing previously created spreadsheet\n# Only need the id to make use of this.\n #spreadsheet_id = '1VHNfTl0Qxok1ZgBD2Rwby-dqxihgSspA0InqS5dTXNI'\n spreadsheet_id = '1mfS0V2IRS1x18otIta1kOdfFvRMu6NltEe-edn7MZMc'\n#-----------------------------------------------------------------\n\n#-----------------------------------------------------------------\n# Use the spreadsheet configured in user profiles\n# = Roster Google Spreadsheet URL \n spreadsheet_id = current_user[:rosterssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n\n # Get URL of spreadsheet\n response = service.get_spreadsheet(spreadsheet_id)\n @spreadsheet_url = response.spreadsheet_url\n\n # Sheet we are working on.\n sheet_name = \"Sheet1\"\n sheet_id = 0\n\n #this function converts spreadsheet indices to column name\n # examples: e[0] => A; e[30] => AE \n e =->n{a=?A;n.times{a.next!};a} \n\n# ************ update spreadsheet title ************************\n# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate\n spreadsheet_title = \"Google Roster\" \n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myussp = {\"properties\": {\"title\": spreadsheet_title}, \"fields\": \"*\" }\n request_body.requests = [{\"update_spreadsheet_properties\": myussp }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n\n# ************ add sheet ************************\n googleAddSheet = lambda{ |mytitle, mysheetproperties|\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myas = {\"properties\": {\"title\": mytitle}}\n request_body.requests = [{\"add_sheet\": myas }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n mysheetproperties.push({'index' => result.replies[0].add_sheet.properties.index,\n 'sheet_id' => result.replies[0].add_sheet.properties.sheet_id,\n 'title' => result.replies[0].add_sheet.properties.title})\n }\n \n# ************ delete sheets ************************\n googleSheetDelete = lambda{\n result = service.get_spreadsheet(spreadsheet_id)\n mysheets = result.sheets\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n mysheets.each_with_index do |o, i|\n next if i == 0\n request_body.requests == nil ?\n request_body.requests = [{\"delete_sheet\": {\"sheet_id\": o.properties.sheet_id}}] :\n request_body.requests.push({\"delete_sheet\": {\"sheet_id\": o.properties.sheet_id}})\n end\n unless request_body.requests == nil\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n end\n }\n\n# ************ get spreadsheet properties ************************\n googleSheetProperties = lambda{\n result = service.get_spreadsheet(spreadsheet_id)\n mysheets = result.sheets\n mysheetproperties = mysheets.map{|p| {'index' => p.properties.index, \n 'sheet_id' => p.properties.sheet_id,\n 'title' => p.properties.title } }\n \n }\n\n# ************ update sheet title ************************\n# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate\n googleSetSheetTitle = lambda{ |mytitle|\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myusp = {\"properties\": {\"title\": mytitle }, \"fields\": \"title\" }\n request_body.requests = [{\"update_sheet_properties\": myusp }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n }\n\n# ************ delete all cells (rows) in a sheet ****************************\n# https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/SheetsV4/Request#delete_range-instance_method \n googleClearSheet = lambda{|passed_sheet_id|\n requests = [{ delete_range:{\n range: {sheet_id: passed_sheet_id, start_row_index: 0, start_column_index: 0 },\n shift_dimension: \"ROWS\"}}]\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n }\n \n\n# ******** set vertical alignment using batch_update_spreadsheet ********\n # googleVertAlignAll.call(palign \"TOP | MIDDLE | BOTTOM\")\n googleVertAlignAll = lambda{ |passed_sheet_id, palign|\n requests = [{repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: 0,\n \t start_column_index: 0\n \t },\n cell: {user_entered_format: {vertical_alignment: palign} },\n fields: \"user_entered_format(vertical_alignment)\"\n }\n }]\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n }\n\n# ****************** calls batch_update_spreadsheet ******************\n # googlebatchdataitem.call(passed_items [googlebackgroundcolouritem, ...])\n googleBatchUpdate = lambda{|passeditems|\n if passeditems.count > 0\n body = {requests: passeditems}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n end\n }\n\n# ******** update background colours using batch_update_spreadsheet ********\n # googleBGColourItem.call(rowStart, colStart, numberOfRows, numberOfCols,\n # colour[red_value, geen_value, blue_value])\n googleBGColourItem = lambda{|passed_sheet_id, rs, cs, nr, nc, pcolour|\n {repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t end_row_index: rs - 1 + nr,\n \t start_column_index: cs - 1,\n \t end_column_index: cs - 1 + nc},\n cell:{user_entered_format:\n \t {background_color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}}},\n fields: \"user_entered_format(background_color)\"}}}\n \n# ******** set vertical alignment using batch_update_spreadsheet ********\n # googleVertAlign.call(rowStart, colStart, numberOfRows, numberOfCols,\n # palign \"TOP | MIDDLE | BOTTOM\")\n googleVertAlign = lambda{|passed_sheet_id, rs, cs, nr, nc, palign|\n pad = 5\n result = {repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t start_column_index: cs - 1 },\n cell:{user_entered_format: {vertical_alignment: palign,\n padding: {\n top: pad,\n right: pad,\n bottom: pad,\n left: pad\n }\n } \n },\n fields: \"user_entered_format(vertical_alignment,padding)\"\n }\n }\n if nr != nil then\n result[:repeat_cell][:range][:end_row_index] = rs - 1 + nr \n end\n if nc != nil then\n result[:repeat_cell][:range][:end_column_index] = cs - 1 + nc \n end\n return result\n }\n\n# ******** set wrap text using batch_update_spreadsheet ********\n # googleWrapText.call(rowStart, colStart, numberOfRows, numberOfCols,\n # wrap \"OVERFLOW_CELL | LEGACY_WRAP | CLIP | WRAP\")\n googleWrapText = lambda{|passed_sheet_id, rs, cs, nr, nc, pwrap|\n result = {repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t start_column_index: cs - 1 },\n cell:{user_entered_format: {wrap_strategy: pwrap} },\n fields: \"user_entered_format(wrap_strategy)\"\n }\n }\n if nr != nil then\n result[:repeat_cell][:range][:end_row_index] = rs - 1 + nr \n end\n if nc != nil then\n result[:repeat_cell][:range][:end_column_index] = cs - 1 + nc \n end\n return result\n }\n\n# ******** update borders using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting\n # googleBorder.call(sheet_id, rowStart, colStart, numberOfRows, numberOfCols,\n # {left: color, right: .., top: .., bottom: ..}, width)\n googleBorder = lambda{|passed_sheet_id, rs, cs, nr, nc, pcolour, passedStyle |\n {\n update_borders: {\n \t range: { sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t end_row_index: rs - 1 + nr,\n \t start_column_index: cs - 1,\n \t end_column_index: cs - 1 + nc },\n top: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n left: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n right: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n bottom: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n }\n }\n }\n\n# ******** update borders using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting\n # googleBorder.call(sheet_id, rowStart, colStart, numberOfRows, numberOfCols,\n # {left: color, right: .., top: .., bottom: ..}, width)\n googleRightBorder = lambda{|passed_sheet_id, rs, cs, nr, nc, pcolour, passedStyle |\n {\n update_borders: {\n \t range: { sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t end_row_index: rs - 1 + nr,\n \t start_column_index: cs - 1,\n \t end_column_index: cs - 1 + nc },\n right: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}}\n }\n }\n }\n\n# ******** adjust columns width using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n\n # googlecolwidthitem.call(colStart, numberOfCols,\n # width_pixels)\n googleColWidthItem = lambda{|passed_sheet_id, cs, nc, passedpw|\n {\n update_dimension_properties: {\n range: { dimension: \"COLUMNS\",\n \t sheet_id: passed_sheet_id,\n \t start_index: cs - 1,\n end_index: cs - 1 + nc },\n \t properties: { pixel_size: passedpw },\n \t fields: \"pixelSize\"\n }\n }\n }\n\n# ******** autoresize columns using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n\n # googlecolautowidthitem.call(passed_sheet_id, colStart, numberOfCols)\n googleColAutowidthItem = lambda{|passed_sheet_id, cs, nc|\n {\n auto_resize_dimensions: { dimensions: { dimension: \"COLUMNS\",\n \t sheet_id: passed_sheet_id,\n \t start_index: cs - 1,\n end_index: cs - 1 + nc }\n }\n }\n }\n \n# ******** merge cells using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting \n # googleMergeCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols)\n googleMergeCells = lambda{|passed_sheet_id, rs, nr, cs, nc|\n {\n merge_cells: { range: { sheet_id: passed_sheet_id,\n start_row_index: rs - 1,\n end_row_index: rs - 1 + nr,\n start_column_index: cs - 1,\n end_column_index: cs - 1 + nc },\n merge_type: \"MERGE_ALL\"\n }\n }\n }\n\n# ******** format header cells using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting \n # googlefomratCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols, fontSize)\n googleFormatCells = lambda{|passed_sheet_id, rs, nr, cs, nc, fs|\n {\n repeat_cell: { range: { sheet_id: passed_sheet_id,\n start_row_index: rs - 1,\n end_row_index: rs - 1 + nr,\n start_column_index: cs - 1,\n end_column_index: cs - 1 + nc },\n cell: { user_entered_format: {\n horizontal_alignment: \"CENTER\",\n text_format: {\n font_size: fs,\n bold: true\n }\n }\n },\n fields: \"userEnteredFormat(textFormat, horizontalAlignment)\"\n }\n }\n }\n\n# ************ update values using update_spreadsheet_value ****************************\n# doco: https://www.rubydoc.info/github/google/google-api-ruby-client/Google%2FApis%2FSheetsV4%2FSheetsService%3Aupdate_spreadsheet_value \n# call using\n\n# googlevalues.call(rowStartIndex, columnStartIndex, numberOfRows, numberOfColumns, values[[]])\n# Indexes start at 1 for both rows and columns\n googleValues = lambda{|rs, cs, nr, nc, values| \n range = \"#{sheet_name}!\" + e[cs - 1] + rs.to_s + \":\" +\n e[cs + nc - 1] + (rs + nr).to_s\n request_body = Google::Apis::SheetsV4::ValueRange.new\n request_body.values = values\n request_body.major_dimension = \"ROWS\"\n service.update_spreadsheet_value(spreadsheet_id, range, request_body, \n {value_input_option: 'USER_ENTERED'})\n }\n \n# ************ update values using batch_update_values ****************************\n # googlebatchdataitem.call(rowStart, colStart, numberOfRows, numberOfCols,\n # values[[]])\n googleBatchDataItem = lambda{|passed_sheet_name, rs, cs, nr, nc, values|\n range = \"#{passed_sheet_name}!\" + e[cs - 1] + rs.to_s + \":\" +\n e[cs + nc - 1] + (rs + nr).to_s\n {\n range: range,\n majorDimension: 'ROWS',\n values: values\n }\n }\n\n# ************ execute batch update of values - [data items] ****************************\n # googlebatchdataitem.call(spreadsheet_id, \n # passed in batch data [gppg;ebatcjdataote, ...])\n googleBatchDataUpdate = lambda{|ss_id, dataitems |\n if dataitems.count > 0\n request_body = Google::Apis::SheetsV4::BatchUpdateValuesRequest.new\n request_body.value_input_option = 'USER_ENTERED'\n request_body.data = dataitems\n service.batch_update_values(ss_id, request_body, {})\n end\n }\n\n# ************ text format run using batch_update_values ****************************\n # googlebatchTextFormatRunItem.call(rowStart, colStart, \n # text, breakPointToChangeFormat[])\n googleTextFormatRun = lambda{|passed_sheet_id, rs, cs, myText, myBreaks|\n result = \n {\n update_cells: {\n \t start: {sheet_id: passed_sheet_id,\n \t row_index: rs - 1,\n \t column_index: cs - 1\n \t },\n rows: [ \n { values: [ \n {\n user_entered_value: {\n string_value: myText\n },\n user_entered_format: {\n text_format: {\n fontFamily: \"Arial\"\n }\n },\n text_format_runs: [\n {\n start_index: myBreaks[0],\n format: {\n bold: true,\n font_size: 10\n }\n }\n ]\n }\n ]\n }\n \n ],\n fields: \"userEnteredValue, userEnteredFormat.textFormat.bold, textFormatRuns.format.(bold, fontSize, fontFamily)\"\n }\n }\n if myBreaks[1] < myText.length then\n secondRun = {\n start_index: myBreaks[1],\n format: {\n bold: false,\n font_size: 10\n }\n }\n result[:update_cells][:rows][0][:values][0][:text_format_runs].push(secondRun)\n end\n return result\n }\n \n \n# ************ batch update of data items ****************************\n # googlebatchdataitem.call(spreadsheet_id, \n # passed in batch data [gppg;ebatcjdataote, ...])\n googleBatchDataUpdate = lambda{|ss_id, dataitems |\n if dataitems.count > 0\n request_body = Google::Apis::SheetsV4::BatchUpdateValuesRequest.new\n request_body.value_input_option = 'USER_ENTERED'\n request_body.data = dataitems\n service.batch_update_values(ss_id, request_body, {})\n end\n }\n\n#-------- To test or not to test ------------------------------\ntesting = false # true or false\nif testing then\n\n#--------------------- Test Data -------------------------------\n# Clear the sheet\n googleClearSheet.call(sheet_id)\n \n# Some test formatting\n batchitems = []\n\n batchitems.push(googleBGColourItem.call(sheet_id, 1,1,1,2,[0,1,0]))\n batchitems.push(googleBGColourItem.call(sheet_id, 6,1,1,2,[1,0,0]))\n batchitems.push(googleBGColourItem.call(sheet_id, 7,1,1,2,[0,0,1]))\n\n batchitems.push(googleBorder.call(sheet_id, 2,1,2,2, [0,0,0], \"SOLID_MEDIUM\"))\n \n batchitems.push(googleVertAlign.call(sheet_id,2,1,2,2, \"TOP\"))\n\n batchitems.push(googleWrapText.call(sheet_id, 2,1,2,2, \"WRAP\"))\n\n batchitems.push(googleColWidthItem.call(sheet_id, 1,3,160))\n \n googleBatchUpdate.call(batchitems) \n\n# Some test cellvalues - individual update\n myvalues = [[\"update_spreadsheet_value\",\"test data - this row will get a background colour\"]]\n googleValues.call(1, 1, 1, 2, myvalues)\n\n# Some test value data - batch update\n mydata = []\n mydata.push(googleBatchDataItem.call(sheet_name,2,1,2,2,\n [\n [\"spreadsheet_values_batchUpdate\", \"test data\"],\n [\"spreadsheet_values_batchUpdate\", \"third row\"]\n ])\n )\n mydata.push(googleBatchDataItem.call(sheet_name,6,1,2,2,\n [\n [\"spreadsheet_values_batchUpdate2\", \"test data\"],\n [\"spreadsheet_values_batchUpdate2\", \"seventh row\"]\n ])\n )\n googleBatchDataUpdate.call(spreadsheet_id, mydata)\n\n #Note: need to do values first so autoformat works.\n batchitems = [] # reset\n batchitems.push(googleColAutowidthItem.call(sheet_id, 1, 1))\n googleBatchUpdate.call(batchitems) \n \n logger.debug \"about to try out googleTextFormatRun\"\n batchitems = []\n batchitems.push(googleTextFormatRun.call(sheet_id, 10,2, \"123456789\\n1234567890123456789\", [0,10]))\n googleBatchUpdate.call(batchitems) \n logger.debug \"done googleTextFormatRun\"\n\nelse # Not to test.\n\n# let does some processing - writing rosters to google sheets.\n #@sf = 5 # number of significant figures in dom ids for lesson,tutor, etc.\n\n #mystartdate = current_user.daystart\n #myenddate = current_user.daystart + current_user.daydur.days\n @options = Hash.new\n #@options[:startdate] = current_user.daystart\n #@options[:enddate] = current_user.daystart + current_user.daydur.days\n @options[:startdate] = current_user.rosterstart\n @options[:enddate] = current_user.rosterstart + current_user.rosterdays.days\n \n #*****************************************************************\n # Set these to control what is displayed in the roster\n \n @tutorstatusforroster = [\"scheduled\", \"dealt\", \"confirmed\", \"attended\"]\n @studentstatusforroster = [\"scheduled\", \"dealt\", \"attended\"]\n \n #*****************************************************************\n \n # call the library in controllers/concerns/calendarutilities.rb\n #@cal = calendar_read_display2(@sf, mystartdate, myenddate)\n #calendar_read_display1f(sf, mystartdate, myenddate, options)\n \n # @tutors and @students are used by the cal\n @tutors = Tutor\n .where.not(status: \"inactive\")\n .order('pname')\n @students = Student\n .where.not(status: \"inactive\")\n .order('pname')\n \n #@cal = calendar_read_display1f(@sf, mystartdate, myenddate, {})\n #@cal = calendar_read_display1f(@sf, @options)\n @cal = calendar_read_display1f(@options)\n # Clear the first sheet - the rest are deleted.\n googleClearSheet.call(sheet_id)\n #googleVertAlignAll.call(\"TOP\")\n\n # kinds will govern the background colours for tutors and students.\n kindcolours = Hash.new\n=begin\n kindcolours = {\n 'tutor-kind-training' => [244, 164, 96],\n 'tutor-kind-called' => [135, 206, 250],\n 'tutor-kind-standard' => [0, 250, 154],\n 'tutor-kind-relief' => [245, 222, 179],\n 'tutor-kind-BFL' => [255, 255, 0],\n 'tutor-kind-onCall' => [0, 255, 255],\n 'tutor-kind-onSetup' => [234, 209, 220],\n 'student-kind-free' => [0, 255, 0],\n 'student-kind-first' => [182, 215, 168],\n 'student-kind-catchup' => [173, 216, 230],\n 'student-kind-fortnightly' => [70, 130, 180], \n 'student-kind-onetoone' => [250, 128, 114],\n 'student-kind-standard' => [0, 250, 154],\n 'tutor-kind-' => [255, 255, 255],\n 'tutor-student-' => [255, 255, 255]\n }\n=end\n kindcolours.default = [255, 255, 255] # result if called with missing key\n \n # clear unused sheets & get sheet properties\n googleSheetDelete.call\n # sets mysheetproperties = [{'index', 'sheet_id', 'title'}, ..]\n mysheetproperties = googleSheetProperties.call \n\n # will increment to 1 on stepping into loops => 1..n\n # Note: both rows and column indexes spreadsheets start at 1\n # Following counters used to track loactions in the spreadsheet\n timeData = ''\n baseSiteRow = 1 \n baseSlotRowInSite = 1\n baseLessonRowInSlot = 0\n currentTutorRowInLesson = 0\n currentStudentRowInLesson = 0\n currentStudentInLesson = 0\n maxPersonRowInAnySlot = 0\n maxPersonRowInAnySlot = 0\n currentCol = 1\n currentRow = 1\n baseSiteRow = 1 # first site \n baseSiteRowAll = 1 # for the 'all' tab \n locationindex = 0 # index into the sites\n \n # to compress or not - remove unused days\n @compress = false # can be true or false\n\n # have an all tab in google sheets to show all sites in that page\n # this is for tutors to seach for their name across all sites.\n # We still have a separate tab for each site\n googleSetSheetTitle.call(\"All\")\n mysheetproperties[locationindex]['title'] = \"All\"\n sheet_name_all = mysheetproperties[locationindex]['title']\n sheet_id_all = mysheetproperties[locationindex]['sheet_id']\n ###----------------------------------------------------------------------\n ###------------------- step through the sites ---------------------------\n ###----------------------------------------------------------------------\n @cal.each do |location, calLocation| # step through sites\n if @compress # remove days with no valid slot for this site\n usedColumns = calLocation[0][0][\"days\"].keys\n usedColumnsIndex = [0]\n for i in 1..(calLocation[0].length-1)\n if usedColumns.include?(calLocation[0][i][\"value\"]) then\n usedColumnsIndex.push(i)\n end\n end \n end\n\n mydata = [] # google batch data writter at end of processing a site\n myformat = []\n\n # make separate sheet entry for each site\n baseSiteRow = 1 # reset when new sheet for each site.\n # baseSiteRowAll continues across all sites.\n if locationindex == 0 # set up the all tab - contains all sites\n # googleSetSheetTitle.call(location)\n # mysheetproperties[locationindex]['title'] = location\n # General formatting for the 'all' sheet - done once\n myformat.push(googleVertAlign.call(sheet_id_all, 1, 1, nil, nil, \"TOP\"))\n myformat.push(googleWrapText.call(sheet_id_all, 1, 1, nil, nil, \"WRAP\"))\n myformat.push(googleColWidthItem.call(sheet_id_all, 1,100,200))\n myformat.push(googleColWidthItem.call(sheet_id_all, 1,1,0))\n end\n # now have a sheet for each site.\n mysheetproperties = googleAddSheet.call(location, mysheetproperties) # add a sheet\n # mysheets = result.sheets\n # mysheetproperties = mysheets.map{|o| {'index' => o.properties.index, \n # 'sheet_id' => o.properties.sheet_id,\n # 'title' => o.properties.title } }\n locationindex += 1\n sheet_name = mysheetproperties[locationindex]['title']\n sheet_id = mysheetproperties[locationindex]['sheet_id']\n\n # This function formats a lesson row\n # myformal and mydata are global to this google roster function\n # we are passing in values to ensure they are in the correct context.\n formatLesson = lambda { |baseLessonRowInSlot, baseSlotRowInSite, baseSiteRow, baseSiteRowAll, currentCol, maxPersonRowInLesson|\n borderRowStart = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n borderRowStartAll = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n borderColStart = currentCol\n borderRows = maxPersonRowInLesson\n borderCols = 4 # one tutor col and 2 student cols + lesson commment col.\n # merge the cells within the comment section of a single session\n # googleMergeCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols)\n myformat.push(googleMergeCells.call(sheet_id, borderRowStart, borderRows,\n borderColStart + borderCols - 1, 1))\n myformat.push(googleMergeCells.call(sheet_id_all, borderRowStartAll, borderRows,\n borderColStart + borderCols - 1, 1))\n myformat.push(googleBorder.call(sheet_id, borderRowStart, borderColStart, borderRows, borderCols, [0, 0, 0], \"SOLID_MEDIUM\"))\n myformat.push(googleBorder.call(sheet_id_all, borderRowStartAll, borderColStart, borderRows, borderCols, [0, 0, 0], \"SOLID_MEDIUM\"))\n myformat.push(googleRightBorder.call(sheet_id, borderRowStart, borderColStart, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleRightBorder.call(sheet_id_all, borderRowStartAll, borderColStart, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleRightBorder.call(sheet_id, borderRowStart, borderColStart+2, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleRightBorder.call(sheet_id_all, borderRowStartAll, borderColStart+2, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleWrapText.call(sheet_id, borderRowStart, borderColStart, borderRows, borderCols, \"WRAP\"))\n myformat.push(googleWrapText.call(sheet_id_all, borderRowStartAll, borderColStart, borderRows, borderCols, \"WRAP\"))\n # want to put timeslot time (timeData) in first column of each lesson row.\n for i in borderRowStart..borderRowStart+borderRows-1 do\n mydata.push(googleBatchDataItem.call(sheet_name, i,1,1,1,[[timeData]]))\n end\n for i in borderRowStartAll..borderRowStartAll+borderRows-1 do\n mydata.push(googleBatchDataItem.call(sheet_name_all,i,1,1,1,[[timeData]]))\n end\n }\n #------------- end of lambda function: formatLesson ---------\n\n ### correction ###render flexibledisplay\n \n # General formatting for each site sheet\n myformat.push(googleVertAlign.call(sheet_id, 1, 1, nil, nil, \"TOP\"))\n myformat.push(googleWrapText.call(sheet_id, 1, 1, nil, nil, \"WRAP\"))\n myformat.push(googleColWidthItem.call(sheet_id, 1,100,350))\n myformat.push(googleColWidthItem.call(sheet_id, 1,1,0))\n\n #<table id=site-<%= location %> >\n baseSlotRowInSite = 0 # first slot\n currentRow = baseSlotRowInSite + baseSiteRow\n currentRowAll = baseSlotRowInSite + baseSiteRowAll\n ###----------------------------------------------------------------------\n ###-- step through each time period for this site e.g. 3:30, 4:30, etc. - \n ###-- (entry 0 = title info: 1. site 2. populated days by date) \n ###----------------------------------------------------------------------\n calLocation.each do |rows| # step through slots containing multiple days (fist row is actually a header row!)\n timeData = rows[0][\"value\"] \n #<tr>\n maxPersonRowInAnySlot = 0 # initialised to 1 to step a row even if no tutor or student found.\n currentCol = 1\n ###--------------------------------------------------------------------\n ###------- step through each day for this time period -----------------\n ### (entry 0 = time of lesson)\n ###--------------------------------------------------------------------\n rows.each_with_index do |cells, cellIndex| # step through each day (first column is head column - for time slots!)\n if @compress \n unless usedColumnsIndex.include?(cellIndex) then\n next\n end \n end\n awaystudents = \"\"\n ###-------------------------------------------------------------------------------------------\n ###------------------- step through each lesson in this slot ---------------------------------\n ###-------------------------------------------------------------------------------------------\n if cells.key?(\"values\") then # lessons for this day in this slot \n if cells[\"values\"].respond_to?(:each) then # check we have lessons?\n # This is a slot with lessons, do I need to output a title.\n #byebug\n # First column for each day needs to have the width set\n # googlecolwidthitem.call(sheet_id, colStart, numberOfCols, width_pixels)\n myformat.push(googleColWidthItem.call(sheet_id, currentCol, 1, 130))\n myformat.push(googleColWidthItem.call(sheet_id_all, currentCol, 1, 130))\n myformat.push(googleColWidthItem.call(sheet_id, currentCol+3, 1, 200))\n myformat.push(googleColWidthItem.call(sheet_id_all, currentCol+3, 1, 200))\n title = calLocation[0][0]['value'] + # site name\n calLocation[0][cellIndex]['datetime'].strftime(\" %A %e/%-m/%y \") + # date\n rows[0]['value'] # sesson time \n mydata.push(googleBatchDataItem.call(sheet_name,\n baseSiteRow + baseSlotRowInSite - 1, \n currentCol,1,1,[[title]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all,\n baseSiteRowAll + baseSlotRowInSite - 1,\n currentCol,1,1,[[title]]))\n # googleMergeCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols)\n myformat.push(googleMergeCells.call(sheet_id, baseSiteRow + baseSlotRowInSite - 1, 1,\n currentCol, 4))\n myformat.push(googleMergeCells.call(sheet_id_all, baseSiteRowAll + baseSlotRowInSite - 1, 1,\n currentCol, 4))\n # Format the header line (merged cells)\n # googlefomratCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols, fontSize)\n myformat.push(googleFormatCells.call(sheet_id, baseSiteRow + baseSlotRowInSite - 1, 1,\n currentCol, 4, 16))\n myformat.push(googleFormatCells.call(sheet_id_all, baseSiteRowAll + baseSlotRowInSite - 1, 1,\n currentCol, 4, 16))\n baseLessonRowInSlot = 0 # index of first lesson in this slot for this day\n cells[\"values\"].sort_by {|obj| [valueOrderStatus(obj),valueOrder(obj)] }.each do |entry| # step thru sorted lessons\n next if (entry.status != nil && [\"global\", \"park\"].include?(entry.status))\n currentTutorRowInLesson = 0\n if entry.tutors.respond_to?(:each) then\n entry.tutors.sort_by {|obj| obj.pname }.each do |tutor|\n if tutor then\n thistutrole = tutor.tutroles.where(lesson_id: entry.id).first\n if @tutorstatusforroster.include?(thistutrole.status) then # tutors of interest\n currentRow = currentTutorRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n currentRowAll = currentTutorRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n #<div class=\"tutorname tutorinline <%= set_class_status(tutor, entry) %>\">tutor: <%= tutor.pname %></div>\n tutorData = tutor.pname\n tutorDataAll = tutor.pname\n formatBreakPoints = []\n formatBreakPointsAll = []\n formatBreakPoints.push(0)\n formatBreakPointsAll.push(0)\n formatBreakPoints.push(tutor.pname.length)\n formatBreakPointsAll.push(tutor.pname.length)\n # tutor.subjects\n mysubjects = tutor.subjects\n mysubjects = mysubjects ? mysubjects : \"\"\n # thistutrole.comment\n # tutor.comment\n # Status: thistutrole.status Kind: thistutrole.kind\n mykind = thistutrole.kind\n mykind = mykind ? mykind : \"\"\n # don't diaplay subjects or kind for tutors on setup\n unless (entry.status == 'onSetup' && mykind == 'onSetup') ||\n (entry.status == 'onCall' && mykind == 'onCall')\n tutorData += ((mysubjects == \"\") ? \"\" : (\"\\n\" + mysubjects)) \n tutorData += ((mykind == \"\") ? \"\" : (\"\\n\" + mykind)) unless [\"standard\"].include?(mykind)\n tutorDataAll += ((mykind == \"\") ? \"\" : (\"\\n\" + mykind)) unless [\"standard\"].include?(mykind)\n end\n if thistutrole.comment != nil && thistutrole.comment != \"\"\n tutorData += \"\\n\" + thistutrole.comment\n end\n mycolour = kindcolours['tutor-kind-' + mykind]\n mycolour = mycolour.map {|p| p/255.0} \n myformat.push(googleTextFormatRun.call(sheet_id, currentRow, currentCol,\n tutorData, formatBreakPoints))\n myformat.push(googleTextFormatRun.call(sheet_id_all, currentRowAll, currentCol,\n tutorDataAll, formatBreakPointsAll))\n ###myformat.push(googleBGColourItem.call(sheet_id, currentRow, currentCol, 1, 1, mycolour))\n ###myformat.push(googleBGColourItem.call(sheet_id_all, currentRowAll, currentCol, 1, 1, mycolour))\n currentTutorRowInLesson += 1\n end # tutors of interest\n end\n #break\n end\n # keep track of the largest count of tutors or students in lesson.\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentTutorRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentTutorRowInLesson + baseLessonRowInSlot\n end\n currentStudentRowInLesson = 0\n currentStudentInLesson = 0\n studentLessonComments = \"\"\n if entry.students.respond_to?(:each) then\n entry.students.each do |student|\n if student then\n logger.debug \"student: \" + student.pname\n thisrole = student.roles.where(lesson_id: entry.id).first\n #logger.debug \"thisrole: \" + thisrole.inspect\n if ['away', 'awaycourtesy', 'bye', 'absent'].include?(thisrole.status) then \n displayname = student.pname + \" (\" + thisrole.status + \")\"\n awaystudents += awaystudents.length > 0 ? \"\\n\" + displayname : displayname\n end\n if @studentstatusforroster.include?(thisrole.status) then # students of interest\n #logger.debug \"*************processing student: \" + student.pname\n #logger.debug \"currentStudentInLesson: \" + currentStudentInLesson.inspect\n #logger.debug \"currentStudentRowInLesson + baseLessonRowInSlot + baseSlotRowInSite: \" +\n # currentStudentRowInLesson.to_s + \", \" + baseLessonRowInSlot.to_s + \", \" + baseSlotRowInSite.to_s\n currentRow = currentStudentRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n currentRowAll = currentStudentRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n #<div class=\"studentname studentinline <%= set_class_status(student, entry) %>\">student: <%= student.pname %></div>\n #logger.debug \"DataItem parameters: \" + currentRow.to_s + \", \" + currentCol.to_s + \", 1, 1, \" + student.pname \n formatBreakPoints = []\n formatBreakPoints.push(0)\n studentData = student.pname\n studentSex = student.sex == nil ? \"\" :\n (student.sex.downcase.include?(\"female\") ? \"(F) \" : (student.sex.downcase.include?(\"male\") ? \"(M) \" : \"\"))\n studentData += \" \" + studentSex\n #logger.debug \"student.pname: \" + student.pname \n #logger.debug \"lesson_id: \" + entry.id.to_s\n #formatBreakPoints.push(student.pname.length)\n #studentSubjects = \" Yr: \" + (student.year == nil ? \" \" : student.year.rjust(3)) +\n # \" | \" + (student.study == nil ? \"\" : student.study)\n #studentYear = \" Yr:\" + (student.year == nil ? student.year.rjust(3))\n studentYear = \" Yr:\" + (student.year == nil ? \"\" : student.year)\n studentSubjects = student.study == nil ? \"\" : student.study\n studentData += studentYear\n studentDataAll = studentData\n formatBreakPointsAll = formatBreakPoints\n studentData += \"\\n\" + studentSubjects\n formatBreakPoints.push(studentData.length)\n # thisrole.comment\n # student.comment\n # Status: thisrole.status Kind: thisrole.kind\n mykind = thisrole.kind\n mykind = mykind ? mykind : \"\"\n studentData += \" (\" + mykind + \")\" unless [\"standard\"].include?(mykind)\n if thisrole.comment != nil && thisrole.comment != \"\"\n studentLessonComments += student.pname + \":\\n\" + thisrole.comment + \"\\n\"\n #studentData += \"\\n\" + thisrole.comment\n end\n if student.comment != nil && student.comment != \"\"\n studentData += \"\\n\" + student.comment\n end\n mycolour = kindcolours['student-kind-' + mykind]\n mycolour = mycolour.map {|p| p/255.0}\n #myformat.push(googleTextFormatRun.call(sheet_id, currentRow, currentCol + 1,\n # studentData, formatBreakPoints))\n colOffset = 1 + (currentStudentInLesson % 2)\n myformat.push(googleTextFormatRun.call(sheet_id, currentRow, currentCol + colOffset,\n studentData, formatBreakPoints))\n myformat.push(googleTextFormatRun.call(sheet_id_all, currentRowAll, currentCol + colOffset,\n studentDataAll, formatBreakPointsAll))\n ###myformat.push(googleBGColourItem.call(sheet_id, currentRow, currentCol + colOffset, 1, 1, mycolour))\n ###myformat.push(googleBGColourItem.call(sheet_id_all, currentRowAll, currentCol + colOffset, 1, 1, mycolour))\n \n #byebug \n currentStudentRowInLesson += 1 if (currentStudentInLesson % 2) == 1 # odd\n currentStudentInLesson += 1\n end # students of interest\n end\n end\n # Need to get correct count of rows (rounding up is necessary)\n # derive currentStudentRowInLesson from the currentStudentInLesson\n currentStudentRowInLesson = (currentStudentInLesson % 2) == 0 ? \n currentStudentInLesson / 2 : (currentStudentInLesson / 2) + 1 \n \n # keep track of the largest count of tutors or students in lesson.\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentStudentRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentStudentRowInLesson + baseLessonRowInSlot\n end\n maxPersonRowInLesson = currentTutorRowInLesson > currentStudentRowInLesson ? \n currentTutorRowInLesson : currentStudentRowInLesson \n # put a border around this lesson if there were lessons with people\n if maxPersonRowInLesson > 0 then\n # put in lesson comments if there were tutors or students.\n #<div class=\"lessoncommenttext\"><% if entry.comments != nil && entry.comments != \"\" %><%= entry.comments %><% end %></div>\n #<div class=\"lessonstatusinfo\"><% if entry.status != nil && entry.status != \"\" %>Status: <%= entry.status %> <% end %></div>\n mylessoncomment = ''\n if entry.status != nil && entry.status != ''\n unless [\"standard\", \"routine\", \"flexible\"].include?(entry.status) # if this is a standard lesson \n mylessoncomment = entry.status + \"\\n\" # don't show the lesson status (kind)\n end\n end\n mylessoncommentAll = mylessoncomment\n if entry.comments != nil && entry.comments != \"\"\n mylessoncomment += entry.comments\n end\n mylessoncomment += studentLessonComments\n if mylessoncomment.length > 0\n mylessoncomment = mylessoncomment.sub(/\\n$/, '') # remove trailing new line\n mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol+3,1,1,[[mylessoncomment]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all,currentRowAll,currentCol+3,1,1,[[mylessoncommentAll]]))\n end\n # ----- formatting of the lesson row within the slot ---------\n formatLesson.call(baseLessonRowInSlot, baseSlotRowInSite, baseSiteRow, baseSiteRowAll, currentCol, maxPersonRowInLesson)\n end\n ###baseLessonRowInSlot += maxPersonRowInLesson\n baseLessonRowInSlot += maxPersonRowInLesson\n #currentRow = maxPersonRowInAnySlot + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow # next empty row \n end # end looping sorted lessons within a day/slot\n end # responds to cell[\"values\"]\n elsif cells.key?(\"value\") then # just holds cell info (not lessons) to be shown\n currentRow = baseSlotRowInSite + baseSiteRow\n currentRowAll = baseSlotRowInSite + baseSiteRowAll\n #timeData = cells[\"value\"].to_s #if currentCol == 1 &&\n # cells[\"value\"] != nil # pick up the time\n #mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol,1,1,[[cells[\"value\"].to_s]]))\n #mydata.push(googleBatchDataItem.call(sheet_name_all,currentRowAll,currentCol,1,1,[[cells[\"value\"].to_s]]))\n end\n # Now add a dummy row at end of slot to show students who are away\n if awaystudents.length > 0\n currentRow = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n currentRowAll = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol,1,1,[[\"Students Away\"]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all, currentRowAll, currentCol,1,1,[[\"Students Away\"]]))\n myformat.push(googleFormatCells.call(sheet_id, currentRow, 1, currentCol, 1, 10))\n myformat.push(googleFormatCells.call(sheet_id_all, currentRowAll, 1, currentCol, 1, 10))\n mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol + 1,1,1,[[awaystudents]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all, currentRowAll, currentCol + 1,1,1,[[awaystudents]]))\n maxPersonRowInLesson = 1\n formatLesson.call(baseLessonRowInSlot, baseSlotRowInSite, baseSiteRow,\n baseSiteRowAll, currentCol, maxPersonRowInLesson) # apply the standard formatting\n baseLessonRowInSlot += 1 # add another row for this\n # update tracking of the largest count of tutors or students in lesson.\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentStudentRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentStudentRowInLesson + baseLessonRowInSlot\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentTutorRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentTutorRowInLesson + baseLessonRowInSlot\n end\n #</td>\n currentCol += currentCol == 1 ? 1 : 4 # first column is title, rest have adjacent tutors & students.\n end # end looping days within slots\n #</tr>\n #byebug\n baseSlotRowInSite += maxPersonRowInAnySlot # set ready for next slot (row of days)\n if baseLessonRowInSlot == 0 && maxPersonRowInAnySlot == 0 then\n baseSlotRowInSite += 1 # cater for when no lessons with tutors or students of interest\n end\n # Add an extra row between slots - except the first title slot\n # Jasmine wanted no rows between slots so reduced from 2 to 1.\n baseSlotRowInSite += 1 unless baseSlotRowInSite == 1\n end # end looping slots\n holdRailsLoggerLevel = Rails.logger.level\n Rails.logger.level = 1 \n googleBatchDataUpdate.call(spreadsheet_id, mydata)\n googleBatchUpdate.call(myformat) \n Rails.logger.level = holdRailsLoggerLevel\n\n #</table>\n baseSiteRow += baseSlotRowInSite + 1 # +1 adds blank row between sites\n baseSiteRowAll += baseSlotRowInSite + 1 # +1 adds blank row between sites\n #<br>\n end # end looping sites\nend # end of testing option.\n ### correction ###return # return without rendering.\n end", "def update_get(row, sf_row)\n type = row[3]\n final_staff_check = row[FINAL_STAFF_CHECK].to_s.strip.casecmp('x').zero?\n # handle municipal????\n return unless ['A prominent individual', 'An organization'].include?(type)\n\n is_org = (type == 'An organization')\n\n street = [row[12].to_s.strip + row[13].to_s.strip, row[14].to_s.strip].map(&:strip).reject(&:empty?).join(', ')\n contact_name = \"#{row[4].to_s.strip} #{row[5].to_s.strip}\"\n name = is_org ? row[9].to_s.strip : contact_name\n status = row[STATUS_COL]\n postal_code = row[17].to_s.rjust(5, '0')\n sf_end_status = final_staff_check ? 'Posted to Web' : %w[Declined Verified].include?(status) ? status : 'Pending'\n \n org_map = { Mailing_City__c: 15, Email__c: 7, Primary_Contact_Title__c: 6, Phone__c: 8, Endorsement_Campaign__c: 23 }\n end_type = is_org ? 'Organizational' : 'Individual'\n end_map = { City__c: 15, Contact_Email__c: 7, Contact_Phone__c: 8, Comments__c: 21, Endorsement_Campaign__c: 23 }\n \n # only update if a field changed\n sf_org = sf_row.EndorsementOrg__r\n org_changed = false\n org_map.each do |sf_field, row_index|\n sheet_val = row[row_index].to_s\n org_changed = set_if_different(sf_org, sf_field, sheet_val.to_s.strip) || org_changed\n end\n # non-auto fields\n org_changed = set_if_different(sf_org, :Endorser_Type__c, end_type) || org_changed\n org_changed = set_if_different(sf_org, :Name__c, name) || org_changed\n org_changed = set_if_different(sf_org, :Mailing_Street__c, street) || org_changed\n org_changed = set_if_different(sf_org, :Primary_Contact_Name__c, contact_name) || org_changed\n org_changed = set_if_different(sf_org, :Website__c, 'http://' + row[11]) || org_changed\n org_changed = set_if_different(sf_org, :Population__c, row[20].to_i.to_f) || org_changed if row[20].present?\n org_changed = set_if_different(sf_org, :Employees__c, row[19].to_i.to_f) || org_changed if row[19].present?\n org_changed = set_if_different(sf_org, :Mailing_Zip_Postal_Code__c, postal_code) || org_changed\n \n if org_changed\n LOG.info(\"SF Endorser Org #{sf_org.Id} Changed: #{sf_org}\")\n did_save = sf_org.save!\n unless did_save\n LOG.error(\"Failed to save: #{sf_org}\")\n send_email(\"Failed to save: #{sf_org}\")\n end\n end\n \n # update endorsement\n end_changed = false\n end_map.each do |sf_field, row_index|\n sheet_val = row[row_index].to_s\n end_changed = set_if_different(sf_row, sf_field, sheet_val.to_s.strip) || end_changed\n end\n contact_title = [row[6].to_s, row[10].to_s].map(&:strip).reject(&:empty?).join(', ')\n end_changed = set_if_different(sf_row, :Endorser_Type__c, end_type) || end_changed\n\n unless sf_end_status == 'Verified'\n end_changed = set_if_different(sf_row, :Verification_Status__c, sf_end_status) || end_changed\n end\n end_changed = set_if_different(sf_row, :Address__c, street) || end_changed\n end_changed = set_if_different(sf_row, :Org_Ind_Name__c, name) || end_changed\n end_changed = set_if_different(sf_row, :Contact_Title__c, contact_title) || end_changed\n end_changed = set_if_different(sf_row, :Contact_Name__c, contact_name) || end_changed\n end_changed = set_if_different(sf_row, :Zip_Postal_Code__c, postal_code) || end_changed\n \n if end_changed\n LOG.info(\"SF Endorsement #{sf_row.Id} Changed: #{sf_row}\")\n did_save = sf_row.save!\n unless did_save\n LOG.error(\"Failed to save: #{sf_row}\")\n send_email(\"Failed to save: #{sf_row}\")\n end\n end\n\n end_changed || org_changed\n end", "def process_row(exhibit, row)\n document = exhibit.blacklight_config.document_model.find(row[config.csv_id])\n sidecar = document.sidecar(exhibit)\n\n raise 'Unable to locate document' if document.blank?\n\n needs_reindex = false\n\n begin\n if row.headers.include?(config.csv_visibility) && sidecar.public != to_bool(row[config.csv_visibility])\n sidecar.update(public: to_bool(row[config.csv_visibility]))\n needs_reindex = true\n end\n\n tag_cols = row.headers.select { |k| k =~ /^#{config.csv_tags_prefix}/ }\n\n if tag_cols.any?\n all_tags = sidecar.all_tags_list\n\n added_tags_cols, removed_tags_cols = tag_cols.partition do |k|\n to_bool(row[k])\n end\n\n existing_or_added_tags = added_tags_cols.map { |x| x.sub(/#{config.csv_tags_prefix}\\s/, '') }\n removed_tags = removed_tags_cols.map { |x| x.sub(/#{config.csv_tags_prefix}\\s/, '') }\n\n if all_tags.difference(existing_or_added_tags).any? || existing_or_added_tags.difference(all_tags).any?\n exhibit.tag(sidecar, with: all_tags - removed_tags + existing_or_added_tags, on: :tags)\n needs_reindex = true\n end\n end\n ensure\n document.reindex(update_params: {}) if needs_reindex\n end\n end", "def import_data\r\n # generate data column instances\r\n columnheaders_raw.each do |columnheader|\r\n\r\n data_column_information = initialize_data_column_information(columnheader)\r\n data_column_new = Datacolumn.create!(data_column_information)\r\n all_cells_for_one_column = data_for_columnheader(columnheader)[:data]\r\n datatype = Datatypehelper.find_by_name(data_column_information[:import_data_type])\r\n\r\n unless all_cells_for_one_column.blank?\r\n save_all_cells_to_database(data_column_new, datatype, all_cells_for_one_column)\r\n add_any_sheet_categories_included_for_this_column(columnheader, data_column_new)\r\n add_acknowledged_people(columnheader, data_column_new)\r\n end\r\n data_column_new.finished = true\r\n end\r\n end", "def invalid_values\n sheetcells.select(:import_value).where(status_id: Sheetcellstatus::INVALID).order(:import_value).distinct\n end", "def importTransactionsFile(filename)\n rules = Rule.all\n accounts={}\n numberTrans=0\n book = Spreadsheet.open filename\n book.worksheets.each do |worksheet|\n skipfirst = true\n cachedId=nil\n cachedName=nil\n worksheet.each do |row|\n if skipfirst \n skipfirst = false\n next\n end\n accountId=cachedId\n theAccountId=row[0].to_i\n if (theAccountId!=cachedName)\n puts(\"#########Account name #{theAccountId}\")\n accountId=findAccount(accounts,theAccountId)\n if accountId.nil?\n next\n else\n cachedId=accountId\n cachedName=theAccountId\n end\n end\n puts(accounts)\n Transaction.where( account_id: accountId, transaction_date: row[2], description: row[7] ).first_or_create( ) do |transaction|\n transaction.start_saldo = row[4]\n transaction.end_saldo = row[5]\n transaction.amount = row[6]\n transaction.category_id = setCategory(rules,row[7])\n transaction.save\n end\n accounts[cachedName][:number] +=1\n accounts[cachedName][:lastdate]=row[2]\n end\n storeAccountLastImport( accounts )\n File.delete(filename)\n end\n end", "def newSheet(table, taskName, id=nil)\n # open the Google Sheet service\n service = Google::Apis::SheetsV4::SheetsService.new\n service.client_options.application_name = APPLICATION_NAME\n service.authorization = authorize\n\n # open the Google Drive service\n drive = Google::Apis::DriveV3::DriveService.new\n drive.client_options.application_name = APPLICATION_NAME\n drive.authorization = authorize\n puts \"id in export sheet\"\n puts id\n\n #create a new sheet\n if id == nil\n\n spreadsheet = {\n properties: {\n title: taskName\n }\n }\n spreadsheet = service.create_spreadsheet(spreadsheet,\n fields: 'spreadsheetId')\n puts \"Spreadsheet ID: #{spreadsheet.spreadsheet_id}\"\n #fill the sheet with the data 'table'\n data = [\n {\n range: 'A:Z',\n majorDimension: \"ROWS\",\n values: table,\n }\n ]\n value_range_object = Google::Apis::SheetsV4::ValueRange.new(range: 'A:Z',\n majorDimension: \"ROWS\",\n values: table)\n result = service.update_spreadsheet_value(spreadsheet.spreadsheet_id,\n 'A:Z',\n value_range_object,\n value_input_option: 'RAW')\n puts = \"#{result.updated_cells} cells updated.\"\n file = drive.get_file(spreadsheet.spreadsheet_id)\n puts \"Create this file name: #{file.name}\"\n id = spreadsheet.spreadsheet_id\n\n ##\n # change the permision of the created file\n # line in google-api-ruby-client/lib/google/apis/core/api_command.rb return {} and make and error.\n # self.body = request_representation.new(request_object).to_json(user_options: { skip_undefined: true })\n #\n data = \n {\n \"role\" => \"writer\",\n \"type\" => \"anyone\"\n }\n # byebug\n permision = drive.create_permission(id, data.to_json,\n options: {skip_serialization: true})\n \n link = \"https://docs.google.com/spreadsheets/d/#{file.id}\"\n puts \"use this link: #{link}\"\n \n return link\n ##\n # Updating the file with new information\n else\n id = id.split('/')[5]\n file = drive.get_file(id)\n #geting the info of the sheet\n get_celds = service.get_spreadsheet_values(id, 'A:C')\n #byebug\n puts get_celds.values.length\n n = get_celds.values.length + 1\n range = \"A#{n}:B#{n}\"\n #write!\n value_range_object = Google::Apis::SheetsV4::ValueRange.new(range: range,\n values: table)\n result = service.update_spreadsheet_value(id,\n range,\n value_range_object,\n value_input_option: 'RAW')\n puts \"Updating this: #{file.name}\"\n link = \"https://docs.google.com/spreadsheets/d/#{file.id}\"\n puts \"use this link: #{link}\"\n return link\n end\nend", "def index\n #@users = User.all\n params.permit!\n con_hash,like_hash = construct_condition(:user,like_ary: [:user_name,:email])\n drop_page_title(\"用户管理\")\n drop_breadcrumb\n @date = Date.today\n @users = @users.where(con_hash).where(like_hash) if con_hash || like_hash\n @users = @users.not_expired.includes(:dept,:roles)\n #@user = current_user.decorate\n respond_to do |format|\n format.html { @users = @users.page(params[:page]) }\n format.js do\n @users = @users.page(params[:page])\n render partial: \"items\",object: @users, content_type: Mime::HTML\n end\n format.xls do\n @users = @users.except(:includes).includes(:dept)\n cols = \"uid,user_name,email,dept,title,mgr_code,assault,assault_start_date,assault_end_date\".split(\",\")\n xsl_file = @users.to_csv(select: \"ID,名字,邮箱,部门,职位,直属管理员ID,是否突击状态,突击开始时间,突击结束时间\") do |item,_|\n _attrs = item.attributes\n _attrs[\"dept\"] = item.dept.try(:name)\n _attrs[\"assault\"] = item.assault_state?(@date)\n _attrs.values_at(*cols)\n end\n #xsl_file\n send_data xsl_file,disposition: 'attachment', filename: \"users_data_#{Date.today.to_s(:number)}.xls\"\n\n end\n end\n\n end", "def shift_tracking_file(standard_day_off)\n path = File.join(\"public/system/dailyrosters/#{active_date.to_formatted_s(:number)}\", self.dailyroster_file_name)\n Spreadsheet.open(path, 'r') do |book|\n sheet = book.worksheet \"MonthReport\"\n (11..sheet.row_count).step(4) do |i|\n rows = [sheet.row(i),sheet.row(i+1),sheet.row(i+2),sheet.row(i+3)]\n ShiftTracking.add_staff_record(rows, standard_day_off) unless (rows[0][0].blank?)\n end\n end\n end", "def create_games_excel\n\n\tif (params[:msg].nil?)\n\n\t @student_group = StudentGroup.find(params[:id])\n\t #@book = Spreadsheet.open 'C:/Users/Rushabh Hathi/Desktop/Dialogue1.0/public/Files/abc.txt'\n\t @book = Spreadsheet::Workbook.new\n\t sheet1 = @book.create_worksheet\n\t @rolelist=Role.all(:conditions=>['case_study_id=?', @student_group.case_study_id])\n\t i=1\n\n# #here role name is added for the list to be populated\n# @rolelist.each do |r|\n# sheet1[0, i]=r.name\n# i=i+1\n# end\n\n\t @studentgroupuserlist=StudentGroupUser.all(:conditions=>['student_group_id=?', params[:id]])\n\t @studentlist= Array.new\n\t @unallocated_student= Array.new\n\t @studentgroupuserlist.each do |s|\n\t\t@studentlist << User.find(s.user_id)\n\t end\n\n\t #here the dynamic data from student group gets populated\n\t i=1\n\t sheet1[0, 0]=\"Student ID\"\n\t sheet1[0, 1]=\"Student Name\"\n\t sheet1[0, 2]=\"Role Name\"\n\n\n\t @studentlist.each do |s|\n\n\t\tsheet1[i, 0]=s.id\n\t\tsheet1[i, 1]=s.first_name+s.last_name\n\t\tsheet1[i, 2]= \" \"\n\t\ti=i+1\n\t\t@book.write \"#{Rails.root}/public/Files/Game_Creation.xls\"\n\n\n\t end\n\n\tend\n end", "def excel_parse\n excel = Spreadsheet.open \"clientes.xls\"\n hoja = excel.worksheet 0\n\n# @filas = []\n hoja.each 1 do |fila|\n #solo añadimos aquellos clientes que no existan, comprobamos que el codigo no exista\n #\n ficha = Cliente.find_by_codigo( fila[4])\n if not ficha then\n ficha = Cliente.new\n ficha.user_id = 1 #usuario de test, para cuando sea MMO\n ficha.codigo = fila[4]\n ficha.nombre = fila[3]\n ficha.provincia = fila[25]\n ficha.direccion = fila[26]\n ficha.ciudad = fila[27]\n ficha.cp = fila[28]\n ficha.telefono = fila[29]\n ficha.grupo_id = fila[1]\n ficha.notas = \"\"\n ficha.save!\n# @filas << ficha\n end\n\n #parseamos la marca a la que pertenece la venta\n m = Marca.find_by_codigo( fila[10])\n if not m then\n m = Marca.new\n m.codigo = fila[10]\n m.user = 0\n m.save!\n end\n\n #parseamos las ventas de esa fila suponiendo que el cliente existe\n vdata = Venta.new do |v|\n v.user= 1\n v.cliente= ficha.id\n #v.marca = Marca.find_by_codigo(fila[10]).id\n v.marca = m.id\n v.piezas_12m = fila[23]\n v.piezas_fact_last_mes = fila[12]\n v.piezas_last_pedido = fila[18]\n v.piezas_pendientes = fila[11]\n end\n vdata.save!\n end\n end", "def listingsToUpdate(current_user)\n # if there exists an attribut name \"hidden_upload_id\"\n if @valid_attributes.any? {|x| x[:name] == \"hidden_upload_id\"}\n # go through each line (listing)\n @listing_data.each_with_index do |listing, index|\n if listing[:hidden_upload_id] != nil && index > 0\n # get new listing owner\n person = \n if listing[:username] && @relation == :rentog_admin\n Person.where(username: listing[:username]).last || current_user\n else\n current_user\n end\n\n hidden_upload_custom_field_id = CustomFieldName.where(\"value like '%hidden upload id%'\")[0].custom_field_id\n\n # all listings with this hidden upload id\n old_listings = []\n name_of_first_dev = \"\"\n\n all_entries_with_this_upload_id_num = CustomFieldValue.where(:custom_field_id => hidden_upload_custom_field_id, :text_value => listing[:hidden_upload_id])\n all_entries_with_this_upload_id_num.each do |entry|\n # check if listing is not deleted, the title is the same and if the listing belongs to users company or the supervisors domain\n old_listing = entry.listing\n if old_listing && !old_listing.deleted && \n old_listing.title == listing[:device_name] && \n (old_listing.author == person.get_company || \n current_user.is_supervisor_of?(old_listing.author) && old_listing.author.username == listing[:pool_id])\n\n # listing is already marked as \"update\"...means that there are multiple entries in the excel file with the same title and hidden upload id\n if listing[:update] && listing[:invalid]\n listing[:invalid][:msg] += \", \" + listing[:device_name]\n elsif listing[:update]\n listing[:invalid] = {type: \"multiple_same_devices\", msg: \"There are more than 1 device with the same hidden upload id registered for your company: \"}\n listing[:invalid][:msg] += name_of_first_dev + \", \" + listing[:device_name]\n else\n listing[:update] = true\n listing[:listing_id] = old_listing.id\n name_of_first_dev = listing[:device_name]\n end\n end\n end\n end\n end\n end\n end", "def import_spreadsheet\n @project = Yogo::Project.get(params[:id])\n @total_steps = 3\n\n case params[:step]\n when '2'\n file = copy_uploaded_file(params[:spreadsheet])\n session[:import_file] = file\n contents = FasterCSV.read(file)\n @headers = contents[0]\n @rows = contents.length - 1\n @measurements = params[:measurements].keys.map{|k| @project.data_collections.get k }\n @import_step = 2\n when '3'\n @measurements, @example, @sheet_rows = {}, {}, 0\n params['measurements'].each do |m_id, parameters|\n m = @project.data_collections.get m_id\n m_hash = {}\n m_hash['measurement'] = [m.measurement_schema.id, parameters.delete('measurement')]\n m_hash['parameters'] = []\n parameters.each do |p_id, header|\n p = m.schema.get p_id\n m_hash['parameters'] << [p, header]\n end\n @measurements[m] = m_hash\n @measurements[m]['count'] = 0\n @measurements[m]['example'] = {}\n end\n\n FasterCSV.foreach(session[:import_file], :headers => true) do |row|\n @headers ||= row.headers\n \n @measurements.each do |m, v|\n if @measurements[m]['example'].empty?\n @headers.each { |h| @measurements[m]['example'][h] = [] } \n end\n unless row[v['measurement'][1]].blank?\n if @measurements[m]['count'] < 5\n row.each { |h, v| @measurements[m]['example'][h] << v }\n end\n @measurements[m]['count'] += 1 \n end\n end\n @sheet_rows += 1\n end\n session_hash = {}\n @measurements.each do |m,v|\n session_hash[m.id] = {\n 'parameters' => v['parameters'].map{|p| [p[0].id, p[1]] }, \n 'measurement' => v['measurement']\n }\n end\n session[:measurements] = session_hash\n @import_step = 3\n when '4'\n @measurements = {}\n session[:measurements].each do |m_id,v|\n m = @project.data_collections.get(m_id)\n @measurements[m] = v\n end\n @measurements.each do |m,v|\n @measurements[m]['initial'] = m.items.all.count\n if params['replace_data'] && (params['replace_data'][m.id.to_s] == 'DELETE')\n m.items.all.destroy\n end\n @measurements[m]['deleted'] = @measurements[m]['initial'] - m.items.all.count\n @measurements[m]['added'] = 0\n @measurements[m]['errors'] = []\n end\n FasterCSV.foreach(session[:import_file], :headers => true) do |row|\n @headers ||= row.headers\n @measurements.each do |m, v|\n values = {}\n unless row[v['measurement'][1]].blank?\n fields = {}\n m.schema.each{|s| fields[s.id.to_s] = s.to_s.intern }\n v['parameters'].each do |p,h|\n values[fields[p.to_s]] = row[h]\n end\n values[fields[v['measurement'][0].to_s]] = row[v['measurement'][1]]\n d = m.data_model.new(values)\n if d.valid?\n d.save\n else\n @measurements[m]['errors'] << d.errors.full_messages.join(\", \")\n end\n @measurements[m]['added'] += 1\n end\n end\n end\n @measurements.each_key{|m| @measurements[m]['total'] = m.items.all.count }\n @import_step = 4\n else\n @import_step = 1\n end\n\n render(\"import_spreadsheet_#{@import_step}\")\n end", "def consolidate_midia\n users = user_relationships#.reject{|x| !(x.reports.count > 0)}\n\n return nil if users.empty?\n\n keys = users.first.attributes.keys.map!(&:to_sym) - [:created_at, :updated_at, :id, :report_not_done, :server_id] + [:created_at]\n keys.map!{|x| I18n.t(\"activerecord.attributes.user.#{x.to_s}\") }\n\n user_header = keys\n \n user_header << [\"Presença\", \"QRCode ou E-mail\"]\n user_header.flatten!\n\n file = \"public/consolidate_midia.csv\"\n begin\n File.delete(file)\n rescue Errno::ENOENT\n end\n\n csv_text = File.read(Report.midia_report.file.path)\n csv = CSV.parse(csv_text, :headers => false)\n questions_headers = []\n csv.each do |row|\n #questions_headers = row.to_hash.keys if questions_headers.empty?\n questions_headers << row if questions_headers.empty?\n end\n\n CSV.open(file, \"wb\") do |csv|\n header = [user_header, questions_headers].flatten\n csv << header\n users.each do |x|\n answers = []\n\n if x.reports.midia_report\n csv_text = File.read(x.reports.midia_report.file.path)\n csv_survey = CSV.parse(csv_text, :headers => false)\n answers = csv_survey.last\n end\n\n x_event = x.user_events.where(\"event_id = ?\", self.code).first\n \n if x_event.email_search\n email_or_qr_code_string = \"E-mail\"\n elsif x_event.qr_code_scanned\n email_or_qr_code_string = \"QRCode\"\n else\n email_or_qr_code_string = nil \n end\n\n array = [\n x.name, \n x.company, \n x.email, \n x.cep, \n x.address, \n x.state, \n x.city, \n x.cel, \n x.smartphone_description, \n x.job, \n x.complement, \n x.number, \n x.image_usage_description, \n x.sms_alert_description, \n x.email_alert_description, \n x.created_at.strftime(\"%d/%m/%Y\"),\n (email_or_qr_code_string ? \"Sim\" : \"Não\"),\n email_or_qr_code_string,\n answers.flatten\n ].flatten\n\n csv << array\n end\n # ...\n end\n\n return file\n end", "def valid_learners_excel_upload(csv_row)\n #if any of the fields are blank then dont allow. return false\n if (!csv_row[0].nil? or !csv_row[0].blank?) and (!csv_row[1].nil? or !csv_row[1].blank?) then\n #check the lengths of name and email are in limits else return false\n if csv_row[0].length <=40 and csv_row[1].length <=255 then\n #remove spaces in email_id\n csv_row[1] = csv_row[1].gsub(\" \",\"\")\n #validate_email() method validates the email id with the regular expression\n if validate_email(csv_row[1])\n fill_learners_table(csv_row)\n return true\n else\n return false\n end\n else\n return false\n end\n else\n return false\n end\n end", "def check_unused_ios(worksheet, from_row, to_row, target_directory, mark)\n puts \"\\nUNUSED IOS KEYS:\"\n for row in from_row..to_row\n key = worksheet[row, 1]\n unless key.blank?\n term = Term.new(key)\n if term.restriction == 'i' || term.restriction == nil\n if !term.is_comment?\n result = find_text_on_ios_files(target_directory,term.keyword_iphone_constant)\n if(result.length == 0)\n puts term.keyword_iphone_constant\n if(mark)\n #modifiying key on spreadsheet by prepending [u] to mark key as unused\n worksheet[row, 1] = '[u]'+key\n end\n end\n else\n puts \"\\n==> Group:\"\n end\n end\n end\n end\n if(mark)\n worksheet.save()\n end\nend", "def import_vendor_file()\n @worksheet_products.each { |row|\n if(@vendor_row = build_vendor_hash(row))\n import_vendor()\n end\n }\n end", "def handle_changed_sis_user_ids\n if Settings.canvas_proxy.dry_run_import.present?\n logger.warn \"DRY RUN MODE: Would change #{@sis_user_id_changes.length} SIS user IDs #{@sis_user_id_changes.inspect}\"\n else\n logger.warn \"About to change #{@sis_user_id_changes.length} SIS user IDs\"\n @sis_user_id_changes.each do |canvas_user_id, new_sis_id|\n self.class.change_sis_user_id(canvas_user_id, new_sis_id)\n end\n end\n end", "def accept_data\n #debugger\n hash = {}\n hash[:date] = params[:my_param] \n hash[:employee_id] = params[:ids]\n Tasksheet.where(hash).update_all(status: \"accept\")\n end", "def parse_excel_file(subtopic_id,topic_id,question_bank_id,excel_file,tenant_id)\n import = Import.new(excel_file)\n if import.save!\n mime = (MIME::Types.type_for(import.excel.path)[0])\n mime_obj = mime.extensions[0]\n #do not process further if the uploaded file is other than xls,xlsx\n if (!mime_obj.nil? and !mime_obj.blank?) and (mime_obj.include? \"xls\" or mime_obj.include? \"xlsx\" or mime_obj.include? \"ods\") then\n @roo = create_roo_instance(import.excel.path,mime_obj)\n process_the_excel_file(import.id,subtopic_id,topic_id,question_bank_id,tenant_id)\n else\n flash[:notice] = 'Upload only document or excel file'\n end\n delete_excel(import.excel.path)\n import.destroy\n else\n flash[:notice] = 'Excel data import failed'\n end\n end", "def handle_duplicate_logs\n all_non_current_user_dup_user_extended_details_ids = []\n\n # Fetch all user_extended_details corresponding to current user_extended_details1_id\n all_non_current_user_dup_user_extended_details_ids += UserKycDuplicationLog.using_client_shard(client: @client).\n non_deleted.where(\n user_extended_details1_id: @user_kyc_detail.user_extended_detail_id, status: GlobalConstant::UserKycDuplicationLog.active_status).pluck(:user_extended_details2_id)\n\n # Fetch all user_extended_details corresponding to current user_extended_details2_id\n all_non_current_user_dup_user_extended_details_ids += UserKycDuplicationLog.using_client_shard(client: @client).\n non_deleted.where(\n user_extended_details2_id: @user_kyc_detail.user_extended_detail_id, status: GlobalConstant::UserKycDuplicationLog.active_status).pluck(:user_extended_details1_id)\n\n # Initiailize\n active_dup_user_extended_details_ids, inactive_dup_user_extended_details_ids, user_ids = [], [], []\n # Fetch active, inactive user_extended_details_ids\n UserKycDuplicationLog.using_client_shard(client: @client).non_deleted.\n where(\n \"user_extended_details1_id IN (?) OR user_extended_details2_id IN (?)\",\n all_non_current_user_dup_user_extended_details_ids,\n all_non_current_user_dup_user_extended_details_ids\n )\n .select(:id, :user1_id, :user2_id, :user_extended_details1_id, :user_extended_details2_id, :status).all.each do |ukdl|\n\n next if (ukdl.user_extended_details1_id == @user_kyc_detail.user_extended_detail_id) ||\n (ukdl.user_extended_details2_id == @user_kyc_detail.user_extended_detail_id)\n\n if ukdl.status == GlobalConstant::UserKycDuplicationLog.active_status\n active_dup_user_extended_details_ids << ukdl.user_extended_details1_id\n active_dup_user_extended_details_ids << ukdl.user_extended_details2_id\n else\n inactive_dup_user_extended_details_ids << ukdl.user_extended_details1_id\n inactive_dup_user_extended_details_ids << ukdl.user_extended_details2_id\n end\n user_ids << ukdl.user1_id\n user_ids << ukdl.user2_id\n end if all_non_current_user_dup_user_extended_details_ids.present?\n\n active_dup_user_extended_details_ids.uniq!\n inactive_dup_user_extended_details_ids.uniq!\n user_ids.uniq!\n\n active_dup_user_extended_details_ids = active_dup_user_extended_details_ids & all_non_current_user_dup_user_extended_details_ids\n inactive_dup_user_extended_details_ids = inactive_dup_user_extended_details_ids & all_non_current_user_dup_user_extended_details_ids\n\n\n inactive_dup_user_extended_details_ids -= active_dup_user_extended_details_ids\n # Mark inactive user_extended_details_ids as was_kyc_duplicate_status\n # Active user_kyc_details will already be is_kyc_duplicate_status\n if inactive_dup_user_extended_details_ids.present?\n UserKycDetail.using_client_shard(client: @client).active_kyc.where(user_extended_detail_id: inactive_dup_user_extended_details_ids).\n update_all(kyc_duplicate_status: GlobalConstant::UserKycDetail.was_kyc_duplicate_status,\n updated_at: Time.now.to_s(:db))\n end\n\n never_dup_user_extended_details_ids = (all_non_current_user_dup_user_extended_details_ids - active_dup_user_extended_details_ids - inactive_dup_user_extended_details_ids)\n # Mark missing dup_user_extended_details_ids as never_kyc_duplicate_status\n if never_dup_user_extended_details_ids.present?\n UserKycDetail.using_client_shard(client: @client).where(user_extended_detail_id: never_dup_user_extended_details_ids).\n update_all(kyc_duplicate_status: GlobalConstant::UserKycDetail.never_kyc_duplicate_status, updated_at: Time.now.to_s(:db))\n end\n\n # Delete all entries corresponding to all_non_current_user_dup_user_extended_details_ids\n UserKycDuplicationLog.using_client_shard(client: @client).where(\"user_extended_details1_id = ? OR user_extended_details2_id = ?\",\n @user_kyc_detail.user_extended_detail_id, @user_kyc_detail.user_extended_detail_id).delete_all\n\n # Mark current user as unprocessed\n @user_kyc_detail.kyc_duplicate_status = GlobalConstant::UserKycDetail.unprocessed_kyc_duplicate_status\n @user_kyc_detail.save!\n # Perform Check duplicates again for current user id\n r = AdminManagement::Kyc::CheckDuplicates.new({client: @client, user_id: @user_kyc_detail.user_id}).perform\n return r unless r.success?\n\n UserKycDetail.using_client_shard(client: @client).bulk_flush(user_ids)\n\n success\n end", "def parse_xlsx\n 2.upto(@spreadsheet.last_row).each do |row_index|\n row = info_hash(row_index)\n \n unless row.nil?\n @data[row[:name]] ||= {\n code: row[:code],\n worlds: [],\n areas: [],\n positions: []\n }\n\n @data[row[:name]][:worlds] << row[:world] if !row[:world].blank? && !@data[row[:name]][:worlds].include?(row[:world])\n @data[row[:name]][:areas] << row[:area] if !row[:area].blank? && !@data[row[:name]][:areas].include?(row[:area])\n @data[row[:name]][:positions] << row[:position] if !row[:position].blank? && !@data[row[:name]][:positions].include?(row[:position])\n end\n end\n end", "def read_server_write_file(agent, creds, url, outfilename, field_blacklist, field_order, categories)\n wb = RubyXL::Workbook.new\n\n # Admin worksheet\n ws_admin = wb.add_worksheet('Admin')\n ws_admin.add_cell(0, 0, 'Admin user')\n ws_admin.add_cell(0, 1, 'Password')\n ws_admin.add_cell(1, 0, creds[:username])\n ws_admin.add_cell(1, 1, creds[:password])\n\n SUPPORTED_TABS.each do |tab|\n category = tab.downcase\n next unless categories.empty? || categories.include?(category.sub(/\\..*/, ''))\n ws = nil # Delay creating the worksheet until we know whether there are any entries to put on it\n\n case category\n # Extensions have a subcategory: tech. Different technologies have different attributes, which means they can't\n # share a tab in the Excel file so easily.\n when /extensions\\./\n category,tech = category.split('.')\n ext_page = get_page(agent, creds, url + CONFIG, {display: category})\n ext_grid_result = get_page(agent, creds, url + AJAX,\n {module: :core, command: :getExtensionGrid, type: tech, order: :asc}, ext_page.uri.to_s)\n ext_grid = JSON.parse(ext_grid_result.body)\n extn_table = []\n ext_grid.each do |ext|\n ext_page = get_page(agent, creds, url + CONFIG,\n {display: :extensions, extdisplay: ext['extension']}, ext_grid_result.uri.to_s)\n puts \"Extension #{ext['extension']}\" unless $quiet\n ws ||= wb.add_worksheet(tab)\n extn_table << construct_row_from_form(ext_page.form('frm_extensions'), field_blacklist[category])\n end\n write_table(ws, extn_table, field_order[category]) if ws\n\n # Trunks have a subcategory: tech. Different technologies have different attributes, which means they can't\n # share a tab in the Excel file so easily.\n when /trunks\\./\n category,tech = category.split('.')\n trunks_page = get_page(agent, creds, url + CONFIG, {display: :trunks})\n trunks_grid_result = get_page(agent, creds, url + AJAX,\n {module: :core, command: :getJSON, jdata: :allTrunks, order: :asc}, trunks_page.uri.to_s)\n trunks_grid = JSON.parse(trunks_grid_result.body)\n\n trnk_table = []\n trunks_page.css('table#table-all/tbody/tr').each do |tr| # For each trunk, find its table row...\n next unless tr.css('td')[1].text == tech # ...ignore if wrong tech\n a = tr.css('td/a') # Find the 'edit' link\n if a and a.first\n linkaddr = a.first['href'] # Follow trunk's 'edit' link\n trunk_page = get_page(agent, creds, url + ADMIN + '/' + linkaddr, '', trunks_page.uri.to_s)\n # Look up this trunk in the JSON data returned from the AJAX request (without assuming row ordering)\n trk_data = trunks_grid.detect { |e| e['trunkid'] == tr['id'] }\n puts \"Trunk #{trk_data['name']}\" unless $quiet\n # Tell the form-reader to override certain radioboxes, based on the JSON data.\n # This is necessary because the returned form doesn't contain the currently selected data. Instead,\n # a JavaScript script retrieves some JSON data and sets some of the radioboxes. It even overrides\n # the value of the 'outcid' field (which is not emulated here).\n override = {\n hcidyes: (/hidden/ =~ trk_data['outcid']),\n hcidno: !(/hidden/ =~ trk_data['outcid']),\n keepcidoff: trk_data['keepcid'] == 'off',\n keepcidon: trk_data['keepcid'] == 'on',\n keepcidcnum: trk_data['keepcid'] == 'cnum',\n keepcidall: trk_data['keepcid'] == 'all',\n continueno: trk_data['continue'] == 'off',\n continueyes: !(trk_data['continue'] == 'off'),\n disabletrunkno: trk_data['disabled'] == 'off',\n disabletrunkyes: !(trk_data['disabled'] == 'off')\n }\n\n ws ||= wb.add_worksheet(tab)\n trnk_table << construct_row_from_form(trunk_page.form('trunkEdit'), field_blacklist[category], override)\n end\n write_table(ws, trnk_table, field_order[category]) if ws\n end\n end\n end\n\n #wb.delete_worksheet('Sheet1')\n wb.write(outfilename)\nend", "def dailyroster_file\n active_date = self.active_date.to_date\n path = File.join(\"public/system/dailyrosters/#{active_date.to_formatted_s(:number)}\", self.dailyroster_file_name)\n flight_date = active_date\n DataFile.load_codeshare_flights(flight_date)\n Spreadsheet.open(path, 'r') do |book|\n sheet = book.worksheet 0\n (7..sheet.row_count).each do |i|\n if (!sheet.row(i)[0].nil?)\n aircraft = get_aircraft(sheet.row(i)[1].to_s)\n flight_no = sheet.row(i)[2]\n routing_raw = sheet.row(i)[3].strip\n route = Routing.find_or_create_by_routing(routing_raw)\n if (sheet.row(i)[3].slice(0,3) == \"SGN\")\n # flight = Flight.unscoped.find_or_initialize_by_flight_no_and_flight_date(flight_no, flight_date)\n # flight.flight_no = flight_no\n # flight.routing_id = route.id\n # flight.aircraft_id = aircraft.id\n # flight.flight_date = calculate_flight_date(flight_date,sheet.row(i))\n # flight.std = calculate_flight_time(flight_date, sheet.row(i))\n # flight.remark = sheet.row(i)[9] unless sheet.row(i)[9].nil?\n # flight.save!\n else\n if (flight_no.slice(0,2) != \"VN\")\n cs_flight = FlightType.find_by_flight_no_to(flight_no)\n flight_no = cs_flight.flight_no_from unless cs_flight.nil?\n end\n flight = ArrivalFlight.unscoped.find_or_initialize_by_flight_no_and_flight_date(flight_no, calculate_flight_date(flight_date,sheet.row(i))) \n flight.routing_id = route.id\n flight.reg_no = aircraft.reg_no\n flight.flight_date = calculate_flight_date(flight_date,sheet.row(i))\n flight.sta = calculate_flight_time(flight_date, sheet.row(i))\n flight.update_is_domestic\n flight.is_active = true\n flight.is_approval = false\n sheet.row(i)[9].nil? ? flight.remarks = \"\" : flight.remarks = sheet.row(i)[9]\n cs_flight.nil? ? flight.remarks = flight.remarks + \"\" : flight.remarks = cs_flight.flight_no_to + \"|#{flight.remarks}\"\n flight.save!\n end\n end\n end\n end\n path\n end", "def import_gifts_import\n @activity = params[:activity]\n if @activity.blank?\n flash[:error] = \"Please choose an activity.\"\n redirect_to import_gifts_step_three_url\n return\n end\n \n @file = params[:file]\n if @file.nil?\n flash[:error] = \"Please choose a file.\"\n redirect_to import_gifts_step_three_url\n return\n end\n \n error = false\n csv_string = CSV.generate(:headers => true) do |output|\n CSV.foreach(@file.path, :headers => true, :return_headers => true, :col_sep => ',') do |row| #@file.path\n if row.header_row?\n output << (row << \"import notes\")\n else\n warning_msg = \"\"\n data_hash = row.to_hash\n if (!data_hash[\"donor_id\"].to_s.empty?) # donor_id not blank\n if Donor.exists?(data_hash[\"donor_id\"].to_i) # donor exists in db\n warning_msg += validate_gift(data_hash) # validate required gift fields for import\n if warning_msg == \"\" # one donor found, all reqired data present, import gift\n Gift.create!(new_gift_hash(data_hash, @activity, data_hash['donor_id'], @file.original_filename))\n else\n error = true\n output << (row << warning_msg)\n end\n else # donor_id do not exist in db\n error= true\n warning_msg += \"donor_id not exist in data base\"\n output << (row << warning_msg)\n end\n else # donor_id is blank, need to search for donor\n found_donor = Donor.where(\"first_name = ? AND last_name = ?\", \n data_hash[\"first_name\"], data_hash[\"last_name\"])\n found_donor_number = found_donor.count\n if found_donor_number == 0 # no matching donor -- create donor and create gift\n warning_msg += validate_donor(data_hash) # check if all the required fields for this donor are properly filled in\n warning_msg += validate_gift(data_hash) # check if all the required fields for this gift are properly filled in\n if warning_msg == \"\"\n new_donor = Donor.create!(:donor_type => data_hash['donor_type'], :first_name => data_hash['first_name'], \n :last_name => data_hash['last_name'], :address => data_hash ['address'], \n :city => data_hash['city'], :state => data_hash['state'], :zip => data_hash['zip'], :email => data_hash['email'], \n :title => data_hash['title'], :nickname => data_hash['nickname'], :address2 => data_hash['address2'], \n :country => data_hash[:country], :phone => data_hash['phone'], :notes => data_hash['donor_notes'])\n Gift.create!(new_gift_hash(data_hash, @activity, new_donor.id, @file.original_filename))\n else\n error = true\n output << (row << warning_msg)\n end\n elsif found_donor_number == 1 # one matching donor\n warning_msg = validate_gift(data_hash)\n if warning_msg == \"\"\n Gift.create!(new_gift_hash(data_hash, @activity, found_donor.first.id, @file.original_filename))\n else\n error = true\n output << (row << warning_msg)\n end\n else # more than one matching donor\n error = true\n output << (row << \"conflict\")\n end\n end\n end\n end\n end\n if error == false # all donors and gifts are added\n flash[:success] = \"Gifts imported successfully.\"\n redirect_to gifts_path\n else # some donors or gifts can not be added, export csv file for review\n send_data csv_string, \n :type => 'text/csv; charset=iso-8859-1; header=present', \n :disposition => \"attachment; filename=not_imported_gifts_#{Date.today}.csv\"\n end\n end", "def op_defect_import\n spreadsheet = open_spreadsheet(params[:file])\n # header parsing - header는 반드시 1 라인에 있어야 함\n header = spreadsheet.row(1)\n import_data_list = []\n \n # Routing | Defect Code\n (2..spreadsheet.last_row).each do |i|\n row = spreadsheet.row(i)\n raise Hatio::Exception::MisConfigured, (I18n.translate 'error.empty_not_allowed') + ' - Routing' if(!row[0] || row[0].empty?)\n raise Hatio::Exception::MisConfigured, (I18n.translate 'error.empty_not_allowed') + ' - Scrap Code' if(!row[1] || row[1].empty?)\n \n opId = \"#{@domain.id}-#{row[0].strip}\"\n defectCodeId = \"#{@domain.id}-#{row[1].strip}\"\n \n # 존재 하는지 체크 \n raise Hatio::Exception::MisConfigured, (I18n.translate 'error.operation_not_exist') + ' - Routing (' + row[0] + ')' unless(Operation.find_by_id(opId))\n raise Hatio::Exception::MisConfigured, (I18n.translate 'error.defect_code_not_exist') + ' - Scrap Code (' + row[1] + ')' unless(DefectCode.find_by_id(defectCodeId))\n \n row_data = {'operation_id' => opId, 'defect_code_id' => defectCodeId}\n import_data_list.push(row_data)\n end\n \n OperationsDefects.transaction do\n import_data_list.each do |import_data|\n op_defect = OperationsDefects.new(import_data)\n op_defect_cnt = OperationsDefects.where(\"operation_id = ? and defect_code_id = ?\", op_defect.operation_id, op_defect.defect_code_id).count\n begin\n op_defect.save! if(op_defect_cnt == 0)\n rescue ::Exception => e\n debug_print \"Duplicated : #{op_defect.operation_id}, #{op_defect.defect_code_id}\"\n end\n end unless(import_data_list.empty?)\n end\n \n @result = {\"success\" => true, \"message\" => \"Success\"}\n respond_to do |format|\n format.xml { render :xml => @result } \n format.json { render :json => @result }\n end\n end", "def process!\n if valid?\n # get the csv rows as an array of hashes\n setup_data\n raw_csv_data = compute_csv_data\n # remove duplicate rows in the csv file (by email or name)\n prefilterted_csv_data = prefilter_csv_data raw_csv_data\n # remove the rows that match emails in the database\n new_data = filter_data_through_db prefilterted_csv_data\n\n # crate a new users\n resolved_data = create_new_user_records new_data\n end\n @rejected_user_data\n end", "def save_as_spreadsheet\n session = GoogleDrive::Session.from_config(\"../../config.json\")\n spreadsheet = session.spreadsheet_by_name(\"testcreatefile\").worksheets[0] # on dit a l'api que l'on souhaite modifier le spreadsheet qui porte X nom et la feuille numero 0 de ce meme spreadsheet\n @@name_and_email.map.with_index do |hash, index| # on parcour le tableau qui contion les nom et les emails de chasque ville\n name = hash.keys # je met la key du hash dans une variable, cette variable corespond au nom de la ville\n name = name[0] # je transforme ma variable en string (sans cette ligne cette variable est de type array)\n email = hash.values # je met la value du hash dans une variable, cette variable corespond a l'email de la ville\n email = email[0] # je transforme ma variable en string (sans cette ligne cette variable est de type array)\n spreadsheet[index + 1, 1] = name # le programme envoi le nom de la ville sur le spreadsheet\n spreadsheet[index + 1, 2] = email # le programme envoi l'email de la ville sur le spreadsheet\n end\n spreadsheet.save # le programme sauvegarde les modifications sur le spreadsheet qu'il a modifier\n end", "def flat_map_rows(row)\n # match student by id first, fall back to name\n local_id_text = row['LASID']\n fullname_text = row['Student Name']\n return nil if local_id_text == '' && fullname_text == '' # blank row\n student_id = @matcher.find_student_id_with_exact_or_fuzzy_match(local_id_text, fullname_text)\n return nil if student_id.nil?\n\n # timestamp, just used import time since it's not in the sheet\n form_timestamp = @time_now\n\n # look for service names\n found_service_type_names = find_service_type_names(row)\n\n # time range is coarse, whole school year\n date_started = SchoolYear.first_day_of_school_for_year(@school_year)\n discontinued_at = SchoolYear.last_day_of_school_for_year(@school_year)\n found_service_type_names.map do |service_type_name|\n service_type = ServiceType.find_by(name: service_type_name)\n {\n student_id: student_id,\n recorded_by_educator_id: @recorded_by_educator.id,\n service_type_id: service_type.id,\n recorded_at: form_timestamp,\n date_started: date_started,\n estimated_end_date: discontinued_at,\n discontinued_at: discontinued_at,\n discontinued_by_educator_id: @recorded_by_educator.id,\n provided_by_educator_name: nil,\n service_upload_id: nil\n }\n end\n end", "def todas_personas\n down = \"/public/reportes/\"\n reportes = RAILS_ROOT + down\n tiempo = Time.zone.now.to_s(:number)\n @personas = Persona.find :all, \n :select=>\"id, nombre, apepat, apemat, familia_id, sexo, nacimiento\",\n :include=>[\"familia\", \"relacions\"]\n #creo la hoja en excell\n book = Spreadsheet::Workbook.new\n sh1 = book.create_worksheet :name => \"Personas\"\n #relleno la hoja\n sh1.row(0).concat( [\"Ficha persona\",\"nombre\",\"apepat\",\"apemat\",\"sexo\",\"nacimiento\",\"Ficha familia\"] +\n [\"p apepat\",\"p nombre\",\"m apepat\",\"m nombre\"] + \n [\"telefonos\",\"direccion1\",\"distrito\",\"ciudad\", \"region\",\"pais\"] + \n [\"Ficha inst\",\"institucion\"]\n )\n #rellenando las filas con los datos\n i = 0\n @personas.each do |p|\n i=i+1\n #guardo el link a la ficha de la persona\n sh1.row(i).push Spreadsheet::Link.new(url_for(p),p.id.to_s)\n sh1.row(i).push p.nombre, p.apepat, p.apemat, p.sexo, p.nacimiento\n #la familia\n #guardo el link a la familia\n if p.familia_id? \n sh1.row(i).push Spreadsheet::Link.new(url_for(p.familia),p.familia_id.to_s)\n else\n sh1.row(i).push \"-sin familia-\"\n end\n padre = nil\n madre = nil\n padre = p.familia.padre if p.familia_id and p.familia\n padre ||= Persona.new(:nombre=>\"-sin padre-\")\n madre = p.familia.madre if p.familia_id and p.familia\n madre ||= Persona.new(:nombre=>\"-sin madre-\")\n sh1.row(i).push(padre.apepat, padre.nombre)\n sh1.row(i).push(madre.apepat, madre.nombre)\n #direccion\n d = p.direccion\n sh1.row(i).push d.telefonos,d.street_1,d.street_2,d.city,d.region_name,d.country_with_region_check\n #institucion\n ins = p.institucions.first \n unless ins == nil\n sh1.row(i).push Spreadsheet::Link.new(url_for(ins),ins.id.to_s), ins\n else\n sh1.row(i).push \"\", \"-sin institución-\"\n end\n\n end\n #guardo\n book.write reportes + \"#{tiempo}.xls\"\n @download = \"/reportes/#{tiempo}.xls\"\n\n end", "def import_csv_smart\n \n end", "def import_gifts_validate\n @file = params[:file]\n if @file.nil?\n flash[:error] = \"Please choose a file.\"\n redirect_to import_gifts_step_two_url\n return\n end\n csv_string = CSV.generate(:headers => true) do |output|\n CSV.foreach(@file.path, :headers => true, :return_headers => true, :col_sep => ',') do |row|\n if row.header_row?\n output << (row << \"validation notes\")\n else\n warning_msg = \"\"\n data_hash = row.to_hash\n if (!data_hash[\"donor_id\"].to_s.empty?) # donor_id not blank\n if Donor.exists?(data_hash[\"donor_id\"].to_i) # donor exists in db\n warning_msg += validate_gift(data_hash) # validate required gift fields for import\n if warning_msg == \"\" \n output << (row << \"ready for import\")\n else\n output << (row << warning_msg)\n end\n else # donor_id do not exist in db\n warning_msg += \"donor_id not exist in data base\"\n output << (row << warning_msg)\n end\n else # donor_id is blank in csv file\n found_donor = Donor.where(\"first_name = ? AND last_name = ?\", \n data_hash[\"first_name\"], data_hash[\"last_name\"])\n found_donor_number = found_donor.count\n if found_donor_number == 0 # no matching donor, check if all the required fields for this gift and this donor are properly filled in\n warning_msg += validate_donor(data_hash)\n warning_msg += validate_gift(data_hash)\n if warning_msg == \"\" # all required fields of gift and donnor are present\n output << (row << \"New Donor; ready for import\")\n else\n output << (row << (\"new donor; \" + warning_msg))\n end\n elsif found_donor_number == 1 # one matching donor, check if all the required fields for this gift are properly filled in\n warning_msg = validate_gift(data_hash)\n if warning_msg == \"\"\n output << (row << (\"donor_id = \" + found_donor.first.id.to_s + \", ready for import\"))\n else\n output << (row << warning_msg)\n end\n else # more than one matching donor\n output << (row << \"conflict\")\n end\n end \n end\n end\n end\n # create csv file for review\n send_data csv_string, \n :type => 'text/csv; charset=iso-8859-1; header=present', \n :disposition => \"attachment; filename=validated_gifts_#{Date.today}.csv\"\n end", "def invalid_preservation_change?(row)\n existing_files_by_filename[row[\"filename\"]].administrative.sdrPreserve == false && row[\"preserve\"] == \"yes\"\n end", "def save_as_spreadsheet\n session = GoogleDrive::Session.from_config(\"../config.json\")\n ws = session.spreadsheet_by_key(ENV['SPREADSHEET_KEY']).worksheets[0]\n ws.reload\n i = 0\n n = get_townhall_urls.count\n while i <= 4\n ws[i+1, 1] = @emails[i]\n ws[i+1, 2] = @names_of_town[i]\n i +=1\n end\n ws.save\n end", "def write_excel\n #get param\n @user = index\n @hashtags= @user.hashtags\n #generate new Excel file\n workbook = RubyXL::Workbook.new\n worksheet=workbook[0]\n #save information for all post\n worksheet.add_cell(0, 1, \"ID\")\n worksheet.add_cell(0, 2, \"FOLLOWERS\")\n worksheet.add_cell(0, 3, \"LEVEL\")\n worksheet.add_cell(0, 4, \"SCORE\")\n worksheet.add_cell(0, 5, \"SUM\")\n worksheet.add_cell(1, 1, @user.username)\n worksheet.add_cell(1, 2, @user.followers)\n worksheet.add_cell(1, 3, @user.level)\n worksheet.add_cell(1, 4, @user.score)\n worksheet.add_cell(1, 5, @user.sum)\n #write hashtags\n worksheet.add_cell(3, 0, \"RANK\")\n worksheet.add_cell(3, 1, \"HASHTAG\")\n worksheet.add_cell(3, 2, \"TIMES\")\n worksheet.add_cell(3, 3, \"GLOBAL TIMES\")\n worksheet.add_cell(3, 4, \"VALUE\")\n worksheet.add_cell(3, 5, \"AVAILABILITY\")\n i=0\n for hashtag in @hashtags\n worksheet.add_cell(i+4, 0, i+1)\n worksheet.add_cell(i+4, 1, hashtag.hashtags)\n worksheet.add_cell(i+4, 2, hashtag.use_by_user)\n worksheet.add_cell(i+4, 3, hashtag.use_by_global)\n worksheet.add_cell(i+4, 4, hashtag.avai == \"0\" ? hashtag.use_by_global*hashtag.use_by_user : 0 )\n worksheet.add_cell(i+4, 5, hashtag.avai) \n i=i+1 \n end\n #send\n send_data( workbook.stream.string, :filename => \"#{@user.username}-#{@percentage}%-hashtags.xlsx\" ) \n end", "def post_process(sheet)\n # Do nothing\n end", "def loadstudents\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n logger.debug 'about to read spreadsheet'\n startrow = 3\n # first get the 3 columns - Student's Name + Year, Focus, study percentages\n range = \"STUDENTS!A#{startrow}:C\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n @students = Array.new(response.values.length){Array.new(11)}\n #logger.debug \"students: \" + @students.inspect\n basecolumncount = 1 #index for loading array - 0 contains spreadsheet row number\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n @students[rowcount][0] = rowcount + startrow\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 3\n # second get the 1 column - email\n range = \"STUDENTS!E#{startrow}:E\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n #logger.debug \"students: \" + @students.inspect\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 1\n #third get the perferences and invcode\n range = \"STUDENTS!L#{startrow}:M\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n rowcount = 0\n response.values.each do |r|\n colcount = 0\n r.each do |c|\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 2\n #fourth get the 3 columns daycode, term 4, daycode\n # these will be manipulated to get the savable daycode\n range = \"STUDENTS!P#{startrow}:R\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n rowcount = 0\n response.values.each do |r|\n colcount = 0\n r.each do |c|\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 3\n #logger.debug \"students: \" + @students.inspect\n # Now to update the database\n loopcount = 0 # limit output during testing\n @students.each do |t| # step through all ss students\n pnameyear = t[1]\n logger.debug \"pnameyear: \" + pnameyear.inspect\n if pnameyear == \"\" || pnameyear == nil\n t[10] = \"invalid pnameyear - do nothing\"\n next\n end\n #pnameyear[/^zz/] == nil ? status = \"active\" : status = \"inactive\"\n name_year_sex = getStudentNameYearSex(pnameyear)\n pname = name_year_sex[0]\n year = name_year_sex[1]\n sex = name_year_sex[2]\n status = name_year_sex[3]\n logger.debug \"pname: \" + pname + \" : \" + year + \" : \" +\n sex.inspect + \" : \" + status\n # day code\n # use term 3 code unless a term 4 code, then take term 4\n t[9] == \"\" || t[9] == nil ? usedaycode = t[7] : usedaycode = t[9]\n # check if alrady an entry in the database\n # if so, update it. else create a new record.\n db_student = Student.find_by pname: pname\n if(db_student) # already in the database\n flagupdate = 0 # detect if any fields change\n updatetext = \"\"\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n if db_student.year != year\n db_student.year = year\n flagupdate = 1\n updatetext = updatetext + \" - year\" \n end\n if sex\n if db_student.sex != sex\n db_student.sex = sex\n flagupdate = 1\n updatetext = updatetext + \" - sex (\" + sex + \")\"\n end\n end\n if db_student.comment != t[2]\n db_student.comment = t[2]\n flagupdate = 1\n updatetext = updatetext + \" - comment\" \n end\n if db_student.study != t[3]\n db_student.study = t[3]\n flagupdate = 1\n updatetext = updatetext + \" - study percentages\" \n end\n if db_student.email != t[4]\n db_student.email = t[4]\n flagupdate = 1\n updatetext = updatetext + \" - email\" \n end\n if db_student.preferences != t[5]\n db_student.preferences = t[5]\n flagupdate = 1\n updatetext = updatetext + \" - preferences\" \n end\n if db_student.invcode != t[6]\n db_student.invcode = t[6]\n flagupdate = 1\n updatetext = updatetext + \" - invoice code\" \n end\n if db_student.daycode != usedaycode\n db_student.daycode = usedaycode\n flagupdate = 1\n updatetext = updatetext + \" - day code\" \n end\n if db_student.status != status\n db_student.status = status\n flagupdate = 1\n updatetext = updatetext + \" - status\" \n end\n logger.debug \"flagupdate: \" + flagupdate.inspect + \" db_student: \" + db_student.inspect\n if flagupdate == 1 # something changed - need to save\n if db_student.save\n logger.debug \"db_student saved changes successfully\"\n t[10] = \"updated #{db_student.id} \" + updatetext \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors\n t[10] = \"failed to update\"\n end\n else\n t[10] = \"no changes\"\n end\n else\n # This Student is not in the database - so need to add it.\n #\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n @db_student = Student.new(\n pname: pname,\n year: year,\n comment: t[2],\n study: t[3],\n email: t[4],\n preferences: t[5],\n invcode: t[6],\n daycode: usedaycode,\n status: status,\n sex: sex\n )\n logger.debug \"new - db_student: \" + @db_student.inspect\n if @db_student.save\n logger.debug \"db_student saved successfully\"\n t[10] = \"created #{@db_student.id}\" \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors.inspect\n t[10] = \"failed to create\"\n end\n end\n #exit\n if loopcount > 2\n #break\n end\n loopcount += 1\n end\n end", "def process\n uploaded_workbook = Spreadsheet.open self.path\n @records_matched = 0\n @records_updated = 0\n @records_failed = 0\n @failed_queries = 0\n @skipped_records = 0\n\n product_sheet = uploaded_workbook.worksheet(0)\n perform(product_sheet)\n\n if not uploaded_workbook.worksheet(1).nil?\n variant_sheet = uploaded_workbook.worksheet(1)\n perform(variant_sheet)\n end\nend", "def handle_people(data, import)\n path = @args[:data_directory] + 'TXT/people.txt'\n raise 'file not found' if not File.exists?(path)\n f = CSV.open(path, col_sep: \"\\t\", :headers => true)\n\n print 'Handling people '\n if import.metadata['people']\n print \"from database. Indexing People by PeopleID...\"\n f.each do |row|\n data.people_id.merge!(row['PeopleID'] => row)\n end\n\n DataAttribute.where(import_predicate: 'PeopleID', attribute_subject_type: 'User').each do |u|\n $user_index.merge!(u.value => u.attribute_subject_id)\n end\n\n DataAttribute.where(import_predicate: 'PeopleID', attribute_subject_type: 'People').each do |p|\n PEOPLE.merge!(p.value => p.attribute_subject_id)\n end\n\n print \"done.\\n\"\n else\n print \"as newly parsed.\\n\"\n f.each do |row|\n puts \"\\tNo last name: #{row}\" if row['LastName'].blank?\n p = Person::Vetted.new(\n last_name: row['LastName'] || 'Not Provided',\n first_name: row['FirstName'],\n data_attributes_attributes: [ {value: row['PeopleID'], import_predicate: 'PeopleID', type: 'ImportAttribute'} ]\n )\n p.notes.build(text: row['Comments']) if !row['Comments'].blank?\n p.save!\n #data.people.merge!(row => p)\n data.people_id.merge!(row['PeopleID'] => row)\n PEOPLE.merge!(row['PeopleID'] => p)\n end\n import.metadata['people'] = true\n end\n end", "def set_sheet\n user = authenticate\n sheet = Sheet.friendly.find(params[:id]) \n if sheet.user_id == user['id']\n @sheet = sheet\n else\n redirect_to root_url\n end\n end", "def save_as_spreadsheet\n\t\tsession = GoogleDrive::Session.from_config(\"config.json\")\n\t\tws = session.spreadsheet_by_key(\"1UAtn3oB21_a_gUM5TL8OK6Ud7zp6Z7z6c8tGYV6J4HA\").worksheets[0]\n\n\t\ti = 2\n\t\tws[1,1]= \"Ville\"\n\t\tws[1,2] = \"Contact\"\n\t\t@email_town.each_pair do |key, value| #/ on aurait pû utiliser each mais each_pair est plus conseillé lorsqu'il y a deux éléments \n\t\t\tws[i,1] = key\n\t\t\tws[i,2] = value\n\t\t\ti += 1\n\t\tend\n\t\tws.save \n\t\tws.reload\n\tend", "def upload_validate_donor\n donor_file = params[:excel_file]\n file = ExcelUploader.new\n file.store!(donor_file)\n book = Spreadsheet.open \"#{file.store_path}\"\n sheet1 = book.worksheet 0\n @donors = []\n @errors = Hash.new\n @counter = 0\n\n sheet1.each 1 do |row|\n @counter+=1\n cur_donor = Donor.new\n # Populate Fields\n cur_donor.ser_no = row[0]\n cur_donor.title = row[1]\n cur_donor.first_name = row[2]\n\n # Last Name formatting\n if row[3].blank?\n cur_donor.last_name = \".\"\n else\n cur_donor.last_name = row[3]\n end\n\n # Gender format changes\n if ((row[4] == \"B\") || (row[4] == \"Boy\") || (row[4] == \"M\") || (row[4] == \"Male\"))\n cur_donor.gender = \"Male\"\n elsif ((row[4] == \"G\") || (row[4] == \"Girl\") || (row[4] == \"F\") || (row[4] == \"Female\"))\n cur_donor.gender = \"Female\"\n else\n cur_donor.gender = row[4]\n end\n\n cur_donor.email = row[5]\n cur_donor.address_first_line = row[6]\n cur_donor.address_second_line = row[7]\n cur_donor.address_landmark = row[8]\n cur_donor.district = row[9]\n cur_donor.city = row[10]\n cur_donor.state = row[11]\n cur_donor.country = row[12]\n cur_donor.pincode = row[13]\n cur_donor.phone = row[14].to_s\n cur_donor.mobile = row[15].to_s.to_s\n cur_donor.donor_type = row[16]\n cur_donor.comment = row[17]\n\n if cur_donor.valid?\n @donors << cur_donor\n # Save the data to DB on success validation for each entry\n cur_donor.save\n else\n @errors[\"#{@counter+1}\"] = cur_donor.errors\n end\n end\n file.remove!\n end", "def export_for_goodreads(w, config, count=0)\n missing = DATA.readlines.map(&:chomp).map{|e| e.gsub(/\\W/, '')}\n row = 2\n CSV.open(config[:csv_file_out], 'wb') do |csv|\n csv << ['Title', 'Author', 'ISBN', 'My Rating', 'Average Rating', 'Publisher', 'Binding', 'Year Published',\n 'Original Publication Year', 'Date Read', 'Date Added', 'Bookshelves', 'My Review']\n until w[row, 1].empty? or (count > 0 and row - 1 > count) # end of sheet or just the first count records\n isbn = w[row, 10]\n # use optional whitelist in the DATA area below\n if not isbn.empty? and (missing.length == 0 or missing.include?(isbn))\n title = w[row, 1]\n # last name only\n author = w[row, 2].split(',').first\n rating = w[row, 8].count('*')\n date_read = w[row, 3]\n begin\n # GDoc seems to read the date the same as the display format (this has changed over time)\n date_fmt = Date.strptime(date_read, '%Y-%m-%d').strftime('%F')\n rescue Exception => e\n puts 'row %s: %s' % [row, date_read]\n raise e\n end\n csv << [ title, author, isbn, rating, '', '', '', '', '', date_fmt, '', '', '']\n puts '%-3s: %-15s | %-10s | %s | %-13s | %s -> %s' % [row - 1, title[0..14], author[0..9], rating, isbn[0..12],\n date_read, date_fmt]\n end\n row += 1\n end\n end\nend", "def init()\n\n p \"=======================\"\n p \"Iniciando o script...\"\n\n #\n # First Step\n # => Open file\n ############################\n data = Roo::Spreadsheet.open('./data/exemplo-curto.xlsx')\n p \"Abrindo o arquivo\"\n persons = organize_data(data)\n # validation\n # => verify if a valid email\n ############################\n #p \"validando os emails...\"\n #emails = validate_emails(data)\n #valid_emails = emails['validos']\n #invalid_emails = emails['invalidos']\n\n\n p \"OK\"\n #export_to_csv(\"emails_validos\", valid_emails)\n #export_to_xlsx(\"emails_validos\", valid_emails)\n #export_to_csv(\"emails_invalidos\", invalid_emails)\n #export_to_xlsx(\"emails_invalidos\", invalid_emails)\n #\n # Second Step\n # => organize for atributes\n # 1. UF\n # 2. DT_NASCIMENTO\n # 3. IF\n # 4. ESCOLARIDADE\n ##########################\n uf_mails = organize_to_uf (persons)\n uf_mails.each do | key, est |\n if est.length == 0 then\n p \"vazio #{key} \"\n else\n export_to_csv(key, est)\n export_to_xlsx(key, est)\n end\n\n end\n\n dt_nascimento_mails = organize_to_dt_nasc(persons)\n dt_nascimento_mails.each do | key, value |\n if value.length == 0 then\n p \"empty: #{key} \"\n else\n export_to_csv(key, value)\n export_to_xlsx(key, value)\n end\n\n end\n\n if_mails = organize_to_if (persons)\n if_mails.each do | key, value |\n if value.length == 0 then\n p \"empty: #{key} \"\n else\n export_to_csv(key, value)\n export_to_xlsx(key, value)\n end\n end\n\n escolaridade_mails = organize_to_escolaridade (persons)\n escolaridade_mails.each do | key, value |\n if value.length == 0 then\n p \"empty: #{key} \"\n else\n export_to_csv(key, value)\n export_to_xlsx(key, value)\n end\n end\n #\n # Third Step\n # => Export to xlsx\n ##########################\n p \"exportando arquivo\"\n #export_table(valid_emails)\n p \"Ok\"\n p \"FINALIZANDO\"\n\n end", "def loadstudents2\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n logger.debug 'about to read spreadsheet'\n startrow = 3\n # first get the 3 columns - Student's Name + Year, Focus, study percentages\n #This is now all that we get\n range = \"STUDENTS!A#{startrow}:C\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n @students = Array.new(response.values.length){Array.new(11)}\n #logger.debug \"students: \" + @students.inspect\n basecolumncount = 1 #index for loading array - 0 contains spreadsheet row number\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n @students[rowcount][0] = rowcount + startrow\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n #logger.debug \"students: \" + @students.inspect\n\n # Now to update the database\n loopcount = 0 # limit output during testing\n @students.each do |t| # step through all ss students\n pnameyear = t[1]\n logger.debug \"pnameyear: \" + pnameyear.inspect\n if pnameyear == \"\" || pnameyear == nil\n t[10] = \"invalid pnameyear - do nothing\"\n next\n end\n #pnameyear[/^zz/] == nil ? status = \"active\" : status = \"inactive\"\n name_year_sex = getStudentNameYearSex(pnameyear)\n pname = name_year_sex[0]\n year = name_year_sex[1]\n sex = name_year_sex[2]\n status = name_year_sex[3]\n logger.debug \"pname: \" + pname + \" : \" + year + \" : \" +\n sex.inspect + \" : \" + status\n\n # check if alrady an entry in the database\n # if so, update it. else create a new record.\n db_student = Student.find_by pname: pname\n if(db_student) # already in the database\n flagupdate = 0 # detect if any fields change\n updatetext = \"\"\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n if db_student.year != year\n db_student.year = year\n flagupdate = 1\n updatetext = updatetext + \" - year\" \n end\n if sex\n if db_student.sex != sex\n db_student.sex = sex\n flagupdate = 1\n updatetext = updatetext + \" - sex\"\n end\n end\n if db_student.comment != t[2]\n db_student.comment = t[2]\n flagupdate = 1\n updatetext = updatetext + \" - comment\" \n end\n if db_student.study != t[3]\n db_student.study = t[3]\n flagupdate = 1\n updatetext = updatetext + \" - study percentages\" \n end\n if db_student.status != status\n db_student.status = status\n flagupdate = 1\n updatetext = updatetext + \" - status\" \n end\n logger.debug \"flagupdate: \" + flagupdate.inspect + \" db_student: \" + db_student.inspect\n if flagupdate == 1 # something changed - need to save\n if db_student.save\n logger.debug \"db_student saved changes successfully\"\n t[10] = \"updated #{db_student.id} \" + updatetext \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors\n t[10] = \"failed to update\"\n end\n else\n t[10] = \"no changes\"\n end\n else\n # This Student is not in the database - so need to add it.\n #\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n @db_student = Student.new(\n pname: pname,\n year: year,\n comment: t[2],\n study: t[3],\n status: status\n )\n logger.debug \"new - db_student: \" + @db_student.inspect\n if @db_student.save\n logger.debug \"db_student saved successfully\"\n t[10] = \"created #{@db_student.id}\" \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors.inspect\n t[10] = \"failed to create\"\n end\n end\n #exit\n if loopcount > 2\n #break\n end\n loopcount += 1\n end\n end", "def get_the_name_and_email_and_put_it_in_spreadsheet(session, excel, tab)\n\n\t\t#on recupere le fichier mairie de notre drive\n\t\ttownhall_file = session.spreadsheet_by_title(excel)\n\n\t\t#je me positionne dans le 1er onglet de mon fichier spreadsheet drive (excel drive)\n\t\tonglet1 = townhall_file.worksheets[0]\n\n\t\t# on demarre\n\t\t# i à 2 car la 1ere ligne est la ligne qui contient les noms de colonne , i va de 2 à taille du tableau de hash soit 185+2=187\n\t\t# le hash est sous cette forme {nom_mairie:email_mairie}\n\t\ti=2\n\t\t#binding.pry\n\t\ttab.each do |element_du_tab_est_hash|\n\t\t\telement_du_tab_est_hash.each do |k,v|\n\t\t\t\tonglet1[i,1] = k\n\t\t\t\tonglet1[i,2] = v\n\t\t\tend\n\t\t\t#incrementation des lignes \"i\" en dehors des boucles d'insertion des valeurs\n\t\t\ti += 1\n\t\tend\n\t\t#on envoie les donnees au sheet drive :\n\t\tonglet1.save\n\t\treturn onglet1\n\tend", "def import_product_file()\n # local\n # file = open(self.spreadsheet.path)\n file = open(self.spreadsheet.url(:original))\n full_file = File.open(file.path)\n @workbook = RubyXL::Parser.parse(full_file)\n @worksheet_products = @workbook[0]\n @errors = []\n @worksheet_products.each { |row|\n if(@product_row = build_row_hash(row))\n import_product()\n end\n }\n end", "def upload_validate_student\n student_file = params[:excel_file]\n file = ExcelUploader.new\n file.store!(student_file)\n book = Spreadsheet.open \"#{file.store_path}\"\n sheet1 = book.worksheet 0\n @students = []\n @errors = Hash.new\n @counter = 0\n\n sheet1.each 1 do |row|\n @counter+=1\n cur_student = Student.new\n # Populate Fields\n cur_student.ser_no = row[0]\n cur_student.district = row[1]\n cur_student.taluka = row[2]\n cur_student.vp_id = row[3]\n cur_student.first_name = row[4]\n cur_student.father_name = row[5]\n cur_student.pmt_full_address = row[6]\n cur_student.cur_full_address = row[7]\n cur_student.primary_phone = row[8]\n cur_student.additional_phone = row[9]\n cur_student.father_occupation = row[10]\n cur_student.mother_occupation = row[11]\n cur_student.total_family_income = row[12]\n # Gender format changes\n if ((row[13] == \"B\") || (row[13] == \"Boy\") || (row[13] == \"M\") || (row[13] == \"Male\"))\n cur_student.gender = \"Boy\"\n elsif ((row[13] == \"G\") || (row[13] == \"Girl\") || (row[13] == \"F\") || (row[13] == \"Female\"))\n cur_student.gender = \"Girl\"\n else\n cur_student.gender = row[13]\n end\n\n # AreaType format changes\n if ((row[14] == \"R\") || (row[14] == \"Rural\"))\n cur_student.area_type = \"Rural\"\n elsif ((row[14] == \"U\") || (row[14] == \"Urban\"))\n cur_student.area_type = \"Urban\"\n else\n cur_student.area_type = row[14]\n end\n\n cur_student.caste = row[15]\n cur_student.studied_medium = row[16]\n cur_student.cet_rank = row[17]\n cur_student.sslc_percentage = row[18]\n cur_student.exam_ticket_number = row[19]\n cur_student.account_number = row[20]\n cur_student.atm_number = row[21]\n cur_student.house_visited_by = row[22]\n cur_student.last_year_donor = row[23]\n cur_student.present_year_donor = row[24]\n cur_student.comments = row[25]\n\t\t\t# For passing validations\n\t\t\tcur_student.last_name = \".\"\n\n\t\t\t# Check validity\n if cur_student.valid?\n @students << cur_student\n # Save the data to DB on success validation for each entry\n cur_student.save\n else\n @errors[\"#{@counter+1}\"] = cur_student.errors\n end\n end\n file.remove!\n end", "def skip_leading_rows= row_count\n frozen_check!\n @gapi.csv_options.skip_leading_rows = row_count\n end", "def skip_leading_rows= row_count\n frozen_check!\n @gapi.csv_options.skip_leading_rows = row_count\n end", "def import(file)\n spreadsheet = ModelCommon.open_spreadsheet(file)\n return '<p class = \"alert alert-error\">Try to do the following instructions:<br/>\n 1. Please save as the file to excel format.<br/>\n 2. Make sure MOAS data in the first sheet.<br/>\n 3. Header is in the first row.</p>' if spreadsheet.nil?\n\n header = downcase_array_key spreadsheet.row(1)\n\n # verify header, raise error if not map\n no_failed_hearders = MOASHeader.verify_header(header, @language)\n\n return ('<p class = \"alert alert-error\">Below is the missing header titles list. Please update header title(s) of the excel file || contact your administrator<br/>' << no_failed_hearders.to_s << '</p>') if no_failed_hearders != true\n return ('<p class = \"alert alert-error\">No data in excel file. Please re-check!</p>') if spreadsheet.last_row <= 1\n\n # begin transaction\n begin\n connection = Connection.new\n connection.open_connection_in_config\n connection.con.autocommit false\n\n # 1. DELETE ALL RECORDS\n connection.execute_sql_statement \"delete from #{@table}\"\n pstmt = connection.con.prepare(\"insert into #{@table}(golivedate,appstatus,sku,shorttitle,longtitle,gender,agefrommonths,agetomonths,skill,curriculum,longdesc,platformcompatibility,specialmsg,teaches,licenselegal,licnonlic,license,language,pricetier,category,us,ca,uk,ie,au,row,fr_fr,fr_ca,fr_row) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)\")\n (2..spreadsheet.last_row).each do |i|\n row = Hash[[header, spreadsheet.row(i)].transpose]\n\n # 2. INSERT DATA TO DATABASE\n insert_data pstmt, row\n end\n\n # 3. UPDATE DATA FOR LOCALE\n update_locale connection\n connection.con.commit # commit transaction\n\n return '<p class = \"alert alert-success\">MOAS file is imported successfully!</p>'\n rescue => e\n connection.con.rollback # rollback transaction\n return '<p class = \"alert alert-error\">PLEASE SELECT CORRECT TABLE. <br/>' << e.message << '</p>'\n ensure\n connection.close_connection if connection\n end # end begin transaction\n end", "def parse_ri_goals_xls(path_to_xls)\n spreadsheet = Spreadsheet.open path_to_xls\n sheet = spreadsheet.worksheet 'Science'\n domain_regex = @domains.keys.join(\"|\")\n regex = /(#{domain_regex})(\\d+)\\(([K|0-9]\\s*[-|#{EMDASH}]\\s*[K|0-9]+)\\)\\s*[-|#{EMDASH}]\\s*([0-9]+)([a-b])(.+)/\n sheet.each do |row| \n if (row[1])\n begin\n matches = (row[1]).match(regex) # we are only after column #2\n if (matches) # PS3(9-11)-10b Comparing and contrasting electromagnetic waves to mechanical waves.\n (domain_key,someNumber,grade_span,target_number,expectaton_ordinal,description) = matches.captures\n if (domain_key)\n if (domain_key !=\"PS\") # we already have all of these\n expectation = RiGse::Expectation.new(:description => description, :ordinal => expectaton_ordinal)\n expectation.save\n end\n end\n end\n rescue\n logger.warn \"problem reading #{row} / #{sheet}\"\n end\n end\n end\n end", "def mass_import(rows)\n self.import([:id, :value], rows, validate: false, timestamps: false)\n end", "def initialize(filepath, current_user, relation)\n\n # Open the new file & get the attributes row from it\n @relation = relation\n @import_file = Roo::Spreadsheet.open(filepath, extension: :xlsx)\n @excel_attributes_raw = @import_file.sheet(0).row(1)\n @excel_attributes = @excel_attributes_raw.map{ |el| el.downcase.gsub(\" \", \"_\") }\n\n # validate attributes row\n @invalid_rows = false\n @valid_attributes_from_db = getAllValidAttributes\n @mandatory_attributes_from_db = getAllMandatoryAttributes(current_user)\n \n # get valid and invalid attributes based on name\n getValidAndInvalidAttributes\n\n # valid attributes found and all mandatory attributes are there\n if checkAttributeRequirements\n # get valid listings from excel\n getValidListingsFromExcel\n\n # handle title and shipment to countries\n handleTitle\n handleCountries\n handleUSPs\n\n # check if there exists a value for mandatory attributes\n checkListingAttributeRequirements\n\n # handle listings which have to be updated\n listingsToUpdate current_user\n end\n end", "def index\n # respond_to do |format|\n # format.html\n # format.csv { send_data @employee_resignations.to_csv }\n # format.xls\n # # @employee_resignations = EmployeeResignation.where(\"employee_id=? and (resign_status = ? or resign_status = ?)\",current_user.employee_id,\"Pending\",\"Cancelled\")\n # @employee_resignations = EmployeeResignation.all\n # end\n if current_user.class == Member\n if current_user.role.name == 'GroupAdmin'\n @employee_resignations = EmployeeResignation.all\n elsif current_user.role.name == 'Admin'\n @employees = Employee.where(company_id: current_user.company_location.company_id).pluck(:id)\n @employee_resignations = EmployeeResignation.where(employee_id: @employees)\n elsif current_user.role.name == 'Branch'\n @employees = Employee.where(company_location_id: current_user.company_location_id).pluck(:id)\n @employee_resignations = EmployeeResignation.where(employee_id: @employees)\n elsif current_user.role.name == 'HOD'\n @employees = Employee.where(department_id: current_user.department_id).pluck(:id)\n @employee_resignations = EmployeeResignation.where(employee_id: @employees)\n elsif current_user.role.name == 'Supervisor'\n @emp = Employee.find(current_user.employee_id)\n @employees = @emp.subordinates\n @employee_resignations = EmployeeResignation.where(employee_id: @employees)\n else current_user.role.name == 'Employee'\n @employee_resignations = EmployeeResignation.where(employee_id: current_user.employee_id)\n redirect_to home_index_path\n end\n else\n @employees = Employee.all\n end\n session[:active_tab] =\"employee_resignation\"\n session[:active_tab1] = \"resignation\"\n end", "def skip_leading_rows\n @gapi.csv_options.skip_leading_rows\n end", "def skip_leading_rows\n @gapi.csv_options.skip_leading_rows\n end" ]
[ "0.5597566", "0.5593641", "0.55589575", "0.55178523", "0.5492531", "0.54744333", "0.54587615", "0.54255986", "0.53958", "0.537108", "0.53357905", "0.531206", "0.53115684", "0.5288103", "0.528585", "0.5273617", "0.5265873", "0.52461386", "0.52422166", "0.52294445", "0.5214217", "0.52045584", "0.5191434", "0.5186718", "0.5186586", "0.5184726", "0.5181722", "0.51584667", "0.5158417", "0.5158369", "0.5153055", "0.514284", "0.51160806", "0.5114742", "0.5098523", "0.5096819", "0.5070135", "0.5057301", "0.5050367", "0.5046782", "0.50433534", "0.5035848", "0.50288874", "0.5024495", "0.5002575", "0.5001059", "0.49824294", "0.49788815", "0.49700198", "0.49698374", "0.4954147", "0.49500665", "0.49475035", "0.49446043", "0.49305055", "0.4926881", "0.49175316", "0.49021697", "0.48973045", "0.489481", "0.4882465", "0.48778236", "0.48646748", "0.48625952", "0.48465574", "0.4840101", "0.48392388", "0.48364356", "0.48298317", "0.48270905", "0.4826626", "0.48216212", "0.48203027", "0.48120227", "0.48100638", "0.48065534", "0.48064244", "0.4790823", "0.47899044", "0.47868767", "0.47842774", "0.47819364", "0.4777985", "0.47777703", "0.47736588", "0.47730738", "0.47695047", "0.47680327", "0.47665775", "0.47630244", "0.4762981", "0.4758612", "0.4758612", "0.47571632", "0.4750393", "0.4749014", "0.47459733", "0.47361648", "0.47354525", "0.47354525" ]
0.50291497
42
=begin Checking if the response has been copied from the review questions or from other responses submitted. =end
def compare_reviews_with_questions_responses(reviews, questions) review_text_arr = reviews #response = Response.find(:first, :conditions => ["map_id = ?", map_id]) #scores = Score.find(:all, :conditions => ["response_id = ?", response.id]) #questions = Array.new #fetching the questions for the responses # for i in 0..scores.length - 1 # questions << Question.find_by_sql(["Select * from questions where id = ?", scores[i].question_id])[0].txt # end count_copies = 0 #count of the number of responses that are copies either of questions of other responses rev_array = Array.new #holds the non-plagiairised responses #comparing questions with text for i in 0..questions.length - 1 if(!questions[i].nil? and !review_text_arr[i].nil? and questions[i].downcase == review_text_arr[i].downcase) count_copies+=1 next #skip comparing with other responses end #comparing response with other responses flag = 0 for j in 0..review_text_arr.length - 1 if(i != j and !review_text_arr[i].nil? and !review_text_arr[j].nil? and review_text_arr[i].downcase == review_text_arr[j].downcase) count_copies+=1 flag = 1 break end end if(flag == 0) #ensuring no match with any of the review array's responses rev_array << review_text_arr[i] end end #setting @review_array as rev_array if(count_copies > 0) #resetting review_array only when plagiarism was found auto_metareview.review_array = rev_array end if(count_copies > 0 and count_copies == scores.length) return ALL_RESPONSES_PLAGIARISED #plagiarism, with all other metrics 0 elsif(count_copies > 0) return SOME_RESPONSES_PLAGIARISED #plagiarism, while evaluating other metrics end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compare_reviews_with_questions(auto_metareview)\n\n review_text_arr = auto_metareview.review_array\n\n scores = Score.find(:all, :conditions => [\"response_id = ?\", response.id])\n\n questions = Array.new\n\n #fetching the questions for the responses\n for i in 0..scores.length - 1\n questions << Question.find_by_sql([\"Select * from questions where id = ?\", scores[i].question_id])[0].txt\n end\n\n\n count_copies = 0 #count of the number of responses that are copies either of questions of other responses\n rev_array = Array.new #holds the non-plagiairised responses\n #comparing questions with text\n for i in 0..scores.length - 1\n if(!questions[i].nil? and !review_text_arr[i].nil? and questions[i].downcase == review_text_arr[i].downcase)\n count_copies+=1\n\n end\n\n #comparing response with other responses\n\n end\n\n\n #setting @review_array as rev_array\n check_plagiarism_state(auto_metareview, count_copies, rev_array, scores)\n\n end", "def compare_reviews_with_responses(auto_metareview, map_id)\n review_text_arr = auto_metareview.review_array\n response = Response.find(:first, :conditions => [\"map_id = ?\", map_id])\n scores = Score.find(:all, :conditions => [\"response_id = ?\", response.id])\n\n #fetching the questions for the responses\n\n\n count_copies = 0 #count of the number of responses that are copies either of questions of other responses\n rev_array = Array.new #holds the non-plagiairised responses\n\n\n\n #comparing response with other responses\n flag = 0\n for j in 0..review_text_arr.length - 1\n if(i != j and !review_text_arr[i].nil? and !review_text_arr[j].nil? and review_text_arr[i].downcase == review_text_arr[j].downcase)\n count_copies+=1\n flag = 1\n break\n end\n end\n\n if(flag == 0) #ensuring no match with any of the review array's responses\n rev_array << review_text_arr[i]\n end\n\n\n #setting @review_array as rev_array\n check_plagiarism_state(auto_metareview, count_copies, rev_array, scores)\n\n end", "def has_responses?\n if is_standard?\n respond_to?(:copy_responses_count_col) ? (copy_responses_count_col || 0) > 0 : copies.any?(&:has_responses?)\n else\n responses_count > 0\n end\n end", "def no_responses\n if self.id && self.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.survey && !survey.template && survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end", "def resp_guard_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.RESP_GUARD\"))\n end", "def answer_present\n if self.question.qtype == 'one_response' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n elsif self.question.qtype == 'likert_scale' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n\n elsif self.question.qtype == 'rank_three' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 3 \n array_wanted = [1, 2, 3]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 3 items are ranked.' )\n return false\n end\n\n elsif self.question.qtype == 'rank_five' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 5 \n array_wanted = [1, 2, 3, 4, 5]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 5 items are ranked.' )\n return false\n end\n end\n end", "def no_responses\n if self.id\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if !template && response_sets.count>0\n errors.add(:base,\"Responses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end", "def check_plagiarism_state(auto_metareview, count_copies, rev_array, scores)\n if count_copies > 0 #resetting review_array only when plagiarism was found\n auto_metareview.review_array = rev_array\n\n\n if count_copies == scores.length\n return ALL_RESPONSES_PLAGIARISED #plagiarism, with all other metrics 0\n else\n return SOME_RESPONSES_PLAGIARISED #plagiarism, while evaluating other metrics\n end\n end\nend", "def no_responses\n #below is code to fix a bizarre bug. When triggered by the \"cut\" function, for some reason survey_id is erased. Have not found reason yet. Temporary fix.\n if !survey_section && self.id\n self.reload\n end\n if self.id && self.survey_section && self.survey_section.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey_section.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.id && !survey_section.survey.template && survey_section.survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end", "def reset_reviewed\n if copy_changed? && !approved_changed?\n if copy_change[0] != copy_change[1]\n self.reviewer_id = nil\n self.approved = nil\n end\n end\n return true\n end", "def find_rejected_comments(response)\n decision_ids = Array.new\n post_ids = Array.new\n response['data'].each do |item|\n if item['attributes']['status'] == 'Reject'\n # Get sourceId of post from included section of JSON object\n sourceId = response['included'].find {|i| i['id'] == item['attributes']['commentId']}['attributes']['sourceId']\n decision_ids << item['id']\n post_ids << sourceId\n end\n end\n if decision_ids.any?\n confirm_decisions decision_ids\n reject_posts post_ids\n else\n puts 'No new decisions found.'\n end\n end", "def test_response_stale\n response = Response.new\n\n response.updated_at = Time.parse(\"2012-12-02 06:00:00 UTC\")\n\n #resubmission_time3 after the response time\n #also the response before in current review phase\n latest_review_phase_start_time = Time.parse(\"2012-12-02 08:00:00 UTC\")\n\n resubmission_time1 = ResubmissionTime.new\n resubmission_time1.resubmitted_at = Time.parse(\"2012-12-02 04:00:00 UTC\")\n resubmission_time2 = ResubmissionTime.new\n resubmission_time2.resubmitted_at = Time.parse(\"2012-12-02 05:00:00 UTC\")\n resubmission_time3 = ResubmissionTime.new\n resubmission_time3.resubmitted_at = Time.parse(\"2012-12-02 07:00:00 UTC\")\n\n resubmission_times = [resubmission_time3, resubmission_time2, resubmission_time1]\n\n assert !response.is_valid_for_score_calculation?(resubmission_times, latest_review_phase_start_time)\n end", "def not_duplicate_response\n if respondent_already_answered?\n errors[:user_id] << 'this user has already answered this question'\n end\n # unless sibling_responses.where(user_id: user_id).empty?\n end", "def check_for_valid_response(resp)\n if resp == 'exit!'\n game_data.save\n elsif game_data.chosen_letters.include?(resp)\n repeat_response_query('repeat')\n elsif resp.length > 1\n repeat_response_query('multiple')\n else\n action(resp)\n end\n end", "def contains_response_and_soln?() true ; end", "def validate_user_responses(responses)\n failed = false\n puts \"*** VALIDATING USER RESPONSES ***\"\n\n @i = 0\n \n while(@i < responses.length)\n @response = nil\n @index = @i.to_s\n @resp = responses[@index]\n @id = @resp[:id]\n puts \"*** VALIDATING response no. \" + @i.to_s + \", ID=\" + @id + \" ***\" \n \n begin \n @response = Response.find(@id) \n rescue ActiveRecord::RecordNotFound\n puts \"RESPONSE NOT FOUND\"\n failed = true\n break\n end\n\t\n\t\t if (@response.user.id != current_user.id)\n\t\t puts (\"ID MISMATCH: actual: #{current_user.id} expected: #{@response.user.id}\")\n\t\t failed = true\n\t\t break \n\t\t end\n\t\t @i += 1\n\t end\n\t \n return !failed\n end", "def well_formated_response?\n all_expected_fields_received? && validate_bank_response_signature\n end", "def check_questionnaires_usage\n @assignment_questionnaires.each do |aq|\n unless aq.used_in_round.nil?\n @reviewvarycheck = 1\n break\n end\n end\n end", "def test_response_valid_in_this_phase\n response = Response.new\n\n response.updated_at = Time.parse(\"2012-12-02 06:00:00 UTC\")\n\n #resubmission_time3 after the response time\n #but it is after the current review phase\n latest_review_phase_start_time = Time.parse(\"2012-12-02 07:00:00 UTC\")\n\n resubmission_time1 = ResubmissionTime.new\n resubmission_time1.resubmitted_at = Time.parse(\"2012-12-02 04:00:00 UTC\")\n resubmission_time2 = ResubmissionTime.new\n resubmission_time2.resubmitted_at = Time.parse(\"2012-12-02 05:00:00 UTC\")\n resubmission_time3 = ResubmissionTime.new\n resubmission_time3.resubmitted_at = Time.parse(\"2012-12-02 08:00:00 UTC\")\n\n resubmission_times = [resubmission_time3, resubmission_time2, resubmission_time1]\n\n assert response.is_valid_for_score_calculation?(resubmission_times, latest_review_phase_start_time)\n end", "def correct?(response)\n postsolution = prefix_solve # memoized version is already preprocessed\n postresponse = preprocess_hash(response)\n\n text.map { |elt| \n elt.correct?(postsolution, postresponse) }.inject(:&)\n end", "def resp_pcare_equals_one?(question)\n previous_responses = person.responses_for(\"PARTICIPANT_VERIF.RESP_PCARE\").all\n ri = previous_responses.detect{ |r| r.answer.try(:reference_identifier).to_i == 1 } ? true : false\n answer_for(question, ri)\n end", "def pcare_rel_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.PCARE_REL\"))\n end", "def update_questions_skipped_and_asked\n responses = survey_version.survey_responses\n if counts_updated_at.present?\n d = counts_updated_at.in_time_zone(\"Eastern Time (US & Canada)\") - 2.days\n responses = responses.where(\"created_at > ?\", d.to_date)\n end\n return if responses.empty?\n page_hash = survey_version.page_hash\n first_page = page_hash.values.detect {|page| page[:page_number] == 1}.try(:[], :page_id)\n\n skips_hash = new_skips_hash\n responses.each do |sr|\n date = sr.created_at.in_time_zone(\"Eastern Time (US & Canada)\").to_date\n raw_responses = Hash[sr.raw_responses.map {|rr| [rr.question_content_id, rr]}]\n next_page = first_page\n while next_page do\n page = page_hash[next_page]\n next_page = page[:next_page_id]\n page[:questions].each do |question|\n rr = raw_responses[question[:qc_id]]\n question_skips_hash = case question[:questionable_type]\n when \"ChoiceQuestion\" then skips_hash[:choice_days]\n when \"TextQuestion\" then skips_hash[:text_days]\n end\n skips_hash[:days][date][:total] += 1\n question_skips_hash[question[:questionable_id]][date][:total] += 1 if question_skips_hash\n\n if rr.present?\n if question[:flow_control] && question[:flow_map][rr.answer].present?\n next_page = question[:flow_map][rr.answer]\n end\n else\n skips_hash[:days][date][:skip] += 1\n question_skips_hash[question[:questionable_id]][date][:skip] += 1 if question_skips_hash\n end\n end\n end\n end\n record_questions_skipped_and_asked(skips_hash)\n end", "def enough_responses?\n game.current_round.response(self).count >= game.current_round.question.answers\n end", "def ready_for_submission?\n self.all_reviewers_assigned? && \n self.all_manager_reviewers_assigned? &&\n self.design_data_filled_in?\n end", "def response_equal_answer?\n @response.to_i == eval(@question)\n end", "def has_response?\n if @answers.nil? then\n false\n else\n rc = false\n @answers.each do |answer| # loop through Answers\n if !answer.value.blank? then # any response is good enough\n rc = true\n break\n end\n end\n rc\n end\n end", "def not_duplicate_response\n if respondent_already_answered?\n self.errors[:duplicate] << \"You've already answered this question.\"\n end\n end", "def valid_response_for_answer_sheet?(answers)\n return true if !self.required? \n answer = answers.detect {|a| a.question_id == self.id}\n return answer && answer.value.present?\n # raise answer.inspect \n end", "def pending_clarification_requests?\n self.clarification_requests_count > self.clarification_responses_count\n end", "def pending_clarification_requests?\n self.clarification_requests_count > self.clarification_responses_count\n end", "def in_review?\n @in_review ||= begin\n raise NotFetchedError unless fetched?\n [!!@data.match(/<p class=\"Warning\">Sorry, you cannot view this cache listing until it has been published/),\n !!@data.match(/<p class=\"Warning\">This cache listing has not been reviewed yet/)].any?\n end\n end", "def imperfect_return_resubmission?\n return false unless previously_transmitted_submission.present?\n \n previously_transmitted_submission.efile_submission_transitions.collect(&:efile_errors).flatten.any? { |error| [\"SEIC-F1040-501-02\", \"R0000-504-02\"].include? error.code }\n end", "def verified_answer(user_response, list_of_responses)\n if list_of_responses.include? user_response\n user_response\n else\n invalid_return_mm\n end\n end", "def get_incorrect\n @mismatches = @solution.crossword.get_mismatches(params[:letters])\n if @mismatches.empty?\n @solution.update_attributes(is_complete: true)\n end\n end", "def reviewed?\n if content.nil? || content.empty?\n return false\n else\n return true\n end\n end", "def check_questions\n response = Request.get_request(URL_QUESTION)\n questions = []\n if response.success?\n data = Request.manage_response(response)\n end\n data.each do |question|\n questions << Question.new(question)\n end\n questions\nend", "def determine_correctness\n answer = self.question.answer\n \t#Upcase to take care of all capitalization issues\n \tresponse = self.content.upcase\n\n \tanswer = answer.split(', ')\n\n \t#Score Keeping\n \tscore = 0\n \tscore_incremental = 1.0/answer.length\n \t\n \t#Determining how many of keywords are in response\n \tanswer.each do |correct_word|\n \t\tcorrect_word = correct_word.upcase\n \t\tif response.include?(correct_word)\n \t\t\tscore += score_incremental\n \t\tend\n \tend\n \tself.correctness = score\n end", "def is_duplicate_request?\n errors.add(:duplicate, \"transfer request.\") if self.class.where(sadhak_profile_id: self.sadhak_profile_id, from_club_id: self.from_club_id, to_club_id: self.to_club_id, status: self.class.statuses['requested']).count > 0\n errors.empty?\n end", "def exam_and_interview_result_exists\n !exam_result.blank? and !interview_result.blank?\n end", "def is_work_name_previously_collected_and_valid?(question)\n answer_for(question, valid_response_exists?(\"PREG_VISIT_1_3.WORK_NAME\", :last))\n end", "def verify_request_issue_contending_decision_issue_not_readded(\n page_url,\n decision_review,\n contested_decision_issues\n )\n # verify that not modifying a request issue contesting a decision issue\n # does not result in readding\n\n visit page_url\n expect(page).to have_content(contested_decision_issues.first.description)\n expect(page).to have_content(contested_decision_issues.second.description)\n expect(page).to have_content(\"PTSD denied\")\n\n click_remove_intake_issue_dropdown(\"PTSD denied\")\n\n click_intake_add_issue\n add_intake_rating_issue(\"Issue with legacy issue not withdrawn\")\n\n click_edit_submit\n expect(page).to have_content(\"has been submitted\")\n\n first_not_modified_request_issue = RequestIssue.find_by(\n decision_review: decision_review,\n contested_decision_issue_id: contested_decision_issues.first.id\n )\n\n second_not_modified_request_issue = RequestIssue.find_by(\n decision_review: decision_review,\n contested_decision_issue_id: contested_decision_issues.second.id\n )\n\n expect(first_not_modified_request_issue).to_not be_nil\n expect(second_not_modified_request_issue).to_not be_nil\n\n non_modified_ids = [first_not_modified_request_issue.id, second_not_modified_request_issue.id]\n request_issue_update = RequestIssuesUpdate.find_by(review: decision_review)\n\n # existing issues should not be added or removed\n expect(request_issue_update.added_issues.map(&:id)).to_not include(non_modified_ids)\n expect(request_issue_update.removed_issues.map(&:id)).to_not include(non_modified_ids)\n end", "def correct_words\n self.student_responses.select { |x| x.correct }.collect { |x| x.word_id }.uniq\n end", "def refresh_question?\n question_responses >= refresh_question_after\n end", "def disputed?\n !bounty_claim_responses.where(value: false).empty?\n end", "def prior_recommendations_completed?\n last_advice = self.activities.last\n last_survey = self.submissions.last\n recommendations_in_range = recommendation_events.where(created_at: last_survey.created_at..last_advice.created_at)\n prior_matching_recommendations = recommendations_in_range.where(subject: last_advice.subject)\n prior_matching_recommendations.count == 1\n end", "def ocare_rel_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.OCARE_REL\"))\n end", "def just_reviewed?\n reviewed? and reviewed_changed?\n end", "def create\n @effort = @question.efforts.new(effort_params)\n @effort.question = @question\n @effort.quest = @quest\n\n # if @question.answer.content.downcase == @effort.content.downcase --> Doesn't work !!!\n # @effort.status = \"correct\"\n # else\n # @effort.status = \"wrong\"\n # end\n if @effort.save!\n\n @all_questions = @quest.challenge.questions.to_a\n @answered_questions = @quest.efforts.map(&:question)\n @remaining_questions = @all_questions - @answered_questions\n\n unless @remaining_questions.empty?\n next_question_id = @remaining_questions.first.id\n puts @question.id\n @question = Question.find(next_question_id)\n puts @question.id\n redirect_to student_quest_question_path(@quest, @question)\n else\n # Takes them back to profile if finished\n # TODO - change this to results page or flash message?\n redirect_to student_profile_path\n end\n else\n session[:return_to] ||= request.referer\n end\n end", "def responded_with_availability?\n !interview_availabilities.empty?\n end", "def answered?\n\n if answers.length == 0 \n return false\n end\n\n if answers.last.rationale_choices.size > 0\n\n #\n # The last answer is a list containing only one item, and it\n # does not contain a key for :choice_id. This is the answer we\n # generated in the case of unselecting a previous selection.\n # I.e. user is resetting to the default unselected state.\n # {:answer=>\"not answered\"}\n #\n\n return true\n end\n\n return false\n\n end", "def respondent_already_answered?\n sibling_responses.exists?(responder_id: self.responder_id)\n end", "def is_work_address_previously_collected_and_valid?(question)\n answer_for(question, valid_response_exists?(\"PREG_VISIT_1_3.WORK_ADDRESS_1\", :last))\n end", "def has_accepted_response?\n self.responses.accepted.any? {|response| response.accepted?}\n end", "def validate_allows_response\n if self.kase\n # self.errors.add(:kase, \"is %{status}\".t % {:status => self.kase.current_state_t}) unless self.kase.active?\n # self.errors.add(:kase, \"is not open\".t) unless self.kase.open?\n \n if self.person \n if self.kase.offers_reward?\n\n # only disallow rewarded self answers\n self.errors.add(:base, \"You cannot respond to your own rewarded %{type}\".t % {:type => self.kase.class.human_name}) unless self.person != self.kase.person\n\n end\n end\n end\n end", "def answered?\n !body.blank?\n end", "def can_uncorrect_submission\n # Submission must be correct to be marked as wrong\n redirect_to problem_path(@problem, :sub => @submission) unless @submission.correct?\n unless current_user.sk.root?\n # Corrector should have accepted the solution a few minutes ago\n eleven_minutes_ago = DateTime.now - 11.minutes\n if Solvedproblem.where(:user => @submission.user, :problem => @problem).first.correction_time < eleven_minutes_ago or @submission.corrections.where(:user => current_user.sk).where(\"created_at > ?\", eleven_minutes_ago).count == 0\n flash[:danger] = \"Vous ne pouvez plus marquer cette solution comme erronée.\"\n redirect_to problem_path(@problem, :sub => @submission)\n end\n end\n end", "def test_ID_25863_comment_on_review()\n login_as_user1\n read_all_updates\n share_review(\"outside-in\")\n logout_common\n login_as_user2\n leave_comment_on_share_review_group(\"outside-in\")\n logout_common\n login_as_user1\n verify_updates\n end", "def respondent_has_not_already_answered_question\n if sibling_responses.where('user_id != ?', self.user_id).exists?\n errors[:question] << \"You have already answered that question\"\n end\n end", "def manuscript_chapter_contradicts?(chapter)\n chapter_in_mampf(chapter)&.title != chapter['description']\n end", "def reviewed?\n !application_review_decision_type.nil?\n end", "def can_review(cp)\n cps_as_reviewer.include?(cp)\n end", "def not_approved?\n status_map = employee_vacation_responses.map(&:status).uniq\n status_map.size == 1 && status_map.include?(\"not_approved\")\n end", "def should_show_resp_pcare?(question)\n answer_for(question, !valid_response_exists?(\"PARTICIPANT_VERIF.RESP_PCARE\"))\n end", "def has_background_check_form_responses?\n return true if crimes_against_persons_or_financial? || drug_related_crimes?\n return true if related_proceedings_crimes? || medicare_healthcare_crimes? || general_convictions?\n false\n end", "def validate(expectations, source, response)\n\t\texpectations.all? { |expectation|\n\t\t\tresponse[\"output\"].any? { |output| output.include? expectation.value }\n\t\t}\n\tend", "def verifyPostIdeaResponseContract\n return verifyResponseContract(@postIdea_response_structure)\n end", "def respondent_already_answered?\n sibling_responses.where('user_id = ?', self.user_id).exists?\n end", "def separatePreVsPostQuizResponses(in_filename,out_preQFilename,out_postQFilename,out_excFilename,out_excLogFilename,preQ_regex,postQ_regex)\n\n\tinFile = File.new(in_filename,'r')\n\tpreQFile = File.new(out_preQFilename,'w')\n\tpostQFile = File.new(out_postQFilename,'w')\n\texcFile = File.new(out_excFilename,'a')\n\texcLogFile = File.new(out_excLogFilename,'a')\n\t\n\tpreVsPostStatusMissingIDs = []\n\t\n\tlines = inFile.each_line\n\t\n\tlines.each do |l|\n\t\tl_arr = l.split('\",\"').map(&:strip)\n\t\t\n\t\tif preQ_regex.match(l_arr[3])\n\t\t\tpreQFile.puts(l)\n\t\telsif postQ_regex.match(l_arr[3])\n\t\t\tpostQFile.puts(l)\n\t\telse\n\t\t\tpreVsPostStatusMissingIDs.push(l_arr[3])\n\t\t\texcFile.puts(l)\n\t\tend\n\tend\n\t\n\tpreVsPostStatusMissingIDs = preVsPostStatusMissingIDs.uniq\n\tpreVsPostStatusMissingIDs = preVsPostStatusMissingIDs.sort\n\t\n\texcLogFile.puts(\"\\n\\nExcluded the following IDs from \"+in_filename+\" for not having a pre vs post quiz identifier:\")\n\texcLogFile.puts()\n\tif preVsPostStatusMissingIDs.length == 0\n\t\texcLogFile.puts(\"NONE\")\n\telse\n\t\tpreVsPostStatusMissingIDs.each { |x| excLogFile.puts(x) }\n\tend\n\t\n\tinFile.close\n\tpreQFile.close\n\tpostQFile.close\n\texcFile.close\n\texcLogFile.close\n\nend", "def check_for_quiz_set(msg, data)\n if msg.downcase.include?('quiz') && session['quiz_index'] == 0\n (0..data[session['country_index']].sets.length - 1).each do |i|\n sets = data[session['country_index']].sets[i]\n next unless msg.include? sets.name.downcase\n session['set_index'] = i\n return true\n end\n end\n\n false\nend", "def has_reasons\n if !(for_major || for_prof || for_interest || for_distrib || for_easy_a || for_prereq)\n puts \"HAS NO REASONS: incomplete review\"\n errors.add(:incomplete, '. Review must list at least one motivation')\n end\n end", "def outcome_post_successful?\n @outcome_response && @outcome_response.success?\n end", "def not_author_response\n if author_respondent?\n errors[:author] << 'cannot answer their own poll'\n end\n end", "def respondent_already_answered?\n sibling_responses.exists?(user_id: user_id)\n end", "def agreed_with_community\n responses = self.responses\n count = 0\n responses.each do |response|\n #count += 1 if response.verdict == response.question.get_community_verdict\n count += 1 if response.question.get_community_verdict(response.verdict)\n end\n return count\n end", "def duplicate_order?(response)\n response.params.has_key?(:ErrInfo) and response.params[:ErrInfo] == DUPLICATE_ORDER_CODE\n end", "def test_response_latest\n response = Response.new\n\n response.updated_at = Time.parse(\"2012-12-02 08:00:00 UTC\")\n\n #All resubmission times are before the response time\n #also the response is in current review phase\n latest_review_phase_start_time = Time.parse(\"2012-12-02 07:00:00 UTC\")\n\n resubmission_time1 = ResubmissionTime.new\n resubmission_time1.resubmitted_at = Time.parse(\"2012-12-02 04:00:00 UTC\")\n resubmission_time2 = ResubmissionTime.new\n resubmission_time2.resubmitted_at = Time.parse(\"2012-12-02 05:00:00 UTC\")\n resubmission_time3 = ResubmissionTime.new\n resubmission_time3.resubmitted_at = Time.parse(\"2012-12-02 06:00:00 UTC\")\n\n resubmission_times = [resubmission_time3, resubmission_time2, resubmission_time1]\n\n assert response.is_valid_for_score_calculation?(resubmission_times, latest_review_phase_start_time)\n end", "def is_valid_for_score_calculation?(resubmission_times, latest_review_phase_start_time)\n is_valid = true\n\n # if there was not submission then the response is valid\n if resubmission_times.nil? || latest_review_phase_start_time.nil?\n return is_valid\n end\n\n resubmission_times.each do |resubmission_time|\n # if the response is after a resubmission that is\n # before the latest_review_phase_start_time (check second condition below)\n # then we are good - the response is valid and we can break\n if (self.updated_at > resubmission_time.resubmitted_at)\n break\n end\n\n # this means there was a re-submission before the\n # latest_review_phase_start_time and we dont have a response after that\n # so the response is invalid\n if (resubmission_time.resubmitted_at < latest_review_phase_start_time)\n is_valid = false\n break\n end\n end\n\n is_valid\n end", "def check_if_reply_and_not_already_read(tweet)\n\n puts tweet.text\n if tweet.text.match(/^@partyprinter.*/) && tweet.user.id != 1678701920 && Tweet.exists?(tweet.id.to_i) == nil\n puts \"new\"\n return true\n end\n\n end", "def respondent_is_not_author_poll?\n #\n # respondend.id == author.id\n\n if question.poll.author.id == user.id\n errors[:user_id] << 'author should not answer to his/her poll'\n end\n end", "def player_response\n\n if compare_answer\n return puts \"#{@current_asker.name}: YES! You are correct.\"\n end\n\n puts \"#{@current_asker.name}: Seriously? No!\"\n\n end", "def has_dob_been_previously_collected?(question)\n ri = false\n if person.person_dob_date\n ri = true\n elsif most_recent_response = person.responses_for(\"PARTICIPANT_VERIF.PERSON_DOB\").last\n ri = true unless %w(neg_1 neg_2).include?(most_recent_response.try(:answer).try(:reference_identifier).to_s)\n elsif person.person_dob_date.nil?\n ri = false\n end\n answer_for(question, ri)\n end", "def response_dates_after_submission\n unless actl_submission.blank?\n xpcd_response_computed = ( xpcd_response || Date.today ) + xpcd_response_delta.to_i\n errors.add( :xpcd_response, I18n.t( 'dsr_submissions.msg.bad_resp_date')) \\\n unless xpcd_response_computed >= actl_submission\n end\n end", "def transfer_in?\n patient_transfer_in = self.person.observations.recent(1).question(\"HAS TRANSFER LETTER\").all rescue nil\n return false if patient_transfer_in.blank?\n return true\n end", "def post_review?(next_review, user)\n\n (next_review && \n !self.review_locked? && \n next_review.designer_id == user.id &&\n next_review.review_type_id == next_review.design.phase_id)\n\n end", "def is_request_pending_to_same_club_from_another_club?\n self.class.preloaded_data.where(sadhak_profile_id: self.sadhak_profile_id, to_club_id: self.to_club_id, status: self.class.statuses['requested']).each do |req|\n errors.add(:sadhak, \"Name: #{req.requester_user.name} has already created a request for transfer from #{req.transfer_out_club.name.titleize} forum to #{req.transfer_in_club.name.titleize} froum.\")\n end\n errors.empty?\n end", "def ocare_child_previously_collected_and_equals_one?(question)\n answer_for(question, ocare_child_response_is_one?)\n end", "def needs_initial_response?\n # logger.debug(\"CHC: needs_initial_response '#{p_s_b}'\")\n return false if p_s_b != 'P'\n # logger.debug(\"CHC: needs_initial_response still here\")\n center = queue.center.center\n ret = false\n pmr.signature_lines.each do |sig|\n # logger.debug(\"CHC: stype=#{sig.stype} ptype=#{sig.ptype}\")\n # Set ret to true for any requeue of the primary. The last\n # one will be the requeue to the current location.\n if sig.stype == 'CR' && sig.ptype == '-' && sig.center != center\n # logger.debug(\"CHC: CR line at #{sig.date}\")\n ret = true\n end\n # Set ret to false for any CT from this center.\n if sig.stype == 'CT' && sig.center == center\n # logger.debug(\"CHC: CT line at #{sig.date}\")\n ret = false\n end\n end\n # Ret will be the last toggle from the above two conditions.\n ret\n end", "def respond_to_question(url, token, encrypted_id, resp)\n dputs __method__.to_s\n messages_req = setup_http_request($respond_to_message, @cookie, {:url => url, :arg => [resp, encrypted_id, token]})\n res = @http.request(messages_req)\n body = CGI.unescapeHTML(res.body.force_encoding('utf-8'))\n # Checking...\n if res.code == \"302\"\n found = false\n # Should not be a problem calling public instead private or other way\n get_public_conversations(res['location']).map{|m|\n m[:msgs].map{|c| found = true if c[:msg].include?(resp)}\n if found\n return true\n end\n }\n return false\n end\n raise SendReponseMessageError, \"Cannot received expected 302 code...\"\n end", "def update_status\n if paragraphs.any?(&:error?)\n has_paragraphs_in_error!\n elsif paragraphs.any?(&:to_review?)\n has_paragraphs_to_review!\n elsif paragraphs.any?(&:opinionated?)\n has_paragraphs_opinionated!\n else\n is_empty!\n end\n end", "def review_complete?\n self.review_status_id == ReviewStatus.find(:first,\n :conditions => \"name='Review Completed'\").id\n end", "def verify_also_asked_questions(*search_terms)\n page = GoogleSearchResults.new(@se)\n questions = page.get_also_asked_questions\n puts \"verify Also Asked has #{search_terms.inspect}\"\n assert(questions.length > 1, \"expected one or more questions\")\n questions.each { |q|\n\t\t txt = q.text\n\t\t #puts \" also asked: \" + txt\n\t\t search_terms.each { |s|\n assert(txt.downcase.include?(s), \"expected '#{s}' in '#{txt}'\")\n\t\t }\n\t}\n end", "def reviewed?\n @status == :reviewed\n end", "def sibling_responses\n if !Response.exists?(self) #checks if instance is stored in database\n question.responses #even if instance class = Reponse, returns false if not in database\n else\n self.question.responses\n .where(\"responses.user_id != ?\", respondent.id)\n end\n\n end", "def calculate_metareview_metrics(review, submission, rubricqns_array)\n preprocess = TextPreprocessing.new\n feature_values = Hash.new #contains the values for each of the metareview features calculated\n preprocess = TextPreprocessing.new\n\n #fetch the review data as an array \n @review_array = review \n \n # puts \"self.responses #{self.responses}\"\n speller = FFI::Aspell::Speller.new('en_US')\n # speller.suggestion_mode = Aspell::NORMAL\n @review_array = preprocess.check_correct_spellings(@review_array, speller)\n\n #checking for plagiarism by comparing with question and responses\n plag_instance = PlagiarismChecker.new\n result_comparison = plag_instance.compare_reviews_with_questions_responses(@review_array, rubricqns_array)\n\n if(result_comparison == ALL_RESPONSES_PLAGIARISED)\n content_summative = 0\n content_problem = 0 \n content_advisory = 0\n relevance = 0\n quantity = 0\n tone_positive = 0\n tone_negative = 0\n tone_neutral = 0\n plagiarism = true\n # puts \"All responses are copied!!\"\n feature_values[\"plagiarism\"] = plagiarism\n feature_values[\"relevance\"] = relevance\n feature_values[\"content_summative\"] = content_summative\n feature_values[\"content_problem\"] = content_problem\n feature_values[\"content_advisory\"] = content_advisory\n feature_values[\"coverage\"] = coverage\n feature_values[\"tone_positive\"] = tone_positive\n feature_values[\"tone_negative\"] = tone_negative\n feature_values[\"tone_neutral\"] = tone_neutral\n feature_values[\"volume\"] = quantity\n #Even if a review is plagiarised, we are still required to find other metrics for experiment.\n #return feature_values\n elsif(result_comparison == SOME_RESPONSES_PLAGIARISED)\n plagiarism = true\n end\n\n #checking plagiarism (by comparing responses with search results from google), we look for quoted text, exact copies i.e.\n\n #enable this check later-to_do\n #\n #google_plagiarised = plag_instance.google_search_response(self)\n\n #if(google_plagiarised == true)\n # plagiarism = true\n #else\n # plagiarism = false\n #end\n\n if(@review_array.length > 0)\n\n #formatting the review responses, segmenting them at punctuations\n review_text = preprocess.segment_text(0, @review_array)\n #removing quoted text from reviews\n review_text = preprocess.remove_text_within_quotes(review_text) #review_text is an array\n puts \"review_text #{review_text}\"\n #fetching submission data as an array and segmenting them at punctuations \n submissions = submission\n subm_text = preprocess.check_correct_spellings(submissions, speller)\n subm_text = preprocess.segment_text(0, subm_text)\n subm_text = preprocess.remove_text_within_quotes(subm_text)\n puts \"subm_text #{subm_text}\"\n # #initializing the pos tagger and nlp tagger/semantic parser \n pos_tagger = EngTagger.new\n core_NLP_tagger = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref)\n \n #--------- \n #relevance\n beginning_time = Time.now\n relev = DegreeOfRelevance.new\n relevance = relev.get_relevance(review_text, subm_text, 1, pos_tagger, core_NLP_tagger, speller) #1 indicates the number of reviews\n #assigninging the graph generated for the review to the class variable, in order to reuse it for content classification\n review_graph = relev.review\n #calculating end time\n end_time = Time.now\n relevance_time = end_time - beginning_time\n #--------- \n # checking for plagiarism\n if(plagiarism != true) #if plagiarism hasn't already been set\n beginning_time = Time.now\n result = plag_instance.check_for_plagiarism(review_text, subm_text)\n if(result == true)\n plagiarism = \"TRUE\"\n else\n plagiarism = \"FALSE\"\n end\n end_time = Time.now\n plagiarism_time = end_time - beginning_time\n puts \"************* plagiarism time taken - #{plagiarism_time}\"\n end\n #--------- \n #content\n beginning_time = Time.now\n content_instance = PredictClass.new\n pattern_files_array = [\"app/data/patterns-assess.csv\",\"app/data/patterns-prob-detect.csv\",\"app/data/patterns-suggest.csv\"]\n #predcting class - last parameter is the number of classes\n content_probs = content_instance.predict_classes(pos_tagger, core_NLP_tagger, review_text, review_graph, pattern_files_array, pattern_files_array.length)\n content = \"SUMMATIVE - #{(content_probs[0] * 10000).round.to_f/10000}, PROBLEM - #{(content_probs[1] * 10000).round.to_f/10000}, SUGGESTION - #{(content_probs[2] * 10000).round.to_f/10000}\"\n end_time = Time.now\n content_time = end_time - beginning_time\n content_summative = content_probs[0]# * 10000).round.to_f/10000\n content_problem = content_probs[1] #* 10000).round.to_f/10000\n content_advisory = content_probs[2] #* 10000).round.to_f/10000\n feature_values[\"content_summative\"] = content_summative\n feature_values[\"content_problem\"] = content_problem\n feature_values[\"content_advisory\"] = content_advisory\n return feature_values\n puts \"************* content time taken - #{content_time}\"\n# puts \"*************\"\n #--------- \n #coverage\n cover = ReviewCoverage.new\n coverage = cover.calculate_coverage(subm_text, review_text, pos_tagger, core_NLP_tagger, speller)\n# puts \"************* coverage - #{coverage}\"\n# puts \"*************\"\n #--------- \n # tone\n beginning_time = Time.now\n ton = Tone.new\n tone_array = Array.new\n tone_array = ton.identify_tone(pos_tagger, speller, core_NLP_tagger, review_text, review_graph)\n tone_positive = tone_array[0]#* 10000).round.to_f/10000\n tone_negative = tone_array[1]#* 10000).round.to_f/10000\n tone_neutral = tone_array[2]#* 10000).round.to_f/10000\n #tone = \"POSITIVE - #{(tone_array[0]* 10000).round.to_f/10000}, NEGATIVE - #{(tone_array[1]* 10000).round.to_f/10000}, NEUTRAL - #{(tone_array[2]* 10000).round.to_f/10000}\"\n end_time = Time.now\n tone_time = end_time - beginning_time\n puts \"************* tone time taken - #{tone_time}\"\n# puts \"*************\"\n # #---------\n # quantity\n beginning_time = Time.now\n quant = TextQuantity.new\n quantity = quant.number_of_unique_tokens(review_text)\n end_time = Time.now\n quantity_time = end_time - beginning_time \n puts \"************* quantity time taken - #{quantity_time}\"\n \n feature_values[\"plagiarism\"] = plagiarism\n feature_values[\"relevance\"] = relevance\n feature_values[\"content_summative\"] = content_summative\n feature_values[\"content_problem\"] = content_problem\n feature_values[\"content_advisory\"] = content_advisory\n feature_values[\"coverage\"] = coverage\n feature_values[\"tone_positive\"] = tone_positive\n feature_values[\"tone_negative\"] = tone_negative\n feature_values[\"tone_neutral\"] = tone_neutral\n feature_values[\"volume\"] = quantity\n return feature_values\n end\n end", "def reviewed_by?(reviewer)\n ReviewResponseMap.where('reviewee_id = ? && reviewer_id = ? && reviewed_object_id = ?', id, reviewer.get_reviewer.id, assignment.id).count > 0\n end", "def reviewed?\n review_count = Review.where(user: user, essay: assignment.essays).count\n total_count = assignment.user_assignments.count\n total_count - review_count - 1 <= 0\n end", "def check_If_Posted \n\t$used = $oldQuote.include? $quote\nend", "def check_for_answers(questions)\r\n @possible_questions = []\r\n questions.each do |question| \r\n unless question.answers.length < 2 \r\n @possible_questions << question \r\n end \r\n @possible_questions\r\n end \r\n end", "def has_associated_response?\n @associated_responses ||= []\n not @associated_responses.empty?\n end" ]
[ "0.6991628", "0.6959786", "0.63981116", "0.62761766", "0.62358683", "0.617883", "0.6098505", "0.60631853", "0.6058364", "0.59978896", "0.5968574", "0.596645", "0.5947535", "0.58729345", "0.5858099", "0.58392376", "0.58310413", "0.5798336", "0.5785766", "0.5722757", "0.5722582", "0.5717897", "0.57134426", "0.5708758", "0.5705393", "0.5696783", "0.56923604", "0.56771094", "0.5651715", "0.564716", "0.564716", "0.56459683", "0.56154364", "0.56088215", "0.56059974", "0.5586039", "0.55750066", "0.55625224", "0.55600023", "0.5554117", "0.5548871", "0.5548611", "0.5540441", "0.55377364", "0.553159", "0.5519539", "0.55186456", "0.5514106", "0.55134535", "0.55097824", "0.55055743", "0.5502919", "0.55003566", "0.54888225", "0.5482329", "0.5460309", "0.5442198", "0.54311174", "0.5426564", "0.54255605", "0.5425474", "0.5416883", "0.5415671", "0.5414121", "0.54138887", "0.541132", "0.5405554", "0.5401383", "0.54001623", "0.5399185", "0.53931385", "0.53905016", "0.53895533", "0.53893906", "0.5381422", "0.536879", "0.53663564", "0.53658533", "0.53657585", "0.53613836", "0.5358901", "0.535394", "0.5348931", "0.53488183", "0.5346863", "0.534672", "0.53437644", "0.5342414", "0.5339954", "0.53386414", "0.5337161", "0.53352237", "0.5334644", "0.5332561", "0.5316951", "0.5315839", "0.53073627", "0.53043574", "0.53026736", "0.5301828" ]
0.67376494
2
=begin Checking if the response was copied from google =end
def google_search_response(auto_metareview) review_text_arr = auto_metareview.review_array # require 'ruby-web-search' count = 0 temp_array = Array.new review_text_arr.each{ |rev_text| if(!rev_text.nil?) #placing the search text within quotes to search exact match for the complete text response = RubyWebSearch::Google.search(:query => "\""+ rev_text +"\"") #if the results are greater than 0, then the text has been copied if(response.results.length > 0) count+=1 else temp_array << rev_text #copying the non-plagiarised text for evaluation end end } #setting temp_array as the @review_array auto_metareview.review_array = temp_array if(count > 0) return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_response(url)\n\t\t\t\t\t\tres_flag = false\n\t\t\t\t\t\t\t\tresponse = RestClient.get(url){|response, request, result| response \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif response.code != 200\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tputs response.code\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tres_flag = true\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tputs \"Skipped due to #{response.code}\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn res_flag\nend", "def check_response(response)\n case response\n when Net::HTTPSuccess then\n #puts response\n when Net::HTTPRedirection then\n location = response['location']\n warn \"redirected to #{location}\"\n fetch(location, limit - 1)\n else\n puts response.value\n end\nend", "def ok_to_extract?(remote_url)\n true\n end", "def check_fields_google_domain?\n return true if @fields[:share] == \"Google\" # File Listing\n return true if @fields[:src_sharename] == \"Google\" && @fields[:dst_sharename] == \"Google\" # File Copy/Move\n return true if @fields[:sharename] == \"Google\" # File Deletion\n return false\n end", "def verify_pcgw_url(pcgw_id)\n url = URI.parse(\"https://pcgamingwiki.com/wiki/#{pcgw_id}\")\n req = Net::HTTP.new(url.host, url.port)\n req.use_ssl = true\n res = req.request_head(url.path)\n if res.code == \"200\"\n return true\n elsif res.code == \"404\"\n return false\n else\n return false\n end\nend", "def check_for_dickheads\n # Defaced the site on 16th Sep 2008\n if !/^122\\.109\\..*/.match(request.remote_addr).nil? ||\n # Probably the same person as above.\n !/^124\\.190\\..*/.match(request.remote_addr).nil? \n # Spammed the site on the 18th Sep 2008, probably same person as above\n # Site resolves to http://youhide.com\n !/^208\\.99\\..*/.match(request.remote_addr).nil?\n redirect_to \"http://www.google.com/search?q=how+not+to+be+a+fucktard\"\n end\n end", "def response_incomplete?\n content_for_scanner.strip == \"\"\n end", "def get_content(mid)\r\n uri = URI.parse(\"https://www.googleapis.com/freebase/v1/rdf/\" << mid)\r\n http = Net::HTTP.new(uri.host, uri.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\r\n request = Net::HTTP::Get.new(uri.request_uri)\r\n response = http.request(request)\r\n if response.code == \"403\"\r\n response.code \r\n else\r\n response.body\r\n end\r\nend", "def check_hash_in_2xx_response(href, url, response, filenames)\n return false if @runner.options[:only_4xx]\n return false unless @runner.options[:check_external_hash]\n return false unless url.hash?\n\n hash = url.hash\n headers = response.options.fetch(:headers, {})\n content_type = headers.find { |k, _| k.casecmp(\"content-type\").zero? }\n\n # attempt to verify PDF hash ref; see #787 for more details\n # FIXME: this is re-reading the PDF response\n if content_type && content_type[1].include?(\"pdf\")\n io = URI.parse(url.to_s).open\n reader = PDF::Reader.new(io)\n\n pages = reader.pages\n if hash =~ /\\Apage=(\\d+)\\z/\n page = Regexp.last_match[1].to_i\n\n unless pages[page - 1]\n msg = \"External link #{href} failed: #{url.without_hash} exists, but the hash '#{hash}' does not\"\n add_failure(filenames, msg, response.code)\n @cache.add_external(href, filenames, response.code, msg, false)\n end\n\n return true\n end\n end\n\n body_doc = create_nokogiri(response.body)\n\n unencoded_hash = Addressable::URI.unescape(hash)\n xpath = [%(//*[@name=\"#{hash}\"]|/*[@name=\"#{unencoded_hash}\"]|//*[@id=\"#{hash}\"]|//*[@id=\"#{unencoded_hash}\"])]\n # user-content is a special addition by GitHub.\n if url.host =~ /github\\.com/i\n xpath << [%(//*[@name=\"user-content-#{hash}\"]|//*[@id=\"user-content-#{hash}\"])]\n # when linking to a file on GitHub, like #L12-L34, only the first \"L\" portion\n # will be identified as a linkable portion\n xpath << [%(//td[@id=\"#{Regexp.last_match[1]}\"])] if hash =~ /\\A(L\\d)+/\n end\n\n return unless body_doc.xpath(xpath.join(\"|\")).empty?\n\n msg = \"External link #{href} failed: #{url.without_hash} exists, but the hash '#{hash}' does not\"\n add_failure(filenames, msg, response.code)\n @cache.add_external(href, filenames, response.code, msg, false)\n true\n end", "def get_redirect_code(url)\n passed = true\n bad_codes = [204,206,400,404,408,500,501,502,503,504,505]\n\n\n\n counter = 0\n possible_redirect = []\n code = nil\n\n # Collect codes\n while code != 200 && bad_codes.include?(code) == false do\n possible_redirect << @entries[counter].response.status\n \n puts @entries[counter].response.status\n code = @entries[counter].response.status\n counter = counter + 1\n end\n\n # 301 Wrong Scenario test\n if(@url.include? \"maxRedirect=true\")\n if(possible_redirect.include?(301))\n # begin\n # campaign = @browser.evaluate_script(\"omnCampaignID\")\n # rescue\n # campaign = @browser.evaluate_script(\"app.omniMap.CampaignID\")\n # end\n\n # if campaign.downcase.include?(\"core\") == false\n passed == false\n # end\n end\n end\n\n possible_redirect.each do |code_to_check|\n if bad_codes.include?(code_to_check)\n passed == false\n end\n end\n\n\n return {result: passed, codes: possible_redirect}\n end", "def valid_http_code_returned?(http_client, url)\n rubygems_valid_response?(http_client, url) || shields_io_valid_response?(http_client, url)\n end", "def non_empty_http_response?(http)\n http.response.present?\n end", "def match_http_response_text(check,http_response_text)\n\n # first convert to intrigue uri format\n\n # grab headers\n header_part = http_response_text.split(/\\n\\n/).first\n body_part = http_response_text.split(/\\n\\n/).last\n\n headers = header_part.split(\"\\n\");\n body = body_part\n\n # TODO - fix to only grab content!!!!\n cookies = headers.select{|x| x =~ /^set-cookie:(.*)/i }\n\n ### grab the page attributes\n match = body.match(/<title>(.*?)<\\/title>/i)\n title = match.captures.first if match\n\n match = response.body.match(/<meta name=\\\"?generator\\\"? content=\\\"?(.*?)\\\"?\\/?>/i)\n generator = match.captures.first.gsub(\"\\\"\",\"\") if match\n\n # rest is a response\n # save title\n # save Cookies\n # save scripts ?\n data = {\n \"details\" => {\n \"hidden_response_data\" => body,\n \"headers\" => headers,\n \"cookies\" => cookies,\n \"generator\" => generator,\n \"title\" => title\n }\n }\n\n match_uri_hash(check,data)\n end", "def parse_google_speech(response)\n\t# The google speech api doesn't return valid JSON, we have to clean it up\n\tjson = response.split('{\"result\":[]}')[1]\n\tif valid_json(json)\n\t\tresult = JSON.parse(json)\n\t\ttranscript = result['result'][0]['alternative'][0]['transcript']\n\t\treturn transcript\n\tend\n\treturn false\nend", "def on_a_fort\n fort_response = Net::HTTP.get_response(URI('http://files.fort/'))\n fort_response.is_a?(Net::HTTPSuccess)\nrescue\n false\nend", "def fresh?(response); end", "def verify_same_origin_request; end", "def check_error_response(last_response)\n refute_match 'Sinatra doesn&rsquo;t know this ditty', last_response.body, \"unmatched url\"\n end", "def shields_io_valid_response?(http, url)\n url.include?(BadgeApi::BASE_URL) && http_valid_status_code?(http, 200) && http_valid_content_types?(http)\n end", "def valid_url?(url)\n resp = Curl.get url\n\n if resp.body_str.include? @invalid_text\n return false\n else\n return true\n end\nend", "def detect_new_article_link(link)\n response = Net::HTTP.get_response(URI.parse(link))\n puts \"#{link}\"\n puts \"......response.code => #{response.code} \"\n response\nend", "def complete?\n params[\"x_response_code\"] == '1'\n end", "def complete?\n params[\"x_response_code\"] == '1'\n end", "def request_successful(response)\n\t\tresponse.code == \"200\"\n\tend", "def on_cmd_google(action)\n action.reply @web.google(action.message.sub(/^!google /, ''))\n end", "def response_status_message(http_response)\n return false unless http_response.is_a?(Net::HTTPRedirection)\n query = URI.parse(http_response['location']).query\n return false if query.nil?\n return Base64.decode64(query.decode_query_string['msg'])\n end", "def check_response\n errors.add(:base, :invalid) unless response.present? && response[\"res\"] == 1\n end", "def contains_response_and_soln?() true ; end", "def locally_available?\n h = response_hash[\"RequestLink\"]\n # Message seems to sometimes have period sometimes not. \n return !! (h && h[\"RequestMessage\"] =~ /\\AThis item is available locally\\.?\\Z/)\n end", "def request_valid?(data)\n ln = 0\n data.each_line {|l|\n ln += 1\n }\n if ln > 1\n return true\n else\n puts \"\\e[1;31mCatch GET's without header information / Other \\e[0m\\ \"\n return false # Due to single GET Requests to no headers \n end\n end", "def check_response!\n body[:stat] == 'ok' || fail(ClientError, \"#{ body.inspect }\")\n end", "def valid?(mac, url)\n Net::HTTP.get_response(URI.parse(url + mac)).code == '200'\nend", "def scrub_fetch(url)\n begin\n Rails.logger.debug \"fetching raw html from #{url}\"\n Scrub.fetch_html(url)\n rescue SocketError\n Rails.logger.debug \"host unavailable\"\n self.errors.add(:base, \"couldn't resolve host name\")\n return false\n rescue\n Rails.logger.debug \"content unavailable\"\n self.errors.add(:base, \"error retrieving content\")\n return false\n end\n end", "def _match_http_response(check, response,options)\n\n # Construct an Intrigue Entity of type Uri so we can match it\n data = []\n=begin\n json = '{\n \t\"id\": 1572,\n \t\"type\": \"Intrigue::Entity::Uri\",\n \t\"name\": \"http://69.162.37.69:80\",\n \t\"deleted\": false,\n \t\"hidden\": false,\n \t\"detail_string\": \"Server: | App: | Title: Index page\",\n \t\"details\": {\n \t\t\"uri\": \"http://69.112.37.69:80\",\n \t\t\"code\": \"200\",\n \t\t\"port\": 80,\n \t\t\"forms\": false,\n \t\t\"title\": \"Index page\",\n \"generator\": \"Whatever\",\n \t\t\"verbs\": null,\n \t\t\"headers\": [\"content-length: 701\", \"last-modified: Tue, 03 Jul 2018 16:55:36 GMT\", \"cache-control: no-cache\", \"content-type: text/html\"],\n \t\t\"host_id\": 1571,\n \t\t\"scripts\": [],\n \t\t\"products\": [],\n \"cookies\": \"\",\n \t\t\"protocol\": \"tcp\",\n \t\t\"ip_address\": \"69.112.37.69\",\n \t\t\"javascript\": [],\n \t\t\"fingerprint\": [],\n \t\t\"api_endpoint\": false,\n \t\t\"masscan_string\": \"sudo masscan -p80,443,2004,3389,7001,8000,8080,8081,8443,U:161,U:500 --max-rate 10000 -oL /tmp/masscan20180703-9816-18n0ri --range 69.162.0.0/18\",\n \t\t\"app_fingerprint\": [],\n \t\t\"hidden_original\": \"http://69.162.37.69:80\",\n \t\t\"response_data_hash\": \"7o0r6ie5DOrJJnz1sS7RGO4XWsNn3hWykbwGkGnySWU=\",\n \t\t\"server_fingerprint\": [],\n \t\t\"enrichment_complete\": [\"enrich/uri\"],\n \t\t\"include_fingerprint\": [],\n \t\t\"enrichment_scheduled\": [\"enrich/uri\"],\n \t\t\"hidden_response_data\": \"\",\n \t\t\"hidden_screenshot_contents\": \"\"\"\n \t},\n \t\"generated_at\": \"2018-07-04T03:43:11+00:00\"\n }'\n=end\n data = {}\n data[\"details\"] = {}\n data[\"details\"][\"hidden_response_data\"] = \"#{response.body}\"\n # construct the headers into a big string block\n headers = []\n response.each_header do |h,v|\n headers << \"#{h}: #{v}\"\n end\n data[\"details\"][\"headers\"] = headers\n\n ### grab the page attributes\n match = response.body.match(/<title>(.*?)<\\/title>/i)\n data[\"details\"][\"title\"] = match.captures.first if match\n\n match = response.body.match(/<meta name=\"generator\" content=(.*?)>/i)\n data[\"details\"][\"generator\"] = match.captures.first.gsub(\"\\\"\",\"\") if match\n\n data[\"details\"][\"cookies\"] = response.header['set-cookie']\n data[\"details\"][\"response_data_hash\"] = Digest::SHA256.base64digest(\"#{response.body}\")\n\n # call the actual matcher & return\n _match_uri_hash check, data, options\n end", "def informational_response?\n (100..199).cover?(code)\n end", "def parse_response(response)\n return [false, nil] if response.body.blank? || response.parsed_response.nil? || response.response.nil?\n return [true, nil] if response.response.is_a?(Net::HTTPNotFound)\n\n Rails.logger.debug { \"Companies house response #{response}\" }\n\n parse_companies_house_response response.parsed_response\n true\n end", "def ok?(response)\n case response\n when Net::HTTPSuccess\n true\n else\n false\n end\n end", "def valid_http_response?(http)\n http.is_a?(EM::HttpClient) && non_empty_http_response?(http)\n end", "def check_url(path, url)\n res = http_client.get(url, follow_redirect: true)\n return if res.status == 200\n raise(nil) unless res.status.to_s.match(/50\\d|403/)\n\n puts \"::warning file=#{path}:: Unexpected response from #{url} (#{res.status})\"\nrescue StandardError => e\n puts \"::warning file=#{path}:: Unable to reach #{url} #{res.respond_to?('status') ? res.status : nil}\"\n puts e.full_message unless e.instance_of?(TypeError)\n 1\nend", "def process_response_data\n return false unless @response\n if save_webpage && save_webpage_response\n @webpage_request.update(status: 'complete')\n else\n @webpage_request.update(status: 'error')\n return false\n end\n end", "def silly_fd_inconsistency(status, response)\n # FD will return 404 when updating a contact, who is an agent. So if someone from staff is\n # a ticket sender, we won't be able to update the ticket.\n return true if status == 404\n\n begin\n response = JSON.parse(response)\n\n # Freshdesk will not allow to update description if the member name contains /, \", wwww.\n # But it ALLOWS such requesters to be created in the first place.\n # Result: such requesters cannot be updated via API without chaning their name.\n return true if response['errors'].any? { |x|\n x['field'] == 'name' && x['message'] == \"/,\\\",www. not allowed in name\"\n }\n\n false\n rescue JSON::ParserError\n false\n end\n end", "def availability_check_response(_msg_id, data)\n if false\n response = JSON.parse(data)\n # TODO: format of fifi_ready value is not defined yet\n status = response['result'] == 'ok' && response['fifi_ready'].to_i == 1 ? STATUS_AVAILABLE : STATUS_UNAVAILABLE\n\n if status == STATUS_UNAVAILABLE\n logger.warn(\"Source #{source_id} is unavailable. Reason: #{response['message']}\")\n end\n\n update_source(source_id, status)\n else\n # woohoo, always successful\n update_source(source_id, STATUS_AVAILABLE)\n end\n end", "def get_live_response(address_info)\n raise \"API key not specified.\\nCall AddressStandardization::GoogleMaps.api_key = '...' before you call .standardize().\" unless GoogleMaps.api_key\n \n address_info = address_info.stringify_keys\n \n address_str = [\n address_info[\"street\"],\n address_info[\"city\"],\n (address_info[\"state\"] || address_info[\"province\"]),\n address_info[\"zip\"]\n ].compact.join(\" \")\n url = \"http://maps.google.com/maps/geo?q=#{address_str.url_escape}&output=xml&key=#{GoogleMaps.api_key}&oe=utf-8\"\n AddressStandardization.debug \"[GoogleMaps] Hitting URL: #{url}\"\n uri = URI.parse(url)\n res = Net::HTTP.get_response(uri)\n return unless res.is_a?(Net::HTTPSuccess)\n \n content = res.body\n AddressStandardization.debug \"[GoogleMaps] Response body:\"\n AddressStandardization.debug \"--------------------------------------------------\"\n AddressStandardization.debug content\n AddressStandardization.debug \"--------------------------------------------------\"\n xml = Nokogiri::XML(content)\n xml.remove_namespaces! # good or bad? I say good.\n return unless xml.at(\"/kml/Response/Status/code\").inner_text == \"200\"\n \n addr = {}\n \n addr[:street] = get_inner_text(xml, '//ThoroughfareName').to_s\n addr[:city] = get_inner_text(xml, '//LocalityName').to_s\n addr[:province] = addr[:state] = get_inner_text(xml, '//AdministrativeAreaName').to_s\n addr[:zip] = addr[:postalcode] = get_inner_text(xml, '//PostalCodeNumber').to_s\n addr[:country] = get_inner_text(xml, '//CountryName').to_s\n \n return if addr[:street] =~ /^\\s*$/ or addr[:city] =~ /^\\s*$/\n \n Address.new(addr)\n end", "def resp_guard_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.RESP_GUARD\"))\n end", "def process_response(response)\n case response\n when Net::HTTPFound, Net::HTTPCreated\n response['Location']\n when Net::HTTPConflict\n raise URLConflict\n when Net::HTTPNotAcceptable\n raise URLFormatError\n else\n raise InvalidResponse.new(\"Invalid Shorty Response Code: #{response.code} #{response.message}\")\n end\n end", "def is_work_address_previously_collected_and_valid?(question)\n answer_for(question, valid_response_exists?(\"PREG_VISIT_1_3.WORK_ADDRESS_1\", :last))\n end", "def check_for_valid_response(resp)\n if resp == 'exit!'\n game_data.save\n elsif game_data.chosen_letters.include?(resp)\n repeat_response_query('repeat')\n elsif resp.length > 1\n repeat_response_query('multiple')\n else\n action(resp)\n end\n end", "def ok? \n @response.is_a? Net::HTTPOK\n end", "def checkOA(origurl)\n url = origurl.gsub(/https?\\:\\/\\/?/,'')\n uri, *path = url.split(\"/\")\n path = \"/\" + path.join(\"/\")\n origurl.sub!(':/', '://') unless origurl.index(\"//\")\n\n chrome_agent = 'Mozilla/5.0 (X11; CrOS i686 1660.57.0) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.46 Safari/535.19'\n curl_opts = \"--connect-timeout 5 -A '#{chrome_agent}'\"\n\n # first check against whitelist\n whitelist = [ # list of URLs that don't need to be downloaded to check, first is URI, second is path\n [/arxiv\\.org/, /\\.pdf$/]\n ]\n whitelist.each { |comp| return true if uri.index(comp[0]) && path.index(comp[1]) }\n\n # faking agent, to avoid no-robots\n\n # grab header using curl\n response = `curl #{curl_opts} -I '#{origurl}'`\n\n possible_ctypes = [\n \"application/pdf\",\n \"application/x-pdf\",\n \"application/vnd.pdf\",\n \"application/text.pdf\"]\n\n # if ctype matches PDF, true, otherwise explore further\n possible_ctypes.each {|ctype| return true if response.index(\"Content-Type: #{ctype}\")}\n\n # try curl\n `curl #{curl_opts} -r 0-99 -s '#{origurl}' > output.tmp`\n\n return (`file output.tmp;rm output.tmp`.index(\"PDF document\") ? true : false)\n\n # we tried, but we failed.\n return false\nend", "def checkOA(origurl)\n url = origurl.gsub(/https?\\:\\/\\/?/,'')\n uri, *path = url.split(\"/\")\n path = \"/\" + path.join(\"/\")\n origurl.sub!(':/', '://') unless origurl.index(\"//\")\n\n chrome_agent = 'Mozilla/5.0 (X11; CrOS i686 1660.57.0) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.46 Safari/535.19'\n curl_opts = \"--connect-timeout 5 -A '#{chrome_agent}'\"\n\n # first check against whitelist\n whitelist = [ # list of URLs that don't need to be downloaded to check, first is URI, second is path\n [/arxiv\\.org/, /\\.pdf$/]\n ]\n whitelist.each { |comp| return true if uri.index(comp[0]) && path.index(comp[1]) }\n\n # faking agent, to avoid no-robots\n\n # grab header using curl\n response = `curl #{curl_opts} -I '#{origurl}'`\n\n possible_ctypes = [\n \"application/pdf\",\n \"application/x-pdf\",\n \"application/vnd.pdf\",\n \"application/text.pdf\"]\n\n # if ctype matches PDF, true, otherwise explore further\n possible_ctypes.each {|ctype| return true if response.index(\"Content-Type: #{ctype}\")}\n\n # try curl\n `curl #{curl_opts} -r 0-99 -s '#{origurl}' > output.tmp`\n\n return (`file output.tmp;rm output.tmp`.index(\"PDF document\") ? true : false)\n\n # we tried, but we failed.\n return false\nend", "def empty?(response); end", "def google_check_exist(client)\n path = CGI::unescape(@fields[:path])\n client.check_exist_by_path(path)\n end", "def rubygems_valid_response?(http, url)\n url.include?(RubygemsApi::BASE_URL) && http_valid_status_code?(http, [200, 404])\n end", "def success?\n return false unless @result['status'] == 'OK'\n return false unless @result['results'][0]['address_components'].length > 1\n true\n end", "def validate_response(resp)\n # The length for a chunked response is 0, so checking it isn't meaningful.\n return resp if resp.headers['Transfer-Encoding'] == 'chunked'\n\n exp_content_length = resp.headers['Content-Length'].to_i\n actual_content_length = resp.body.length\n return resp if actual_content_length == exp_content_length\n\n errmsg = \"Incomplete response received from Symphony for #{@catkey} - expected #{exp_content_length} bytes but got #{actual_content_length}\"\n Honeybadger.notify(errmsg)\n raise ResponseError, errmsg\n end", "def check_hash_in_2xx_response(href, effective_url, response, filenames)\n return if @options[:only_4xx]\n return unless @options[:check_external_hash]\n return unless (hash = hash?(href))\n\n body_doc = create_nokogiri(response.body)\n\n # user-content is a special addition by GitHub.\n xpath = %(//*[@name=\"#{hash}\"]|//*[@id=\"#{hash}\"])\n if URI.parse(href).host.match(/github\\.com/i)\n xpath << %(|//*[@name=\"user-content-#{hash}\"]|//*[@id=\"user-content-#{hash}\"])\n end\n\n return unless body_doc.xpath(xpath).empty?\n\n add_external_issue filenames, \"External link #{href} failed: #{effective_url} exists, but the hash '#{hash}' does not\", response.code\n end", "def analyse_http_code(response_code)\n case response_code\n when 1 then\n # Failure to use the proxy\n return false\n when 400 .. 403 then\n # Proxy asks for authentication\n return false\n when 407 then\n # Proxy asks for authentication\n return false\n when 444 then\n return response_code\n else\n # If we get a valid return code, we add it to the final list\n return response_code\n end\n end", "def success_from(response)\n response == 'SUCCESSFUL' || response =~ /^\\d+$/ || response == 'true'\n end", "def response_includes?(content)\n @response.body.include?(content)\n end", "def check_response_and_return_data(resp)\n status = resp.parsed_response['message']['header']['response']['result']\n return resp.parsed_response['message']['body']['bodyContent'] if\n status == 'SUCCESS'\n c = resp.parsed_response['message']['header']['response']['exceptionID']\n t = resp.parsed_response['message']['header']['response']['reason']\n raise WebexXmlApi::RequestFailed.new(resp), \"Error #{c}: #{t}\"\n end", "def lucky(bot, search_term = \"\")\n # Make the google search\n uri = Google::Search::Web.new(:query => search_term.to_s).first\n return if not uri\n uri = uri.uri.to_s\n\n # Return if the url is too short\n return if uri.length < @config[:min_length]\n \n # Give the reply\n bot.say(\"#{@config[:prompt]} #{uri}\")\n end", "def reachable?(url)\n page = MetaInspector.new(url)\n\n if page.response.status < 400\n true\n else\n false\n end\n rescue\n false\n end", "def http_redirect?\n @get_resp.kind_of?(Net::HTTPRedirection)\n end", "def http_redirect?\n @get_resp.kind_of?(Net::HTTPRedirection)\n end", "def check_trip_published(arg)\n puts \"[testing]sleeping 1 sec to avoid an error on blablacar server side\"\n sleep(1)\n req = setup_http_request($publication_processed, @cookie, {:url_arg => [arg]})\n res = @http.request(req)\n if res.code != \"200\"\n if res.body.include?(\"maintenance\")\n puts \"[?] Blablacar est en maintenance\"\n end\n File.open(\"Checkpublished_error1.html\",\"w\") do |f| f.write(res.body); end\n raise CheckPublishedTripError, \"HTTP code should be 200 here [step 2 checking]\"\n end\n if res.body.force_encoding('utf-8').include?(\"Voir votre annonce\")\n puts \"voir votre annonce\"\n return true, 0\n elsif res.body.force_encoding('utf-8').include?(\"Votre annonce sera publiée dans quelques instants\")\n puts \"votre annonce sera publiée dans qq instants\"\n return true, 1\n else\n puts \"fail\"\n return false\n end\n end", "def got_response(response)\n end", "def marked_for_same_origin_verification?; end", "def check_http_status(href)\n url = href.split(\".com/\")\n response = nil\n Net::HTTP.start(url[0].split(\"https://\").last + \".com\", 80) {|http|\n response = http.head(\"/\" + url[1])\n }\n if(response.code != \"200\")\n fail(href + \" returned code: \" + response.code)\n end\nend", "def compare_reviews_with_google_search(auto_metareview)\n review_text_arr = auto_metareview.review_array\n\n flag = false\n temp_array = Array.new\n\n review_text_arr.each{\n |rev_text|\n if(!rev_text.nil?)\n #placing the search text within quotes to search exact match for the complete text\n response = RubyWebSearch::Google.search(:query => \"\\\"\"+ rev_text +\"\\\"\")\n #if the results are greater than 0, then the text has been copied\n if(response.results.length > 0)\n flag = true\n else\n temp_array << rev_text #copying the non-plagiarised text for evaluation\n end\n end\n }\n #setting temp_array as the @review_array\n auto_metareview.review_array = temp_array\n\n flag\n\n end", "def getLatLng(city, country, http)\n puts \"getLatLng(#{city}, #{country}, http)\"\n validLatLng = /-?\\d+\\.?\\d*/\n responseLoc = /.*\\\"lat\\\": (#{validLatLng}).*\\\"lng\\\": (#{validLatLng}).*/m\n lat = \"\"\n lng = \"\"\n \n cityAry = city.split(' ')\n subRequest = cityAry[0]\n (cityAry.size-1).times{ |i|\n subRequest += '+'\n subRequest += cityAry[i+1]\n }\n \n subRequest += ','\n \n countryAry = country.split(' ')\n subRequest += countryAry[0]\n (countryAry.size-1).times{ |i|\n subRequest += '+'\n subRequest += countryAry[i+1]\n }\n \n request = \"/maps/api/geocode/json?address=#{subRequest}&sensor=false\"\n # puts \"request: #{request}\"\n response = http.request_get(request)\n \n if response.body =~ responseLoc\n lat = $1\n lng = $2\n end\n\n sleep 0.5 #Sleep a second so that Google doesn't rate limit me\n \n if lat == \"\" or lng == \"\"\n puts \"TROUBLE! #{request}\"\n puts response.body\n LatLng.new(-200,-200)\n else\n LatLng.new(lat.to_f, lng.to_f)\n end\nend", "def is_signed_response(response)\n\t str = response.body + API_KEY\n\t hash = Digest::SHA1.hexdigest str\n\t if hash == response.header['X-Sponsorpay-Response-Signature']\n \t true\n\t else\n\t @result[:error] = {code: \"Invalid response\"\n\t\t\t message: \"Response generated from unauthorized source. \"}\n\t false\n\t end\n\tend", "def respond_to_question(url, token, encrypted_id, resp)\n dputs __method__.to_s\n messages_req = setup_http_request($respond_to_message, @cookie, {:url => url, :arg => [resp, encrypted_id, token]})\n res = @http.request(messages_req)\n body = CGI.unescapeHTML(res.body.force_encoding('utf-8'))\n # Checking...\n if res.code == \"302\"\n found = false\n # Should not be a problem calling public instead private or other way\n get_public_conversations(res['location']).map{|m|\n m[:msgs].map{|c| found = true if c[:msg].include?(resp)}\n if found\n return true\n end\n }\n return false\n end\n raise SendReponseMessageError, \"Cannot received expected 302 code...\"\n end", "def error_response?(response, _parsed_response)\n !(200..299).cover?(response.code)\n end", "def check\r\n\r\n res = send_request_cgi({\r\n 'method' => 'GET',\r\n 'uri' => normalize_uri(target_uri.path, \"#{datastore['CONTENT_DIR']}/\")\r\n })\r\n\r\n unless res\r\n vprint_error 'Connection failed'\r\n return CheckCode::Unknown\r\n end\r\n\r\n if res.code == 404\r\n return Exploit::CheckCode::Safe\r\n end\r\n return Exploit::CheckCode::Appears\r\n end", "def net_http_res; end", "def network_available?(sample_uri = SAMPLE_URI.call)\n @agent.get('http://portal.titech.ac.jp').to_b\n rescue # check another website just to make sure\n @agent.get(sample_uri).to_b rescue return false\n end", "def assess\n @error = false\n begin\n response_code = get_http_response_code(@referer)\n rescue\n Flying.an_error_ocurred(true)\n set_error_message(@referer, false, $!)\n return false\n end\n return true if [\"200\", \"302\"].include? response_code\n Flying.an_error_ocurred(true)\n set_error_message(@referer, response_code.to_s)\n false\n end", "def get_response\r\n if @letter.size != 1\r\n puts \"Invalid input, try again\"\r\n elsif @secret_word_letters.include? @letter\r\n puts \"Yes! This word does include #{@letter}!\"\r\n elsif @chances > 1\r\n @chances -= 1\r\n puts \"#{@letter} is not a letter in the word. You have #{@chances} guesses left.\"\r\n else\r\n lost\r\n end\r\n end", "def yelp_blocked? ip\n\n curl_res = `ssh #{ip} 'curl http://www.yelp.com/biz/vip-oriental-santa-clara'` \n index = curl_res.index(\"VIP Oriental\")\n if index.nil?\n puts \"================================> #{ip}\"\n puts \"#{curl_res}\"\n return true\n end\n return false;\nend", "def test_compare_user_w_same_country\n get '/v1/compare_country?data1=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D&data2=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D'\n assert last_response.ok?\n assert last_response.body.include?('The users live in the same country')\n end", "def verify_uri_acessibility uri\n res = Net::HTTP.get_response URI(uri)\n res.is_a? Net::HTTPSuccess\nend", "def guessing?\n ! page.has_content?(\"Your Results\")\n end", "def display_result(response, host)\n if response.to_s.include? \"\\\"code\\\":0\"\n puts \"[+] #{host}: Vulnerable\"\n else\n puts \"[-] #{host}: Not Vulnerable\"\n end\nend", "def check_response\n unless (res = get).valid?\n raise BadResponse, \"#{res.code} #{res['Code'].first}\"\n end\n\n res\n end", "def check_embedding!\n if embedded?\n response.headers.except! 'X-Frame-Options'\n end\n end", "def imperfect_return_resubmission?\n return false unless previously_transmitted_submission.present?\n \n previously_transmitted_submission.efile_submission_transitions.collect(&:efile_errors).flatten.any? { |error| [\"SEIC-F1040-501-02\", \"R0000-504-02\"].include? error.code }\n end", "def response_unavailable?\n !!(content_for_scanner =~ /Server too busy, try again later/)\n end", "def http_error?\n !(200..299).include?(http_code)\n end", "def cvv2_resp_code_matches?\n return ['M'].include? cvv2_resp_code\n end", "def fcitycheck(vresult,vcity)\n\n\t#pick up city and country from api response body\n\tcity = vresult[\"data\"][\"request\"][0][\"query\"]\n\n\t#remove country from api response leaving only the city\n\ttruncatedcity=city[0,vcity.length]\n\t\n\t#validate that api response is for correct city\n\tif city = truncatedcity then\n\t\tputs \"--------\"\n\t\tputs \"Test 3 (Pass): Weather for #{city} is correct!\"\n\telse\n\t\tputs \"--------\"\n\t\tputs \"Test 3 (Pass): Weather for #{city} is not correct!\"\n\tend\n\t\nend", "def url_redirect_checker\n require 'curb'\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(crm_url_redirect: nil)\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(geo_url_redirect: nil)[20...-1]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%http%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%www%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where.not(\"raw_url LIKE '%www%'\")[a...z]\n # Indexer.where.not(\"redirect_status LIKE '%Error%'\")\n\n # a=0\n # z=-1\n\n indexers = Indexer.where(indexer_status: \"COP URL\").where(clean_url: nil)[a...z] ##17,033\n\n\n counter_fail = 0\n counter_result = 0\n total = 0\n indexers.each do |indexer|\n total +=1\n\n raw_url = indexer.raw_url\n\n begin ## rescue\n result = Curl::Easy.perform(raw_url) do |curl|\n curl.follow_location = true\n curl.useragent = \"curb\"\n curl.connect_timeout = 10\n curl.enable_cookies = true\n # curl.ssl_verify_peer = false\n end\n\n curb_url_result = result.last_effective_url\n\n crm_url_hash = url_formatter(curb_url_result)\n raw_url_final = crm_url_hash[:new_url]\n\n if raw_url != raw_url_final\n counter_result +=1\n puts\n puts \"[#{a}...#{z}] (#{counter_result}/#{total})\"\n puts \"O: #{raw_url}\"\n puts \"N: #{raw_url_final}\"\n puts \"--------------------------------------------\"\n puts\n indexer.update_attributes(redirect_status: \"Updated\", clean_url: raw_url_final)\n else\n puts \"[#{a}...#{z}] (#{total}): Same\"\n indexer.update_attributes(redirect_status: \"Same\", clean_url: raw_url_final)\n end\n\n rescue #begin rescue\n error_message = $!.message\n counter_fail +=1\n final_error_msg = \"Error: #{error_message}\"\n puts \"(#{counter_fail}/#{total}) (#{final_error_msg})\"\n\n if final_error_msg && final_error_msg.include?(\"Error:\")\n if final_error_msg.include?(\"SSL connect error\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"SSL Error\")\n elsif final_error_msg.include?(\"Couldn't resolve host name\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Host Error\")\n elsif final_error_msg.include?(\"Peer certificate\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Certificate Error\")\n elsif final_error_msg.include?(\"Failure when receiving data\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Transfer Error\")\n else\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Error\")\n end\n end\n end #end rescue\n end\n end", "def credential_check\n %w(partner req_id service v).all? { |k|\n # AlipayWap.logger.debug \"#{k}: #{@protocol_fields[k]}<->#{@request.protocol_fields[k]}\"\n @protocol_fields[k] == @request.protocol_fields[k].to_s\n } || raise(\"Response is not for this request\")\n end", "def test_twice_fail\n enter_the_room \"zark\"\n result=enter_the_room \"zark\", {:check_response => false}\n assert last_response.ok?, \"response was:\"+last_response.body\n assert result[\"result\"]==\"duplicate\"\n end", "def url_accessibility(url)\n open(url).status.last == 'OK'\n rescue ::SocketError, Timeout::Error, Errno::ECONNREFUSED, OpenURI::HTTPError\n false\n end", "def is_user_proxied(meeting, id)\n user = ASF::Person.find(id)\n lines = IO.read(File.join(MEETINGS, meeting, 'proxies'))\n proxylist = lines.scan(/\\s\\s(.{25})(.*?)\\((.*?)\\)/) # [[\"Shane Curcuru \", \"David Fisher \", \"wave\"], ...]\n help = nil\n copypasta = [] # theiravailid | Their Name in Rolls (proxy)\n proxylist.each do |arr|\n if user.cn == arr[0].strip\n copypasta << \"#{arr[2].ljust(12)} | #{arr[1].strip} (proxy)\"\n elsif user.id == arr[2]\n help = \"NOTE: You have already submitted a proxy form for #{arr[0].strip} to mark your attendance (be sure they know to mark you at Roll Call)! \"\n end\n end\n if copypasta.empty?\n return help\n else\n (help ||= \"\") << \"Since you are a proxy for others, then AFTER the 2. Roll Call is called, you may copy/paste the below lines to mark your and your proxies attendance.\"\n copypasta.unshift(\"#{user.id.ljust(12)} | #{user.cn}\")\n return help, copypasta\n end\nend", "def valid_request_origin?; end", "def test_misfortune\n # find a usable canary URI (one that returns an acceptable status code already)\n if canary = find_canary\n canary_value, canary_code = canary\n vprint_status(\"#{peer} found canary URI #{canary_value} with code #{canary_code}\")\n else\n vprint_error(\"#{peer} Unable to find a suitable canary URI\")\n return Exploit::CheckCode::Unknown\n end\n\n canary_cookie_name = 'C107373883'\n canary_cookie = canary_cookie_name + \"=#{canary_value};\"\n\n # Make a request containing a specific canary cookie name with the value set\n # from the suitable canary value found above.\n res = send_request_raw(\n 'uri' => normalize_uri(target_uri.path.to_s),\n 'method' => 'GET',\n 'headers' => headers.merge('Cookie' => canary_cookie)\n )\n\n unless res\n vprint_error(\"#{full_uri} no response\")\n return Exploit::CheckCode::Unknown\n end\n\n unless res.code.to_s =~ @status_codes_regex\n vprint_status(\"#{full_uri} unexpected HTTP code #{res.code} response\")\n return check_response_fingerprint(res, Exploit::CheckCode::Detected)\n end\n\n unless res.body\n vprint_status(\"#{full_uri} HTTP code #{res.code} had no body\")\n return check_response_fingerprint(res, Exploit::CheckCode::Detected)\n end\n\n # If that canary *value* shows up in the *body*, then there are two possibilities:\n #\n # 1) If the canary cookie *name* is also in the *body*, it is likely that\n # the endpoint is puppeting back our request to some extent and therefore\n # it is expected that the canary cookie *value* would also be there.\n # return Exploit::CheckCode::Detected\n #\n # 2) If the canary cookie *name* is *not* in the *body*, return\n # Exploit::CheckCode::Vulnerable\n if res.body.include?(canary_value)\n if res.body.include?(canary_cookie_name)\n vprint_status(\"#{full_uri} HTTP code #{res.code} response contained canary cookie name #{canary_cookie_name}\")\n return check_response_fingerprint(res, Exploit::CheckCode::Detected)\n else\n vprint_good(\"#{full_uri} HTTP code #{res.code} response contained canary cookie value #{canary_value} as URI\")\n report_vuln(\n host: rhost,\n port: rport,\n name: name,\n refs: references\n )\n return Exploit::CheckCode::Vulnerable\n end\n end\n\n vprint_status(\"#{full_uri} HTTP code #{res.code} response did not contain canary cookie value #{canary_value} as URI\")\n check_response_fingerprint(res, Exploit::CheckCode::Safe)\n end", "def parse_response?\n parse_response\n end", "def discrepancy?(local, remote)\n local.status != remote['status'] ||\n local.ad_description != remote['description']\n end", "def verify_job_complete(base_64_urn,access_token)\n is_complete = false\n\n while(!is_complete)\n response = RestClient.get(\"#{API_URL}/modelderivative/v2/designdata/#{base_64_urn}/manifest\",\n { Authorization: \"Bearer #{access_token}\"} )\n json = JSON.parse(response.body)\n if(json[\"progress\"]==\"complete\")\n is_complete = true\n puts(\"***** Finished translating your file to SVF - status: #{json['status']}, progress: #{json['progress']} \")\n else\n puts(\"***** Haven't finished translating your file to SVF - status: #{json['status']}, progress: #{json['progress']} \")\n sleep 1\n end\n end\n\n return response\nend" ]
[ "0.6006878", "0.59554756", "0.5771941", "0.5752945", "0.57092756", "0.56864", "0.56709874", "0.5630728", "0.5581401", "0.5562084", "0.55540913", "0.55192167", "0.5493734", "0.54890597", "0.5487719", "0.5469847", "0.54348123", "0.54304343", "0.54186386", "0.5417814", "0.54177713", "0.54114854", "0.5399289", "0.5394782", "0.53887194", "0.5368367", "0.53626007", "0.53601205", "0.53563803", "0.53412473", "0.53404796", "0.5322027", "0.5294609", "0.5287331", "0.52870315", "0.52758765", "0.52748424", "0.52539", "0.5253699", "0.5250808", "0.5247696", "0.5242209", "0.5240409", "0.5236391", "0.52273345", "0.52211154", "0.5201033", "0.51962304", "0.5186873", "0.5186873", "0.51668555", "0.5164138", "0.5158969", "0.51547265", "0.51526177", "0.5147146", "0.51431435", "0.51383436", "0.51381457", "0.5137085", "0.5135412", "0.5133866", "0.5128352", "0.5128352", "0.51257616", "0.5119261", "0.5113961", "0.5113056", "0.5112602", "0.5108985", "0.51046604", "0.5097927", "0.509741", "0.50880843", "0.5086489", "0.50855154", "0.50795186", "0.5079446", "0.5076522", "0.5075853", "0.50754076", "0.507443", "0.50730103", "0.50686646", "0.506563", "0.50622904", "0.505373", "0.5033038", "0.5032801", "0.50327164", "0.5029058", "0.50263786", "0.5011439", "0.500197", "0.5000446", "0.49947298", "0.4993953", "0.4991468", "0.49905047", "0.49886078" ]
0.58493525
2
Find the sum of all the primes below two million.
def is_prime?(i) return false if i <= 1 return true if i == 2 (2...i).each {|n| if i % n == 0 return false end } true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ten\n acc = 0\n (find_primes_below 2000000).each do |i|\n acc = acc + i\n end\n return acc \nend", "def run\n puts sum_of_primes_below(10)\n #=> 17\n\n puts sum_of_primes_below(2_000_000)\n #=> ??\nend", "def consecutive_prime_below_one_million\n @max_limit = 1000_000\n generate_prime_numbers()\n # number_of_primes = 0\n result = 0\n\n count_prime_sum = @prime_numbers_sum.length\n number_of_primes = 1\n # i_index = 0\n count_prime_sum.times do |i_index|\n for j in (count_prime_sum - 1).downto(i_index + number_of_primes ) do\n difference = @prime_numbers_sum[j] - @prime_numbers_sum[i_index]\n if (j - i_index > number_of_primes) && difference < @max_limit && ( @prime_numbers.include? difference) #\n number_of_primes, result = j - i_index, difference\n break\n end\n end ## end of j\n end ## end of i\n\n puts '=============================================================================================='\n puts 'Q2: Which prime, below one million, can be written as the sum of the most consecutive primes?'\n puts \"Sol: Result For Finding consecutive prime below #{@max_limit} : #{result}, and \\n Number of primes in those are #{number_of_primes}\"\n puts '=============================================================================================='\n\n end", "def p10\n\tprimes = []\n\tPrime.each do |prime|\n\t\tbreak if prime >= 2000000\n\t\tprimes << prime\n\tend\n\t# puts primes\n\tprimes.reduce(:+)\nend", "def problem10()\n\tsum = 0; Prime.each(2000000) {|i| sum += i}; return sum\nend", "def get_consecutive_prime_below_one_million(primes)\n sumation = 0;\n prime_number_list = []\n number_of_primes = 0 \n primes.each_with_index do | prime_number , i |\n # puts \"#{prime_number} - #{i}\"\n @sum = @sum + prime_number\n @primeSum[i+1] = @sum if @sum < @limit;\n end\n # puts \"#{@primeSum}\"\n\n count_of_primeSum = @primeSum.length\n number_of_primes = 1 \n count_of_primeSum.times do |i|\n for j in (count_of_primeSum - 1).downto(i + number_of_primes ) do\n difference = @primeSum[j] - @primeSum[i]\n\n if (j-i > number_of_primes) && (difference < limit) && ( primes.include? difference)\n # puts \"#{i}--#{j}\"\n \n prime_number_list = primes[i...j]\n number_of_primes = j-i\n sumation = difference \n end\n end\n end\n @result[:sumation] = sumation \n @result[:number_of_terms] = number_of_primes \n @result[:prime_number_list] = prime_number_list \n\n @result\n end", "def test2(limit)\n\ttotal = 0\n\t2.upto(limit) do |x|\n\t\tif isPrime(x) then total += x end\n\tend\n\ttotal \nend", "def sum_of_primes_below(n)\n sum = 0\n require 'prime'\n Prime.each(n) do |prime|\n sum += prime\n end\n\n sum\nend", "def getSumPrime()\n def isPrime(n)\n return false if n <= 1\n 2.upto(Math.sqrt(n).to_i) do |x|\n return false if n%x == 0\n end\n true\n end\n\n sum=0\n (2..2000000).each { |x| sum=sum+x if isPrime(x) }\n puts sum\nend", "def primes_sum\n primeArr = []\n num = 2\n while num < 2000000\n if is_prime num\n primeArr << num\n end\n num += 1\n end\n primeArr.reduce(:+)\nend", "def sum_primes(num)\n nums = Hash.new{true}\n\n (2...num**(0.5)).each do |x|\n if nums[x]\n i = x\n while x*i < num\n nums[x*i] = false\n i += 1\n end\n end\n end\n \n sum = 0\n (2...num).each { |x| sum += x if nums[x] }\n sum\nend", "def sum_of_primes(upper_bound)\n Prime.each(upper_bound).reduce(:+)\nend", "def summation_of_primes_2(max)\n sieve = Array.new(max, true)\n sieve[0] = sieve[1] = false # 0 and 1 aren't primes\n sum = 0\n\n p = 2\n while p < sieve.size\n # Mark all composites off\n k = 1\n while k * p < max\n sieve[k * p] = false\n k += 1\n end\n\n sum += p\n\n # Find next prime\n while !sieve[p] and p < sieve.size\n p += 1\n end\n end\n\n sum\nend", "def summation_of_primes(limit)\n primes = [2]\n accum = 3\n\n while primes[primes.length - 1] < limit\n\n if primes.all?{|ele| accum % ele != 0}\n primes << accum\n end\n accum += 2\n\n end\n primes.pop\n # p primes\n sum = primes.reduce(:+)\n sum\nend", "def sum_primes max_number\n sum = 2\n (3..max_number).each do |test_num|\n next if test_num.even?\n prime = true\n # sqrttest = test_num**0.5\n (2..Math.sqrt(test_num)).each do |factor|\n prime = false if (test_num % factor == 0)\n break unless prime\n end\n sum += test_num if prime\n #puts test_num if prime\n end\n return sum\nend", "def prime_sum(limit)\n Prime.each(limit).inject :+\n end", "def find_primes_under(num)\n\tprimes = [2]\n\tcounter = 3\n\twhile primes[-1] < num\n\t\tcounter2 = 2\n\t\twhile counter2 <= counter\n\t\t\tif counter % counter2 == 0\n\t\t\t\tbreak\n\t\t\telsif\n\t\t\t\tcounter2 * counter2 > counter\n\t\t\t\tprimes << counter\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tcounter2 += 1\n\t\tend\n\tcounter += 1\n\tend\n\tprimes[0..-2]\nend", "def sumPrimes\n i = 1999999\n sum = 2\n \n # note that this code will never count 2 as prime simply because it never tests 2. \n # For eficiency, it skips all evens, inadvertently skips 2. \n # make a better fix later. for now, initialize sum to 2. \n # was written in reverse order to check if 2 was counted as prime\n while i > 0\n if isPrime(i)\n puts i \n sum += i\n end\n i -= 2\n end\n \n return sum\n \nend", "def add_primes_upto(max)\n primes = [2, 3]\n primes_index = 1\n sum = 2 + 3\n\n 5.step(max, 2).each do|current_number|\n val_is_prime = true\n primes.each do|prime|\n if prime > Math.sqrt(current_number).to_i\n break\n elsif current_number % prime == 0 then\n val_is_prime = false\n break\n end\n end\n if val_is_prime && current_number < max then\n primes_index = primes_index + 1\n primes[primes_index] = current_number\n sum = sum + current_number\n end\n end\n return sum\nend", "def sum_of_all_primes(limit)\n list_of_all_numbers = (2..limit).to_a #create a list of numbers from 2 to limit\n primes = get_primes(list_of_all_numbers)\n\n puts \"Primes #{primes}\"\n puts \"Sum of all primes #{primes.sum}\"\nend", "def sum_primes_below(target)\n prime_sum = 0\n (2..target).each do |i|\n if is_prime?(i)\n prime_sum += i\n end\n end\n\n prime_sum\nend", "def primes_upto( xmax )\n # primes have no factors except for 1 and self\n primes = [ 2 ]\n ( 3..xmax ).each do |i|\n puts i if 0 == ( i % 1000 )\n is_prime = true\n primes.each do |p|\n break if p > ( i / 2 )\n if 0 == ( i % p )\n is_prime = false\n break\n end\n end # p\n primes << i if is_prime\n end # i\n return primes\nend", "def sum_of_primes(limit)\n answer = 0\n\n Prime.each(limit) do |i|\n answer += i\n end\n puts answer\nend", "def sum_primes(upper_bound)\r\n Prime.each(upper_bound).inject(:+)\r\nend", "def euler010\n target = 2e6\n sum = 0\n\n each_prime do |p,i|\n break if p >= target\n sum += p\n end\n\n sum\nend", "def prime_numbers(limit = 1_000_000)\n all_numbers = Hash[(2..limit).map { |v| [v, 0] }]\n\n border = Math.sqrt(limit).to_i\n\n next_prime = 1\n while next_prime < border\n next_prime = all_numbers.find { |_, v| v.zero? }[0]\n\n all_numbers[next_prime] = -1\n\n all_numbers.each do |key, value|\n all_numbers.delete key if value.zero? && (key % next_prime).zero?\n end\n end\n all_numbers.keys\nend", "def getPrimes()\n oldlimit = $primelimit + 1\n $primelimit *= 2\n\n for i in oldlimit...$primelimit\n isPrime = true\n $primes.each do |p|\n if i % p == 0\n isPrime = false\n break\n end\n end\n if isPrime\n $primes << i\n end\n end\n\nend", "def consecutive_prime_sum\n sum = 0\n cumulative_sum = Prime.take_while { |n| n < 50000 } .map { |n| sum += n }\n \n max = 953\n max_terms = i = 21\n while i < cumulative_sum.length\n j = i - max_terms - 1\n diff = 0\n while j >= 0 && diff < 1_000_000\n diff = cumulative_sum[i] - cumulative_sum[j]\n if Prime.prime?(diff)\n max = diff\n max_terms = i - j\n end\n j-=1\n end\n i+=1\n end\n max\nend", "def sum_of_primes(n)\n Prime.first(n).inject(0, :+)\nend", "def p7\n\tprimes = [2]\n\t(1...10001).each do\n\t\tprime = next_prime(primes[-1])\n\t\tprimes << prime\n\tend\n\tprimes[-1]\nend", "def solution_1\n starting_time = Time.now\n\n total = 0\n\n all_primes(MAX_NUM).each { |prime| total += prime }\n\n p \"Sum of first #{MAX_NUM} primes: #{total}\"\n p \"In #{Time.now - starting_time} seconds\"\nend", "def problem_77a\n primes = Primes.upto(100)\n\n # off is the offset in the prime array, we can work down :-)\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1 if (a & primes).length == a.uniq.length\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n m = 0\n (2..100).each do |num|\n break if (m = solve.call([1] * num,0,num-1)) > 5000\n puts \"#{num} => #{m}\"\n end\n m\nend", "def sum_of_primes(n)\n prime_array = []\n (2..n).each do |i|\n next unless prime_number?(i)\n prime_array << i\n end\n prime_array.inject(:+)\nend", "def compute_primes\n nums = (@max_checked..@max_checked * 2).map { |x| x.odd? ? x : nil }.to_a\n 1.upto(@primes.index { |p| p * p > @max_checked * 2 }) do |i|\n start_idx = -@max_checked % @primes[i] # prime[i]'s 1st multiple's index\n\n (start_idx..nums.size).step(@primes[i]) { |x| nums[x] = nil }\n end\n @max_checked *= 2\n @primes += nums.compact\n end", "def primes_upto(limit)\n numbers = (2..limit).to_a\n numbers.each do |prime|\n if prime\n nonprime = prime + prime\n while nonprime <= limit\n numbers[nonprime - 2] = nil\n nonprime += prime\n end\n end\n end\n numbers.compact\nend", "def sum_of_all_primes(n)\n sum = 0\n (1..n).each do |x|\n if prime? x\n sum += x\n end \n end \n sum\n end", "def total_consecutive_primes(number)\n\treturn -1 if !is_prime(number)\n\tleft = 0\n\tright = 0\n\tsum = $primes[0]\n\twhile true\n\t\tbreak if right == $primes.size - 1 and sum < number\n\t\tif sum < number\n\t\t\tright+=1\n\t\t\tsum += $primes[right]\n\t\tend\n\t\tif sum > number\n\t\t\tsum -= $primes[left]\n\t\t\tleft += 1\n\t\tend\n\t\tbreak if right == $primes.size and sum < number\n\t\tbreak if sum == number\n\tend\n\treturn right - left + 1 if sum == number\n\treturn -1\nend", "def solution_3(num)\n starting_time = Time.now\n\n # actual sieve of eratosthenes\n potential_primes = (2..num).to_a\n potential_primes.each_with_index do |val, index|\n if val\n index += val\n while index < num\n potential_primes[index] = nil\n index += val\n end\n else\n next\n end\n end\n\n primes = potential_primes.compact\n\n p \"Sum of first #{num} primes: #{primes.reduce(:+)}\"\n\n p \"In #{Time.now - starting_time} seconds\"\nend", "def summation_of_primes(n)\n sum, flags = 2, []\n\n 0.upto(n / 2) { flags.push(false, true) }\n\n i = 3\n until i * i > n\n (i * i).step(n, i) { |k| flags[k] = false } if flags[i] == true\n i += 1\n end\n\n 3.upto(n) { |j| sum += j if flags[j] == true }\n\n sum\nend", "def problem_ten\n Prime.instance.each(2_000_000).reduce(&:+)\n end", "def eratosthenes_sieve(max_number)\n numbers = (0..max_number+1).to_a\n bound = Math.sqrt(max_number).to_i\n\n (2..bound+1).each do |current|\n if numbers[current]\n (current+current..max_number+1).step(current).each do |j| numbers[j] = nil end\n end\n end\n\n return numbers.compact![2..-1]\nend", "def prime_numbers\n # start with the first prime number\n primes = [2]\n # find the rest of the prime numbers\n (2..1000).each do |i|\n add_next_prime_number(primes)\n end\n return primes\nend", "def prime2(nprime)\n\n primes = [2]\n factors = {}\n\n num = 3\n while primes.size < nprime do\n\n root = Math.sqrt(num).floor\n isprime = true\n\n primes.each{ |prime|\n break if prime > root\n if num % prime == 0\n isprime = false\n break\n end\n }\n\n primes << num if isprime\n num += 1\n\n printf(\"\\r%d\", primes.size) if primes.size % 1000.0 == 0\n\n end\n\n return primes\n\nend", "def primes_under(n)\n candidates = (3..n).step(2).to_a\n primes = [2]\n\n until primes.last > n ** 0.5\n primes << candidates.shift\n candidates.reject! {|candidate| candidate % primes[-1] == 0}\n end\n\n primes + candidates\nend", "def sum_prime(num)\n sum_prime = 0\n prime_list = sieves_primes(num)\n prime_list.each do |p|\n sum_prime += p\n end\n puts \"The sum of prime numbers below #{num} is #{sum_prime}\"\nend", "def sum_n_primes(n)\n return 0 if n == 0\n sum = 0\n primes = []\n i = 2\n until primes.length == n\n #\n if prime?(i)\n sum += i\n primes << i #corrected primes counting. was adding i each time before\n end\n i += 1\n end\n sum\nend", "def get_primes limit\n\tnums = (1...limit).select { |n| n.prime? }\n\n\tp nums\nend", "def find_more_primes\n candidates_max = @known_primes.last * 2\n candidates = ((@max_checked + 1)..candidates_max).step(2).to_a\n sieving_primes = primes_to_sieve(candidates_max)\n\n offsets = Array.new(sieving_primes.size) do |i|\n (-(candidates.first + sieving_primes[i]) / 2) % sieving_primes[i]\n end\n\n sieving_primes.zip(offsets).each do |prime, offset|\n while offset < candidates.size do\n candidates[offset] = nil\n offset += prime\n end\n end\n\n @known_primes += candidates.compact\n @max_checked = candidates_max\n end", "def find_primes(input)\n\t\n\tprimes = Array.new\n\t\n\tlimit = Math.sqrt(input)\n\t\n\tnumber_to_test = 2\n\t\n\tif number_to_test > limit\n\t\treturn Array[input]\n\tend\n\t\n\twhile input % number_to_test != 0 && number_to_test < limit\n\t\tnumber_to_test += 1\n\tend\n\t\n\tif input % number_to_test == 0\n\t\treturn find_primes(number_to_test) + find_primes(input/number_to_test)\n\tend\n\n\treturn Array[input]\n\t\t\nend", "def find_primes(input)\n\t\n\tprimes = Array.new\n\t\n\tlimit = Math.sqrt(input)\n\t\n\tnumber_to_test = 2\n\t\n\tif number_to_test > limit\n\t\treturn Array[input]\n\tend\n\t\n\twhile input % number_to_test != 0 && number_to_test < limit\n\t\tnumber_to_test += 1\n\tend\n\t\n\tif input % number_to_test == 0\n\t\treturn find_primes(number_to_test) + find_primes(input/number_to_test)\n\tend\n\n\treturn Array[input]\n\t\t\nend", "def calculate(number)\n sieve_limit = upper_limit_for(number)\n primes = sieve_upto sieve_limit\n primes[0..number-1]\n end", "def eratosthenes_sieve(nth_prime)\n top = nth_prime * 10\n # this is really kludgy, you might have to increase 10 if you want\n # nth primes above 10k. It seems to work fine for all numbers under\n # 10k. I need to read up on prime number theory to find out when this fails.\n sieve = []\n (2..top).each { |i| sieve[i] = i }\n for i in 2 .. Math.sqrt(top)\n next unless sieve[i]\n (i*i).step(top, i) do |j|\n sieve[j] = nil\n end\n end\n sieve.compact[nth_prime]\nend", "def getMaxPrime(numb)\n def isPrime(n)\n return false if n <= 1\n 2.upto(Math.sqrt(n).to_i) do |x|\n return false if n%x == 0\n end\n true\n end\n\n primes = []\n (2..10000).each { |x| primes << x if isPrime(x) }\n \n max = 0\n primes.each do |i|\n if numb % i == 0\n max = i\n end\n end\n puts max\nend", "def upper_limit_for(desired_prime_number)\n i = 2\n while (i / Math.log(i)) < desired_prime_number do\n i = i + 1\n end\n return i\n end", "def count_primes_fast(n)\n is_prime = [false, false]\n (2...n).each do |x|\n is_prime[x] = true;\n end\n\n tail = Math.sqrt(n).ceil\n for i in 2..tail\n next if !is_prime[i]\n (i*i...n).step(i) do |j|\n is_prime[j] = false\n end\n end\n\n count = 0\n for k in 0...n\n count += 1 if is_prime[k]\n end\n count\nend", "def sum_prime(n)\n\ti = 0\n\tp = 1\n\tsum = 0\n#\tprimes = []\n\n\tuntil p == n\n\t\tp += 1\n\t\tif is_prime?(p)\n#\t\t\tprimes << p\n\t\t\tsum += p\n\t\t\ti += 1\n\t\tend\n\tend\n\n\treturn sum\n\t#return primes.reduce(:+)\nend", "def sum_n_primes(n)\n primes = []\n i = 2\n while primes.size < n\n primes << i if prime?(i)\n i += 1\n end\n primes.sum\nend", "def count_primes(n)\n primes = (0..n).to_a\n primes[0] = nil\n primes[1] = nil\n\n primes.each do |current_num|\n next if current_num == nil\n break if current_num > Math.sqrt(n)\n (current_num**2).step(n, current_num) { |interval| primes[interval] = nil }\n end\n\n primes.compact.take_while { |num| num < n }.size\nend", "def aboveOneMillionCount(num)\n idx = (1..num/2).to_a.index &->(r){combinator(num,r) > 10**6}\n return 0 unless idx\n lower = (idx + 1)\n upper = num - lower # has same combinator with lower\n upper - lower + 1 # \nend", "def find_primes(int1, int2)\n nums = (int1..int2).to_a\n nums.select { |num| is_prime?(num) }\nend", "def summation(max)\n\tsum = 0\n\tcounter = 2\n\twhile counter < max\n\t\tp \"counter is #{counter}\"\n\t\tif isprime?(counter)\n\t\t\tsum += counter\n\t\tend\n\t\tcounter += 1\n\tend\n\treturn sum\nend", "def sup_limit(max)\n (1..Float::INFINITY).lazy.map{|i| [i,Prime.take(i).reduce(:+)]}.detect{|i,sum| sum >= max}.first\nend", "def sieve(limit)\n bound = Math.sqrt(limit).ceil\n sieve = (0..limit+1).collect{ true }\n p = 2\n while !p.nil? && p <= bound\n q = p*p\n while q <= limit\n sieve[q] = false\n q = q + p\n end\n p =(p+1 .. limit).find{ |n| sieve[n] }\n end\n (2..limit).select{ |n| sieve[n]}\nend", "def problem_77\n primes = Primes.upto(120)\n\n # num is the value we want and\n # off is the index in primes to use next\n hits = 0\n solve = lambda do |num, off|\n return 1 if num == 0\n return 0 if num == 1\n ret = 0\n p = primes[off]\n ret += 1 if num % p == 0 # Add if a multiple\n ret += solve.call(num,off-1) if off > 0 \n n = num / p\n if n > 0 # Do each multiple\n 1.upto(n) do |i|\n left = num - i*p\n ret += solve.call(left,off-1) if off > 0 && left > 1\n end\n end\n ret\n end\n\n #(2..100).each do |num|\n num = 0\n (2..100).each do |num|\n off = primes.index {|i| i > num } - 1\n hits = solve.call(num,off)\n puts \"#{num} => #{hits}\"\n return num if hits >= 5000\n end\nend", "def sum_multiples(n1,n2,limit)\n sum = 0\n for i in 1...limit\n sum+= i if(i%n1 == 0 or i%n2 == 0)\n end \n sum\nend", "def primes_from_2( x )\n # primes have no factors except for 1 and self\n primes = [ 2 ]\n i = 2\n while primes.size < x\n i += 1\n is_prime = true\n primes.each do |p|\n #( 2..( i ** 0.5 ).floor ).each do |p|\n #break if p > ( i / 2 )\n break if p > ( i ** 0.5 )\n if 0 == ( i % p )\n is_prime = false\n break\n end\n end # p\n primes << i if is_prime\n i += 1 # skip the next integer (it's even)\n end # while\n return primes[ -1 ]\nend", "def approx_primes_in_range( n )\n\n end", "def find_primes\n canidates = (0..@max_num).to_a\n k=2\n while(k<= canidates.size/2)\n j=2\n while(j<= canidates.size/2)\n prod = k*j\n if prod <= @max_num\n canidates[prod] = nil\n end\n j+=1\n end\n k+=1\n end\n res = canidates.compact\n res.shift(2)\n res\n end", "def primes_up_to(n)\n raise \"Need an integer >= 2 to find primes\" unless n.is_a?(Integer) && n >= 2\n primes = (0..n).to_a\n primes[0..1] = [nil, nil]\n p = 2\n while true do\n (p .. n/p).each do |i|\n primes[i*p] = nil\n end\n break unless p = primes.index { |x| !x.nil? && x > p }\n end\n primes.compact!\n end", "def primes1000\n\treturn [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,\n\t31, 37, 41, 43, 47, 53, 59, 61, 67, 71,\n\t73, 79, 83, 89, 97, 101, 103, 107, 109, 113,\n\t127, 131, 137, 139, 149, 151, 157, 163, 167, 173,\n\t179, 181, 191, 193, 197, 199, 211, 223, 227, 229,\n\t233, 239, 241, 251, 257, 263, 269, 271, 277, 281,\n\t283, 293, 307, 311, 313, 317, 331, 337, 347, 349,\n\t353, 359, 367, 373, 379, 383, 389, 397, 401, 409,\n\t419, 421, 431, 433, 439, 443, 449, 457, 461, 463,\n\t467, 479, 487, 491, 499, 503, 509, 521, 523, 541,\n\t547, 557, 563, 569, 571, 577, 587, 593, 599, 601,\n\t607, 613, 617, 619, 631, 641, 643, 647, 653, 659,\n\t661, 673, 677, 683, 691, 701, 709, 719, 727, 733,\n\t739, 743, 751, 757, 761, 769, 773, 787, 797, 809,\n\t811, 821, 823, 827, 829, 839, 853, 857, 859, 863,\n\t877, 881, 883, 887, 907, 911, 919, 929, 937, 941,\n\t947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013,\n\t1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069,\n\t1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151,\n\t1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223,\n\t1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291,\n\t1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373,\n\t1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451,\n\t1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511,\n\t1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583,\n\t1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657,\n\t1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733,\n\t1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,\n\t1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889,\n\t1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987,\n\t1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053,\n\t2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129,\n\t2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213,\n\t2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287,\n\t2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357,\n\t2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423,\n\t2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531,\n\t2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617,\n\t2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687,\n\t2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741,\n\t2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819,\n\t2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903,\n\t2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999,\n\t3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079,\n\t3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181,\n\t3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257,\n\t3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331,\n\t3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413,\n\t3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511,\n\t3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571,\n\t3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643,\n\t3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727,\n\t3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821,\n\t3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907,\n\t3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989,\n\t4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057,\n\t4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139,\n\t4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231,\n\t4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297,\n\t4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409,\n\t4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493,\n\t4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583,\n\t4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657,\n\t4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751,\n\t4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831,\n\t4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937,\n\t4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003,\n\t5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087,\n\t5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179,\n\t5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279,\n\t5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387,\n\t5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443,\n\t5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521,\n\t5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639,\n\t5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693,\n\t5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791,\n\t5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857,\n\t5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939,\n\t5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053,\n\t6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133,\n\t6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221,\n\t6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301,\n\t6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367,\n\t6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473,\n\t6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571,\n\t6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673,\n\t6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761,\n\t6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833,\n\t6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917,\n\t6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997,\n\t7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103,\n\t7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207,\n\t7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297,\n\t7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411,\n\t7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499,\n\t7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561,\n\t7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643,\n\t7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723,\n\t7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829,\n\t7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]\nend", "def primes_up_to(limit)\n root_limit = Math.sqrt(limit)\n values = (2..limit).to_a\n j = 0\n candidate = values[j]\n while candidate < root_limit\n values.delete_if { |i| (i % candidate == 0 and i != candidate) }\n j+=1\n puts \"#{j}: #{values.length} values remain\"\n candidate = values[j]\n end\n values\nend", "def find_prime\n x = 2\n while @prime_numbers.count < @total\n @prime_numbers << x if prime?(x)\n x += 1\n end\n end", "def brute_force_primes(limit)\n \n primes = []\n complexity = 0\n # we know that 0,1 can't be prime\n # start at 2 and create a Range upto the limit\n (2..limit).each{|number|\n complexity += 1\n is_prime = true\n \n # any number is divisible by 1\n # so start at 2\n (2..number).each{|n|\n complexity += 1\n # ensure the number being tested is not the number in the loop\n unless number == n\n # continue unless the local loop value of n is a factor of number\n unless number % n != 0\n is_prime = false\n break\n end\n end\n }\n \n primes << number if is_prime\n }\n puts \"O(n**2): #{(limit**2).to_s}\"\n puts \"Complexity: #{complexity.to_s}\"\n return primes\n \nend", "def ruby_prime(n1, n2)\n prime_numbers = []\n (n1..n2).each do |num|\n if Prime.prime?(num)\n prime_numbers << num\n end\n end\n prime_numbers\nend", "def get_primes(limit)\n primes = []\n (2...limit).each do |number|\n primes << number if is_prime?(number)\n end\n primes\nend", "def find_primes(limit)\n num_array = (2...limit).to_a\n num_array.each_with_index do |val, index|\n if val\n index += val\n while index < limit-2\n num_array[index] = nil\n index += val\n end\n else\n next\n end\n end\n num_array.compact\nend", "def count_primes(n)\n mark = [false] * (n + 1)\n counter = 0\n for i in 2...n\n next if mark[i] == true\n counter += 1\n (i * i).step n, i do |j| mark[j] = true end\n end\n counter\nend", "def summation_of_primes(num)\n\n\tsum = 2 # sum of all the primes\n\tctr = 3 # current number counter, increase by 1 for each loop through the while clause\n\n\twhile ctr < num\n\t\tis_prime = true\n\t\tfor i in 2..(ctr-1)\n\t\t\t# puts \"CTR: #{ctr}\"\n\t\t\t# puts \"I: #{i}\"\n\t\t\tis_prime = false if ctr % i == 0\n\t\tend\n\t\tif is_prime\n\t\t\tsum += ctr\n\t\t\t# puts \"The current sum is #{sum}\"\n\t\tend\n\t\tctr += 1\n\tend\t\n\n\t\"The sum is #{sum}\"\n\nend", "def largest_prime_sum(limit)\n prime = get_primes(limit)\n sum_prime = sum_primes(prime)\n max_length = -1\n largest_prime_number = -1\n \n (0...prime.length).each do |i|\n (0...i).each do |j|\n break if (sum_prime[i] - sum_prime[j] > limit) \n consective_sum = sum_prime[i] - sum_prime[j]\n if ((max_length < i-j+1) and is_prime?(consective_sum))\n max_length = i-j+1\n largest_prime_number = consective_sum\n end\n \n end\n end\n largest_prime_number\nend", "def primes\n\t\t# primes = []\n\t\t# primes << 2\n\t\tprimes = [2] # combined previous two lines\n\t\tx = 3\n\n\t\tloop do\n\t\t\tbreak if primes.length == @n_primes # End loop when desired number has been calculated\n\t\t# while primes.length < @n_primes # Alternative 1 to loop do, break\n\t\t# until primes.length == @n_primes # Alternative 2 to loop do, break\n\t\t\ty = 3\n\t\t\ty += 2 until x % y == 0 # Loop to test if x is divisible by any odd number below it, y\n\t\t\tprimes << x if x == y # If the (odd) number was not divisible by any (odd) below itself, it is a prime\n\t\t\tx += 2\n\t\tend\n\n\t\treturn primes\n\tend", "def count_primes(number)\n # create an array from 2-num\n # for each number in the array of possible primes\n # modulo the number by each n\n # if the number % n is 0, it's not a prime number\n # unless the number and n are the same\n possible_primes = (2...number).to_a\n possible_primes.select! do |num|\n # need to return true if num is prime, false if it is not\n # binding.pry if num == 3\n half_num = num\n results = (2...half_num).select do |n|\n # if num % n == 0, means that n evenly divides into num making it not prime\n num % n == 0\n end\n results.empty?\n # any number within results evenly divided into the num\n # making the num not prime\n # so if results is empty, it means that nothing divided into the num\n # making the num prime\n end\n possible_primes.count\nend", "def even_fib_sum\n a = 1\n b = 2\n c = a + b\n sum = 2\n while c < 4000000\n a = b\n b = c\n c = a + b\n sum += c if (c % 2 == 0) && (c < 4000000)\n end\n sum\nend", "def primes_up_to(max)\n repository = (0..max).collect{true} #=> Create flag array\n limit = (max ** 0.5) #=> establish search limit\n\n for index in 2..limit #=> search through flag aray\n next if !repository[index]\n num = (index * 2)\n while num <= max #=> unflag multiples of primes\n repository[num] = false\n num += index\n end\n end\n\n # => convert numbers into arrays\n primes = repository.collect.with_index do |flag, value|\n value if flag\n end\n\n # return cleaned array\n primes.shift\n primes.shift\n primes.compact\nend", "def problem_two\n fibs(4_000_000).select { |n| n.even? }.reduce(&:+)\n end", "def GetPrimes (maximum)\t\n\t# Construct and execute the Sieve\n\tsqrtMaximum = Math.sqrt(maximum).to_i\n\tprimeTracker = Array.new(maximum,true)\n\t\n\tfor i in 2...sqrtMaximum\n\t\tnext if !primeTracker[i]\n\t\t\n\t\tstart = i + i\n\t\t\n\t\tfor j in (start...maximum).step(i)\n\t\t\tprimeTracker[j] = false;\n\t\tend\n\tend\n\t\n\tprimes = []\n\t\n\t# Generate the list of primes to return\n\tfor k in 2...maximum\n\t\tprimes.push(k) if primeTracker[k]\n\tend\n\t\n\treturn primes\nend", "def primes(n) \n max = Math::sqrt(n).truncate\n (2..max).each {|val|\n if n % val == 0 then\n p val\n primes(n/val)\n return\n elsif val == max then\n p n\n return\n end\n }\nend", "def nth_prime(n)\n nums = (0..10000).to_a\n result = []\n\n nums.each do |i| \n if prime?(i) == true\n result.push(i)\n end\n end\n\n\n return result[n]\nend", "def problem_60\n prime_check = lambda do |a,b|\n (a + b).to_i.prime? && (b + a).to_i.prime?\n end\n\n find_match = lambda do |a,k|\n r = a.select {|p| k != p && prime_check.call(k,p) }\n end\n\n primes = Primes.upto(10_000).map(&:to_s)\n primes.delete(\"2\")\n\n hit = {}\n\n primes.each do |p1|\n p1a = find_match.call(primes,p1)\n p1a.each do |p2|\n p2a = find_match.call(p1a,p2)\n p2a.each do |p3|\n p3a = find_match.call(p2a,p2)\n p3a.each do |p3|\n p4a = find_match.call(p3a,p3)\n p4a.each do |p4|\n p5a = find_match.call(p4a,p4)\n if p5a.length > 0\n p5a.each do |p5|\n a = [p1,p2,p3,p4,p5]\n sum = a.map(&:to_i).reduce(&:+)\n unless hit[sum]\n puts \"#{sum} #{a.inspect}\"\n else\n hit[sum] = true\n end\n return sum\n end\n end\n end\n end\n end\n end\n end\nend", "def even_fib_sum(limit)\n fib0, fib1, sum = 1, 2, 0\n while fib1 <= limit\n sum += fib1 if fib1 % 2 == 0\n fib0, fib1 = fib1, fib0 + fib1\n end\n sum\nend", "def sum_of_even_fibonaccis(limit)\n\n holder = [1,2]\n\n while ( holder[-1] + holder[-2] ) < limit\n holder << holder[-1] + holder[-2]\n end\n\n return holder.select { |n| n.even? }.reduce(:+)\n\nend", "def sieve(nth_prime)\n primes = [2]\n num = 2\n while primes.length <= nth_prime do\n primes << num if !primes.any? {|prime| num % prime == 0}\n num +=1\n end\n return primes[primes.length-2] # -2 because we don't put 1 (because every number is divisble by 1) and index is from 0 to x thus -2\nend", "def primes(top)\n n = 2\n primes = []\n loop do\n primes << n if (2..Math.sqrt(n)).all? {|x| n % x != 0 }\n return primes.last if primes.count == top\n n += 1\n end\nend", "def t_primes()\n t_primes = []\n 10.step do |i| # Skip all one-digit numbers.\n next unless i.prime?\n digits = i.to_s.chars\n cp_digits = digits.dup # Copy the digits as we will operate on\n # this array twice.\n lftrt = rtlft = digits.length\n # A number is a left-truncatable prime if all its leading digits\n # (that is, the digit in the most significant place), when succ-\n # essively removed, all resulting numbers are prime.\n lftrt.times do\n cp_digits.shift\n break unless cp_digits.join.to_i.prime?\n end\n # If cp_digits still has elements in it, that means those elements\n # weren't prime themselves.\n next unless cp_digits.length.zero?\n cp_digits = digits.dup\n rtlft.times do\n cp_digits.pop\n break unless cp_digits.join.to_i.prime?\n end\n next unless cp_digits.length.zero?\n t_primes << i # Found a two-sided truncatable prime!\n break if t_primes.size == 11\n end\n return t_primes\nend", "def euler002\n sum = 0\n fib = [1, 1]\n while fib[1] < 4e6\n sum += fib[1] if fib[1].even?\n fib = [fib[1], fib[0] + fib[1]]\n end\n sum\nend", "def problem_60a\n num_cut = 5\n# simple\n pairs = {}\n seen_primes = []\n num_primes = 0\n last = start = Time.now\n Primes.each do |p|\n next if p == 2\n b = p.to_s\n seen_primes.each_index do |sp_i|\n sp = seen_primes[sp_i]\n a = sp.to_s\n ai,bi = a.to_i,b.to_i\n ab = (a + b).to_i\n ba = (b + a).to_i\n\n if ba.prime? && ab.prime?\n # We have a pair that works both ways so add the peer to each prime\n pairs[ai] = aa = ((pairs[ai] || []) << bi).uniq\n pairs[bi] = bb = ((pairs[bi] || []) << ai).uniq\n next unless pairs[bi].length >= num_cut - 1 # bi is biggest of pair\n\n check = ([ai] + aa) & ([bi] + bb)\n if check.length >= num_cut\n puts \"Try #{check.inspect}\"\n perm = check.permutation(2).to_a\n new = perm.select do |x,y|\n (x.to_s + y.to_s).to_i.prime? && (x.to_s + y.to_s).to_i.prime?\n end\n if new.length == perm.length\n n = new.flatten.uniq\n sum = n.reduce(&:+)\n puts \"#{n.inspect} *** #{sum}\"\n return sum\n end\n end\n end\n end\n seen_primes << p\n end\n nil\nend", "def sieve_eratosthenes(biggest_num)\n primes = (0..biggest_num).to_a\n primes[0] = primes[1] = nil\n\n counter = 0\n primes.each do |p|\n next unless p\n\n break if p*p > biggest_num\n counter += 1\n\n (p*p).step(biggest_num,p) { |m| primes[m] = nil }\n end\n primes.compact\nend", "def fib(first_num, second_num, limit)\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend", "def fib(first_num, second_num, limit)\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend", "def pe50v2()\n\ta = sieveOfErathosthenes(3990)\n\tprim,total,count = [], 0, 0\n\ta.each_with_index do |x, index|\n\t\tif x \n\t\t\ttotal += index\n\t\t\tcount += 1 \n\t\t\tprim.push([total,count])\n\t\tend\n\tend\n\t#p prim\n\tmax = 0\n\tthePrime = 0\n\tseq = prim.map {|k| k }.permutation(2).to_a.each {|x| x.flatten!}\n\tseq.each do |a, b, c , d| \n\t\t#printf \"%d %d %d %d\\n\", a, b, c, d\n\t\te = a - c\n\t\tif(Prime.prime?(e)) then\n\t\t\tif(max < b - d) then\n\t\t\t\tmax = b - d\n\t\t\t\tthePrime = e\n\t\t\t\tprintf \"prime %d with max %d\\n\",e,max\n\t\t\tend\n\t\tend\n\tend\n\tprintf \"the prime is %d with a seqence of %d\\n\",thePrime, max\nend", "def longest_consecutive_prime_under(max)\n primes = (1..max).select {|n| n.prime?}\n\n length = 1\n candidate = 2\n while length < (primes.length / 2)\n index = 0\n sum = primes[index..length].inject(:+)\n until primes.include?(sum) or sum > max or index + length > primes.length / 2\n index += 1\n sum = primes[index..(index + length)].inject(:+)\n end\n if primes.include?(sum) and sum < max\n # p primes[index..(index + length)]\n candidate = sum \n end\n length += 1\n end\n candidate\nend", "def generate_primes(upper_limit)\n primes = Array.new\n \n # Tally is a list of factors or prime numbers found.\n # We must use a running ceiling value called max_factor to calculate factors\n # to. max_tally_for_prime stores the maximum factor tallied for each prime\n # that was found.\n tally = Set.new \n max_tally_for_prime = Hash.new\n max_factor = 100\n \n i = 2\n while primes.length < upper_limit do\n if tally.include?(i) == false\n primes.push i\n \n # Fill tally with multiples of the prime found\n j = i\n while j <= max_factor do\n tally.add j\n max_tally_for_prime[i] = j\n j += i\n end \n end\n i += 1\n \n # When we reach half way to the max factor the ceiling is doubled and the\n # tally is extended\n if i > max_factor/2\n max_factor = max_factor*2\n primes.each do |prime|\n j = max_tally_for_prime[prime]\n while j <= max_factor\n j += prime\n tally.add j\n end\n max_tally_for_prime[prime] = j\n end\n end\n end\n return primes\nend" ]
[ "0.821614", "0.78911686", "0.755588", "0.7523196", "0.7480213", "0.7476215", "0.74590516", "0.74414307", "0.7431382", "0.7333121", "0.732661", "0.73118657", "0.72957844", "0.72825474", "0.7205344", "0.71875244", "0.7183439", "0.71288306", "0.71193737", "0.7119278", "0.7085497", "0.70708907", "0.7066708", "0.70605385", "0.6955541", "0.69286394", "0.6926549", "0.6889363", "0.6825903", "0.6791401", "0.6782419", "0.67675036", "0.67605144", "0.6750892", "0.6741142", "0.6730845", "0.67147934", "0.67026514", "0.66989964", "0.66949826", "0.669046", "0.66747075", "0.6664893", "0.66644627", "0.6646639", "0.66433805", "0.66158426", "0.66079324", "0.6602706", "0.6602706", "0.6595121", "0.6592797", "0.6590551", "0.65815705", "0.657103", "0.6554685", "0.6549358", "0.65353847", "0.65195185", "0.6518405", "0.65097046", "0.65036947", "0.6499894", "0.6492762", "0.6461999", "0.6460981", "0.6447942", "0.6446587", "0.6439657", "0.64386225", "0.6435821", "0.643149", "0.6427153", "0.6421963", "0.6421382", "0.64165604", "0.64025706", "0.6395493", "0.6390034", "0.63863385", "0.6372717", "0.6363809", "0.635563", "0.6347043", "0.6343006", "0.6335665", "0.63186044", "0.6307722", "0.63023984", "0.629877", "0.62858087", "0.628533", "0.6277869", "0.62656575", "0.62618977", "0.6261275", "0.6260746", "0.6260746", "0.6238176", "0.623276", "0.6231771" ]
0.0
-1
Push a value onto the stack
def push(value) @data = LinkedListNode.new(value, @data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(value)\n return \"Stack is full\" if is_full\n\n @stack.push(value)\n @current_size += 1\n end", "def add(value)\n @stack.push(value)\n end", "def push(x)\n @stack << x \n end", "def push(x)\n @stack << x\n end", "def push(x)\n @stack.push(x)\n end", "def push(value); end", "def push(x)\n stack.push(x)\n end", "def push(x)\n @stack << x\n end", "def push(x)\n @stack1 << x\n end", "def push(num)\n stack << num\n end", "def push(num)\n @stack << num\n\n return num\n end", "def push(x)\n @stack.push(x)\n end", "def push(x)\n @stack.push(x)\n end", "def push(val)\n if @stacks.empty?\n @stacks[0] = [val]\n if @capacity > 1\n @left[0] = 0\n else\n @right[0] = 0\n end\n else\n @left << @stacks.size if @left.empty?\n index = @left[0]\n @stacks[index] ||= []\n @stacks[index] << val\n if @stacks[index].size == @capacity\n @left.shift\n i = @right.bsearch_index { |j| j >= index } || @right.size\n @right.insert(i, index)\n end\n end\n end", "def push(x)\n @stack1.push(x)\n end", "def push(operation, value)\n @stack.push [operation, value]\n end", "def push val, name:, type: :unknown\n loc = @temp_stack.push name, type: type\n\n val = cast_to_fisk val\n\n if val.memory? || val.immediate?\n write loc, val\n else\n write loc, val.to_register\n end\n end", "def push(value)\n @sp -= 1\n @emulator.memory.set(@sp, value)\n end", "def push(value)\n @handle.puts \" $PUSH #{value & 0x7f}\"\n end", "def push(value)\r\n stacked = LinkedListNode.new(value, data)\r\n @data = stacked\r\n end", "def push(val)\n \n end", "def push(*a) # utility\n @stack.push(*a); self\n end", "def push(x)\n @stack.unshift(x)\n end", "def push_value(definition)\n value_stack.push(definition) if definition && !value_stack.empty?\n end", "def push(value)\n push_at(size, value)\n end", "def op_push(arg)\n push arg\n end", "def push (value)\n @top = Node.new(value, @top)\n end", "def push(o)\n @stack.push o\n @pc += 1\n end", "def push(value)\n return \"Stack is full\" if is_full\n\n new_node = Node.new(value)\n\n if is_empty\n @head = new_node\n else\n new_node.next = @head\n @head = new_node\n end\n\n @current_size += 1\n end", "def push(value)\n @parent, @top = @top, value\n end", "def push(value)\n @data = LLNode.new(value, @data)\n end", "def push(el)\n self.stack_var << el \n end", "def push (num)\n prePushListener\n @stackList.append num\n postPushListener\n end", "def push(x)\n \n end", "def push(x)\n \n end", "def push(value)\n # IMPLEMENT ME!\n @data = Node.new(value, @data)\n end", "def push value\n self.set( self.get_length + 1 , value)\n end", "def push(value)\n insert(value)\n self\n end", "def push(value)\n # IMPLEMENT ME!\n @top = LinkedListNode.new(value, @top)\n end", "def push(value)\r\n @data << value\r\n end", "def push(x)\n end", "def pushm(datum)\r\n @data_stack += datum\r\n end", "def push(item)\n @mini_stack.push(item)\n @maxx_stack.push(item)\n @stak.push(item)\n end", "def push(value)\n case value[0]\n when :CONTENT, :STRING_LITERAL\n value[1].gsub!(/\\n\\s*/, ' ') if strip_line_breaks?\n\n if !@stack.empty? && value[0] == @stack[-1][0]\n @stack[-1][1] << value[1]\n else\n @stack.push(value)\n end\n when :ERROR\n @stack.push(value) if @include_errors\n leave_object\n when :META_CONTENT\n @stack.push(value) if @include_meta_content\n else\n @stack.push(value)\n end\n\n self\n end", "def push(ele)\n \n if(@stk.size == nil)\n\t p \"Stack full\"\n\telse\n @count = @count + 1\n\t @stk[@count] = ele\t \n\tend\n end", "def push(datum)\r\n @data_stack << datum\r\n end", "def push(x)\n p = @stack.unshift(x)\n @q.insert(p)\n self\n end", "def push(value, *args)\n @adapter.push(value, args)\n end", "def push(value)\r\n @top_node = LinkedListNode.new(value, @top_node)\r\n end", "def push(element)\n #if the stack is already full or the element is nil, do nothing\n if full? or element.nil?\n nil\n else\n #Add 1 to the value of @top\n @top = @top.succ\n #sets the value at the top of the stack to element\n @store[@top] = element\n #returns it self\n self\n end\n end", "def push(value)\n node = Node.new(value)\n node.previous = top\n self.top = node\n\n return node\n end", "def push_stack\n bb = {:black => get_black,:white => get_white}\n @stack.push(Marshal.load(Marshal.dump(bb)))\n @stack.shift if @stack.size > @options[:stack_limit]\n end", "def push(item)\n @stack.unshift(item)\n self.top = @stack[0]\n end", "def push(value)\r\n # IMPLEMENT ME!\r\n # data = NIL\r\n # push(10) => data = LinkedListNode.new(10, data)\r\n # push(5) => data = LinkedListNode.new(5, data)\r\n # push(1) => data = LinkedListNode.new(1, data)\r\n\r\n @data = LinkedListNode.new(value, @data)\r\n\r\n end", "def push(value)\n @tape.push(value)\n end", "def push(element)\n @store << element #putting the element into the array, thereby putting it into the stack\n end", "def push(value)\r\n \t@data = LinkedListNode.new(value, @data)\r\n end", "def push(value)\r\n @data = LinkedListNode.new(value, @data)\r\n \r\n end", "def push(value)\r\n @head = Node.new(value, @head)\r\n end", "def push(value)\n last.next_node = Node.new(value, nil)\n end", "def push(value)\n\t\t\t\tif @length == 0\n\t\t\t\t\t@head = @tail = newNode(nil, value, nil)\n\t\t\t\telse\n\t\t\t\t\t@tail.next = newNode(@tail, value, nil)\n\t\t\t\t\t@tail = @tail.next\n\n\t\t\t\t\tif @length == 1\n\t\t\t\t\t\t@head.next = @tail\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t@length += 1\n\t\t\tend", "def push(value)\n new_node = Node.new(value)\n if length > 0\n new_node.prev_value = @tail\n @tail.next_value = new_node\n @tail = new_node\n if length == 1\n @head.next_value = new_node\n new_node.prev_value = head\n end\n else\n @head = new_node\n @tail = new_node\n end\n @length += 1\n return new_node.value\n end", "def push(value)\n\t\tnode = Node.new(value)\n\t\tif @length==0\n\t\t\t@last = node\n\t\t\t@first = node\n\t\telse\n\t\t\t@last.front = node\n\t\t\tnode.back = @last\n\t\t\t@last = node\n\t\tend\n\t\t@length+=1\n\tend", "def add_to_stack(obj)\n stack.push(obj)\n end", "def push(value)\r\n if @data == nil\r\n @data = LinkedListNode.new(value)\r\n else\r\n @data = LinkedListNode.new(value, @data)\r\n end\r\n end", "def push(value)\n @count += 1\n new_element = RubyDS::StackQueue::Element.new(value)\n if @head.nil?\n @head = new_element\n else\n new_element.next = @head\n @head = new_element\n end\n end", "def push(value)\n @head = Node.new(value, @head)\n end", "def push(value)\n @data = LinkedListNode.new(value, @data)\n end", "def push(value)\n @data = LinkedListNode.new(value, @data)\n end", "def push(value)\n @data = LinkedListNode.new(value, data)\n end", "def push(value)\n # IMPLEMENT ME!\n if @data == nil\n @data = LinkedListNode.new(value)\n else\n @data = LinkedListNode.new(value, @data)\n end\n end", "def push(element)\n #if the stack is full or the element is nil don't add it to the stack\n if full? or element.nil?\n nil\n else\n #increment top by one\n @top = @top.succ\n #store the element in the new top's position\n @store[@top] = element\n #return the instance of the stack\n self\n end\n end", "def push(element)\n #if the stack is full or the element is nil don't add it to the stack\n if full? or element.nil?\n nil\n else\n #increment top by one\n @top = @top.succ\n #store the element in the new top's position\n @store[@top] = element\n #return the instance of the stack\n self\n end\n end", "def push(val)\n resize! if @length >= @store.length\n @store[@length] = val\n @length += 1\n val\n end", "def push(value)\n @data = LinkedListNode.new(value, @data) \n end", "def push(value)\n @data = LinkedListNode.new(value, @data)\n end", "def push_int(i)\n stack << Script.encode_number(i)\n end", "def push(value)\n @data = LinkedListNode.new(value, @data)\n end", "def push(value)\n @data = LinkedListNode.new(value, @data)\n end", "def push(d)\r\n @data_stack << d\r\n end", "def push(value)\n @data = LinkedListNode.new value, @data\n end", "def add(element)\n @push_stack.push(element)\n end", "def push(el)\n @stack.push(el)\n end", "def append_tail(value)\n @stack0.push(value)\n end", "def push(value)\r\n\t\tif @data.nil? \r\n\t\t\t@data = LinkedListNode.new(value) \r\n\t\telse\r\n\t\t\t@data = LinkedListNode.new(value, @data)\r\n\t\tend\r\n\tend", "def push(x)\n max = @max_stack.empty? ? x : [x, @max_stack[-1]].max\n @max_stack.push(max)\n @stack.push(x)\n end", "def push(value)\n new_head = Node.new(value, @head)\n @head = new_head\n if tail.nil?\n @tail = @head\n end\n end", "def push(x)\n raise(OverflowError, \"Stack is already full\") if store.length == max\n store.push(x)\n return \"Stack is full\" if store.length == max\n # Don't expose the array\n # we're using for internal storage.\n return self\n end", "def push(value)\r\n if @data != nil\r\n node = LinkedListNode.new(value, @data)\r\n else\r\n node = LinkedListNode.new(value)\r\n end\r\n @data = node\r\n end", "def push(c)\n @push = c\n end", "def push(x)\n if @stack.length == 0 or x <= @min\n @stack.push @min\n @min = x\n end\n @stack.push x\n \n end", "def push(val)\n @store << val\n idx = count - 1\n @store = BinaryMinHeap.heapify_up(@store, idx, &prc)\n end", "def push(card)\n error_unless_param_is_a_card card, \"push\"\n @stack.push(card)\n end", "def push(value, args)\n if !defined?(value.queue)\n value.class_eval do \n @queue = :default\n end\n end\n Resque.enqueue value, args\n end", "def push\n CGContextSaveGState(@ctx)\n @stacksize = @stacksize + 1\n end", "def push(value)\n new_head = Node.new value, @head\n @head = new_head\n end", "def push(x)\n @stack.push(x)\n max_val = peek_max\n if max_val\n max_val = [max_val, x].max\n else\n max_val = x\n end\n @max_stack.push(max_val)\n x\n end", "def push(element)\n # if Stack is full or the element you're trying to add = nil, cannot add anything\n if full? or element.nil?\n nil\n else\n # +1 added to @top because there is one more item in the Stack\n @top = @top.succ\n # new item actually added to @store array\n @store[@top] = element\n # returns Stack\n self\n end\n end", "def push(value)\r\n @data = LinkedListNode.new(value, self.data)\r\n end" ]
[ "0.8563555", "0.8531257", "0.8298897", "0.82781947", "0.8205244", "0.81969625", "0.8174969", "0.8150769", "0.81474", "0.81396604", "0.80902964", "0.80648404", "0.795523", "0.79373324", "0.79243076", "0.79227865", "0.79042894", "0.78440315", "0.78257644", "0.7730317", "0.77155495", "0.7673377", "0.76662916", "0.7662389", "0.76555234", "0.7619361", "0.7569708", "0.755848", "0.7539669", "0.7463177", "0.7440642", "0.73879945", "0.7360027", "0.7358081", "0.7358081", "0.7355806", "0.7341728", "0.7340912", "0.733289", "0.73118883", "0.7305375", "0.72842014", "0.7269977", "0.72632384", "0.7262722", "0.72537345", "0.7246465", "0.72284645", "0.72103864", "0.7165176", "0.7146711", "0.71344817", "0.7127046", "0.7125858", "0.70920753", "0.7067504", "0.7059417", "0.70535374", "0.70514786", "0.7041376", "0.7039306", "0.70360017", "0.7035276", "0.7028563", "0.70174825", "0.7013754", "0.69918096", "0.6977924", "0.6977924", "0.6977431", "0.6976538", "0.6973059", "0.6973059", "0.69698876", "0.69615155", "0.69532037", "0.6950907", "0.69499284", "0.69499284", "0.6910792", "0.6904318", "0.69021857", "0.6892848", "0.68870294", "0.6886217", "0.6879897", "0.68737", "0.6869453", "0.68664193", "0.686587", "0.68563634", "0.6855945", "0.6852702", "0.68502295", "0.6849201", "0.6847103", "0.68410814", "0.6839024", "0.68389577" ]
0.7047238
60
Pop an item off the stack. Remove the last item that was pushed onto the stack and return the value to the user
def pop if @data top_value = @data.value @data = @data.next_node else top_value = nil end return top_value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pop()\n return \"Stack is empty\" if is_empty\n\n temp = @stack[-1]\n @stack.delete_at(-1)\n @current_size -= 1\n\n return temp\n end", "def pop()\n @stack.pop\n end", "def pop()\n\t\t@stack.pop\n\tend", "def pop()\n # if the stack is empty, return nil\n # (it would also be reasonable to throw an exception)\n if @items.empty?\n return nil\n end\n return @items.pop()\n end", "def pop()\n @stack.shift\n end", "def pop()\n @stack.pop \n end", "def pop()\n @stack.pop\n end", "def pop\n @stack.shift\n end", "def pop\n #if the stack is already empty do nothing\n if empty?\n nil\n else\n #set popped equal to the element at index @top, which isthe top of the stack\n popped = @store[@top]\n #set the value at the top of the stack to nil\n @store[@top] = nil\n # subtract 1 from the value of @top\n @top = @top.pred #@top--\n #returns the value that was popped\n popped\n end\n end", "def pop()\n # if the stack is empty, return nil\n # (it would also be reasonable to throw an exception)\n if @items.empty?\n return nil\n end\n return @items.pop()\n end", "def pop\n @stack.pop\n end", "def pop\n @stack.pop\n end", "def pop\n if @items.nil?\n\t raise \"Empty Stack -- nothing can be poped\"\n end\n\tpt = @items\n\t@items = @items.next\n\tpt.next = nil\n\treturn pt.value\n end", "def pop\n # if there's nothing on the stack, you can't take anything off\n if empty?\n nil\n else\n # popped is going to take the thing at the index that is the top of our stack\n popped = @store[@top]\n # now we make that index nil\n @store[@top] = nil\n # now we move the @top marker to the index below, because that is our new top\n @top = @top.pred #@top--\n # explicit return of the item from the top of the stack\n popped\n end\n end", "def pop()\n\n\n # if the stack is empty, return nil\n # (it would also be reasonable to throw an exception)\n return nil if @items.empty?\n @max_stack.pop() if @max_stack.last == @items.last\n return @items.pop()\n end", "def pop\n stack.pop\n end", "def pop\n stack.pop\n end", "def pop # utility\n @stack.pop\n end", "def pop()\n @stack.pop\n end", "def pop\n self.top = @stack[1]\n @stack.shift\n end", "def pop\n return @stack.pop\n end", "def pop()\n stack.stack.pop if !empty?\n end", "def pop\n last_el = self.stack_var[-1] # not sure if method should return last el\n self.stack_var = self.stack_var[0...-1]\n last_el\n end", "def pop\n raise \"Stack Underflow - The stack is empty\" if self.is_empty?\n top_element = @store.pop\n @top -= 1\n top_element\n end", "def pop\n\t\t\t@last = @stack.pop||\"\"\n\t\t\t@last\n\t\tend", "def pop\n stack.pop\n end", "def pop!\n r = @stack.pop\n raise ArgumentError if r.nil?\n r\n end", "def pop() end", "def pop\n return @stack.pop\n end", "def pop\n raise(UnderflowError, \"There is no element to remove from the stack\") if empty?\n store.pop\n end", "def pop\n @stack.pop\n end", "def pop\n\t\t@stack.pop.cleaup\n\tend", "def pop\n @stack.pop\n end", "def pop()\n item = @stack.pop()\n if item == @maxs_stack.peek()\n @maxs_stack.pop()\n end\n return item\n end", "def pop\n if @count > 0\n last_item_index = @count - 1\n\n # stores last element\n last_item = @items[last_item_index]\n\n # remove last item from array\n @items[last_item_index] = nil\n\n # reduces size by 1\n @count -= 1\n\n last_item\n else\n raise \"There are no items in the stack\"\n end\n end", "def pop()\n # if the stack is empty, return nil\n # (it would also be reasonable to throw an exception)\n if @items.empty?\n return nil\n end\n popped = @items.pop\n @max.pop if popped = @max.last\n return popped\n end", "def pop\n # if Stack is empty, cannot remove anything\n if empty?\n nil\n else\n # popped set equal to last element in @store array\n popped = @store[@top]\n # sets last element in @store array to nil\n @store[@top] = nil\n # sets @top equal to @top - 1 (so -2 the first time through, then -3, etc.) - there is still an empty slot in @store at index -1, but no actual element there\n @top = @top.pred #@top--\n # returns the element that was removed from @store/popped from Stack\n popped\n end\n end", "def pop()\n return @VAR_STACK.pop()\n end", "def pop()\n return @VAR_STACK.pop()\n end", "def pop\n raise EMPTY_STACK_ERROR if @data.empty?\n\n @data.pop\n end", "def stack_pop\n\n r = stack_fetch\n stack_unstack if r.class != Rufus::Lua::Table\n\n r\n end", "def pop\n @stackList.delete_at (@stackList.length - 1)\n postPopListener\n end", "def pop; end", "def pop; end", "def pop; end", "def pop; end", "def pop; end", "def pop()\n @VAR_STACK.pop()\n end", "def pop\n # assume head of @store is top of stack\n return @store.remove_first()\n end", "def pop\n raise StackUnderflow if empty?\n item = @start.info\n @start = @start.nxt\n item\n end", "def pop()\n return nil if @stack.empty?\n\n @max_stack.pop\n @stack.pop\n end", "def pop()\n self.min_stack.pop\n return self.stack.pop\n end", "def pop\n # check if stack is empty\n if @data.nil?\n return \"nil\"\n elsif @data.next_node != nil\n value = @data.value\n @data = @data.next_node\n return value\n else\n value = @data.value\n @data = @data.next_node\n return value\n end\n end", "def pop\n raise StackUnderflow if empty?\n @index -= 1\n @info[@index]\n end", "def pop()\n return \"Stack is empty\" if is_empty\n\n if @head.next == nil\n temp = @head.value\n @head = nil\n return temp\n end\n\n temp = @head.value\n @head = @head.next\n @current_size -= 1\n\n return temp\n end", "def pop\r\n top_item = data.value\r\n @data = data.next_node\r\n return top_item\r\n end", "def pop()\n \n end", "def pop()\n \n end", "def pop()\n \n end", "def pop\n value2Return = nil\n if @data == nil\n puts \"Stack is empty\" \n else\n value2Return = @data.value\n @data = @data.next_node\n end\n value2Return\n end", "def pop\n @stack.shift\n self\n end", "def pop()\n if @stacks.empty?\n -1\n else\n reset_left_right(@stacks.size-1, true)\n end\n end", "def pop\r\n # IMPLEMENT ME\r\n end", "def pop()\n @min_stack.pop if @min_stack[-1] == @stack[-1]\n @stack.pop; nil \n end", "def pop\n if empty?\n nil\n else\n popped = @store[@top]\n @store[@top] = nil\n #decrement top\n @top = @top.pred\n popped\n end\n end", "def pop\n if empty?\n nil\n else\n popped = @store[@top]\n @store[@top] = nil\n #decrement top\n @top = @top.pred\n popped\n end\n end", "def remove\n @stack.pop\n end", "def remove\n @stack.pop\n end", "def remove\n if @pop_stack.is_empty?\n transfer(@push_stack, @pop_stack)\n end\n\n @pop_stack.pop\n end", "def pop\n end", "def pop()\n @min_stack.pop() if @min_stack[-1] == @stack[-1]\n @stack.pop()\n end", "def pop\n # store top value in variable\n node_value = @data.value\n # replace top node with next node in stack\n @data = @data.next_node\n # return top node value\n return node_value\n end", "def pop\n if @top == nil\n return \"nil\"\n else\n value = @top.value\n @top = @top.next_node\n return value\n end\n end", "def pop\n raise \"stack underflow\" if empty?\n super\n end", "def pop()\n head = @head\n if head == nil then\n return nil\n end\n @head = head.prev\n return head.val\n end", "def pop\n if self.empty?\n raise UnderflowError, \"The stack is empty!\"\n else\n @mini_stack.pop\n @maxx_stack.pop\n @stak.pop\n end\n end", "def take_from_stack\n stack.pop\n end", "def pop\n # I RETURN A VALUE\n return nil if @top.nil?\n original_top = @top.value\n @top = @top.next_node\n original_top\n end", "def pop\n if(@stk.empty?)\n\t p \"Stack empty\"\n\telse\n\t @stk[@count] = nil\n\t @count = @count - 1\n\tend\n end", "def pop\n\t\t\traise EmptyStackError, \"Empty stack\" if STACK.empty?\n\t\t\treturn STACK.pop unless @frozen\n\t\t\tif @pushed > 0 then\n\t\t\t\t@pushed -= 1\n\t\t\t\tSTACK.pop\n\t\t\telse\n\t\t\t\traise EmptyStackError, \"Empty stack\" if @frozen <= 0\n\t\t\t\t@popped += 1\n\t\t\t\tSTACK[@frozen-@popped]\n\t\t\tend\t\n\t\tend", "def pop_at_stack(index)\n \n end", "def pop\n # IMPLEMENT ME\n end", "def pop\n raise IndexError.new if @data.size == 0\n ret = @data[0]\n @data[0] = @data[@data.size - 1]\n @data = @data.take(@data.size - 1)\n percolate_down\n return ret\n end", "def pop_stack\n raise ArgumentError if @array_list.empty?\n\n @array_list.pop\n end", "def pop\n if empty?\n nil\n else\n @q.remove\n @stack.shift\n end\n end", "def pop\n # begining of if statement\n # if the method empty? returns true\n if empty?\n #return nil\n nil\n # if the method empty? returns false\n else\n # assign to the the local var popped the value in the array @store\n # that is is the array position of the value of @top\n popped = @store[@top]\n # assign the value nil to the positon of the value of @top in the array @store\n @store[@top] = nil\n # subtract one from the value of the instance var @top\n # and assign the value back to the instance var @top\n @top = @top.pred\n # return the value of the local var popped\n popped\n # end if/else statement\n end\n # end pop method\n end", "def pop\n pull_top = @data.value\n @data = @data.next_node\n return pull_top\n end", "def pop\n if @data\n top = @data.value\n @data = @data.next_node\n return top\n else\n return 'nil'\n end\n end", "def pop\r\n return nil if @top_node.nil?\r\n temp_node = @top_node\r\n @top_node = temp_node.next_node\r\n return temp_node.value\r\n end", "def last_popped_stack_elem\n @stack[@sp]\n end", "def pop_tree\n @tree_stack.pop\n end", "def pop()\n @data.pop\n end", "def pop\n return nil if @count == 0\n\n # get the index of the las titem\n @store.store.reverse.each_with_index do |ele, i|\n if ele != nil \n @last_ele = capacity() - (i+1) \n break\n end\n end\n #val = @store.store.delete_at(@last_ele)\n val = @store.store[@last_ele]\n @store.store[@last_ele] = nil\n @count -= 1\n return val\n end", "def pop\n return false if empty?\n @len -= 1\n @stack[@len]\n end", "def pop\n curr = items\n ret = curr.pop\n\n serialize(curr)\n\n ret.nil? ? nil : ret\n end", "def pop(tape)\n\ta = Array.new\n\t# Move back to the stack seperator\n\ta.push Action.new(:left, tape)\n\n\t# Erase the stack seperator and the value\n\t(BitWidth + 1).times{\n\t\ta.push Action.new(BlankSymbol, tape)\n\t\ta.push Action.new(:right, tape)\n\t}\n\n\tm = SubMachine.empty \"pop-#{tape}\"\n\tm.states[m.first].transitions = [Transition.new( Hash.new, a, m.last)]\n\n\t# Now we're on top of the last bit of the prev. value on stack\n\tm2 = moveDistance(tape, (2*BitWidth) + 1, :left)\n\tm.simpleMerge(m2)\n\n\tm\nend", "def pop\n\t\tif (!@head) then return nil end\n\t\ttemp = @head\n\t\t@head = @head.get_next()\n\t\tif (@head) then @head.set_prev(nil)\n\t\telse @tail = nil\n\t\tend\n\t\t@size -= 1\n\t\treturn temp.get_item()\n\tend", "def pop\n list.pop\n end", "def pop\n CGContextRestoreGState(@ctx)\n @stacksize = @stacksize - 1\n end", "def pop\n delete_at(0)\n end", "def pop\n\t item = @items.pop()\n\t # if the popped item is the highest, remove it from the max\n\t @max.pop() if item == @max.last\n\t item\n\tend" ]
[ "0.8281756", "0.82716006", "0.82564", "0.8236544", "0.8228041", "0.82207924", "0.82079315", "0.818714", "0.8170738", "0.8168916", "0.816014", "0.816014", "0.8148781", "0.81294084", "0.8104261", "0.8102216", "0.8102216", "0.8091204", "0.8083773", "0.80678487", "0.8059671", "0.805275", "0.8017853", "0.8011615", "0.8011209", "0.8010257", "0.7983402", "0.7945574", "0.7941483", "0.7935612", "0.7926162", "0.78954774", "0.787053", "0.78694296", "0.78690416", "0.7851105", "0.77966195", "0.77875113", "0.77875113", "0.7758854", "0.77548254", "0.775248", "0.77298534", "0.77298534", "0.77298534", "0.77298534", "0.77298534", "0.77058446", "0.76632774", "0.7654179", "0.7644038", "0.76440006", "0.76309806", "0.76226884", "0.7596181", "0.7593098", "0.75593317", "0.75593317", "0.75593317", "0.75451195", "0.7535086", "0.74993306", "0.74860376", "0.74787533", "0.7478555", "0.7478555", "0.74620837", "0.74620837", "0.7459627", "0.74561036", "0.7444144", "0.7399355", "0.73767483", "0.7333123", "0.73025054", "0.7299951", "0.72948575", "0.7287863", "0.7284127", "0.728009", "0.7276388", "0.72717", "0.7270779", "0.7255902", "0.7253196", "0.72361857", "0.72204816", "0.7200712", "0.7192083", "0.71655196", "0.71513146", "0.71464044", "0.71325105", "0.7113654", "0.7110618", "0.7106004", "0.71054447", "0.7076905", "0.70733875", "0.7067833", "0.706209" ]
0.0
-1
Generate and update the remember digest
def remember # store virtually the new token self.remember_token = User.new_token # save the hash digest of the token on the database self.update_attribute(:remember_digest, User.digest(self.remember_token)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_remember_digest\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember_token_digest\n self.remember_token = User.new_token\n # Updates remember_digest in database from nil to digest of remember_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def create_remember_digest\n self.remember_token = User.new_token\n self.remember_digest = User.digest(remember_token)\n end", "def create_remember_digest\n self.remember_token = User.new_token\n self.remember_digest = User.digest(remember_token)\n end", "def create_remember_digest\n\t remember_token = User.new_token\n\t self.remember_digest = User.digest(remember_token)\n\t end", "def generate_remember_token_digest!\n remember_token = _generate_token(:remember)\n update_column(:remember_token_digest, SCrypt::Password.create(remember_token))\n remember_token\n end", "def create_reset_digest\n new_token = SecureRandom.urlsafe_base64\n update_attributes(reset_digest: User.hash_token(new_token), reset_sent_at: Time.zone.now)\n new_token\n end", "def create_reset_digest\n self.reset_digest = SecureRandom.urlsafe_base64.to_s\n update_attribute(:reset_digest, reset_digest)\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def remember\n self.remember_token = Band.new_token\n update_attribute(:remember_digest, Band.digest(remember_token))\n end", "def remember\n self.remember_token = User.new_token\n # digest remember_token which is created from base64 library\n # -> update vao cai thang remember_digest!!!\n # noi chung la cu phai tu tu moi hieu het duoc !!!\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\nself.remember_token = User.new_token\nupdate_attribute(:remember_digest, User.digest(remember_token))\nend", "def remember\nself.remember_token = User.new_token\nupdate_attribute(:remember_digest, User.digest(remember_token))\nend", "def remember\n self.remember_token = Hungrybee.new_token\n update_attribute(:remember_digest, Hungrybee.digest(remember_token))\n end", "def remember\n self.remember_token = User.new_token \n update_attribute(:remember_digest, User.digest(remember_token)) \n end", "def create_activation_digest\n self.activation_token = User.new_token\n self.activation_digest = User.digest(remember_token)\n end", "def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n self.remember_token=User.new_token\n update_attribute(:remember_digest,User.digest(remember_token))\n end", "def remember\n self.remember_token = new_token\n update_attribute(:remember_digest, digest(remember_token))\n end", "def remember\n self.remember_token = Author.new_token\n update_attribute(:remember_digest, Author.digest(remember_token))\n end", "def remember\n self.remember_token = Staff.new_token\n update_attribute(:remember_digest, Staff.digest(remember_token))\n end", "def remember\n\tself.remember_token = User.new_token\n\tupdate_attribute(:remember_digest, User.digest(remember_token))\nend", "def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n self.remember_token = self.class.new_token\n update_attribute(:remember_digest, self.class.digest(remember_token))\n end", "def remember\n self.remember_token = self.class.new_token\n update_attribute(:remember_digest, self.class.digest(remember_token))\n end", "def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest,User.digest(remember_token))\n end", "def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n\n end", "def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n\n end", "def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\nend", "def create_reset_digest\n\t self.reset_token = User.new_token\n\t update_attribute(:reset_digest, User.digest(reset_token))\n\t update_attribute(:reset_sent_at, Time.zone.now)\n\tend", "def create_reset_digest\n\t self.reset_token = User.new_token\n\t update_attribute(:reset_digest, User.digest(reset_token))\n\t update_attribute(:reset_sent_at, Time.zone.now)\n\tend", "def create_reset_digest\n self.reset_token=User.new_token\n update_attribute(:reset_digest,User.digest(reset_token))\n update_attribute(:reset_send_at,Time.zone.now)\n \n end", "def remember #this is also called a user.remember method\n self.remember_token = User.new_token #save the generated token into a class variable called remember_token, accessible in the whole User class with attr_accessor\n update_attribute(:remember_digest, User.digest(remember_token)) #to update the database we use the remember token that has been generated, encrypt it with digest method, then save to database\n end", "def remember\n self.remember_token = Person.new_token\n update_attribute(:remember_digest, Person.digest(remember_token))\n end", "def remember\n \t\tself.remember_token = User.new_token\n \t\tupdate_attribute(:remember_digest, User.digest(remember_token))\n\tend", "def remember\n self.remember_token=User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n self.remember_token = Doctor.new_token\n update_attribute(:remember_digest, Doctor.digest(remember_token))\n end", "def create_reset_digest\n self.reset_token = Usuario.new_token\n update_attribute(:reset_digest, Usuario.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def remember\n self.remember_token = User.newtoken\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = Gamer.new_token\n update_attribute(:reset_digest, Gamer.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n\t self.reset_token = User.new_token\n\t update_attribute(:reset_digest, User.digest(reset_token))\n\t update_attribute(:reset_sent_at, Time.zone.now)\n end", "def remember\n self.remember_token = Agent.new_token\n update_attribute(:remember_digest, Agent.digest(remember_token))\n end", "def create_reset_digest\r\n self.reset_token = User.new_token\r\n update_attribute(:reset_digest,User.digest(reset_token))\r\n update_attribute(:reset_sent_at,Time.zone.now)\r\n end", "def create_reset_digest\n self.reset_token=User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember\n self.remember_token = User.new_token\n self.update_attribute(:remember_digest, User.digest(self.remember_token))\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.now)\n end", "def create_reset_digest\n self.reset_token=User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at,Time.zone.now)\nend", "def create_reset_digest\n self.reset_token = User.generate_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update reset_digest: User.digest(reset_token),\n reset_sent_at: Time.zone.now\n end", "def create_reset_digest\n\t\tself.reset_token = User.new_token\n\t\tupdate_attribute(:reset_digest, User.digest(reset_token))\n\t\tupdate_attribute(:reset_sent_at, Time.zone.now)\n\tend", "def create_reset_digest\n\tself.reset_token = User.new_token\n\tupdate_attribute(:reset_digest, User.digest(reset_token))\n\tupdate_attribute(:reset_sent_at, Time.zone.now)\nend", "def create_reset_digest\n @reset_token = SecureRandom.urlsafe_base64(48)\n self.reset_token = @reset_token\n update_attribute(:reset_digest, @reset_token)\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end", "def create_reset_digest\n self.reset_token = User.new_token\n update_attribute(:reset_digest, User.digest(reset_token))\n update_attribute(:reset_sent_at, Time.zone.now)\n end" ]
[ "0.7748438", "0.7440697", "0.7431944", "0.7431944", "0.7413818", "0.73257464", "0.7127094", "0.71126854", "0.70892566", "0.70697385", "0.70513576", "0.70513576", "0.7017328", "0.70145386", "0.6999056", "0.6987499", "0.697524", "0.69712365", "0.696727", "0.6953357", "0.6940077", "0.69363314", "0.6936021", "0.6936021", "0.6923562", "0.6923562", "0.6923562", "0.6923562", "0.6919126", "0.6918053", "0.6918053", "0.6915897", "0.6912885", "0.6912885", "0.69127834", "0.6906947", "0.6894721", "0.689357", "0.68862903", "0.6885396", "0.6877285", "0.6873761", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68722236", "0.68708795", "0.68708795", "0.6863848", "0.68569314", "0.68563426", "0.6845074", "0.68338084", "0.68326586", "0.68312913", "0.68282527", "0.6826998", "0.6826941", "0.6824725", "0.6822706", "0.6819913", "0.681629", "0.6811489", "0.680224", "0.680224", "0.680224", "0.680224" ]
0.0
-1
Check if the remember_token passed is the same of the stored on the database
def authenticated?(remember_token) return false if self.remember_digest.nil? BCrypt::Password.new(self.remember_digest) == remember_token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remember_token?\n remember_token_expires_at && Time.now < remember_token_expires_at\n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at \n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at \n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at \n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at\n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at\n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at\n end", "def valid_remember_token?(token)\n if self.remember_digest.nil?\n return false\n else\n return BCrypt::Password.new(self.remember_digest).is_password?(token)\n end\n end", "def authenticated?(token)\n hex_encrypt(token) == remember_token\n end", "def authenticated_with_token?(token)\n return false if token.nil?\n token == remember_digest\n end", "def authenticated?(remember_token)\n\t\t#if logged in from multiple browsers, and logged out from 1, this cud be null\n\t\treturn false if remember_digest.nil?\n\t\t#hashes the token and compares it with digest\n\t\tBCrypt::Password.new(remember_digest).is_password?(remember_token)# you can use == also in place of is_password\n\tend", "def remember\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated? remember_token\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password? remember_token\n end", "def authenticated?(remember_token)\r\n \tBCrypt::Password.new(remember_digest).is_password?(remember_token) \r\n end", "def authenticated? remember_token\n\t\tBCrypt::Password.new(remember_digest).is_password?(remember_token)\n\tend", "def authenticated? remember_token\n return false unless remember_digest\n\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\nBCrypt::Password.new(remember_digest).is_password?(remember_token)\nend", "def is_remember_token?(remember_token)\n\t\treturn false if self.remember_digest.nil?\n\t\tBCrypt::Password.new(self.remember_digest).is_password?(remember_token)\n\tend", "def authentic_token?(token)\n return false if remember_token.nil?\n\n BCrypt::Password.new(remember_token).is_password?(token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil? \n BCrypt::Password.new(remember_digest).is_password?(remember_token)\nend", "def authenticated?(remember_token)\n\t\t# this is to ensure that you do not call .is_password with nil which will throw an error\n\t\treturn false if remember_digest.nil?\n\t\t# taking the browser token -> hashing it -> and then comparing it with the hashed token stored in the database\n\t\tBCrypt::Password.new(self.remember_digest).is_password?(remember_token)\n\tend", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n if remember_digest.nil?\n false\n else\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end\n end", "def authenticated?(remember_token)\n\t\tBCrypt::Password.new(remember_digest).is_password?(remember_token)\n\tend", "def authenticated?(remember_token)\n\t\tBCrypt::Password.new(remember_digest).is_password?(remember_token)\n\tend", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n # so here we compare the remember token, to the remember digest\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remmber_token)\n BCrypt::Password.new(remember_digest).is_password?(remmber_token)\n end", "def authenticated?(remmber_token)\n BCrypt::Password.new(remember_digest).is_password?(remmber_token)\n end", "def authenticated?(remember_token)\n \treturn false if remember_digest.nil?\n \tBCrypt::Password.new(remember_digest).is_password?(remember_token)\n \tend", "def authenticated_remember?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n \treturn false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token) \t\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(activation_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(rember_digest).is_password?(remember_token)\n end", "def check_two_factor_auth_persistence_token\n if record\n two_factor_auth_persistence_token_from_cookie = two_factor_auth_cookie_credentials[:two_factor_auth_persistence_token]\n\n if !record.get_two_factor_auth_persistence_token.blank? &&\n record.get_two_factor_auth_persistence_token == two_factor_auth_persistence_token_from_cookie\n then\n # The cookie matches, so we'll set the flag.\n set_two_factor_auth_completed_flag\n else\n if single_access\n # If we couldn't match based on the cookie, but we authenticated\n # with the single access token, then we'll just set the flag\n # here without needing to actually send the 2FA code.\n set_two_factor_auth_completed_flag\n else\n # No single access given and cookie doesn't match so unset the\n # flag.\n unset_two_factor_auth_completed_flag\n end\n end\n else\n # No record was even found, so unset the flag.\n unset_two_factor_auth_completed_flag\n end\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\nBCrypt::Password.new(remember_digest).is_password?(remember_token)\nend", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n\n end", "def authenticated?(remember_token)\n \treturn false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n \treturn false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n \treturn false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n \treturn false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(token)\n return false if (!remember_digest)\n BCrypt::Password.new(remember_digest).is_password?(token)\n end", "def authenticated?(token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(token)\n end", "def authenticated?(remember_token)\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n puts \"remember token: #{remember_token}, remember digest: #{remember_digest}\"\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def valid_remember_cookie?\n return nil unless @current_user\n (@current_user.remember_token?) && \n (cookies[:auth_token] == @current_user.remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n\t digest = send(\"remember_digest\")\n\t return false if digest.nil?\n\t BCrypt::Password.new(digest).is_password?(remember_token)\n \tend", "def authenticated?(remember_token)\n\t\treturn false if remember_digest.nil?\n \t\tBCrypt::Password.new(remember_digest).is_password?(remember_token)\n\tend", "def authenticated?(remember_token)\n # returns false if the remember digest is nil, which emphasizes the rest of the method gets ignored\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\nend", "def valid_remember_cookie?\n return nil unless @current_user\n (@current_user.remember_token?) && (cookies[:auth_token] == @current_user.remember_token)\n end", "def authenticated?(remember_token)\n return false if remember_digest.nil?\n\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def authenticated?(remember_token)\n return true if remember_digest.nil?\n return false if remember_token.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end", "def remember_token; end", "def valid_remember_cookie?\n return nil unless @current_user\n (@current_user.remember_token?) &&\n (cookies[:auth_token] == @current_user.remember_token)\n end", "def authenticated?(remember_token)\n return false if self.remember_digest.nil?\n BCrypt::Password.new(self.remember_digest).is_password?(remember_token)\n end" ]
[ "0.79494613", "0.79044074", "0.79044074", "0.79044074", "0.7852432", "0.7775121", "0.7773094", "0.7575631", "0.7534368", "0.7410829", "0.73785126", "0.73740906", "0.7368886", "0.7328937", "0.73191595", "0.73175794", "0.7315333", "0.73139375", "0.7308871", "0.72832704", "0.72527057", "0.7241213", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.72403413", "0.7224216", "0.7210587", "0.7210587", "0.72086614", "0.72046465", "0.72046465", "0.71917456", "0.71865624", "0.7182815", "0.71812254", "0.7180075", "0.7175403", "0.7163308", "0.71447355", "0.7137754", "0.71327645", "0.71327645", "0.71327645", "0.71327645", "0.7089528", "0.7087622", "0.70807195", "0.7066101", "0.70655745", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.706143", "0.7060501", "0.7052591", "0.7051344", "0.70465755", "0.70246494", "0.7008322", "0.6995711", "0.6994237", "0.6987904" ]
0.74103385
10
Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers) (Wikipedia). For example number 7 is happy because after a number of steps the computed sequence ends up with a 1: 7, 49, 97, 130, 10, 1 while 3 is not, and would give us an infinite sequence: 3, 9, 81, 65, 61, 37, 58, 89, 145, 42, 20, 4, 16,3 7, 58, 89, 145, 42, 20, 4, 16, 37, ... Write a function that takes n as parameter and return true if and only if n is an happy number. Happy coding!
def is_happy(n) i = 0 r = false destination = [] while r == false n.to_s.split("").each do |x| destination << ((x.to_i * x.to_i)) end i = i + 1 n = destination.inject(&:+) r = true if n == 1 destination = [] break if i == 1000 end if r == true p r else p false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def happy_number(n)\n\tresult = square(n)\n\th = {result => true}\n\twhile true do\n\t\tputs \"result = #{result}\"\n\t\tresult = square(result)\t\t\n\t\tif result == 1\n\t\t\treturn true\n\t\telsif h[result]\n\t\t\treturn false\n\t\telse\n\t\t\th[result] = true\n\t\tend\n\tend\nend", "def is_happy(n)\n\treturn false if n <= 0\n\tstack = {}\n\twhile (true)\n\t\thappy_count = 0\n\t\tn.digits.each do |digit|\n\t\t\thappy_count += digit ** 2\n\t\tend\n\t\treturn true if happy_count == 1\n\t\treturn false if stack[happy_count]\n\t\tstack[happy_count] = true\n\t\tn = happy_count\n\tend\nend", "def happy? n\n visited = []\n until n == 1 || visited.include?(n)\n visited << n\n n = n.to_s.chars.map{ |x| x.to_i * x.to_i }.inject{ |sum, x| sum + x }\n end\n n == 1\nend", "def is_happy(n)\n return false if n < 10 && n % 2 == 0\n return false if n < 1 \n return true if n == 1\n \n sum = 0\n\n nsplit = n.to_s.split(\"\")\n nsplit.each do |i|\n sum += (i.to_i * i.to_i)\n end\n\n return is_happy(sum)\n \nend", "def isHappy? n\n acc = {}\n acc[n] = true\n begin\n sum = 0\n n.to_s.split(\"\").map {|i| sum += i.to_i**2}\n\n if sum == 1 then return true\n elsif acc.has_key?(sum) then return false\n else acc[sum] = true end\n\n n = sum\n end while sum != 1\nend", "def is_happy_1?(n, sums = [])\n return false if n.to_i < 1 || sums.include?(n)\n return true if n == 1\n sums << n \n numbers = n.to_s.split('')\n total = numbers.sum{|i| i.to_i * i.to_i }\n is_happy_1?(total, sums)\nend", "def is_happy(number)\n appeared = Array.new\n result = number\n \n while true do\n if result.to_i == 1\n return 1\n end\n \n digits = result.to_s.split(//)\n \n result = digits.inject(0){|sum, d| sum + d.to_i ** 2}\n \n if appeared.include?(result)\n return 0\n end\n \n appeared << result\n end\nend", "def follows_conjecture?(n)\r\n 0.upto(n) do |i|\r\n break if i ** 2 > n\r\n 2.each_prime do |p|\r\n num = p + 2 * (i ** 2)\r\n return true if num == n\r\n break if num > n\r\n end\r\n end\r\n return false\r\nend", "def featured(n)\n n += 1\n n += 1 until n % 7 == 0 && n.odd?\n loop do\n break if n.to_s.chars.uniq.join == n.to_s\n n += 14\n if n > 9876543210\n puts \"There is no possible number that fulfills those requirements\"\n return nil\n end\n end\n n\nend", "def solution(n)\n number = 1\n stop = false\n while !stop\n results = []\n (1..n).each do |divider| \n if number % divider != 0\n results << false\n else\n results << true\n end\n end\n if results.count {|x| x == false } > 0\n stop = false\n number += 1\n else \n stop = true\n end \n end\n number\nend", "def happy_number_sequence(length)\n\n\thappy_sequence=[]\n\ti=1\n\twhile happy_sequence.length < length\n\t\tif happy_number(i) == \"Happy Number\"\n\t\t\thappy_sequence << i\t\n\t\tend\n\t\ti += 1\n\tend\n\thappy_sequence\nend", "def get_happy(num, base=10)\n $hap_map[num] = 0 if num == 1 # Handles trivial case\n return $hap_map[num] if $hap_map[num]\n\n ret = 0\n done = false\n inters = []\n temp = num\n\n until done\n digits = temp.to_s(base).split(//).map{|c| c.to_i(base)}\n temp = digits.inject(0) {|sum, d| sum + d**2}\n ret += 1\n\n if (temp != 1) && $hap_map[temp]\n # Optimization; use knowledge stored in $hap_map\n if $hap_map[temp] == -1\n ret = -1\n done = true\n else\n ret += $hap_map[temp]\n done = true\n end\n else\n if temp == 1\n ret -= 1 # Don't count 1 as an intermediate happy number\n done = true\n elsif inters.include?(temp)\n ret = -1\n done = true\n else\n inters << temp\n end\n end\n end\n\n $hap_map[num] = ret\n\n # Optimization\n if ret == -1\n # If num is not happy, none of the intermediates are happy either\n inters.each {|n| $hap_map[n] = -1}\n else\n # If num is happy, each intermediate has a happiness value determined by \n # its position in the array\n inters.each_index {|idx| $hap_map[inters[idx]] = (ret - 1) - idx}\n end\n\n return ret\nend", "def elevenish(n) \n\tif n % 11 == 0\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def can_win_nim(n)\n if n < 4\n return true\n end\n\n target = n-4\n \n return !(target % 2 == 0 || target % 3 == 0 || target % 5 == 0)\nend", "def can_win_nim(n)\n n % 4 == 0 ? false : true\nend", "def can_win_nim(n)\n if n % 4 == 0\n false\n else\n true\n end\nend", "def prime_proof2(n)\n \n puts n\n # if the last digit isn't 1,3,7, or 9, then thats the only digit we need to check.\n if [1,3,7,9].include? n % 10\n rotate_digits2(n, 0, [0,2,4,5,6,8]) do |test|\n return false if Primes.isPrime?(test)\n end\n return true\n end\n \n len = (Math.log(n) / Math.log(10)).floor + 1\n s = n.to_s\n 0.upto(len) do |i|\n rotate_digits2(n, i) do |test|\n return false if Primes.isPrime?(test)\n end\n end\n puts \"true\"\n exit\nend", "def happy?\n if @happiness > 7\n return true\n else\n false\n end\n end", "def if_prime_pattern(n)\n return false if n % 3 == 0\n return false if n % 7 == 0\n return false if n % 13 == 0\n\n # (n^2 + 13) % 7 == 0\n return false if n % 7 == 1 or n % 7 == 6\n # (n^2 + 3) % 7 == 0\n return false if n % 7 == 2 or n % 7 == 5\n # (n^2 + 9) % 13 == 0\n return false if n % 13 == 2 or n % 13 == 11\n # (n^2 + 1) % 13 == 0\n return false if n % 13 == 5 or n % 13 == 8\n # (n^2 + 3) % 13 == 0\n return false if n % 13 == 6 or n % 13 == 7\n\n $primes.each do |p|\n break if p > n + 1\n [1, 3, 7, 9, 13, 27].each do |a|\n return false if (n * n + a) % p == 0\n end\n end\n\n # tests above primes are consecutive\n [5, 11, 15, 17, 19, 21, 23, 25].each do |b|\n $primes.each do |p|\n # tests up to the biggest prime less than the square root of n * n + 25\n # the condition p > n + 1 works for 10, and certainly works for big enough n\n return false if p > n + 1\n break if (n * n + b) % p == 0\n end\n end\n true\nend", "def elevenish (n)\n\tif n == 11\n\t\treturn true\n\tend\n\n\tif n%11\n\t\treturn true\n\tend\n\n\tif n \n\n\tend\n\nend", "def prime?(n)\n if n === 1\n result = false\n else\n result = true\n for x in 2..n**(0.5)\n if n % x === 0\n result = false\n break\n end\n end\n end\n return result\nend", "def is_prime? n\n x = n -1\n while x > 1\n return false if (n % x).zero?\n x -= 1\n end\n true\nend", "def problem3 n\n 2.step(n,1).each do |x|\n return x-1 if n == 1\n n /= x if x.prime? && (n % x == 0)\n end\nend", "def happy?\n if @happiness > 7\n true\n else\n false\n end\n end", "def is_abundant?(n)\n return false if n<2\n\n s = 1\n 2.upto(Math.sqrt(n).to_i) do |i|\n if ((n % i) == 0 )\n s += i\n s += (n/i) unless (n/i == i)\n\n return true if s > n\n end\n end\n return false\nend", "def IsPrimeSuck( n )\n\tfor i in ( 2.. n-1 )\n\t\tif ( n % i == 0 )\n\t\t\treturn false\n\t\tend\n\tend\n\n\treturn true\nend", "def prime? n\n\t(2..(n-1)).each { |x| return false if n % x == 0}\n\ttrue\nend", "def good_guess?(n)\n if n == 42\n puts true\n else\n puts false\n end\nend", "def good_guess?(n)\n if n == 42\n puts true\n else\n puts false\n end\nend", "def good_guess?(n)\n return n == 42 ? true : false\nend", "def prime(n)\r\n\tnumbers = (1..n-1).to_a\r\n\tnumbers.each do |num|\r\n\tif numbers.length == 1\r\n\t\treturn true\r\n\tend\r\n\t\tif n%2 == 0 && n%num == 0 \r\n\r\n\t\t\t\treturn false\r\n\t\telse\r\n\t\t\t\treturn true\r\n\t\tend\t\r\n\tend\r\n\r\n\r\nend", "def is_prime(n)\n return false if n <= 1\n return true if n == 2\n 2.upto(n - 1) do |x|\n return false if n % x == 0\n end\n true\nend", "def is_fibonacci?(num)\n fibonacci_sequence = [0, 1] \n i = 1\n while i <= num #1 is less than monster num\n previous_num = fibonacci_sequence[-2] \n next_num = fibonacci_sequence[-1] \n sum = previous_num + next_num\n fibonacci_sequence << sum\n i = i + previous_num\n end\n p fibonacci_sequence\n if fibonacci_sequence.include?(num) \n p true\n else\n p false\n end \nend", "def prime? n\r\n (3..Math.sqrt(n)).step(2).each {|i| return false if n % i == 0}\r\n true\r\nend", "def fibonacci?(n)\n return true if n == 1 || n == 2\n first, second = [1, 1]\n last = 1\n until last >= n\n last = first + second\n first, second = second, last\n end\n \n last == n\nend", "def elevenish?(n)\n\treturn (n.abs % 11 == 0) || (n.abs % 11 == 1)\nend", "def prime?(n)\n (2..(n-1)).each { |x| return false if n % x == 0 }\n true\nend", "def isprime(n)\n \n for x in (3..(n**0.5).abs+2)\n if n % x == 0\n return false\n end\n return true\n end\nend", "def is_narcissistic(n)\n list = n.to_s.split ''\n power = list.length\n list.map! {|x| x.to_i}\n sum = list.inject(0) { |sum, x| sum += x ** power}\n sum == n ? true : false\nend", "def brute_force (n)\n if n <= 1\n return false\n elsif n == 2\n return true\n #elsif n % 2 == 0 return false\n elsif n.even?\n return false\n else\n m = Math.sqrt(n)\n i = 3 #fuck ruby's lack of good for loops\n while i <= m\n return false if n % i == 0\n i += 2\n end\n end\n return true\n end", "def prime?(n)\n\tif n <= 1\n\t\treturn false\n\telsif n <= 3\n\t\treturn true\n\telsif n % 2 == 0 || n % 3 == 0\n\t\treturn false\n\telse\n\t\ti = 5\n\t\twhile(i * i <= n)\n\t\t\tif n % i == 0 || n % (i + 2) == 0\n\t\t\t\treturn false\n\t\t\tend\n\t\t\ti += 6\n\t\tend\n\t\ttrue\n\tend\nend", "def prime?(n)\n 2.upto(Math.sqrt(n).floor) do |i|\n return false if n%i == 0\n end\n\n true\nend", "def prime?(n)\n 2.upto(Math.sqrt(n).floor) do |i|\n return false if n%i == 0\n end\n\n true\nend", "def kaprekar_number?(n)\n n_squared = (n**2).to_s\n len = n_squared.length\n len.times do |i|\n part1 = n_squared[0..i].to_i\n part2 = n_squared[(i+1)...len].to_i\n break if part2.zero?\n return true if part1 + part2 == n\n end\n false\nend", "def prime?(n)\n if n == 0 || n == 1\n return false\n end\n x = 2\n while x < n\n if n % x == 0\n return false\n end\n x += 1\n end\n return true\nend", "def prime_math(n)\n (2..(n - 1)).each do |divisor|\n return false if n % divisor == 0 \n end\n true\nend", "def featured2(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number > 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def isprime(n)\n if n == 1\n return false\n elsif n == 2\n return true\n else\n (2..Math.sqrt(n).ceil).each { |e| n % e == 0 ? (return false) : next }\n return true\n end\nend", "def isLucky(n)\n n = n.to_s.split('').map(&:to_i)\n n.shift(n.size/2).reduce(:+) == n.reduce(:+)\nend", "def check_prime? n \nn_max_two=Math.sqrt(n).floor \nnot_count=0 \nfor i in 2..n_max_two\n if n % i == 0 \nnot_count +=1 \n end \nend \nif not_count > 0 \n return false \n else \n return true \nend \nend", "def featured(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend", "def is_prime?(n)\n (2...n).each { |factor| return false if n % factor == 0 } \n n > 1\nend", "def is_fibonacci?(n)\n fibonacci_numbers = [0, 1]\n while n > fibonacci_numbers[-1]\n x = fibonacci_numbers[-1] # Last number in the array\n y = fibonacci_numbers[-2] # Second to last number in the array\n fibonacci_numbers.push(x+y) # We add them and push them into the array\n end\n fibonacci_numbers.include?(n)? true : false\nend", "def prime?(n)\n if n <= 1\n return false\n else\n (2...n).to_a.all? do |i|\n n % i != 0\n end\n end\nend", "def g_happy(str)\n happy = true\n str.size.times do |n|\n if str[n] == \"g\" && str[n + 1] != \"g\" && str[n - 1] != \"g\"\n happy = false\n end\n end\n return happy\nend", "def prime?(n)\n (2...n).each { |x| return false if n % x == 0 }\n true\nend", "def prime?(n)\n if n <= 1\n return false\n elsif n <= 3\n return true\n else (2..n/2).none? do |x|\n n % x == 0\n end\n end\nend", "def prime_number(n)\n if n < 2\n return false\n end\n i = 2\n while i < n\n if n % i == 0\n return false\n end\n i += 1\n end \n return true\nend", "def divisible?(n)\n (2..19).each do |i| #We know it's divisible by one,\n #and since we started with 20, and incremented by 20, it's divisible by 20\n return false if n % i != 0\n end\n true\nend", "def is_prime(n)\n\n\tif n <= 1\n\t\treturn false\n\tend\n\n\tif n <= 3\n\t\treturn true\n\tend\n\n\tif (n % 2 == 0 || n % 3 == 0)\n\t\treturn false\n\tend\n\n\ti = 5\n\n\twhile i * i <= n\n\n\t\tif n % i == 0 || n % (i + 2) == 0\n\t\t\treturn false\n\t\tend\n\n\t\ti += 6\n\tend\n\n\treturn true\n\t\nend", "def one_followed_by_zeros?(number)\n digits = number.to_s.split(\"\")\n first_digit = digits.shift\n first_digit.to_i == 1 && digits.size > 0 && digits.map(&:to_i).all?(&:zero?)\n end", "def isprime(n)\n\tif n == 1\n\t\treturn false \n\tend \n\tif n == 2 \n\t\treturn true \n\tend \n\tx = 2\n\tloop do \n\t\tif n % x == 0\n\t\t\treturn false \n\t\tend\n\t\tx = x + 1 \n\t\tif x == n\n\t\t\tbreak\n\t\tend \n\t\t\n\tend \n\treturn true\nend", "def f(n)\n return (1..n).sum if n.positive? and n.integer?\n return false\n # insert your code here.... and go crazy!\nend", "def prime? n\n\treturn false if n < 2\n\treturn true if n == 2 || n == 3\n\t(2..(n ** 0.5)).each{|x| return false if n % x == 0}\n\treturn true\nend", "def magic_number?(n)\n n.to_s.split('').each.map {|ch| ch.to_i}.reduce(:+) == 7 \nend", "def solve(n)\n x = 0\n while x <= n\n if (n - x) % 3 == 0\n return true\n end\n x += 7\n end\n return false\nend", "def prime?(n)\n\tif n < 2\n return false\n elsif n == 2 || n == 3 || n ==5 || n ==7 || n== 11 || n ==13 #finish for all prime numbers\n return true\n elsif n % 2 == 0|| n % 3 == 0 || n % 5 ==0 || n % 7 == 0 || n % 11 ==0 || n% 13 == 0#... finish for all prime numbers\n return false\n else\n return true\n end\nend", "def is_prime?(n)\n (2..(n-2)).detect{ |i| n % i == 0 }\nend", "def is_number_valid?(n)\n puts n\n # RANGE.detect {|i| !is_whole?(n.to_f / i)}.nil?\n i = 1\n i += 1 until !is_whole?(n.to_f / i)\n i >= MAX\nend", "def is_prime?(n)\n return false if n == 1\n (2..n-1).each do |divisor|\n return false if n % divisor == 0\n end\n true\nend", "def process n\n i = 1\n while (2**i <= n)\n i += 1\n end\n n == 2**(i-1)\nend", "def isPrime?(n)\n\ti = 2\n\twhile i < n\n\t\treturn false if n % i == 0\n\t\ti += 1\n\tend\n\treturn true\nend", "def prime?(n)\n if n <= 2\n return false\n end\n for d in 2..(n - 1)\n if (n % d) == 0\n return false\n end\n end\n true\nend", "def yra_lyginis(number)\n return true if number.even?\n end", "def one_to_twenty(num)\n arr = (1..20).to_a\n result = arr.map{|x| num % x}\n result = result.inject{|memo, x| memo + x}\n if result == 0\n true\n else \n false\n end\nend", "def is_prime?(n)\n i = 2\n while i < n\n if n == 2\n return true\n elsif n % i == 0\n return false\n end\n i += 1\n end\n true\nend", "def prime?(number)\n (2..(number-1)).each do |possible_factor|\n return false if number % possible_factor == 0\n end\n true\nend", "def is_prime?(n)\n if n <= 1\n return false\n elsif n == 2\n return true\n else\n (2..(n-1)).each do |num|\n if n % num == 0\n return false\n end\n end\n end\n return true\nend", "def is_prime?(n)\n\t(2..(n-1)).each {|i| return false if n % i == 0}\n\t\ttrue\nend", "def odd_integer(n)\n if n % 2 == 0 || n == 0\n return false\n else \n return true\n end\nend", "def prime?(n)\n factor = 2\n if n <= 1\n return false\n end\n if n == 2\n return true\n end\n if n == 3\n return true\n end\n if n % 2 == 0\n return false\n end\n if n % 3 == 0\n return false\n end\n if n < 12\n if n % 2 == 0\n return false\n end\n if n % 3 == 0\n return false\n end\n if n % 5 == 0\n return false\n end\n if n % 7 == 0\n return true\n end\n if n % 11 == 0\n return true\n end\n end\n \n ##################REVISIT FOR BETTER ALGORITHM/ASK INSTRUCTOR\n if n == 105557\n return true\n end\n i = 5 \n \n while i * i <= n\n if n % i == 0 or n % (i + 2) == 0\n return false\n end\n i += 6\n end\nend", "def is_prime?(n)\n\treturn n >= 1 if n <= 3\n\treturn false if n % 2 || n % 3 == 0\n\n\ti = 5 \n\twhile i*i <= n\n\t\treturn false if (n % i == 0 || n % (i + 2) == 0)\n\t\ti += 6\n\tend\n\n\ttrue\nend", "def prime?(n)\n return false if n == 1\n return true if n == 2\n\n (2..(Math.sqrt(n).to_i + 1)).each { |rn| return false if n % rn == 0 }\n\n true\nend", "def featured(num)\n num += 1\n num += 1 until num.odd? && (num % 7).zero?\n loop do\n return num if num.to_s.chars.size == num.to_s.chars.uniq.size\n num += 14\n break if num > 9_876_543_210\n end\n 'There is no possible number that fulfills those requirements'\nend", "def featured(int)\n int += 1\n int += 1 until int % 7 == 0 && int.odd?\n \n loop do\n double_check = int.to_s.split(\"\")\n if double_check.uniq == double_check\n return int\n else\n int += 14\n end \n break if int >= 9_876_543_210 \n end\n \"There is no possible number that fulfills those requirements\"\nend", "def good_guess? (number)\n\tnumber.to_i\n\tif number == 42\n\t\tp true\n\telse \n\t\tp false\n\tend\nend", "def is_fibonacci?(num)\n fibo_list = []\n penultimate_number = 0\n last_number = 1\n until last_number > num\n next_number = penultimate_number + last_number\n fibo_list << next_number\n penultimate_number = last_number\n last_number = next_number\n end\n return fibo_list.include? num\nend", "def sequential(number)\r\n # number.digits.reverse.each_with_index do |num, idx|\r\n # if idx + 1 == num\r\n # return true\r\n # end\r\n # end\r\n \r\n number.digits.reverse.all? {|num| num.index + 1 == num }\r\nend", "def sum_to_n?(numbers, n)\n\tif numbers.length == 0\n\t\tif n == 0\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\telse\n\t\treturn numbers.permutation(2).any?{|pair| pair.inject(:+) == n}\n\tend\nend", "def is_prime n\n for d in 2..(n - 1)\n if (n % d) == 0\n puts \"hi\"\n return false\n end\n end\nreturn true\nend", "def missing_sequence_of_two\n [1,2,3].each {|i|\n return true if count_dice_in_sequence(i, i+3) == 2\n }\n return false\n end", "def featured(int)\n loop do \n int += 1\n if int.odd? && int % 7 == 0\n return int if int.to_s.chars.uniq == int.to_s.chars\n end\n break if int == 9_999_999\n end\n \"There is no possible number that fulfils those requirements\"\nend", "def checkprime(n)\n if n == 2\n return true\n end\n \n for i in 2..Math.sqrt(n)\n if n % i == 0\n return false\n end\n end\n \n return true\nend", "def is_prime(number)\n if number == 1\n return true\n end\n 2.upto(number) do |x|\n if (number % x == 0) && (number != x)\n return false\n end\n end\n return true\nend", "def strong_num(n)\n array = n.to_s.chars.map(&:to_i)\n sumarray = []\n array.each do |number|\n sum = (1..number).inject(:*) || 1\n sumarray << sum\n end\n sumarray.sum == n ? \"STRONG!!!!\" : \"Not Strong !!\"\nend", "def g_happy(string)\n count_g = 0 \n next_to = 0 \n string.size.times do |n|\n if string[n] == \"g\"\n count_g += 1\n end\n if string[n] == \"g\" && string[n+1] == \"g\"\n next_to += 1\n end \n end \n if next_to == (count_g-1) \n return true\n else \n return false\n end \nend", "def is_fibonacci?(num)\n\tseeds = [0,1]\n\tnext_num = 0\n\twhile seeds.max <= num\n\t\tseeds.length.times do |i|\n\t\t\tnext_num = (seeds[i]+seeds[i-1])\n\t\tend\n\t\tseeds = seeds.push(next_num)\n\tend\n\treturn seeds.include?(num)\nend", "def is_prime? n\n for m in 2..(Math.sqrt(n))\n if n%m == 0\n return false\n end\n end\n return true\nend", "def s1(n)\n if n.even? then 0\n else 1 end\nend" ]
[ "0.8162589", "0.81556606", "0.8077448", "0.77234554", "0.76529074", "0.7349204", "0.72184724", "0.7118219", "0.669254", "0.65510374", "0.6503217", "0.6483044", "0.64699423", "0.6446987", "0.6402002", "0.6375336", "0.63509446", "0.63175166", "0.6305271", "0.6287781", "0.62600476", "0.62469876", "0.6235479", "0.6225135", "0.6223871", "0.620406", "0.62020534", "0.6201121", "0.6201121", "0.619274", "0.61828977", "0.61581457", "0.61489683", "0.6148871", "0.6139166", "0.61340934", "0.61251545", "0.61181647", "0.6097471", "0.6095861", "0.6092043", "0.60864407", "0.60864407", "0.60860777", "0.6083958", "0.60756654", "0.60695016", "0.6066462", "0.6063194", "0.6061676", "0.6053868", "0.6052169", "0.60406786", "0.6039724", "0.6038597", "0.6037937", "0.6033852", "0.6033558", "0.60274863", "0.6011878", "0.60104346", "0.60094696", "0.600746", "0.6005532", "0.60053605", "0.6001791", "0.5989547", "0.5988151", "0.59870356", "0.5985466", "0.59811205", "0.59808594", "0.5977796", "0.5972754", "0.59699273", "0.5965252", "0.59529686", "0.59509367", "0.59479046", "0.59471685", "0.5944686", "0.594349", "0.59419", "0.59373593", "0.5925721", "0.5924119", "0.5923361", "0.59209985", "0.5919594", "0.5917311", "0.5915665", "0.5909551", "0.5902861", "0.59012336", "0.58931315", "0.5891139", "0.5890732", "0.5890136", "0.58898443", "0.5889455" ]
0.77671945
3
add getter and setter methods
def initialize(year, bed_type) # add add bed_type param super(year) # add @bed_type = bed_type # add end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getters; end", "def setter_methods\n return @setter_methods if @setter_methods\n @setter_methods = get_setter_methods\n end", "def setter_methods\n return @setter_methods if @setter_methods\n @setter_methods = get_setter_methods\n end", "def name\n return @name\nend\ndef age\n return @age\nend\n#setters, allows you to change or set something\ndef name=(name)\n @name = name\nend", "def accessors\n self.class.accessors\n end", "def create_getter\n @model.class_eval <<-EOS, __FILE__, __LINE__\n #{reader_visibility}\n def #{@getter}\n attribute_get(#{name.inspect})\n end\n EOS\n\n if @primitive == TrueClass && !@model.instance_methods.include?(@name.to_s)\n @model.class_eval <<-EOS, __FILE__, __LINE__\n #{reader_visibility}\n alias #{@name} #{@getter}\n EOS\n end\n end", "def method_missing(meth, *args, &blk)\n match = meth.to_s.match(/^([a-zA-Z\\_]+)(=|$)$/)\n if match\n attribute, setter = match[1], !match[2].blank?\n if setter\n write_attribute(attribute, args.first)\n else\n read_attribute(attribute)\n end\n else\n super(meth, *args, &blk)\n end\n end", "def getter_method_names; end", "def inject_acl_object_getter_setter(method_name)\n inject_acl_object_check(method_name, :read)\n inject_acl_object_check(\"#{method_name}=\",:write)\n end", "def attr_accessor_sybling(method)\n attr_reader?(method) ? to_attr_writer(method) : to_attr_reader(method)\n end", "def define_attribute_methods\n return if generated_methods?\n property_names.each do |name|\n unless instance_method_already_implemented?(name)\n define_read_method(name.to_sym)\n end\n unless instance_method_already_implemented?(\"#{name}=\")\n define_write_method(name.to_sym)\n end\n unless instance_method_already_implemented?(\"#{name}?\")\n define_question_method(name)\n end\n end\n end", "def add_accessors(name, opts)\n name_equals = (name.to_s + \"=\").to_sym\n\n self.send(:define_method,name_equals) do |arg|\n attribute_set(name, arg)\n end\n self.send(:define_method,name) do \n attribute_get(name)\n end\n\n end", "def create_getters\n self.class::ATTRS.each do |method_name|\n self.class.class_eval do\n define_method(method_name) do\n get_webpage\n eval(\"scrape_#{method_name}\")\n eval(\"@#{method_name}\")\n end\n end\n end\n end", "def setter_to_getter(node); end", "def add_instance_getters_and_setters(var)\n singleton = (class << self; self end)\n singleton.send :define_method, var.to_sym do\n instance_variable_get \"@#{var}\"\n end\n singleton.send :define_method, \"#{var}=\".to_sym do |val|\n instance_variable_set \"@#{var}\", val\n end\n end", "def create_accessors(name, meth, options = {})\n field = fields[name]\n generated_field_methods.module_eval do\n if field.cast_on_read?\n define_method(meth) do\n field.get(read_attribute(name))\n end\n else\n define_method(meth) do\n read_attribute(name)\n end\n end\n define_method(\"#{meth}=\") do |value|\n write_attribute(name, value)\n end\n define_method(\"#{meth}?\") do\n attr = read_attribute(name)\n (options[:type] == Boolean) ? attr == true : attr.present?\n end\n end\n end", "def define_accessor_methods(mod)\n define_reader_method(mod)\n define_writer_method(mod)\n self\n end", "def method_missing(method, *args, &block)\n \n # The getter\n if @metadata.has_key?(method)\n return attribute_get(method)\n else\n # The setter\n \n if (attribute=method.to_s.match(/(.+)=$/).to_a.last)\n attribute_set(attribute, args.first)\n return\n end\n end\n \n super\n \n end", "def create_accessors(name, meth, options = {})\n field = fields[name]\n create_field_getter(name, meth, field)\n create_field_setter(name, meth, field)\n end", "def define_accessors\n self.metadata.properties_and_identity.each do |name, _|\n self.model.send :attr_accessor, name.downcase\n end\n end", "def create_getters\n instance_variables.each do |v|\n define_singleton_method(v.to_s.tr('@','')) do\n instance_variable_get(v)\n end\n end\n end", "def create_property_method\n @resource.class.properties.each do |type|\n name = type.name\n self.class.send(:define_method, name) do\n get_value(name)\n end\n self.class.send(:define_method, \"#{name}=\") do |value|\n set_value(name,resource[name])\n end\n end\n end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def method_missing(meth,*args,&block)\n\n method = meth.to_s # convert method name to a string\n setter = method.end_with?('=') # determine if this is a setter method (which would have the last character \"=\" in the method name)\n attribute = setter ? method.chop : method # the attribute name needs to have the \"=\" removed if it is a setter\n multivalued_field = attribute.end_with?(self.class.multivalued_field_marker) # in place editing fields can end with the special character marker, which will join arrays when return; and split them when setting\n attribute.gsub!(self.class.multivalued_field_marker,'') if multivalued_field\n\n solr_field_config=self.class.field_mappings[attribute.downcase.to_sym] # lookup the solr field for this accessor\n if solr_field_config\n solr_field_name=solr_field_config[:field].downcase\n default_value=solr_field_config[:default] || ''\n if setter # if it is a setter, cache the edit if it has changed\n old_values=self[solr_field_name]\n new_values=args.first\n if !self.class.is_equal?(old_values,new_values,multivalued_field) # we should only cache the edit if it actually changed\n value = (multivalued_field ? new_values.split(\"|\") : new_values) # split the values when setting if this is an in place edit field\n cache_edit({solr_field_name.to_sym=>value})\n return value\n else\n return old_values\n end\n else # if it is a getter, return the value\n value = unsaved_edits[solr_field_name.to_sym] || self[solr_field_name] # get the field value, either from unsaved edits or from solr document\n value = default_value if value.blank?\n return (multivalued_field && value.class == Array ? value.join(\" | \") : value) # return a joined value if this is an in place edit field, otherwise just return the value\n end\n else\n super # we couldn't find any solr fields configured, so just send it to super\n end\n\n end", "def method_missing(method, *args, &block)\n meth, setter = /^(.*?)(=?)$/.match(method).values_at(1,2)\n if valid_temporal_attribute?(meth.to_sym) \n setter.empty? ? get(meth, *args) : set(meth, *args)\n else super\n end\n end", "def define_accessors attribute_name\n define_getter attribute_name\n define_setter attribute_name\n\n self.attribute_names ||= []\n attribute_names << attribute_name.to_s\n attribute_names.uniq!\n end", "def def_set_accessor(key)\n key = key.to_sym\n raise ArgumentError.new('Invalid entry type: %s' % key) if respond_to?(key)\n metaclass.class_eval do\n define_method(key) {|*val| val.size > 0 ? (self[key] ||= Set.new).merge(val) : self[key] }\n define_method(\"#{key}!\") {|*val| val.size > 0 ? (cache[key] ||= Set.new).merge(val) : cache[key] }\n end\n end", "def method_missing(method,val=nil)\n if val.nil?\n get(method)\n else\n method = method.to_s[0..-2].to_sym # get rid of = sign\n set(method,val)\n end\n end", "def create_accessors!\n self.each do |key,val|\n create_accessor_for(key)\n end\n end", "def define_getter_for(name)\n define_method(\"#{name}\") do\n instance_variable_get(\"@#{name}\") or\n instance_variable_set(\"@#{name}\", deserialize(name)) or\n instance_variable_set(\"@#{name}\", load_associated(name))\n end\n end", "def _define_method(method)\n #Getters\n self.class.send(:define_method, method) do\n _get method.to_sym\n end\n\n #Setters\n self.class.send(:define_method, \"#{method.to_s}=\") do |value|\n _set method, value\n end\n\n #Incrementer\n self.class.send(:define_method, \"inc_#{method.to_s}\") do |*args|\n value = args.first || 1\n _inc method, value\n end\n\n #Decrementer\n self.class.send(:define_method, \"dec_#{method.to_s}\") do |*args|\n value = args.first || 1\n _dec method, value\n end\n end", "def create_accessors(attribute_name)\n class_eval do\n define_method(attribute_name) do\n odata_entity[property_map[attribute_name]]\n end\n\n define_method(\"#{attribute_name}=\") do |value|\n # unless entity[property_map[attribute_name]] == value\n # send(\"#{attribute_name}_will_change!\") if defined?(::ActiveModel)\n # end\n\n odata_entity[property_map[attribute_name]] = value\n end\n end\n\n nil\n end", "def define_getter\n name = @name\n klass.send :define_method, \"#{name}\" do\n return unless send(\"#{name}?\")\n Unitwise(send(\"#{name}_value\"), send(\"#{name}_unit\"))\n end\n end", "def metaattr_accessor(*meths)\n metaclass.instance_eval{attr_accessor(*meths)}\n end", "def create_accessors(name, meth, options = {})\n define_method(meth) { read_attribute(name) }\n define_method(\"#{meth}=\") { |value| write_attribute(name, value) }\n define_method(\"#{meth}?\") do\n attr = read_attribute(name)\n (options[:type] == Boolean) ? attr == true : attr.present?\n end\n end", "def get_setter_methods\n meths = instance_methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if primary_key && restrict_primary_key?\n meths\n end", "def setter_methods(type)\n if type == :default && !@singleton_setter_added\n return model.setter_methods\n end\n\n meths = methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if primary_key && model.restrict_primary_key?\n meths\n end", "def methods() end", "def create_getter\n @model.class_eval <<-EOS, __FILE__, __LINE__\n #{reader_visibility}\n def #{@getter}\n self[#{name.inspect}]\n end\n EOS\n end", "def representable_property(name, options={})\n attr = add_representable_property(name, options)\n \n attr_reader(attr.getter) unless options[:accessors] == false\n attr_writer(attr.getter) unless options[:accessors] == false\n end", "def method_missing(method, *args, &block)\n if method[-1] == '='\n # setter\n key = method.slice(0...-1).to_sym\n\n unless has_key?(key)\n super\n end\n self[key] = args[0]\n else\n unless has_key?(method)\n super\n end\n\n prop = self[method]\n if prop.is_a? JSFunction\n prop.call_with_instance(self, *args, &block)\n else\n prop\n end\n end\n end", "def create_getter(name, meth)\n define_method(meth) do\n read_attribute(name)\n end\n end", "def add_attr_accessors(p_attributes, p_type = :both)\n p_type.to_h.assert_valid_keys(:read, :write, :both) #validate type\n\n #loop through the accessors to be added\n Array(p_attributes).flatten.each do |k|\n\n #lets set the write reader if needed\n if [:read, :both].include?(p_type) && !self.respond_to?(k.to_s) #is there already one defined\n self.class.send(:define_method, k.to_sym) do #lets create one as requested\n instance_variable_get('@' + k.to_s) # equivalent of an attr_reader is created here\n end\n end\n\n # Lets set the write accessor if needed\n if [:write, :both].include?(p_type) && !self.respond_to?(\"#{k.to_s}=\") #is there already one defined\n self.class.send(:define_method, \"#{k}=\".to_sym) do |value| #lets create one as requested\n instance_variable_set(\"@\" + k.to_s, value) # equivalent of an attr_writer is created here\n end\n end\n\n end # end p_attributes..do\n self #all done return self\n end", "def add_setting_accessors( name, options, &writer_hook )\n\t\tif options[:use_class_vars]\n\t\t\tself.target.class_variable_set( \"@@#{name}\", nil )\n\t\telse\n\t\t\tself.target.instance_variable_set( \"@#{name}\", nil )\n\t\tend\n\n\t\treader = self.make_setting_reader( name, options )\n\t\twriter = self.make_setting_writer( name, options, &writer_hook )\n\n\t\tself.target.define_singleton_method( \"#{name}\", &reader )\n\t\tself.target.define_singleton_method( \"#{name}=\", &writer )\n\n\t\tif options[:predicate]\n\t\t\tpredicate = self.make_setting_predicate( name, options )\n\t\t\tself.target.define_singleton_method( \"#{name}?\", &predicate )\n\t\tend\n\tend", "def attr_reader(*)\n end", "def define_attribute_methods\n return if attribute_methods_generated?\n @attributes.each_pair do |k,v|\n self.class.module_eval %Q?\n def #{k}\n read_attribute :#{k}\n end\n def #{k}=(value)\n write_attribute :#{k},value\n end\n ?\n end\n self.class.attribute_methods_generated = true\n end", "def def_accessor(key)\n key = key.to_sym\n raise ArgumentError.new('Invalid entry type: %s' % key) if respond_to?(key)\n metaclass.class_eval do\n define_method(key) {|*a| a.size > 0 ? (self[key] = a[0]) : self[key] }\n define_method(\"#{key}=\") {|val| self[key] = val }\n define_method(\"#{key}!\") {|val| cache[key] = val }\n end\n end", "def create_accessors!\n instance.each do |key,val|\n create_accessor_for(key)\n end\n end", "def create_setters\n schema_fields.keys.each do |key|\n self.class.send(:define_method, \"#{key.to_s}=\".to_sym) do |value| \n @data[key] = value #get_value key, value\n end\n end\n end", "def create_accessors(field_name)\n define_singleton_method(field_name) { read_attribute(field_name) }\n define_singleton_method(\"#{field_name}=\") { |value| write_attribute(field_name, value) }\n end", "def methods\n super + property.keys.map { |v| [\"configure_#{v}\".to_sym, \"request_#{v}\".to_sym] }.flatten\n end", "def add_attr_accessors_to_self\n instance_variables.each do |name|\n method_name = name[1..-1].to_sym\n MetricFu::Configuration.send(:attr_accessor, method_name)\n end\n end", "def generated_property_methods\n @generated_property_methods ||= begin\n mod = const_set(:GeneratedPropertyMethods, Module.new)\n include mod\n mod\n end\n end", "def add_accessors(column, name, position, default)\n mask = (1 << position)\n self.bitflags[name] = mask\n if default \n self.default_mask += mask\n end\n \n # now the instance accessors\n # return true/false\n define_method( (name + '?').to_sym ) do\n bits = self[column] ||= 0\n bits[position].eql? 1\n end\n \n # set with true/false \n define_method( (name + '=').to_sym ) do |v|\n bits = self[column] ||= 0\n flag = [ \"true\", '1', 'yes', 'ok' ].include? v.to_s.downcase\n self[column] = flag ? bits |= mask : bits &= ~mask\n end\n \n # make this easy for the form builders like 'check_box' to use standard accessors\n define_method( name.to_sym ) do\n bits = self[column] ||= 0\n bits[position].eql? 1\n end\n \n end", "def attr_writer(sym, *more) end", "def delegate_object_reader_method; end", "def define_getter_for(name, property_name: name)\n return if getters.include?(name)\n define_method(name) { |&block| self.[](property_name, &block) }\n getters << name\n end", "def get_setter_methods\n if allowed_columns\n # SEQUEL5: Remove allowed_columns handling\n allowed_columns.map{|x| \"#{x}=\"}\n else\n meths = instance_methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if primary_key && restrict_primary_key?\n meths\n end\n end", "def field_accessors(name)\n field_reader(name)\n attr_writer(name)\n end", "def add_reader_tags(klass, new_method, member)\n member_tag = member_tag_for_member(klass, member, :read)\n return_type = return_type_from_tag(member_tag)\n getter_doc_text = member_tag ? member_tag.text : \"Returns the value of attribute #{member}\"\n new_method.docstring.replace(getter_doc_text)\n new_method.add_tag YARD::Tags::Tag.new(:return, \"the current value of #{member}\", return_type)\n end", "def method_missing(method, *args, &block)\n if Parser::PROPERTIES.include?(method)\n self.class.define_property_method(method)\n send(method, *args, &block)\n elsif Parser::METHODS.include?(method)\n self.class.define_method_method(method)\n send(method, *args, &block)\n elsif method.to_s =~ /([a-z_]+)\\?/ and (Parser::PROPERTIES + Parser::METHODS).include?($1.to_sym)\n self.class.define_question_method($1)\n send(method)\n else\n super\n end\n end", "def md_accessor(*accessors)\n md_reader(*accessors)\n md_writer(*accessors)\n end", "def to_getter\n\t\t\t\tis_setter? ? self.to_s[0...-1].to_sym : self\n\t\t\tend", "def method_missing(method, *args)\n if method.to_s[-1,1] == '='\n self.put(method.to_s.tr('=',''), *args)\n else\n self.get(method)\n end\n end", "def to_setter\n\t\t\t\t(to_getter.to_s+\"=\").to_sym\n\t\t\tend", "def define_attribute_methods\n super\n self.generated_methods.each do |method|\n if method.to_s =~ Regexp.new(\"^#{self.to_s.underscore}__\")\n new_method_name = $~.post_match\n alias_method(new_method_name, method)\n private method\n self.generated_methods << new_method_name\n end\n end\n end", "def key_attr_reader(key)\n define_method key do\n self[key]\n end\n end", "def mattr_accessor(*syms)\n mattr_reader(*syms) + mattr_writer(*syms)\n end", "def attr_writer(name)\n meth = Rubinius::AccessVariable.set_ivar name\n @method_table.store \"#{name}=\".to_sym, meth, :public\n Rubinius::VM.reset_method_cache name\n nil\n end", "def method_missing(name, *args, &block)\n return super unless block.nil? # don't do anything if handed a block\n return super if name =~ /^find_$/ # superclass wants to handle these itself\n \n str = name.to_s\n if str.end_with?('=') # setter method?\n return super unless args.size == 1 # don't do anything unless we have a single argument\n \n # create a new instance method\n base_name = str[0..-2].intern\n _singleton_class.instance_exec(name) do |name|\n define_method(name) do |value|\n @written_md_vars[base_name.to_sym] = (value.nil? ? false : true)\n @metadata[base_name.to_s] = value\n end\n end\n \n # manually set the value now\n @written_md_vars[base_name.to_sym] = (args[0].nil? ? false : true)\n @metadata[base_name.to_s] = args[0]\n else # getter method\n return super unless args.size == 0 # don't override if there are args\n return super unless @metadata.has_key? str\n \n # create a new instance method ready for next time\n _singleton_class.instance_exec(name) do |name|\n define_method(name) do\n @metadata[str]\n end\n end \n \n # return the value from metadata now\n @metadata[str]\n end\n end", "def method_missing(method, *args)\n # Give OpenStruct a chance to create getters and setters for the\n # corresponding field\n super method, *args\n\n if field = setter?(method)\n # override setter logic to apply any existing sanitization rules before\n # assigning the new value to the field\n override_setter_for(field) if sanitize?(field)\n # uses the newly created setter to set the field's value and apply any\n # existing sanitization rules\n send(method, args[0])\n end\n end", "def create_getter!\n @target.class_eval <<-EOS\n #{reader_visibility.to_s}\n def #{name}\n attribute_get(#{name.inspect})\n end\n EOS\n \n if type == TrueClass\n @target.class_eval <<-EOS\n #{reader_visibility.to_s}\n def #{name.to_s.ensure_ends_with('?')}\n attribute_get(#{name.inspect})\n end\n EOS\n end\n rescue SyntaxError\n raise SyntaxError.new(column)\n end", "def method_missing(method, *args)\n PROPERTIES.has_key?(method.to_sym) ? self[method.to_sym] : super\n end", "def attribute_setter_getter(attribute)\n define_method attribute.to_s.to_sym do |value = nil|\n if value.nil?\n instance_variable_get \"@#{attribute}\"\n else\n instance_variable_set \"@#{attribute}\", value\n end\n end\nend", "def create_field_setter(name, meth, field)\n generated_methods.module_eval do\n define_method(\"#{ meth }=\") do |value|\n instance_variable_set \"@#{ name }\", value\n end\n end\n end", "def method_missing(method, *args)\n is_set_method = (method.to_s =~ /(.*)=$/)\n key = is_set_method ? $1 : method.to_s\n # No such key\n super unless @data.has_key?(key)\n # Set\n return @data[key] = args[0] if is_set_method\n # Get\n return @data[key]\n end", "def methods=(value)\n @methods = value\n end", "def method_missing(method_name, *args, &block)\n # Check if the method missing an \"attr=\" method\n raise unless method_name.to_s.end_with?(\"=\")\n\n setter = method_name\n getter = method_name.to_s.slice(0...-1).to_sym\n instance_var = \"@#{getter}\".to_sym\n\n # attr_writer\n define_singleton_method(setter) do |new_val|\n instance_variable_set(instance_var, new_val)\n end\n\n # attr_reader\n define_singleton_method(getter) { instance_variable_get(instance_var) }\n\n # Ignores all arguments but the first one\n value = args[0]\n\n # Actually sets the value on the instance variable\n send(setter, value)\n rescue MethodMissing\n # Raise error as normal, nothing to see here\n super(method_name, *args, &block)\n end", "def get_setters!\r\n return @extended_spec.first.get_setter!.merge(@setters) if !@extended_spec.empty?\r\n return @setters\r\n end", "def create_accessor_for(name, extensions)\n define_method name do |*args|\n if args.length == 0\n attributes[name].tap do |out|\n extensions.each do |extension|\n out.extend( extension )\n end\n end\n else\n send(\"#{name}=\", *args)\n self\n end \n end\n end", "def properties\n decorate_with_methods(read_attribute(:properties))\n end", "def create_setter(name, meth)\n define_method(\"#{meth}=\") do |value|\n write_attribute(name, value)\n end\n end", "def method_missing(method_name, *args, &block)\n if method_name.to_s.end_with?('=')\n set_attribute(method_name, *args)\n elsif has_attribute?(method_name)\n get_attribute(method_name)\n else\n super\n end\n end", "def setter_methods(type)\n if type == :default\n if !@singleton_setter_added || model.allowed_columns # SEQUEL5: Remove model.allowed_columns\n return model.setter_methods\n end\n end\n\n if type.is_a?(Array)\n type.map{|x| \"#{x}=\"}\n else\n meths = methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if type != :all && primary_key && model.restrict_primary_key?\n meths\n end\n end", "def get\n raise NotImplementedError\n end", "def define_methods_for(field)\n generic_reader(field)\n case field.type\n when Symbol\n send(\"#{field.type}_writer\", field)\n when String\n typed_writer(field)\n end\n end", "def accessor\n @@accessor ||= nil\n @@accessor\n end", "def method_missing(meth, *args)\n return if not method_missing_hook(meth, args)\n\n d = self.class.structure_field_names\n m = meth.to_s\n\n setter = (m[-1].chr == \"=\") ? true : false\n m = m[0..-2] if setter\n\n puts \"WARNING: assignment to @value as struct field\" if setter and m == \"value\"\n\n if (i = d[m.intern])\n if setter\n self[m.intern] = args[0]\n else\n self[m.intern]\n end\n else\n super(meth, *args)\n end\n end", "def expose!\n expose_attribute!\n expose_helper_methods!\n end", "def getter_method_names\n @getter_method_names ||= instance_methods.map!(&:to_s).tap do |list|\n list.reject! { |item| item.end_with?(\"=\") }\n end\n end", "def getter\r\n @getter ||= Field.getter(@name)\r\n end", "def define_attribute_methods\n define_method :saved_changes do\n (@previously_changed ||= ActiveSupport::HashWithIndifferentAccess.new).merge(super())\n end\n\n @attribute_names.each do |name|\n define_method :\"saved_change_to_#{name}?\" do\n previous_changes.include?(Mobility.normalize_locale_accessor(name))\n end\n\n define_method :\"saved_change_to_#{name}\" do\n previous_changes[Mobility.normalize_locale_accessor(name)]\n end\n\n define_method :\"#{name}_before_last_save\" do\n previous_changes[Mobility.normalize_locale_accessor(name)].first\n end\n\n alias_method :\"will_save_change_to_#{name}?\", :\"#{name}_changed?\"\n alias_method :\"#{name}_change_to_be_saved\", :\"#{name}_change\"\n alias_method :\"#{name}_in_database\", :\"#{name}_was\"\n end\n end", "def def_accessor(key)\n raise ArgumentError.new('Invalid entry type: %s' % key) if respond_to?(key)\n\n class << self; self end.class_eval do\n define_method(key) { |*args| val = args.first; val ? (self[key]=val) : self[key] }\n define_method(\"#{key}=\") { |val| self[key] = val }\n define_method(\"#{key}!\") { |val| cache[key] = val }\n end\n end", "def create_accessors\n @buckets.keys.each do |bucket_name|\n class_eval do\n # Define the getter.\n define_method(bucket_name) do\n @buckets[bucket_name]\n end\n # Define the setter.\n define_method(\"#{bucket_name}=\") do |new_value|\n @buckets[bucket_name] = new_value\n end\n end\n end \n end", "def add_reader_tags(klass, new_method, member); end", "def internal_attr_accessor(*syms)\n internal_attr_reader(*syms)\n internal_attr_writer(*syms)\n end", "def method_added(meth)\n clear_setter_methods_cache if meth.to_s.end_with?('=')\n super\n end", "def method_added(meth)\n clear_setter_methods_cache if meth.to_s.end_with?('=')\n super\n end" ]
[ "0.77670574", "0.70840245", "0.70840245", "0.6843785", "0.67145234", "0.6654084", "0.6647551", "0.6643148", "0.662397", "0.65693176", "0.65496945", "0.653281", "0.6525444", "0.65035874", "0.64805615", "0.64593333", "0.64262307", "0.64222443", "0.6397445", "0.6364543", "0.6339052", "0.63349134", "0.63205063", "0.63205063", "0.63205063", "0.63205063", "0.6304709", "0.62943715", "0.62921286", "0.6289216", "0.6282896", "0.62740105", "0.62715995", "0.62542427", "0.6242784", "0.62159556", "0.62011826", "0.6185568", "0.6183944", "0.61782384", "0.61674064", "0.61452526", "0.6132319", "0.61215687", "0.6113594", "0.61079586", "0.60979855", "0.60699385", "0.6069503", "0.6069251", "0.60663784", "0.6066314", "0.6033502", "0.6018267", "0.60182464", "0.6006718", "0.6005732", "0.6004768", "0.59809226", "0.5980822", "0.59700114", "0.5963111", "0.5953468", "0.59437084", "0.5932762", "0.59169", "0.5915209", "0.5914176", "0.5899674", "0.58981067", "0.58974975", "0.58934", "0.5890553", "0.58892787", "0.58862954", "0.58769345", "0.5875511", "0.58727896", "0.58727163", "0.58702976", "0.5866256", "0.58360493", "0.5834778", "0.5831241", "0.5828595", "0.5822853", "0.58177584", "0.5805828", "0.5794847", "0.5794827", "0.57925034", "0.57851005", "0.5783777", "0.57812804", "0.577779", "0.57773304", "0.57662034", "0.5764419", "0.57613766", "0.57599646", "0.57599646" ]
0.0
-1
piece parsers bottom to top
def interval0(i) rex(:interval0, i, /(year|month|week|day|hour|min(ute)?|sec(ond)?)(?![a-z])/i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(board, color, move_str)\n str = move_str.gsub(/[+\\#!]/, '')\n capture = str.delete!('x')\n\n # the promotion piece setting, e.g. h8=Q\n if str =~ /^.*(=.).*$/\n Pawn.set_promotion_piece(color, \n Board::PieceLetterMap.detect{|k,v| v.include?($1[1,1])}[0])\n str.gsub!($1, '')\n end\n \n case str.length\n when 2\n move_to = send(str)\n piece_pos = [move_to[0], move_to[1] - Piece.advance_direction(color)]\n piece = board.at(piece_pos)\n piece ||= board.at([piece_pos[0], \n piece_pos[1] - Piece.advance_direction(color)])\n \n mv = piece ? piece.moves.detect{|m| m.to == move_to} : nil\n \n when 3\n if str == 'O-O'\n mv = board.king(color).moves.detect{|m| m.to_s == 'O-O'}\n else\n c = str[0,1]\n move_to = send(str[1,2])\n \n if c == c.capitalize\n klass = Board::PieceLetterMap.detect{|k,v| v.include?(c)}[0]\n moves = board.pieces.select do |p|\n p.class == klass and p.color == color\n end.map(&:moves).flatten\n mv = moves.detect{|m| m.to == move_to}\n elsif capture\n x_diff = str[0,1] > str[1,1] ? 1 : -1\n \n pieces = board.pieces.select do |p| \n p.class == Pawn and p.color == color and \\\n p.x == move_to[0] + x_diff\n end\n \n mv = pieces.map{|p| p.moves}.flatten.detect{|m| [move_to, [move_to[0], move_to[1]+m.piece.advance_direction]].include?(m.to)}\n end\n end\n \n when 4\n c = str[0,1]\n move_to = send(str[2,2])\n \n if c == c.capitalize\n klass = Board::PieceLetterMap.detect{|k,v| v.include?(c)}[0]\n x_diff = nil\n y_pos = nil\n if str[1,1] <= '9'\n y_pos = str[1,1].to_i - 1\n else\n x_diff = str[1] - str[2]\n end\n piece = board.pieces.detect do |p|\n p.class == klass and p.color == color and \\\n (x_diff ? p.x == move_to[0] + x_diff : p.y == y_pos)\n end\n mv = piece ? piece.moves.detect{|m| m.to == move_to} : nil\n else\n move_from = send(str[0,2])\n piece = board.at(move_from)\n mv = piece ? piece.moves.detect{|m| m.to == move_to} : nil\n end\n \n when 5\n if str == 'O-O-O'\n mv = board.king(color).moves.detect{|m| m.to_s == 'O-O-O'}\n else\n move_from = send(str[1,2])\n move_to = send(str[3,2])\n piece = board.at(move_from)\n mv = piece ? piece.moves.detect{|m| m.to == move_to} : nil\n end\n end\n \n raise ParseError.new(\"Invalid move: #{move_str}\") if mv.nil?\n \n mv\n end", "def parse_moves\n s0 = @scanner.pos\n s1 = parse_firstboard\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n parse_split\n s2 = []\n s3 = parse_move\n while s3 != :failed\n s2 << s3\n s3 = parse_move\n end\n parse_result\n @reported_pos = s0\n s0 = s2.unshift(s1)\n end\n s0\n end", "def parse_firstboard\n s0 = @scanner.pos\n s1 = []\n s2 = parse_comment\n while s2 != :failed\n s1 << s2\n s2 = parse_comment\n end\n parse_pointer\n @reported_pos = s0\n s1.empty? ? {} : { 'comments' => s1 }\n end", "def parse_firstboard\n s0 = @scanner.pos\n s1 = []\n s2 = parse_comment\n while s2 != :failed\n s1 << s2\n s2 = parse_comment\n end\n parse_pointer\n @reported_pos = s0\n s1.empty? ? {} : { 'comments' => s1 }\n end", "def gen_bishop_moves(color, piece=:bishop)\n moves = []\n if color == :white\n position = @position.white \n comrades = @position.white_pieces\n enemy = @position.black_pieces\n else\n position = @position.black\n comrades = @position.black_pieces\n enemy = @position.white_pieces\n end\n\n # no work to do when there are no pieces\n return moves if position[piece].nil?\n \n # for each piece\n position[piece].set_bits.each do |from| \n # [i,j] = current position\n i = from / 8\n j = from % 8\n\n #dirs flags which directions the piece is blocked\n dirs = 0\n for k in 1..7\n break if dirs == 0xf\n \n # try moving north-east\n if (dirs & 0x1) != 0x1\n to = from+k*9\n if i+k>7 || j+k>7 || comrades.set?(to)\n # no further north-east moves possible\n dirs = dirs | 0x1\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x1 if enemy.set?(to) \n end\n end\n \n # try moving south-west\n if (dirs & 0x2) != 0x2\n to = from-k*9\n if i<k || j<k || comrades.set?(to)\n # no further south-west moves possible\n dirs = dirs | 0x2\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further south-west moves possible\n dirs = dirs | 0x2 if enemy.set?(to) \n end\n end\n \n # try moving north-west\n if (dirs & 0x4) != 0x4\n to = from+k*7\n if i+k>7 || j<k || comrades.set?(to)\n # no further north-west moves possible\n dirs = dirs | 0x4\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north-west moves possible\n dirs = dirs | 0x4 if enemy.set?(to) \n end\n end \n \n # try moving south-east\n if (dirs & 0x8) != 0x8\n to = from-k*7\n if i<k || j+k>7 || comrades.set?(to)\n # no further south-east moves possible\n dirs = dirs | 0x8\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further south-east moves possible\n dirs = dirs | 0x8 if enemy.set?(to) \n end\n end\n \n end\n end \n moves\n end", "def starting_pieces(color)\n #8 pieces total\n i = (color == :white) ? [0,1] : [6,7]\n\n 8.times do |j| #build back row pieces\n if (j+i[0]).odd?\n c = Piece.new(color, [i[0],j])\n @pieces << c\n end\n end\n\n 8.times do |j| #build front row pieces\n if (j+i[0]).even?\n c = Piece.new(color, [i[1],j])\n @pieces << c\n end\n end\n end", "def parse\n @parts = []\n\n sect = text.split(/^\\-\\-\\-/)\n\n if sect.size == 1\n @header = {}\n @parts << Part.new(sect[0]) #, *[@stencil, @default].compact.flatten)\n else\n sect.shift if sect.first.strip.empty?\n\n head = sect.shift\n head = YAML::load(head)\n parse_header(head)\n\n sect.each do |body|\n index = body.index(\"\\n\")\n formats = body[0...index].strip\n formats = formats.split(/\\s+/) if String===formats\n #formats = @default if formats.empty?\n #formats.unshift(@stencil) if @stencil\n text = body[index+1..-1]\n @parts << Part.new(text, *formats)\n end\n end\n end", "def parse_moves\n s0 = @scanner.pos\n s1 = parse_firstboard\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = []\n s3 = parse_move\n while s3 != :failed\n s2 << s3\n s3 = parse_move\n end\n s3 = parse_result\n s3 = nil if s3 == :failed\n @reported_pos = s0\n s0 = -> (hd, tl, res) do\n tl.unshift(hd)\n tl << { 'special' => res } if res && !tl[tl.length - 1]['special']\n tl\n end.call(s1, s2, s3)\n end\n s0\n end", "def parse_board(lines)\n i = -1\n Board.new(\n lines.inject([]) do |memo, raw_line|\n memo += segments_from_line(raw_line, i+=1)\n memo\n end\n )\n end", "def parse_move(move)\n #Is this enough of a repetition for me to iterate? It seemed more\n #tedious for me to iterate in this situation\n from = [(8-(move[0][1].to_i)), ((\"a\"..\"h\").to_a.index(move[0][0]))]\n to = [(8-(move[1][1].to_i)), ((\"a\"..\"h\").to_a.index(move[1][0]))]\n [from, to]\n end", "def parse_initialboard\n s0 = s1 = @scanner.pos\n if match_space == :failed\n @scanner.pos = s1\n else\n parse_nonls\n s2 = parse_nl\n @scanner.pos = s1 if s2 == :failed\n end\n s2 = @scanner.pos\n if match_str('+') == :failed\n @scanner.pos = s2\n else\n parse_nonls\n @scanner.pos = s2 if parse_nl == :failed\n end\n s4 = parse_ikkatsuline\n if s4 == :failed\n s3 = :failed\n else\n s3 = []\n while s4 != :failed\n s3 << s4\n s4 = parse_ikkatsuline\n end\n end\n if s3 == :failed\n @scanner.pos = s0\n :failed\n else\n s4 = @scanner.pos\n if match_str('+') == :failed\n @scanner.pos = s4\n else\n parse_nonls\n @scanner.pos = s4 if parse_nl == :failed\n end\n @reported_pos = s0\n transform_initialboard(s3)\n end\n end", "def gen_rook_moves(color, piece=:rook)\n moves = []\n if color == :white\n position = @position.white \n comrades = @position.white_pieces\n enemy = @position.black_pieces\n else\n position = @position.black\n comrades = @position.black_pieces\n enemy = @position.white_pieces\n end\n\n # no work to do when there are no pieces\n return moves if position[piece].nil?\n \n # for each piece\n position[piece].set_bits.each do |from| \n # [i,j] = current position\n i = from / 8\n j = from % 8\n\n #dirs flags which directions the piece is blocked\n dirs = 0\n for k in 1..7\n break if dirs == 0xf\n \n # try moving north\n if (dirs & 0x1) != 0x1\n to = from+k*8\n if i+k>7 || comrades.set?(to)\n # no further north moves possible\n dirs = dirs | 0x1\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x1 if enemy.set?(to) \n end\n end\n \n # try moving south\n if (dirs & 0x2) != 0x2\n to = from-k*8\n if i<k || comrades.set?(to)\n # no further south moves possible\n dirs = dirs | 0x2\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x2 if enemy.set?(to) \n end\n end\n \n # try moving east\n if (dirs & 0x4) != 0x4\n to = from+k\n if j+k>7 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x4\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further east moves possible\n dirs = dirs | 0x4 if enemy.set?(to) \n end\n end\n \n # try moving west\n if (dirs & 0x8) != 0x8\n to = from-k\n if j-k<0 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x8\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further west moves possible\n dirs = dirs | 0x8 if enemy.set?(to) \n end\n end \n end\n end \n moves\n end", "def parsed_range(splits)\n last_tuple = splits.pop\n body_of(splits) + head_of(last_tuple)\n end", "def next_piece\n @current_block = MyPiece.next_piece(self)\n @current_pos = nil\n end", "def parse\n start_x = 0\n start_y = 0\n\n @maze.each_with_index do |line, index|\n if line.include? 'S'\n start_y = line.index('S')\n start_x = index\n break\n end\n end\n [start_x, start_y]\n end", "def next_piece\n if @cheat then\n @current_block = MyPiece.new([[[0,0]]],self)\n @cheat = false\n else\n @current_block= MyPiece.next_piece(self)\n end\n @current_pos = nil\n end", "def bottomToTopWraparound(grid, width, height)\n\n strings = bottomToTop(grid, width, height)\n\n for string in strings do\n\n string << string\n\n end\n\n return strings\n\nend", "def get_moves(pieces)\n\t\tarrPos = [] \n\t\tif team == 1\n\t\t\tarrPos << [@xCord, @yCord + 1] if square_is_open?(pieces, [@xCord, @yCord + 1])\n\t\t\tarrPos << [@xCord, @yCord + 2] if @yCord == 1 && square_is_open?(pieces, [@xCord, @yCord + 2])\n\t\telsif team == 2\n\t\t\tarrPos << [@xCord, @yCord - 1] if square_is_open?(pieces, [@xCord, @yCord - 1])\n\t\t\tarrPos << [@xCord, @yCord - 2] if @yCord == 6 && square_is_open?(pieces, [@xCord, @yCord - 2])\n\t\tend\n\t\tarrPos\n\tend", "def pieces\n list = []\n n = @data['info']['pieces'].bytesize / PIECE_SIZE\n n.times do |i|\n list << @data['info']['pieces'][(i * PIECE_SIZE)..(i * PIECE_SIZE + PIECE_SIZE - 1)]\n end\n list\n end", "def chop() end", "def chop() end", "def next_part\n nl \"#{algn\"|::#{id_name}: search_space\"}#{search_space.inspect}\", 3\n nl \"#{algn\"|::#{id_name}: limit\"}#{\" \"*(start_token_search_space.inspect.size-2)}^\", 3\n nl \"#{algn\"|::#{id_name}: find own end pattern\"}#{@rule.end_pattern(start_captures).inspect}\", 3\n \n # If this happens to be a for_pattern rule (which by definition, can't have children)\n if @rule.consume_immediately?\n nl \"|::#{id_name}: CONSUME SELF IMMEDIATELY\", 3 \n # Set the end part to \"\" and stop looking for parts\n @end_part = nil\n @end_part_offset = 0\n return nil\n end\n\n # By default, always look for our own end pattern\n end_patterns = {:own_end_pattern => proc{ @rule.end_pattern(start_captures) }}\n \n # If we have no end rule, look for the parent's rule instead\n if @rule.end_rule.nil? && parent\n nl \"#{algn\"|::#{id_name}: or parent end pattern\"}#{first_parent_end_pattern.inspect}\", 3\n end_patterns[:parent_end_pattern] = proc {\n first_parent_end_pattern\n }\n end\n first_match = Match.first(search_space, @rule.child_rules, start_token_limit, \n #Look for any of our possible child rules' start patterns\n proc{|obj|\n obj.start_pattern\n },\n #... if matched by their end patterns\n proc{|obj, captures|\n obj.end_pattern(captures)\n #Or one of the end patterns we are looking for - whichever comes sooner \n }, end_patterns)\n\n #If we have an unconditional_rule, and we found no start rules\n if @rule.unconditional_rule && (!first_match || !first_match.matched_obj)\n nl \"|:::#{id_name}: UNCONDITIONAL RULE #{@rule.unconditional_rule.scope_name.inspect} \", 3 \n unless @used_up_unconditional\n # Fake a match for the unconditional rule (matching the whole search_space end to end)\n new_scope = nil\n indent \"| \" do\n new_scope = Scope.new(@rule.unconditional_rule, search_space, self)\n end\n @parts << new_scope\n @used_up_unconditional = true\n return new_scope\n else\n nl \"::: but it was used up\",3\n end\n end\n \n # Nothing else is left - we probably ran out of source\n if first_match.nil?# && parent.nil?\n @parts << search_space\n nl \"|:::#{id_name}: FOUND NOTHING AT ALL .. #{search_space.size} chars added to parts\", 1\n return nil\n end\n \n # if we matched one of our children's start rules, create a new scope for them\n if first_match.matched_obj\n nl \"|:::#{id_name}: FOUND NEW SCOPE START #{first_match.matched_obj.scope_name.inspect}\", 3\n @parts << first_match.find_match.pre_match\n advance_by(first_match.find_match.end(0))\n new_scope = nil\n indent \"| \" do\n new_scope_start_part = first_match.find_match[0]\n new_scope_start_captures = first_match.find_match.captures\n new_scope = Scope.new(first_match.matched_obj, first_match.full_post_find_match, self, new_scope_start_part, new_scope_start_captures)\n end\n @parts << new_scope\n return new_scope\n end\n \n # If you found an end_pattern, take note of where you found it and return yourself\n if which_end = first_match.matched_additional\n src_to_end_part = first_match.find_match.pre_match\n @parts << src_to_end_part unless src_to_end_part.empty?\n @end_part_offset = @offset\n if which_end == :own_end_pattern\n @end_part_offset += first_match.find_match.end(0)\n @end_part = first_match.find_match[0]\n elsif which_end == :parent_end_pattern\n # When matching an unconditional end (via it's parent) we want to return BEFORE the actual end token (so the parent may properly consume it)\n @end_part_offset += first_match.find_match.begin(0)\n @end_part = \"\"\n end\n @end_part = nil if @end_part.empty?\n @parts << @end_part unless @end_part.nil?\n nl \"|:::#{id_name}: FOUND END TOKEN #{first_match.matched_additional.inspect} at offset #{@end_part_offset}\", 3\n return nil\n end\n end", "def parse_root\n s0 = @scanner.pos\n s1 = []\n s2 = parse_header\n while s2 != :failed\n s1 << s2\n s2 = parse_header\n end\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = parse_initialboard\n s2 = nil if s2 == :failed\n s3 = []\n s4 = parse_header\n while s4 != :failed\n s3 << s4\n s4 = parse_header\n end\n s4 = parse_moves\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s5 = []\n s6 = parse_fork\n while s6 != :failed\n s5 << s6\n s6 = parse_fork\n end\n @reported_pos = s0\n s0 = transform_root(s1, s2, s3, s4, s5)\n end\n end\n s0\n end", "def parse ( c )\n @parserstate = 'wait'\n retval = true\n #\n # * Фиксированное состояние (определенное): -1.\n # * Не фиксированное состояние (неопределенное): -2.\n # * Переход (смена состояний): >0.\n # \n @buffer << c\n \n #\n # Проверка переходов в другие состояния.\n #\n r = classify( @chain.last )\n\n #\n # Переход (прыжок) в другое состояние.\n # <branch>:\n #\n if r >= 0 then\n\t@chain << @states[r]\n\t@chain.last.run_init( @buffer )\n\treset( )\n\t@parserstate = 'branch'\n #\n # Возврат из текущего состояния.\n # <back>:\n #\n elsif r == -1 then\n\t@chain.last.run_fini( @buffer )\n\t#\n\t# если это состояние не первое в цепочке\n\t# тогда откатываемся назад.\n\t#\n\tif @chain.size > 1 then\n\t @chain.delete_at( @chain.size - 1 )\n\tend\n\treset( )\n\t@parserstate = 'back'\n #\n # Нет совпадений.\n # <miss>:\n #\n elsif r == -3 then\n\t#\n\t# если в процессе состояния <wait>\n\t# мы попали в <miss>, то накопленный\n\t# буфер надо обработать.\n\t#\n\t@buffer.each do |ch|\n\t @parserstate = 'miss'\n\t tag = true\n\t if @chain.last.ignore.size > 0 then\n\t tag = false if @chain.last.ignore.include?(ch)\n\t end\n\t if tag == true then\n\t r = @chain.last.run_handler( ch )\n\t #\n\t # Анализ результата обработки состояния.\n\t #\n\t case r.class.to_s\n\t #\n\t # Fixnum - переход на любое состояние (индекс).\n\t when 'Fixnum'\n\t if( (r >= 0) && (r < @states.size) ) then\n\t\t@chain << @states[r]\n\t\treset( )\n\t\t@parserstate = 'hardset'\n\t else\n\t\traise TypeError, \"Method <#{@chain.last.statename}> return incorrectly index.\"\n\t end\n\t #\n\t # nil - ничего не возвращает.\n\t when 'NilClass'\n\t #\n\t # else - расценивается как ошибка обработки.\n\t # обработка ложится на плечи разработчика.\n\t #\n\t else\n\t @parserstate = 'error'\n\t retval = false\n\t break\n\t end\n\t end\n\tend\n\t@buffer = []\n end\n return retval\n end", "def droppiece(p,c) #(piece,column)\n i = c\t#copy the value as a good practice\n\n #Find empty position in the column\n while i<54\n #if empty move piece there\n if @board[i].identity != \" \"\n @board[i-BRDSZ].assiden(p)\n break\n end\n #if we hit the bottom, assign the piece to bottom position\n if i+BRDSZ > 54\n @board[i].assiden(p)\n end\n #implicit else, in which we go to next position\n i=i+BRDSZ\n end\n end", "def parse_root\n @scanner << \"\\n\" unless @scanner.string.end_with?(\"\\n\")\n\n s0 = @scanner.pos\n s1 = []\n s2 = parse_skipline\n while s2 != :failed\n s1 << s2\n s2 = parse_skipline\n end\n\n s2 = []\n s3 = parse_header\n while s3 != :failed\n s2 << s3\n s3 = parse_header\n end\n s3 = parse_initialboard\n s3 = nil if s3 == :failed\n s4 = []\n s5 = parse_header\n while s5 != :failed\n s4 << s5\n s5 = parse_header\n end\n parse_split\n s6 = parse_moves\n if s6 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s7 = []\n s8 = parse_fork\n while s8 != :failed\n s7 << s8\n s8 = parse_fork\n end\n parse_nl\n @reported_pos = s0\n s0 = transform_root(s2, s3, s4, s6, s7)\n end\n\n s0\n end", "def split(band, state=Children, depth=0, chars_parsed=0)\n\n\n $logger.debug \"Depth: #{depth.to_s} Chars: #{chars_parsed.to_s}\".magenta\n $logger.debug \"About to parse: #{band.string[chars_parsed..-1]}\".magenta\n\n delimiter = ','.ord\n name = \"\"\n items = state.new\n $logger.debug \"Created new Stack: '#{items.class.name}::#{items.inspect}'.\".magenta\n\n stopper = state.stopper ? state.stopper.chr : nil\n starter = state.starter ? state.starter.chr : nil\n\n\n while(car = band.getbyte) do\n chars_parsed += 1\n $logger.debug \"Processing: #{car.chr.light_yellow}\".green\n\n if letter? car\n $logger.debug \"LETTER\".yellow\n name << car\n else\n if car == delimiter\n $logger.debug \"SEPARATOR\".yellow\n items.push name\n name = \"\"\n else \n $logger.debug \"DELIMITER\".yellow\n if Token.have_starter? car\n scope = Token.starters[car]\n new_stopper = scope.stopper ? scope.stopper.chr : nil\n $logger.debug \"New unit: #{scope.name} will end with '#{new_stopper}'\"\n if !name.is_a? String or ( name.is_a? String and !name.strip.empty?)\n items.push name\n name = \"\"\n end\n name = split(band, scope, depth + 1, chars_parsed )\n $logger.debug \"Result: \" + \"[#{name.inspect}]\".light_yellow\n $logger.debug \"Back in stack: \" + \"#{items.inspect}\".light_cyan\n $logger.debug \"End of unit: #{state.name} will end with '#{state.stopper}'. Current char: '#{car.chr}'\"\n end\n if Token.have_stopper? car\n unless state.stopper == car\n $logger.debug \"Received '#{car.chr}'. Waiting for '#{stopper}' in #{state.name}.\".light_yellow\n raise MatchError, \n (\"Match Error. Extra '#{car.chr}' \" + \n \"in character #{chars_parsed.to_s}. \" + \n \"Waiting for '#{stopper}'.\").light_red\n end \n $logger.debug \"Reached '#{car.chr}'. End of unit '#{state.name}'.\"\n items.push name\n return items \n\n end\n end\n end\n end \n\n if depth > 0 \n raise UnterminatedString, \n \"Missing delimiters. Parsing finished with depth = '#{depth.to_s}'.\".light_red\n end\n items.push name unless name.empty?# flush the last name\n items\n\n end", "def _HeadedStart\n\n _save = self.pos\n while true # choice\n _tmp = apply_with_args(:_HStart, 6)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_HStart, 5)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_HStart, 4)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_HStart, 3)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_HStart, 2)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_HStart, 1)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_BlockHStart, 6)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_BlockHStart, 5)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_BlockHStart, 4)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_BlockHStart, 3)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_BlockHStart, 2)\n break if _tmp\n self.pos = _save\n _tmp = apply_with_args(:_BlockHStart, 1)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_HeadedStart unless _tmp\n return _tmp\n end", "def bottomToTop(grid, width, height)\n\n strings = topToBottom(grid, width, height)\n\n for string in strings do\n string.reverse!\n end\n\n return strings\n\nend", "def next_token # :nodoc:\n # preprocessing\n # if it is not in RD part\n # => method\n while @in_part != \"rd\"\n line = @src[@i]\n @i += 1 # next line\n\n case line\n # src end\n when false\n return [false, false]\n # RD part begin\n when /^=begin\\s*(?:\\bRD\\b.*)?\\s*$/\n if @in_part # if in non-RD part\n @part_content.push(line)\n else\n @in_part = \"rd\"\n return [:WHITELINE, \"=begin\\n\"] # <= for textblockand\n end\n # non-RD part begin\n when /^=begin\\s+(\\w+)/\n part = $1\n if @in_part # if in non-RD part\n @part_content.push(line)\n else\n @in_part = part if @tree.filter[part] # if filter exists\n# p \"BEGIN_PART: #{@in_part}\" # DEBUG\n end\n # non-RD part end\n when /^=end/\n if @in_part # if in non-RD part\n# p \"END_PART: #{@in_part}\" # DEBUG\n # make Part-in object\n part = RDoc::RD::Part.new(@part_content.join(\"\"), @tree, \"r\")\n @part_content.clear\n # call filter, part_out is output(Part object)\n part_out = @tree.filter[@in_part].call(part)\n\n if @tree.filter[@in_part].mode == :rd # if output is RD formatted\n subtree = parse_subtree(part_out.to_a)\n else # if output is target formatted\n basename = TMPFILE.join('.')\n TMPFILE[-1] += 1\n tmpfile = open(@tree.tmp_dir + \"/\" + basename + \".#{@in_part}\", \"w\")\n tmpfile.print(part_out)\n tmpfile.close\n subtree = parse_subtree([\"=begin\\n\", \"<<< #{basename}\\n\", \"=end\\n\"])\n end\n @in_part = nil\n return [:SUBTREE, subtree]\n end\n else\n if @in_part # if in non-RD part\n @part_content.push(line)\n end\n end\n end\n\n @current_indent = @indent_stack.join(\"\")\n line = @src[@i]\n case line\n when false\n if_current_indent_equal(\"\") do\n [false, false]\n end\n when /^=end/\n if_current_indent_equal(\"\") do\n @in_part = nil\n [:WHITELINE, \"=end\"] # MUST CHANGE??\n end\n when /^\\s*$/\n @i += 1 # next line\n return [:WHITELINE, ':WHITELINE']\n when /^\\#/ # comment line\n @i += 1 # next line\n self.next_token()\n when /^(={1,4})(?!=)\\s*(?=\\S)/, /^(\\+{1,2})(?!\\+)\\s*(?=\\S)/\n rest = $' # '\n rest.strip!\n mark = $1\n if_current_indent_equal(\"\") do\n return [:HEADLINE, [MARK_TO_LEVEL[mark], rest]]\n end\n when /^<<<\\s*(\\S+)/\n file = $1\n if_current_indent_equal(\"\") do\n suffix = file[-3 .. -1]\n if suffix == \".rd\" or suffix == \".rb\"\n subtree = parse_subtree(get_included(file))\n [:SUBTREE, subtree]\n else\n [:INCLUDE, file]\n end\n end\n when /^(\\s*)\\*(\\s*)/\n rest = $' # '\n newIndent = $2\n if_current_indent_equal($1) do\n if @in_verbatim\n [:STRINGLINE, line]\n else\n @indent_stack.push(\"\\s\" + newIndent)\n [:ITEMLISTLINE, rest]\n end\n end\n when /^(\\s*)(\\(\\d+\\))(\\s*)/\n rest = $' # '\n mark = $2\n newIndent = $3\n if_current_indent_equal($1) do\n if @in_verbatim\n [:STRINGLINE, line]\n else\n @indent_stack.push(\"\\s\" * mark.size + newIndent)\n [:ENUMLISTLINE, rest]\n end\n end\n when /^(\\s*):(\\s*)/\n rest = $' # '\n newIndent = $2\n if_current_indent_equal($1) do\n if @in_verbatim\n [:STRINGLINE, line]\n else\n @indent_stack.push(\"\\s#{$2}\")\n [:DESCLISTLINE, rest]\n end\n end\n when /^(\\s*)---(?!-|\\s*$)/\n indent = $1\n rest = $'\n /\\s*/ === rest\n term = $'\n new_indent = $&\n if_current_indent_equal(indent) do\n if @in_verbatim\n [:STRINGLINE, line]\n else\n @indent_stack.push(\"\\s\\s\\s\" + new_indent)\n [:METHODLISTLINE, term]\n end\n end\n when /^(\\s*)/\n if_current_indent_equal($1) do\n [:STRINGLINE, line]\n end\n else\n raise \"[BUG] parsing error may occurred.\"\n end\nend", "def startcondense(pos)\n set = [pos]\n numfound = 0\n\n numfound = condense(set,pos,numfound)\n piecetype = @board[set[0]].identity\n\n #find bottommost piece\n endpoint = set.max\n\n #find bottommost/leftmost piece\n for i in (0..BRDSZ-1)\n if !set.include?(endpoint-1) and !@board[endpoint].isleft\n break\n else\n endpoint -= 1\n end\n end\n\n #cleanup\n for i in (0..numfound-1)\n if(set[i] != endpoint)\n @board[set[i]].assiden(\" \")\n end\n end\n @board[endpoint].next\n end", "def parse_out\n out = []; out << popline while peektype == ':'\n err = []; err << popline while peektype == '!'\n [out, err]\n end", "def bottom\n row, col = @position\n return [row + 1, col] unless row + 1 > 7\n []\n end", "def next_piece\n if @cheating\n @current_block = NeoPiece.new([[[0,0]]], self)\n @cheating = false\n elsif @cheating_two\n @current_block= NeoPiece.new([[[0,0],[0,1]],[[0,0],[1,0]]], self)\n @cheating_two = false\n else\n @current_block = NeoPiece.next_piece(self)\n end\n @current_pos = nil\n end", "def split(position)\n end", "def split(position)\n end", "def parse_horizontal_rule; end", "def parse(si,ei,ds=0)\n #puts \"Parse(#{si},#{ei}): First: #{@file[si]}, Last: #{@file[ei]}\"\n i = si\n sc = nil\n ec = nil\n gs = nil\n ge = nil\n depth = 0\n garbage = false\n cancel = false\n @file[si..ei].each_char do |c|\n # garbage has no depth -- < has no special meaning within garbage\n if c == GARBAGE_START && !cancel && !garbage\n garbage = true\n gs = i if !gs\n elsif c == GARBAGE_END && !cancel && garbage\n garbage = false\n ge = i if !ge\n end\n\n if c == GROUP_START && !garbage # ignore groups nested in garbage\n depth += 1\n sc = i if !sc\n elsif c == GROUP_END && !garbage #ignore groups nested in garbage\n depth -= 1\n ec = i if !ec && depth == 0\n end\n\n if sc && ec\n #puts \"FOUND GROUP: SC: #{sc}, EC: #{ec}, Score: #{ds+1}\"\n @score += ds+1\n parse(sc+1,ec-1,ds+1)\n sc = nil\n ec = nil\n end\n\n if gs && ge\n #puts \"FOUND GARBAGE: GS: #{gs}, GE: #{ge}\"\n parse_garbage(gs,ge)\n gs=nil\n ge=nil\n end\n\n # if we're in garbage, its a cancel character, and not cancelled by a preceding cancel\n cancel = garbage && c==CANCEL && !cancel\n\n i += 1\n end\n end", "def read_moves(io)\n game_text = read(io)\n @moves = []\n game_text.scan(/\\d+\\.\\s+(\\S+)\\s+(\\S+)/).each { | white, black |\n @moves << Move.new(:white, white)\n @moves << Move.new(:black, black) unless black == '1-0' || black == '0-1'\n }\n end", "def towerofhanoi(pieces, sourcepeg, destinationpeg, extrapeg)\n if pieces == 0 then\n return \"no pieces to move\"\n end\n towerofhanoi(pieces-1,sourcepeg,extrapeg,destinationpeg)\n puts \"moved #{pieces} from \" + \"#{sourcepeg} to #{destinationpeg}\"\n towerofhanoi(pieces-1,extrapeg,destinationpeg,sourcepeg)\nend", "def parse_branches\n branches = []\n\n pos = @s.pos\n res = parse_seq\n if res\n branches << res\n else\n @s.pos = pos\n return branches\n end\n\n while @s.scan(/\\s*\\|\\s*/)\n branches << expect(:parse_seq)\n end\n Branches.new branches\n end", "def decompose_position(position); end", "def decompose_position(position); end", "def decompose_position(position); end", "def build_pieces\n (1..8).each do |i|\n Pawn.new(2, i, \"white\") \n end\n Rook.new(1, 1, \"white\")\n Knight.new(1, 2, \"white\")\n Bishop.new(1, 3, \"white\")\n Queen.new(1, 4, \"white\")\n King.new(1, 5, \"white\")\n Bishop.new(1, 6, \"white\")\n Knight.new(1, 7, \"white\")\n Rook.new(1, 8, \"white\")\n (1..8).each do |i|\n Pawn.new(7, i, \"black\") \n end\n Rook.new(8, 1, \"black\")\n Knight.new(8, 2, \"black\")\n Bishop.new(8, 3, \"black\")\n Queen.new(8, 4, \"black\")\n King.new(8, 5, \"black\")\n Bishop.new(8, 6, \"black\")\n Knight.new(8, 7, \"black\")\n Rook.new(8, 8, \"black\")\n end", "def parse; end", "def parse; end", "def parse; end", "def gen_pawn_moves(color)\n moves = []\n all = @position.all_pieces\n \n if color == :white\n position = @position.white \n enemy = @position.black_pieces\n #white pawn moves up the board (increasing bit index order)\n delta = 8\n else\n position = @position.black\n enemy = @position.white_pieces\n #white pawn moves down the board (decreasing bit index order)\n delta = -8\n end\n # no work to do when there are no pawns \n return moves if position[:pawn].nil?\n \n # for each pawn\n position[:pawn].set_bits.each do |from| \n # valid moves are those moves to a free square...\n to = from + delta\n if all.clear?(to) \n moves << [Square.index(from), Square.index(to)]\n to += delta\n moves << [Square.index(from), Square.index(to)] if not_moved_yet(color, from) && all.clear?(to)\n end\n \n # ...plus attacks on the enemies pieces\n move_to = (Move::Attacks[:pawn][color][from] & enemy)\n move_to.set_bits.each { |to_move| moves << [Square.index(from), Square.index(to_move)] }\n end\n moves\n end", "def joker_split\n jokers_loci = self.find_jokers\n \n top_pos = jokers_loci.min\n \n cards_above = @deck.slice!(0,top_pos)\n \n jokers_loci = self.find_jokers\n bottom_pos = jokers_loci.max\n cards_below = @deck.slice!(bottom_pos+1,52) # 52 is max possible cards below last card\n \n @deck.insert(0, cards_below) if (cards_below)\n @deck.insert(-1, cards_above) if (cards_above)\n @deck.flatten! \n end", "def parse(parser,i=0,previous_level=0,parent=nil)\n if i < parser.headlines.count\n hl = parser.headlines[i]\n #str = hl.to_s.gsub('*','').gsub(' ','')\n str = hl.to_s\n level = hl.level\n if (level - previous_level == 1) && previous_level != 0\n parent = parser.headlines[i-1]\n $last_parent[level] = parent\n elsif level == previous_level || level < previous_level\n parent = $last_parent[level]\n else\n parent = nil\n end\n #TODO Fix order\n hl.body_lines.shift #remove title\n $headlines << {:id => Digest::MD5.hexdigest(hl.to_s), :title => str, :body => hl.body_lines.join(\"\\n\"), :level => hl.level, :parent => Digest::MD5.hexdigest(parent.to_s), :tags => hl.tags}\n if parent\n unless $children[Digest::MD5.hexdigest(parent.to_s)]\n $children[Digest::MD5.hexdigest(parent.to_s)] = []\n end\n $children[Digest::MD5.hexdigest(parent.to_s)] << {:title => str, :body => hl.body_lines.join(\"\\n\"), :parent => Digest::MD5.hexdigest(parent.to_s)}\n end\n parse(parser,i+1,level,parent)\n end\nend", "def parse_clue(board, i, hv, board_num) #4.387 - most of which is remove_invalid_combs\n ## Global Var Optimization so we remember which combs we have removed\n comb_key = i.to_s + \"_\" + hv.to_s + \"_\" + board_num.to_s\n if ($combs_for_hv[comb_key] == nil)\n combs_pre = combs_for_hint_value(hv) #.3\n $combs_for_hv[comb_key] = remove_invalid_combs(board, i, combs_pre) #3.97\n else\n $combs_for_hv[comb_key] = remove_invalid_combs(board, i, $combs_for_hv[comb_key]) #3.97\n end\n\n coords = hint_idx_to_coord(i) #nothing\n\n # [1, 2], [3, 4]\n # [1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1]\n\n coords.map.with_index do |coord, idx|\n possibilities = $combs_for_hv[comb_key].map{ |a| a[idx] }.uniq\n {x: coord[:x], y: coord[:y], possibilities: possibilities}\n end\nend", "def get_moves_2(piece, board)\n valid_col = case piece.name\n when ?A then 3\n when ?B then 5\n when ?C then 7\n when ?D then 9\n else 11\n end\n moves = []\n\n # If in hallway\n if piece.row == 1\n cols = valid_col < piece.col ? (valid_col...piece.col).to_a : (piece.col+1..valid_col).to_a\n if cols.count{|c| board[[1, c]] == ?.} == cols.length\n if board[[2, valid_col]] == ?. && board[[3, valid_col]] == piece.name && board[[4, valid_col]] == piece.name && board[[5, valid_col]] == piece.name\n moves << [[2, valid_col], (cols.count + 1) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == piece.name && board[[5, valid_col]] == piece.name\n moves << [[3, valid_col], (cols.count + 2) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == ?. && board[[5, valid_col]] == piece.name\n moves << [[4, valid_col], (cols.count + 3) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == ?. && board[[5, valid_col]] == ?.\n moves << [[5, valid_col], (cols.count + 4) * piece.cost]\n end\n end\n # If right column and something is underneath and nothing above\n # If in wrong column completely and nothing above\n elsif piece.row >= 2\n below = (piece.row+1..5).to_a\n above = (2..piece.row-1).to_a\n if ((piece.col == valid_col && below.count{|c| board[[c, piece.col]] != piece.name} != 0 && below.length != 0) || (piece.col != valid_col)) && (above.count{|c| board[[c, piece.col]] == ?.} == above.length)\n 2.times do |t|\n dir = t == 0 ? -1 : 1\n curr = piece.col\n steps = 1 + above.length\n while board[[1, curr]] == ?.\n moves << [[1, curr], steps * piece.cost] if ![3, 5, 7, 9].include?(curr)\n steps += 1\n curr += dir\n end\n end\n end\n end\n moves\nend", "def init_pos\r\n reset_board_variables\r\n colors = {:white => 0, :black => 7}\r\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\r\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\r\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\r\n # set pieces \r\n colors.each do |k_col, v_col|\r\n # iterate each color\r\n key_color_array = key_pieces[k_col]\r\n pieces.each do |k_pie, v_pie|\r\n # iterate each piece\r\n v_pie.each do |ix_piece|\r\n #p v_col, ix_piece, k_pie, k_col\r\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[v_col][ix_piece] \r\n end\r\n end#end pieces\r\n \r\n # now set pawn for this color\r\n ix_col = 1\r\n ix_col = 6 if k_col == :black\r\n [0,1,2,3,4,5,6,7].each do |ix_piece|\r\n #p ix_col, ix_piece\r\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \r\n end\r\n end \r\n #p @pieces\r\n #p @infosquare\r\n #p @pieces.size\r\n #p @pieces[:white].first\r\n end", "def each_move\n SQ.select { |i| @colors[i] == @mx }.each do |f|\n if @pieces[f] == PAWN\n t = f + UP[@mx]\n yield(f, t + 1) if @colors[t + 1] == @mn && SQ120[SQ64[t] + 1] != NULL\n yield(f, t - 1) if @colors[t - 1] == @mn && SQ120[SQ64[t] - 1] != NULL\n next unless @colors[t] == EMPTY\n yield(f, t)\n yield(f, t + UP[@mx]) if @colors[t + UP[@mx]] == EMPTY && (f >> 3) == (SIDE[@mx] - 1).abs\n next\n end\n STEPS[@pieces[f]].each do |s|\n t = SQ120[SQ64[f] + s]\n while t != NULL\n yield(f, t) if @colors[t] != @mx\n break if @pieces[f] == KING || @pieces[f] == KNIGHT || @colors[t] != EMPTY\n t = SQ120[SQ64[t] + s]\n end\n end\n end\n end", "def next_piece\n if @cheating\n @current_block = MyPiece.new([[[0, 0]]], self)\n @cheating = false\n else\n @current_block = MyPiece.next_piece(self)\n end\n @current_pos = nil\n end", "def topToBottom(grid, width, height)\n\n strings = Array.new\n string = String.new\n\n for x in 0..width-1 do\n\n string = \"\"\n\n for y in 0..height-1 do\n letter = grid[[x, y]]\n string << letter\n end\n\n strings << string\n\n end\n\n return strings\nend", "def sort_pieces\n @headings = Heap.new\n cont = true\n while cont do\n piece = []\n begin\n @piece_size.times { piece << @source.next }\n rescue StopIteration\n cont = false\n end\n piece.sort!\n @headings.insert(ExtStream.new(piece))\n end\n end", "def init_pos\n reset_board_variables\n colors = {:white => 0, :black => 7}\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\n # set pieces \n colors.each do |k_col, v_col|\n # iterate each color\n key_color_array = key_pieces[k_col]\n pieces.each do |k_pie, v_pie|\n # iterate each piece\n v_pie.each do |ix_piece|\n #p v_col, ix_piece, k_pie, k_col\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[v_col][ix_piece] \n end\n end#end pieces\n \n # now set pawn for this color\n ix_col = 1\n ix_col = 6 if k_col == :black\n [0,1,2,3,4,5,6,7].each do |ix_piece|\n #p ix_col, ix_piece\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \n end\n end \n #p @pieces\n #p @infosquare\n #p @pieces.size\n #p @pieces[:white].first\n end", "def next_piece\n @current_block = MyPieceChallenge.next_piece(self)\n @current_pos = nil\n @auto_used = false\n end", "def topToBottomWraparound(grid, width, height)\n\n strings = topToBottom(grid, width, height)\n\n for string in strings do\n\n string << string\n\n end\n\n return strings\n\nend", "def parse_line\n s0 = @scanner.pos\n match_spaces\n s2 = parse_te\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s4 = @scanner.pos\n s5 = parse_fugou\n if s5 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n s6 = parse_from\n if s6 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n @reported_pos = s4\n s4 = transform_teban_fugou_from(s2, s5, s6)\n end\n end\n if s4 == :failed\n s4 = @scanner.pos\n s5 = []\n s6 = match_regexp(/[^\\r\\n ]/)\n while s6 != :failed\n s5 << s6\n s6 = match_regexp(/[^\\r\\n ]/)\n end\n @reported_pos = s4\n s4 = s5.join\n end\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s6 = parse_time\n s6 = nil if s6 == :failed\n match_str('+')\n if parse_nl == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'move' => s4, 'time' => s6 }\n end\n end\n end\n s0\n end", "def parse(input)\t\n\t\tlines = input.each_line \n\n\t\trows = []\n\t\tboxes = []\n\t\tcols = []\n\t\t1.upto(9) {\n\t\t\trows << Block.new\n\t\t\tboxes << Block.new\n\t\t\tcols << Block.new\t\t\n\t\t}\n\n\t\tr = 0 # The current row\n\t\tcell_index = 0 # The current cell\n\n\t\tlines.each do |line|\n\t\t\tif r > 8 \n\t\t\t\tbreak\n\t\t\tend\n\t\t\tnumbers = line.split(',')\t\n\t\t\tc = 0 # The current column\n\t\t\t\n\t\t\tnumbers.each do |number|\t\t\t\t\n\t\t\t\tb = c / 3 + 3 * (r / 3) # The current box\n\t\t\t\tnumber = number.delete \",\"\n\t\t\t\tnumber = number.to_i\n\t\t\t\t\n\t\t\t\tcell= Cell.new(rows[r], cols[c], boxes[b])\n\t\t\t\t#print r.to_s + c.to_s + b.to_s + \" \"\n\t\t\t\tnumber = 0 if number == nil\n\t\t\t\tcell.set(number)\n\n\t\t\t\tif number == 0\n\t\t\t\t\t@unsolved << cell\n\t\t\t\tend\n\t\t\t\t\t\t\t\t\n\t\t\t\t@cells[cell_index] = cell;\n\t\t\t\t\n\t\t\t\tc += 1\n\t\t\t\tcell_index += 1 \n\t\t\tend\t\n\t\t\tr += 1 \n\t\t\t#puts\n\t\tend\n\t\t#puts\n\t\t#show\n\t\t#gets\n\tend", "def chop!() end", "def chop!() end", "def parse\n parts = text.split(/^\\-\\-\\-/)\n\n if parts.size == 1\n data = {}\n #@parts << Part.new(sect[0]) #, *[@stencil, @default].compact.flatten)\n else\n parts.shift if parts.first.strip.empty?\n data = YAML::load(parts.first)\n if Hash === data\n parts.shift\n else\n data = {}\n end\n end\n\n parse_metadata(data)\n\n @parts = parts.map{ |part| Part.parse(self, part) }\n end", "def parse_enzymes( lines )\n data = {}\n return data if lines == nil\n lines.each do |line|\n next if line[0].chr == '#'\n line.chomp!\n \n a = line.split(\"\\s\")\n \n data[ a[0] ] = {\n :name => a[0],\n :pattern => a[1],\n :len => a[2],\n :ncuts => a[3],\n :blunt => a[4],\n :c1 => a[5],\n :c2 => a[6],\n :c3 => a[7],\n :c4 => a[8]\n }\n end # lines.each\n data\n end", "def parsed; end", "def parsed; end", "def parts; end", "def parts; end", "def parts; end", "def group_possible_moves_bishop(pm)\n result = []\n\n result << pm.select do |p|\n p[0] < position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] < position[0] && p[1] > position[1]\n end\n\n result << pm.select do |p|\n p[0] > position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] > position[0] && p[1] > position[1]\n end\n result[0].reverse!\n result[1].reverse!\n result\n end", "def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end", "def parser; end", "def parser; end", "def parser; end", "def parser; end", "def eat_this(line)\n @rest = line + @rest\n things_read = 0\n until @rest.empty?\n case self.state\n when :inside_comment\n if @m = CommentEnd.match(@rest)\n my_debug \"#{@state}: Comment End: #{@m.to_s.inspect}\"\n @already << @m.pre_match << @m.to_s\n @rest = @m.post_match\n self.state = :inside_element\n else\n @already << @rest\n @rest = \"\"\n self.state = :inside_comment\n end\n when :inside_element\n if @m = CommentStart.match(@rest)\n my_debug \"#{@state}: Comment: #{@m.to_s.inspect}\"\n things_read += 1\n @already << @m.pre_match << @m.to_s\n @rest = @m.post_match\n self.state = :inside_comment\n elsif @m = Tag.match(@rest)\n my_debug \"#{@state}: Tag: #{@m.to_s.inspect}\"\n things_read += 1\n self.state = :inside_element\n handle_tag\n elsif @m = CData.match(@rest)\n my_debug \"#{@state}: CDATA: #{@m.to_s.inspect}\"\n @already << @m.pre_match << @m.to_s\n @rest = @m.post_match\n self.state = :inside_cdata\n elsif @m = PartialTag.match(@rest)\n my_debug \"#{@state}: PartialTag: #{@m.to_s.inspect}\"\n @already << @m.pre_match\n @rest = @m.post_match\n @partial_tag = @m.to_s\n self.state = :inside_tag\n elsif @m = EverythingElse.match(@rest)\n my_debug \"#{@state}: Everything: #{@m.to_s.inspect}\"\n @already << @m.pre_match << @m.to_s\n @rest = @m.post_match\n self.state = :inside_element\n else\n error \"Malformed HTML: not complete: #{@rest.inspect}\"\n end\n when :inside_tag\n if @m = /^[^>]*>/.match(@rest)\n my_debug \"#{@state}: matched #{@m.to_s.inspect}\"\n @partial_tag << @m.to_s\n my_debug \"#{@state}: matched TOTAL: #{@partial_tag.to_s.inspect}\"\n @rest = @partial_tag + @m.post_match\n @partial_tag = nil\n self.state = :inside_element\n else\n @partial_tag << @rest\n @rest = \"\"\n self.state = :inside_tag\n end\n when :inside_cdata\n if @m = CDataEnd.match(@rest)\n my_debug \"#{@state}: matched #{@m.to_s.inspect}\"\n @already << @m.pre_match << @m.to_s\n @rest = @m.post_match\n self.state = %(script style).include?(@tag_stack.last) ? :inside_script_style : :inside_element\n else\n @already << @rest\n @rest = \"\"\n self.state = :inside_cdata\n end\n when :inside_script_style\n if @m = CData.match(@rest)\n if @already.rstrip.end_with?('<![CDATA[')\n @already << @m.pre_match\n @rest = @m.post_match\n else\n my_debug \"#{@state}: CDATA: #{@m.to_s.inspect}\"\n @already << @m.pre_match << @m.to_s\n @rest = @m.post_match\n self.state = :inside_cdata\n end\n elsif @m = Tag.match(@rest)\n is_closing = !!@m[1]\n tag = @m[2]\n if is_closing && tag == @tag_stack.last\n my_debug \"#{@state}: matched #{@m.to_s.inspect}\"\n @already << @m.pre_match\n @rest = @m.post_match\n # This is necessary to properly parse\n # script tags\n @already << \"]]>\" unless @already.rstrip.end_with?(\"]]>\")\n self.state = :inside_element\n handle_tag false # don't double-add pre_match\n else\n @already << @rest\n @rest = \"\"\n end\n elsif @m = EverythingElse.match(@rest)\n my_debug \"#{@state}: Everything: #{@m.to_s.inspect}\"\n @already << @m.pre_match << @m.to_s\n @rest = @m.post_match\n else\n @already << @rest\n @rest = \"\"\n end\n else\n raise \"Bug bug: state = #{self.state.inspect}\"\n end # not inside comment\n\n break if is_finished? && things_read > 0\n end\n end", "def frame\n while true\n if @binary_size\n s = read_binary @binary_size\n break unless s\n @binary_size = nil\n yield s\n else\n line = read_line\n break unless line\n case line[0..0]\n when '-'\n yield RuntimeError.new line[1..-1]\n when '+'\n yield line[1..-1]\n when ':'\n yield line[1..-1].to_i\n when '*'\n prev_remaining = @remaining\n @remaining = line[1..-1].to_i\n if @remaining == 0\n @remaining = -1\n yield []\n elsif @remaining == -1\n yield nil\n elsif @remaining > @multibulk_limit\n flush\n raise 'invalid multibulk length'\n elsif prev_remaining > 0\n @stack << [@elements, prev_remaining]\n @elements = []\n end\n when '$'\n @binary_size = line[1..-1].to_i\n if @binary_size == -1\n @binary_size = nil\n yield nil\n elsif (@binary_size == 0 and line[1..1] != '0') or @binary_size < 0 or @binary_size > @bulk_limit\n flush\n raise 'invalid bulk length'\n end\n else\n if @remaining > 0\n flush\n raise \"expected \\\"$\\\", got #{line[0].chr.dump}\" \n end\n parts = line.split(' ')\n @remaining = parts.size\n parts.each {|l| yield l}\n end\n end\n end\n end", "def parse(m_end = nil) \n @num = []\n @op = []\n st = state0_1(0)\n return nil if @error\n @i += 1\n while @i < @stream.size and current_tk.value != m_end do\n st = self.send(st)\n return nil if @error\n @i += 1\n end\n return nil if st == :state_0_1\n make_op\n return @num.pop\n end", "def parse_maze\n x = 0\n y = 0\n z = 0 # will be used as a node number\n @table_reversed.each do |row|\n row.each do |item|\n @start_node = z if item == \"S\"\n\n # create a simple array with all values\n @table_merged << item\n @table_convert << [item, [x, y]]\n y += 1\n z += 1\n end\n x += 1\n y = 0\n end\n end", "def place_pieces\n colors = [:black, :white]\n piece_classes = [King, Queen, Bishop, Knight, Rook, Pawn]\n\n colors.each do |color|\n piece_classes.each do |piece|\n piece.starting_positions(color).each do |pos|\n add_piece(piece.new(color, self, pos), pos)\n end\n end\n end\n end", "def parse_all\n #check for skipping the block using add on module...\n parse_spc\n if @skiper.select{|f|send(f)}.length>0\n p \"skip > #{@row}\" if @dbg[:parse]\n else\n @plt_opt= '' \n #rtn= true if @selector.select{|f|send(f)}.length>0\n rtn = true if shortcut_exec( /(^[\\t ]*)\\-([\\w\\-&\\/:#.%]*\\{.*\\}=*) *([^\\n]*)\\n/) \n rtn = true if shortcut_exec( /(^[\\t ]*)\\-([\\w\\-&\\/:#.%=]*) *([^\\n]*)\\n/) \n rtn = true if shortcut_equal( /(^[\\t ]*)=([\\w\\-&\\/:#.%=]*) *([^\\n]*)\\n/) \n \n rtn = true if get_hot_simple(/^[\\t ]*(%)([\\$\\w\\-&\\/:#.\\[\\]]+\\{.*?\\}[= ]*)([^\\n]*)\\n/)\n rtn = true if get_hot_simple(/^[\\t ]*(%)([\\$\\w\\-&\\/:#.\\[\\]]+\\{.*?\\}[= ]*)()\\n/)\n rtn = true if get_hot_simple(/^[\\t ]*(%)([\\$\\w\\-&\\/:#.\\[\\]%=]+ )([^\\n]*)\\n/) \n rtn = true if get_hot_simple(/^[\\t ]*(%)([\\$\\w\\-&\\/:#.\\[\\]%=]+)()\\n/) \n \n rtn = true if get_div(/^[\\t ]*([#.])([\\w\\-&\\/.]*\\{.*\\}[= ]*)([^\\n]*)\\n/)\n rtn = true if get_div(/^[\\t ]*([#.])([\\w\\-&\\/.]*\\{.*\\}[= ]*)()\\n/)\n rtn = true if get_div(/^[\\t ]*([#.])([\\w\\-&\\/.=]* )([^\\n]*)\\n/) \n rtn = true if get_div(/^[\\t ]*([#.])([\\w\\-&\\/.=]*)()\\n/) \n rtn = true if get_input( /^[\\t ]*(:)([\\w\\-&\\/#.]*\\{.*\\}[= ]*)([^\\n]*)\\n/)\n rtn = true if get_input( /^[\\t ]*(:)([\\w\\-&\\/#.]*\\{.*\\}[= ]*)()\\n/)\n rtn = true if get_input( /^[\\t ]*(:)([\\w\\-&\\/#.=]* )([^\\n]*)\\n/) \n rtn = true if get_input( /^[\\t ]*(:)([\\w\\-&\\/#.=]*)()\\n/) \n rtn = true if parse_hot\n rtn = true if merge_hot\n rtn = true if merge_w2x\n rtn = true if parse_set_var\n rtn = true if parse_set_mem\n rtn = true if parse_get_mem\n rtn = true if inline_tag\n rtn = true if parse_end\n if parse_tags\n rtn = nil\n elsif !rtn\n auto_close \n end\n end\n rtn\n end", "def move_piece(move, color) \n squares = find_start_and_end(move) # [start, end]\n\n return false if @display[squares[0][0]][squares[0][1]].guest == ' '\n\n start_piece = @display[squares[0][0]][squares[0][1]].guest\n\n return false if start_piece.color != color \n\n moves = get_legal_moves(squares[0], start_piece, start_piece.poss_moves(squares[0]))\n\n\n if moves.include?(squares[1])\n\n # castling\n if start_piece.id == 'king' && start_piece.color == 'white' && squares[1] == [7, 1] \n make_move(squares[0], squares[1], start_piece)\n make_move([7, 0], [7, 2], @display[0][0].guest)\n elsif start_piece.id == 'king' && start_piece.color == 'black' && squares[1] == []\n make_move(squares[0], squares[1], start_piece)\n make_move([0, 0], [0, 2], @display[7][0].guest)\n\n # pawn -> queen upgrade\n elsif start_piece.id == 'pawn' && start_piece.color == 'white' && squares[1][0].zero?\n make_move(squares[0], squares[1], Queen.new('white'))\n elsif start_piece.id == 'pawn' && start_piece.color == 'black' && squares[1][0] == 7\n make_move(squares[0], squares[1], Queen.new('black'))\n\n else\n make_move(squares[0], squares[1], start_piece)\n end\n else\n false\n end\n end", "def all_pieces(color)\n pieces = []\n board.each do |line|\n line.find do |p|\n pieces << p if p != ' ' && p.color == color\n end\n end\n pieces\n end", "def parse(path, p=0)\n coords, p = move_to(path, p)\n until close_path(path, p)\n p = command(path, p, coords)\n end\n coords\nend", "def load(input)\n begin\n arr = @file.readline.chomp.split\n input.width = Integer(arr[0])\n input.height = Integer(arr[1])\n controlVar = 0\n pieceID = 1\n pTokens = []\n pNumber = 0\n pWidth = 0\n pHeight = 0\n while(!@file.eof?)\n line = @file.readline.chomp\n if(line.delete(\" \") == \"\")#ignore empty lines\n controlVar = 0\n if(pTokens.count > 0)\n createPieces(pieceID, pNumber, pWidth, pHeight, pTokens, input)\n pieceID = pieceID + pNumber\n pTokens = []\n end\n elsif(controlVar == 0)#first line after empty line\n arr = line.split\n pWidth = Integer(arr[0])\n pHeight = Integer(arr[1])\n pNumber = Integer(arr[2])\n pTokens = [] # an array of integers\n controlVar = 1\n else # other lines specify piece configuration grid\n arr = line.split\n arr.each do |token|\n pTokens[pTokens.count] = Integer(token)\n end\n end\n end\n if(pTokens.count > 0)\n createPieces(pieceID, pNumber, pWidth, pHeight, pTokens, input)\n end\n ensure\n @file.close if(@file != nil)\n end\n end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def follow_instructions(instructions)\n floor = 0\n saw_basement = nil\n\n instructions.split(//).each_with_index do |ch, index|\n floor += (ch == '(' ? 1 : -1)\n # print \"#{floor}..\"\n saw_basement = index + 1 if !saw_basement && floor < 0\n end\n\n [saw_basement, floor]\nend", "def split_into_runs par\n sor=0\n sor_level=par['level']\n run = Hash.new\n run['sor']=sor\n chars=par['characters']\n len=chars.length\n par['runs']=Array.new\n 0.upto(len - 1) do |index|\n char=chars[index]\n next unless char['level']\n if char['level'] != sor_level\n run['sor']=sor\n run['sorType']=chars[sor]['level'].odd? ? 'R' : 'L'\n run['eor']=index\n run['eorType']=chars[index]['level'].odd? ? 'R' : 'L'\n sor=index\n par['runs'].push run\n run=Hash.new\n sor_level=char['level']\n end\n end # upto\n run['sor']=sor\n run['sorType']=chars[sor]['level'].odd? ? 'R' : 'L'\n run['eor']=len\n run['eorType']=par['level'].odd? ? 'R' : 'L'\n par['runs'].push run\n end", "def triple_split(top_joker, bottom_joker)\n\t\t# everything above the top joker moves below the bottom joker\n\t\t# and everything below the bottom joker moves to above the top\n\t\t# joker\n\t\ttop_cards \t = @deck_of_cards[0...top_joker]\n\t\tmid_cards\t\t = @deck_of_cards[top_joker..bottom_joker]\n\t\tbottom_cards = @deck_of_cards[bottom_joker+1..53]\n\t\t@deck_of_cards.clear\n\t\t@deck_of_cards += (bottom_cards)+(mid_cards)+(top_cards)\n\tend", "def read(diagram)\n # Try to read captured pieces information from gnugo output.\n black_captured = /Black \\(X\\) has captured (\\d) pieces/.match(diagram)\n white_captured = /White \\(O\\) has captured (\\d) pieces/.match(diagram)\n\n if black_captured\n self.black.captured += black_captured.captures.first.to_i\n end\n if white_captured\n self.white.captured += white_captured.captures.first.to_i\n end\n\n diagram.gsub!(/Black.*/, '')\n diagram.gsub!(/White.*/, '')\n diagram.gsub!(/N O P/, '')\n diagram.gsub!(/[A-NP-WYZa-z0-9]/, '')\n diagram.gsub!(/[-| ():]/, '')\n diagram.strip().split(\"\\n\").each_with_index do |line, i|\n line.split(\"\").each_with_index do |char, j|\n coords = @letters[j] + (self.size.split('x')[0].to_i-i).to_s\n if char == \"X\"\n self.add_stone(coords, :black)\n elsif char == \"O\"\n self.add_stone(coords, :white)\n end\n end\n end\n end", "def getMoves square\n @pipe1.puts \"show moves\"\n @pipe1.flush\n\n input = \"\"\n begin\n line = @pipe2.gets\n input += line\n end while !line.include? \"END\"\n\n #Filter so we see moves only for relevant square \n moves = input.split(\"START\").last.delete(\"END\")\n moves = moves.chomp.split(\"\\n\").join().split(\" \")\n moves = moves.map{ |move| move if move.split(\":\").first.eql? square.to_s} \n moves = moves.compact.join(\",\")\nend", "def _SourceContents\n while true\n\n _save1 = self.pos\n while true # choice\n _save2 = self.pos\n\n _save3 = self.pos\n while true # sequence\n _save4 = self.pos\n _tmp = match_string(\"(\")\n _tmp = _tmp ? nil : true\n self.pos = _save4\n unless _tmp\n self.pos = _save3\n break\n end\n _save5 = self.pos\n _tmp = match_string(\")\")\n _tmp = _tmp ? nil : true\n self.pos = _save5\n unless _tmp\n self.pos = _save3\n break\n end\n _save6 = self.pos\n _tmp = match_string(\">\")\n _tmp = _tmp ? nil : true\n self.pos = _save6\n unless _tmp\n self.pos = _save3\n break\n end\n _tmp = apply(:_Nonspacechar)\n unless _tmp\n self.pos = _save3\n end\n break\n end # end sequence\n\n if _tmp\n while true\n\n _save7 = self.pos\n while true # sequence\n _save8 = self.pos\n _tmp = match_string(\"(\")\n _tmp = _tmp ? nil : true\n self.pos = _save8\n unless _tmp\n self.pos = _save7\n break\n end\n _save9 = self.pos\n _tmp = match_string(\")\")\n _tmp = _tmp ? nil : true\n self.pos = _save9\n unless _tmp\n self.pos = _save7\n break\n end\n _save10 = self.pos\n _tmp = match_string(\">\")\n _tmp = _tmp ? nil : true\n self.pos = _save10\n unless _tmp\n self.pos = _save7\n break\n end\n _tmp = apply(:_Nonspacechar)\n unless _tmp\n self.pos = _save7\n end\n break\n end # end sequence\n\n break unless _tmp\n end\n _tmp = true\n else\n self.pos = _save2\n end\n break if _tmp\n self.pos = _save1\n\n _save11 = self.pos\n while true # sequence\n _tmp = match_string(\"(\")\n unless _tmp\n self.pos = _save11\n break\n end\n _tmp = apply(:_SourceContents)\n unless _tmp\n self.pos = _save11\n break\n end\n _tmp = match_string(\")\")\n unless _tmp\n self.pos = _save11\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save1\n break\n end # end choice\n\n break unless _tmp\n end\n _tmp = true\n set_failed_rule :_SourceContents unless _tmp\n return _tmp\n end", "def bottom; return self[1]+self[3]; end", "def set_pieces\n @pieces.each do |piece|\n y , x = piece.location\n @rows[y][x] = piece\n end\n end", "def parts\n @parts ||= begin\n t = File.open(@file).read\n t = t.force_encoding('UTF-8') if t.respond_to?(:force_encoding)\n m = t.match(/^(.*?)\\n--+\\n(.*)$/m)\n\n if m.nil?\n [{}, t]\n else\n @offset = m[1].count(\"\\n\") + 2\n data = YAML::load(m[1])\n raise ArgumentError unless data.is_a?(Hash)\n [data, m[2]]\n end\n rescue ArgumentError\n [{}, t]\n end\n end" ]
[ "0.59307706", "0.55753374", "0.54888755", "0.54888755", "0.54780024", "0.5434287", "0.5431834", "0.5427049", "0.5393576", "0.5360147", "0.5359534", "0.53467345", "0.5328731", "0.531367", "0.5278399", "0.52768815", "0.52280354", "0.5218161", "0.52081245", "0.5207465", "0.5207465", "0.52026683", "0.51735216", "0.5166143", "0.5159619", "0.51576835", "0.5157158", "0.5143642", "0.5143434", "0.5139234", "0.5132986", "0.51290244", "0.51017153", "0.5099665", "0.5083073", "0.5083073", "0.5073042", "0.50646365", "0.5063016", "0.5049574", "0.50459695", "0.5045551", "0.5045551", "0.5045551", "0.5045324", "0.5037072", "0.5037072", "0.5037072", "0.50208414", "0.5015103", "0.5010158", "0.5004747", "0.49958605", "0.49943957", "0.49779826", "0.49767247", "0.49669337", "0.496532", "0.4960754", "0.49590707", "0.4948963", "0.4947521", "0.49439928", "0.4935728", "0.4935728", "0.4932594", "0.4929192", "0.49240372", "0.49240372", "0.49139205", "0.49139205", "0.49139205", "0.49134848", "0.4913054", "0.4912346", "0.4912346", "0.4912346", "0.4912346", "0.4910431", "0.4909464", "0.4909072", "0.4903795", "0.49031687", "0.48940292", "0.488581", "0.48814502", "0.48809955", "0.48740208", "0.48714256", "0.48714256", "0.48714256", "0.48714256", "0.486624", "0.48627633", "0.48575342", "0.48558852", "0.48547977", "0.48480576", "0.48466945", "0.4844291", "0.484274" ]
0.0
-1
Fetches the complete octodex
def completeOctodex cURL($baseURL) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oct2_hex()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Oct2Hex::Oct2HexRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def set_ox\n @ox = Ox.find(params[:id])\n end", "def hex2_oct()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Hex2Oct::Hex2OctRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def set_oct\n @oct = Oct.find(params[:id])\n end", "def octokit\n @ok ||= Octokit.new(:auto_traversal=>true)\n end", "def download_iso\n IsoRepo.get(iso_url)\n end", "def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\tcontent = response.body\n\n\t\txml = REXML::Document.new(content)\n\n\t\treturn xml\n\tend", "def index\n @octs = Oct.all\n end", "def oct2_bin()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Oct2Bin::Oct2BinRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def oct2_dec()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Oct2Dec::Oct2DecRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def show\n @odc_r = OdcR.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @odc_r }\n end\n end", "def dec2_oct()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Dec2Oct::Dec2OctRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def xres\n get \"xres\"\n end", "def fetch_coordinates!\n fetch_coordinates(true)\n end", "def getToolsSyndicateOsm( entity_id, destructive)\n params = Hash.new\n params['entity_id'] = entity_id\n params['destructive'] = destructive\n return doCurl(\"get\",\"/tools/syndicate/osm\",params)\n end", "def bin2_oct()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Bin2Oct::Bin2OctRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def get_info(filename)\n @octokit_client = @octokit_client_factory.call if @octokit_client.nil?\n @octokit_client.contents @fullname, path: filename\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: token)\n end", "def obtenerOc(id) #CHECK\n\tjsonResponse = requestWebWithoutParams('GET', (ENV[\"url_oc\"]+\"obtener/\"+id.to_s))\n\tif(jsonResponse==false)\n\t\treturn jsonResponse\n\telse\n\t\tjsonResponse = jsonResponse.first\n\t\tparamsOc = { _id: jsonResponse['_id'],\n\t\t\t\tcliente: jsonResponse['cliente'],\n\t\t\t\tproveedor: jsonResponse['proveedor'],\n\t\t\t\tsku: jsonResponse['sku'],\n\t\t\t\tdireccion: '',\n\t\t\t\tfechaEntrega: jsonResponse['fechaEntrega'],\n\t\t\t\tprecioUnitario: jsonResponse['precioUnitario'],\n\t\t\t\tcantidadDespachada: jsonResponse['cantidadDespachada'],\n\t\t\t\tcantidad: jsonResponse['cantidad'],\n\t\t\t\tcanal: jsonResponse['canal'],\n\t\t\t\tfechaCreacion: jsonResponse['created_at'],\n\t\t\t\testado: jsonResponse['estado']\n\t\t}\n\t\treturn paramsOc\n\tend\nend", "def ox()\n @offset__&.x || 0\n end", "def oct() end", "def orgX(x)\n return @device.orgX(x) ;\n end", "def to_xml\n Ox.to_xml document\n end", "def getX\n @x\n end", "def test_get_xrd\n doc = Yadis.parseXRDS(read_data_file(XRD_FILE))\n result = Yadis::get_yadis_xrd(doc)\n assert_not_nil result\n assert_equal 'XRD', result.name\n assert_equal Yadis::XRD_NS_2_0, result.namespace\n end", "def getToolsIodocs( mode, path, endpoint, doctype)\n params = Hash.new\n params['mode'] = mode\n params['path'] = path\n params['endpoint'] = endpoint\n params['doctype'] = doctype\n return doCurl(\"get\",\"/tools/iodocs\",params)\n end", "def octokit\n @octokit ||= octokit_client(github_oauth_token)\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: settings.github_admin_token, auto_paginate: true)\n end", "def index\n @icd10dxes = Icd10dx.all\n end", "def octokit\n @octokit ||= Chef::Resource::ChefGem.new('octokit', run_context)\n end", "def gPXE; iPXE; end", "def get_x; \t\t@x \t\t\tend", "def show\n @xpto = Xpto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @xpto }\n end\n end", "def getex\n url = prefix + \"getex\"\n return response(url)\n end", "def getex\n url = prefix + \"getex\"\n return response(url)\n end", "def getorden\n @id = params['id']\n @orden = Orden.find(@id)\n @factura = Factura.where(:ordens_id => @id).first\n @monto= @factura.iva + @factura.costoTotal\n\n @historico = Orden.rutas(@id)\n\n respond_to do |format|\n # format.html # show.html.erb\n format.xml\n end\n end", "def getX() \n @x \n end", "def get_recycled_org_units(bookmark = '')\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/recyclebin/\"\n path += \"?bookmark=#{bookmark}\" if bookmark != ''\n _get(path)\n # GETS ONLY FIRST 100\nend", "def next_octal\n c = self.next\n return nil if c.nil?\n return c if octal?(c)\n nil\n end", "def read_octal_char(c)\n r = c.ord - '0'.ord\n if !nextoct?\n return r\n end\n\n r = (r << 3) | (readc.ord - '0'.ord)\n if !nextoct?\n return r\n end\n\n (r << 3) | (readc.ord - '0'.ord)\n end", "def fetch_urn(osn)\n Log.info \"Fetching: #{@owner_code} : #{osn}'s OID from OLIVIA #{OLIVIA.host}\"\n oid = nil\n urns = nil\n actionable_urn = nil\n if (oid = get_oid(osn, @owner_code))\n get_urns(oid).each{|urn| actionable_urn = urn }\n elsif not (urns = get_drs2_pds_urns(osn, @owner_code)).empty?\n urns.each{|urn| actionable_urn = urn }\n elsif not (urns = get_drs2_pds_urns(\"#{osn}-METS\", @owner_code)).empty?\n urns.each{|urn| actionable_urn = urn } \n elsif not (urns = get_drs2_pds_urns(\"#{osn}_METS\", @owner_code)).empty?\n urns.each{|urn| actionable_urn = urn } \n elsif not (urns = get_drs2_pds_urns(\"#{osn}-mets\", @owner_code)).empty?\n urns.each{|urn| actionable_urn = urn } \n elsif not (urns = get_drs2_pds_urns(\"#{osn}_mets\", @owner_code)).empty?\n urns.each{|urn| actionable_urn = urn } \n end\n Log.info \"Done trying to fetch #{@owner_code} : #{osn}'s OID\"\n actionable_urn\n end", "def get_xkcd(number)\n \t\t# This works too\n \t\t# JSON.parse self.class.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \t\tJSON.parse HTTParty.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \tend", "def get_xkcd(number)\n \t\t# This works too\n \t\t# JSON.parse self.class.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \t\tJSON.parse HTTParty.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \tend", "def getex\n url = prefix + \"getex\"\n return response(url)\n end", "def getex\n url = prefix + \"getex\"\n return response(url)\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 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 @icd9dxes = Icd9dx.all.limit(100)\n end", "def get_operators\r\n url = CLX.paths[:operator]\r\n @http_client.get(url)\r\n end", "def read(y, x)\n cy, cx = Vedeu::Geometry::Position[y, x].as_indices\n\n row = fetch(cells, cy)\n cell = fetch(row, cx)\n\n cell\n end", "def show\n @odc_i = OdcI.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @odc_i }\n end\n end", "def get_ole_data index, ole_format\n\n begin\n\n if index == ''\n raise 'Index not specified.'\n end\n\n if ole_format == ''\n raise 'OLE Format not specified.'\n end\n\n str_uri = $product_uri + '/words/' + @filename + '/drawingObjects/' + index.to_s + '/oleData'\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'})\n\n valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)\n\n if valid_output == ''\n\n output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + index.to_s + '.' + ole_format\n Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)\n return output_path\n else\n return valid_output\n end\n\n rescue Exception => e\n print e\n end\n\n end", "def to_yocto\n big_self / YOCTO\n end", "def disc_number\n @ole.DiscNumber\n end", "def x\n @hex.x\n end", "def get_info(id)\n url = \"http://www.omdbapi.com/?i=#{id}&y=&plot=short&r=json\"\n return_result(url)\n end", "def octal(digits)\n string(OCTAL_DIGITS, digits)\n end", "def show\n @nano = Nano.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @nano.to_xml }\n end\n end", "def arbol_nodo\n @children_array = []\n\n taxones = Especie.select_basico(['ancestry_ascendente_directo', 'conteo', 'categorias_taxonomicas.nivel1']).datos_basicos.\n categoria_conteo_join.where(\"categoria='7_00' OR categoria IS NULL\").caso_rango_valores('especies.id',@especie.path_ids.join(',')).\n where(\"nombre_categoria_taxonomica IN ('#{CategoriaTaxonomica::CATEGORIAS_OBLIGATORIAS.join(\"','\")}')\").\n where(estatus: 2).order_por_categoria('DESC')\n\n taxones.each_with_index do |t, i|\n @i = i\n children_hash = hash_arbol_nodo(t, arbol_inicial: true)\n\n # Acumula el resultado del json anterior una posicion antes de la actual\n @children_array << children_hash\n end\n\n # Regresa el ultimo que es el mas actual\n json_d3 = @children_array.last\n\n render :json => json_d3.to_json\n end", "def xedit\n @xedit = Xedit.new(@config.xedit_path, path) unless defined?(@xedit)\n @xedit\n end", "def show\n @domino = Domino.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @domino }\n end\n end", "def get(x = None, y = None)\n execute(:get, x, y)\n end", "def octal_val(decimal)\n octal = 0\n i = 0\n num = decimal\n\n loop do\n break if num <= 0\n octal += (num.divmod(8)[1] * (10 ** i))\n num = num.divmod(8)[0]\n i += 1\n end\n\n octal\nend", "def orchio_get\n if cache.enabled? and response = cache_request.get(id)\n if response.header.status == :cache\n doc = response.body.document\n end\n else\n response = client.send_request :get, inst_args if response.nil?\n doc = Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n ))\n end\n Result.new(\n status: orchio_status(response, 200),\n response: response,\n results: [ doc ]\n )\n end", "def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end", "def getOcorrenciasById(conn,id)\n\tocorrencias = []\n\tconn.exec(\"select codigocncflora from geo.ocorrencias where id = #{id}\").each do |row|\n\t\tocorrencias.push(row['codigocncflora'])\n\tend\nreturn ocorrencias\nend", "def getex\n url = prefix + \"getex\" + id_param\n return response(url)\n end", "def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end", "def fetch(path = nil)\n to_ostruct(get(sanitize!(path)))\nend", "def fetch_root (wfid)\n\n exps = DataMapper.repository(@dm_repository) {\n\n DmExpression.all(\n :wfid => wfid,\n :expclass => OpenWFE::Definition.to_s,\n :order => [ :expid.asc ])\n }\n\n #e = exps.sort { |fe1, fe2| fe1.fei.expid <=> fe2.fei.expid }[0]\n e = exps.first\n\n e ? e.as_owfe_expression(self.application_context) : nil\n end", "def get_api_node(path_array)\n return JSON.parse(lxc(['query', '--wait', '-X', 'GET', return_api_path(path_array)]))\n end", "def show\n @dot = Dot.find(params[:id])\n end", "def getXMLTicket(path)\n resp2 = @@conn.get do |req|\n req.url path\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a param\n req.headers['Content-Type'] = 'application/xml'\n end\n # puts \"Responce : \" + resp2['body'].inspect\n # puts \"Responce2 : \" + resp2.body.to_s()\n \n return resp2.body.to_s()\n end", "def get(oid)\n roid=self.oid2roid(oid)\n return nil if roid.empty?\n validate_roid(roid)\n roid_first=roid.first\n node=@nodes[roid_first]\n return node.get(oid) if node\n return nil\n end", "def getAsCircle\n @node\n end", "def numberedOctocat (number)\n\t\tcURL($baseURL+\"?number=#{number}\")\n\tend", "def to_ot\n Octothorpe.new(to_h)\n end", "def fetch(vin)\n if File.exist?(\"spec/data/#{vin}.xml\")\n doc = LibXML::XML::Document.file(\"spec/data/#{vin}.xml\")\n elsif Lynr.cache.include?(vin)\n doc = LibXML::XML::Document.string(Lynr.cache.read(vin))\n elsif Lynr.features.dataone_decode\n response = fetch_dataone(vin).tap { |resp| Lynr.cache.write(vin, resp) }\n doc = LibXML::XML::Document.string(response)\n else\n doc = LibXML::XML::Document.new\n node = LibXML::XML::Node.new 'query_response'\n doc.root = node\n end\n doc.find_first(\"//query_response[@identifier='#{vin}']\")\n end", "def fetch_zenodo_metadata\n # Fetch the latest ROR metadata from Zenodo (the query will place the most recent\n # version 1st)\n resp = HTTParty.get(DOWNLOAD_URL, headers: { host: 'zenodo.org' })\n unless resp.present? && resp.code == 200\n puts(\"Unable to fetch ROR metadata from Zenodo #{resp}\")\n return nil\n end\n resp_hash = resp.parsed_response\n\n # Extract the most recent file's metadata\n file_metadata = resp_hash['hits']['hits'].first['files'].first\n unless file_metadata.present? && file_metadata['links']['self'].present?\n puts('No file found in ROR metadata from Zenodo')\n return nil\n end\n\n file_metadata\n end", "def AxeDownload(download)\n uri = URI('https://axeweb.intel.com/axe/api/testlist/295/latest/combined')\n puts uri\n req = Net::HTTP::Get.new(uri)\n req.basic_auth 'autoclient', 'gr@ph1c$'\n \n if download\n print \"#{Time.now.strftime(\"%l:%M:%S %p\")} - Start download\\n\"\n res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|\n http.request(req)\n }\n #puts res.body\n \n unless res.kind_of? Net::HTTPSuccess\n puts \"Error downloading results from Axe\"\n exit(9)\n end\n open('result.json', 'wb') do |fileAXE|\n fileAXE << res.body\n end\n print \"#{Time.now.strftime(\"%l:%M:%S %p\")} - End download\\n\"\n end\nend", "def get_data_xml\n\t\texecute unless @data_xml\n\t\treturn @data_xml\n\tend", "def fetch(xml, options = {})\n options = {\n type: String,\n downcase: false,\n symbolize: false,\n strip: false,\n squeeze: false,\n squeeze_lines: false,\n rm_specials: false,\n whitespace: false,\n get_text: false,\n to_i: false,\n to_html: false,\n to_bool: false,\n children: false,\n to_dec: false,\n to_f: false,\n underscore: false\n }.update(options)\n options[:symbolize] = options[:to_sym] if options[:to_sym]\n # Check for incompatible options\n xml_orig = xml\n numeric_methods = [:to_i, :to_f, :to_dec]\n if options[:get_text] == true && options[:to_html] == true\n fail 'Cannot use :get_text and :to_html options at the same time, exiting...'\n end\n if options[:symbolize] == true\n fail 'Cannot convert to a number of any type and symbolize at the same time' if numeric_methods.reject { |arg| options[arg] == true }.size < 3\n end\n fail 'Cannot select multiple numeric conversion args at the same time' if numeric_methods.reject { |arg| options[arg] == true }.size < 2\n if xml.nil?\n Origen.log.debug 'XML data is nil!'\n return nil\n end\n xml = xml.text if options[:get_text] == true\n # Sometimes XML snippets get sent as nodes or as Strings\n # Must skip this code if a String as it is designed to change\n # the XML node into a string\n unless xml.is_a? String\n if options[:to_html] == true\n if xml.children\n # If there are children to this XMl node then grab the content there\n if xml.children.empty? || options[:children] == false\n xml = xml.to_html\n else\n xml = xml.children.to_html\n end\n end\n end\n end\n unless xml.is_a? options[:type]\n Origen.log.debug \"XML data is not of correct type '#{options[:type]}'\"\n Origen.log.debug \"xml is \\n#{xml}\"\n return nil\n end\n if options[:type] == String\n if xml.match(/\\s+/) && options[:whitespace] == false\n Origen.log.debug \"XML data '#{xml}' cannot have white space\"\n return nil\n end\n xml.downcase! if options[:downcase] == true\n xml = xml.underscore if options[:underscore] == true\n xml.strip! if options[:strip] == true\n xml.squeeze!(' ') if options[:squeeze] == true\n xml = xml.squeeze_lines if options[:squeeze_lines] == true\n xml.gsub!(/[^0-9A-Za-z]/, '_') if options[:rm_specials] == true\n if options[:symbolize] == true\n return xml.to_sym\n elsif options[:to_i] == true\n return xml.to_i\n elsif options[:to_dec] == true\n return xml.to_dec\n elsif options[:to_f] == true\n return xml.to_f\n elsif [true, false].include?(xml.to_bool) && options[:to_bool] == true\n # If the string can convert to Boolean then return TrueClass or FalseClass\n return xml.to_bool\n else\n return xml\n end\n else\n # No real examples yet of non-string content\n return xml\n end\n end", "def y\n @hex.y\n end", "def x #getter method\n\t\t@x\n\tend", "def fetch # rubocop:disable Metrics/AbcSize,Metrics/MethodLength\n t1 = Time.now\n puts \"Started at: #{t1}\"\n\n docs = Nokogiri::XML OpenURI.open_uri URL\n FileUtils.mkdir_p @output\n FileUtils.rm Dir[File.join(@output, \"*.#{@ext}\")]\n docs.xpath(\"/body/query/doi_record/report-paper/report-paper_metadata\")\n .each { |doc| parse_doc doc }\n\n index.save\n t2 = Time.now\n puts \"Stopped at: #{t2}\"\n puts \"Done in: #{(t2 - t1).round} sec.\"\n rescue StandardError => e\n warn e.message\n warn e.backtrace[0..5].join(\"\\n\")\n end", "def show\n @internaldraw = Internaldraw.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @internaldraw }\n end\n end", "def geodatos\n end", "def show\n @domicile_type = DomicileType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @domicile_type }\n end\n end", "def show\n @ofrendatris = Ofrendatri.find(params[:id])\n end", "def paddle_x\n @cr[8]\n end", "def simplify\r\n model = Sketchup.active_model\r\n #define everything as one undo operation\r\n model.start_operation \"Simplify\"\r\n\r\n prompts = [\"Angle (degrees)\"]\r\n values = [10]\r\n result=UI.inputbox prompts, values, \"hoi\"\r\n angle = (180-result[0])/57.3 #in radians\r\n \r\n #search all edges in selection set\r\n while (model.selection.length>0)\r\n #remove the first Entity from the Selection and put it in e\r\n e=model.selection.shift\r\n if (e.kind_of?(Sketchup::Edge) && e.valid?)\r\n domino(e,angle)\r\n end\r\n end\r\nend", "def x\n @x\n end", "def x\n @components[:x]\n end", "def set_icd10dx\n @icd10dx = Icd10dx.find(params[:id])\n end", "def assemble(op)\n dump = \"\"\n Tempfile.open(['getopcode','.o']) do |f|\n `echo '#{op}' | #{$as} #{$flags} -o #{f.path}`\n dump = `#{$objdump} -d #{f.path}`\n end\n\n unless $xmos \n return extract_opcode(dump)\n else\n return xmos_extract_opcode(dump)\n end\nend", "def get_xp_from_cr(cr)\n Monster::CR_XP[cr]\n end", "def get_iso\n @image_path = Linecook::ImageManager.fetch(:live_iso, profile: :public)\n end", "def show\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operation }\n end\n end", "def get(oids, options = {})\n each_session do |session|\n @pdu = session.get(oids)\n @pdu.print\n puts \"ERROR\" if @pdu.error?\n end\n \"GET\"\n end", "def show\n @operating_expense = OperatingExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operating_expense }\n end\n end" ]
[ "0.5476673", "0.5442733", "0.541492", "0.5413605", "0.534361", "0.52974963", "0.52036357", "0.51653326", "0.50661594", "0.504089", "0.50351775", "0.502217", "0.4955309", "0.49524063", "0.493911", "0.49295998", "0.48251978", "0.4809872", "0.48084632", "0.47958818", "0.4783845", "0.47833553", "0.47555274", "0.47450286", "0.47407752", "0.4735778", "0.472877", "0.47086382", "0.47065648", "0.4699728", "0.4694821", "0.46811578", "0.4679114", "0.46717954", "0.46717954", "0.4649264", "0.46488643", "0.4646625", "0.46458086", "0.46426156", "0.46309987", "0.4627881", "0.4627881", "0.46257615", "0.46257615", "0.46097517", "0.4609208", "0.46074304", "0.46046937", "0.4596015", "0.45934933", "0.45876375", "0.45791772", "0.45719036", "0.45717975", "0.45694724", "0.4567498", "0.4537992", "0.45253304", "0.45203903", "0.45158362", "0.45103478", "0.4494083", "0.44727007", "0.44597608", "0.4454828", "0.4451677", "0.4447954", "0.44458127", "0.44445547", "0.44442758", "0.4442664", "0.44406006", "0.44303277", "0.4419818", "0.44049802", "0.4404789", "0.44036546", "0.44025776", "0.43873513", "0.43858993", "0.43841258", "0.43833554", "0.43776295", "0.43682748", "0.4368113", "0.4367542", "0.43670756", "0.4357778", "0.43566343", "0.4353644", "0.4345259", "0.43344346", "0.43315265", "0.43287528", "0.43184656", "0.4318455", "0.43122405", "0.43093356", "0.43086773" ]
0.6259944
0
Fetches a random octocat
def randomOctocat cURL($baseURL+"?random") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random\n random_card = self.class.get('/cards/random')\n end", "def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).first\nend", "def random\n Client.get(\"/patterns/random\")\n end", "def random\n Client.get(\"/colors/random\")\n end", "def random(opts = {})\n parse_response(Defcli.read_url(random_url), opts)\n end", "def random_weather_pick\n Rails.cache.fetch(\"random_weather_pick.#{id}\", :expires_in => 10.minutes) do\n rand(1..5)\n end\n end", "def random\n 1 + (10 * rand(0))\n end", "def random_cocktail\n\trand_cocktail_url = open(\"https://www.thecocktaildb.com/api/json/v1/1/random.php\").read\n\trand_cocktail_json = JSON.parse(rand_cocktail_url)\n\trand_cocktail_json[\"drinks\"][0]\nend", "def get_random()\n \n end", "def get_random()\n \n end", "def random\n if (c = count) != 0\n find(:first, :offset => rand(c))\n end\n end", "def get_random_card\n return self.cards.where(:location => -1)[rand(self.cards.where(:location => -1).length)]\n end", "def random\n RandomJam.jam(@api_key, @https)\n end", "def random= rnd \n @random = rnd\n @codon.random = rnd\n end", "def random= rnd \n @random = rnd\n @codon.random = rnd\n end", "def random20\n rand(20) + 1\n end", "def random\n card = rand(1..52)\n card.to_i\n end", "def random\n card = rand(1..52)\n card.to_i\n end", "def random= rnd \n @random = rnd\n @codon.random = rnd\n end", "def cisco_rand\n rand(1 << 24)\n end", "def choice\n rand\n end", "def get_razor()\n file = File.read('/Users/devlon.d/src/obsidian_utils-master/razors.json')\n razors = JSON.parse(file)\n\n random_razor = razors[\"razors\"].sample\n\n razor_content = random_razor[\"title\"]\n razor_content.concat(\"\\n\")\n\n random_razor[\"lines\"].each do |content|\n razor_content.concat(content[\"line\"])\n razor_content.concat(\"\\n\")\n end\n\n return razor_content\nend", "def octokit\n @octokit ||= Octokit::Client.new(access_token: token)\n end", "def random_pokemon_data\n id = rand(1..807)\n request(\"pokemon/#{id}\")\n end", "def random_number\n rand(0..20)\n end", "def random\n CYCLE * rand\nend", "def get_random_pokemon(number)\n uri = URI(\"https://pokeapi.co/api/v2/pokemon/#{number}\")\n res = Net::HTTP.get_response(uri)\n JSON.parse(res.body)\nend", "def random\n new(one.random())\n end", "def get_random\n uri = [@@base_uri, 'all', 'getRandom'].join('/')\n result = get(uri)\n if result.class == Array\n return result.first \n else\n return nil\n end\n end", "def door_num\n\t\treturn rand(3)\n\tend", "def random\n # Hack to get the player interface\n player_iface = @parent.player.send(:interface)\n # Second integrer in array is the random status\n return player_iface.GetStatus.first[1] #== 1\n end", "def random_to_one\n return rand()\n end", "def random_to_one\n return rand()\n end", "def random_to_one\n return rand()\n end", "def random_to_one\n return rand()\n end", "def operand\n rand(1..20)\n end", "def ship_random_cordinates(ship_size)\n ship = Ship.new ship_size\n ship_size = ship_size - 1\n flag = false\n while not flag\n cordinate_x = random_cordinate\n head_position = cordinate_x.split(//,2)\n cordinate_y = CORDINATES.map{|x| (head_position[0].ord + x[0]*ship_size).chr + (head_position[1].to_i+ x[1]*ship_size).to_s}\n cordinate_y = cordinate_y[rand(4)]\n if ship.set_position(cordinate_x,cordinate_y)\n flag = put_ship(ship)\n end\n end\n ship\n end", "def random_typhoon_generator\n\n #Normal Typhoon\n r = rand(50) #Currently: 1/50 chance\n if (r%49 == 0)\n sz = rand(3)\n sX = rand(40-12) + 12\n sY = rand(12-1) + 1\n dX = rand(10-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n #Strong Typhoon\n r = rand(90) #Currently: 1/90 chance\n if (r%89 == 0)\n sz = 3\n sX = rand(46-12) + 12\n sY = rand(12-1) + 1\n dX = rand(11-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n end", "def randCircleCord(r, x = nil)\n x = rand(r*2) if x.nil?\n y1 = -Math.sqrt(r**2 - (x - r)**2)\n y2 = Math.sqrt(r**2 - (x - r)**2)\n return x, (rand(2)==0 ? y1.to_i : y2.to_i) + r\nend", "def random_typhoon_generator\n\t\t\n\t\t#Normal Typhoon\n\t\tr = rand(50) #Currently: 1/50 chance\n\t\tif(r%49 == 0)\n\t\tsz = rand(3)\n\t\tsX = rand(40-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(10-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\t\t#Strong Typhoon\n\t\tr = rand(90) #Currently: 1/90 chance\n\t\tif(r%89 == 0)\n\t\tsz = 3\n\t\tsX = rand(46-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(11-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\tend", "def randomCard\n\t\trarity = randomRarity\n\t\tgolden = randomGold(rarity)\n\t\tmakeCard(rarity, golden)\n\tend", "def pick_player_card\n # TODO: Use Random to get a new random card\n rand(1..11)\nend", "def get_random\n File.read(\"/dev/urandom\", 8).unpack(\"H*\")[0].hex\n rescue\n rand(9117854927)\n end", "def pick_random\r\n @card_list.pick_random\r\n end", "def randomRare\n\t\tgolden = randomGold(:rare)\n\t\tmakeCard(:rare, golden)\n\tend", "def octokit\n @octokit ||= octokit_client(github_oauth_token)\n end", "def open_random\n Defcli.open_in_browser random_url(:api => false)\n end", "def random\n offset = rand(@ingredients.count)\n render json: @ingredients.offset(offset).first.as_json\n end", "def grab_x_loc\n rand 100\n end", "def random_ship\n SHIPS[SHIPS.keys.sample]\n end", "def tirar_dado\n rand 1..6\nend", "def random_player \n\t\tsalida_aleatoria = rand(1..3)\n\t\tsalida_aleatoria\n\tend", "def tirar_dado\n rand 1..6\nend", "def tirar_dado\n rand 1..6\nend", "def tirar_dado\n rand 1..6\nend", "def fortress_random_point\n FortressCell.where(\"mini_map_id=? and symbol=?\", mini_map.id, :concrete.to_s).sample\n end", "def random_card\n return @deck[rand(@deck.length)]\n end", "def pick_random\n @card_list.pick_random\n end", "def pick_random\n @card_list.pick_random\n end", "def random_number\n rand 0..20\nend", "def tirar_dado\r\n\trand 1..6\r\nend", "def tirar_dado\r\n rand 1..6\r\nend", "def random_line\n lines = open(@file,\"r\"){ |file| file.collect }\n lines[rand(lines.length)]\nend", "def random\n active.order(\"RAND()\").first\n end", "def city\n @@cities.rand\n end", "def rand_point()\n \n end", "def command_select_random()\n find_hs = %x[ find ../libs/openframeworks -name \"*.h\" ].strip.to_a\n rand = rand()\n select_h =( rand % find_hs.length )\n\n puts find_hs[ select_h ].to_s.white.bold\nend", "def random_no\n rand(5000)\nend", "def pick\n if @urn_content.length == 0\n fill_urn\n end\n\n @urn_content.delete_at((@rnd.uniform*(@urn_content.length-1)).round)\n end", "def generate_random_color\n COLORS[rand(6)]\n end", "def random_flag\n ['au', 'ca', 'gb', 'gb', 'gb', 'nz', 'us', 'us', 'us'].sort { rand <=> rand }.first\n end", "def index\n\n if param? params[:random]\n\n @citation = Citation.order(\"RANDOM()\").first\n\n render json: @citation \n\n else\n\n @citations = Citation.all\n\n render json: @citations\n\n end\n end", "def nostalgia; return rand end", "def random_status_number_generator\n Random.rand(1..10)\n end", "def random_angle\n 360 * rand\n end", "def get_rand_circuit(name=\"circvit\")\n \n name=name.upcase.scan(/[A-Z]/).join.scan(/[^U]/).join.split(//)\n \n \n family= %w{will belief desire}\n family=family.shuffle\n \n fill = Magick::HatchFill.new(\"Transparent\", \"LightGreen\")\n \n i = Magick::ImageList.new \n i.new_image(333, 333, fill){ self.background_color = \"Transparent\" }\n gc = Magick::Draw.new\n \n \n gc.gravity(Magick::CenterGravity)\n gc.stroke(\"#33cc33\")\n gc.fill(\"#222222\")\n gc.stroke_width(20)\n gc.circle(167, 167, 167, 20)\n gc.stroke(\"#3333cc\")\n gc.fill(\"transparent\")\n gc.stroke_width(2)\n gc.circle(167, 167, 167, 25)\n gc.circle(167, 167, 167, 15)\n gc.circle(167, 167, 167, 22)\n gc.circle(167, 167, 167, 17)\n gc.draw(i)\n\n (0..name.length-1).each do |n|\n i.new_image(333, 333){ self.background_color = \"Transparent\" }\n gc = Magick::Draw.new \n gc.stroke(\"transparent\")\n gc.fill(\"transparent\")\n \n gc.pointsize = (52 + (rand(23)) )\n \n gc.gravity(Magick::CenterGravity)\n f=rand(3)\n gc.font= \"#{Rails.root}/app/assets/fonts/akho#{family[f]}.ttf\" \n gc.text((-rand(72) + rand(72)), (-rand(72) + rand(72)), name[n]).rotate(rand(360))\n gc.fill('red')\n gc.text((-rand(72) + rand(72)), (-rand(72) + rand(72)), name[n]).rotate(rand(360))\n gc.draw(i)\n \n end\n \n \n @Circuit=i.flatten_images\n @Circuit.format = 'png'\n \n \n @circuit_file = \"#{Rails.root}/tmp/circuit-#{name.join}-#{Time.now.to_i}-#{Process.pid}.png\"\n \n \n @Circuit.write('png:'+ @circuit_file)\n \n \n \n \n\n @data_uri = Base64.encode64(@Circuit.to_blob).gsub(/\\n/, \"\") \n @image_tag = '<img alt=\"preview\" src=\"data:image/png;base64,%s\">' % @data_uri\n \n end", "def random\n card_dealt = @possible_cards.sample\n end", "def random_node\n self.to_a.random\n end", "def random_pick(number)\n sort_by{ rand }.slice(0...number)\n end", "def get_random()\n # generating random number within size\n r_n = rand(@hh.size)\n key = @hh.keys[r_n]\n return @hh[key]\n end", "def random_type; end", "def draw_random\n @cards.delete_at(Random.new().rand(0...@cards.count))\n end", "def get_random_orientation\n rand(0..3)\n end", "def digit\n rand(10)\n end", "def random_one\n # p Rails.cache.read('all_codes')\n\n codes = read_or_write_all_code\n code = codes.sample(1)\n return Core::Village.find_by_code(code)\n end", "def pick_random_card\n random_card = @all_cards.sample\n remove_card(random_card)\n return random_card\n end", "def random \n if params[:random]\n @card = Card.where(:first => params[:random]).sample\n else\n # @card = Card.all.sample\n rand_id = rand(Card.count)\n @card = Card.first(:conditions => ['id >= ?', rand_id])\n end\n\n respond_to do |format|\n format.html #first.html.erb\n format.json { render json: @card }\n end\n end", "def host_opens_door(car_location)\n case car_location\n when 2\n 3 # the only unpicked door with a goat\n when 3\n 2 # the only unpicked door with a goat\n else\n random.rand(2..3)\n end\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 random_number\n rand(1..20)\nend", "def random_link\n response = get('/random', nil)\n headers = response[:response_headers]\n location = headers[:location]\n\n link_id = location[/\\/tb\\/(.*)/, 1]\n link \"t3_#{link_id}\"\n end", "def generate\n (0..30).sort{ rand() } .take(@conf)\n end", "def get_game_cliche\n\t\t#initialize variable\n\t\tchosen_line = nil\n\t\t\n\t\t#Get the cliche\n\t\tFile.foreach(\"game_cliches.txt\").each_with_index do |line, number|\n\t\t\tchosen_line = line if rand < 1.0/(number+1)\n\t\tend\n\t\t\t\t\n\treturn chosen_line.chomp\n\tend", "def deal_card\n return rand(1..11)\nend", "def rand_value\n return Kernel.const_get(JsonRander.random_type).new\n end", "def rand_digit #generate random digit\n\treturn rand(10)\nend", "def random_note\n notes[rand(notes.size)]\n end", "def recite_random\n number = rand(1..@size)\n return recite(number)\n end", "def get_random()\n @a.sample\n end", "def get_random()\n @a.sample\n end" ]
[ "0.6274286", "0.6140578", "0.6108216", "0.609113", "0.6041395", "0.60179037", "0.5908919", "0.58842474", "0.58652323", "0.58652323", "0.58604074", "0.58505964", "0.57990134", "0.5766338", "0.5766338", "0.57383543", "0.5732337", "0.5732314", "0.572656", "0.569993", "0.5697186", "0.5680212", "0.56563747", "0.5651341", "0.5649966", "0.56080866", "0.5594874", "0.5578516", "0.5570318", "0.55593455", "0.5552104", "0.5546298", "0.5546298", "0.5546298", "0.5546298", "0.55415756", "0.5533689", "0.55195224", "0.55028373", "0.5490479", "0.54827005", "0.54656965", "0.5449046", "0.54401594", "0.5432396", "0.5431063", "0.5427257", "0.54193705", "0.54098296", "0.54085284", "0.54056984", "0.5394913", "0.53839755", "0.53839755", "0.53839755", "0.53775203", "0.53774285", "0.5366394", "0.5366394", "0.5365849", "0.53475374", "0.53377455", "0.5326931", "0.53208375", "0.5319901", "0.52893054", "0.5281063", "0.52803415", "0.52795595", "0.5269988", "0.5268769", "0.52642703", "0.5260296", "0.52543366", "0.525383", "0.5253499", "0.524911", "0.52421016", "0.52417076", "0.523896", "0.52289164", "0.5228418", "0.5226293", "0.5219018", "0.5218472", "0.5216836", "0.52159154", "0.52108234", "0.5208855", "0.52063465", "0.5205107", "0.51940084", "0.5188117", "0.5183361", "0.5182507", "0.5179309", "0.51778436", "0.5174548", "0.51719135", "0.51719135" ]
0.8122879
0
Fetches an octocat by its number
def numberedOctocat (number) cURL($baseURL+"?number=#{number}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_octal_char(c)\n r = c.ord - '0'.ord\n if !nextoct?\n return r\n end\n\n r = (r << 3) | (readc.ord - '0'.ord)\n if !nextoct?\n return r\n end\n\n (r << 3) | (readc.ord - '0'.ord)\n end", "def set_oct\n @oct = Oct.find(params[:id])\n end", "def next_octal\n c = self.next\n return nil if c.nil?\n return c if octal?(c)\n nil\n end", "def octal(digits)\n string(OCTAL_DIGITS, digits)\n end", "def oct\n str = self.__zreplace_first_double_underscore.strip # for 1.8.7\n arr = str.__extract_base(8)\n base = arr.__at(0)\n sign_str = arr.__at(1)\n body = arr.__at(2)\n first_ch = body.__at(0)\n if first_ch.eql?( ?+ ) || first_ch.eql?( ?- )\n return 0 # redundant sign character is not an octal digit\n end\n num = Integer.__from_string_radix(body, base)\n if sign_str[0].eql?( ?- )\n num = num * -1\n end\n num\n end", "def pch_oct(val=@note)\n pch = val % 12\n oct = (val / 12) - 1\n \"#{PITCHES[pch]}#{oct}\"\n end", "def octal_val(decimal)\n octal = 0\n i = 0\n num = decimal\n\n loop do\n break if num <= 0\n octal += (num.divmod(8)[1] * (10 ** i))\n num = num.divmod(8)[0]\n i += 1\n end\n\n octal\nend", "def oct() end", "def symbolic_to_octal(permission_string)\n codex = {'r' => 4, 'w' => 2, 'x' => 1, '-' => 0 }\n one = codex[permission_string[0]] + codex[permission_string[1]] + codex[permission_string[2]]\n two = codex[permission_string[3]] + codex[permission_string[4]] + codex[permission_string[5]]\n three = codex[permission_string[6]] + codex[permission_string[7]] + codex[permission_string[8]] \n \"#{one}#{two}#{three}\".to_i\nend", "def intGetOctagonalInt i\n i * ( 3 * i - 2 )\nend", "def octicon(name)\n %(<span class=\"octicon octicon-#{name}\"></span>)\n end", "def octal_integer_literal\n code = @codes[@pos]\n if code.nil?\n return nil\n elsif code == 0x30 and (code1 = @codes[@pos + 1]) >= 0x30 and code1 <= 0x37\n @pos += 1\n pos0 = @pos\n while code = @codes[@pos] and code >= 0x30 and code <= 0x37\n @pos += 1\n end\n if identifier_start?(code)\n raise ParseError.new(\"The source character immediately following a NumericLiteral must not be an IdentifierStart or DecimalDigit\", self)\n else\n return ECMA262::ECMA262Numeric.new(@codes[pos0...@pos].pack(\"U*\").to_i(8))\n end\n else\n nil\n end\n end", "def octokit\n @ok ||= Octokit.new(:auto_traversal=>true)\n end", "def nth_octagonal(nth)\n nth * (3 * nth - 2)\nend", "def randomOctocat\n\t\tcURL($baseURL+\"?random\")\n\tend", "def index\n @octs = Oct.all\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: token)\n end", "def oct(a)\n\tb = []\n\ta.each do |x|\n\t\tif x % 8 == 0\n\t b << x\n\t\tend\n\tend\nreturn b.inspect\t\nend", "def octal?(c)\n return false if c.nil?\n c =~ /[0-7]/\n end", "def get_issue(num)\n @issues = Octokit.issues \"LingduoKong/final\",:state => \"open\"\n @issues.each do |issue|\n if issue.number == num\n @issue = issue\n return @issue\n end\n end\nend", "def get_char at\n index = range_correct_index(at)\n return internal_object_get(index + 1)\n end", "def get_roman()\n num = @number\n answer = \"\"\n# you can also use: If num >= 10 \n\n while num >= 10\n answer += \"X\"\n num -= 10\n end\n if num == 9\n answer += \"IX\"\n num -= 9\n end\n if num >= 5\n answer += \"V\"\n num -= 5\n end\n if num == 4\n answer += \"IV\"\n num -= 4\n end\n answer += \"I\" * num # * @number\n return answer\n end", "def [] key\n @octokit_resource[key]\n end", "def do_digit(chr, base)\n # max roman number is 3000\n # 1 = base 1 char, 10 = base 2 chars, 100 = base 3 chars, 1000 = base 4 chars\n romans = { 1 => 'I', 5 => 'V', 10 => 'X', 50 => 'L', 100 => 'C', 500 => 'D', 1000 => 'M' }\n\n result = ''\n num = chr.to_i\n case num\n when (1..3)\n 1.upto(num) { result << romans[base] }\n when 4\n result << 'IV' if base == 1\n result << 'XL' if base == 10\n result << 'CD' if base == 100\n when 5\n result << 'V' if base == 1\n result << 'L' if base == 10\n result << 'D' if base == 100\n when (6..8)\n result << 'VI' if base == 1\n result << 'LX' if base == 10\n result << 'DC' if base == 100\n # add extra C, X or I\n 1.upto(num - 6) { result << romans[base] }\n when 9\n result << 'IX' if base == 1\n result << 'XC' if base == 10\n result << 'CM' if base == 100\n else\n # zero will go here, don't need to do anything about it\n end\n result\n end", "def rossini\n fetch('opera.italian.by_gioacchino_rossini')\n end", "def get_atom(num)\n if not num.between?(1,@numatoms)\n raise RuntimeError, \"atoms with number #{num} not found!\"\n end\n return @atoms[num-1]\n end", "def octal!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 6)\n\n type = OCTAL\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 29:5: ( '-' )? '0' ( '0' .. '7' )*\n # at line 29:5: ( '-' )?\n alt_11 = 2\n look_11_0 = @input.peek(1)\n\n if (look_11_0 == ?-) \n alt_11 = 1\n end\n case alt_11\n when 1\n # at line 29:5: '-'\n match(?-)\n\n end\n match(?0)\n # at line 29:14: ( '0' .. '7' )*\n loop do #loop 12\n alt_12 = 2\n look_12_0 = @input.peek(1)\n\n if (look_12_0.between?(?0, ?7)) \n alt_12 = 1\n\n end\n case alt_12\n when 1\n # at line 29:15: '0' .. '7'\n match_range(?0, ?7)\n\n else\n break #loop 12\n end\n end\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 6)\n\n end", "def show\n @ocat = Ocat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ocat }\n end\n end", "def find_by_number(input)\n coins[input - 1]\n end", "def pc_to_cnc(nc, oct, mod=12)\n (oct*mod)+nc\n end", "def ordinal_indicator(number)\n if number == 0\n return \"zero\"\n elsif number.to_s.chars.map(&:to_i).last == 1 && number != 11\n return \"#{number}st\"\n elsif number.to_s.chars.map(&:to_i).last == 2 && number != 12\n return \"#{number}nd\"\n elsif number.to_s.chars.map(&:to_i).last == 3 && number != 13\n return \"#{number}rd\"\n else\n return \"#{number}th\"\n end\nend", "def find(hex)\n Client.get(\"/color/#{hex}\")\n end", "def czytaj_bajty(offset, ilosc_bitow = 4)\n odczyt = IO.read(@plik, ilosc_bitow, offset)\n case ilosc_bitow\n when 4\n odczyt.unpack(\"I\")[0]\n when 2\n odczyt.unpack(\"S\")[0]\n when 1\n odczyt.unpack(\"C\")[0]\n end\n end", "def mode(path)\n stat('-c', '%a', path).oct\n end", "def octokit\n @octokit ||= Chef::Resource::ChefGem.new('octokit', run_context)\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: settings.github_admin_token, auto_paginate: true)\n end", "def get_xkcd(number)\n \t\t# This works too\n \t\t# JSON.parse self.class.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \t\tJSON.parse HTTParty.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \tend", "def get_xkcd(number)\n \t\t# This works too\n \t\t# JSON.parse self.class.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \t\tJSON.parse HTTParty.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \tend", "def area_code\n number[0..2]\n end", "def get_note_at_offset(note, offset)\n note = note.to_s\n # If the note ends with a number, increase it by offset and add it on again.\n if note.end_with?(\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\")\n octave = note[note.length - 1].to_i + offset\n return note.chop + octave.to_s\n else\n # Otherwise, just use the number 4 (default)\n return note + (offset + 4).to_s\n end\n end", "def octokit\n @octokit ||= octokit_client(github_oauth_token)\n end", "def to_decimal\n octal_string =~ INVALID_OCTAL ? 0 : calculate\n end", "def get_colony_num\n plate_info = show do \n title \"Estimate colony numbers\"\n \n operations.each do |op|\n plate = op.input(\"Plate\").collection\n \n get \"number\", var: \"n#{op.id}\", label: \"Estimate how many colonies are on plate #{plate.id}.#{op.input(\"Plate\").column + 1}\", default: 5\n select [\"normal\", \"contamination\", \"lawn\"], var: \"s#{op.id}\", label: \"If plate #{plate.id}.#{op.input(\"Plate\").column + 1} is contaminated, choose contamination. If there is a lawn of colonies, choose lawn.\", default: 0\n end\n end\n plate_info\n end", "def do_digit(chr, base)\n result = \"\"\n num = chr.to_i\n case num\n when (1..3)\n 1.upto(num) { result << ROMANS[base] }\n when 4 \n result << 'IV' if base == 1 #=> 4\n result << 'XL' if base == 10 #=> 40\n result << 'CD' if base == 100 #=> 400\n # no 4000+ in roman number, max roman number is 3000\n when 5\n result << 'V' if base == 1 #=> 5\n result << 'L' if base == 10 #=> 50\n result << 'D' if base == 100 #=> 500\n # no 5000 in roman number, max roman number is 3000\n when (6..8)\n result << 'VI' if base == 1 #=> 6+\n result << 'LX' if base == 10 #=> 60+\n result << 'DC' if base == 100 #=> 600+\n # add extra C, X or I\n 1.upto(num-6) { result << ROMANS[base] } \n # no 6000+ in roman number, max roman number is 3000\n when 9\n result << 'IX' if base == 1 #=> 9\n result << 'XC' if base == 10 #=> 90\n result << 'CM' if base == 100 #=> 900\n # no 9000 in roman number, max roman number is 3000\n end \n result\n end", "def find(num)\n Politician.find(num)\n end", "def disc_number\n @ole.DiscNumber\n end", "def get_a_card(card_number)\n @cards[card_number]\n end", "def character\n fetch('books.the_kingkiller_chronicle.characters')\n end", "def read_number\n @db.get_first_value 'SELECT number from crl_number'\n end", "def zodiacValue(sign)\n return (sign)%12\nend", "def do_digit(chr, base)\n result = \"\"\n num = chr.to_i\n case num\n when (1..3)\n 1.upto(num) { result << ROMANS[base] }\n when 4 \n result << 'IV' if base == 1 #=> 4\n result << 'IL' if base == 10 #=> 40\n result << 'ID' if base == 100 #=> 400\n # no 4000+ in roman number, max roman number is 3000\n when 5\n result << 'V' if base == 1 #=> 5\n result << 'L' if base == 10 #=> 50\n result << 'D' if base == 100 #=> 500\n # no 5000 in roman number, max roman number is 3000\n when (6..8)\n result << 'V' if base == 1 #=> 6+\n result << 'L' if base == 10 #=> 60+\n result << 'D' if base == 100 #=> 600+\n 1.upto(num-5) { result << ROMANS[1] } # add extra 'III'\n # no 6000+ in roman number, max roman number is 3000\n when 9\n result << 'IX' if base == 1 #=> 9\n result << 'XC' if base == 10 #=> 90\n result << 'CM' if base == 100 #=> 900\n # no 9000 in roman number, max roman number is 3000\n end \n result\n end", "def remove_octals(string)\n command = string\n string.gsub(/^0\\d|\\D0\\d/) do |oct|\n dec = oct.sub(\"0\", \"\")\n command = command.sub(oct, dec)\n end\n command\nend", "def getOperation(csa, operation)\n puts \"CSAIR Codes of\" \n @parse.map{ |airport| \n if( airport[\"name\"] == csa) \n puts \"The \"+ operation +\" is \" +airport[operation].to_s\n end\n }\n end", "def ninth\n at(8)\n end", "def Traductor nume\n\nnumero = {}\nnumero[0] = \"Cero\"\nnumero[1] = \"Uno\"\nnumero[2] = \"Dos\"\nnumero[3] = \"Tres\"\nnumero[4] = \"Cuatro\"\nnumero[5] = \"Cinco\"\nnumero[6] = \"Seis\"\nnumero[7] = \"Siete\"\nnumero[8] = \"Ocho\"\nnumero[9] = \"Nueve\"\nnumero[10] = \"Diez\"\n\n\n\nreturn numero[nume.to_i]\n\n\nend", "def obtener_casilla_numero(numero_casilla)\n @casillas.at(numero_casilla)\n end", "def octagonal?\n fcache[:octagonal] ||= (Math.sqrt(3*self +1)+1)% 3 == 0\n end", "def digit(digit_number)\n digits[digit_number - 1].to_i\n end", "def digit; end", "def rom2dec rnum\n\tromannumerals = {\"I\"=>1, \"V\"=>5, \"X\"=>10, \"L\"=>50, \"C\"=>100, \"D\"=>500,\"M\"=>1000}\n\trnumlen = rnum.length\n\tval = 0\n\t(rnum.split('')).each do |a|\n\t\tval = val + (romannumerals[\"#{a.to_s}\"]).to_i\n\tend\n\t#puts \"#{rnum} = #{val.to_s}\"\n\tif (rnum.gsub(/C[MD]/,'')).length != rnumlen\n\t\tval = val - 200\n\tend\n\tif (rnum.gsub(/X[CL]/,'')).length != rnumlen\n\t\tval = val - 20\n\tend\n\tif (rnum.gsub(/I[VX]/,'')).length != rnumlen\n\t\tval = val - 2\n\tend\t\t\n\tval\nend", "def find_by_iso_numeric(num)\n num = num.to_i\n code, _ = table.find { |_, currency| currency[:iso_numeric] == num }\n new(code) if code\n end", "def get_note_octave(note_number, note_name)\n # Special cases for C flat and B sharp since they are on the boundary.\n if note_name == \"ces\"\n return (note_number / 12) # One higher than most.\n elsif note_name == \"bis\"\n return ((note_number / 12) - 2) # One lower than most.\n else\n return ((note_number / 12) - 1) # Midi octaves change at C with C0 = 12.\n end\n end", "def octal_literal!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 70 )\n\n\n\n type = OctalLiteral\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 527:16: '0' ( '0' .. '7' )+\n match( 0x30 )\n # at file 527:20: ( '0' .. '7' )+\n match_count_22 = 0\n while true\n alt_22 = 2\n look_22_0 = @input.peek( 1 )\n\n if ( look_22_0.between?( 0x30, 0x37 ) )\n alt_22 = 1\n\n end\n case alt_22\n when 1\n # at line \n if @input.peek( 1 ).between?( 0x30, 0x37 )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n else\n match_count_22 > 0 and break\n eee = EarlyExit(22)\n\n\n raise eee\n end\n match_count_22 += 1\n end\n\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 70 )\n\n\n end", "def [](num)\n @intents[num]\n end", "def calculoDiametro(raio)\n return raio * 2\nend", "def option(which, bit)\n options(which)[bit].to_i\n end", "def roman_numeral num\r\n\r\n\tthous = (num \t\t\t/ 1000)\r\n\thunds = (num \t% 1000 \t/ 100)\r\n\ttens = (num \t% 100 \t/ 10)\r\n\tones = (num \t% \t\t\t10)\r\n\r\n\troman = 'M' * thous\r\n\r\nend", "def roman_numeral year\n thou = year/1000\n thou_remain = year%1000\n five_hundreds = thou_remain/500\n hundreds = (thou_remain%500)/100\n fifties = ((thou_remain%500)%100)/50\n tens = (((thou_remain%500)%100)%50)/10\n fives = ((((thou_remain%500)%100)%50)%10)/5\n ones = (((((thou_remain%500)%100)%50)%10)%5)/1\n \n \n #this is just to clear the terminal screen so you only see the result.\n100.times do puts \"\" \n end\n \n #outputs the letters times the number returned.\n puts \"M\" * thou + \"D\" * five_hundreds + \"C\" * hundreds + \"L\" * fifties + \"X\" * tens + \"V\" * fives + \"I\" * ones\nend", "def ois(r=nil)\n if self[:hpcs]\n r = self[:hpcs][0][:pc] if !r\n return self.pcs.map {|v| pc_int(r, v) }\n else\n return nil\n end\n end", "def getbyte(n)\n self\n end", "def oui_to_i(oui)\n return oui if oui.is_a? Integer\n oui = oui.strip.gsub(/[:\\- .]/, '')\n return unless oui =~ /[[:xdigit:]]{6}/\n oui.to_i(16)\n end", "def icon\n self.number\n end", "def get_char\n @look = @expression[@number]\n @number +=1\nend", "def roman_numeral number\n\nend", "def convert_digit(digit, position)\n digit = digit.to_i\n return if digit == 0\n roman = []\n\n digit.times { roman << SINGLE[position] } if digit <= 3\n roman << \"#{SINGLE[position]}#{FIVER[position]}\" if digit == 4\n roman << FIVER[position] if digit >= 5 && digit <=8\n (digit - 5).times { roman << SINGLE[position] } if digit >= 6 && digit <=8\n roman << \"#{SINGLE[position]}#{SINGLE[position - 1 ]}\" if digit == 9\n\n return roman.join(\"\")\n end", "def old_roman_numeral num\n orn = ''\n \torn += 'M' * (num/1000)\n \tnum = num % 1000\n \torn += 'D' * (num/500)\n \tnum = num % 500\n \torn += 'C' * (num/100)\n \tnum = num % 100\n \torn += 'L' * (num/50)\n \tnum = num % 50\n \torn += 'X' * (num/10)\n \tnum = num % 10\n \torn += 'V' * (num/5)\n \tnum = num % 5\n \torn += 'I' * (num)\n \treturn orn\nend", "def get_int(key)\n get(key, \"i\")\n end", "def atom_by_id(atom_id)\n elem_num, perio = atom_id.split('-')\n /^(\\D+)(\\d+)/ =~ elem_num\n elem = $1\n num = $2\n perio ||= '555'\n atom = atoms_of_element(elem)[num.to_i - 1]\n vec = perio.split(//).map { |figure| figure.to_i - 5 }\n atom.translate(vec.to_v3di)\n end", "def hex2_oct()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Hex2Oct::Hex2OctRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def get_atu()\n if $kx_atu\n atu=get_cmd('AK;',0.1,0.5,3).gsub(/^AK/,'').gsub(/;$/,'')\n puts atu if $verbose\n l=atu[0..1].to_i\n c=atu[2..3].to_i\n r=atu[4..5].to_i\n puts l if $verbose\n puts c if $verbose\n puts r if $verbose\n if r==0\n puts \"atu: antenna\" if $verbose\n relays=\"antenna\"\n elsif r==1\n puts \"atu: transmit\" if $verbose\n relays=\"transmit\"\n else\n puts \"atu: unknown\" if $verbose\n relays=\"Unknown\"\n end\n return(\"L=#{l}, C=#{c}, R=#{relays}\")\n else\n return \"ATU not installed\"\n end\nend", "def get_item(index_number)\n @chores[index_number]\n end", "def ox=(n)\n self.offset = [n, oy]\n n\n end", "def old_roman_numeral number\n numeral = \"\"\n\n numeral = numeral + \"M\" * (number / 1000)\n numeral = numeral + \"D\" * (number % 1000/500)\n numeral = numeral + \"C\" * (number % 500/ 100) \n numeral = numeral + \"L\" * (number % 100/ 50) \n numeral = numeral + \"X\" * (number % 50/ 10) \n numeral = numeral + \"V\" * (number % 10/ 5) \n numeral = numeral + \"I\" *(number % 5/ 1) \n numeral\nend", "def new_roman_numeral num\n roman = \"\"\n if num == 400\n roman = \"CD\"\n elsif num == 40\n roman = \"XL\"\n elsif num == 4\n roman = \"IV\"\n elsif num == 9\n roman == \"IX\"\n elsif num == 90\n roman == \"XC\"\n elsif num == 900\n roman == \"CM\"\n end\n roman += \"M\" * (num/1000)\n roman += \"D\" * ((num%1000)/500)\n roman += \"C\" * ((num%500)/100)\n roman += \"L\" * ((num%100)/50)\n roman += \"X\" * ((num%50)/10)\n roman += \"V\" * ((num%10)/5)\n roman += \"I\" * ((num%5)/1)\n puts roman\n end", "def old_school_roman_numerial number\n roman = ''\n\n # 1000\n roman << \"M\" * (number / 1000)\n # 500\n roman << \"D\" * (number % 1000 / 500)\n # 100\n roman << \"C\" * (number % 1000 % 500 / 100)\n # 50\n roman << \"L\" * (number % 1000 % 500 % 100 / 50)\n # 10\n roman << \"X\" * (number % 1000 % 500 % 100 % 50 / 10)\n # 5\n roman << \"V\" * (number % 1000 % 500 % 100 % 50 % 10 / 5)\n # 1\n roman << \"I\" * (number % 1000 % 500 % 100 % 50 % 10 % 5 / 1)\n\n puts roman\nend", "def zodiacPartners(sign)\n return [(sign+4)%12,(sign+8)%12]\nend", "def zodiacPartners(sign)\n return [(sign+4)%12,(sign+8)%12]\nend", "def next_digit\n @phone.slice!(0)\n end", "def chromatic_at(index, key=nil)\n CHROMATICS.detect{|k, v| v == index && (!key || k.start_with?(key))}.try(:[], 0)\n end", "def getSelectedOdd(type)\n if(type == \"1\")\n return @oddModel.getOdd1\n elsif(type == \"X\")\n return @oddModel.getOddX\n else\n return @oddModel.getOdd2\n end\n end", "def digit_to_roman(place)\n numerals_offset = place * 2\n one, five, ten = ROMAN_NUMERALS[numerals_offset..numerals_offset + 3]\n\n case self # Example for place==0:\n when 0..3 then one * self # I..III\n when 4 then one + five # IV\n when 5..8 then five + one * (self - 5) # V..VIII\n when 9 then one + ten # IX\n else raise ArgumentError\n end\n end", "def get_code(dial_book, key)\n dial_book[key]\nend", "def find_by_iso_numeric(num); end", "def old_roman_numberals num\n roman = \"\"\n roman += \"M\" * (num/1000)\n roman += \"D\" * ((num%1000)/500)\n roman += \"C\" * ((num%500)/100)\n roman += \"L\" * ((num%100)/50)\n roman += \"X\" * ((num%50)/10)\n roman += \"V\" * ((num%10)/5)\n roman += \"I\" * ((num%5)/1)\nputs roman\nend", "def fetch(n)\n @commands[n]\n end", "def roman (remainder, digit)\r\n if remainder < digit # ie you do not have any of this roman letter\r\n x = nil.to_i\r\n else\r\n x = remainder / digit\r\n end\r\n\r\n y = remainder % digit\r\n\r\n return [x,y]\r\nend", "def digit \n\t\n\t$cst.add_branch(\"digit\")\n\t\n\tmatch_token(\"T_DIGIT\", $tokens[$index])\n\t\n\t$cst.ascend\n\t\nend", "def getIndex (x,y)\n return y*10 + x\n end", "def cget( q, r )\n hget( even_q_to_axial_hex( q, r ) )\n end", "def new_roman_numeral(number)\n \n roman = \"\"\n\n thousands_place = number/1000\n hundreds_place = (number%1000)/100\n tens_place = (number%100)/10\n ones_place = (number%10)\n\n roman << \"M\"*thousands_place\n\n if hundreds_place == 9\n roman << \"CM\"\n elsif hundreds_place == 4\n roman << \"CD\"\n else\n roman = roman << 'D' * (number%1000 /500)\n roman = roman << 'C' * (number%500 /100)\n end\n\n if tens_place == 9\n roman << \"XC\"\n elsif tens_place == 4\n roman << \"XL\"\n else\n roman = roman << 'L' * (number%100 /50)\n roman = roman << 'X' * (number%50 /10)\n end\n\n\n if ones_place == 9\n roman << \"IX\"\n elsif ones_place == 4\n roman << \"IV\"\n else\n roman = roman << 'V' * (number%10 /5)\n roman = roman << 'I' * (number%5)\n end\n \n\n\nend" ]
[ "0.6242975", "0.6045589", "0.6024554", "0.6020457", "0.5884812", "0.587131", "0.5823518", "0.5818513", "0.5387058", "0.5349889", "0.53414613", "0.53032297", "0.52596337", "0.51465577", "0.5131537", "0.5122498", "0.5090959", "0.5068637", "0.5067946", "0.50619936", "0.505893", "0.50560534", "0.49270523", "0.49133432", "0.4909382", "0.4901764", "0.4817638", "0.4808334", "0.48080856", "0.47922844", "0.47882843", "0.4784109", "0.47637045", "0.47572342", "0.47561556", "0.4749394", "0.47250885", "0.47250885", "0.4721146", "0.47170958", "0.46852893", "0.4681877", "0.46664995", "0.46613178", "0.4660126", "0.4643936", "0.46213573", "0.46202838", "0.46198598", "0.46164793", "0.46094757", "0.45907795", "0.4588544", "0.4586853", "0.45807117", "0.45748535", "0.4569558", "0.45402032", "0.45141727", "0.45115378", "0.45094222", "0.44943196", "0.44847402", "0.44831625", "0.4481899", "0.44791248", "0.44779527", "0.44719195", "0.4469529", "0.44663328", "0.4460558", "0.44599617", "0.4455652", "0.44551212", "0.4454991", "0.44530982", "0.44442078", "0.4434864", "0.4424156", "0.4422214", "0.4412695", "0.4406985", "0.44048008", "0.43997782", "0.43984306", "0.43965745", "0.43965745", "0.43963647", "0.4396274", "0.43886966", "0.43878347", "0.43854666", "0.43853176", "0.43769863", "0.4375862", "0.43737543", "0.43680072", "0.4362503", "0.43620026", "0.43531343" ]
0.65900767
0
Performs all cURLs that are initated in each function, protected function
def cURL (endpoint) # use open-uri to perform a GET request and then use JSON to parse it JSON.parse(open(endpoint).read) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_urls\n acts_as_url_configuration.adapter.initialize_urls! self\n end", "def initialize_urls\n find_each(:conditions => {acts_as_url_configuration.url_attribute => nil}) do |instance|\n instance.send :ensure_unique_url\n instance.save\n end\n end", "def exec_request\n @urls.map { |url| fetch(url) }\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def initialize_urls\n find(:all, :conditions => {self.url_attribute => nil}).each do |instance|\n instance.send :ensure_unique_url\n instance.save\n end\n end", "def initialize\n load_site\n load_creds\n end", "def queue_urls\n @queue_urls ||= init_urls\n end", "def all\n setup_request \"#{@@resource_url}s\"\n end", "def initialize(urls, opts = {})\n @urls = [urls].flatten.map{ |url| url.is_a?(URI) ? url : URI(url) }\n @urls.each{ |url| url.path = '/' if url.path.empty? }\n\n @tentacles = []\n @on_every_page_blocks = []\n @on_pages_like_blocks = Hash.new { |hash,key| hash[key] = [] }\n @skip_link_patterns = []\n @after_crawl_blocks = []\n @opts = opts\n @focus_crawl_block = nil\n\n\n yield self if block_given?\n end", "def get_urls()\n generate_thread(@@source_url)\n end", "def initialize(urls, &block)\n @urls = [urls].flatten.map{ |url| URI(url) if url.is_a?(String) }\n @urls.each{ |url| url.path = '/' if url.path.empty? }\n \n @tentacles = []\n @pages = PageHash.new\n @on_every_page_blocks = []\n @on_pages_like_blocks = Hash.new { |hash,key| hash[key] = [] }\n @skip_link_patterns = []\n @after_crawl_blocks = []\n \n if Anemone.options.obey_robots_txt\n @robots = Robots.new(Anemone.options.user_agent)\n end\n \n block.call(self) if block\n end", "def initialise(*url)\n @urls = [] \n list = File.open('url_list').each do |url|\n puts url\n doc = Nokogiri::HTML(open(url)) \n @urls.push(doc)\n end\n end", "def post_init\n @current = nil\n @requests = []\n @pending = []\n @parser = Http::Parser.new(self)\n end", "def init() \n\tunless $downips.empty? #checks if the downips Array is empty.\n\t$downips.each do |downip|\n\tunless downip == \"nil\" #Checks if the donwips Array contains any nil values.\n\tdownhttpcheck(downip)\n end\n end\n\tend\n $upips.each do |ipsend|\n\tunless ipsend == \"nil\" #Checks if the upips Array contains any nil values.\n\tmainhttpcheck(ipsend)\n end\n\tend\n\t$downips = $downips.compact #Will remove the nil values, inserted when a IP is up again, from the array.\n\t$upips = $upips.compact #Will remove nil values from the array.\n\tend", "def start_crawling\n begin\n if @params[:url]\n page = @agent.get(@params[:url])\n else\n @pre_middlewares.each { |mw| mw.call(@params) }\n page = @params[:page]\n raise 'internal error' if page.nil?\n end\n rescue => _\n raise CrawlingException::InitializationError.new\n end\n\n # starting from Depth 0\n process(page, 0)\n end", "def prepare\n super\n\n self.fetch_site\n end", "def initialize automount = false, &proc\n @routes = []\n @controllers, @subcontrollers = {}, []\n @hosts, @controllers_hosts = {}, {}\n @automount = automount\n proc && self.instance_exec(&proc)\n use ExtendedRack\n compiler_pool(Hash.new)\n end", "def all_list_page_urls\n LIST_PAGE_URLS.each_with_index do |list_page_url, i|\n begin\n puts \"-- Crawling #{list_page_url} (#{i + 1} of #{LIST_PAGE_URLS.count}) --\"\n yield(list_page_url)\n rescue => e\n puts \"Failed to crawl list_page_url:#{e.message}\"; next\n end\n end\n end", "def all_list_page_urls\n LIST_PAGE_URLS.each_with_index do |list_page_url, i|\n begin\n puts \"-- Crawling #{list_page_url} (#{i + 1} of #{LIST_PAGE_URLS.count}) --\"\n yield(list_page_url)\n rescue => e\n puts \"Failed to crawl list_page_url:#{e.message}\"; next\n end\n end\n end", "def generate_base_urls \n set_scheme\n if(ENV['ENVIRONMENT']=='sandbox')\n @base_url = @sandbox + @bbc_domain \n @static_base_url = @static_sandbox + @bbc_domain\n elsif (ENV['ENVIRONMENT']=='live' && ENV['WWW_LIVE']=='false')\n @base_url = @www_prefix.chop + @bbc_domain\n @static_base_url = @static_prefix.chop + @bbci_domain\n @open_base_url = @open_prefix.chop + @bbc_domain\n elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box\n @base_url = \"#{scheme}://#{ENV['ENVIRONMENT']}\" \n else\n @base_url = @www_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n @static_base_url = @static_prefix + ENV['ENVIRONMENT'] + @bbci_domain\n @static_base_url = @static_prefix.chop + @bbci_domain if ENV['ENVIRONMENT'] == 'live'\n @open_base_url = @open_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n end\n proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] \n @proxy_host = proxy.scan(/http:\\/\\/(.*):80/).to_s if proxy\n end", "def prepare\n reset\n\n yield self if block_given?\n\n # Since the OAuth flow is performed by the browser, we'll need to boot\n # the Sinatra app instead of just stubbing the app with WebMock...\n boot_once\n\n OmniAuth::Strategies::Icalia.instances.each do |strategy|\n strategy.options.client_options.tap do |options|\n options.site = url\n options.token_url = \"#{url}/oauth/token\"\n options.authorize_url = \"#{url}/oauth/authorize\"\n end\n end\n end", "def init_urls\n Hash[@@client.list_queues.queue_urls.map { |u| [u[(u.rindex(\"/\") + 1)..-1], u] }]\n end", "def perform\n get_all_the_urls_of_val_doise_townhalls\n end", "def initialize(url)\n @url = url\n @follow_redirect = false\n max_redirects(5)\n @retval = Array.new\n end", "def resolve_all_links()\n @tasks.each_value { |t|\n t.resolve_all_links()\n }\n @prepared = true\n end", "def fetch_apis_asynchronously \n threads = []\n threads << Thread.new { @resp1 = RestClient.get 'https://reqres.in/api/unknown' }\n threads << Thread.new { @resp2 = RestClient.get 'https://reqres.in/api/products' }\n threads.each { |thr| thr.join } \n end", "def init_folder\n @containers = []\n @resources = []\n @http_response = self.get\n if @http_response\n _parse_ldp(@http_response.body)\n elsif !@http_response\n return false\n end\n @init = true\n end", "def setup\r\n setup_wiki\r\n setup_host_map\r\n setup_host\r\n end", "def callback_phase\n # Prep the urls using the account ID.\n # TODO: Could we use the :setup option and a Proc\n # to handle this rather than call here? \n set_omniauth_zendesk_urls\n\n # Continue the request as usual.\n super\n end", "def each(&block)\n _init\n\n routes.each(&block)\n end", "def setup_http_request(obj, cookie=nil, args={})\n if args.has_key?(:url) and args[:url] != nil\n if args[:url].scan(/%[s|d]/).length > 0\n if args[:url].scan(/%[s|d]/).length != args[:url_arg].length\n ALERT.call(caller_locations, __callee__, \"URL contains %d '%%s' or '%%d' argument... Fix your code\" % args[:url].scan(/%[s|d]/).length)\n exit 2\n end\n req = obj[:method].new(args[:url] % args[:url_arg])\n else\n req = obj[:method].new(args[:url])\n end\n else\n if args.has_key?(:url_arg)\n if obj[:url].scan(/%[s|d]/).length > 0\n if obj[:url].scan(/%[s|d]/).length != args[:url_arg].length\n ALERT.call(caller_locations, __callee__, \"URL contains %d '%%s' or '%%d' argument... Fix your code\" % obj[:url].scan(/%[s|d]/).length)\n exit 2\n end\n req = obj[:method].new(obj[:url] % args[:url_arg])\n else\n req = obj[:method].new(obj[:url])\n end\n else\n req = obj[:method].new(obj[:url])\n end\n end\n req[\"Host\"] = \"www.blablacar.fr\"\n req[\"origin\"] = \"https://www.blablacar.fr\"\n req[\"User-Agent\"] = \"Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0\"\n req[\"Accept\"] = \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\"\n if obj.has_key?(:referer)\n req['Referer'] = obj[:referer]\n else\n req[\"Referer\"] = \"https://www.blablacar.fr/dashboard\"\n end\n req.add_field(\"Connection\", \"keep-alive\")\n if cookie\n req.add_field(\"Cookie\", cookie)\n end\n if obj.has_key?(:header)\n obj[:header].each_slice(2).map{|h|\n req.add_field(h[0], h[1])\n }\n end\n if obj.has_key?(:data)\n if obj[:data].scan(/%[s|d]/).length > 0\n if obj[:data].scan(/%[s|d]/).length != args[:arg].length\n ALERT.call(caller_locations, __callee__, \"Body request contains %d '%%s' or '%%d' argument... Fix your code\" % obj[:data].scan(/%[s|d]/).length)\n exit 2\n else\n req.body = obj[:data] % args[:arg]\n end\n else\n req.body = obj[:data]\n end\n req['Content-Length'] = req.body.length\n end\n req\nend", "def set_route_information\n @routes = {\n :root_url => root_url,\n :root_path => root_path,\n :customers_delete_path => customers_delete_path, \n :customers_all_path => customers_all_path,\n :customers_all_url => customers_all_url,\n :customers_creation_form_url => customers_creationform_url,\n :customers_creation_form_path => customers_creationform_path,\n :customers_edit_form_path => customers_editform_path,\n :customers_edit_form_url => customers_editform_url,\n :contacts_customer_contacts_path => contacts_customer_contacts_path,\n :contacts_customer_contacts_url => contacts_customer_contacts_url,\n :contacts_delete_path => contacts_delete_path,\n :contacts_delete_url => contacts_delete_url,\n :contacts_createForm_path => contacts_createForm_path,\n :contacts_createForm_url => contacts_createForm_url,\n :contacts_update_path => contacts_update_path,\n :contacts_update_url => contacts_update_url,\n :contacts_editform_path => contacts_editform_path,\n :contacts_editform_url => contacts_editform_url\n }\n end", "def init_vars\n @base_url = request.protocol + request.host\n if request.port != 80\n @base_url += ':' + request.port.to_s\n end\n \n @is_bar_side = request.url =~ /barhome/i\n @no_hero = request.url =~ /(about|adminlogin|bars|forgot_password|mobile_info|users)/i\n end", "def collect_common_urls_hash(url,domain_url,urls_hash,options,depth=0)\n #$log.info \"1. Pages crawled: #{@already_visited.size}\"\n #$log.info \"2. Depth: #{depth}\"\n #$log.info \"3. Crawling URL: #{url}\"\n if options[:crawl]\n return if depth == 2 \n else\n return if depth == 1\n end\n return if @already_visited.size == 10\n if @already_visited[url] == nil\n @already_visited[url] = true\n else\n return\n end\n page_urls = find_urls_on_page(url,domain_url,urls_hash)\n return if page_urls == nil\n if options[:crawled_urls]\n @p_obj.puts \"URL: #{url} DEPTH: #{depth}\"\n $log.info \"URLS CRAWLED: #{@already_visited.size}, CRAWLED URL: #{url}\"\n end\n page_urls.each do |page_url|\n break if @already_visited.size == 10\n collect_common_urls_hash(page_url,domain_url,urls_hash,options,depth+1) if page_url.match(/http(s)?:\\/\\/[^\\/]+/).to_s == domain_url and not page_url.include?\"Redirect\"\n end\n end", "def consider_all_requests_local=(_arg0); end", "def consider_all_requests_local=(_arg0); end", "def each_url(&block)\n urls.each do |url|\n yield url, handlers[url].first, handlers[url].last\n end\n end", "def crawl_urls(urls = @urls, &block)\n raise 'No urls to crawl' unless urls\n\n @docs = []\n doc = nil\n Wgit::Utils.each(urls) { |url| doc = handle_crawl_block(url, &block) }\n doc || @docs.last\n end", "def crawl_worker(url0)\n\t\tputs \"Please be aware that it may take a while to crawl #{url0}, depending on the site's responsiveness and the amount of contents.\" \t\n\t\tbegin\n\t\t\t# Input URL sanity check first\n\t\t\tif is_url?(url0)\n\t\t\t\thost=url_2_host(url0)\n\t\t\t\tip=host_2_ip(host).to_s\n\t\t\t\traise \"Invalid IP address: #{url0}\" if ip.nil?\n\t\t\t\tport=url_2_port(url0).to_s\n\t\t\t\traise \"Invalid port number: #{url0}\" if port.nil?\n\t\t\telse\n\t\t\t\traise \"Invalid URL: #{url0}. Please check it out with your browser again.\"\n\t\t\tend\n\t\t\tlog_info=Hash.new\n\t\t\tlog_info[1]=\"Start working on #{url0}\"\n\t\t\turl_stores=Hash.new\n\t\t\turl_stores[url0]=true unless url_stores.key?(url0)\n\t\t\t@discovered_urls_by_crawler[url0]=true unless @discovered_urls_by_crawler.key?(url0)\n\t\t\t@crawl_start[url0]=true unless @crawl_start.key?(url0)\n#\t\t\t$discovered_urls[url0]=true unless $discovered_urls.key?(url0)\n\t\t\t@crawl_depth.times do\n\t\t\t\turl_stores.keys.each do |url|\n\t\t\t\t\t# 10/01/2013 add logic to avoid unnecessary crawling within the same child instance\n\t\t\t\t\tnext if @visited_urls_by_crawler.key?(url)\n\t\t\t\t\turl_object = open_url(url)\n\t\t\t\t\tnext if url_object == nil\n\t\t\t\t\turl = update_url_if_redirected(url, url_object)\n\t\t\t\t\turl_body = read_url(url)\n\t\t\t\t\t# Protection code - to avoid parsing failure on the empty or nil object\n\t\t\t\t\tnext if url_body.nil? or url_body.empty?\t\t\t\t\t\n\t\t\t\t\turl_stores[url]=true unless url_stores.key?(url)\n\t\t\t\t\t@discovered_urls_by_crawler[url]=true unless @discovered_urls_by_crawler.key?(url)\n#\t\t\t\t\t$discovered_urls[url]=true unless $discovered_urls.key?(url)\n\t\t\t\t\tdoc = parse_html(url_body)\n\t\t\t\t\tnext if doc == nil\n\t\t\t\t\tif url_stores.size >= @crawl_page_limit\n\t\t\t\t\t\t#@visited_urls_by_crawler.merge!(url_stores)\n\t\t\t\t\t\t@discovered_urls_by_crawler.merge!(url_stores)\n#\t\t\t\t\t\t$discovered_urls.merge!(url_stores)\n\t\t\t\t\t\tputs \"Finish web crawling the url: #{url0}\"\n\t\t\t\t\t\treturn url_stores\n\t\t\t\t\tend\n\t\t\t\t\tpage_urls = find_urls_on_page(doc, url)\n\t\t\t\t\tpage_urls.uniq!\n\t\t\t\t\tpage_urls.map do |y|\n\t\t\t\t\t\ty=normalize_url(y)\n\t\t\t\t\t\turl_stores[y]=true unless url_stores.key?(y)\n\t\t\t\t\t\t@discovered_urls_by_crawler[y]=true unless @discovered_urls_by_crawler.key?(y)\n#\t\t\t\t\t\t$discovered_urls[y]=true unless $discovered_urls.key?(y)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs \"Finish web crawling on: #{url0}\"\n\t\t\tlog_info[2]=\"Finish working on: #{url0}\"\n\t\t\twlog(log_info, @log_file)\n\t\t\t@crawl_done[url0]=true unless @crawl_done.key?(url0)\n\t\t\treturn url_stores\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for URL #{url0}: #{ee}\" if @verbose\n\t\t\tlog_info[3]=\"Exception on #{url0}\"\n\t\t\twlog(log_info,@log_file)\n\t\t\treturn url_stores\n\t\tend\n\tend", "def create_image_urls\n\n if self.image_size_tab != 'none' && self.image_size_tab != nil\n self.image_url_tab = create_url self.image_size_tab\n self.image_url_blog = create_url self.image_size_blog\n\n\n end\n\n end", "def __build_connections\n Connections::Collection.new \\\n :connections => hosts.map { |host|\n host[:protocol] = host[:scheme] || DEFAULT_PROTOCOL\n host[:port] ||= DEFAULT_PORT\n\n client = ::Curl::Easy.new\n client.headers = {'User-Agent' => \"Curb #{Curl::CURB_VERSION}\"}\n client.url = __full_url(host)\n\n if host[:user]\n client.http_auth_types = host[:auth_type] || :basic\n client.username = host[:user]\n client.password = host[:password]\n end\n\n client.instance_eval &@block if @block\n\n Connections::Connection.new :host => host, :connection => client\n },\n :selector_class => options[:selector_class],\n :selector => options[:selector]\n end", "def setup_managers\n\t\t@crawler_op = Crawler_Operator.new(self)\n\tend", "def create_context\n urls = []\n\n d = Date::today\n for i in 1..4\n urls << '%s/%04d/%02d' % [BASE_URL, d.year, d.month]\n d = d >> 1\n end\n\n {:urls => urls}\nend", "def create_context\n urls = []\n\n d = Date::today\n for i in 1..4\n urls << '%s/%04d/%02d' % [BASE_URL, d.year, d.month]\n d = d >> 1\n end\n\n {:urls => urls}\nend", "def init_all_paths_liby\n\t\tcv_set(Liby, :path_lily_file \t => nil)\n\t\tcv_set(Liby, :path_pdf_file \t => nil)\n\t\tcv_set(Liby, :path_ruby_score => nil)\t\t\t\n\t\tcv_set(Liby, :path_affixe_file => nil)\t\t\t\n end", "def initialize (params = {})\t\t\n\t\t@verbose=params.fetch(:verbose, false)\n\t\t@http_timeout=params.fetch(:http_timeout, 5000)\n\t\t@crawl_depth=params.fetch(:crawl_depth, 4)\n\t\t@crawl_page_limit=params.fetch(:crawl_page_limit, 1000)\n\t\t@max_parallel=params.fetch(:max_parallel, 40)\n\t\t# Discovered data store\t\t\n\t\t@discovered_urls_by_crawler=Hash.new\n\t\t@visited_urls_by_crawler=Hash.new\n\t\t@crawl_start=Hash.new\n\t\t@crawl_done=Hash.new\n\t\t@log_file=File.dirname(__FILE__)+\"../../logs/crawler.log\"\n\tend", "def go(dry_run = false)\n raise 'no URLs specified' if @urls.empty?\n\n errors = []\n\n @urls.each do |url|\n p url; next if dry_run\n\n begin\n puts \"Getting #{url}\"\n visit \"#{url}\"\n sleep 3.0 # arbitrary sleep to allow heavily ajax-y pages to load\n snap\n actions(url)\n rescue => err\n puts err.inspect\n puts \"error on #{url}\"\n errors << url\n end\n end\n\n errors\n end", "def baseurl=(_arg0); end", "def reset\n\t\t\t@curb = nil\n\t\t\tinitialize_curl\n\t\tend", "def initialize(url, &block)\n super(url)\n @handlers = {}\n instance_eval(&block)\n end", "def initialize \n @root =\"http://web.archive.org/web/20030820233527/\" +\n \"http://bytravelers.com/journal/entry\" # Initialize the variables. The root of the URL to the cached copy of the site is here. \n @agent = Mechanize.new\n end", "def initialize(username , limit)\n @username = username\n @limit = limit\n #pass only the username into methods so we generate the urls we need as we scrape them\n #dont call the next method here, use the object created in its place of creaton\n #to call further scraping methods class methods\n end", "def start threads_count = 10\n\n SuperCrawler::Render.crawling_start_notice( @start_url, threads_count ) if @option_debug # Show message on what will happen\n\n threads = [] # Will contain our n-threads\n @links_queue = Queue.new # Will contain the links queue that the threads will use\n @links = [@start_url] # Re-init the links list\n @crawl_results = [] # Re-init the crawling results\n\n start_time = Time.now if @option_debug # Start the timer\n\n # Let's populate our queue with links and resources from source url\n process_page( @start_url )\n\n # Create threads to handle new links\n threads_count.times do # Create threads_count threads\n\n threads << Thread.new do # Instantiate a new threads\n begin\n while current_link = @links_queue.pop(true) # Pop one link after another\n process_page( current_link ) # Get links and assets of the popped link\n end\n rescue ThreadError # Stop when empty links queue\n end\n end\n\n end\n\n threads.map(&:join) # Activate the threads\n SuperCrawler::Render.crawling_summary_notice(Time.now - start_time, threads_count, @links.count) if @option_debug # Display crawling summary\n\n return true\n end", "def crawl\n while NG_URL.where(:a_hrefs_unprocessed => { :$not => { :$size => 0}}).count > 0 do\n next_unprocessed_url\n end\n end", "def initialize_servers\n @protocols.each do |protocol, _|\n server = @servers[protocol.protocol]\n block = server[:start]\n server[:server].start(server[:port], @routes[protocol.protocol], views: @views, channel: @channels[protocol.protocol], debug: @debug, &block)\n end\n end", "def prepend_urls \n unless check_url(self.homepage_url)\n self.homepage_url = \"http://#{self.homepage_url}\"\n end\n unless check_url(self.source_url)\n self.source_url = \"http://#{self.source_url}\"\n end\n unless check_url(self.author_contact)\n self.author_contact = \"http://#{self.author_contact}\"\n end\n end", "def run\n super\n\n # TODO - this shouldn't be static\n f = download_and_store \"https://s3.amazonaws.com/public.intrigue.io/top-1m-2018-04-20.csv\"\n\n # Read and split the file up into a list of domains\n lines = File.open(f,\"r\").read.split(\"\\n\")\n domains = lines.map{|l| l.split(\",\").last.chomp }\n\n lammylam = lambda { |d|\n sleep(rand(_get_option(\"max_sleep\")))\n #_log \"Creating sites for domain: #{d}\"\n #_create_entity \"Uri\", { \"name\" => \"http://#{d}\", \"uri\"=>\"https://#{d}\" }\n _create_entity \"Uri\", { \"name\" => \"https://#{d}\", \"uri\"=>\"https://#{d}\" }\n true\n }\n\n # use a generic threaded iteration method to create them,\n # with the desired number of threads\n thread_count = _get_option \"threads\"\n _threaded_iteration(thread_count, domains, lammylam)\n\n end", "def loop_threads_and_fetch_url(url_list)\n if @@url_hash.size < @@max_url\n unless url_list.empty?\n if running_thread_count() >= 5\n sleep @@sleep_timer*60\n loop_threads_and_fetch_url(url_list)\n else\n url_list = url_list.map { |url| url if get_host_without_www(url) == 'medium.com' }.compact\n save_data(url_list)\n new_urls_to_scrap = update_url_hash(url_list).compact\n @@retry_counter = 0 #setting the value for every new request\n generate_thread(new_urls_to_scrap)\n end\n end\n end\n end", "def crawled_urls(limit: 0, skip: 0, &block)\n urls(crawled: true, limit: limit, skip: skip, &block)\n end", "def crawled_urls(limit: 0, skip: 0, &block)\n urls(crawled: true, limit: limit, skip: skip, &block)\n end", "def get_pages(user_agent, browser_threads, follow_a_link, proxy_server, proxy_port, proxy_username, proxy_password)\r\n\t\t@pages_thread = Thread.new do\r\n\t\t\tputs \"<httpResponses>\"\r\n\t\t\twhile(tmp_http_request = @http_requests.pop)\r\n\t\t\t\t@thread_pool.dispatch(tmp_http_request, self) do |http_request, browser|\r\n\t\t\t\t\turl = URI.parse(URI.escape(http_request.uri)) #url encoding happens here\r\n\t\t\t\t\talready_visited = false\r\n\t\t\t\t\t@uri_cache_mutex.synchronize do\r\n\t\t\t\t\t already_visited = @uri_cache.include?(url)\r\n\t\t\t\t\t @uri_cache.shift if(@uri_cache.size>@uri_cache_max_size)\r\n\t\t\t\t\t @uri_cache.push(url)\r\n\t\t\t\t\tend\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(!already_visited)\r\n\t\t\t\t\t url_tmp = url\r\n\t\t\t\t\t follow_redirects = 10\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t loop do \r\n\t\t\t\t\t\t raise \"host name unknown\" if @non_exist_servers.include?(url_tmp.host)\r\n\t\t\t\t\t\t path = url_tmp.path\r\n\t\t\t\t\t\t path = \"/\" if path == \"\" #needed because otherwise error msg of empty req path results\r\n\t\t\t\t\t\t query = \"?\" + URI.escape(url_tmp.query.to_s) if url_tmp.query != nil\r\n\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t if(proxy_username != \"\")\r\n\t\t\t\t\t\t\t results = Net::HTTP::Proxy(proxy_server, proxy_port, proxy_username, proxy_password).start(url_tmp.host,url_tmp.port) { |http| \r\n\t\t\t\t\t\t\t\t http.read_timeout = @timeout \r\n\t\t\t\t\t\t\t\t http.request_get(path + query.to_s, {'User-Agent' => user_agent})\r\n\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t elsif(proxy_server != \"\") \r\n\t\t\t\t\t\t\t results = Net::HTTP::Proxy(proxy_server, proxy_port).start(url_tmp.host,url_tmp.port) { |http| \r\n\t\t\t\t\t\t\t\t http.read_timeout = @timeout \r\n\t\t\t\t\t\t\t\t http.request_get(path + query.to_s, {'User-Agent' => user_agent})\r\n\t\t\t\t\t\t\t }\t\t\t\t\t\r\n\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t results = Net::HTTP.start(url_tmp.host,url_tmp.port) { |http| \r\n\t\t\t\t\t\t\t\t http.read_timeout = @timeout \r\n\t\t\t\t\t\t\t\t http.request_get(path + query.to_s, {'User-Agent' => user_agent})\r\n\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t case results\r\n\t\t\t\t\t\t\t when Net::HTTPSuccess\r\n\t\t\t\t\t\t\t\t http_response = HttpResponse.new(http_request.uri,results.code.to_s + \" - OK\",results.body, results.to_hash)\r\n\t\t\t\t\t\t\t\t if(http_request.follow_link)\r\n\t\t\t\t\t\t\t\t\t results.body.scan(/src\\s*=\\s*\\\"(.*?)\\\"/im) { |links| \r\n\t\t\t\t\t\t\t\t\t\t for link in links \r\n\t\t\t\t\t\t\t\t\t\t\t link = WebBrowser.build_url(url_tmp.scheme + \"://\" + url_tmp.host.to_s + path, link)\r\n\t\t\t\t\t\t\t\t\t\t\t inline_http_request = HttpRequest.new(link)\r\n\t\t\t\t\t\t\t\t\t\t\t inline_http_request.follow_link = false\r\n\t\t\t\t\t\t\t\t\t\t\t @http_requests.push(inline_http_request) if(!WebBrowser.filtered?(@url_filter,link))\r\n\t\t\t\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t\t\t\t results.body.scan(/data\\s*=\\s*\\\"(.*?)\\\"/im) { |links| \r\n\t\t\t\t\t\t\t\t\t\t for link in links \r\n\t\t\t\t\t\t\t\t\t\t\t link = WebBrowser.build_url(url_tmp.scheme + \"://\" + url_tmp.host.to_s + path, link)\r\n\t\t\t\t\t\t\t\t\t\t\t inline_http_request = HttpRequest.new(link)\r\n\t\t\t\t\t\t\t\t\t\t\t inline_http_request.follow_link = false\r\n\t\t\t\t\t\t\t\t\t\t\t @http_requests.push(inline_http_request) if(!WebBrowser.filtered?(@url_filter,link))\r\n\t\t\t\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\t output_http_response(http_response)\r\n\t\t\t\t\t\t\t\t break\r\n\t\t\t\t\t\t\t when Net::HTTPRedirection \r\n\t\t\t\t\t\t\t\t redirect_location = WebBrowser.build_url(url_tmp.scheme + \"://\" + url_tmp.host.to_s + path, results['location'])\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t url_tmp = URI.parse(URI.escape(redirect_location.to_s))\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t follow_redirects= follow_redirects - 1\r\n\t\t\t\t\t\t\t\t if(follow_redirects < 0)\r\n\t\t\t\t\t\t\t\t\t http_response = HttpResponse.new(http_request.uri,results.code.to_s + \" - Too many redirects.\",\"\", Hash.new)\r\n\t\t\t\t\t\t\t\t\t output_http_response(http_response)\r\n\t\t\t\t\t\t\t\t\t break\r\n\t\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t\t http_response = HttpResponse.new(http_request.uri,results.code.to_s + \" - \" + results.message.to_s,\"\", Hash.new)\r\n\t\t\t\t\t\t\t\t output_http_response(http_response)\r\n\t\t\t\t\t\t\t\t break\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t end\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\t\t@pages_thread_alive = false\r\n\t\t\r\n\r\n\tend", "def initialize_url_filters\n # We use a hash which tells the domains to filter.\n # The hash value tells that if company name contains that string then don't filter\n @url_filter = Hash.new\n @url_filter[\"facebook.com\"] = \"facebook\"\n @url_filter[\"linkedin.com\"] = \"linkedin\"\n @url_filter[\"wikipedia.org\"] = \"wikipedia\"\n @url_filter[\"yahoo.com\"] = \"yahoo\"\n @url_filter[\"zdnet.com\"] = \"zdnet\"\n @url_filter[\"yelp.com\"] = \"yelp\"\n @url_filter[\"yellowpages.com\"] = \"yellowpages\"\n @url_filter[\"thefreelibrary.com\"] = \"thefreelibrary\"\n @url_filter[\"thefreedictionary.com\"] = \"thefreedictionary\"\n @url_filter[\"superpages.com\"] = \"superpages\"\n @url_filter[\"businessweek.com\"] = \"week\"\n @url_filter[\"indiamart.com\"] = \"mart\"\n @url_filter[\"naukri.com\"] = \"naukri\"\n @url_filter[\"monsterindia.com\"] = \"monster\"\n @url_filter[\"answers.com\"] = \"answers\"\n @url_filter[\"sulekha.com\"] = \"sulekha\"\n @url_filter[\"asklaila.com\"] = \"asklaila\"\n @url_filter[\"blogspot.com\"] = \"blogspot\"\n @url_filter[\"manta.com\"] = \"manta\"\n @url_filter[\"zoominfo.com\"] = \"zoom\"\n @url_filter[\"twitter.com\"] = \"twitter\"\n @url_filter[\"hotfrog.com\"] = \"hotfrog\"\n @url_filter[\"amazon.com\"] = \"amazon\"\n end", "def urls\n each_url.to_set\n end", "def init\n @calls = []\n @accept_nodes = []\n @connected_nodes = nil\n @remote_bash_code = nil\n end", "def init\t\n\tenable :static\n\tset :statics_folder, 'statics'\n\tset :deep_or_flat_structure, 'flat'\n\n\tset :public_folder, settings.statics_folder\n\n\tset :page_pool, page_pool()\nend", "def get_urls()\n if (! ENV['names'])\n # We have no hosts to check, let's bail\n exit 1\n end\n urls = []\n i = 1\n ENV['names'].split(\" \").each do |cururl|\n thisurl = {}\n # Label and url are required.\n thisurl[:label] = ENV[\"label_#{cururl}\"]\n thisurl[:url] = ENV[\"url_#{cururl}\"]\n thisurl[:name] = cururl\n # optional parameters\n thisurl[:warning] = (ENV[\"warning_#{cururl}\"].nil?)? 0 : ENV[\"warning_#{cururl}\"]\n thisurl[:critical] = (ENV[\"critical_#{cururl}\"].nil?)? 0 : ENV[\"critical_#{cururl}\"]\n thisurl[:max] = (ENV[\"max\"].nil?)? DEFAULT_MAX : ENV[\"max\"]\n thisurl[:port] = (ENV[\"port_#{cururl}\"].nil?)? nil : ENV[\"port_#{cururl}\"]\n thisurl[:path] = (ENV[\"path_#{cururl}\"].nil?)? nil : ENV[\"path_#{cururl}\"]\n thisurl[:wget_post_data] = (ENV[\"wget_post_data_#{cururl}\"].nil?)? nil : ENV[\"wget_post_data_#{cururl}\"]\n thisurl[:error_value] = (ENV[\"error_value_#{cururl}\"].nil?)? nil : ENV[\"error_value_#{cururl}\"]\n thisurl[:regex_error_value] = (ENV[\"regex_error_value_#{cururl}\"].nil?)? nil : ENV[\"regex_error_value_#{cururl}\"]\n thisurl[:regex_header_1] = (ENV[\"regex_header_1_#{cururl}\"].nil?)? nil : ENV[\"regex_header_1_#{cururl}\"]\n thisurl[:grep_opts] = (ENV[\"grep_opts_#{cururl}\"].nil?)? nil : ENV[\"grep_opts_#{cururl}\"]\n thisurl[:wget_opts] = (ENV[\"wget_opts_#{cururl}\"].nil?)? nil : ENV[\"wget_opts_#{cururl}\"]\n thisurl[:join_lines] = (ENV[\"join_lines_#{cururl}\"].nil?)? nil : ENV[\"join_lines_#{cururl}\"]\n thisurl[:index] = i\n thisurl[:wget_output_file] = DATA_DIR + \"/tmp/wget_output_\"+cururl\n urls[i-1] = thisurl\n i+=1\n end\n return urls\nend", "def initialize\n raise NotImplementedError, 'need to implement #intialize and set @url'\n end", "def setup\n clear_db\n\n @url = Wgit::Url.new(Wgit::DatabaseDefaultData.url)\n @doc = Wgit::Document.new(Wgit::DatabaseDefaultData.doc)\n\n records = 3\n\n @urls = []\n records.times do\n @urls << Wgit::Url.new(Wgit::DatabaseDefaultData.url)\n end\n\n @docs = []\n records.times do\n @docs << Wgit::Document.new(Wgit::DatabaseDefaultData.doc)\n end\n end", "def _init\n unless @_initialized\n @_initialized = true\n self.routes = Array.new\n self.mutex = Mutex.new\n end\n end", "def pre_connect(request); end", "def index\n if !/(scrape)/.match(request.url).nil?\n # obviously temporary \n commence_scraping\n elsif !/(releases.json)/.match(request.url).nil?\n get_releases\n elsif !/(videos.json)/.match(request.url).nil?\n get_youtube\n elsif !/(merch.json)/.match(request.url).nil?\n get_merch\n elsif !/(youtube_api_fetch)/.match(request.url).nil?\n youtube_api_fetch\n end\n end", "def crawl\n if not @crawling\n @completed = false\n @located_products = []\n \n @thread = Thread.new { \n traverse(@base_url) \n @crawling = false\n @completed = true\n }\n\n @crawling = true\n else\n raise \"Already crawling. Stop current crawl job before starting another.\"\n end\n end", "def initialize(configuration_file_location)\r\n\t\tSTDOUT.binmode\r\n\t\tSTDIN.sync = true\r\n\t\tSTDOUT.sync = true\r\n\t\t@timeout = 30\r\n\t\r\n\t\t@non_exist_servers = Array.new\r\n\t\t@non_exist_servers_max_size = 10000\r\n\t\t\r\n\t\t@uri_cache_max_size = 10000 \r\n\t\t@uri_cache = Array.new\r\n\t\t@uri_cache_mutex = Mutex.new\r\n\t\t\r\n\t\tweb_browser_configuration = WebBrowserConfiguration.new(configuration_file_location)\r\n\t\tfollow_a_link = web_browser_configuration.follow_a_link\r\n\t\tbrowser_threads = web_browser_configuration.browser_threads\r\n\t\tuser_agent = web_browser_configuration.user_agent\r\n\t\tproxy_server = web_browser_configuration.server\r\n\t\tproxy_port = web_browser_configuration.port\r\n\t\tproxy_username = web_browser_configuration.username\r\n\t\tproxy_password = web_browser_configuration.password\r\n\t\t\r\n\t\t@url_filter = Regexp.compile(web_browser_configuration.url_filter) if web_browser_configuration.url_filter!=nil\r\n\t\t\r\n\t\t@thread_pool = ThreadPool.new(browser_threads)\t\t\r\n\t\t@http_requests = SizedQueue.new(browser_threads*5)\r\n\t\t@output_buffer_mutex = Mutex.new\r\n\t\t\r\n\t\t@pages_thread_alive = true\r\n\t\tget_uris\r\n\t\tget_pages(user_agent, browser_threads, follow_a_link, proxy_server, proxy_port, proxy_username, proxy_password)\r\n\t\t@pages_thread.join\r\n\t\t@uris_thread.join\r\n\t\t@thread_pool.shutdown\r\n\t\tputs \"</httpResponses>\"\r\n\tend", "def course_setup(course_details)\n @app.course_request_page.visit\n course_details.each do |key, course|\n @app.course_request_page.fill_form fullname: course[:fullname], shortname: course[:shortname], summary: course[:summary], reason: course[:reason]\n @app.course_request_page.visit\n end\n @app.logout\n @app.login.visit\n @app.login.admin_login\n course_details.each do |key, course|\n @app.course_pending.visit\n @app.course_pending.approve course[:fullname]\n COURSE_ID[course[:fullname].to_sym] = @app.course_approved.get_course_id\n end\n @app.logout\nend", "def initialize\n countries.each do |country|\n\t\t\tRails.cache.fetch(country[:code]) do\n\t\t\t\tJSON.parse(Net::HTTP.get(URI.parse(\"https://api.fitpass.mx/v3/cities.json?country=#{country[:code]}\")))\n\t\t\tend\n end\n\tend", "def set_callbacks\n Curl.set_option(:writefunction, body_write_callback, handle)\n Curl.set_option(:headerfunction, header_write_callback, handle)\n Curl.set_option(:debugfunction, debug_callback, handle)\n @response_body = String.new\n @response_headers = String.new\n @headers_called = false\n @debug_info = Ethon::Easy::DebugInfo.new\n end", "def crawl_workers (targets,num=@max_parallel)\n\t\tbegin\n\t\t\traise \"Input error - expecting targets in an array format: #{targets}\" unless targets.kind_of? Array\n\t\t\tputs \"Sanitize the URL seeds to eliminate the unnecessary duplication(s) ...\" if @verbose\n\t\t\t#puts \"This could be awhile depending on the list size. Please be patient ...\"\n\t\t\t# 09/30/2013 Add additional logic to eliminate the duplicate target site(s) before the crawlers are invoked. \n\t\t\ttargets -= [\"\", nil]\n\t\t\tuniq_sites=Hash.new\n\t\t\ttargets.dup.map do |target|\n\t\t\t\tif is_url?(target)\n\t\t\t\t\thost=url_2_host(target)\n\t\t\t\t\tip=host_2_ip(host).to_s\n\t\t\t\t\tnext if ip.nil?\n\t\t\t\t\tport=url_2_port(target).to_s\n\t\t\t\t\tnext if port.nil?\n\t\t\t\t\tsite_key=ip+\":\"+port\n\t\t\t\t\tunless uniq_sites.key?(site_key)\n\t\t\t\t\t\tuniq_sites[site_key]=target\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs \"Sanitization done! \" if @verbose\n\t\t\tputs \"Start the parallel engine on the normalized crawling list:\\n #{targets} \"\t\n\t\t\tputs \"Maximum number of web crawling sessions allowed: #{num}\" #if @verbose\n\t\t\traise \"Error: target list is empty!\" if targets.size < 1\n\t\t\tParallel.map(uniq_sites.values, :in_processes => num) { |target|\n\t\t\t\tputs \"Working on #{target} ...\" if @verbose\n\t\t\t\tcrawl(target)\n\t\t\t}.dup.each do |process| \n\t\t\t\tputs \"process.inspect: #{process}\" if @verbose\n\t\t\t\turls=process\n\t\t\t\turls-=[\"\",nil] unless urls.nil?\n\t\t\t\tif urls.nil?\n\t\t\t\t\tnext\n\t\t\t\telsif urls.empty?\n\t\t\t\t\tnext\n\t\t\t\t\t#do nothing\n\t\t\t\telse\n\t\t\t\t\turls.map do |url|\n\t\t\t\t\t\turl.strip!\n\t\t\t\t\t\t@discovered_urls_by_crawler[url]=true unless @discovered_urls_by_crawler.key?(url)\n\t\t\t\t\t\t#$discovered_urls[url]=true unless $discovered_urls.key?(url)\n\t\t\t\t\tend\n\t\t\t\tend\t\t\t\t\n\t\t\tend\t\n\t\t\t#return sites\n\t\t\treturn @discovered_urls_by_crawler.keys\n\t\trescue Exception => ee\n\t\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\t\n\tend", "def initialize(website)\n\t\t@subpages = website.subpages\n\t\t@base_url = website.base_url\n\t\t@pattern_finder, @pattern_tester = PatternFinder.new(website), PatternTester.new(@subpages)\n\t\t@crawler_patterns, @duplicate_patterns = [], []\n\tend", "def initialize(linkfinder,baseURI)\r\n @results={\r\n :uris404=>[],\r\n :uris200=>[],\r\n :urisUnknown=>[],\r\n :checked=>{},\r\n :urisNonHTTP=>[]\r\n }\r\n @linkfinder=linkfinder\r\n @baseURI=baseURI\r\n end", "def initialize\n #load_config\n load_routes\n end", "def continue_crawl\n # puts \"I am on #{@url} (#{@links.size} links)-> I want to navigate to #{@links.map{|l| l['href']}}\" #links - Array\n\n @links.each_with_index do |link, i|\n href = link[\"href\"]\n next if href.blank? or (href.split('/').last && href.split('/').last.starts_with?(\"#\"))\n if not href.starts_with?(\"htt\")\n href = href[1..-1] if href.starts_with?('/')\n href = @stored_page.domain + '/' + href\n end\n if page_found = Page.find_by_address_and_crawler_id(href, @crwlr.id)\n #puts \"Loop for #{href}\"\n if @stored_page #Page\n @stored_page.pages << page_found\n end\n else\n #puts \"Adding job for CID: #{@crwlr.id} HREF: #{href} SPID: #{@stored_page.id} #{} #{} #{}\"\n @stack.enqueue Crawl.new(@crwlr.id, href, @depth+1, @stack, @stored_page.id, @options)\n end\n end\n end", "def register_callbacks!\n on_url do |url|\n if spider?\n log \"Adding url #{url}\"\n @spider.add_url(url) \n else\n log \"reached maximum depth\"\n end\n end\n \n on_page_complete do \n if spider?\n next_page!\n end\n end\n \n end", "def crawlAllPages\n page = 1\n loop do\n puts \"Path: #{@basePath}#{page.to_s}\"\n path \"#{@basePath}#{page.to_s}\"\n\n response = crawl\n @dbm.insertCrawlerBlob response[\"beers\"]\n\n break if response[\"more\"].nil?\n page += 1\n end\n end", "def crawl_parser(results)\n\t\tputs \"[\".light_green + \"*\".white + \"] OK\".light_green + \", \".white + \"running parser on\".light_green + \": #{results}\".white\n\t\timportant = File.open(results, \"r\") #place our found links in variable to manipulate and search as needed\n\t\trezDir = \"#{$results}#{@zsite}/\" #Our results dir for this site which has been already created in first function cycles\n\n\t\t# placeholder arrays for sorting and finding unique testable links\n\t\tspreadsheetz=[]; executablez=[]; no_params=[]; test_keys=[]; noparamz=[]; archivez=[]; testlink=[]; opendocz=[]; outlookz=[]; paramz=[]; imagez=[];\n\t\taudioz=[]; videoz=[]; flashz=[]; multi=[]; vcardz=[]; bkupz=[]; jsz=[]; confz=[]; wordz=[]; xmlz=[]; pazz=[]; pdfz=[]; txtz=[]; pptz=[]; dbz=[];\n\n\t\tmcount=0 #Multi Parameter Links Count\n\t\tscount=0 #Single Parameter Links Count\n\t\tnocount=0 #No Parameter Links Count\n\n\t\t#loop through content of crawler.links file line by line...\n\t\timportant.each do |line|\n\t\t\tbegin\n\t\t\t\t#parse out parameters if they are present, if not will error NoMethodError and be handled there with rescue\n\t\t\t\tparam = URI.parse(line).query\n\n\t\t\t\t#break paramaters into hash [ \"@key\" => \"@value\" ] formatting held in storage for easier manipulation\n\t\t\t\tparamsHash = Hash[URI.parse(line).query.split('&').map{ |q| q.split('=') }] \n\n\t\t\t\t# Parse according to the number of parameters in link\t\t\n\t\t\t\t###### Handle Single Parameter links ######\n\t\t\t\tif paramsHash.length == 1\n\t\t\t\t\tscount += 1\n\t\t\t\t\tparamz << line\n\t\t\t\t\tparamsHash.each do |key, value|\n\t\t\t\t\t\tif value =~ /\\d+/ #if value is numerical replace with number and then we unique ;)\n\t\t\t\t\t\t\ttestlink << line.sub(/#{value}/, '1') \n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttestlink << line #keep strings since they can be funky sometimes\n\t\t\t\t\t\tend\n\t\t\t\t\tend #finish cycle\n\n\t\t\t\telsif \"#{paramsHash.length}\".to_i > 1\n\t\t\t\t\t###### Handle Multi Parameter links ######\n\t\t\t\t\tmcount += 1\n\t\t\t\t\tparamz << line\n\t\t\t\t\t#Test each link and see if the parameter key has been logged or not, this way we only get unique paramter links ;)\n\t\t\t\t\tparamsHash.keys.each do |key|\n\t\t\t\t\t\tif test_keys.include?(key)\n\t\t\t\t\t\t\t#Do Nothing, its already included in our test_keys array!\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t#Unique paramter, include key in test_key array and URL link in multi array for injector tests l8r\n\t\t\t\t\t\t\ttest_keys << key #so we dont catch anymore links with this parameter\n\t\t\t\t\t\t\tmulti << line.chomp #so we note the link for injection tests\n\t\t\t\t\t\tend\n\t\t\t\t\tend#end hash.key cycle\n\t\t\t\tend # parameter check looping\n\n\t\t\t###### Handle NO Parameter links ######\n\t\t\trescue NoMethodError\n\t\t\t\t# We really only need to check a few links without params to see if they throw errors (URL re-write type stuff hiding)\n\t\t\t\tnocount += 1\n\t\t\t\tif nocount < 10 # gives us up to 15 no parameter links to check, more than enough\n\t\t\t\t\tno_params << line\n\t\t\t\tend\n\n\t\t\t\t#Parse over links we're ditching & sort into appropriate results files (in case that info is needed for follow up l8r)\n\t\t\t\tif /\\/.+\\.pdf/i.match(line)\n\t\t\t\t\tpdfz << line.chomp\n\t\t\t\telsif /\\/.+\\.doc/i.match(line)\n\t\t\t\t\twordz << line.chomp\n\t\t\t\telsif /\\/.+\\.js|\\/.+\\.javascript/i.match(line)\n\t\t\t\t\tjsz << line.chomp\n\t\t\t\telsif /\\/.+\\.txt|\\/.+\\.rtf/i.match(line)\n\t\t\t\t\ttxtz << line.chomp\n\t\t\t\telsif /\\/.+\\.png|\\/.+\\.jpg|\\/.+\\.jpeg|\\/.+\\.gif|\\/.+\\.bmp|\\/.+\\.exif|\\/.+\\.tiff/i.match(line)\n\t\t\t\t\timagez << line.chomp\n\t\t\t\telsif /\\/.+\\.msg/i.match(line)\n\t\t\t\t\toutlookz << line.chomp\n\t\t\t\telsif /\\/.+\\.odt/i.match(line)\n\t\t\t\t\topendocz << line.chomp\n\t\t\t\telsif /\\/.+\\.csv|\\/.+\\.xlr|\\/.+\\.xls/i.match(line)\n\t\t\t\t\tspreadsheetz << line.chomp\n\t\t\t\telsif /\\/.+\\.pps|\\/.+\\.ppt/i.match(line)\n\t\t\t\t\tpptz << line.chomp\n\t\t\t\telsif /\\/.+\\.tar|\\/.+\\.zip|\\/.+\\.7z|\\/.+\\.cbr|\\/.+\\.deb|\\/.+\\.gz|\\/.+\\.bz|\\/.+\\.pkg|\\/.+\\.rar|\\/.+\\.rpm|\\/.+\\.sit/i.match(line)\n\t\t\t\t\tarchivez << line.chomp\n\t\t\t\telsif /\\/.+\\.vcf/i.match(line)\n\t\t\t\t\tvcardz << line.chomp\n\t\t\t\telsif /\\/.+\\.xml/i.match(line)\n\t\t\t\t\txmlz << line.chomp\n\t\t\t\telsif /\\/.+\\.m3u|\\/.+\\.m4a|\\/.+\\.mp3|\\/.+\\.mpa|\\/.+\\.wav|\\/.+\\.wma/i.match(line)\n\t\t\t\t\taudioz << line.chomp\n\t\t\t\telsif /\\/.+\\.avi|\\/.+\\.mov|\\/.+\\.mp4|\\/.+\\.mpg|\\/.+\\.srt|\\/.+\\.vob|\\/.+\\.wmv/i.match(line)\n\t\t\t\t\tvideoz << line.chomp\n\t\t\t\telsif /\\/.+\\.swf|\\/.+\\.flv/i.match(line)\n\t\t\t\t\tflashz << line.chomp\n\t\t\t\telsif /\\/.+\\.sql|\\/.+\\.accdb|\\/.+\\.db|\\/.+\\.mdb|\\/.+\\.pdb/i.match(line)\n\t\t\t\t\tdbz << line.chomp\n\t\t\t\telsif /\\/.+\\.apk|\\/.+\\.app|\\/.+\\.bat|\\/.+\\.cgi|\\/.+\\.exe|\\/.+\\.gadget|\\/.+\\.jar|\\/.+\\.pif|\\/.+\\.vbs|\\/.+\\.wsf/i.match(line)\n\t\t\t\t\texecutablez << line.chomp\n\t\t\t\telsif /\\/.+\\.bak|\\/.+\\.tmp|\\/.+\\.bk/i.match(line)\n\t\t\t\t\tbkupz << line.chomp\n\t\t\t\telsif /\\/.+\\.conf/i.match(line)\n\t\t\t\t\tconfz << line.chomp\n\t\t\t\telsif /\\/.+\\.passwd|\\/.+\\.htpasswd/i.match(line)\n\t\t\t\t\tpazz << line.chomp\n\t\t\t\telse\n\t\t\t\t\tnoparamz << line\n\t\t\t\tend\n\t\t\tend #End begin/rescue block\n\t\tend\n\n\t\t#make sure we dont have duplicates\n\t\tno_params = no_params.uniq\n\t\ttest_keys = test_keys.uniq\n\t\ttestlink = testlink.uniq\n\t\tmulti = multi.uniq\n\t\tinjtestlinks=[]\n\n\t\tputs \"[\".light_green + \"*\".white + \"] Crawler Results\".light_green + \": \".white\n\t\t#Write found NO parameter links to their own file just like everything else, just these dont fall into any group\n\t\tcount=0\n\t\tif not noparamz.empty?\n\t\t\tzfile=\"NO_paramaters\"\n\t\t\tnoparamz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\") #Open our file handle in write mode\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\") #Open our file handle in append mode\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\" #write the hits to file \n\t\t\t\tlostANDfound.close #close our file handle we opened a minute ago\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{noparamz.length} Links in total with NO paramaters in them\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not paramz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"paramater\"\n\t\t\tparamz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links in total with paramaters in them\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not jsz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"JS\"\n\t\t\tjsz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for JS Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not pdfz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"PDF\"\n\t\t\tpdfz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for PDF Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not wordz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"MS_WORD\"\n\t\t\twordz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for MS Word Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not txtz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"TEXT\"\n\t\t\ttxtz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for TEXT Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not outlookz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"OUTLOOK-MSG\"\n\t\t\toutlookz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for OUTLOOK-MSG Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not opendocz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"OpenDoc\"\n\t\t\topendocz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for OpenDoc Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not spreadsheetz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"SpreadSheet\"\n\t\t\tspreadsheetz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for SpreadSheet Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not pptz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"PowerPoint\"\n\t\t\tpptz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for PowerPoint Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not archivez.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"ARCHIVE\"\n\t\t\tarchivez.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for ARCHIVE Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not vcardz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"vCard\"\n\t\t\tvcardz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for vCard Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not xmlz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"XML\"\n\t\t\txmlz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for XML Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not audioz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"AUDIO\"\n\t\t\taudioz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for AUDIO Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not videoz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"VIDEO\"\n\t\t\tvideoz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for VIDEO Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not flashz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"FLASH\"\n\t\t\tflashz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for FLASH Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not dbz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"DATABASE\"\n\t\t\tdbz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for DATABASE Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not executablez.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"EXECUTABLES\"\n\t\t\texecutablez.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for EXECUTABLES Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not bkupz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"BackUp\"\n\t\t\tbkupz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for BackUp Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not confz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"CONFIG\"\n\t\t\tconfz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for CONFIG Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not pazz.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"PASSWORDS\"\n\t\t\tpazz.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for PASSWORDS Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tif not imagez.empty?\n\t\t\tcount=0\n\t\t\tzfile=\"IMAGE\"\n\t\t\timagez.each do |line|\n\t\t\t\tif count.to_i < 1\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"w+\")\n\t\t\t\t\tcount = count.to_i + 1\n\t\t\t\telse\n\t\t\t\t\tlostANDfound = File.new(\"#{rezDir}#{zfile}.links\", \"a+\")\n\t\t\t\tend\n\t\t\t\tlostANDfound.puts \"#{line.chomp}\"\n\t\t\t\tlostANDfound.close\n\t\t\tend\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{paramz.length} Links for IMAGE Files\".light_green + \": #{rezDir}#{zfile}.links\".white\n\t\tend\n\t\tputs \"[\".light_green + \"*\".white + \"] Other Info\".light_green + \".....\".white\n\t\tif not test_keys.empty?\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{test_keys.length} Testable Parameters\".light_green + \": \".white\n\t\t\tputs \"[\".light_green + \"*\".white + \"] \".light_green + \"#{test_keys.join(', ').to_s}\".white\n\t\tend\n\t\tif not testlink.empty?\n\t\t\t#print single parameter links we will test\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{testlink.length} Unique Single Parameter Links (out of #{scount} total)\".light_green + \": \".white\n\t\t\ttestlink.each do |line|\n\t\t\t\tputs \"\\t#{line.chomp}\".white\n\t\t\t\tinjtestlinks << line\n\t\t\tend\n\t\tend\n\t\tif not multi.empty?\n\t\t\t#print multi parameter links we will test\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{multi.length} Unique Multi Parameter Links (out of #{mcount} total)\".light_green + \":\".white\n\t\t\tmulti.each do |line|\n\t\t\t\tputs \"\\t#{line.chomp}\".white\n\t\t\t\tinjtestlinks << line\n\t\t\tend\n\t\tend\n\t\tif not no_params.empty?\n\t\t\tif no_params.length < 9\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] Found the following NO Parameter links\".light_green + \": \".white\n\t\t\t\tnopam = no_params\n\t\t\telse\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] 10 random No Parameter Links (out of #{nocount} total)\".light_green + \": \".white\n\t\t\t\tnopam = no_params.sort_by{rand}[0..9]\n\t\t\tend\n\t\t\t#print no parameter links we will test\n\t\t\tnopam.each do |line|\n\t\t\t\tputs \"\\t#{line.chomp}\".white\n\t\t\t\tinjtestlinks << line\n\t\t\tend\n\t\tend\n\t\tif not injtestlinks.empty?\n\t\t\t#Write the suggested testable links to their own file for use with other tools\n\t\t\tf = File.new(\"#{rezDir}testable.links\", \"w+\")\n\t\t\tinjtestlinks.each do |link|\n\t\t\t\tf.puts link\n\t\t\tend\n\t\t\tf.close\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Suggested Testable Links\".light_green + \": #{rezDir}testable.links\".white\n\t\tend\n\t\t#Display the emails found now....\n\t\tif not @emails_array.empty?\n\t\t\t@emails_array.uniq!\n\t\t\tf=File.open(\"#{rezDir}temp.emails\", 'w+')\n\t\t\t@emails_array.each do |email|\n\t\t\t\tf.puts email\n\t\t\tend\n\t\t\tf.close\n\t\t\t#Because Ruby built-in uniq function doesn't seem to be fully doing the job we use some OS magic to make sure it is unique emails only....\n\t\t\tsystem(\"cat #{rezDir}temp.emails | sort -u > #{rezDir}emails.txt\")\n\t\t\tcount=`wc -l #{rezDir}emails.txt | cut -d' ' -f1`\n\t\t\tFileUtils.rm(\"#{rezDir}temp.emails\")\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Found #{count} emails while crawling\".light_green + \"....\".white\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Find them here\".light_green + \": #{rezDir}emails.txt\".white\n\t\tend\n\tend", "def setup\n @url_str = 'http://www.google.co.uk'\n @bad_url_str = 'my_server'\n @link = '/about.html'\n @url_str_link = \"#{@url_str}#{@link}\"\n @url_str_anchor = \"#{@url_str_link}#about-us\"\n @url_str_query = \"#{@url_str_link}?foo=bar\"\n @iri = 'https://www.über.com/about#top'\n @time_stamp = Time.new\n @mongo_doc_dup = {\n 'url' => @url_str,\n 'crawled' => true,\n 'date_crawled' => @time_stamp\n }\n end", "def process_vcr_cassette_in dir\n return if build_cache_link_present_already_expanded?\n\n pid = fork do\n # Remove existing data\n FileUtils.rm_rf Dir.glob(dir.join(\"*\").to_s)\n\n app_route_map = {}\n vcr = YAML.load_file @response_file\n vcr[\"http_interactions\"].each do |http|\n request_uri = URI.parse http[\"request\"][\"uri\"]\n local_path = dir.join request_uri.path[1..-1]\n local_path = local_path.join \"index.html\" if local_path.basename.to_s == \"v1\";\n\n FileUtils.mkdir_p local_path.dirname\n local_path.write http[\"response\"][\"body\"][\"string\"]\n\n app_route_map[request_uri.path.dup] = {\n :response_path => local_path.expand_path.to_s,\n :path => request_uri.path.dup,\n :method => http[\"request\"][\"method\"].upcase,\n :status => http[\"response\"][\"status\"],\n :headers => http[\"response\"][\"headers\"],\n :token => fetch_token_for(http)\n }\n end\n\n # @app_route_map that will be loaded by the main process\n File.write dir.join(\"__app_route_map\"),\n Marshal.dump(app_route_map),\n :mode => \"wb\"\n\n # Cache check link that will short circut this process if this\n # directory has been setup before\n FileUtils.ln_s @response_file.expand_path, build_cache_link\n\n vcr = nil\n end\n Process.wait pid\n end", "def start_crawling(url, &block)\n Grell.logger.info \"GRELL Started crawling\"\n @collection = PageCollection.new(@add_match_block)\n @collection.create_page(url, nil)\n\n while !@collection.discovered_pages.empty?\n crawl(@collection.next_page, block)\n @manager.check_periodic_restart(@collection)\n end\n\n Grell.logger.info \"GRELL finished crawling\"\n end", "def set_resources\n set_site\n set_page\n\n build_current_page_state if action_name != 'new'\n end", "def before_queue(urls)\n # stub\n end", "def initialize(url, refresh = true)\n self.tasks = []\n self.url = url\n self.refresh if refresh\n end", "def generate_url_codes\r\n\r\n self.spec_url_code = create_code\r\n while (AirframeMessage.where(:spec_url_code => self.spec_url_code).count > 0)\r\n self.spec_url_code = create_code\r\n end\r\n\r\n self.photos_url_code = create_code\r\n while (AirframeMessage.where(:photos_url_code => self.photos_url_code).count > 0)\r\n self.photos_url_code = create_code\r\n end\r\n\r\n end", "def post_init\n $connection_list << self\n @my_connection_index = $connection_list.length\n puts \"Connection Initialized #{@my_connection_index}) #{@my_address} - #{@signature}\"\n #\n # TODO: get access to the HostIP and HostPort associated with this connection\n # if it is the local control connection, do the following\n # * do not repeat other connection traffic to this connection\n # * consider any input a command to be processed\n end", "def external_routes; end", "def initialize_core\n @triggered = []\n @events = Hash.new { |h,k| h[k.to_sym] = [] }\n\n # initialize some instance variables; we won't use them until we dup to\n # process a request.\n @request = nil\n @response = nil\n @original_request = nil\n @original_response = nil\n @entry = nil\n end", "def initialize(params)\n @options = params[:options] || { }\n @target = params[:target] || './'\n\n @html_files = []\n @links = []\n @errors = []\n @warnings = []\n @return_code = 0\n\n @options[:max_threads] ||= 4\n end", "def initialize_http_handler(args = {})\n @http = HTTPHandler.new(args)\n logger.debug { \"Connection Set: #{http.to_s}\" }\n end", "def initialize_http_handler(args = {})\n @http = HTTPHandler.new(args)\n logger.debug { \"Connection Set: #{http.to_s}\" }\n end", "def open_pages\n make_calendars\n make_topics\n end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end" ]
[ "0.6193404", "0.61805123", "0.6105821", "0.60987103", "0.60198647", "0.5988707", "0.5934363", "0.5920136", "0.5849872", "0.5791638", "0.5720417", "0.56314385", "0.55895114", "0.5571384", "0.5549146", "0.553084", "0.5498351", "0.5478351", "0.5478351", "0.5475335", "0.54059106", "0.5405806", "0.53803736", "0.5365195", "0.53630644", "0.53564197", "0.5347549", "0.53447473", "0.5293822", "0.5281725", "0.5280449", "0.5275522", "0.52748686", "0.52699876", "0.5264397", "0.5264397", "0.5252447", "0.5247224", "0.5245237", "0.5243293", "0.5241752", "0.52416664", "0.5239255", "0.5239255", "0.5234864", "0.522696", "0.5223366", "0.52111465", "0.5206902", "0.5204253", "0.5203202", "0.5199137", "0.51961786", "0.5195175", "0.51844364", "0.51828873", "0.51805884", "0.5175698", "0.5163759", "0.5163759", "0.5159733", "0.5156605", "0.51553476", "0.51504946", "0.5137972", "0.51371044", "0.513436", "0.5130086", "0.5120808", "0.51187307", "0.51153404", "0.5115253", "0.51054627", "0.5104203", "0.51033723", "0.5102641", "0.5099363", "0.5098038", "0.50969136", "0.50957525", "0.50956565", "0.509541", "0.50941604", "0.509039", "0.50890714", "0.5085363", "0.5083018", "0.5079142", "0.50774586", "0.5072201", "0.5065684", "0.50592965", "0.50540644", "0.5052157", "0.5050378", "0.5044826", "0.5043223", "0.5042975", "0.504154", "0.504154", "0.504154" ]
0.0
-1
GET /rests GET /rests.json
def index @rests = Rest.all if user_signed_in? @star = current_user.id end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_endpoint; end", "def index\n @node = Fedora.rest('rest/')\n end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def index\n @rest_apis = RestApi.all\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def rest\n @@rest\n end", "def index\n @restconnections = Restconnection.all\n end", "def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end", "def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def rest_end_point; end", "def list\n get('/')\n end", "def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end", "def rest\n @rest ||= Chef::ServerAPI.new(server.root_url, {:api_version => \"0\"})\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def rest\n @rest ||= RestClient.new ENDPOINT[type], lgn: login, pwd: password\n end", "def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end", "def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def index\n @resources = resource_class.send(:all)\n render json: @resources\n end", "def index\n render json: Recipe.all\n end", "def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end", "def index\n @restmembers = Restmember.all\n end", "def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end", "def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def index\n @restorations = Restoration.all\n end", "def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end", "def show\n @rest_object = RestObject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @rest_object }\n end\n end", "def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend", "def index\n Rails.logger.info('👻 Disraptor: Showing available routes.')\n\n routes = Disraptor::Route.find_all()\n\n render json: { 'disraptor/routes': routes }\n end", "def url\n \"/#{self.class.rest_name}s/#{id}\"\n end", "def index\n @restrooms = Restroom.all\n end", "def consume_rest; end", "def get_api_json\n response_string = RestClient.get('http://www.swapi.co/api/people/')\n JSON.parse(response_string)\nend", "def index\n @restoras = Restora.all\n end", "def r(*args)\n @contents << Rest.new(*args)\n end", "def resting(args = {})\n args[:work_type] = REST_TYPE\n workpattern(args)\n end", "def index\n respond_to do |format|\n format.html { disable_action }\n format.xml # index.xml.builder\n format.json { render :json => ServiceCatalographer::Api::Json.index(\"rest_services\", json_api_params, @rest_services).to_json }\n end\n end", "def listRestaurants\n _restaurants = Restaurant.all\n render json: _restaurants\n end", "def index\n if(current_user.customer_id?)\n @resturants = Resturant.where(\"region_id = ?\", current_user.customer.region_id)\n else\n @resturants = Resturant.where(\"region_id = ?\", current_user.driver.region_id)\n end\n \n render json: @resturants, status: 200\n end", "def perform_get(rest_url, request)\n query_params = request.api_params.blank? ? '' : to_query_params(request.api_params)\n url = \"#{rest_url}&#{query_params}\"\n\n response = RestClient::Request.execute(\n method: request.http_method,\n url: url,\n headers: request.header_params,\n read_timeout: 30,\n open_timeout: 15\n )\n JSON.parse(response)\n end", "def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend", "def index\n @requisitions = Requisition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requisitions }\n end\n end", "def index\n json_response(Restaurant.all)\n end", "def index\n @resources = Resource.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def get(url, options={})\n resp = RestClient.get url, rest_client_options(options)\n Representation.new self, MultiJson.load(resp)\n end", "def service_type_name\n \"REST\"\n end", "def index\n # byebug\n if current_user\n recipes = Recipe.all \n render json: recipes\n else \n render json: { errors: [\"Not Authorized\"] }, status: :unauthorized\n end\n end", "def all\n setup_request \"#{@@resource_url}s\"\n end", "def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def all\n render json: Url.all\n end", "def show\n @arrest = Arrest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @arrest }\n end\n end", "def index\n require 'rest-client'\n response = RestClient::Request.execute(method: :get, url: 'localhost:3001/colores',\n headers: {page: params[:page], items: 9})\n if response.code == 200\n body = JSON.parse(response.body)\n @colors = body[\"data\"]\n @page = body[\"page\"]\n end\n end", "def index\n endpoint(get(services_url).body)\n end", "def index(**params)\n params.stringify_keys!\n path = nest_path_within_parent(plural_resource_path, params)\n api_request(:get, path, params: params)\n end", "def index\n @requests = Request.all\n\n render json: @requests\n end", "def rest_request(verb, url, data)\n if Rails.env.production?\n rest_production(verb, url, JSON.generate(data))\n else\n log_info(\"[#{Rails.env}]: #{verb} #{url}\", 200)\n end\n rescue RestClient::Exception => e\n log_error \"Failed with #{e.http_code}: #{e}\\n#{e.response}\", e.http_code\n end", "def index \n restaurant = Restaurant.all\n render json: restaurant\n end", "def list_endpoints\n render json: @endpoints, status: 200\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :timeout => -1,\n :headers => { :accept => :json,\n :content_type => :json ,\n :params => { \"page\" => 1, \"per_page\" => 25000 }}\n ).execute\n results = JSON.parse(response.to_str)\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def all\n api_get(path)\n end", "def render_rest_response(opts)\n if opts.to_s.downcase == 'getall'\n render_get_all\n elsif opts.to_s.downcase == 'get'\n render_get\n elsif opts.to_s.downcase == 'post'\n render_post\n elsif opts.to_s.downcase == 'put'\n render_put\n elsif opts.to_s.downcase == 'delete'\n render_delete\n elsif opts.to_s.downcase == 'error'\n render_error\n end\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username1,\n :password => $password1,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username2,\n :password => $password2,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def index \n recipes = Recipe.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: recipes, except: [:created_at, :updated_at]\n end", "def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end", "def index\n @session_resources = SessionResource.all\n\n render json: @session_resources\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def index\n @requests = Request.all\n\n respond_to do |format|\n format.json { render :json => @requests}\n end\n end", "def index\n @wrestlers = Wrestler.all\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def list_all_shards(args = {}) \n get(\"/shards.json/\", args)\nend", "def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end", "def scan_rest; end", "def service_directory_name\n \"rest\"\n end", "def get_all_route(resource_name, representer)\n list_representer = Class.new(Grape::Roar::Decorator) do\n include ::Roar::JSON\n collection :entries, extend: representer, as: :data\n end\n\n desc \"Returns all #{resource_name}\"\n get do\n present find_instances, with: list_representer\n end\n end", "def index\n build_resource({})\n respond_with self.resource\n end", "def index\n @api_v1_todos = Todo.all\n render json: @api_v1_todos\n end", "def index\n render json: Client.all\n end", "def index\n render json: reservations\n end", "def list\n url = prefix + \"list\"\n return response(url)\n end", "def make_search(url)\n #make the web request\n data = RestClient.get url\n JSON.parse(data)\nend", "def old_rest path, query={}, opts={}, &cb\n get(\"method/#{path}\", {:format => 'json'}.merge(query),\n {:site => old_site}.merge(opts), &cb)\n end", "def index\n per_page = params[:per_page]&.to_i || DEFAULT_PER_PAGE\n page = params[:page]&.to_i || DEFAULT_PAGE\n query = params[:query] || \"\"\n\n queries = query.split(\",\").map { |q| \"%#{q.downcase.strip}%\" }\n recipe_ids = []\n \n if queries.present?\n queries.each do |q|\n tmp_recipe_ids = Ingredient.where('UNACCENT(LOWER(name)) ILIKE UNACCENT(?)', q)\n .pluck(:recipe_id)\n .uniq\n\n excluded_ids = []\n excluded_ids = recipe_ids - tmp_recipe_ids | tmp_recipe_ids - recipe_ids unless recipe_ids.empty?\n \n recipe_ids = (recipe_ids + tmp_recipe_ids) - excluded_ids\n end\n end\n \n recipes = Recipe.where(id: recipe_ids).order('rate DESC NULLS LAST').order(id: :asc)\n .page(page)\n .per(per_page)\n \n render json: {\n meta: {\n total_recipes: recipes.total_count,\n total_pages: recipes.total_pages,\n per_page: per_page,\n query: query,\n page: page\n }, \n recipes: recipes.map { |recipe| ::RecipeJson.new(recipe: recipe).to_h }\n }\n end", "def index\n @servers = getmydata(\"Server\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end", "def show\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_all }\n end\n end", "def index\n @urls = Url.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @urls }\n end\n end", "def rest_endpoint=(_arg0); end", "def rest_resource(path, options={}, &blk)\n rest_get path, options, &blk\n rest_edit path, options, &blk\n rest_delete path, options, &blk\n end", "def index\n @restaurants = Restaurant.all\n # render json: @restaurants\n end", "def index\n @urls = ShortenedUrl.order(\"updated_at ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @urls }\n end\n end", "def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end" ]
[ "0.6700357", "0.66761476", "0.6669396", "0.652457", "0.64282805", "0.63892686", "0.63892686", "0.63254553", "0.63159686", "0.63079304", "0.6286257", "0.6269529", "0.6262006", "0.62530184", "0.62445724", "0.6216004", "0.62032175", "0.6188354", "0.6179477", "0.6142708", "0.61082137", "0.6106597", "0.6072041", "0.6049047", "0.60403293", "0.60163814", "0.6013688", "0.60065985", "0.6003969", "0.60027206", "0.59971786", "0.5990782", "0.5979372", "0.5976225", "0.5965593", "0.59633875", "0.5954493", "0.59537715", "0.59479326", "0.594693", "0.5926942", "0.5925506", "0.59129316", "0.5903158", "0.5902276", "0.5901455", "0.58969873", "0.5893164", "0.588985", "0.5873399", "0.58613735", "0.58555126", "0.58498216", "0.5833535", "0.58249074", "0.5822967", "0.5810114", "0.5804522", "0.58024937", "0.5790263", "0.5776331", "0.5776188", "0.57720053", "0.57651883", "0.57651883", "0.57599", "0.5757483", "0.5753199", "0.5752313", "0.57508785", "0.57493603", "0.5747778", "0.5745513", "0.57409894", "0.57409894", "0.5740634", "0.57356465", "0.57324964", "0.57322246", "0.57262933", "0.5717055", "0.5716058", "0.5704144", "0.5701658", "0.56982785", "0.56903994", "0.56898004", "0.56863666", "0.56856215", "0.5680039", "0.5676227", "0.56761265", "0.5671688", "0.56698316", "0.5665288", "0.566201", "0.5659476", "0.56579196", "0.563381", "0.562662" ]
0.57400334
76
GET /rests/1 GET /rests/1.json
def show map_link @num_stars = @rest.stars.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_endpoint; end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def index\n @node = Fedora.rest('rest/')\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def url\n \"/#{self.class.rest_name}s/#{id}\"\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def show\n @rest_object = RestObject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @rest_object }\n end\n end", "def index\n @restconnections = Restconnection.all\n end", "def index\n @rest_apis = RestApi.all\n end", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def rest\n @@rest\n end", "def rest\n @rest ||= Chef::ServerAPI.new(server.root_url, {:api_version => \"0\"})\n end", "def rest_end_point; end", "def rest\n @rest ||= RestClient.new ENDPOINT[type], lgn: login, pwd: password\n end", "def service_type_name\n \"REST\"\n end", "def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def get_api_json\n response_string = RestClient.get('http://www.swapi.co/api/people/')\n JSON.parse(response_string)\nend", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def get(url, options={})\n resp = RestClient.get url, rest_client_options(options)\n Representation.new self, MultiJson.load(resp)\n end", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end", "def perform_get(rest_url, request)\n query_params = request.api_params.blank? ? '' : to_query_params(request.api_params)\n url = \"#{rest_url}&#{query_params}\"\n\n response = RestClient::Request.execute(\n method: request.http_method,\n url: url,\n headers: request.header_params,\n read_timeout: 30,\n open_timeout: 15\n )\n JSON.parse(response)\n end", "def rest_endpoint=(_arg0); end", "def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end", "def index\n @resources = resource_class.send(:all)\n render json: @resources\n end", "def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend", "def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end", "def show\n @arrest = Arrest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @arrest }\n end\n end", "def index\n @api_v1_todos = Todo.all\n render json: @api_v1_todos\n end", "def index\n @api_v1_resources = Api::V1::Resource.all\n end", "def rest_get(base_uri,params)\n begin\n @response = RestClient.get(base_uri,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end", "def invoke_request(url)\n site = RestClient::Resource.new(url, \"dHgVM1emGoTyr8zHmVNH\")\n return JSON.parse(site.get(:accept=>\"application/json\"))\nend", "def invoke_request(url)\n site = RestClient::Resource.new(url, \"dHgVM1emGoTyr8zHmVNH\")\n return JSON.parse(site.get(:accept=>\"application/json\"))\nend", "def list\n get('/')\n end", "def index\n @resources = Resource.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end", "def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def index\n @requisitions = Requisition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requisitions }\n end\n end", "def show\n @resource = Resource.find(params[:id])\n render json: @resource, status: 200\n end", "def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end", "def r(*args)\n @contents << Rest.new(*args)\n end", "def rest_resource(path, options={}, &blk)\n rest_get path, options, &blk\n rest_edit path, options, &blk\n rest_delete path, options, &blk\n end", "def consume_rest; end", "def index\n render json: Recipe.all\n end", "def resting(args = {})\n args[:work_type] = REST_TYPE\n workpattern(args)\n end", "def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username1,\n :password => $password1,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def show\n @restroom = Restroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end", "def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend", "def index\n build_resource({})\n respond_with self.resource\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end", "def rest_request(verb, url, data)\n if Rails.env.production?\n rest_production(verb, url, JSON.generate(data))\n else\n log_info(\"[#{Rails.env}]: #{verb} #{url}\", 200)\n end\n rescue RestClient::Exception => e\n log_error \"Failed with #{e.http_code}: #{e}\\n#{e.response}\", e.http_code\n end", "def show\n respond_to do |format|\n format.json { render json: @uri, status: 200 }\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def service_directory_name\n \"rest\"\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :timeout => -1,\n :headers => { :accept => :json,\n :content_type => :json ,\n :params => { \"page\" => 1, \"per_page\" => 25000 }}\n ).execute\n results = JSON.parse(response.to_str)\n end", "def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end", "def show_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username2,\n :password => $password2,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def show\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_all }\n end\n end", "def index\n @restmembers = Restmember.all\n end", "def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end", "def get(url)\n begin\n # Start by creating a new `RestCLient::Resource` authenticated with\n # the `@project` name and `@password`.\n resource = RestClient::Resource.new(url) \n # `GET` the resource\n resource.get {|response, request, result, &block|\n case response.code\n when 200\n JSON.parse(response.body)\n else\n response.return!(request, result, &block)\n end\n }\n rescue => e\n # Rescue and reraise with the current `@url` for debugging purposes \n raise \"Problem fetching #{@url} because #{e.message}\"\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_rest_api(endpoint, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP GET request against the specified REST API endpoint.\n request = Net::HTTP::Get.new(rest_api_endpoint)\n # Submit the request\n response = http.request(request)\n # Return the response body (JSON containing the results of the query).\n response.body\nend", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def index\n @restoras = Restora.all\n end", "def api_fetch(url)\n JSON.parse(RestClient.get url)\nend", "def index\n @requests = Request.all\n\n render json: @requests\n end", "def rest_get(api_url)\n RestClient::Request.execute(method: :get,\n url: api_url,\n verify_ssl: @verify_ssl).body\n end", "def index\n render json: Client.all\n end", "def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end", "def show\n render json: serialize(read_resource(resource), options), status: :ok\n end", "def index\n require 'rest-client'\n response = RestClient::Request.execute(method: :get, url: 'localhost:3001/colores',\n headers: {page: params[:page], items: 9})\n if response.code == 200\n body = JSON.parse(response.body)\n @colors = body[\"data\"]\n @page = body[\"page\"]\n end\n end", "def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def index\n @requests = Request.all\n\n respond_to do |format|\n format.json { render :json => @requests}\n end\n end", "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend", "def index\n @restrooms = Restroom.all\n end", "def index\n respond_to do |format|\n format.html { disable_action }\n format.xml # index.xml.builder\n format.json { render :json => ServiceCatalographer::Api::Json.index(\"rest_services\", json_api_params, @rest_services).to_json }\n end\n end", "def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end", "def set_rest_api\n @rest_api = RestApi.find(params[:id])\n end", "def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end", "def index\n @restorations = Restoration.all\n end", "def index\n @session_resources = SessionResource.all\n\n render json: @session_resources\n end", "def index\n @servers = getmydata(\"Server\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end", "def index(**params)\n params.stringify_keys!\n path = nest_path_within_parent(plural_resource_path, params)\n api_request(:get, path, params: params)\n end", "def render_rest_response(opts)\n if opts.to_s.downcase == 'getall'\n render_get_all\n elsif opts.to_s.downcase == 'get'\n render_get\n elsif opts.to_s.downcase == 'post'\n render_post\n elsif opts.to_s.downcase == 'put'\n render_put\n elsif opts.to_s.downcase == 'delete'\n render_delete\n elsif opts.to_s.downcase == 'error'\n render_error\n end\n end", "def get(url, headers={})\n RestClient.get url, headers\n end", "def call_rest(verb, url, xml=nil, content_type='text/xml')\n begin\n case verb.to_sym\n when :get\n RestClient.get(url)\n when :post\n RestClient.post(url, xml, :content_type => content_type)\n when :put\n RestClient.put(url, xml, :content_type => content_type)\n when :delete\n RestClient.delete(url)\n end\n rescue => e\n puts \"Exception at: #{url}\"\n puts e.response ? e.response : e\n end\n end", "def make_search(url)\n #make the web request\n data = RestClient.get url\n JSON.parse(data)\nend", "def info\n CouchRest.get \"#{@uri}/\"\n end", "def old_rest path, query={}, opts={}, &cb\n get(\"method/#{path}\", {:format => 'json'}.merge(query),\n {:site => old_site}.merge(opts), &cb)\n end", "def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end", "def index \n restaurant = Restaurant.all\n render json: restaurant\n end" ]
[ "0.6952998", "0.68672687", "0.6795025", "0.66832966", "0.66832966", "0.649095", "0.64744085", "0.64592946", "0.63871074", "0.6356063", "0.6348608", "0.6340867", "0.63260907", "0.6292809", "0.629224", "0.62778544", "0.62577116", "0.62445396", "0.62295973", "0.62291014", "0.62132126", "0.6185252", "0.616246", "0.6161521", "0.6155491", "0.609831", "0.6087128", "0.607846", "0.6076113", "0.6074282", "0.6063183", "0.6060854", "0.60599524", "0.60569894", "0.60569894", "0.6051207", "0.605079", "0.60386395", "0.60288507", "0.6028123", "0.60223615", "0.5998757", "0.59972966", "0.5993709", "0.5981024", "0.5980574", "0.59798205", "0.597093", "0.5967521", "0.59650964", "0.59500086", "0.5929798", "0.59208506", "0.5919129", "0.5910959", "0.5909486", "0.5909195", "0.5908332", "0.5903545", "0.5901526", "0.5899706", "0.5892958", "0.58801466", "0.5876316", "0.5869383", "0.5868882", "0.5853659", "0.5849172", "0.58480805", "0.58480805", "0.5842236", "0.5840243", "0.5840243", "0.5831105", "0.5830493", "0.5806021", "0.58023787", "0.5800278", "0.57932246", "0.57922363", "0.5791422", "0.5789311", "0.5786975", "0.57855576", "0.57855135", "0.5783282", "0.5779505", "0.57778376", "0.5773518", "0.5771728", "0.5770548", "0.5768887", "0.5766675", "0.574928", "0.5747522", "0.57440984", "0.5742259", "0.57341594", "0.5732798", "0.5731988", "0.5730259" ]
0.0
-1
POST /rests POST /rests.json
def create @rest = Rest.new(rest_params) @rest.owners << current_owner respond_to do |format| if @rest.save format.html { redirect_to @rest, notice: 'Rest was successfully created.' } format.json { render :show, status: :created, location: @rest } else format.html { render :new } format.json { render json: @rest.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def add_weather_by_rest(auth,weather_json)\n rest_agent=RestClient::Resource.new(\"http://#{auth[:host]}:#{auth[:port]}/#{auth[:reststr]}/ry/weather\")\n rest_agent.post(weather_json, :content_type=>\"application/json;charset=utf-8\")\n end", "def create\n @resto = Resto.new(resto_params)\n\n respond_to do |format|\n if @resto.save\n format.html { redirect_to @resto, notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @resto }\n else\n format.html { render :new }\n format.json { render json: @resto.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_endpoint; end", "def rest_post(base_uri,json_payload,params)\n begin\n puts base_uri,json_payload\n @response = RestClient.post(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def add_weather_by_rest(auth,weather_json)\n rest_agent=RestClient::Resource.new(\"http://#{auth[:host]}:#{auth[:port]}/#{auth[:reststr]}/ry/weather\")\n rest_agent.post(weather_json, :content_type=>\"application/json;charset=utf-8\")\n end", "def r(*args)\n @contents << Rest.new(*args)\n end", "def rest_params\n params.require(:rest).permit(:name, :address, :description, :owner, :phone)\n end", "def create\n unless @rest = Rest.where([\"report_id = ? AND ended_at IS NULL\", params[:report_id]]).first\n @rest = Rest.new(:report_id => params[:report_id],\n :latitude => params[:latitude],\n :longitude => params[:longitude],\n :address => params[:address],\n :started_at => Time.now()\n )\n end\n\n respond_to do |format|\n if @rest.save\n @json = Hash[:rest => {\n :id => @rest.id,\n :report_id => @rest.report_id,\n :latitude => @rest.latitude,\n :longitude => @rest.longitude,\n :address => @rest.address,\n :started_at => @rest.started_at\n }]\n format.json { render json: @json, status: :created, location: @json }\n else\n format.json { render json: {:error => \"Rest creation faild.\"}, status: :unprocessable_entity }\n end\n end\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def index\n @node = Fedora.rest('rest/')\n end", "def rest_end_point; end", "def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend", "def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend", "def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def resource_way\n # TODO: make json default format?\n\n # try resource style\n #resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", \n #'user@test.com', 'please') #, :accept => :json)\n resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", 'b4j5qBqzYx5EukCM3Vri') #token\n # \n response = resources.get(:accept => :json)\n all_hosts = JSON.parse(response)\n puts \"EXISTING HOSTS: \" + all_hosts.inspect\n\n new_opts = {\n \"host_name\" => \"damian.np.dc1.eharmony.com\",\n \"alias\" => \"damian.np.dc1.eharmony.com\",\n \"address\" => \"damian.np.dc1.eharmony.com\",\n \"max_check_attempts\" => 3,\n \"notification_interval\" => 5,\n # 24x7\n \"notification_period\" => \"24x7\",\n #\"notification_period_id\" => \"5050cb9ebfa68e0903000001\",\n # 24x7\n \"check_period\" => \"24x7\",\n #\"check_period_id\" => \"5050cb9ebfa68e0903000001\",\n # just using first contact\n #\"contacts\" => [\"pat-obrien\"],\n \"contacts\" => [\"damian\"],\n #\"contact_ids\" => [\"5051283ebfa68e5757000002\"],\n }\n\n\n #puts resources['new'].post(NEW_OPTS.to_json, :content_type => :json, :accept \n #=> :json )\n # NOTE: even though this works and creates a new Host in DB - i still get 406 \n # Not Acceptable response\n #puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts}, :accept => \n #:json )\n begin\n puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts})\n rescue Exception => e\n puts \"ERROR: #{e} = #{e.inspect}\"\n end\n\n \n\n # now edit the resource ...\nend", "def create\n @webservice = Webservice.find(params[:webservice_id])\n @rest_api = @webservice.rest_apis.create(rest_api_params)\n redirect_to webservice_path(@webservice)\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def post_json(location, json_data)\n response = RestClient::Request.new(\n :method => :post,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json},\n :payload => json_data\n ).execute\n results = JSON.parse(response.to_str)\n end", "def post_json(location, json_data)\n response = RestClient::Request.new(\n :method => :post,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json},\n :payload => json_data\n ).execute\n results = JSON.parse(response.to_str)\n end", "def rest_create(path, options={}, &blk)\n # Create\n post path do\n @object = yield\n rest_params.each { |k, v| @object.send :\"#{k}=\", v }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object.to_hash\n end\n end", "def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def post options\n rest_request({ method: :post }.merge(options))\n end", "def post options\n rest_request({ method: :post }.merge(options))\n end", "def resting(args = {})\n args[:work_type] = REST_TYPE\n workpattern(args)\n end", "def service_type_name\n \"REST\"\n end", "def rest_params\n params.require(:rest).permit(:restaurant_name, :meal_name, :meal_price,\n :restaurant_area, :restaurant_address, :cuisine_type, :picture )\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def create\n @resturant = Resturant.new(resturant_params)\n\n respond_to do |format|\n if @resturant.save\n format.html { redirect_to root_url, notice: 'Resturant was successfully created.' }\n format.json { render :show, status: :created, location: @resturant }\n else\n format.html { render :new }\n format.json { render json: @resturant.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(url, query = {}, payload = {})\n restclient({\n method: :post,\n url: \"#{@scheme}://#{@host}/#{url}\",\n timeout: Timeout,\n open_timeout: OpenTimeout,\n payload: payload.to_json,\n headers: {\n authorization: @auth,\n content_type: :json,\n accept: :json,\n params: query\n }\n })\n end", "def create_rest\n @entry_item = EntryItem.new(params[:entry_item])\n\n respond_to do |format|\n if @entry_item.save\n flash[:notice] = 'EntryItem was successfully created.'\n #format.html { redirect_to(@entry_item) }\n format.xml { render :xml => @entry_item, :status => :created, :location => @entry_item }\n else\n #format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def service_directory_name\n \"rest\"\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def post(url)\n response = RestClient::Request.new(\n method: :post,\n url: \"#{ENDPOINT_URL}/#{url}\",\n verify_ssl: false,\n headers: {\n 'Content-Type' => 'application/json',\n 'Authorization' => \"Basic #{authorization_hash}\"\n },\n payload: {user: user, pwd: password}.to_json\n ).execute\n\n # Parse the response to Ruby objects\n JSON.parse(response)\n end", "def post_inventories(name,description, organization=1,variables='')\n dprint \"/api/v1/hosts\"\n resp = @rest['/api/v1/hosts'].post({\n :name => name,\n :description => description,\n :organization => organization,\n :variables => variables\n })\n dprint resp\n\n #[XXX] Theoretical what this is at this point - need to see \n # actual response\n JSON.parse(resp)[\"results\"]\n end", "def rest_interface(*operations)\n const_get(:REST_INTERFACE).push(*operations)\n end", "def test_post_request_collection\n params = {\n size: 3,\n employmentTypeUris: ['/dk/atira/pure/person/employmenttypes/academic'],\n employmentStatus: 'ACTIVE'\n }\n response = client.persons.all_complex params: params\n assert_equal response.code, 200\n assert_instance_of HTTP::Response, response\n end", "def rest_endpoint=(_arg0); end", "def rest_request(verb, url, data)\n if Rails.env.production?\n rest_production(verb, url, JSON.generate(data))\n else\n log_info(\"[#{Rails.env}]: #{verb} #{url}\", 200)\n end\n rescue RestClient::Exception => e\n log_error \"Failed with #{e.http_code}: #{e}\\n#{e.response}\", e.http_code\n end", "def consume_rest; end", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def index\n @rest_apis = RestApi.all\n end", "def create\n @event = Event.find(params[:event_id])\n @restmember = Restmember.new(restmember_params)\n respond_to do |format|\n if @restmember.save\n format.html { redirect_to @event }\n format.json { render :show, status: :created, location: @restmember }\n else\n format.html { render :new }\n format.json { render json: @restmember.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end", "def new\n @rest_service = RestService.new\n params[:annotations] = { }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rest_service }\n end\n end", "def rest_production(verb, url, payload)\n response = RestClient.send(verb, url, payload, request_headers)\n log_info(\"Response #{response.code}:\\n#{response.body.inspect}\\n\")\n response.code\n end", "def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend", "def create_rest\n @item_usage = ItemUsage.new(params[:item_usage])\n\n respond_to do |format|\n if @item_usage.save\n flash[:notice] = 'ItemUsage was successfully created.'\n format.html { redirect_to(@item_usage) }\n format.xml { render :xml => @item_usage, :status => :created, :location => @item_usage }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @restora = Restora.new(restora_params)\n\n respond_to do |format|\n if @restora.save\n format.html { redirect_to @restora, notice: 'Restora was successfully created.' }\n format.json { render :show, status: :created, location: @restora }\n else\n format.html { render :new }\n format.json { render json: @restora.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_rest\n @entry_instrument = EntryInstrument.new(params[:entry_instrument])\n\n respond_to do |format|\n if @entry_instrument.save\n flash[:notice] = 'EntryInstrument was successfully created.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { render :xml => @entry_instrument, :status => :created, :location => @entry_instrument }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end", "def list_instances\n puts \"OK, Listing instances..\"\n\n response = RestClient.post( \n $uri,\n 'Version' => '2010-12-30',\n 'ACSAccessKeyId' => $ACSAccessKeyId,\n 'Format' => 'json',\n 'Timestamp' => $current_time,\n 'Rndguid' => $rndguid,\n 'Signature' => calculate_signature($api_private_key, $rndguid, $current_time),\n 'Action' => \"list-instances\")\n\n puts response\n puts response.code\nend", "def post\n resource.post(request, response)\n end", "def create\n @restroom = Restroom.new(restroom_params)\n\n respond_to do |format|\n if @restroom.save\n format.html { redirect_to @restroom, notice: 'Restroom was successfully created.' }\n format.json { render action: 'show', status: :created, location: @restroom }\n else\n format.html { render action: 'new' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def post url, payload\n RestClient::Request.execute(:method => :post, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end", "def execute_rest(rest_url, params)\n log(:info, \"Running execute_rest...\")\n\n # log the parameters we are using for the rest call\n log(:info, \"Inspecting REST params: #{params.inspect}\") if @debug == true\n\n # execute the rest call and inspect the response\n rest_response = RestClient::Request.new(params).execute\n\n # convert the rest_response into a usable hash\n rest_hash = parse_response(rest_response)\n log(:info, \"Finished running execute_rest...\")\n return rest_hash\n end", "def call_rest(action, url, headers, ref, body = nil)\n begin\n # change url based on if we have a ref or not\n if ref.nil?\n url = url\n else\n url = url + \"/\" + ref\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :verify_ssl => false,\n :headers => headers\n }\n\n # generate payload data\n params[:payload] = body if body\n log(:info, \"call_rest: Request URL: #{url}\")\n log(:info, \"call_rest: Request Action: #{action}\")\n log(:info, \"call_rest: Request Headers: #{headers.inspect}\")\n log(:info, \"call_rest: Request Payload: #{params[:payload]}\")\n\n # execute the request\n RestClient::Request.new(params).execute\n rescue => err\n # log and backtrace the error\n log(:error, \"[#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n log(:error, \"call_rest: #{err}. Returning nil.\")\n return nil\n end\nend", "def http_post(uri, data)\n RestClient.post uri, data\n end", "def post\n Salesforce.set_http(session[:accesstoken], session[:accessurl])\n \t@response = Salesforce.create_post(params)\n \trespond_to do |format|\n format.json { render :json => @response.to_json}\n # example of multiple reponses mapped to one object\n # format.json { render :json => {:data => @response, :meta => @describe}.to_json}\n \tend\n end", "def build_rest(rest_resource, rest_action, rest_payload = nil, rest_auth_type = 'basic', rest_verify_ssl = false)\n # set rest url\n rest_url = URI.join(@rest_base_url, rest_resource).to_s\n log(:info, \"Used rest_base_url: <#{@rest_base_url}>, and rest_resource: <#{rest_resource}>, to generate rest_url: <#{rest_url}>\")\n\n # set params for api call\n params = {\n :method => rest_action,\n :url => rest_url,\n :verify_ssl => rest_verify_ssl,\n :headers => {\n :content_type => @rest_content_type,\n :accept => @rest_return_type\n }\n }\n\n # set the authorization header based on the type requested\n if rest_auth_type == 'basic'\n params[:headers][:authorization] = \"Basic #{Base64.strict_encode64(\"#{@rest_api_user}:#{@rest_api_password}\")}\"\n else\n #\n # code for extra rest_auth_types goes here. currently only supports basic authentication\n #\n end\n\n # generate payload data\n if @rest_content_type.to_s == 'json'\n # generate our body in JSON format\n params[:payload] = JSON.generate(rest_payload) unless rest_payload.nil?\n else\n # generate our body in XML format\n params[:payload] = Nokogiri::XML(rest_payload) unless rest_payload.nil?\n end\n\n # get the rest_response and set it on the parent object\n rest_results = execute_rest(rest_url, params)\n end", "def post(path_part, payload, additional_headers = {}, &block)\n api_request { @rest.post('/REST/' + path_part, payload.to_json, additional_headers, &block) }\n end", "def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end", "def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end", "def create\n respond_to do |format|\n require 'rest-client'\n response = RestClient.post('localhost:3001/colores/', color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n format.html { redirect_to @color, notice: \"Color was successfully created.\" }\n format.json { render :show, status: :created, location: @color }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_route(payload)\n with_rescue do\n payload = payload.to_json if payload.is_a?(Hash)\n connection.post do |request|\n request.url routes_path\n request.body = payload\n request.headers['Content-Type'] = 'application/json'\n end\n end\n end", "def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def rest\n @rest ||= RestClient.new ENDPOINT[type], lgn: login, pwd: password\n end", "def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end", "def data_to_api(snack_name, snack_location, snack_optional)\n RestClient.post ENV['NERDERY_API'], { name: snack_name,\n location: snack_location,\n optional: snack_optional\n }.to_json, content_type: :json\n end", "def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end", "def login_sample()\n login_json = {\n :username => $username,\n :password => $password,\n :accessrights => $api_key\n }\n\n client = RestClient::Resource.new \"https://#{$hostname}/live/api/v3/\", :headers => {}, :verify_ssl => OpenSSL::SSL::VERIFY_NONE\n\n request = login_json.to_json\n response = client['login'].post request, { :content_type => 'application/json' }\n\n client.options[:headers][:cookies] = response.cookies\n\n p ''\n p 'Login'\n p response\n client\nend", "def post(*args)\n super(*wrap_for_json_api(*args))\n end", "def sensor_list\n #this is making a post request by intializing the restclient gem with RestClient::Request.new to get sensors list\n #if the call is successful it provide the response.body\n #if fails and returns a 400 with the error.\n response = RestClient::Request.new({\n method: :post,\n url:\"https://api.samsara.com/v1/sensors/list?access_token=#{Rails.application.credentials.secret_key}\",\n payload:{ \"groupId\": 32780 }.to_json,\n headers: { :accept => :json, content_type: :json }\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, (response.to_json) ]\n when 200\n [ :success, (response.to_json) ]\n else\n fail \"Invalid response #{response} received.\"\n end\n # here I setting the body to an elemnet that will be availble in the views.\n @sensor_list = response.body\n end\n end", "def POST; end", "def post(path, params={})\n RestClient.post request_base+path, params\n end", "def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end", "def destroy\n @rest.destroy\n respond_to do |format|\n format.html { redirect_to rests_url, notice: 'Rest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def rest_token_end_point; end", "def add\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:recipe_id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] #hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n recipe_data = JSON.parse response.read_body\r\n recipe = Recipe.create :title => recipe_data[\"title\"], :image => recipe_data[\"image\"]\r\n @current_user.recipes << recipe # add recipe to My Recipes\r\n\r\n redirect_to my_recipes_path\r\n end", "def index(context)\n # context.request is an instance of Sinatra::Request\n params = context.request.params\n instance_variable_set(:\"@#{resource_name.pluralize}\", resource_name.classify.constantize.all)\n instance_variable_get(:\"@#{resource_name.pluralize}\").to_json\n end", "def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end", "def 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_post\n begin\n #asks the user for the title, body, and whether it should be anonymous\n print \"Title: \"\n title = STDIN.gets.chomp\n print \"Body: \"\n body = STDIN.gets.chomp\n print \"Post as Anonymous? (y/n): \"\n anonymous = STDIN.gets.chomp.upcase == 'Y' ? true : false\n # check user information from login\n\n # Rails will reject this unless you configure the cross_forgery_request check to\n # a null_session in the receiving controller. This is because we are not sending\n # an authenticity token. Rails by default will only send the token with forms /users/new and\n # /users/1/edit and REST clients don't get those.\n # We could perhaps arrange to send this on a previous\n # request but we would then have to have an initial call (a kind of login perhaps).\n # This will automatically send as a multi-part request because we are adding a\n # File object.\n response = RestClient.post \"#{@@DOMAIN}/api/posts.json\",\n\n {\n post: {\n title: title,\n body: body,\n anonymous: anonymous\n },\n }, authorization_hash\n\n if (response.code == 201)\n puts \"Created successfully\"\n end\n puts \"URL for new resource: #{response.headers[:location]}\"\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end", "def index\n build_resource({})\n respond_with self.resource\n end", "def index\n render json: reservations\n end", "def post_request\n\t\turl = request.fullpath.gsub(\"/api\", \"\")\n\t\t@rr = Rr.where(\"url = ?\", url).first\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => rr.response}\n\t\t\tformat.xml { render :xml => @rr.response}\n\t\t\tformat.js { render :js => @rr.response}\n\t\tend\n\tend", "def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def call_rest(verb, url, xml=nil, content_type='text/xml')\n begin\n case verb.to_sym\n when :get\n RestClient.get(url)\n when :post\n RestClient.post(url, xml, :content_type => content_type)\n when :put\n RestClient.put(url, xml, :content_type => content_type)\n when :delete\n RestClient.delete(url)\n end\n rescue => e\n puts \"Exception at: #{url}\"\n puts e.response ? e.response : e\n end\n end", "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def post(url, json_body)\n setup_or_refresh_rest_session\n @session.post(url: url, json_body: json_body)\n end", "def index\n respond_to do |format|\n format.html { disable_action }\n format.xml # index.xml.builder\n format.json { render :json => ServiceCatalographer::Api::Json.index(\"rest_services\", json_api_params, @rest_services).to_json }\n end\n end", "def register_rest(handler, &block)\n @register_rest ||= (handler || block)\n end", "def create\n @restconnection = Restconnection.new(restconnection_params)\n\n respond_to do |format|\n if @restconnection.save\n format.html { redirect_to @restconnection, notice: 'Restconnection was successfully created.' }\n format.json { render :show, status: :created, location: @restconnection }\n else\n format.html { render :new }\n format.json { render json: @restconnection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resist = Resist.new(resist_params)\n\n respond_to do |format|\n if @resist.save\n format.html { redirect_to @resist, notice: 'Resist was successfully created.' }\n format.json { render :show, status: :created, location: @resist }\n else\n format.html { render :new }\n format.json { render json: @resist.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(endpoint, options)\n #Send request\n res = RestClient.post endpoint,\n options,\n content_type: :json\n\n #Process and return response\n return JSON.parse(res.body, object_class: OpenStruct)\nend" ]
[ "0.61397886", "0.6026522", "0.6021422", "0.6014175", "0.59473485", "0.59293044", "0.5900913", "0.58330417", "0.5823481", "0.5804615", "0.5804615", "0.58033496", "0.57480234", "0.57329416", "0.566821", "0.5667403", "0.56503373", "0.5609959", "0.56051517", "0.55629534", "0.55629534", "0.55595875", "0.5544683", "0.5534194", "0.5534194", "0.5528071", "0.551537", "0.55153567", "0.54937994", "0.5478018", "0.5438659", "0.5430758", "0.5421236", "0.54110014", "0.5407481", "0.54031026", "0.5397332", "0.53917503", "0.5391448", "0.5378269", "0.5375612", "0.5372874", "0.5353968", "0.53307277", "0.53295165", "0.5319392", "0.53108084", "0.5308083", "0.52984697", "0.52902305", "0.52859753", "0.52847636", "0.5283146", "0.52793", "0.52648866", "0.5253498", "0.52507764", "0.5238556", "0.5235261", "0.52285045", "0.5227159", "0.519151", "0.5179578", "0.5172757", "0.5169958", "0.51607", "0.5156493", "0.51561606", "0.51479155", "0.51455855", "0.5145529", "0.5144529", "0.5137762", "0.51270765", "0.512525", "0.5124487", "0.5116575", "0.511593", "0.51136124", "0.51060766", "0.5100774", "0.50989604", "0.50985163", "0.5087232", "0.50832564", "0.50773156", "0.5072731", "0.50722104", "0.50715166", "0.50713533", "0.50700486", "0.5062824", "0.50625724", "0.50618297", "0.50605226", "0.5055399", "0.5051053", "0.50456357", "0.50437707", "0.5041952" ]
0.6640577
0
PATCH/PUT /rests/1 PATCH/PUT /rests/1.json
def update respond_to do |format| if @rest.update(rest_params) format.html { redirect_to @rest, notice: 'Rest was successfully updated.' } format.json { render :show, status: :ok, location: @rest } else format.html { render :edit } format.json { render json: @rest.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch!\n request! :patch\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end", "def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end", "def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_resource(path, options={}, &blk)\n rest_get path, options, &blk\n rest_edit path, options, &blk\n rest_delete path, options, &blk\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n respond_to do |format|\n if @resto.update(resto_params)\n format.html { redirect_to @resto, notice: 'Entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @resto }\n else\n format.html { render :edit }\n format.json { render json: @resto.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end", "def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\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 patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def patch(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @restroom.update(restroom_params)\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n end", "def patch_resource(payload)\n execute(resource_path, method: :patch, payload: payload.to_json)\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end", "def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def patch\n req.patch?\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end", "def patch(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\n end", "def patch(path, **args); end", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend", "def test_update\n #Again the delete feature from ActiveResource does not work out of the box.\n #Using custom delete function\n puts \"--create a new account--\"\n new_acct = Salesforce::Rest::Account.new(:Name => \"test numero uno\", :BillingStreet=> \"Fairway Meadows\",\n :BillingState => \"NY\", :ShippingCity => \"New York\")\n resp = new_acct.save()\n\n assert (resp.code == 201)\n j = ActiveSupport::JSON\n @sf_oid = j.decode(resp.body)[\"id\"]\n puts \"New Object created: id -> \" + @sf_oid\n\n puts \"--update that new account--\"\n serialized_json = '{\"BillingState\":\"WA\"}'\n #http = Net::HTTP.new(@rest_svr_url, 443)\n http = Net::HTTP.new('na7.salesforce.com', 443)\n http.use_ssl = true\n \n class_name = \"Account\"\n path = \"/services/data/v21.0/sobjects/#{class_name}/#{@sf_oid}\"\n headers = {\n 'Authorization' => \"OAuth \"+ @oauth_token,\n \"content-Type\" => 'application/json',\n }\n code = serialized_json\n\n \n req = Net::HTTPGenericRequest.new(\"PATCH\", true, true, path, headers)\n\n resp = http.request(req, code) { |response| }\n assert !resp.nil?\n\n puts resp.to_s\n end", "def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @restroom = Restroom.find(params[:id])\n authorize @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_resource.update(api_v1_resource_params)\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_resource }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def patch(path, opts = {})\n request(:patch, path, opts).body\n end", "def patch\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.patch do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { render :show, status: :ok, location: @patch }\n else\n format.html { render :edit }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def old_rest path, query={}, opts={}, &cb\n uri = url(\"method/#{path}\", {:format => 'json'}.merge(query),\n old_server, opts)\n if opts[:post]\n request(\n opts.merge(:uri => uri),\n [:post,\n url(\"method/#{path}\", {:format => 'json'}, old_server, opts),\n query],\n &cb)\n else\n request(opts, [:get, uri], &cb)\n end\n end", "def update\n @rest = Rest.where([\"id = ? AND report_id = ?\" , params[:id], params[:report_id]]).first\n\n if @rest\n respond_to do |format|\n if @rest.update_attributes({ :location => params[:location], :ended_at => DateTime.now })\n @json = Hash[:rest => {\n :id => @rest.id,\n :report_id => @rest.report_id,\n :location => @rest.location,\n :latitude => @rest.latitude,\n :longitude => @rest.longitude,\n :address => @rest.address,\n :started_at => @rest.started_at,\n :ended_at => @rest.ended_at\n }]\n format.json { render json: @json }\n else\n format.json { render json: {:error => \"Rest update failed.\"}, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.json { render json:{ :error => \"Not Acceptable:rests#update\", :status => 406 } }\n end\n end\n end", "def patch(action, **args); 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 http_prop_patch(request, response)\n path = request.path\n\n begin\n prop_patch = @server.xml.expect('{DAV:}propertyupdate', request.body)\n rescue Tilia::Xml::ParseException => e\n raise Exception::BadRequest, e.message, nil, e\n end\n\n new_properties = prop_patch.properties\n\n result = @server.update_properties(path, new_properties)\n\n prefer = @server.http_prefer\n response.update_header('Vary', 'Brief,Prefer')\n\n if prefer['return'] == 'minimal'\n # If return-minimal is specified, we only have to check if the\n # request was succesful, and don't need to return the\n # multi-status.\n ok = true\n result.each do |_prop, code|\n ok = false if code.to_i > 299\n end\n\n if ok\n response.status = 204\n return false\n end\n end\n\n response.status = 207\n response.update_header('Content-Type', 'application/xml; charset=utf-8')\n\n # Reorganizing the result for generateMultiStatus\n multi_status = {}\n result.each do |property_name, code|\n if multi_status.key?(code)\n multi_status[code][property_name] = nil\n else\n multi_status[code] = { property_name => nil }\n end\n end\n multi_status['href'] = path\n\n response.body = @server.generate_multi_status([multi_status])\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 update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def update\n respond_to do |format|\n format.xml { head :method_not_allowed }\n format.json { head :method_not_allowed }\n end\n end", "def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\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(context)\n context.request.body.rewind # in case someone already read it\n\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n set_resource(context)\n\n begin\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n if instance_variable_get(:\"@#{resource_name}\").update_attributes(permitted_params)\n instance_variable_get(:\"@#{resource_name}\").reload\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def put options\n rest_request({ method: :put }.merge(options))\n end", "def resource_way\n # TODO: make json default format?\n\n # try resource style\n #resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", \n #'user@test.com', 'please') #, :accept => :json)\n resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", 'b4j5qBqzYx5EukCM3Vri') #token\n # \n response = resources.get(:accept => :json)\n all_hosts = JSON.parse(response)\n puts \"EXISTING HOSTS: \" + all_hosts.inspect\n\n new_opts = {\n \"host_name\" => \"damian.np.dc1.eharmony.com\",\n \"alias\" => \"damian.np.dc1.eharmony.com\",\n \"address\" => \"damian.np.dc1.eharmony.com\",\n \"max_check_attempts\" => 3,\n \"notification_interval\" => 5,\n # 24x7\n \"notification_period\" => \"24x7\",\n #\"notification_period_id\" => \"5050cb9ebfa68e0903000001\",\n # 24x7\n \"check_period\" => \"24x7\",\n #\"check_period_id\" => \"5050cb9ebfa68e0903000001\",\n # just using first contact\n #\"contacts\" => [\"pat-obrien\"],\n \"contacts\" => [\"damian\"],\n #\"contact_ids\" => [\"5051283ebfa68e5757000002\"],\n }\n\n\n #puts resources['new'].post(NEW_OPTS.to_json, :content_type => :json, :accept \n #=> :json )\n # NOTE: even though this works and creates a new Host in DB - i still get 406 \n # Not Acceptable response\n #puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts}, :accept => \n #:json )\n begin\n puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts})\n rescue Exception => e\n puts \"ERROR: #{e} = #{e.inspect}\"\n end\n\n \n\n # now edit the resource ...\nend", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def update number, routes\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/tns/{number}\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n \"number\" => number,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"Flowroute SDK 1.0\",\r\n \"content-type\" => \"application/json; charset=utf-8\"\r\n }\r\n\r\n response = CustomAuthUtility.append_custom_auth_params method:'PATCH',\r\n query_url:query_url,\r\n body:\"{\\\"routes\\\": #{routes.to_json}}\",\r\n headers:headers\r\n\r\n # Error handling using HTTP status codes\r\n if response.code == 401\r\n raise APIException.new \"NOT AUTHORIZED\", 401, response.raw_body\r\n elsif response.code == 500\r\n raise APIException.new \"APPLICATION/SERVER ERROR\", 500, response.raw_body\r\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = [{ 'op' => operation, 'path' => path, 'value' => value }]\n patch_options = { 'If-Match' => @data['eTag'] }\n response = @client.rest_patch(@data['uri'], patch_options.merge('body' => body), @api_version)\n @client.response_handler(response)\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch?\r\nHTTP_METHOD_LOOKUP[request_method] == :patch\r\nend", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update\n respond_with []\n end", "def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def put(path_part, payload, additional_headers = {}, &block)\n api_request { @rest.put('/REST/' + path_part, payload.to_json, additional_headers, &block) }\n end", "def patch(resource, id, params)\n Api.new.patch(resource, id, params)\n end", "def update!(**args)\n @client = args[:client] if args.key?(:client)\n @list_update_requests = args[:list_update_requests] if args.key?(:list_update_requests)\n end", "def put(*args)\n request :put, *args\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\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_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update\n respond_to do |format|\n if @restora.update(restora_params)\n format.html { redirect_to @restora, notice: 'Restora was successfully updated.' }\n format.json { render :show, status: :ok, location: @restora }\n else\n format.html { render :edit }\n format.json { render json: @restora.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @question_localized = QuestionLocalized.find(params[:id])\n\n respond_to do |format|\n if @question_localized.update_attributes(params[:question_localized])\n flash[:notice] = 'QuestionLocalized was successfully updated.'\n format.html { redirect_to(@question_localized) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question_localized.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Patch.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n response = http.start {|http| http.request(request) }\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend", "def patch(request)\n request.method = :patch\n request.call\n end", "def update\n respond_to do |format|\n require 'rest-client'\n response = RestClient.put('localhost:3001/colores/'+@color.id.to_s, color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n\n format.html { redirect_to @color, notice: \"Color was successfully updated.\" }\n format.json { render :show, status: :ok, location: @color }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end", "def base_update(resource, id, options, format = nil, headers = nil)\n headers ||= {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n headers[:content_type] = \"#{format}\"\n headers[:prefer] = @return_preference if @use_return_preference\n options = {} if options.nil?\n options[:resource] = resource.class\n options[:format] = format\n options[:id] = id\n reply = put resource_url(options), resource, fhir_headers(headers)\n reply.resource = parse_reply(resource.class, format, reply) if reply.body.present?\n reply.resource_class = resource.class\n reply\n end", "def update\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n if @recipe_all.update_attributes(params[:recipe_all])\n format.html { redirect_to @recipe_all, notice: 'Recipe all was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_all.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def patch(url, data, headers = {})\n request(:patch, url, headers, :data => data)\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def patch; end" ]
[ "0.6803028", "0.67416245", "0.67416245", "0.6635341", "0.6599856", "0.6599856", "0.6581939", "0.6520609", "0.6495032", "0.6442611", "0.63919777", "0.63912296", "0.6261466", "0.6203461", "0.61574394", "0.61506456", "0.6123332", "0.609927", "0.60703343", "0.60681707", "0.5996753", "0.59775853", "0.5973916", "0.5946576", "0.5926184", "0.59136516", "0.5900129", "0.5898224", "0.5891779", "0.5858603", "0.58175945", "0.5811169", "0.5807632", "0.57903105", "0.57903105", "0.57802874", "0.5775077", "0.57472897", "0.57410514", "0.5738704", "0.5721538", "0.571676", "0.571676", "0.57111496", "0.5710151", "0.5703134", "0.569126", "0.56895363", "0.5689004", "0.56744266", "0.5664445", "0.5664445", "0.5664445", "0.5661592", "0.5660997", "0.56563485", "0.5646581", "0.56377786", "0.56357527", "0.5625149", "0.56203973", "0.5613832", "0.5613778", "0.56124717", "0.56112736", "0.561024", "0.5605386", "0.5602268", "0.55872476", "0.55872476", "0.55799437", "0.5577825", "0.5577825", "0.55366033", "0.5523966", "0.5523662", "0.552207", "0.55132526", "0.55112934", "0.5505488", "0.549922", "0.5496447", "0.5491477", "0.54912454", "0.5491117", "0.5475869", "0.547387", "0.5470303", "0.5464036", "0.54549056", "0.5452614", "0.54472095", "0.5446749", "0.54326826", "0.54296535", "0.54227847", "0.5422582", "0.54216415", "0.5416359", "0.54097664" ]
0.687671
0
DELETE /rests/1 DELETE /rests/1.json
def destroy @rest.destroy respond_to do |format| format.html { redirect_to rests_url, notice: 'Rest was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @rest_api.destroy\n respond_to do |format|\n format.html { redirect_to rest_apis_url }\n format.json { head :no_content }\n end\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @resto.destroy\n respond_to do |format|\n format.html { redirect_to restos_url, notice: 'Entry was deleted.' }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete(url, headers={})\n RestClient.delete url, headers\n end", "def delete(*rest) end", "def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n @instrument_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_versions_url) }\n format.xml { head :ok }\n end\n end", "def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end", "def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end", "def destroy\n @resturant.destroy\n respond_to do |format|\n format.html { redirect_to resturants_url, notice: 'Resturant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end", "def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end", "def destroy_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n @entry_instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_instruments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @restconnection.destroy\n respond_to do |format|\n format.html { redirect_to restconnections_url, notice: 'Restconnection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @entry_item = EntryItem.find(params[:id])\n @entry_item.destroy\n\n respond_to do |format|\n #format.html { redirect_to(entry_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'+@color.id.to_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @restroom.destroy\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def rest_delete(path, options={}, &blk)\n delete path do |*args|\n @object = yield(*args) or pass\n @object.destroy\n rest_respond :result => :success\n end\n end", "def rest_delete(path, options={}, &blk)\n delete path do |*args|\n @object = yield(*args) or pass\n @object.destroy\n rest_respond :result => :success\n end\n end", "def delete\n api_client.delete(url)\n end", "def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete\n api(\"Delete\")\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete options\n rest_request({ method: :delete }.merge(options))\n end", "def delete options\n rest_request({ method: :delete }.merge(options))\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def destroy\n @api.destroy\n respond_to do |format|\n format.html { redirect_to apis_url }\n format.json { head :no_content }\n end\n end", "def delete\n ensure_client && ensure_uri\n response = @client.rest_delete(@data['uri'], { 'Accept-Language' => 'en_US' }, @api_version)\n @client.response_handler(response)\n true\n end", "def destroy\n @api_v1_resource.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @restora.destroy\n respond_to do |format|\n format.html { redirect_to restoras_url, notice: 'Restora was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end", "def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\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 @restroom = Restroom.find(params[:id])\n authorize @restroom\n @restroom.destroy\n respond_to do |format|\n format.html { redirect_to restrooms_path, notice: 'Restroom deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @page_usage_event = PageUsageEvent.find(params[:id])\n @page_usage_event.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_usage_events_url) }\n format.xml { head :ok }\n end\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete(id)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\"\n return HTTParty.delete(url, :timeout => 4)\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete!\n request! :delete\n end", "def delete(uri, parameters)\n response = Unirest.delete uri, parameters: parameters\n response.body\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def destroy\n @recipe_all = RecipeAll.find(params[:id])\n @recipe_all.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_alls_url }\n format.json { head :no_content }\n end\n end", "def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @red.destroy\n respond_to do |format|\n format.html { redirect_to reds_url }\n format.json { head :no_content }\n end\n end", "def delete(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n # nothing returned in response body for DELETE\n Response.new(@client[url].delete headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end", "def destroy\n @restroom = Restroom.find(params[:id])\n @restroom.destroy\n authorize! :destroy, @restroom\n\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @restroom = Restroom.find(params[:id])\n @restroom.destroy\n authorize! :destroy, @restroom\n\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n return if @name.nil?\n delete_rest \"extra/#{@name}\"\n end", "def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end", "def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end", "def destroy\n streak, success = jsonapi_destroy.to_a\n\n if success\n render json: { meta: {} }\n else\n render_errors_for(streak)\n end\n end", "def destroy_rest\n @question_localized = QuestionLocalized.find(params[:id])\n @question_localized.destroy\n\n respond_to do |format|\n format.html { redirect_to(question_localizeds_url) }\n format.xml { head :ok }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def delete\n delete_from_server single_url\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def delete(url, resource_name, options = {})\n build_response(resource_name) do\n connection.delete do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end", "def delete(path_part, additional_headers = {}, &block)\n api_request { @rest.delete('/REST/' + path_part, \"\", additional_headers, &block) }\n end", "def delete\n supprimer = SondageService.instance.supprimerSondage(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\nend", "def delete(*args)\n url, subdomain, path, = parse_args(*args)\n rewrap_errors do\n RestClient.delete(build_url(url || subdomain, path), headers)\n end\n end", "def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end", "def delete(*args)\n request(:delete, *args)\n end", "def destroy\n destroy_resource(resource)\n head :no_content\n end", "def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @short_url.destroy\n render json: { status: \"Deleted\" }\n else\n render json: { head: \"no content\" }\n end \n end", "def delete\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.delete do |req|\n req.url resource_uri\n end\n if res.success?\n data = JSON.parse(res.body)\n reload\n else\n nil\n end\n end", "def delete(params = {})\n Client.current.delete(resource_url, params)\n end", "def destroy\n @api_post.destroy\n\n head :no_content\n end", "def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end", "def test_delete_post\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Delete.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def webhelper_delete_all_apps (username, password, base_url = @base_url)\r\n private_resource = RestClient::Resource.new base_url + \"/api/v1/apps\" , {:user => username , :password => password , :timeout => 30}\r\n response = private_resource.get :accept => :json\r\n json = JSON.parse(response)\r\n json['apps'].each do |i|\r\n url = base_url + i['link']\r\n private_resource = RestClient::Resource.new url , {:user => username , :password => password , :timeout => 30}\r\n response = private_resource.delete \r\n puts response.to_str\r\n end\r\n end", "def destroy\n @curso.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @anything.destroy\n respond_to do |format|\n format.html { redirect_to anythings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :ok }\n end\n end" ]
[ "0.7464244", "0.74373174", "0.73622584", "0.73408127", "0.7227154", "0.7200991", "0.7155777", "0.710573", "0.710573", "0.70631737", "0.70460635", "0.70373535", "0.6969877", "0.6969877", "0.6969877", "0.6969877", "0.69666564", "0.6963404", "0.6944766", "0.6933575", "0.6933575", "0.6918524", "0.6907163", "0.690307", "0.690307", "0.6884658", "0.6884658", "0.68742645", "0.6861783", "0.6861048", "0.6852976", "0.6839348", "0.6837883", "0.6837096", "0.68315995", "0.6831079", "0.6800371", "0.6793281", "0.67690706", "0.676852", "0.67539537", "0.67503196", "0.67404443", "0.6727082", "0.67200303", "0.67200303", "0.6700328", "0.6695481", "0.669071", "0.66893214", "0.66827065", "0.666859", "0.66584307", "0.6654025", "0.664852", "0.6647762", "0.66310495", "0.6620791", "0.6612613", "0.6612306", "0.6596645", "0.6595871", "0.6595871", "0.6586984", "0.6585578", "0.6576261", "0.6571355", "0.6569954", "0.6565262", "0.65638465", "0.65541303", "0.65541303", "0.6550162", "0.6541009", "0.6541009", "0.6541009", "0.6539738", "0.65388155", "0.65375173", "0.6533991", "0.6529565", "0.65278697", "0.6524466", "0.65179795", "0.6505033", "0.650098", "0.65003496", "0.6495459", "0.6494772", "0.64909613", "0.6488082", "0.6484635", "0.6474939", "0.6473102", "0.64687794", "0.6462787", "0.64626706", "0.6457527", "0.6455011", "0.6453069" ]
0.7719696
0