query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
did not come up with this on my own
def is_even(n) !n.odd? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def offences_by; end", "def schubert; end", "def anchored; end", "def terpene; end", "def formation; end", "def rassoc(p0) end", "def berlioz; end", "def stderrs; end", "def loc; end", "def loc; end", "def loc; end", "def ismn; end", "def verdi; end", "def starting_position; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def first_offset; end", "def first_offset; end", "def required_positionals; end", "def trd; end", "def identify; end", "def deco_pos; end", "def first; end", "def first; end", "def same; end", "def intensifier; end", "def internship_passed; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def malts; end", "def pos() end", "def pos() end", "def pos() end", "def pos() end", "def suivre; end", "def getc() end", "def getc() end", "def getc() end", "def offences_by=(_arg0); end", "def expanded; end", "def schumann; end", "def at(p0) end", "def offset; end", "def offset; end", "def offset; end", "def custom; end", "def custom; end", "def rest_positionals; end", "def blg; end", "def ext=(_arg0); end", "def ext=(_arg0); end", "def ext=(_arg0); end", "def probers=(_arg0); end", "def from; end", "def from; end", "def from; end", "def from; end", "def original_result; end", "def escaper; end", "def implemented_in; end", "def isolated; end", "def isolated; end", "def hiss; end", "def leading; end", "def celebration; end", "def tld; end", "def tld; end", "def refs_at; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def specialty; end", "def who_we_are\r\n end", "def starting_position=(_arg0); end", "def bs; end", "def original; end", "def user_os_complex\r\n end", "def real_name; end", "def parts; end", "def parts; end", "def parts; end", "def first?; end", "def upc_e; end", "def index(p0) end" ]
[ "0.656105", "0.5981003", "0.57980824", "0.57980824", "0.57980824", "0.57980824", "0.5785658", "0.57535094", "0.5641894", "0.5612703", "0.5585282", "0.55651945", "0.5549495", "0.5436121", "0.5411029", "0.5411029", "0.5411029", "0.5387723", "0.5371195", "0.53625906", "0.53519297", "0.53519297", "0.53519297", "0.53519297", "0.53519297", "0.53519297", "0.5329656", "0.5329656", "0.53054595", "0.53042316", "0.5300996", "0.5282166", "0.52782804", "0.52782804", "0.5257411", "0.52473456", "0.5247292", "0.52462834", "0.52462834", "0.52462834", "0.52462834", "0.52462834", "0.52462834", "0.52462834", "0.52462834", "0.52272177", "0.5222629", "0.5222629", "0.5222629", "0.5222629", "0.52008885", "0.5198167", "0.5198167", "0.5198167", "0.5197931", "0.5182368", "0.51745147", "0.51627266", "0.516263", "0.516263", "0.516263", "0.51614416", "0.51614416", "0.5155178", "0.51276463", "0.5127041", "0.5127041", "0.5127041", "0.5117984", "0.51132864", "0.51132864", "0.51132864", "0.51132864", "0.5105702", "0.5103391", "0.5098533", "0.50972104", "0.50972104", "0.5076627", "0.5059546", "0.50501543", "0.5049897", "0.5049897", "0.5043577", "0.5043017", "0.5043017", "0.5043017", "0.5043017", "0.5038489", "0.5035319", "0.502778", "0.5024382", "0.502427", "0.5023123", "0.50224966", "0.50159335", "0.50159335", "0.50159335", "0.5010799", "0.49992853", "0.4996573" ]
0.0
-1
string The String which is to be decided. Examples is_empty("") => true Returns the boolean value of the comparison.
def is_empty(string) return true if string.length == 0 return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_string?(); @type == GRT_STRING; end", "def is_string\n return @is_string\n end", "def string?\n type == \"STRING\"\n end", "def empty_str?(value)\n EMPTY_STRING.eql?(value)\n end", "def empty(string)\n if string == \"\" \n return true\n else \n return false\n end\nend", "def string?\n @kind == :double_string_lit || @kind == :single_string_lit\n end", "def check_string(string)\n string.empty? ? nil : string\n end", "def string?\n !@arg[:textValue].nil?\n end", "def string_message(string)\n if string.empty?\n \"It's an empty string!\"\n else\n \"The string is nonempty.\"\n end\n end", "def value?(value) value.is_a?(String) end", "def is_empty(string)\n return true if string == \"\"\n return false\nend", "def blank?( string )\n string.respond_to?(:empty?) ? !!string.empty? : !string\n end", "def require_string(value)\n if value.nil? == true || value.to_s.empty?\n log_error_and_raise(\"expected string value, got nil or empty string\")\n end\n\n if value.is_a?(String) != true\n log_error_and_raise(\"expected string value, got #{value.class}, #{value.inspect}\")\n end\n\n end", "def present?(string)\n return !blank?(string)\n end", "def string_message(str = \"\")\n if str.empty?\n \"It's an empty string!\"\n else\n # explicit return option\n return \"The string is nonempty.\"\n end\n end", "def string?(input)\n input.class == String\nend", "def ==(string)\n @data == string\n end", "def == other\n\t\tstring == other.string\n\tend", "def correct?(string)\n \"#{string}\".downcase == self.string.downcase\n end", "def plain_string?\n (type == :string || type == :text) && # String typed\n !value.nil? &&\n !value.empty? &&\n !is_text_run? && # No inline styles\n !is_formula? &&\n !is_array_formula?\n end", "def string?(str)\n str.is_a?(String)\n end", "def string?\n data_type == String\n end", "def ==(other)\n str == other\n end", "def true_string?(field)\n field == 'true' || field == true\n end", "def is_string(input)\n input.kind_of?(String)\n end", "def string?(description)\n description.type == :str\n end", "def string?; end", "def string?(string, &block)\n string !~ /\\0/ && runner( String, string, &block )\n end", "def value_is_boolean?(string)\n return %w[true false yes no y n].include?(string.downcase)\n end", "def is_empty(str)\n return str.empty?\nend", "def str_to_bool(str)\n if str.size > 0 and str[0].chr == '!'\n command = str[1, str.length]\n value = `#{command}`\n else\n value = str\n end\n\n case value.downcase.strip\n when \"false\", \"0\", \"nil\", \"\", \"no\", \"off\"\n nil\n when \"true\", \"1\", \"yes\", \"on\"\n true\n else\n value\n end\n end", "def valid_string?(string)\n if string.class == String\n string\n else\n false\n end\nend", "def string_message2(string)\n return \"It's an empty string!\" if string.empty?\n return \"The string is nonempty.\"\n end", "def validString?(s)\n if s.nil? \n false\n else if s.empty?\n false\n end\n end\n true\nend", "def validString?(s)\n if s.nil? \n false\n else if s.empty?\n false\n end\n end\n true\nend", "def valid_string?(field, param)\n true\n end", "def == other\n string == other.string\n end", "def decide string\n @current_state = @start_state\n string.each_char do |c|\n if [email protected]? c then\n return false\n end\n transition = false\n @transition_rules.each do |rule|\n if rule.input_char === c && rule.current_state === @current_state then\n transition = rule\n break\n end\n end\n if !transition then \n return false\n else\n @current_state = transition.end_state\n end\n end\n\n if @accept_states.include? @current_state then\n return true\n else\n return false\n end\n end", "def can_show? str\n \treturn not(str.nil? || str === \"\")\n end", "def truthy?(string)\n string.to_s.casecmp('true').zero?\nend", "def truthy?(string)\n string.to_s.casecmp('true').zero?\nend", "def is_strtype?(); @type == GRT_STRTYPE; end", "def string?(value, options = nil)\n return true if value.nil? and not required(options) \n return false unless value.is_a?(String)\n return true unless options.is_a?(Hash)\n if options.key?(:min)\n return false unless gt(options[:min], value.split(\"\").size, options[:include])\n end\n\n if options.key?(:max)\n return false unless gt(value.split(\"\").size, options[:max], options[:include])\n end\n\n return true\n end", "def before_tarantula(string)\n tarantula = 'tarantula'\n return value = tarantula <=> string\n \n if value == 0 \n return false\n elsif value == 1\n return true\n else \n return false \n end\n\nend", "def validate_string( str )\r\n if str.kind_of?(String)\r\n return true\r\n else\r\n puts \"#{self.class}:check_string: Error: Input must be a string.\"\r\n return false\r\n end\r\n end", "def is_ustring?(); @type == GRT_USTRING; end", "def boolString(value)\n if value == \"0\"\n return \"false\"\n else\n return \"true\"\n end\n end", "def is_string?\n @name.is_a?(String) && @stack.empty?\n end", "def missing_default_forged_as_empty_string?(default)\n type != :string && ! null && default == ''\n end", "def Starts_whit(string1,character)\n return string1[0] == character\nend", "def compare_strings(str1, str2)\n\tif str1 > str2\n\tp true\n else \n \tp false\n \tend\n end", "def str_to_bool(str)\n if str.size > 0 and str[0].chr == '!'\n command = str[1, str.length]\n value = `#{command}`\n else\n value = str\n end\n\n case value.downcase.strip\n when \"false\", \"0\", \"nil\", \"\", \"no\", \"off\"\n nil\n when \"true\", \"1\", \"yes\", \"on\"\n true\n when /\\n/\n value.strip.split(/\\n+/)\n else\n value\n end\n end", "def blank?(str)\n str.nil? || str.to_s.strip == ''\nend", "def is_nil_or_empty_string(str)\n return false unless ((str == nil) or (str == \"\"))\n return true\n end", "def correct?(str)\n str = str.is_a?(String) ? str : str.to_s\n str == (@answer.is_a?(String) ? @answer : @answer.to_s) # don't change @answer type\n end", "def result\n val = value.sub(/^boolean-/, '')\n val.casecmp(\"true\").zero?\n end", "def string\n lambda do |x, convert = false|\n return x.to_s if convert\n\n x.to_s == x\n end\n end", "def to_bool(questionable_string)\n\tbool = true\n\tunless questionable_string == \"true\"\n\t\tbool = false\n\tend\n\tbool\nend", "def string= string\n #This is a stub, used for indexing\n end", "def provided?\n [email protected]?\n end", "def double_quotes_required?(string); end", "def double_quotes_required?(string); end", "def empty?(input)\n input == \"\" ? true : false\n end", "def is_true?\n [true, \"true\", 1, \"1\", \"T\", \"t\"].include?(\n self.value.class == String ? self.value.downcase : self.value\n )\n end", "def myspace?; myspace.to_s != \"\" end", "def blank?(str)\n str.nil? or (str.is_a? String and str.strip.empty?)\n end", "def sb(s)\r\n (s == '(none)' || s == '') ? '' : s\r\n end", "def string(str); end", "def carried_by_string\n return \"in\"\n end", "def string_value?(value)\n string = value.to_s\n [NonWordMatcher, KeywordMatcher].any? { |matcher|\n matcher.match string\n }\n end", "def is_string()\n res = super(context,self)\n return res\n end", "def empty(input)\n string = input.to_s\n if string.length != 0\n return false\n else\n return true\n end\nend", "def string(string)\n Types::String.cast(string)\n end", "def get_string_value\n\t\tend", "def test_equality_string\n value1_ = ::Versionomy.parse(\"1.8.7p72\")\n assert_operator(value1_, :==, \"1.8.7p72\")\n assert_operator(value1_, :==, \"1.8.7.0-72.0\")\n end", "def in_both?(string)\n\t\t[\"elsif\",\"else\",\"when\",\"rescue\",\"ensure\"].each{|x|\n\t\treturn true if string.lstrip.slice(/^#{x}/)\n\t\t}\n\t\tfalse\n\tend", "def string\n @string\n end", "def string\n @string\n end", "def isStringConstant(str)\n return (str[0].to_s == \"\\\"\" and str[str.to_s.size - 1].to_s == \"\\\"\") #if statement surrounded by quotation marks of any kinds\n\n return false\nend", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def string; end", "def is_string?\n columns.all? { |col| col.is_string? }\n end", "def to_boolean(string)\r\n if string.downcase == 'y'\r\n string = true\r\n elsif string.downcase == 'n'\r\n string = false\r\n end\r\nend", "def string_to_bool(value)\n return false if value.nil? || value.casecmp('no').zero?\n return true if value.casecmp('yes').zero?\n value # if it doesn't match anything\n end", "def is_s?\n true if String(self) rescue false\n end", "def allcaps(string) # Defining our method with a name and parameter\n if string.length > 10 # 'if' condition\n puts string.upcase # If above is true then this gets executed\n else\n puts string # If above 'if' condition is false this gets executed\n end\nend", "def string_condition_type=(string_condition_type)\n validator = EnumAttributeValidator.new('String', ['equals', 'contains', 'starts_with', 'ends_with', 'regex'])\n unless validator.valid?(string_condition_type)\n fail ArgumentError, 'invalid value for \"string_condition_type\", must be one of #{validator.allowable_values}.'\n end\n @string_condition_type = string_condition_type\n end", "def isEmpty(value) \n return value.nil? || value.strip == \"\"\nend", "def is_palindrome = 'racecar'", "def to_boolean(string)\n string == 'true'\nend", "def is_strname?(); @type == GRT_STRNAME; end", "def nil_or_empty_string?(obj)\n obj.nil? || obj.empty?\n end", "def string(value = '')\n return '' unless present?(value)\n\n send(value)\n rescue NoMethodError\n ''\n end" ]
[ "0.6848677", "0.6819934", "0.6817137", "0.6809451", "0.6780125", "0.6743893", "0.6686278", "0.65856427", "0.65034145", "0.64639074", "0.64535916", "0.64395416", "0.64324284", "0.63794", "0.63222355", "0.6315465", "0.6314787", "0.63009185", "0.62568605", "0.6254949", "0.625475", "0.6230701", "0.6198238", "0.61952513", "0.6188297", "0.61877567", "0.61317027", "0.60994345", "0.608843", "0.60726756", "0.6070642", "0.60668766", "0.60644037", "0.60586154", "0.60586154", "0.60464996", "0.604185", "0.6040207", "0.60222334", "0.5998635", "0.5998635", "0.5994335", "0.59847426", "0.59650636", "0.59513235", "0.5948375", "0.5939299", "0.58930564", "0.584891", "0.58414733", "0.58253294", "0.5824989", "0.58164144", "0.5807421", "0.57827747", "0.5770799", "0.5764276", "0.5759397", "0.5755529", "0.5753388", "0.5731815", "0.5731815", "0.57196593", "0.57065", "0.57026666", "0.5699622", "0.5698567", "0.56842816", "0.5684041", "0.56708765", "0.5655106", "0.56475604", "0.56379884", "0.5624398", "0.5611568", "0.56095487", "0.56036925", "0.56036925", "0.5598518", "0.5572919", "0.5572919", "0.5572919", "0.5572919", "0.5572919", "0.5572919", "0.5572919", "0.5572919", "0.5572919", "0.55454993", "0.55447114", "0.554458", "0.5539647", "0.55379903", "0.55370903", "0.5536566", "0.55350035", "0.55279946", "0.55267006", "0.5518334", "0.5511866" ]
0.57386243
60
Special accessors that need typecasting or other parsing
def id return self.topic['id'].to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_value; end", "def parse\n raise NotImplementedError\n end", "def parse\n raise NotImplementedError.new\n end", "def value_coercion(value); end", "def cast_types; end", "def read_attr(anno, res, col, offset = 0)\n if anno[:class].ancestor? Integer\n self.class.parse_int(res[col + offset])\n elsif anno[:class].ancestor? Float\n self.class.parse_float(res[col + offset])\n elsif anno[:class].ancestor? String\n res[col + offset]\n elsif anno[:class].ancestor? Time\n self.class.parse_timestamp(res[col+ offset])\n elsif anno[:class].ancestor? Date\n self.class.parse_date(res[col + offset])\n elsif anno[:class].ancestor? TrueClass\n self.class.parse_boolean(res[col + offset])\n elsif anno[:class].ancestor? Og::Blob\n self.class.parse_blob(res[col + offset])\n else\n if res[col+offset].nil? or res[col+offset].empty?\n return nil\n else\n return YAML::load(res[col + offset])\n end\n end\n end", "def parse_values; end", "def parsed\n raise NotImplementedError\n end", "def value\n typecast.present? ? typecasted_value : super\n end", "def typecast(value)\n if value.kind_of?(Range) then Range.new(typecast(value.first), typecast(value.last))\n elsif value.kind_of?(Array) then value.map{|v| typecast(v)}\n elsif primitive == BigDecimal then super(value).to_f\n elsif primitive == DateTime then Time.parse(super(value).to_s).to_i\n elsif primitive == Date then Time.parse(super(value).to_s).to_i\n elsif primitive == Time then super(value).to_i\n else\n super(value) # Good luck\n end\n end", "def getters; end", "def parse()\n #This is a stub, used for indexing\n end", "def nonregular_type; end", "def parse; end", "def parse; end", "def parse; end", "def cast(sval)\n case sid\n when 'integer' then sval.to_i\n when 'string', 'text' then sval\n when 'boolean' then BoolTrueReps.member?(sval.to_s)\n when 'float' then sval.to_f\n when 'date' then sval && Date.parse(sval)\n else raise \"Don't know how to handle MetaPropertyType with sid '#{sid}'.\"\n end\n end", "def parse(sval)\n case sid\n when 'integer' then sval.to_s\n when 'string', 'text' then sval.to_s\n when 'boolean' then BoolTrueReps.member?(sval.to_s).to_s\n when 'float' then sval.to_s\n when 'date' then sval.presence && (sval.is_a?(String) ? Date.parse(sval) : sval).strftime(\"%Y-%m-%d\")\n else raise \"Don't know how to handle MetaPropertyType with sid '#{sid}'.\"\n end\n end", "def coerce(oth)\n case oth\n when String\n oth = parser.parse(oth)\n else\n super\n end\n\n return oth, self\n end", "def converters; end", "def converters; end", "def converters; end", "def parse\n end", "def parse\n raise \"absctract method called\"\n end", "def method_missing(meth, *args, &block)\n if not @parsed.nil? and @parsed.respond_to?(meth)\n return @parsed.send(meth.to_s, *args, &block)\n end\n return super\n end", "def raw_value; end", "def method_missing(meth, *args, &block)\n if args.empty? && !block_given? && (match = /\\Ato_(\\w+)\\Z/.match(meth.to_s))\n begin\n convert_to(match[1])\n rescue ExpressionError\n super(meth, *args, &block)\n end\n else\n super(meth, *args, &block)\n end\n end", "def call(values)\n super.load_typecast\n end", "def read_attribute_before_type_cast(name)\n if prop = property(name)\n attributes_before_type_cast[prop.as]\n else\n attributes_before_type_cast[name.to_s]\n end\n end", "def value_read; end", "def get_field_deserializers()\n return super.merge({\n \"unit\" => lambda {|n| @unit = n.get_string_value() },\n \"value\" => lambda {|n| @value = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def method_missing(method, *args, &block)\n if self.data.respond_to?(method)\n typecast(self.data.send(method,*args,&block))\n elsif self.data.is_a?(Hash) && self.data.key?(method.to_s)\n typecast(self.data[method.to_s])\n else\n super\n end\n end", "def cast_eav_value value, attribute # :nodoc:\n attributes = self.class_eav_attributes.stringify_keys\n return value unless attributes.keys.include?(attribute)\n return value if attributes[attribute] == String # no need for casting\n\n\n begin\n # for core types [eg: Integer '12']\n eval(\"#{attributes[attribute]} '#{value}'\")\n\n rescue\n begin\n # for BigDecimal [eg: BigDecimal.new(\"123.45\")]\n eval(\"#{attributes[attribute]}.new('#{value}')\")\n\n rescue\n begin\n # for date/time classes [eg: Date.parse(\"2011-03-20\")]\n eval(\"#{attributes[attribute]}.parse('#{value}')\")\n rescue\n value\n end\n\n end\n end\n end", "def [](name)\n field(name).convert(@raw)\n end", "def typecast(value)\n value\n end", "def object_field_value(method)\n meth = \"#{method}_before_type_cast\"\n if object && object.respond_to?(meth)\n object.send(meth)\n elsif object && object.respond_to?(method)\n object.send(method)\n else\n method.to_s.humanize\n end\n end", "def cast_as_value(as_type,as_property)\n if(as_type == :date)\n return \"XMLUtils.dateToXML(#{as_property})\"\n elsif(as_type == :datetime)\n return \"TolDateUtils.toTimeParam(#{as_property})\"\n else\n return as_property\n end\n end", "def lenient_value_coercions; end", "def cast_value(v)\r\n return nil if v.nil?\r\n if @type == :date\r\n self.style = STYLE_DATE if self.style == 0\r\n v\r\n elsif (@type == :time && v.is_a?(Time)) || (@type == :time && v.respond_to?(:to_time))\r\n self.style = STYLE_DATE if self.style == 0\r\n # one simple little fix. I DO NOT WANT TIME IN LOCAL TIME!\r\n unless v.is_a?(Time)\r\n v = v.respond_to?(:to_time) ? v.to_time : v\r\n end\r\n v\r\n elsif @type == :float\r\n v.to_f\r\n elsif @type == :integer\r\n v.to_i\r\n elsif @type == :boolean\r\n v ? 1 : 0\r\n elsif @type == :iso_8601\r\n #consumer is responsible for ensuring the iso_8601 format when specifying this type\r\n v\r\n else\r\n @type = :string\r\n # TODO find a better way to do this as it accounts for 30% of\r\n # processing time in benchmarking...\r\n Axlsx::trust_input ? v.to_s : ::CGI.escapeHTML(v.to_s)\r\n end\r\n end", "def get_int(attr); end", "def as(type_symbol)\n return case type_symbol.to_sym\n when :string\n self.string_value\n when :text\n self.text_value\n when :integer\n self.integer_value\n when :float\n self.float_value\n when :date\n self.datetime_value.nil? ? nil : self.datetime_value.to_date\n when :time\n self.datetime_value.nil? ? nil : self.datetime_value.to_time\n when :datetime\n self.datetime_value\n when :answer\n self.answer_id\n else\n self.answer_id\n end\n end", "def assign_value\n if assigned_attr = AttrName.find_by_id(self.attr_name_id)\n case assigned_attr.value_type\n when \"STRING\"\n self.string_val = self.raw_value\n when \"FLOAT\" #has a special case to remove the dollar symbol in front of it\n #remove_dollar_sign\n self.float_val = self.raw_value.to_f\n when \"DATETIME\"\n self.datetime_val = self.raw_value.to_datetime\n when \"BOOLEAN\"\n if self.raw_value == 'true'\n self.bool_val = true\n else\n self.bool_val = false\n end\n when \"INTEGER\"\n if assigned_attr.treat_as_price\n logger.debug \"Treating this as a price\"\n self.price_val_cents = Money.parse(self.raw_value).cents\n else\n self.int_val = self.raw_value.to_i\n end\n else\n self.string_val = self.raw_value\n end\n end\n end", "def typecast_attribute_for_read(attr_name, value)\n self\n .find_typecaster(attr_name)\n .from_api(value)\n end", "def raw_getter field\n val = self.instance_variable_get(\"@#{field}\")\n return nil if val.nil? == true || val == false\n\n if BOOL_ATTRIBUTES.include? field\n return field.to_s.gsub '_', '-' \n end\n\n if STR_ATTRIBUTES.include? field \n return val \n end\n\n if ARR_STR_ATTRIBUTES.include? field && val.empty? == false \n return val.join ' '\n end\n\n if SUB_STR_ATTRIBUTES.include? field \n return SUB_STR_ATTRIBUTES[field].sub '%sub%', val \n end \n end", "def reflection; end", "def reflection; end", "def cast\n defined_attributes.each do |name, attr|\n value = public_send(name)\n next if value.nil?\n\n begin\n casted = attr.cast!(value)\n public_send(\"#{name}=\", casted)\n rescue ActiveEntity::CastError\n end\n end\n nil\n end", "def force_parse; end", "def read_attribute_before_type_cast(name)\n attributes.before_type_cast(name.to_sym)\n end", "def parser\n attributes.fetch(:parser)\n end", "def untypecasted_value\n read_attribute(:value)\n end", "def parse(virtual); end", "def attr_get_sb2(attr_type, strict = true)\n #This is a stub, used for indexing\n end", "def typecast_attributes\n @attributes.each_pair do |name,value|\n # skip primary key columns\n # ajay Singh --> skip the loop if attribute is null (!name.present?)\n next if (name == \"id\") or (!name.present?)\n attr_type = attr_type_for(name)\n \n # empty attributes should stay empty (e.g. an empty int field shouldn't be typecast as 0)\n if [:datetime, :datetimecombo, :int].include? attr_type && (value.nil? || value == '')\n @attributes[name] = nil\n next\n end\n \n case attr_type\n when :bool\n @attributes[name] = (value == \"1\")\n when :datetime, :datetimecombo\n begin\n @attributes[name] = DateTime.parse(value)\n rescue\n @attributes[name] = value\n end\n when :int\n @attributes[name] = value.to_i\n end\n end\n @attributes\n end", "def converter; end", "def cast_attribute(value, type_name)\n case type_name\n when :integer then value.to_i\n when :float then value.to_f\n when :boolean then !!value\n else value\n end\n end", "def value_types; end", "def type\n case super\n when 'get' then :get\n when 'set' then :set\n when 'result' then :result\n when 'error' then :error\n else nil\n end\n end", "def attribute_convert val\n case val\n when Fixnum\n if val >= members.size\n raise IndexError, \"offset #{val} too large for #{description}\"\n elsif val < (members.size * -1)\n raise IndexError, \"offset #{val} too small for #{description}\"\n end\n\n val = members.size + val if val < 0\n val = members[val]\n when Symbol, String\n val = val.to_sym\n unless members.include? val\n raise NameError, \"no attribute #{val} in factory\"\n end\n else\n raise TypeError\n end\n val\n end", "def attr; end", "def parsed; end", "def parsed; end", "def cast_value\n value.mongoize\n end", "def get_attribute(name); end", "def get_attribute(name); end", "def validated_parser_type(type); end", "def data_type\n\tend", "def get_field_deserializers()\n return super.merge({\n \"format\" => lambda {|n| @format = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WorkbookChartDataLabelFormat.create_from_discriminator_value(pn) }) },\n \"position\" => lambda {|n| @position = n.get_string_value() },\n \"separator\" => lambda {|n| @separator = n.get_string_value() },\n \"showBubbleSize\" => lambda {|n| @show_bubble_size = n.get_boolean_value() },\n \"showCategoryName\" => lambda {|n| @show_category_name = n.get_boolean_value() },\n \"showLegendKey\" => lambda {|n| @show_legend_key = n.get_boolean_value() },\n \"showPercentage\" => lambda {|n| @show_percentage = n.get_boolean_value() },\n \"showSeriesName\" => lambda {|n| @show_series_name = n.get_boolean_value() },\n \"showValue\" => lambda {|n| @show_value = n.get_boolean_value() },\n })\n end", "def get_cast\n @cast\n end", "def parse_attribute(value, type)\n case type\n when 'INTEGER'\n value.to_i\n when 'BOOLEAN'\n value.to_i == 1\n when 'TEXT'\n value.strip\n else\n raise 'Invalid data type'\n end\n end", "def cast_value(value)\n case value\n when String then decode_and_initialize(value)\n when Hash then extract_model_klass(value).new(value)\n when nil then value\n else\n raise_cast_error(value) unless value.class.ancestors.include?(StoreModel::Model)\n\n value\n end\n rescue ActiveModel::UnknownAttributeError => e\n handle_unknown_attribute(value, e)\n end", "def data_type\n\t\tend", "def convert\n raise NotImplementedError\n end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def typecast(value)\n value\n end", "def attributes_before_type_cast\n @attributes\n end", "def convert(object); end", "def raw_cast(value)\n # We can strip value here but we do not want to squish it unless for number\n value = value.to_s.strip\n return nil if value.empty?\n\n case data_type\n when 'number'\n BigDecimal(remove_decimal_mark(value.squish))\n when 'date'\n # date_format likely will be '%m/%d/%Y', but if we got '19/8/2014',\n # then `strptime` will raise invalid date error\n # Sometimes we can get '27/11 /1981' also :(\n begin\n Date.strptime(value, @resultset.date_format)\n rescue StandardError\n # We could be getting back these date:\n # '17.12.95', '19/05/99', '27/11 /1981'\n # '1959-07-03' will be beyond us, so consider returning exact value\n value = value.gsub(/-|\\./, '/')\n split = value.split('/').map(&:strip)\n split[2] = \"19#{split[2]}\" if split[2].size == 2\n value = split.join('/')\n\n Date.strptime(\n Date.parse(value)\n .strftime(@resultset.date_format), @resultset.date_format\n )\n end\n when 'time'\n DateTime.strptime(\"1/1/-4712 #{value}\", @resultset.timestamp_format)\n when 'timestamp'\n DateTime.strptime(value, @resultset.timestamp_format)\n when 'container'\n # container may return value that include URI scheme already\n return URI.parse(value) if value.start_with?('http')\n URI.parse(\"#{@resultset.server.url}#{value}\")\n else\n value\n end\n rescue StandardError => e\n warn \"Could not coerce #{name}: #{value} due to #{e.message.force_encoding(\"UTF-8\")}\"\n value\n end", "def parse_data\n [object_ref, get_symbol, parse]\n end", "def strict_value_coercions; end", "def get_field_deserializers()\n return super.merge({\n \"self\" => lambda {|n| @self_escaped = n.get_string_value() },\n })\n end", "def typecast_to_numeric(value, method)\n if value.is_a?(String)\n value = value.strip.gsub(/,/, '.').gsub(/[^\\d\\-\\.]/, '').gsub(/\\.(?!\\d*\\Z)/, '')\n value.empty? ? nil : value.send(method)\n elsif value.respond_to?(method)\n value.send(method)\n else\n nil\n end\n end", "def convert\n end", "def convert\n end", "def to_getter\n\t\t\t\tis_setter? ? self.to_s[0...-1].to_sym : self\n\t\t\tend", "def type_cast(value)\n case type\n when 'N' # number\n unpack_number(value)\n when 'I' # integer\n unpack_unsigned_long(value)\n when 'F' # float\n unpack_float(value)\n when 'D' # date\n decode_date(value)\n when 'T' # datetime\n decode_datetime(value)\n when 'L' # logical\n boolean(value)\n else\n value.to_s.strip\n end\n end", "def read_attribute_with_type_conversion(property)\n self.class._converter(property).to_ruby(read_attribute_without_type_conversion(property))\n end", "def attribute(name); end", "def attr_get_sb4(attr_type, strict = true)\n #This is a stub, used for indexing\n end", "def value() end", "def parse\n @parsed\n end", "def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"v10_0\" => lambda {|n| @v10_0 = n.get_boolean_value() },\n \"v8_0\" => lambda {|n| @v8_0 = n.get_boolean_value() },\n \"v8_1\" => lambda {|n| @v8_1 = n.get_boolean_value() },\n }\n end", "def read_attribute_with_type_conversion(property)\n self.class._converter(property).to_ruby(read_attribute_without_type_conversion(property))\n end", "def variables\n super.transform_values do |details|\n if details['type'] == 'Json'\n JSON.parse(details['value'])\n else\n details['value']\n end\n end\n end", "def get_field_deserializers()\n return {\n \"extensionAttribute1\" => lambda {|n| @extension_attribute1 = n.get_string_value() },\n \"extensionAttribute10\" => lambda {|n| @extension_attribute10 = n.get_string_value() },\n \"extensionAttribute11\" => lambda {|n| @extension_attribute11 = n.get_string_value() },\n \"extensionAttribute12\" => lambda {|n| @extension_attribute12 = n.get_string_value() },\n \"extensionAttribute13\" => lambda {|n| @extension_attribute13 = n.get_string_value() },\n \"extensionAttribute14\" => lambda {|n| @extension_attribute14 = n.get_string_value() },\n \"extensionAttribute15\" => lambda {|n| @extension_attribute15 = n.get_string_value() },\n \"extensionAttribute2\" => lambda {|n| @extension_attribute2 = n.get_string_value() },\n \"extensionAttribute3\" => lambda {|n| @extension_attribute3 = n.get_string_value() },\n \"extensionAttribute4\" => lambda {|n| @extension_attribute4 = n.get_string_value() },\n \"extensionAttribute5\" => lambda {|n| @extension_attribute5 = n.get_string_value() },\n \"extensionAttribute6\" => lambda {|n| @extension_attribute6 = n.get_string_value() },\n \"extensionAttribute7\" => lambda {|n| @extension_attribute7 = n.get_string_value() },\n \"extensionAttribute8\" => lambda {|n| @extension_attribute8 = n.get_string_value() },\n \"extensionAttribute9\" => lambda {|n| @extension_attribute9 = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end" ]
[ "0.64054626", "0.63684815", "0.6135872", "0.6096579", "0.6064413", "0.6058247", "0.60174483", "0.5997507", "0.59937274", "0.5988434", "0.598519", "0.5972595", "0.5926462", "0.58929044", "0.58929044", "0.58929044", "0.5877874", "0.58736825", "0.58443475", "0.581363", "0.581363", "0.581363", "0.58035046", "0.5779199", "0.5763814", "0.5750858", "0.5741423", "0.5738685", "0.5729805", "0.5709786", "0.5691091", "0.5687946", "0.5679248", "0.5672302", "0.5656031", "0.56541586", "0.56495816", "0.5647681", "0.5640623", "0.562467", "0.5621456", "0.5617018", "0.56099206", "0.5597478", "0.5584442", "0.5584442", "0.55729014", "0.55606544", "0.55589044", "0.55522585", "0.55362755", "0.5530482", "0.5516238", "0.55062425", "0.5496427", "0.54928553", "0.5488249", "0.547304", "0.54691535", "0.5461277", "0.54599607", "0.54599607", "0.5455153", "0.5438584", "0.5438584", "0.5432462", "0.54302806", "0.54251325", "0.5424212", "0.5416203", "0.54114765", "0.5406833", "0.5400285", "0.5397387", "0.5397387", "0.5397387", "0.5397387", "0.5397387", "0.5397387", "0.5397387", "0.53953475", "0.5370864", "0.53648496", "0.53601944", "0.5358114", "0.5340054", "0.533369", "0.53318596", "0.53308463", "0.53308463", "0.53293777", "0.53293526", "0.5326205", "0.53148276", "0.53137124", "0.53123593", "0.53093696", "0.5302972", "0.52994406", "0.5298992", "0.5293398" ]
0.0
-1
When using Draper, we wrap the collection draper in a new class that correctly delegates methods that Active Admin depends on.
def collection_decorator if decorator_class Wrapper.wrap decorator_class end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @coll = self.class.collection\n end", "def collection\n klass.collection\n end", "def collection_decorator\n if decorator_class\n Wrapper.wrap decorator_class\n end\n end", "def initialize\n @coll=self.class.collection\n end", "def collection\n self.class.collection\n end", "def collection\n self.class.collection\n end", "def initialize(attrs, collection_name, klass, client, method_name, method_options)\n @attrs = attrs\n @client = client\n @method_name = method_name\n @method_options = method_options\n @collection = Array(attrs[collection_name.to_sym]).map do |item|\n if klass\n klass.fetch_or_new(item)\n else\n item\n end\n end\n singleton_class.class_eval do\n alias_method(collection_name.to_sym, :collection)\n end\n end", "def collection\n klass.collection\n end", "def driver\n collection.driver\n end", "def collection; end", "def collection; end", "def initialize(attrs, collection_name, klass, client, id, method_name, method_options)\n @attrs = attrs\n @client = client\n\t\t\t@id = id\n @method_name = method_name\n @method_options = method_options\n @collection = Array(attrs[:data]).map do |item|\n if klass\n klass.fetch_or_new(item)\n else\n item\n end\n end\n class_eval do\n alias_method(:data, :collection)\n end\n end", "def collection\n @collection ||= load_collection\n end", "def decorated_collection\n @collection.map do |element|\n Resource.new(element, @controller)\n end\n end", "def collection\n @collector.collection\n end", "def make_collection\n @resource.make_collection\n end", "def collection_class\n defined?(Effective::StyleGuide) ? Effective::StyleGuide : super\n end", "def initialize(collection)\n @collection = collection\n end", "def make_collection\n raise NotImplementedError\n end", "def collection\n @collection ||= Collection.load(self.collection_url)\n end", "def collection(objectName)\n Hirsute::Collection.new(objectName)\nend", "def collection_class\n OneToMany::Collection\n end", "def collection_class\n OneToMany::Collection\n end", "def collection\n get_collection_ivar || begin\n set_collection_ivar class_name.all\n end\n end", "def method_missing(method_name, *args, &proc)\n collection.send(method_name, *args, &proc)\n end", "def initialize(collection)\n @collection = collection\n end", "def collection(name)\n Kernel.const_get(\"#{name}Collection\").new(@browser)\n end", "def collection_path\n self.class.collection_path\n end", "def collections; end", "def load_collection\n model_class.all(find_options)\n end", "def collection_method name, &block\n collection_methods[name] = block\n end", "def load_collection_classes\n # load collection scripts at this point so they will override\n # any of the default ones (for example: TeiToEs)\n Dir[\"#{@coll_dir}/scripts/overrides/*.rb\"].each do |f|\n require f\n end\n end", "def prepare_collection!(_wrapper, _element, _options)\n end", "def collection_methods\n (@_collection_methods ||= {})\n end", "def decorate_collection(collection, decorator_class)\n decorated_collection = decorator_class.decorate_collection(collection)\n yield(decorated_collection) if block_given?\n decorated_collection\n end", "def detect_collection_methods; end", "def collections_path; end", "def collection\n instance_variable_get(collection_name) || set_collection(find_collection)\n end", "def set_collection\n @collection = Collection.friendly.find(params[:id])\n end", "def build_collection_proxy(target, association_name:, class_name:, embedded:)\n CollectionProxy.new(**{\n parent: self,\n target: target,\n embedded: embedded,\n class_name: class_name,\n association_name: association_name\n })\n end", "def collection\n return nil unless collection_member?\n @collection ||= SolrDocument.new(\n Blacklight.solr.select(\n :params => {\n :fq => \"#{SolrDocument.unique_key}:\\\"#{self[blacklight_config.collection_member_identifying_field].first}\\\"\"\n }\n )[\"response\"][\"docs\"].first\n )\n end", "def set_collection\n @collection = Collection.friendly.find params[:id]\n end", "def collection_representer_klass\n resource_module::Representer::Collection\n end", "def collection\n raise(NotImplementedError, '#collection must be defined in the TypicalSituation implementation.')\n end", "def model\n options.key?(:collection) ? call(:collection).klass : collection\n end", "def collection_name; end", "def collection_name; end", "def collection_name; end", "def load_collection\n current_site.links\n end", "def getCollection\n return @coll\n end", "def paginate_collection!\n set_collection get_collection.page(params[:page]).per(self.class.per_page)\n end", "def instantiate_collection_with_collection(collection, prefix_options = {})\n if collection.is_a?(Hash) && collection[\"type\"] == \"collection\"\n collectables = collection.values.find{|c| c.is_a?(Hash) || c.is_a?(Array) }\n collectables = [collectables].compact unless collectables.kind_of?(Array)\n instantiated_collection = WillPaginate::Collection.create(collection[\"current_page\"], collection[\"per_page\"], collection[\"total_entries\"]) do |pager|\n pager.replace instantiate_collection_without_collection(collectables, prefix_options)\n end \n else\n instantiate_collection_without_collection(collection, prefix_options)\n end \n end", "def initialize(collection, options = {})\n @collection = collection\n @options = options\n end", "def initialize(collection, options = {})\n @collection = collection\n @options = options\n end", "def collection_url\n super_url(with_chain(resource_class))\n end", "def setup *args, &block\n setup_without_mongoid *args, &block\n\n require 'active_admin/mongoid/comments'\n require 'active_admin/mongoid/adaptor'\n require 'active_admin/mongoid/filter_form_builder'\n require 'active_admin/mongoid/data_access'\n require 'active_admin/mongoid/resource'\n require 'active_admin/mongoid/document'\n require 'active_admin/mongoid/helpers/collection'\n require 'active_admin/mongoid/criteria'\n\n end", "def collection(name, options = {})\n set_default_options(name, options)\n super(name, options)\n end", "def collection_path\n self.class.collection_path\n end", "def new_collection\n Models::Collection.new\n end", "def collection\n attr_name = \"@\" + self.resources_configuration[:self][:collection_name].to_s\n unless instance_variable_get(attr_name)\n col = end_of_association_chain\n col = col.sorted(params[:sort], default_sort)\n col = col.page(params[:page])\n instance_variable_set(attr_name, col)\n end\n instance_variable_get(attr_name)\n end", "def collection\n action_name == 'show' ? @presenter : @collection\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 _collection(name)\n @collections[name] ||= Dynamodb::Collection.new(\n @client,\n Lotus::Model::Adapters::Dynamodb::Coercer.new(_mapped_collection(name)),\n name,\n _identity(name),\n )\n end", "def collections\n respond_to?(:articleHasCollection) ? articleHasCollection : []\n end", "def reader\n @proxy ||= CollectionProxy.new(klass, self)\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 collection\n @collection.is_a?(Proc) ? @collection.call : @collection\n end", "def collection; @opts['collection'] end", "def collection_names; end", "def collection_url\n send route_prefix_to_method_name(\"#{class_name.model_name.route_key}_url\")\n end", "def collection(collection, options = {})\n respond_with_object_and_type collection, options, :collection, false\n end", "def set_collection_instance\n instance_variable_set(\"@#{resource_plural_name}\", resource_proxy)\n end", "def collection(model = name.to_s.classify.constantize)\n model\n end", "def collection\n current_grandma.mock_apple_pies\n end", "def initialize\n @collection={}\n end", "def prepare_collection!(wrapper, element, options)\n wrap =\n case options[:wrap]\n when false then options.delete(:wrap)\n when true then true\n when nil then WRAP_COLLECTIONS\n end\n options[:wrap] = wrapper.to_s.demodulize.downcase if wrap\n options[:as] ||= element.to_s.demodulize.downcase\n end", "def initialize *args\n super *args\n self.collection ||= 'infochimps' # test_collection' # \n end", "def find_collections_for_form\n Hyrax::CollectionsService.new(self).search_results(:edit)\n end", "def initialize(args = {})\n args.each { |k, v| send(\"#{k}=\", v) }\n page_collection!\n order_collection!\n search_collection!\n filter_collection!\n end", "def collection_from_options\n if options[:collection].is_a?(Proc)\n template.instance_exec(&options[:collection])\n else\n super\n end\n end", "def collection\n return @client.api_helper.collection(\"items\")\n end", "def instantiate_collection(collection)\n collection.collect! { |record| instantiate_record(record) }\n end", "def collection\n @collection ||= collection_values\n end", "def initialize\n @collection = []\n end", "def find_collection\n @collection = Collection.find(params[:id])\n end", "def collection\n resource_class.all\n end", "def perform_request_with_objects_from_collection(request_method, path, options, klass, collection_name) # rubocop:disable Metrics/ParameterLists\n options = {collection_name.to_sym => options} unless options.empty?\n\n perform_request(request_method, path, options).fetch(collection_name.to_sym).collect do |element|\n klass.new(element)\n end\n end", "def present_collection(collection = resource); nil; end", "def method_missing symbol, *args\n if @klass.collection_methods[symbol]\n instance_exec *args, &@klass.collection_methods[symbol]\n else\n super\n end\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 collection\n @collection ||= PublicEarth::Db::Collection.find_by_id!(collection_id)\n end", "def base_collection\n @base_collection ||= resource_model.all\n end", "def collection\n @collection ||= database.collection Crocoduck::Store.server_collection\n end", "def embedded\n {\n _embedded: {\n @name => decorated_collection\n }\n }\n end", "def collection\n Jrodb::Collection::Basic.new(self)\n end", "def set_collection\n @collection = Collection.find(params[:id])\n end", "def set_collection\n @collection = Collection.find(params[:id])\n end", "def set_collection\n @collection = Collection.find(params[:id])\n end", "def collection_node; end", "def collection_node; end" ]
[ "0.6528904", "0.6510735", "0.64654833", "0.63368165", "0.6327918", "0.6327918", "0.63276905", "0.6294771", "0.6256529", "0.6166439", "0.6166439", "0.615145", "0.6131435", "0.60946006", "0.59815013", "0.59517276", "0.5946922", "0.5946313", "0.592683", "0.5924381", "0.5924103", "0.5914841", "0.5914841", "0.5912164", "0.58808595", "0.58616513", "0.5859454", "0.5836669", "0.5811357", "0.5804725", "0.5777694", "0.5771817", "0.5750722", "0.5720302", "0.57186127", "0.5684941", "0.5670633", "0.5654522", "0.56471974", "0.5645082", "0.56084424", "0.56016636", "0.55953157", "0.5538692", "0.55283254", "0.5523525", "0.5523525", "0.5523525", "0.5519032", "0.55085695", "0.55074763", "0.5505484", "0.54925734", "0.54925734", "0.54885614", "0.5455914", "0.5451485", "0.5442461", "0.54377306", "0.54375345", "0.5430666", "0.5424357", "0.5411076", "0.5404604", "0.54041314", "0.54035354", "0.539532", "0.5384174", "0.53795826", "0.537273", "0.5370306", "0.53691953", "0.5365916", "0.53598636", "0.5357793", "0.5331887", "0.53190094", "0.53185743", "0.5318099", "0.53139067", "0.5312183", "0.5304614", "0.5303898", "0.53029734", "0.52910715", "0.52905405", "0.52864593", "0.5278979", "0.5272523", "0.5265742", "0.5260805", "0.52430797", "0.52418536", "0.52352405", "0.52331483", "0.52317506", "0.52317506", "0.52317506", "0.5228431", "0.5228431" ]
0.64501905
3
Use callbacks to share common setup or constraints between actions.
def set_email @email = params[:id] ? Email.find(params[:id]) : Email.new(email_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 set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def 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 revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\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\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup(&block)\n define_method(:setup, &block)\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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def 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 setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def duas1(action)\n action.call\n action.call\nend", "def call\n setup_context\n super\n end" ]
[ "0.6165422", "0.60457647", "0.5946384", "0.5916027", "0.58905005", "0.583495", "0.5777223", "0.56995213", "0.56995213", "0.56532377", "0.5621348", "0.5422839", "0.54118705", "0.54118705", "0.54118705", "0.53935355", "0.5379617", "0.53577393", "0.53407264", "0.53398263", "0.53316694", "0.53116405", "0.52972704", "0.5296464", "0.529617", "0.52609056", "0.52449894", "0.52388823", "0.52388823", "0.52388823", "0.52388823", "0.52388823", "0.52339035", "0.52324325", "0.52277064", "0.5221976", "0.5219301", "0.52134573", "0.5207571", "0.52070796", "0.51770556", "0.517467", "0.51727664", "0.51673347", "0.51603955", "0.51581466", "0.515401", "0.51533973", "0.5152852", "0.5143863", "0.5140699", "0.513394", "0.5113603", "0.5113603", "0.51126283", "0.5110439", "0.51070756", "0.50922215", "0.50881314", "0.50826275", "0.50788856", "0.50678945", "0.5055518", "0.5052638", "0.5049997", "0.5049997", "0.50348604", "0.5026469", "0.50217324", "0.50154436", "0.5013927", "0.50015604", "0.50013465", "0.49973735", "0.49900484", "0.49900484", "0.49862546", "0.4981161", "0.49783245", "0.49772155", "0.49678212", "0.49645492", "0.49579585", "0.49572104", "0.49550694", "0.4954394", "0.4952923", "0.49466532", "0.49427935", "0.49338013", "0.4931052", "0.49276745", "0.4927467", "0.4924998", "0.49223173", "0.49208498", "0.49184024", "0.49167758", "0.49163175", "0.4916066", "0.49157935" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def email_params params.require(:email).permit(:name, :image, :image_cache, :remove_image, :description, :ngo, :ngo_link, :published) 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
Pseudocode: 1. Print welcome 2. Get horses 'define horses name' 3. Get user's bet 'select in theses horses the one that is going to win get.chomp' 4. Run the race 'select a horse randomly and compare it with the user choice ' 5. Print results 'print if you lose or win'
def you_win(winner) `say "Congratulation! YOU WON, #{winner} was the 1st one!"` end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game\n horse_playing = true\n while horse_playing == true\n selecting = TTY::Prompt.new\n horses = ['PinkLightning', 'WildCat', 'Eclipse', 'Delphi', 'TheDaringDrunk', 'CrazySisterSeline', 'JackSparrow', 'RunningBull', \"RazMaTazz\"]\n racers = []\n selector = 0\n 4.times{\n racer = horses.sample\n horses.delete(racer)\n racers.push(racer)\n }\n puts \"The following horses are racing\"\n puts racers\n choice = selecting.select(\"Who do you think will win\", racers)\n bet = gamble()\n winner = racers.sample\n case winner == choice\n when true\n if choice != \"RazMaTazz\"\n puts \"#{winner} comes thundering over the line, you have won this time\"\n @balance = bet + @balance\n else\n puts \"#{winner} comes in last, better luck next time!\"\n @balance = @balance - bet\n end\n when false\n puts \"#{winner} comes in first, better luck next time!\"\n @balance = @balance - bet\n end\n horse_playing = selecting.select(\"Would you like to bet on the next race\" , [\"Yes\",\"No\"]) == \"Yes\"\n end\n puts \"Returning to Game Menu\"\n end", "def start_game\n\nai = ['R','P','S'].sample\n\nprompt(\"Choose paper(p), rock(r) or scissor(s)\")\nhuman = gets.chomp.upcase\n\n case\n when human == \"P\" && ai == \"P\"\n prompt(\"You chose Paper and I chose Paper: Tie\")\n when human == \"R\" && ai == \"R\"\n prompt(\"You chose Rock and I chose Rock: Tie\")\n when human == \"S\" && ai == \"S\"\n prompt(\"You chose Scissors and I chose Scissors: Tie\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose paper and I chose Rock, you win!\")\n when human == \"R\" && ai == \"S\"\n prompt(\"You chose Rock and I chose Scissors, You win!\")\n when human == \"S\" && ai == \"P\"\n prompt(\"You chose Scissors and I chose Paper, You win!\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose Paper and I chose Rock, You win! \")\n when human == \"S\" && ai == \"R\"\n prompt(\"You chose Scissors and I chose Rock, I win!\")\n when human == \"P\" && ai == \"S\"\n prompt(\"You chose Paper and I chose Scissors, I win\")\n when human == \"R\" && ai == \"P\"\n prompt(\"You chose Rock and I chose Paper, I win!\")\n end\nend", "def human_vs_computer_game\n game = nil\n puts \"Get three in a row to win!\"\n puts \" \"\n puts \"Do you want to be X? Enter y/n\"\n selection = gets.strip\n if selection == \"y\"\n game = Game.new(Players::Human.new(\"X\"), Players::Computer.new(\"O\"))\n elsif selection == \"n\"\n game = Game.new(Players::Computer.new(\"X\"), Players::Human.new(\"O\"))\n else\n puts \"Please enter a valid response\"\n selection = gets.strip\n end\n game.play\n play_again?\n end", "def game\n puts \"\\nIs your baby (H)ungry, (S)leepy, or (P)oopy?\"\n sleep(1)\n puts \"\\nWAAAAAAAH\"\n puts \"\\nWAH WAH WAH\"\n sleep(1)\n puts \"\\nWAAAAAAAH\"\n\n computer = \"hsp\"[rand(3)].chr\n player = gets.chomp.downcase\n case [player, computer]\n when ['h','h'],['s','s'],['p','p']\n puts \"\\nAwesome! The baby stopped crying. You're doing great.\"\n puts \"\\nThe baby is #{computer}.\"\n roundcount\n again\n when ['s','p'],['p','h'],['h','s']\n puts \"\\nWAAAAH! Something else must be wrong! Try again.\"\n puts \"\\nThe baby is #{computer}.\"\n roundcount\n again\n when ['s','h'],['p','s'],['h','p']\n puts \"\\nDon't just stand there! Help your baby!\"\n puts \"\\nThe baby is #{computer}.\"\n roundcount\n again\n else\n puts \"\\nType the first letter of what the baby needs to stop crying!\"\n game\n end\nend", "def game_start\n computer_choice = get_random_choice\n puts(\"Welcome to rock, paper, scissors, lizard, spock game\")\n puts(\"Please enter your choice\")\n \n # a user has 3 chances for an invalid input\n is_valid = false\n user_choice = gets.chomp\n user_choice = user_choice.downcase\n for i in 0..1\n if (!is_valid_input(user_choice))\n puts(\"Invalid input, please enter one of: rock, paper, scissors, lizard, spock\")\n user_choice = gets.chomp\n user_choice = user_choice.downcase\n else\n is_valid = true\n break\n end\n end\n\n if !is_valid\n puts(\"You've entered an invalid choice for three times, game over\")\n else\n match_status = computer_choice.is_defeat(user_choice)\n case match_status\n when 0\n puts(\"DRAW\")\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n when -1 # computer lose\n puts(\"You WIN!\" )\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n puts(announce_winner(user_choice, computer_choice.get_name))\n when 1 # computer win\n puts (\"You LOSE :(\")\n puts(\"your choice: \" + user_choice )\n puts(\"computer choice: \" + computer_choice.get_name)\n puts(announce_winner(computer_choice.get_name, user_choice))\n end\n end\n end", "def play_a_game\n\t#PLAYER 1 choses a valid selection of r,p,s\n\tprint \"\\nPLAYER 1, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_1_choice = choice\n\n\tputs \"-------------------------------------------------\"\n\tprint \"\\nPLAYER 2, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\t\t#PLAYER 2 choses a valid selection of r,p,s\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_2_choice = choice\n\n\tputs lets_see_who_wins(player_1_choice, player_2_choice)\n\nend", "def play\n\n\t\tif ran_out_of_options?\n \t\t\tputs \"SORRY, YOU ARE HOPELESSLY INDECISIVE\".red.blink\n \t\t\texit\n \tend\n\n\t\t@winner = select_winner\n\n\t until self.set_of_ten_dup.length == 1 do\n\t \t@challenger = select_challenger\n\t \n\t system \"clear\"\n\n\t\tCLI.intro_image\n\t\tdisplay_choices\n\t\tinput = input_prompt\n\t \n\t\tmatch_arr = add_businesses\n\n\t\tadd_to_winner_loser_tables(match_arr[0],match_arr[1]) if input == '1' || input == '1!'\n\t\tadd_to_winner_loser_tables(match_arr[1],match_arr[0]) if input == '2' || input == '2!'\n\t\tremove_from_match_options(input)\n\t\t@winner = @challenger if input == '2' || input == '2!'\n\t\tself.url = @winner[:url]\n\t\tbreak if input == '1!' || input == '2!'\n\t end\n\t puts \"We recommend you go to \" + \"#{@winner[:name]}\".green + \"!\" \n end", "def play_game\n display_header\n user = collect_and_validate_input \"Choose a Play (R/P/S)\", :play\n computer = %w(R P S).sample\n \n # determine who won this round\n display_header\n string = case user\n when computer\n \"It's a TIE!!!\"\n when \"P\"\n computer == \"R\" ? \"Paper covers rock! YOU WIN!\" : \"Scissors cut paper! Computer Wins!\"\n when \"R\"\n computer == \"S\" ? \"Rock breaks scissors! YOU WIN!\" : \"Paper covers Rock! Computer Wins!\"\n when \"S\"\n computer == \"P\" ? \"Scissors cut paper! YOU WIN!\" : \"Rock breaks scissors! Computer Wins!\"\n end\n puts string\n \n # ask the user if they wish to play again\n again = (collect_and_validate_input \"Would you like to go again? (Y/N)\", :again).upcase\n again == \"Y\" ? play_game : (puts \"Thanks for playing!\")\nend", "def print_winning_message(winning_choice)\n case\n when 'Rock'\n say('Rock smashes scissors!')\n when 'Paper'\n say('Paper covers rock!')\n when 'Scissors'\n say('Scissors cuts paper!')\n end\nend", "def display_what_beats_what\n if human.choice == 'rock' && computer.choice == 'scissors' ||\n human.choice == 'scissors' && computer.choice == 'rock'\n puts 'Rock crushes scissors!'\n elsif human.choice == 'rock' && computer.choice == 'lizard' ||\n human.choice == 'lizard' && computer.choice == 'rock'\n puts 'Rock crushes lizard!'\n elsif human.choice == 'paper' && computer.choice == 'rock' ||\n human.choice == 'rock' && computer.choice == 'paper'\n puts 'Paper covers rock!'\n elsif human.choice == 'paper' && computer.choice == 'spock' ||\n human.choice == 'spock' && computer.choice == 'paper'\n puts 'Paper disproves Spock!'\n elsif human.choice == 'scissors' && computer.choice == 'paper' ||\n human.choice == 'paper' && computer.choice == 'scissors'\n puts 'Scissors cut paper!'\n elsif human.choice == 'scissors' && computer.choice == 'lizard' ||\n human.choice == 'sizard' && computer.choice == 'scissors'\n puts 'Scissors decapitates lizard!'\n elsif human.choice == 'lizard' && computer.choice == 'spock' ||\n human.choice == 'spock' && computer.choice == 'lizard'\n puts 'Lizard poisons Spock!'\n elsif human.choice == 'lizard' && computer.choice == 'paper' ||\n human.choice == 'paper' && computer.choice == 'lizard'\n puts 'Lizard eats paper!'\n elsif human.choice == 'spock' && computer.choice == 'rock' ||\n human.choice == 'rock' && computer.choice == 'spock'\n puts 'Spock vaporizes rock!'\n elsif human.choice == 'spock' && computer.choice == 'scissors' ||\n human.choice == 'scissors' && computer.choice == 'spock'\n puts 'Spock smashes scissors!'\n end\n end", "def game\n puts \"\\nTake your pick: (R)ock, (P)aper, (S)cissors\"\n sleep(1)\n puts \"\\nShoot!\"\n\n computer = \"rps\"[rand(3)].chr\n player = gets.chomp.downcase\n case [player, computer]\n when ['r','s'],['s','p'],['p','r']\n puts \"\\nWIN\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n when ['r','r'],['p','p'],['s','s']\n puts \"\\nTIE\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n when ['s','r'],['p', 's'],['r', 'p']\n puts \"\\nLOSER\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n else\n puts \"\\nARE YOU A MORON? CHOOSE R,P,S\"\n game\n end\nend", "def player_name\n puts \"What is your name?\"\n name = gets\n name_chomped = name.chomp.capitalize\n puts \"Hi #{name_chomped}! How are you doing today?\"\n response = gets.capitalize\n if response.include? \"not\"\n \tputs \"I am sorry, there's nothing I can do. Let's get on with the game.\"\n elsif response.include? \"Good\" or response.include? \"Great\" \n \tputs \"I am sure you are! But you won't be if you lose!\"\n else\n \tputs \"Okay! Good Luck with the game!\"\n end\n name_chomped\nend", "def play_to_n\n puts \"Prepare to battle your opponent!\\n\\nYour weapons: A rock, a piece of paper, and a pair of scissors.\\n\\nThe rock will crush the scissors, the paper will smother the rock, and the scissors will cut the paper to shreds. The first player to win the following number of games wins the battle. What number would you like to play to?: \"\n \n @num_of_games = gets.chomp.to_i\n until @num_of_games > 0 && @num_of_games.class == Fixnum\n puts \"Your answer was not recognized, please try again.\"\n @num_of_games = gets.chomp.to_i\n @num_of_games\n end\n \n # Public: #players_choose\n # Sets each player's move to a unique variable then prints what each player chose.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # Prints two sentences stating what move each player chose.\n #\n # State Changes:\n # Sets @p1_game_move and @p2_game_move.\n \n def players_choose\n @p1_game_move = @player1.p1_moves\n @p2_game_move = @player2.p2_moves\n puts \"#{@player1.name} chooses: #{@p1_game_move}\\n\" + \"#{@player2.name} chooses: #{@p2_game_move}\"\n end\n\n # Public: #determine_winner\n # Determines which player won based on each round's moves.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # Prints out tie, or if there was not a tie, which player won and what the score is.\n #\n # State Changes:\n # None.\n \n # def determine_winner\n # players_choose\n # if @p1_game_move == @p2_game_move\n # puts \"Tie!\"\n # format\n # elsif @p1_game_move == \"rock\" && @p2_game_move == \"scissors\" || @p1_game_move == \"paper\" && @p2_game_move == \"rock\" || @p1_game_move == \"scissors\" && @p2_game_move == \"paper\"\n # @player1.p1_win\n # puts \"#{@player1.name} wins!\\n\" \"The score is: #{@player1.name} - #{@player1.score}\\t #{@player2.name} - #{@player2.score}\"\n # format\n # else\n # @player2.p2_win\n # puts \"#{@player2.name} wins!\\n\" \"The score is: #{@player1.name} - #{@player1.score}\\t #{@player2.name} - #{@player2.score}\"\n # format\n # end\n # end\n\n # Public: #game_loop\n # Continues the game each round until a player has won the stated number of games.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # The determine_winner method\n #\n # State Changes:\n # None.\n \n def game_loop\n until @player1.score >= @num_of_games || @player2.score >= @num_of_games do\n #determine_winner\n @rules.determine_winner\n end\n end\n \n # Public: #play\n # Initiates the game loop and prints who the winner is once the game is over.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # A puts statement which states who the overall winner is.\n #\n # State Changes:\n # None.\n \n def play \n game_loop\n if @player1.score >= @num_of_games\n puts \"#{@player1.name} is the WINNER!\"\n elsif @player2.score >= @num_of_games\n puts \"#{@player2.name} is the WINNER!\"\n end\n end\n \n # Public: #format\n # Separates each round with a line of dashes.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # Sixty dashes.\n #\n # State Changes:\n # None.\n \n def format\n puts \"-\" * 60\n end\n\nend", "def display_winner\n puts \"You chose #{human.move}.\" ######## THIS BIT HERE.... WHAT IS HUMAN -- we instantiate a Player obj and assign to @human, and another to @computer\n puts \"The computer chose #{computer.move}.\"\n\n case human.move\n when 'rock'\n puts \"It's a tie!\" if computer.move == 'rock'\n puts \"You won!\" if computer.move == 'scissors'\n puts \"Computer won!\" if computer.move == 'paper'\n when 'paper'\n puts \"It's a tie!\" if computer.move == 'paper'\n puts \"You won!\" if computer.move == 'rock'\n puts \"Computer won!\" if computer.move == 'scissors'\n when 'scissors'\n puts \"It's a tie!\" if computer.move == 'scissors'\n puts \"You won!\" if computer.move == 'paper'\n puts \"Computer won!\" if computer.move == 'rock'\n end\n end", "def run_a_round\n # Sets player one's choice\n player_one_selection = select_player_choice(@player_one)\n # Sets player two's choice\n player_two_selection = select_player_choice(@player_two)\n # Determines winner with correct output string\n puts determine_winner(player_one_selection, player_two_selection)\n end", "def choose_game\n puts \"Please choose from the following options:\"\n puts \"1) Roulette\"\n puts \"2) Casino War\"\n puts \"3) Blackjack\"\n puts \"4) $1 Slots\"\n puts \"5) Show wallet balance\"\n puts \"6) Cash out and leave\"\n answer = gets.strip.to_i\n case answer\n when 1\n play_roulette\n when 2\n play_casino_war\n when 3\n play_blackjack\n when 4\n play_slots\n when 5\n @person_wallet.show_wallet\n choose_game\n when 6\n @person_wallet.final_wallet\n exit\n else\n puts \"That is not a valid choice. Please choose again.\\n\\n\"\n choose_game\n end\n end", "def play_game\n until win_game? == true do\n get_user_selection\n get_comp_selection\n play_round\n end #end of until\n\n #adding option to play best of out of 5\n puts \"You you like to play best out of 5? (enter \\\"yes\\\" or \\\"no\\\")\"\n user_answer = gets.chomp.downcase\n\n if user_answer == \"y\" || user_answer == \"yes\"\n until best_out_of_five? == true do\n get_user_selection\n get_comp_selection\n play_round\n end\n else\n puts \"Until next time, have a great day!!\"\n end\n\n end", "def paper_scissors_rock\n clear_screen\n draw_shovel_line\n\tputs \"\\n Play with the Sphinx's stomach to get out!\\n\"\n sleep(1)\n\tresult = rand(3).floor\n\task_user \"\\n What have you got?:\" , \" \\n\\n 1| for paper \\u{1F4C3}\\n 2| for scissors \\u{2702}\\n 3| for rock \\u{270A}\\n\\n\"\n\tsleep(0.5)\n puts \" \\u{1F449}\"\n choice = gets.chomp.to_i\n\n\tif choice == result\n\t\tsay \"\\nIt's a tie!\\n\"\n sleep(1.5)\n\t\tpaper_scissors_rock\n\telsif choice < result\n\t\tsay \"\\nSorry, you lost\\n Try again!\"\n sleep(1.5)\n\t\tpaper_scissors_rock\n\telsif choice > result\n\t\tputs \"\\n You won! Get out!!!!\\n\"\n sleep(1.5)\n draw_shovel_line\n sleep(1.5)\n\n\tend\nend", "def game_over\n puts \"#{@current_player[:name]} loses. The final score is: #{@player1[:name]}: #{@player1[:lives]} points to #{@player2[:name]}: #{@player2[:lives]} points. Better luck next time, #{@current_player[:name]}! Type 'play' to play again or 'exit' to quit.\".yellow\n input = gets.chomp\n case input\n when 'play'\n @player1[:lives]= 3\n @player2[:lives]= 3\n run \n else \n exit\n end\nend", "def menu\n puts \"Select An Option \\n1) Rock \\n2) paper \\n3) Scissors\"\n u = gets.strip.to_i\n c = rand(1..3)\n\n if u == c\n puts \"tie\"\n elsif u == 1 && c == 3 || u == 2 && c == 1 || u == 3 && c == 2\n puts \"You win!\"\n else\n puts \"You lose!\"\n end\nend", "def winner\n puts \"██╗ ██╗██╗███╗ ██╗███╗ ██╗███████╗██████╗ \"\n sleep(1)\n puts \"██║ ██║██║████╗ ██║████╗ ██║██╔════╝██╔══██╗\"\n sleep(1)\n puts \"██║ █╗ ██║██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝\"\n sleep(1)\n puts \"██║███╗██║██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗\"\n sleep(1)\n puts \"╚███╔███╔╝██║██║ ╚████║██║ ╚████║███████╗██║ ██║\"\n sleep(1)\n puts \" ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝\"\n sleep(1)\n puts \" \"\n sleep(1)\n restart_game\nend", "def player_decision(player, hand, hand_index, double, split)\n puts \"#{player.name}, your options for Hand #{hand_index+1}:\"\n puts \" H: Hit\"\n puts \" S: Stand\"\n puts \" D: Double Down\" if double\n puts \" P: Split the Pair\" if split\n puts \" T: Training Mode Recommendation\" if $Training_Mode\n puts \" C: Card Counting Mode Recommendation\" if $Counting_Mode\n puts \" #{shoe_count}\" if $Counting_Mode\n print \"Your choice? \"\n choice = gets.strip.downcase.take(1)\n linebreak\n\n if \"h\" == choice # Hit\n puts \"The dealer gives you a #{player.take(@shoe.hit, hand_index)}.\"\n !busted? hand\n elsif \"s\" == choice # Stand\n false\n elsif \"d\" == choice # Double Down\n player.wallet -= hand.bet\n hand.double_down\n puts \"The dealer gives you a #{player.take(@shoe.hit, hand_index)}.\"\n busted? hand\n false\n elsif \"p\" == choice # Split\n player.wallet -= hand.bet\n puts \"The dealer splits you into:\"\n player.split(hand_index, @shoe.hit, @shoe.hit)\n elsif \"t\" == choice && $Training_Mode # Training Hint\n puts training_recommendation(hand, double, split)\n linebreak\n player_decision(player, hand, hand_index, double, split)\n elsif \"c\" == choice && $Counting_Mode # Counting Hint\n puts counting_recommendation\n linebreak\n player_decision(player, hand, hand_index, double, split)\n else # Invalid\n puts \"Selection not recognized. Please try again.\"\n player_decision(player, hand, hand_index, double, split)\n end\n end", "def handle_betting\n puts \"Player #{@number}, See, fold, or raise?\"\n\n case (resp = gets.chomp)\n when /see/i\n :see\n when /fold/i\n :fold\n when /raise/i\n Integer(resp.split(' ')[1])\n else\n raise \"Unknown player response: #{resp}\"\n end\n end", "def show_winner\n human_winner = true\n for pl in 1..3 do\n if @players[pl].score > @players[0].score\n human_winner = false \n end \n end\n if human_winner\n a = Artii::Base.new\n puts a.asciify(\"Congrats!\").colorize(:red)\n space\n print_with_pause(\" You have beat the computers. \".colorize(:red))\n waits(3)\n else\n a = Artii::Base.new\n puts a.asciify(\"DEFEAT\").colorize(:red)\n space\n print_with_pause(\"You are no match for machines! Enjoy crying yourself to sleep tonight!\".colorize(:red))\n waits(3)\n end\n print_with_pause(\" Press Enter to go back to Main Menu\".colorize(:red))\n gets.chomp\n puts `clear`\n end", "def player_turn\r\n answer = nil\r\n puts \"#{player.name} has #{player.total_for_hand}\"\r\n loop do\r\n puts \"Do you want to hit or stay? (enter 'h' or 's') \"\r\n loop do\r\n answer = gets.chomp.downcase\r\n break if ['h', 's'].include? answer\r\n puts \"Please enter h or s\"\r\n end\r\n if answer == 's'\r\n player.show_hand\r\n break\r\n elsif answer == 'h'\r\n player.add_to_hand(deck)\r\n puts \"#{player.name} has #{player.total_for_hand}\"\r\n end\r\n break if player.busted?\r\n end\r\n end", "def determine_winner(player_one_selection, player_two_selection)\n if player_one_selection == player_two_selection\n outcome = \"\\nThis round was a tie. You both chose '#{player_one.move}'\"\n elsif player_one_selection == \"rock\" && player_two_selection == \"scissors\" ||\n player_one_selection == \"paper\" && player_two_selection == \"rock\" ||\n player_one_selection == \"scissors\" && player_two_selection == \"paper\"\n outcome = \"\\n#{player_one.name} won this round!\"\n @player_one.wins_round\n elsif player_two_selection == \"rock\" && player_one_selection == \"scissors\" ||\n player_two_selection == \"paper\" && player_one_selection == \"rock\" ||\n player_two_selection == \"scissors\" && player_one_selection == \"paper\"\n outcome = \"\\n#{player_two.name} won this round!\"\n @player_two.wins_round\n else\n puts \"\\nSomething strange happened here\"\n end\n outcome\n end", "def report_winner\n\t\tif reason = won_by?(:hunter)\n\t\t\tputs \"\\n\\nHunter (#{@hunter.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\[email protected](\"GAMEOVER #{current_round} WINNER HUNTER #{reason}\")\n\t\t\[email protected](\"GAMEOVER #{current_round} LOSER PREY #{reason}\")\n\t\t\[email protected]{|s| s.puts \"GAMEOVER #{current_round} WINNER HUNTER #{reason}\"}\n\t\t\treturn {:winner => @hunter.username, :role => \"Hunter\", :time => current_round, :reason => reason}\n\t\telsif reason = won_by?(:prey)\n\t\t\tputs \"\\n\\Prey (#{@prey.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\[email protected](\"GAMEOVER #{current_round} LOSER HUNTER #{reason}\")\n\t\t\[email protected](\"GAMEOVER #{current_round} WINNER PREY #{reason}\")\n\t\t\[email protected]{|s| s.puts \"GAMEOVER #{current_round} WINNER PREY #{reason}\"}\n\t\t\treturn {:winner => @prey.username, :role => \"Prey\", :time => current_round, :reason => reason}\n\t\tend\n\tend", "def game \n loop do\n puts \"r for rock\"\n puts \"s for scissors\"\n puts \"p for paper\\n\"\n print \"\\nEnter one of the above to play: \"\n\n computer = \"rsp\"[rand(3)].chr\n player = $stdin.gets.chomp.downcase\n\n case [player, computer]\n when ['p','r'], ['s','p'], ['r','s']\n \tputs \"\\n\\nYou Win!\"\n when ['r','r'], ['p','p'], ['s','s']\n \tputs \"\\n\\nYou tied!\"\n else puts \"\\n\\nYou LOSE!\"\n end\n\n puts \"The computer choose: #{computer}\"\n\n puts \"Type 'yes' to continue playing.\"\n\n input = $stdin.gets.chomp.downcase \n break unless input == \"yes\"\n # use following condition if you want to enable the user to press <Enter> to conitnue\n # break unless input == \"/n\"\nend\nend", "def play()\n \n begin\n \n @computer_choice = get_computer_choice()\n @player_choice = get_player_choice()\n \n result = logic(@computer_choice, @player_choice)\n\n get_choices()\n \n case result\n\n when \"tie\"\n @rounds -= 1\n @ties += 1\n puts \"[~] it's a tie !\"\n \n when \"player win\"\n @rounds -= 1\n @player_wins += 1\n puts \"[$] Player win this round (#{@player_wins}/3)!\"\n\n when \"computer win\"\n @rounds -= 1\n @computer_wins += 1\n puts \"[$] Computer win this round (#{@computer_wins}/3)!\"\n\n end\n\n rescue Interrupt\n\n puts \"\\n\\n[!] Keyboard interrupt, Exting.\"; exit()\n \n \n end\n \n\n end", "def run_game\n bet()\n starting_hands()\n user_input = ''\n while user_input != \"s\" && user_input != \"stand\"\n show_hands()\n if hand_value(@player_hand) == 21\n puts \"\\BLACKJACK! YOU WIN!\"\n @user[:balance] += (@wager * 1.5)\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n return\n end\n puts \"\\nWould you like to (H)it or (S)tand?\"\n user_input = gets.chomp.downcase\n if user_input == 'h' || user_input == 'hit'\n hit(@player_hand)\n if hand_value(@player_hand) > 21\n puts \"BUST! Sorry, you LOSE\"\n @user[:balance] -= @wager\n puts \"\\Your new balance is $#{@user[:balance]}\"\n return\n end\n elsif user_input == 'S' || user_input == 'stand'\n puts \"\\Good Luck!\"\n else\n puts \"\\Invalid input, try again\"\n end\n end \n dealer_decision()\n calculate_conditions() \n end", "def play\n #keep running this loop till game over. could also do while both lives > 0 instead of definding game over\n until game_over do\n \n next_round\n \n # setting current player\n current_player = @players[0]\n \n # player is asked question via chomps\n new_question = Question.new\n puts \"#{current_player.name}: What does #{new_question.num_1} plus #{new_question.num_2} equal?\"\n answer = $stdin.gets.chomp.to_i\n if answer == new_question.answer\n puts \"#{current_player.name}: YES! You are correct.\"\n else \n puts \"#{current_player.name}: Seriously? No!\"\n current_player.hp_loss\n end\n \n # show game status\n current_hp\n\n #could add sleep (sleep 1) to add wait time between rounds\n\n end\n # show winner once above until loop is done\n display_winner\n\n end", "def player_turns\n show_hands_initial\n response = \"\"\n until (response == \"s\") or (player.bust == true) or (player.hand_total == 21)\n puts \"Would you like to hit or stay (h/s)\"\n response = get_console_char\n if response == \"h\"\n self.hit(player)\n show_hands_initial\n elsif response == \"s\"\n puts \"Good move!\"\n else\n puts \"You provided '#{response}'. Please provide 'h' or 's'.\"\n player_turns\n end\n hand_check(player)\n end\n dealer_turns\n end", "def winner\n if (win?(player) == true) && (win?(dealer) == false)\n show_hands_final\n puts \"#{player.name} wins!!!\\n\" ;player.score += 1\n elsif (win?(dealer) == true) && (win?(player) == false)\n show_hands_final\n puts \"#{dealer.name} wins!!!\\n\" ;dealer.score += 1\n elsif (win?(player) == \"Bust\") || (win?(dealer) == \"Bust\")\n show_hands_final\n puts \"#{player.name} and #{dealer.name} busted. It's a tie!\\n\"\n elsif win?(player) == \"Tie\"\n show_hands_final\n if player.hand_count > dealer.hand_count\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\n#{player.name} wins with #{player.hand.length} cards!!!\"\n player.score += 1\n elsif dealer.hand_count > player.hand_count\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\nDealer wins with #{dealer.hand.length} cards!!!\"\n dealer.score += 1\n else\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\n#{player.name} wins since both players have #{player.hand.length} cards!!!\\n\"\n player.score += 1\n end\n end\n again?\n end", "def won\n divider\n if @input == @comp\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦┌┬┐┌─┐ ┌─┐ ┌┬┐┬┌─┐ \n ║ │ └─┐ ├─┤ │ │├┤ \n ╩ ┴ └─┘ ┴ ┴ ┴ ┴└─┘o\"\n divider2\n puts \"Current Score: [User] #{@u_score} *** [Computer] #{@c_score}\" \n play_again\n elsif @input == \"rock\" && @comp == \"scissors\" || @input == \"paper\" && @comp == \"rock\" || @input == \"scissors\" && @comp == \"paper\"\n @u_score += 1\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦ ╦┌─┐┬ ┬ ┬ ┬┬┌┐┌┬\n ╚╦╝│ ││ │ ││││││││\n ╩ └─┘└─┘ └┴┘┴┘└┘o\"\n divider2\n puts \"Current Score: [User] #{@u_score} *** [Computer] #{@c_score}\"\n play_again\n elsif \n @c_score += 1\n @input == \"rock\" && @comp == \"paper\" || @input == \"paper\" && @comp == \"scissors\" || @input == \"scissors\" && @comp == \"rock\"\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦ ╦╔═╗╦ ╦ ╦ ╔═╗╔═╗╔═╗┬┬┬\n ╚╦╝║ ║║ ║ ║ ║ ║╚═╗║╣ │││\n ╩ ╚═╝╚═╝ ╩═╝╚═╝╚═╝╚═╝ooo\"\n divider2\n puts \"Current Score: [User] #{@u_score} /// [Computer] #{@c_score}\"\n play_again\n else\n puts \"You dun fucked up, I'm not even telling you the score because I don't even know how you got here bro\"\n play_again\n end\n end", "def player_turn(player_cards, dealer_cards, deck)\n answer = nil\n puts \"\\nYou have #{cards_string(player_cards)}.\\n\\\ntotal: #{hand_value(player_cards)}\"\n loop do\n puts \"\\nHit, Stay or Odds?\\n\\\n('h': hit, 's': stay, 'o': odds of win/tie/lose):\"\n answer = gets.chomp\n if answer.downcase.start_with? 'h'\n hit(player_cards, deck)\n puts \"You have: #{cards_string(player_cards)}.\\n\\\ntotal: #{hand_value(player_cards)}\"\n elsif answer.downcase.start_with? 'o'\n display_odds(player_cards, dealer_cards)\n end\n break if answer.downcase.start_with?('s') || busted?(player_cards)\n end\n puts \"You chose to stay!\" if answer.downcase.start_with? 's'\n puts \"You busted!\" if busted?(player_cards)\nend", "def run\n choose_game(prompt)\nend", "def playRound(score)\n\tputs \"Player 1 enter your weapon: \"\n\tp1 = gets.chomp.downcase\n\tputs \"Player 2 enter your weapon: \"\n\tp2 = gets.chomp.downcase\n\tresult = determineWinner(p1, p2)\n\tupdateScore(score,result)\nend", "def determineWinner\n if @botChoice == @playerChoice\n puts \"It's a tie! Redo round:\"\n elsif (@playerChoice == \"paper\" and @botChoice == \"rock\") or \\\n (@playerChoice == \"scissors\" and @botChoice == \"paper\") or \\\n (@playerChoice == \"rock\" and @botChoice == \"scissors\")\n @roundsWon += 1\n @roundsLeft -= 1\n puts \"You won this round! Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n else\n @roundsLost += 1\n @roundsLeft -= 1\n puts \"You lost this round... Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n end\n end", "def winning_message(player)\n case player\n when 'Paper'\n puts \"Paper wraps rock\"\n when 'Rock'\n puts \"Rock breaks scissors\"\n when 'Scissors'\n puts \"Scissors cuts paper\"\n end\nend", "def select_the_player_role\n output = nil\n # input validation\n until %w[maker breaker].include?(output)\n puts 'Do you want to be a [maker] or a [breaker]?'\n output = gets.chomp\n end\n output\n end", "def determine_winner(player_choice, computer_choice)\n # initialise a hash to extract long forms (Rock for r etc.)\n choices_hash = {\"r\" => \"rock\", \"p\" => \"paper\", \"s\" => \"scissors\"}\n player_choice_extended = choices_hash[player_choice]\n computer_choice_extended = choices_hash[computer_choice]\n puts \"Player chose #{player_choice_extended}\"\n puts \"Computer chose #{computer_choice_extended}\"\n case\n when player_choice == \"r\" && computer_choice == \"s\"\n puts \"Rock smashes scissors. Player wins.\"\n when player_choice == \"r\" && computer_choice == \"p\"\n puts \"Paper covers Rock. Computer wins.\"\n when player_choice == \"p\" && computer_choice == \"s\"\n puts \"Scissors cut paper. Computer wins.\"\n when player_choice == \"p\" && computer_choice == \"r\"\n puts \"Paper covers rock. Player wins.\"\n when player_choice == \"s\" && computer_choice == \"p\"\n puts \"Scissors cut paper. Player wins.\"\n when player_choice == \"s\" && computer_choice == \"r\"\n puts \"Rock smashes scissors. Computer wins.\"\n else\n puts \"Same choice. Tie!\"\n end\nend", "def play\n until over? == true\n turn\n end\n if self.winner == nil\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{self.winner}!\"\n #Congradulate the winner of the game, using the person with the most X or O combinations\n #Code in a play again option, so players don't have to re enter name\n board.display\n end\n end", "def win_game\n clear_message_box\n @ui.place_text('THY QUEST IS OVER!'.center(20),1,2)\n (0..36).each do |i|\n hero_direction = POS_TURN.rotate!(i <=> 16)[0]\n @ui.place_text(DungeonOfDoom::CHAR_PLAYER[hero_direction], @cur_x+2, @cur_y+6, DungeonOfDoom::C_WHITE_ON_RED)\n sleep 0.1\n @ui.refresh\n end\n ask_question(\"THY SCORE=#{((@treasure*10)+(@gold_count*@stats[:experience])+@stats[:strength]+\n @stats[:vitality]+@stats[:agility]).round}\",MSG_KEY)\n end", "def win_lose\n if @word_blank == @split_word.join\n puts \"\\nGood job #{@player}, you guessed #{@computer}\\'s word! Would you like to play again?(Yes/No)\\n\"\n rematch = gets.chomp.downcase\n \n elsif @mistakes == 7\n puts \"\\nSorry, #{@player} #{@computer}\\'s word was #{@chosen_word}. Would you like to play again?(Yes/No)\"\n rematch = gets.chomp.downcase\n end\n \n if rematch == \"yes\"\n \n new_game = Hangman.new(\"#{@player}\")\n new_game.chosen_word\n new_game.run\n \n elsif rematch == 'no'\n puts \"\\nThank you for playing!\"\n exit\n end\nend", "def menu_choice\n puts \"Votre réponse :\"\n print \">\"\n user_answer = gets.chomp\n\n if(user_answer == \"a\")\n then @human_player.search_weapon\n end\n if(user_answer == \"s\")\n then @human_player.search_health_pack\n end\n if(user_answer == 0.to_s)\n then @human_player.attacks(@player1)\n end\n if(user_answer == 1.to_s)\n then @human_player.attacks(@player2)\n end\n if(user_answer == 2.to_s)\n then @human_player.attacks(@player3)\n end\n if(user_answer == 3.to_s)\n then @human_player.attacks(@player4)\n end\n kill_player\n end", "def gameLogic(option)\n newOption = option.downcase \n playersChoice = newOption[0]\n computer = self.random\n \n p \"Computer Chose: #{computer}\"\n if playersChoice == computer[0]\n return 'tie'\n elsif playersChoice == 'r' && computer[0] == 'p'\n return false \n elsif playersChoice =='s' && computer[0] = 'r'\n return false\n elsif playersChoice == 'p' && computer[0] == 's'\n return false\n else\n return true\n end\n end", "def display_results(player, computer)\n if win?(player, computer)\n prompt 'You won!'\n elsif win?(computer, player)\n prompt 'You lost!'\n else\n prompt \"It's a tie!\"\n end\nend", "def winner\n\tputs \" - WoooW #{@name} !!!! Tu m'impressionne, Tu as gagne !!! \"\n\tputs \" \"\n end", "def choose_weapons\n puts \"Choose 'r' for rock, 'p' for paper or 's' for scissors\"\n return gets.chomp.downcase\n end", "def choose_winner; end", "def afterStory(username)\n\nputs \"\n\nWould you like to hear another story?\"\n\nplayagainyesorno = gets.chomp.downcase\n\n case playagainyesorno\n when 'yes', 'yes please', 'yup'\n puts \"Great!\"\n puts \"Your choices are: Rom-Com, Cop Story, or Sci-Fi.\"\n choosestory(username)\n when 'no', 'nope', 'no way'\n puts \"\nOkay, goodbye!\"\n else\n puts \"I don't know what you said! \"\n afterStory(username)\n end\nend", "def play\n # print \"\\n Welcome to the game of Scissors-Paper-Rock\"\n print \"\\n Enter your name: \"\n user_name = gets.chomp\n until @user_score == @score_required || @computer_score == @score_required\n options = ['scissors', 'paper', 'rock']\n \n print \"\\nHi #{user_name}, please select 's' for scissors, 'p' for paper or 'r' for rock. \"\n \n # Display user selection:\n selected_options = gets.chomp\n \n puts \"User has selected #{user_choice}.\"\n # p user_choice\n\n # display the computer's randomised selection:\n # options = ['s', 'p', 'r']\n @computer_choice = options.sample\n # p computer_choice\n puts \"Computer has selected #{computer_choice}.\"\n\n result()\n end\n \n return @user_score > @computer_score ? (puts \"Game over! you won!\"): (puts \"Game over! Computer won!\")\n \n end", "def win(pick_w)\n case pick_w \n when 'r' \n puts \"You: Rock | Me: Scissors\"\n when 'p'\n puts \"you: Paper | Me: Rock\"\n when 's'\n puts \"you: Scissors | Me: Paper\"\n end\nend", "def determineWinner(p1_weapon, p2_weapon)\n\tif p1_weapon == \"rock\"\n\t\tif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"paper\"\n\t\tif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"scissors\"\n\t\tif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telse\n\t\ttext = \"Please enter rock, paper, or scissors!\"\n\tend\n\tputs text\n\treturn text\nend", "def determine_winner(playerHand, dealerHand)\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Show the value of the player and dealer's hands\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n write_log_file(\"Player's hand: \" + playerHand.to_s)\r\n write_log_file(\"Dealer's hand: \" + dealerHand.to_s)\r\n\r\n if playerHand > 21 then #See if the player has gone bust\r\n puts \"You have gone bust!\\n\\n\"\r\n write_log_file(\"The Player has gone bust.\")\r\n print \"Press Enter to continue.\"\r\n else #See if the player and dealer have tied\r\n if playerHand == dealerHand then\r\n puts \"Tie!\\n\\n\"\r\n write_log_file(\"Tie!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n #Dee if the dealer has gone bust\r\n if dealerHand > 21 then\r\n puts \"The Dealer has gone bust!\\n\\n\"\r\n write_log_file(\"The Dealer has gone bust.\")\r\n print \"Press Enter to continue.\"\r\n else\r\n #See if the player's hand beats the dealer's hand\r\n if playerHand > dealerHand then\r\n puts \"You have won!\\n\\n\"\r\n write_log_file(\"The Player has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n #See if the dealer's hand beats the player's hand\r\n if playerHand < dealerHand then\r\n puts \"The Dealer has won!\\n\\n\"\r\n write_log_file(\"The Dealer has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n end\r\n end\r\n\r\n write_log_file(\"-\" * 50)\r\n Console_Screen.pause #Pause the game\r\n\r\n end", "def win_game_choice\nputs \"You win. Very impressive.\"\n # case win_game_menu()\n # when \"Stats\"\n # stats_menu_choice_endgame()\n # when \"Exit\"\n exit!\n # end\n\nend", "def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end", "def display_win_message(winning_choice)\n case winning_choice\n when 'p'\n puts \"Paper covers Rock!\"\n when 'r'\n puts \"Rock smashes Scissors\"\n when 's'\n puts \"Scissors cuts Paper!\"\n end\nend", "def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end", "def rps_game\n puts \"Player 1 enter rock, paper, or scissors: \"\n player1 = gets.chomp\n puts \"Player 2 enter rock, paper, or scissors: \"\n player2 = gets.chomp\n if player1 != \"rock\" || player1 != \"paper\" || player1 != \"scissors\"\n puts \"Player 1 MUST enter rock, paper, or scissors! \"\n elsif player2 != \"rock\" || player2 != \"paper\" || player2 != \"scissors\"\n puts \"Player 2 MUST enter rock, paper, or scissors! \"\n elsif player1 == \"rock\" && player2 == \"paper\"\n puts \"Player 2 wins\"\n elsif player1 == \"rock\" && player2 == \"scissors\"\n puts \"Player 1 wins\"\n elsif player2 == \"rock\" && player1 == \"paper\"\n puts \"Player 1 wins\"\n elsif player2 == \"rock\" && player1 == \"scissors\"\n puts \"Player 2 wins\"\n elsif player1 == \"paper\" && player2 == \"scissors\"\n puts \"Player 2 wins\"\n elsif player1 == \"paper\" && player2 == \"rock\"\n puts \"Player 2 wins\"\n else\n puts \"Its a tie!\"\n end\nend", "def play_game\n\t#user_choose_rps \n\tcomp_choice = comp_choose_rps #<-- no need to use this because it's used once \n\tuser_choice = user_choose_rps \n\tputs \"The computer chose #{comp_choice}. You chose #{user_choice}.\" \n\tputs get_winner(comp_choice, user_choice) \n\treplay \nend", "def win_or_lose\n if game_data.guesses_remaining.zero?\n puts File.read('./views/you_dead')\n puts File.read('./views/dead')\n elsif game_data.letters_left_to_guess == []\n puts File.read('./views/winscreen')\n else\n # allows us to break recursion if we are testing\n @test_cond == false ? Turn.new(game_data) : true\n end\n end", "def play\n # playing the first hand\n players.each { |player| ask_for_user_input(player, \"play_first_hand\") }\n self.to_s\n puts \" the winner of the first hand #{first_hand_winner.nickname}\"\n\n #playing the second hand\n ask_for_user_input(first_hand_winner, \"play_second_hand\")\n ask_for_user_input(other_player(first_hand_winner), \"play_second_hand\")\n\n self.to_s\n puts \" the winner of the second hand #{second_hand_winner.nickname}\"\n return if player_won_first_two_hands?\n\n #playing the third hand\n ask_for_user_input(second_hand_winner, \"play_third_hand\")\n ask_for_user_input(other_player(second_hand_winner), \"play_third_hand\")\n\n self.to_s\n end", "def play_game\n\n\t\t# ask who would like to go first, user or computer\n\t\tputs \"Would you like to go first? Y/N\"\n\t\tstarter = gets.chomp.upcase\n\n\t\t# case when user takes first go\n\t\tif starter == \"Y\"\n\t\t\twhile total(current_score) > 0\n\t\t\t\tplayer_turn\n\t\t\t\t\n\t\t\t\t# case when player wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"You win!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\n\t\t\t\tcomputer_turn\n\n\t\t\t\t# case when computer wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"The computer wins!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\t\t\tend\n\t\t\n\t\t# case when computer takes first go\n\t\telse\n\t\t\twhile total(current_score) > 0\n\t\t\t\tcomputer_turn\n\n\t\t\t\t# case when player wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"The computer wins!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\n\t\t\t\tplayer_turn\n\t\t\t\t\n\t\t\t\t# case when computer wins\n\t\t\t\tif total(current_score) == 0\n\t\t\t\t\tputs \"You win!\"\n\t\t\t\t\tplay_again\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def result\n if victory? == @player1 || victory? == @player2\n puts \"Congratulations #{victory?.name}, you won!\"\n puts \" \"\n puts '╭━━━┳━╮╱╭┳━━━╮╭━━━┳━━━╮╭━━━┳━━━┳━╮╭━┳━━━╮\n ┃╭━━┫┃╰╮┃┣╮╭╮┃┃╭━╮┃╭━━╯┃╭━╮┃╭━╮┃┃╰╯┃┃╭━━╯\n ┃╰━━┫╭╮╰╯┃┃┃┃┃┃┃╱┃┃╰━━╮┃┃╱╰┫┃╱┃┃╭╮╭╮┃╰━━╮\n ┃╭━━┫┃╰╮┃┃┃┃┃┃┃┃╱┃┃╭━━╯┃┃╭━┫╰━╯┃┃┃┃┃┃╭━━╯\n ┃╰━━┫┃╱┃┃┣╯╰╯┃┃╰━╯┃┃╱╱╱┃╰┻━┃╭━╮┃┃┃┃┃┃╰━━╮\n ╰━━━┻╯╱╰━┻━━━╯╰━━━┻╯╱╱╱╰━━━┻╯╱╰┻╯╰╯╰┻━━━╯\n ╭━━━┳╮╱╱╭━━━┳╮╱╱╭╮╭━━━┳━━━┳━━━┳━━┳━╮╱╭┳━━━╮\n ┃╭━╮┃┃╱╱┃╭━╮┃╰╮╭╯┃┃╭━╮┃╭━╮┃╭━╮┣┫┣┫┃╰╮┃┃╭━╮┃\n ┃╰━╯┃┃╱╱┃┃╱┃┣╮╰╯╭╯┃┃╱┃┃┃╱╰┫┃╱┃┃┃┃┃╭╮╰╯┣╯╭╯┃\n ┃╭━━┫┃╱╭┫╰━╯┃╰╮╭╯╱┃╰━╯┃┃╭━┫╰━╯┃┃┃┃┃╰╮┃┃╱┃╭╯\n ┃┃╱╱┃╰━╯┃╭━╮┃╱┃┃╱╱┃╭━╮┃╰┻━┃╭━╮┣┫┣┫┃╱┃┃┃╱╭╮\n ╰╯╱╱╰━━━┻╯╱╰╯╱╰╯╱╱╰╯╱╰┻━━━┻╯╱╰┻━━┻╯╱╰━╯╱╰╯'\n else\n puts \"Too bad! Tied game...\"\n puts \" \"\n puts '╭━━━┳━╮╱╭┳━━━╮╭━━━┳━━━╮╭━━━┳━━━┳━╮╭━┳━━━╮\n ┃╭━━┫┃╰╮┃┣╮╭╮┃┃╭━╮┃╭━━╯┃╭━╮┃╭━╮┃┃╰╯┃┃╭━━╯\n ┃╰━━┫╭╮╰╯┃┃┃┃┃┃┃╱┃┃╰━━╮┃┃╱╰┫┃╱┃┃╭╮╭╮┃╰━━╮\n ┃╭━━┫┃╰╮┃┃┃┃┃┃┃┃╱┃┃╭━━╯┃┃╭━┫╰━╯┃┃┃┃┃┃╭━━╯\n ┃╰━━┫┃╱┃┃┣╯╰╯┃┃╰━╯┃┃╱╱╱┃╰┻━┃╭━╮┃┃┃┃┃┃╰━━╮\n ╰━━━┻╯╱╰━┻━━━╯╰━━━┻╯╱╱╱╰━━━┻╯╱╰┻╯╰╯╰┻━━━╯\n ╭━━━┳╮╱╱╭━━━┳╮╱╱╭╮╭━━━┳━━━┳━━━┳━━┳━╮╱╭┳━━━╮\n ┃╭━╮┃┃╱╱┃╭━╮┃╰╮╭╯┃┃╭━╮┃╭━╮┃╭━╮┣┫┣┫┃╰╮┃┃╭━╮┃\n ┃╰━╯┃┃╱╱┃┃╱┃┣╮╰╯╭╯┃┃╱┃┃┃╱╰┫┃╱┃┃┃┃┃╭╮╰╯┣╯╭╯┃\n ┃╭━━┫┃╱╭┫╰━╯┃╰╮╭╯╱┃╰━╯┃┃╭━┫╰━╯┃┃┃┃┃╰╮┃┃╱┃╭╯\n ┃┃╱╱┃╰━╯┃╭━╮┃╱┃┃╱╱┃╭━╮┃╰┻━┃╭━╮┣┫┣┫┃╱┃┃┃╱╭╮\n ╰╯╱╱╰━━━┻╯╱╰╯╱╰╯╱╱╰╯╱╰┻━━━┻╯╱╰┻━━┻╯╱╰━╯╱╰╯'\n end\n end", "def check_who_win(user_input, computer_input)\n if user_input == computer_input\n 'Haha! It is draw! You can try again!'\n elsif user_input == 'R'\n if computer_input == 'S'\n 'Wow! Rock smashes Scissors! You Win!'\n elsif computer_input == 'P'\n 'Oh! Paper covers Rock! You Lose!'\n end\n elsif user_input == 'P'\n if computer_input == 'R'\n 'Wow! Paper covers Rock! You Win!'\n elsif computer_input == 'S'\n 'Oh! scissors cuts Paper! You Lose!'\n end\n elsif user_input == 'S'\n if computer_input == 'P'\n 'Wow! Scissors cuts Paper! You Win!'\n elsif computer_input == 'R'\n 'Oh! Rock smashes Scissors! You Lose!'\n end\n end\nend", "def get_user_selection\n guess_again = true\n until guess_again == false\n puts \"Please choose rock, paper, or scissors (or q to quit)\"\n @user_current_throw = gets.chomp\n case @user_current_throw.downcase\n when \"q\"\n puts \"Thanks for playing!\"\n exit\n when \"rock\"\n @user_current_throw = @rock\n guess_again = false\n when \"scissors\"\n @user_current_throw = @scissors\n guess_again = false\n when \"paper\"\n @user_current_throw = @paper\n guess_again = false\n else\n puts \"That is not a valid entry\"\n guess_again = true\n end\n end #end of until\n end", "def introduction\n system 'clear'\n prompt(\"Each match is 5 rounds. First to 5 wins!\")\n prompt(\"Who is going first? Player or Computer? (p or c)\")\nend", "def players_home\n @prompt = TTY::Prompt.new\n clear_terminal\n choice = @prompt.select(\"Tell me, #{@user.name} what player are you looking for today?\\n\",\n [\"Players resume\",\"Top 10 scorers of the league\",\"Top 10 goalkeepers\", \"Top 10 defenders\", \"Top 10 dangerous players\"],\"-> Back\",\"-> Quit\",\"-> Restart\" )\n divider\n case choice\n when \"Players resume\"\n player_info\n when \"Top 10 scorers of the league\"\n table_top_10_Goal_scores\n when \"Top 10 goalkeepers\" \n table_top_10_GoalKeepers\n when \"Top 10 defenders\"\n table_top_10_Defenders\n when \"Top 10 dangerous players\"\n table_top_danger\n when \"-> Back\"\n home\n when \"-> Quit\" || \"QUIT\"\n when \"-> Restart\" || \"RESTART\"\n run\n else\n error\n end\n end", "def play\r\n turn until over?\r\n \r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n \r\n else\r\n puts \"Cat's Game!\"\r\n end\r\nend", "def play_round\n puts \"Your throw: #{@user_current_throw}\"\n puts \"Computers throw: #{@comp_current_throw}\"\n case @user_current_throw\n when @rock\n if @comp_current_throw == @rock\n puts \"Tie! play again\"\n elsif @comp_current_throw == @scissors\n @user_score += 1\n puts \"You win this round!\"\n elsif @comp_current_throw == @paper\n @comp_score += 1\n puts \"Computer wins this round\"\n end\n when @paper\n if @comp_current_throw == @paper\n puts \"Tie! play again\"\n elsif @comp_current_throw == @rock\n @user_score += 1\n puts \"You win this round!\"\n elsif @comp_current_throw == @scissors\n @comp_score += 1\n puts \"Computer wins round\"\n end\n when @scissors\n if @comp_current_throw == @scissors\n puts \"Tie! play again\"\n elsif @comp_current_throw == @paper\n @user_score += 1\n puts \"You win this round!\"\n else\n puts \"Computer wins round\"\n @comp_score += 1\n end\n end #end of case/when\n puts \"Current scores: You: #{@user_score} Computer: #{@comp_score}\"\n end", "def main_game\n p1_wins = 0\n p2_wins = 0\n puts \"Let's play Rock-Paper-Scissors!\"\n games = how_many_games\n best_of(games)\n\n until p1_wins == games || p2_wins == games\n winner = one_round\n display_winner(winner)\n p1_wins += track_p1_wins(winner)\n p2_wins += track_p2_wins(winner)\n end\n\n overall_winner = overall_winner?(p1_wins, p2_wins)\n display_overall_winner(overall_winner)\nend", "def winner(user, computer)\r\n winner = \"\"\r\n if (user == 'p' && computer == 'r')||\r\n (user == 's' && computer == 'p') ||\r\n (user == 'r' && computer == 's')\r\n winner = \"You\"\r\n elsif (computer == 'p' && user == 'r')||\r\n (computer == 's' && user == 'p') ||\r\n (computer == 'r' && user == 's')\r\n winner = \"Computer\"\r\n else\r\n winner = \"tie\"\r\n end\r\n \r\n if winner == \"tie\"\r\n puts \"It's a tie!\"\r\n else\r\n puts \"#{winner} won!\"\r\n end\r\nend", "def game\n puts \"Time to play rock, paper, scissors, lizard, spock!\"\n puts \"Choose your move!\"\n get_input\n puts \"play again? (y)es (n)o\"\n choice = gets.chomp.strip.downcase\n exit unless choice.include?(\"y\")\n game\nend", "def play\n puts \"Please enter '1' for one player or '2' for two\"\n choice = gets.strip\n if choice == \"2\"\n until over?\n if current_player == \"X\"\n puts \"It's X's turn\"\n elsif current_player == \"O\"\n puts \"It's O's turn\"\n end\n turn\n end\n \n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"It's a draw!\"\n end\n\n elsif choice == \"1\"\n until over?\n puts \"Now it's my turn...\"\n comp_turn\n break if won? || draw?\n puts \"Now it's your turn...\"\n turn\n end\n \n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"It's a draw!\"\n end\n end\n end", "def choosestory(username)\n\nstorychoice = gets.chomp.downcase\n\n case storychoice\n when 'cop story', 'cop story', 'cop', 'cop'\n puts \"\nYou have chosen Cop Story.\"\n copstory(username)\n when 'rom com', 'rom-com', 'romance', 'rom', 'romcom'\n puts \"\n\nYou have chosen Rom-Com.\"\n romcom(username)\n when 'sci fi', 'sci-fi', 'sci', 'science fiction'\n puts \"\n\nYou have chosen Sci-Fi.\"\n scifi(username)\n else\n puts \"Sorry, I don't understand!\n \nWould you like to hear a Rom-Com, Cop Story, or Sci-Fi?\"\n choosestory(username)\n end\nend", "def display_winner_one_game(r)\n if r == 1\n puts \"#{@player_1_name} wins\"\n elsif r == 2\n puts \"#{@player_2_name} wins\"\n else\n puts \"Tie\"\n end\n end", "def kill\n puts \"When #{@name} is turned the other way, you grab a rock and bash its skull in.\n The dark blood drips down and pools on the ground below it. It isn't quite dead,\n but rather fatally injured. It turns at you to look forlornly, a look of betrayal\n plain on its face. Do you choose to \\'nurture\\' it back to help or \\'smash\\' again\n with the rock?\"\n choice = gets.chomp\n run = true\n while run\n if choice == 'nurture'\n puts \"You attempt to nurture #{@name} back to health but it never trusts you again\n and kills you in your sleep shortly thereafter.\"\n exit\n elsif choice == 'kill' || choice == 'smash'\n puts \"You fly into a frenzy and desecrate the remains of #{@name}, bringing\n dishonor to your family and placing a curse of bad luck on your posterity\n for the next 10 generations.\"\n exit\n else\n puts \"nurture or smash?\"\n choice = gets.chomp\n end\n end\n end", "def villain_battle_sequence(hero, villain)\n Battle.start_a_battle(hero, villain)\n battle = Battle.all.last\n hero_hp = hero.hp\n villain_hp = villain.hp\n while villain.hp > 0 && hero.hp > 0 do\n attack(hero, villain)\n line\n puts \"The hero's health is #{hero.hp}\"\n puts \"The villain's health is #{villain.hp}\"\n end\n #if villain and hero looses battle, hero dies and villain gets sent to insane asylum\n if villain.hp <= 0 && hero.hp <= 0\n battle.villain_lost(villain)\n line\n puts \"'Today, we lost a great hero. #{hero.name}, or as many of you knew them as #{hero.alter_ego}, was one of the best of us. It is a sad day for #{battle.location}'\"\n battle.hero_lost(hero)\n battle.update(hero_win: false)\n villain.update(hp: villain_hp)\n line\n puts \"'Darn foiled again, but you'll never end me!' said #{villain.name} as they were lead to the asylum.\"\n puts \"GAME OVER\"\n line\n elsif villain.hp <=0 \n battle.villain_lost(villain)\n battle.update(hero_win: true)\n hero.update(hp: hero_hp)\n villain.update(hp: villain_hp)\n line\n puts \"#{hero.alter_ego} has won the battle\"\n puts \"'Darn foiled again, but you'll never end me!' said #{villain.name} as they were lead to the asylum.\"\n puts \"GAME OVER\"\n line\n #destroys the hero, the hero lost and died, sends villain to the main menu\n elsif hero.hp <= 0\n line\n puts \"#{villain.alter_ego} has won the battle\"\n puts \"'Today, we lost a great hero. #{hero.name}, or as many of you knew them as #{hero.alter_ego}, was one of the best of us. It is a sad day for #{battle.location}'\"\n line\n battle.hero_lost(hero)\n battle.update(hero_win: false)\n villain.update(hp: villain_hp)\n battle.destruction\n villain_main_menu(villain)\n end\n end", "def play\n if player1_score < 21\n puts \"Would you like to Hit or Stay..\"\n userinput = gets.chomp.downcase\n until userinput != \"hit\" || player1_score >= 21\n player_hit\n if player1_score == 21\n puts \"Blackjack!! You win!!\"\n player_win\n play_again\n elsif player1_score > 21\n dealer_win\n puts \"Your total was #{player1_score}\"\n puts \"You Busted..sad face..\"\n play_again\n elsif player1_score < 21\n puts \"Your new total is #{player1_score}.\"\n play\n elsif player_hand == 6 && player1_score < 21\n puts \"Somehow you achieved this, I'll let you have this win..\"\n player_win\n play_again\n else\n wrong\n end\n wrong\n end\n if userinput == \"stay\"\n stay\n end\n wrong\n end\n end", "def display_score(player_wins, computer_wins) # keeps track of number of wins for each side\n puts \"================================================\"\n if player_wins == MAXIMUM_WINS\n prompt(\"Congratulations, Player collected #{MAXIMUM_WINS} wins. Player won the entire game!\")\n elsif computer_wins == MAXIMUM_WINS\n prompt(\"Sorry, Computer has won #{MAXIMUM_WINS} times before you #sad_day\")\n else\n prompt(\"Current Score is #{player_wins}(User):#{computer_wins}(Computer)\")\n end\n puts \"================================================\"\nend", "def gameplay\n \n game_setup # Calls the game_setup method\n human = true # declare a boolean variable\n \n # whan human score and computer score are both less than the target score given by the user than enter the loop\n while human_score.to_i < target_score.to_i && computer_score.to_i < target_score.to_i\n \n # Conditional statment to check if it's human or computer's turn\n if human == true\n # Human's turn\n puts \"It is now #{name}\\'s turn\", \"\"\n puts \"Whoever gets to #{target_score} wins\" \n human_turn # Calls the human turn method \n human = false # After human turn ends set the human turn boolean value to false \n else \n # Computer's turn\n puts \"It is now the computer\\'s turn \\n\"\n puts \"Whoever gets to #{target_score} wins\"\n computer_turn # Calls the computer turn method \n human = true # Set human boolean value to true \n end\n\n # Output score\n puts \"Current Scores: \"\n puts \"\\t#{name}: #{human_score}\"\n puts \"\\tComputer: #{computer_score}\"\n end\n\n # Announce Winner\n puts \"We have a winner\"\n \n end", "def rock_battle\n if computer_rand == \"p\"\n puts \"Paper beats rock.\"\n puts \"The computer won.\"\n elsif computer_rand == \"s\"\n puts \"Rock beats scissors.\"\n puts \"You won!\"\n end\nend", "def pick_player\n \n puts \"Let's play Tic Tac Toe!\"\n puts \"But first, let's get acquainted. I am your computer #{Socket.gethostname}\"\n puts \"What's your name?\n \"\n\n # if you don't pick a name we'll pick a greeting for you\n @player = gets.chomp\n if @player == ''\n @player = 'Human friend'\n end\n \n # getting cracking already\n clr \n puts \"A pleaure to see you, #{@player}.\"\n puts \"Please choose if you want to play as X or O\"\n puts \"by pressing the corresponding key on your keyboard.\n \"\n input = ''\n until input == \"x\" || input ==\"o\" do\n input = gets.chomp.upcase\n if input == \"X\" || input == \"O\"\n @marker = input\n puts \"Thanks #{@player}, you picked #{@marker}, what's your move?\\n\"\n new_board\n make_move\n else\n puts \"that's not an X or an O. Try again\"\n end\n end\n end", "def start_game\n p = super\n cpu_move = pick_rps\n s = p.select(\"Your opponent throws #{cpu_move}. You throw:\", rpsArr) #Prompt Rc/Pp/Sc and wait for input\n winner?(win_hash[cpu_move.to_sym],s)\n end", "def turnon()\n puts \"You put ingredients in the blender.\"\n puts \"Would you like to turn the blender on? If so type 'Yes'\"\n prompt = gets.chomp.downcase\n\n # Until loop prompts for correct \"Yes\"/\"yes\" answer or keeps asking\n until prompt == \"yes\"\n puts \"Sure you don't want to push 'Yes'?\"\n prompt = gets.chomp.to_s.downcase \n end\n # If until loop passed, run outcome method which then runs puts blend method\n outcome \n end", "def choose\r\n\tputs \"And what about programing? Do you like programing? Remember, Yes, no, or maybe, only!\"\r\n\tchoice = gets.chomp\r\n\tcase choice.downcase\r\n\twhen \"yes\"\r\n\t\tputs \"That\\'s great!\"\r\n\twhen \"no\"\r\n\t\tputs \"That\\'s too bad!\"\r\n\twhen \"maybe\"\r\n\t\tputs \"Glad you\\'re giving it a chance!\"\r\n\telse\r\n\t\tputs \"What does that even mean??\"\r\n\tend\r\nend", "def game(chosen_door)\n if chosen_door\n puts \"You have entered the #{chosen_door[:name]}\"\n puts \"You now have to face #{chosen_door[:character]}\"\n puts \"#{chosen_door[:character_action]}\"\n puts \"What are you going to do?\"\n puts \"1. #{chosen_door[:decision_one].upcase}\"\n puts \"2. #{chosen_door[:decision_two].upcase}\"\n\n print \"> \"\n decision = $stdin.gets.chomp\n\n puts \"_________________________\"\n\n if decision == \"1\"\n puts chosen_door[:outcome_one].upcase\n elsif decision == \"2\"\n puts chosen_door[:outcome_two].upcase\n else\n handle_typos(chosen_door)\n end\n else\n handle_typos(chosen_door)\n end\nend", "def judge_winner\n\t\tif attacker.army.all_curr_hp.zero?\n\t\t\tresult.winner = defender\n\t\t\twinner = defender\n\t\telsif defender.army.all_curr_hp.zero?\n\t\t\tresult.winner = attacker\n\t\t\twinner = defender\n\t\tend\n\tend", "def user_choose_rps\n\tputs \"Enter rock, paper or scissors:\"\n user = gets.chomp\n user\nend", "def choice\n puts \"How do you want to play?:\"\n print \"Many Battles \"\n print \"- Choose Your Stats \"\n print \"- Move Battle(unavailable)\"\n puts \" \"\n print \"Enter your choice: \"\n choice = gets.chomp\n\n if choice == \"Many Battles\"\n system \"clear\"\n many_battles\n elsif choice == \"many battles\"\n system \"clear\"\n many_battles\n elsif choice == \"Many battles\"\n system \"clear\"\n many_battles\n elsif choice == \"many Battles\"\n system \"clear\"\n many_battles\n elsif choice == \"Choose Your Stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose your stats\"\n system \"clear\"\n user_input\n elsif choice == \"Choose your stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose Your stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose your Stats\"\n system \"clear\"\n user_input\n elsif choice == \"Move Battle\"\n puts \"This Mode is unavailable\"\n elsif choice == \"move battle\"\n puts \"This Mode is unavailable\"\n else\n puts \"Type in one of the choices\"\n end\n end", "def play\n\n\tsecret_choice = SecretNumber.new\n\tsecret_number = secret_choice.random\n\n\tplayer = Player.new\n\tplayer.name\n\n\n\t#Welcome the player to the game\nputs \"Welcome to the guessing a number game!\"\n\n#Let them know who created the game\nputs \"Do you want to play? (yes/no)\"\n\n\ndecision = false\nwhile decision == false\n\tplay = gets.chomp\nif play.to_s.downcase == \"yes\"\n\tputs \"Awesome\"\n\tdecision = true\nelsif play.to_s.downcase == \"no\"\n\tputs \"please play with me... okay?\"\nelse puts \"answer yes or no please :)\"\nend\nend\n\n\n\nsleep 1\n\n#Ask for the player's name and personally greet them by saying \"hi Player_name!\"\n\n\n#Communicate the rules of the game\nputs \"Here are the rules of the game\"\nsleep 0.75\nputs \"I am thinking of a number between 1 and 10.\"\nsleep 0.75\nputs \"You have three tries to guess the secret number.\"\nsleep 0.75\nputs \"If you fail 3 times...\"\nsleep 0.75\nputs \"you lose and I win\"\nsleep 0.75\n\n#for fun, ask then if they are ready to play\nputs \"Are you ready to play the game?\"\ndecision = false\nwhile decision == false\n\tplay = gets.chomp\nif play.to_s.downcase == \"yes\"\n\tputs \"Awesome\"\n\tdecision = true\nelsif play.to_s.downcase == \"no\"\n\tputs \"please play with me... okay?\"\nelse puts \"answer yes or no please :)\"\nend\nend\n\n#Ask the user for their guess\n#Verify if their guess is correct, if it is corrrect, congratulate them and end the game\n#Let the player know how many guesses they have left\n#If the player does not guess the answer in 3 tries let them know they lost and tell them the number\n\nguessNumber = 3\nwhile guessNumber > 0 \n\tputs \"What do you think the secret number is?\"\n\tguess = gets.chomp\nif secret_number == guess.to_i\n\tputs \"OMG, you won!! \"+secret_number.to_s+\" was totally my number!! Nice Job\"\n\tsleep 0.5\n\tputs \"Game Over\"\n\tbreak\nelsif secret_number != guess.to_i\n\tputs \"I'm sorry, but you did not guess correctly\"\n\tguessNumber -= 1\n\t\tif guessNumber > 1\n\t\tputs \"You have \"+guessNumber.to_s+\" more guesses left...\"\n\t\telse puts \"You have \"+guessNumber.to_s+\" more guess left...\"\n\t\tend\n\tend\nend\n\nif guessNumber.to_i < 1\n\tputs \"Oh, jeez... it looks like you have lost\"\n\tsleep 0.5\n\tputs \"The secret number was \"+secret_number.to_s\n\tputs \"Game Over\"\nend\t\n\n\n\n\n\nend", "def intro\n\tputs \"Welcome to the Secret Number game!! Created by Jason Haas.\"\n\tputs \"What is your name?\"\n\tplayer_name = gets.chomp\n\tputs \"Hi #{player_name}!!\"\n\tputs \"For this game you must guess a number between 1 and 10. You have 3 tries to guess correctly.\"\n\t# player_name\t\t# return the player_name\nend", "def run_game\n while @p1.score != @length && @p2.score != @length\n run_round\n end\n @winner = @p1 if @p1.score == @length\n @winner = @p2 if @p2.score == @length\n puts @winner.name + \" wins the game!\"\n puts \"Congratultions!\" if @winner.control == \"HUMAN\"\n @winner\n end", "def victory\n @current_player = @players[\"plyr2\"]\n unless @winner == false\n @over = true\n puts \" \"\n puts \" Code-breaker #{@current_player} wins!!\"\n puts \" \"\n end\n end", "def classify_player(chosen)\n if chosen == 'R' || chosen == 'r'\n return 'Rock'\n elsif chosen == 'P' || chosen == 'p'\n return 'Paper'\n elsif chosen == 'S' || chosen == 's'\n return 'Scissors'\n elsif chosen == 'y' || chosen == 'Y'\n output \"Great! Let's go!!!\"\n play_again(chosen)\n elsif chosen == 'n' || chosen == 'N'\n puts \"Goodbye!\"\n exit\n elsif chosen.to_s.empty?\n puts \"*****Please enter a valid option!*****\\n\"\n play_again(chosen)\n else puts \"*****Invalid option!*****\\n\"\n play_again(chosen)\n end\nend", "def determine_result(player, computer)\n if win?(player, computer)\n \"Win\"\n elsif win?(computer, player)\n \"Lose\"\n else\n \"Tie\"\n end\nend", "def win?\n\t\tif @win_condition == @pegs[2]\n\t\t\tputs \"\\nCongratulations! You have solved this Tower of Hanoi! Would you like to start over? Please enter 'y' for yes or 'n' for no!\"\n\t\t\tresponse = gets.chomp.downcase\n\t\t\tplay_again?(response)\n\t\tend\n\t\tputs \"\\nPlease make your next move!\"\n\t\tmove_input\n\tend", "def play_round()\n # Deal hand to all players\n for p in @players\n hand = Hand.new\n hand.deal_hand()\n p.hands << hand\n end\n\n # Dealer deals his own hand\n @dealers_hand.deal_hand()\n\n # Gather bets from all players\n for p in @players\n game_state()\n puts \"Player #{p.player}, how much would you like to bet?\"\n bet_amount = gets.chomp.to_i\n while !(p.can_bet(bet_amount))\n game_state()\n puts \"Player #{p.player}, that's an invalid bet! Try again.\"\n bet_amount = gets.chomp.to_i\n end\n p.bet(bet_amount)\n\n for h in p.hands\n p.place_bet(h)\n end\n end\n\n # Allow players to finalize their bet(s) and hand(s)\n for player in @players\n for hand in player.hands\n while !(hand.is_stand())\n valid_moves = ['h']\n if hand.is_split and player.can_bet_double()\n valid_moves += ['s', 'd', 'e']\n elsif player.can_bet_double()\n valid_moves += ['d', 'e']\n else\n valid_moves += ['e']\n end\n\n game_state()\n puts \"Player #{player.player}, what would you like to do for your #{hand} hand? Your valid moves: #{valid_moves}\"\n puts \"Legend: ['h' -> hit, 's' -> split, 'd' -> double down, 'e' -> end turn]\"\n\n move = gets.chomp\n while !(valid_moves.include? move)\n game_state()\n puts \"Player #{player.player}, that is not a valid move! Try again. Your valid moves: #{valid_moves}\"\n puts \"Legend: ['h' -> hit, 's' -> split, 'd' -> double down, 'e' -> end turn]\"\n move = gets.chomp\n end\n\n case move\n when 'h'\n hand.hit()\n when 's'\n new_hand = hand.split()\n player.place_bet(new_hand)\n\n hand.hit()\n new_hand.hit()\n player.hands << new_hand\n when 'd'\n player.place_bet(hand)\n hand.hit()\n hand.stand()\n when 'e'\n hand.stand()\n end\n\n if hand.is_bust()\n puts \"You busted!\"\n hand.stand()\n end\n end\n end\n end\n\n # Determine dealer's ending hand\n while @dealers_hand.value() < 17\n @dealers_hand.hit()\n end\n\n puts \"-=-=-=- Resulting Hands For This Round -=-=-=-\"\n game_state()\n\n # Determine winnings of each player and their hand(s)\n for player in @players\n for hand in player.hands\n if (!hand.is_bust() and @dealers_hand.is_bust()) or (!hand.is_bust() and !@dealers_hand.is_bust and hand.value() > @dealers_hand.value())\n player.win_hand(hand)\n puts \"Player #{player.player}'s #{hand} beat the dealer's #{@dealers_hand} hand!\"\n elsif (hand.is_bust() and @dealers_hand.is_bust()) or (hand.value() == @dealers_hand.value())\n player.tie_hand(hand)\n puts \"Player #{player.player}'s #{hand} tied with the dealer's #{@dealers_hand} hand!\"\n else\n player.lose_hand(hand)\n puts \"Player #{player.player}'s #{hand} lost to the dealer's #{@dealers_hand} hand! :(\"\n end\n end\n end\n\n # Determine who can continue playing\n continuing_players = []\n for player in @players\n if player.money != 0\n continuing_players << player\n else\n puts \"Player #{player.player} has no money and is eliminated!\"\n end\n end\n @players = continuing_players\n\n # Clear all playing hands.\n for player in @players\n player.hands = []\n player.bet = 0\n end\n end", "def announce_winner\n\t\[email protected]\n\t\tputs \"\"\n\t\tputs \"**********************************\"\n\t\tcase @current_turn\n\t\twhen @player_one\n\t\t\tif @ai == false\n\t\t\t\tputs \"Checkmate! Player 2 is the winner!\"\n\t\t\telsif @ai == true\n\t\t\t\tputs \"Checkmate! The computer is the winner!\"\n\t\t\tend\n\t\twhen @player_two\n\t\t\tputs \"Checkmate! Player 1 is the winner!\"\n\t\twhen @ai_color\n\t\t\tputs \"Checkmate! You are the winner!\"\n\t\tend\n\tend", "def play\r\n\tputs \"Press 'Enter' or 'Return' to continue..\"\r\n\tgets\r\n\tputs \"\\n\\n\\n\\n\"\r\n\tputs \"-NEW GAME-\"\r\n\t\t\"------------------------------------\\n\\n\"\r\n\tmarbles_left = rand(6..15)\r\n\t#0 is copmuter's turn, 1 is player's turn\r\n\tputs $turn == 0 ? \"The computer won the coin toss, it will go first\": \r\n\t\t\"You won the coin toss, you will go first\"\r\n\t$turn = rand(0..1)\r\n\twhile $playing == true\r\n\t\tif $turn == 0\r\n\t\t\tmarbles_left = computerTurn(marbles_left)\r\n\t\telsif $turn == 1\r\n\t\t\tmarbles_left = playerTurn(marbles_left)\r\n\t\telse \r\n\t\t\tputs \"\\n\\n\\n##############################\"\r\n\t\t\t\t\"Something went horribly wrong!\" +\r\n\t\t\t\t\"The game has ended. You probably\" +\r\n\t\t\t\t\"would have won anyway.\"\r\n\t\t\trestart()\r\n\t\tend\r\n\t\tif marbles_left <= 0\r\n\t\t\tputs \"\\n---No marbles remaining:---\\n\\n\\n\"\r\n\t\t\tputs $turn == 1 ? \"\\tThe computer won.\": \"\\tYou won!!\"\r\n\t\t\trestart()\r\n\t\tend\r\n\tend\r\n\r\nend" ]
[ "0.8146855", "0.72749084", "0.7211143", "0.7176953", "0.7140253", "0.7102776", "0.7057495", "0.6873467", "0.68657655", "0.6842399", "0.68106127", "0.67998683", "0.6792916", "0.67908597", "0.6786418", "0.67746675", "0.6755455", "0.6731502", "0.6727311", "0.6716355", "0.67102695", "0.67048246", "0.66939557", "0.669257", "0.6692491", "0.66882247", "0.66845083", "0.667419", "0.66575176", "0.66475016", "0.6632185", "0.6628429", "0.6625067", "0.6619226", "0.6610557", "0.6608126", "0.6604278", "0.6598312", "0.6587993", "0.6569201", "0.65683115", "0.6562796", "0.6561657", "0.6556569", "0.6552074", "0.65457326", "0.6541877", "0.6540563", "0.6539051", "0.6537786", "0.6536847", "0.6533263", "0.65263015", "0.6484615", "0.6481159", "0.6476264", "0.64760953", "0.64663434", "0.6465908", "0.6465777", "0.64656687", "0.6465137", "0.6463767", "0.64599264", "0.6456703", "0.64486897", "0.6443182", "0.6435843", "0.64317465", "0.64316994", "0.64283437", "0.6427454", "0.64175224", "0.64143336", "0.6413325", "0.6410608", "0.64103353", "0.63969135", "0.63949555", "0.6394837", "0.6390236", "0.6390062", "0.6386818", "0.63852125", "0.6385033", "0.6377013", "0.6376699", "0.637582", "0.6374371", "0.63699436", "0.6365518", "0.6365078", "0.6363589", "0.6362751", "0.63585573", "0.6358026", "0.6348217", "0.6346932", "0.6344786", "0.6344447", "0.63440466" ]
0.0
-1
If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_'). Examples: solution('abc') should return ['ab', 'c_'] solution('abcdef') should return ['ab', 'cd', 'ef']
def solution(str) if str.size.even? res = str.scan(/../) else str << '_' res = str.scan(/../) end res end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(str)\n str.scan(/.{1,2}/).map{ |str| str.size == 1 ? str + \"_\" : str }\nend", "def solution(str)\n str << \"_\" if str.length % 2 != 0\n str.chars.each_slice(2).map(&:join)\nend", "def solution(str)\n str.scan(/.{1,2}/).map { |e| e[1].nil? ? e + '_' : e }\nend", "def solution(str)\n str+=\"_\" if str.length.odd?\n res = []\n index = 0\n while index < str.length\n res << str[index .. index+1]\n index+=2\n end\n res\nend", "def neuter(s)\n s = s.strip.gsub(/[^a-zA-Z0-9]/, '_')\n s = s[1..-1] while s[0, 1] == '_'\n s = s[0..-2] while s[-1, 1] == '_'\n s\nend", "def to_underscore(string)\n result = []\n \n if string.to_s.length > 1\n string.scan(/[A-Z][a-z0-9]+/) do |word|\n \tresult << word.downcase << \"_\" \n end\n else \n return string.to_s\n end\n \n result.join(\"_\") #insert a underscore between to element of any array\nend", "def split_string_c(str)\n str << \"_\" if str.length.odd?\n str.chars.each_slice(2).map(&:join)\nend", "def evenator(s)\n s.delete(\".,?!_\").split(\" \").map do |word|\n word.length % 2 == 1? word << word[-1] : word\n end.join(\" \")\nend", "def underscore(a_word)\n u_word = a_word.dup\n u_word.gsub!(/::/, '/')\n u_word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2')\n u_word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n u_word.tr!(\"-\", \"_\")\n u_word.downcase!\n u_word\nend", "def repeater(str)\n new_str = ''\n return new_str if str.eql?('')\n str.chars.each do|char|\n new_str << char * 2\n end\n new_str\nend", "def solution(str)\n if str.size.odd? # если не чётное\n str << '_' # то добавить в конец подчёркивание и при разбиении оно будет с подчеркиванием\n str.scan(/../)\n else\n str.scan(/../) # если чётное просто разбить по два\n end\nend", "def repeater(str)\n str.chars.each_with_object('') {|char, str| str << char * 2}\nend", "def repeater(string)\n string.chars.map! { |char| char * 2 }.join('')\nend", "def double_char(str)\n\tarr = str.split('')\n\tnew_arr = []\n\tarr.each do |i| \n\t\t2.times {new_arr.push(i)}\n\tend\n\tstr = new_arr.join()\n\treturn str;\nend", "def to_underscore(string)\n string.gsub(/(.)([A-Z])/,'\\1_\\2').downcase\nend", "def repeater(string)\n string = string.split(\" \")\n\n string.map do |word|\n word = word.split('')\n word.map {|letter| letter * 2}.join('')\n end.join(' ')\nend", "def replace_correct_letters\n result = @secret_word\n @secret_word.split('').each do |letter|\n unless @characters_guessed_correctly.include? letter\n result = result.gsub(letter, '_')\n end\n end\n @word_guessed = result\n result\n end", "def dash_insert_ii(str)\n result = ''\n str.each_char.with_index do |char, idx|\n result << char\n next if char == '0' || idx >= str.size - 1 || str[idx + 1] == '0'\n if char.to_i.even? && str[idx + 1].to_i.even?\n result << '*'\n elsif char.to_i.odd? && str[idx + 1].to_i.odd?\n result << '-'\n end\n end\n result\nend", "def repeater(string)\n array = string.split('')\n array.map! do |char|\n char * 2\n end\n array.join\nend", "def to_underscore(string)\n res = \"\"\n if string.is_a?Integer\n return string.to_s\n else\n letter = string.split(\"\")\n letter.each{|item|\n if (\"A\"..\"Z\").include?item\n res += \"_\" + item.downcase\n else\n res += item\n end\n }\n end\n\n return res[1..res.length]\nend", "def pig_it(str)\n str.gsub(/(\\w)(\\w+)*/, '\\2\\1ay')\nend", "def to_underscore(string)\n string.to_s.gsub(/([A-Z][A-Z0-9]?)/) { '_' + $1.downcase }.gsub(/^_|\\s_/, ' ').gsub(/^\\s/, '')\nend", "def repeater(string)\n string.split('').map { |char| char * 2 }.join\nend", "def repeater(str)\n\n str.chars.map {|char| char*2}.join\n\nend", "def rule2(str = @word)\n newstr = str.chars\n newstr.each_index do |index|\n if (newstr[index..index+5].uniq.length==1)\n newstr[index..index+5] = newstr[index]\n end\n end\n newstr.join('').to_s.squeeze(\" \")\n end", "def repeater(string)\n string.split(//).map {|char| char * 2 }.join\nend", "def to_underscore(string)\n string = string.to_s\n string.split(/(?=[A-Z])/).map(&:downcase).join('_')\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def every_other_letter(string)\r\n # your code here\r\n every_other_letter = \"\"\r\n i = 0\r\n for i in 0 ... string.length\r\n if i % 2 == 0\r\n every_other_letter << string[i]\r\n end\r\n end\r\n every_other_letter\r\nend", "def repeater(string)\n string.chars.map{ |char| char * 2 }.join\nend", "def reverberate(str)\n \n new_str = str.split(\" \").map do |wrd|\n new_wrd = wrd.length > 3 ? reverberate_word(wrd) : wrd\n wrd.capitalize == wrd ? new_wrd.capitalize : new_wrd\n end\n\n new_str.join(\" \")\nend", "def underscore(str)\n str = str.to_s\n str = str[0].downcase + str[1...str.length].gsub(/([A-Z]+)/) { |m| \"_#{m.downcase}\" }\n str.to_sym\n end", "def repeater(string)\n new_string = ''\n string.chars.each do |char|\n 2.times { new_string << char }\n end\n new_string\nend", "def underscore_string(str)\n word = str.to_s.dup\n word.gsub!(' ', '_')\n word.gsub!(/::/, '/')\n word.gsub!(/([A-Z\\d]+)([A-Z][a-z])/,'\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n word.tr!('-', '_')\n word.squeeze!('_')\n word.downcase!\n word\n end", "def alternate_words(string)\n\t# clean_string gets rid of ! @ $ # % ^ & * ( ) - = _ .....\n\tclean_string = string.to_s.gsub(/[^’'A-Za-z0-9\\s]/i,' ')\n\n\t#array then turns clean_string into an array of words split using the space character \n clean_string_array = clean_string.split(\" \")\n\n #create a new array called final\n final = []\n\n #len is the total number of values in the clean_string_array\n len = clean_string_array.length-1\n\n #loop throught clean_string_array\n for i in 0..len\n\n \t#if i is an odd number then select that index from the clean_string_array\n \tstr = clean_string_array[i] if i % 2 == 0\n\t\t\n\t\t#if str does not have an empty space then pass it through\n \tif str != \"\"\n\n \tfinal << str\n \tstr = \"\"\n end\n end\n return final\n \nend", "def DashInsert(str)\n str.chars\n .each_cons(2)\n .map { |i,j| (i.to_i.odd? && j.to_i.odd?) ? i+'-' : i }\n .join + str[-1]\nend", "def repeater(string)\r\n new_string = \"\"\r\n string.each_char { |char| new_string << char*2 }\r\n new_string\r\nend", "def repeater(string)\n string.chars.map { |el| el * 2 }.join\nend", "def oddify(string)\n words = string.split(/[ .]+/)\n\n words.map.with_index do |word, idx|\n idx.odd? ? word.reverse : word\n end.join(' ') << '.'\nend", "def repeater(word)\n word.chars.map { |char| char * 2 }.join\nend", "def to_underscore(string)\n string.to_s.scan(/.?[a-z\\d]+/).map(&:downcase).join('_')\nend", "def double_char(str)\n str.chars.map { |letter| letter * 2 }.join\nend", "def DashInsert(str)\n str = str.split(\"\")\n odd = \"13579\"\n i = 0\n new = \"\"\n\n while i < str.length\n new += str[i]\n if odd.index(str[i]) && str[i+1] && odd.index(str[i + 1])\n new += \"-\"\n end\ni+= 1\n end\n # code goes here\n return new\n\nend", "def repeater(str)\n str.chars.map { |chr| chr * 2}.join\nend", "def to_underscore(string)\n string.to_s.split(/(?=[A-Z])/).join('_').downcase\nend", "def underscore(string)\n word = string.to_s.dup\n word.gsub!(/::/, '/')\n word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n word.tr!(\"-\", \"_\")\n word.downcase!\n word\n end", "def encode_repeating(my_string)\n # return if nil or empty\n return if (my_string == nil || my_string.length == 0)\n\n entering_index = 0 # this is where characters will get replaced\n examining_index = 0 # this is where the current character is getting examined and counted\n length = my_string.length\n while examining_index < length # all n characters will be examined\n temp = my_string[examining_index] # current character\n count = 1 # current character count\n while my_string[examining_index+1] == temp && examining_index < length\n examining_index += 1 # increment index\n count += 1 # increment current character count\n end\n # update at entering_index on seeing the subsequent character changing\n if count > 2 # enter the current character followed by it's count\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n my_string[entering_index] = count.to_s\n entering_index += 1\n elsif count == 2 # enter the current character twice\n count.times do\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n else # count == 1, enter the current character once\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n examining_index += 1 # move to next character\n end\n\n # delete trailing characters in the string.\n count = length - entering_index\n count.times do # worst case: delete n-2 number of characters\n my_string.slice! entering_index # trim the string\n end\n return\nend", "def repeater(string)\r\n result = \"\"\r\n string.chars.each do |letter|\r\n result << letter * 2\r\n end\r\n result\r\nend", "def swap_chars string # my version\n new_string = string.split.map do |word|\n first = word[0]\n word[0] = word[-1]\n word[-1] = first\n word\n end\n new_string.join(' ')\nend", "def repeater(str)\n temp_arr = []\n str.chars do |letter|\n temp_arr << letter * 2\n end\n \n temp_arr.join('')\nend", "def underscore(camel_cased_word)\n word = camel_cased_word.to_s.gsub('::', '/')\n word.gsub!(/([A-Z\\d]+)([A-Z][a-z])/,'\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n word.tr!(\"-\", \"_\")\n word.downcase!\n word\n end", "def to_underscore(string)\n string.to_s.chars.slice_before(/[A-Z]/).map { |word| word.join.downcase }.join('_')\nend", "def DashInsert(str)\n \n i = 0\n while i < str.length - 1\n if str[i].to_i % 2 != 0 && str[i+1].to_i % 2 != 0 && str[i].to_i != 0 \n \t str[i] = str[i] + \"-\"\n end\n i += 1\n end\n \n str\n \nend", "def display_word(word, triedchars)\n res = \"\"\n word.split(\"\").each do |char|\n if triedchars.include?(char.upcase) or not char.match(/^[[:alpha:]]$/)\n res += char\n elsif\n res += \"_\"\n end\n end\n res\nend", "def underscore(camel_cased_word)\n word = camel_cased_word.to_s.dup\n word.gsub!(/([A-Z\\d]+)([A-Z][a-z])/,'\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n word.tr!(\"-\", \"_\")\n word.tr!(\"[\", \"_\")\n word.tr!(\"]\", \"\")\n word.downcase!\n word\n end", "def encode_repeating(my_string)\r\n i = 0\r\n j = 0\r\n letter = my_string[i]\r\n while i < my_string.length\r\n j += 1 while my_string[j + 1] == letter\r\n if j - i >= 2\r\n my_string[(i + 1)..j] = (j - i + 1).to_s\r\n end\r\n additional = 0\r\n additional = 1 if j > i\r\n i += 1 + additional\r\n j = i\r\n letter = my_string[i]\r\n end\r\n return my_string\r\nend", "def snakify(string)\n string.split(/(?=[A-Z])/).map(&:downcase).join('_')\n end", "def underscore(camel_cased_word)\n word = camel_cased_word.to_s.dup\n word.gsub!(/::/, '/')\n word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n word.tr!(\"-\", \"_\")\n word.downcase!\n word\n end", "def to_underscore(string)\n string.to_s.gsub(/([A-Z])/) { \"_#{$1.downcase}\" }.gsub(/^_/,'')\nend", "def double_char(str)\n str.chars.map{|e|e *2}.join\nend", "def to_underscore(string)\n return string.to_s if string.is_a?(Integer)\n translation = []\n alphabet = (\"a\"..\"z\").to_a\n\n string.chars.each do |element|\n if element == element.upcase && alphabet.include?(element.downcase)\n translation << \"_\"\n translation << element.downcase\n else\n translation << element\n end\n end\n translation.drop(1).join\nend", "def without_two(str)\n return str if str.length < 2\n return '' if str.length == 2\n return str[2..] if str[0...2].eql? str[-2..]\n\n str\n end", "def swap(string)\n string = string.split\n new_string = []\n\n\n string.map do |word|\n word = word.chars\n c1 = word[0]\n c2 = word[-1]\n\n word[0] = c2\n word[-1] = c1\n\n new_string << word.join\n\n end\n\n new_string.join(' ')\nend", "def to_underscore(string)\n # TODO: complete\n string.to_s.gsub(/(.)([A-Z])/, '\\1_\\2').downcase\nend", "def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend", "def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend", "def staggered_case(str)\n spongebob_case = str.split('').map.with_index do |char, index|\n if index.odd?\n char.upcase\n elsif index.even?\n char.downcase\n else\n char\n end\n end.join\n\n spongebob_case\nend", "def underscore(string)\n string.gsub('::', '_')\n .gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n .gsub(/([a-z\\d])([A-Z])/, '\\1_\\2')\n .tr('-', '_')\n .downcase\n end", "def underscore_string(str)\n str.to_s.strip.\n gsub(' ', '_').\n gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n squeeze(\"_\").\n downcase\n end", "def repeater(string)\n new_str = ''\n\n string.chars.each { |x| new_str << x * 2 }\n new_str\nend", "def odds_and_evens(string, return_odds)\nif return_odds == false\n return string.gsub(/(.)./, '\\1')\n\nelse return_odds == true\n if string.length.odd?\n return string.gsub(/.(.)/, '\\1')[0...-1]\n else \n return string.gsub(/.(.)/, '\\1')\n end\nend\nend", "def underscore(str)\n str.gsub(/.*::/,'').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end", "def to_underscore(string)\n string.to_s.scan(/[A-Z]?[a-z\\d]+/).map {|x| x.downcase }.join('_')\nend", "def underscore(string)\n string.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end", "def double_char(str)\n str = \"String\"\n arr = str.split('')\n arr.map do |letter|\n letter * 2\n end.join\n \nend", "def underscore\n started = false\n split(/([A-Z])/).inject([]) do |parts, word|\n if word.size == 1 && word =~ /[A-Z]/\n parts << \"_\" if started\n end\n\n if word.size > 0\n parts << word.downcase\n started = true\n end\n parts\n end.join\n end", "def fix_string(input_string)\n input_string.delete! '_'\n input_string.delete! '-'\n input_string.delete! ' '\n input_string.downcase!\n return input_string.singularize\n end", "def underscore_string(str)\n str.to_s.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end", "def encode_repeating(my_string)\n return my_string if !my_string || my_string.length < 2\n current, check_next = 0, 1\n until current == my_string.length\n check_next += 1 while my_string[current] == my_string[check_next]\n repeats = check_next - current\n if repeats > 2\n my_string[current + 1] = repeats.to_s\n check_next -= my_string.slice!((current + repeats.to_s.length + 1)...check_next).length\n end\n current = check_next\n end\n return my_string\nend", "def repeater(string)\n doubled_string = []\n\n string.chars.each do |char|\n doubled_string << char * 2\n end\n\n doubled_string.join\nend", "def solution(string)\n def is_upcase?(letter)\n (\"A\"..\"Z\").cover?(letter)\n end\n\n def letter?(letter)\n letter = letter.downcase\n (\"a\"..\"z\").cover?(letter)\n end\n\n count = 0\n string.split('').each_with_index do |letter, index|\n index = index + count\n if is_upcase?(letter) && letter?(string[index - 1]) && letter?(string[index + 1])\n string.insert(index, ' ')\n count += 1\n end\n end\n return string\nend", "def odd_words(string)\n return 'invalid input' if invalid_input?(string)\n\n results = []\n temp_string = ''\n string = string.squeeze(' ').sub(/\\s*\\./, '.')\n string.chars.each do |char|\n if char.match(/[A-Za-z]/)\n temp_string << char\n elsif char.match(/(\\.| )/)\n temp_string = temp_string.reverse if results.size.odd?\n results << temp_string.clone\n temp_string.clear\n end\n end\n\n results.join(' ') + '.'\nend", "def solve(s)\n new_str = ''\n s.each_char do |char|\n if new_str[-1] != char\n new_str += char\n end\n end\n return new_str\nend", "def first_two_letters_correction(wrong, right)\n if wrong.length > 2 && right.length > 2\n wrong != capitalize_first_two(wrong) &&\n right != capitalize_first_two(right)\n \"ia #{capitalize_first_two(wrong)} #{capitalize right}\"\n end\n end", "def snake(str)\n words = str.split\n current_word = 1\n\n loop do\n words[current_word].downcase!\n\n current_word += 1\n break if current_word >= words.size\n end\n\n words.join('_')\nend", "def alternate_words(str)\n\n '!@$#%^&*()-=_+[]:;,./<>?\\\\|'.split(//).each do |char|\n str = str.gsub(char, ' ')\n end\n\nalternate_array = []\n str.split.map.each_slice(2) do |first, second|\n alternate_array << first\n end\n alternate_array\nend", "def odd(str)\n result = ''\n is_odd_idx = false\n space_just_added = false\n last_letter_idx = nil\n last_space_idx = nil\n str.each_char do |char|\n if char == ' '\n next if space_just_added\n result << ' '\n space_just_added = true\n last_space_idx = result.size\n is_odd_idx = !is_odd_idx\n elsif char.match?(/[a-z]/i)\n is_odd_idx ? result.insert(last_space_idx, char) : result << char\n last_letter_idx = result.size - 1\n raise ArgumentError if last_letter_idx - last_space_idx.to_i >= 20\n space_just_added = false\n elsif char == '.'\n break\n else\n raise ArgumentError, 'invalid input'\n end\n end\n last_letter_idx ? result[0..last_letter_idx] + '.' : result\nend", "def swap(string)\n string_arr = string.split.map do |word|\n first_letter = word[0]\n word = word.gsub(word[0], word[-1])\n word[-1] = first_letter\n word\n end\n string_arr.join(' ')\nend", "def underscore(string)\n string\n .to_s\n .gsub(/::/, \"/\")\n .gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n .gsub(/([a-z\\d])([A-Z])/, '\\1_\\2')\n .tr(\"-\", \"_\")\n .downcase\n end", "def underscore(s)\n s.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/, '\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end", "def repeater(str)\n repeated_str = ''\n\n str.each_char do |char|\n repeated_str << char * 2\n end\n\n repeated_str\nend", "def same_char_collapse(str)\n word = \"\"\n str.each_char.with_index do |char, i|\n if (char == word[-1])\n word = word[0...-1]\n else\n word += char \n end\n end\n\n return word\nend", "def repeater(str)\n new_str = ''\n str.chars.each do |char|\n new_str << char * 2\n end\n \n p new_str\nend", "def reverse_alternate(string)\n string.split.map.with_index{ |word, index| index.odd? ? word.reverse : word }.join(\" \")\nend", "def swap (str)\n words = str.split\n new_words = []\n\n words.each do |word|\n if word.length > 3\n new_words << word[-1] + word[1..-1] + word[0]\n else \n \n end \n\n new_words.join(' ')\nend \n\n\np swap('Oh what a wonderful day it is') #== 'hO thaw a londerfuw yad ti si'\np swap('Abcde') #== 'ebcdA'\np swap('a') #== 'a'", "def underscore(str)\n str.to_s.gsub(/\\B[A-Z](?:[a-z])/, '_\\&').downcase\n end" ]
[ "0.8301458", "0.81800497", "0.7939715", "0.76024735", "0.6747341", "0.6555052", "0.6513336", "0.6415058", "0.629731", "0.62598735", "0.6237132", "0.62004805", "0.6181425", "0.61359906", "0.611304", "0.6086847", "0.6083299", "0.6060474", "0.6038935", "0.6016481", "0.60141504", "0.6010318", "0.5997747", "0.59960115", "0.59915817", "0.5957964", "0.59523916", "0.5945284", "0.5945284", "0.5945284", "0.5945284", "0.5945284", "0.5929307", "0.59266853", "0.59246755", "0.59246373", "0.5922695", "0.592094", "0.5920888", "0.5918128", "0.5918107", "0.5914342", "0.59064955", "0.5904348", "0.58655924", "0.5862653", "0.5861363", "0.58545995", "0.5849525", "0.58457285", "0.5845412", "0.58403486", "0.5837476", "0.5828104", "0.5826427", "0.582075", "0.58206826", "0.5817093", "0.5813898", "0.5812386", "0.58087444", "0.58005905", "0.579284", "0.579255", "0.57896537", "0.5786019", "0.57798564", "0.5770406", "0.57574916", "0.57574916", "0.5757083", "0.57450974", "0.5740773", "0.5740593", "0.5736547", "0.57340705", "0.5733896", "0.5731894", "0.57301086", "0.57296413", "0.5729478", "0.5727163", "0.5711592", "0.5696534", "0.56958646", "0.5686002", "0.5681075", "0.56694305", "0.5667567", "0.5663378", "0.5662796", "0.5658327", "0.5658204", "0.5657276", "0.56521255", "0.56520575", "0.56506646", "0.56428546", "0.564278", "0.56416917" ]
0.72064626
4
GET /apid_drivers GET /apid_drivers.json
def index respond_with ApidDriver.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_drivers\n drivers\n end", "def get_drivers\n return return_all_drivers\n end", "def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def get_driver_details\n @resource = Resource.find(params[:id])\n @driver = Driver.find(AgencyStore.find_by_resource_id(params[:id]).driver_id)\n render :layout => false\n end", "def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def index\n @drivers = Driver.all\n end", "def index\n @drivers = Driver.all\n end", "def show\n\t\t\t\trespond_with Driver.find(params[:id])\n\t\t\tend", "def index\n\t\t\t\trespond_with Driver.all\n\t\t\tend", "def show\n # Show one record\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def create\n respond_with :api,:v1, ApidDriver.create_or_update(params[:apid_driver])\n end", "def drivers\n send :adapters\n end", "def show\n respond_with ApidDriver.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n respond_with nil\n end", "def index\n # Show all records\n @drivers = Driver.search(params[:search], params[:column]).order(sort_column(Driver, 'name') + ' ' + sort_direction).page(params[:page]).per(10)\n \n get_params()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def pending_drivers\n users = User.needing_driver_verification\n render :json => users, each_serializer: SlimPendingDriverSerializer, root: false, status: 200\n end", "def set_driverslist\n @driverslist = Driverslist.find(params[:id])\n end", "def show\n @driver_record = DriverRecord.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver_record }\n end\n end", "def driver(driver_id)\n from_resource(\n :driver,\n connection.get(api_uri(\"drivers/#{driver_id}\"))\n )\n end", "def index\n @driverslists = Driverslist.all\n end", "def get_with_http_info(policy_activity_id, driver_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriversApi.get ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriversApi.get\"\n end\n # verify the required parameter 'driver_id' is set\n if @api_client.config.client_side_validation && driver_id.nil?\n fail ArgumentError, \"Missing the required parameter 'driver_id' when calling DriversApi.get\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/drivers/{driverId}'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s).sub('{' + 'driverId' + '}', driver_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Bearer']\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 => 'Driver')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriversApi#get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_drvies_with_http_info(year, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DrivesApi.get_drvies ...'\n end\n # verify the required parameter 'year' is set\n if @api_client.config.client_side_validation && year.nil?\n fail ArgumentError, \"Missing the required parameter 'year' when calling DrivesApi.get_drvies\"\n end\n # resource path\n local_var_path = '/drives'\n\n # query parameters\n query_params = {}\n query_params[:'year'] = year\n query_params[:'seasonType'] = opts[:'season_type'] if !opts[:'season_type'].nil?\n query_params[:'week'] = opts[:'week'] if !opts[:'week'].nil?\n query_params[:'team'] = opts[:'team'] if !opts[:'team'].nil?\n query_params[:'offense'] = opts[:'offense'] if !opts[:'offense'].nil?\n query_params[:'defense'] = opts[:'defense'] if !opts[:'defense'].nil?\n query_params[:'conference'] = opts[:'conference'] if !opts[:'conference'].nil?\n query_params[:'offenseConference'] = opts[:'offense_conference'] if !opts[:'offense_conference'].nil?\n query_params[:'defenseConference'] = opts[:'defense_conference'] if !opts[:'defense_conference'].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<Drive>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DrivesApi#get_drvies\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n admin_check\n @drivers = Driver.all\n end", "def index\n @ride_drivers = RideDriver.all\n end", "def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end", "def nearby_drivers(args = {})\n make_request(\n http_method: :get,\n endpoint: path_for(:nearby_drivers),\n access_token: args.delete(:access_token),\n options: { query: args }\n )\n end", "def index\n redirect_to search_drivers_path unless current_user and current_user.is_admin\n @drivers = Driver.all\n end", "def index\n @devices = Device.all.includes(:browsers)\n json_response(@devices, :ok, [:browsers])\n end", "def index\n id = params[:id].to_i\n\n if id != 0\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find_all_by_id(id)\n if @agencies.any?\n @agency_name = @agencies.first.name\n end\n else\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find(:all)\n end\n\n\t\t@records_returned = @agencies.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @agencies }\n end\n end", "def get_all_with_http_info(policy_activity_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriversApi.get_all ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriversApi.get_all\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/drivers'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Bearer']\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<DriverSummary>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriversApi#get_all\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def drivers\n rides.map { |ride| ride.driver }\n end", "def add_drivers params\n @driver_hash = JSON.parse(params)\n\n @driver_hash['drivers'].each do |driver|\n add_driver(driver[\"id\"],driver[\"location\"])\n end\n true\n end", "def index\n @apis = Api.all\n end", "def drivers()\n self.rides().map { | ride | ride.driver }\n end", "def find_driver(id)\n return find_by_id(@drivers, id)\n end", "def index\n\n @enterprise = current_user\n @drivers = @enterprise.drivers\n\n #logeando vista drivers con autos desde enterprise\n @cars = @enterprise.cars\n # @drivers = Driver.all\n end", "def driver_info\n return Rideshare::Driver.find(@driver_id)\n end", "def index\n json_response(@device.browsers)\n end", "def set_driver\n cities = City.find(params[:city_id])\n @drivers = cities.drivers.find(params[:id])\n end", "def index\n @references_vehicle_drivers = ReferencesVehicleDriver.all\n end", "def driver_params\n json_api_params(Driver,[:first_name,:last_name,:phone_no,:plant_id, :user_id,:enabled]).fetch(:attributes, {})\n end", "def index\n @drivers_licesnses = DriversLicesnse.all\n end", "def drivers\n @drivers ||= ActiveSupport::HashWithIndifferentAccess.new\n end", "def hired\n authorize current_company, :index?\n @drivers = current_company.hired_drivers.distinct\n @drivers = @drivers.page(params[:page]).per(10)\n end", "def driver\n @data[\"driver\"]\n end", "def show\n @route = Route.find(params[:id])\n @driver = Hitchhiker.find(@route.hitchhiker_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @route }\n end\n end", "def get_all_0_with_http_info(policy_activity_id, status, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriversApi.get_all_0 ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriversApi.get_all_0\"\n end\n # verify the required parameter 'status' is set\n if @api_client.config.client_side_validation && status.nil?\n fail ArgumentError, \"Missing the required parameter 'status' when calling DriversApi.get_all_0\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/drivers/{status}'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s).sub('{' + 'status' + '}', status.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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Bearer']\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<DriverSummary>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriversApi#get_all_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @driver_applications = DriverApplication.all\n end", "def index\n @apis = Api.all(:order => \"query\")\n #@apis = Api.order(\"query\").page(params[:page]).per(20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apis }\n end\n end", "def interesting(options = {})\n response = Typhoeus::Request.get(\"#{DARKSKY_API_URL}/interesting/#{@api_key}\", DEFAULT_OPTIONS.dup.merge(options))\n JSON.parse(response.body) if response.code == 200 \n end", "def index\n @offers = Offer.all\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n format.html { @offers }\n end\n end", "def return_all_drivers\n return @trips.map{ |trip| trip.driver }\n end", "def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end", "def getDriver\n @driver\n end", "def getDriver\n @driver\n end", "def show\n @driver_license_type = (DriverLicenseType.find_by_sql 'SELECT * FROM driver_license_type WHERE id = ' + params[:id])[0]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver_license_type }\n end\n end", "def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end", "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 index \n ip_addr = request.env['REMOTE_ADDR'] \n @browse_by = [[\"Browse By\",''],[\"Guides\",'1'],[\"Places\",'2']]\n @characteristics = [\"Latest\",'1'],[\"Most Popular\",'2'],[\"Highest Rated\",'3'],[\"Stress Factor\",'4']\n @notice = notice\n @guides = Guide.where(\"publish=?\",true).order(\"CREATED_AT DESC\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @guides }\n end\n end", "def details\n options = {}\n # include=driver\n # fields[driver]=average_rating\n if params[:fields]\n driver_fields = params[:fields].permit(:driver).to_h.\n inject({}) { |h, (k,v)| h[k.to_sym] = v.split(\",\").map(&:to_sym); h }\n options.merge!(fields: driver_fields)\n end\n\n # multiple associated resources are comma-separated\n if params[:include]\n options[:include] = params[:include].split(\",\").map(&:to_sym)\n end\n\n @trip = Trip.includes(:driver).find_by(id: params[:id])\n\n render json: TripSerializer.new(@trip, options).serializable_hash\n end", "def show\n @adv = Advantage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @adv }\n end\n end", "def index\n\t\t\t\t# @reviews = Driver.find_by!(id: params[:driver_id]).driver_reviews#.order('created_at DESC').to_a\n\t\t\t\t@reviews = DriverReview.where(driver_id: params[:driver_id])\n\t\t\tend", "def get_info(id)\n url = \"http://www.omdbapi.com/?i=#{id}&y=&plot=short&r=json\"\n return_result(url)\n end", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def index\n unless access_token\n redirect_to controller: 'oauths', action: 'welcome'\n return\n end\n \n @drivers = [:chrome, :ff, :ie, :safari]\n @scenarios = Scenario.where(user_id: current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scenarios }\n end\n end", "def index\n @admin_agencies = Admin::Agency.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_agencies }\n end\n end", "def call_api\n\t\tputs \"Getting info on elected officials for zipcode: #{zip_code}\"\n\t\t@api_data_on_electeds = JSON.load RestClient.get \"https://congress.api.sunlightfoundation.com/legislators/locate?zip=#{zip_code}&apikey=952d630dfb75498ab63de7a362a85335\"\n\tend", "def show\n @trip_driver = TripDriver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip_driver }\n end\n end", "def get(api, params={})\n url2json(:GET, \"#{@endpoint}#{api}\", params)\n end", "def apis; end", "def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end", "def show\n @api = Api.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api }\n end\n end", "def devices(params={})\n res = @client.get(\"#{path}/devices\", params)\n\n res.json[\"devices\"].map{ |atts| ::M2X::Client::Device.new(@client, atts) } if res.success?\n end", "def create\n\t\t\t\trespond_with Driver.create(params[:driver])\n\t\t\tend", "def info\n get(\"/api-info\")\n end", "def driver_ids\n\t\tdrivers.map{|d| d.id.to_s + \"_\" + self.id.to_s}\n\tend", "def set_drivers_licesnse\n @drivers_licesnse = DriversLicesnse.find(params[:id])\n end", "def show\n render json: Agent.find(params[:id]).buyers\n end", "def show\n @api = Api.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @api }\n end\n end", "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 trip_get_driver(driver_id)\n RideShare::Driver.find(driver_id)\n end", "def show\n @bluetooth = Bluetooth.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bluetooth }\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 api\n @api\n end", "def show\n @vendor = Vendor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vendor }\n end\n end", "def index\n @api_versions = ApiVersion.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def show\n @api_tag = Api::Tag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_tag }\n end\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def find(id)\n @api.get(\"api/#{id.to_s}.json\")\n end", "def index\n @vehicles = Vehicle.all\n\n id = Vehicle.pluck(:api_id) # integer array\n\n \n end", "def index\n # # if page value a param, use that, else ...\n # page = 3\n # request_url = MOVIE_DB_URL + \"&api_key=#{ENV[\"API_KEY\"]}\"\n genre_request_url = GENRE_URL + \"&api_key=#{ENV[\"API_KEY\"]}\"\n # request_url += \"&page=#{page}\"\n # if sort by release date\n # request_url += RELEASE_DATE_DESC_URL\n # if sort by title\n # request_url += RELEASE_DATE_DESC_URL;\n # @movies = Unirest.get(request_url).body[\"results\"]\n @genres = Unirest.get(genre_request_url).body[\"genres\"]\n # puts @genres\n end", "def index \n @browse_by = [[\"Browse By\",''],[\"Guides\",'1'],[\"Places\",'2']]\n @characteristics = [\"Latest\",'1'],[\"Most Popular\",'2'],[\"Highest Rated\",'3'],[\"Stress Factor\",'4']\n @notice = notice\n @guides = Guide.order(\"CREATED_AT DESC\").all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @guides }\n end\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end" ]
[ "0.70294434", "0.68312633", "0.6802067", "0.6802067", "0.65791625", "0.6509949", "0.6509949", "0.64879316", "0.64879316", "0.6417385", "0.62555367", "0.618175", "0.6169089", "0.6144645", "0.6135036", "0.6112338", "0.6081415", "0.60653627", "0.6027641", "0.60162634", "0.59756666", "0.590621", "0.58475506", "0.5822667", "0.57840407", "0.5763186", "0.5754687", "0.5753718", "0.5658379", "0.56402767", "0.56242025", "0.5621241", "0.56109613", "0.56079763", "0.5593745", "0.55840904", "0.5560025", "0.55485994", "0.55473655", "0.5546831", "0.5546121", "0.5536262", "0.55232364", "0.552138", "0.54679537", "0.54581594", "0.54516", "0.5434011", "0.5428655", "0.5410623", "0.5391813", "0.5376658", "0.53754675", "0.53366834", "0.53256947", "0.53256947", "0.53179103", "0.5315597", "0.5315468", "0.5303657", "0.5278489", "0.52704895", "0.5262643", "0.5254063", "0.52504116", "0.5248894", "0.52384067", "0.52240396", "0.52230924", "0.5220711", "0.52197164", "0.52035964", "0.5203385", "0.519704", "0.51963496", "0.5189679", "0.5186086", "0.5174479", "0.51677173", "0.5165896", "0.51628804", "0.51579887", "0.5149148", "0.5136491", "0.51347643", "0.5124915", "0.5121719", "0.5114392", "0.5112652", "0.5112652", "0.5112652", "0.5112652", "0.5112652", "0.5112652", "0.5107204", "0.51066333", "0.5102812", "0.5101135", "0.50916845", "0.50916845" ]
0.6880389
1
GET /apid_drivers/1 GET /apid_drivers/1.json
def show respond_with ApidDriver.find(params[:id]) rescue ActiveRecord::RecordNotFound respond_with nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_drivers\n drivers\n end", "def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def get_driver_details\n @resource = Resource.find(params[:id])\n @driver = Driver.find(AgencyStore.find_by_resource_id(params[:id]).driver_id)\n render :layout => false\n end", "def index\n respond_with ApidDriver.all\n end", "def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def show\n\t\t\t\trespond_with Driver.find(params[:id])\n\t\t\tend", "def get_drivers\n return return_all_drivers\n end", "def show\n # Show one record\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def index\n @drivers = Driver.all\n end", "def index\n @drivers = Driver.all\n end", "def create\n respond_with :api,:v1, ApidDriver.create_or_update(params[:apid_driver])\n end", "def show\n @driver_record = DriverRecord.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver_record }\n end\n end", "def driver(driver_id)\n from_resource(\n :driver,\n connection.get(api_uri(\"drivers/#{driver_id}\"))\n )\n end", "def index\n\t\t\t\trespond_with Driver.all\n\t\t\tend", "def index\n # Show all records\n @drivers = Driver.search(params[:search], params[:column]).order(sort_column(Driver, 'name') + ' ' + sort_direction).page(params[:page]).per(10)\n \n get_params()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def set_driverslist\n @driverslist = Driverslist.find(params[:id])\n end", "def get_with_http_info(policy_activity_id, driver_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriversApi.get ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriversApi.get\"\n end\n # verify the required parameter 'driver_id' is set\n if @api_client.config.client_side_validation && driver_id.nil?\n fail ArgumentError, \"Missing the required parameter 'driver_id' when calling DriversApi.get\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/drivers/{driverId}'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s).sub('{' + 'driverId' + '}', driver_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Bearer']\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 => 'Driver')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriversApi#get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def drivers\n send :adapters\n end", "def find_driver(id)\n return find_by_id(@drivers, id)\n end", "def index\n @driverslists = Driverslist.all\n end", "def index\n id = params[:id].to_i\n\n if id != 0\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find_all_by_id(id)\n if @agencies.any?\n @agency_name = @agencies.first.name\n end\n else\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find(:all)\n end\n\n\t\t@records_returned = @agencies.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @agencies }\n end\n end", "def show\n @driver_license_type = (DriverLicenseType.find_by_sql 'SELECT * FROM driver_license_type WHERE id = ' + params[:id])[0]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver_license_type }\n end\n end", "def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end", "def pending_drivers\n users = User.needing_driver_verification\n render :json => users, each_serializer: SlimPendingDriverSerializer, root: false, status: 200\n end", "def get_all_0_with_http_info(policy_activity_id, status, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriversApi.get_all_0 ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriversApi.get_all_0\"\n end\n # verify the required parameter 'status' is set\n if @api_client.config.client_side_validation && status.nil?\n fail ArgumentError, \"Missing the required parameter 'status' when calling DriversApi.get_all_0\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/drivers/{status}'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s).sub('{' + 'status' + '}', status.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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Bearer']\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<DriverSummary>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriversApi#get_all_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def driver_info\n return Rideshare::Driver.find(@driver_id)\n end", "def index\n @ride_drivers = RideDriver.all\n end", "def index\n admin_check\n @drivers = Driver.all\n end", "def get_drvies_with_http_info(year, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DrivesApi.get_drvies ...'\n end\n # verify the required parameter 'year' is set\n if @api_client.config.client_side_validation && year.nil?\n fail ArgumentError, \"Missing the required parameter 'year' when calling DrivesApi.get_drvies\"\n end\n # resource path\n local_var_path = '/drives'\n\n # query parameters\n query_params = {}\n query_params[:'year'] = year\n query_params[:'seasonType'] = opts[:'season_type'] if !opts[:'season_type'].nil?\n query_params[:'week'] = opts[:'week'] if !opts[:'week'].nil?\n query_params[:'team'] = opts[:'team'] if !opts[:'team'].nil?\n query_params[:'offense'] = opts[:'offense'] if !opts[:'offense'].nil?\n query_params[:'defense'] = opts[:'defense'] if !opts[:'defense'].nil?\n query_params[:'conference'] = opts[:'conference'] if !opts[:'conference'].nil?\n query_params[:'offenseConference'] = opts[:'offense_conference'] if !opts[:'offense_conference'].nil?\n query_params[:'defenseConference'] = opts[:'defense_conference'] if !opts[:'defense_conference'].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<Drive>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DrivesApi#get_drvies\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\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 get_all_with_http_info(policy_activity_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriversApi.get_all ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriversApi.get_all\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/drivers'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Bearer']\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<DriverSummary>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriversApi#get_all\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @references_vehicle_drivers = ReferencesVehicleDriver.all\n end", "def show\n @bluetooth = Bluetooth.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bluetooth }\n end\n end", "def index\n @devices = Device.all.includes(:browsers)\n json_response(@devices, :ok, [:browsers])\n end", "def driver_params\n json_api_params(Driver,[:first_name,:last_name,:phone_no,:plant_id, :user_id,:enabled]).fetch(:attributes, {})\n end", "def show\n @route = Route.find(params[:id])\n @driver = Hitchhiker.find(@route.hitchhiker_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @route }\n end\n end", "def driver\n @data[\"driver\"]\n end", "def index\n json_response(@device.browsers)\n end", "def set_driver\n cities = City.find(params[:city_id])\n @drivers = cities.drivers.find(params[:id])\n end", "def index\n @apis = Api.all\n end", "def index\n redirect_to search_drivers_path unless current_user and current_user.is_admin\n @drivers = Driver.all\n end", "def trip_get_driver(driver_id)\n RideShare::Driver.find(driver_id)\n end", "def getDriver\n @driver\n end", "def getDriver\n @driver\n end", "def show\n @trip_driver = TripDriver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip_driver }\n end\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def index\n @vehicles = Vehicle.all\n\n id = Vehicle.pluck(:api_id) # integer array\n\n \n end", "def series_get(id)\n begin\n api = \"#{$config['sonarr']['api_url']}/series/#{id}\"\n log_debug(api)\n uri = URI(api)\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json', 'X-Api-Key'=> $config['sonarr']['api_key'])\n \n json = {}\n json['id'] = id\n \n req.body = json.to_json\n res = http.request(req) \n json = JSON.parse(res.body)\n debug json\n rescue => e\n puts \"failed #{e}\"\n end\n end", "def hired\n authorize current_company, :index?\n @drivers = current_company.hired_drivers.distinct\n @drivers = @drivers.page(params[:page]).per(10)\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def show\n @adv = Advantage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @adv }\n end\n end", "def index\n @drivers_licesnses = DriversLicesnse.all\n end", "def drivers\n rides.map { |ride| ride.driver }\n end", "def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end", "def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end", "def add_drivers params\n @driver_hash = JSON.parse(params)\n\n @driver_hash['drivers'].each do |driver|\n add_driver(driver[\"id\"],driver[\"location\"])\n end\n true\n end", "def set_api_v1_scraper\n @api_v1_scraper = Api::V1::Scraper.find(params[:id])\n end", "def update\n\t\t\t\trespond_with Driver.update(params[:id],params[:driver])\n\t\t\tend", "def find(id)\n @api.get(\"api/#{id.to_s}.json\")\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def create\n\t\t\t\trespond_with Driver.create(params[:driver])\n\t\t\tend", "def show\n @vendor = Vendor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vendor }\n end\n end", "def drivers\n @drivers ||= ActiveSupport::HashWithIndifferentAccess.new\n end", "def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end", "def index\n\n @enterprise = current_user\n @drivers = @enterprise.drivers\n\n #logeando vista drivers con autos desde enterprise\n @cars = @enterprise.cars\n # @drivers = Driver.all\n end", "def drivers()\n self.rides().map { | ride | ride.driver }\n end", "def show\n @api = Api.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api }\n end\n end", "def details\n options = {}\n # include=driver\n # fields[driver]=average_rating\n if params[:fields]\n driver_fields = params[:fields].permit(:driver).to_h.\n inject({}) { |h, (k,v)| h[k.to_sym] = v.split(\",\").map(&:to_sym); h }\n options.merge!(fields: driver_fields)\n end\n\n # multiple associated resources are comma-separated\n if params[:include]\n options[:include] = params[:include].split(\",\").map(&:to_sym)\n end\n\n @trip = Trip.includes(:driver).find_by(id: params[:id])\n\n render json: TripSerializer.new(@trip, options).serializable_hash\n end", "def index\n @apis = Api.all(:order => \"query\")\n #@apis = Api.order(\"query\").page(params[:page]).per(20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apis }\n end\n end", "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\n @api = Api.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @api }\n end\n end", "def show\n @api_tag = Api::Tag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_tag }\n end\n end", "def find(vendor_id)\n @client.get(\"/#{@model}/#{vendor_id}\")\n end", "def index \n ip_addr = request.env['REMOTE_ADDR'] \n @browse_by = [[\"Browse By\",''],[\"Guides\",'1'],[\"Places\",'2']]\n @characteristics = [\"Latest\",'1'],[\"Most Popular\",'2'],[\"Highest Rated\",'3'],[\"Stress Factor\",'4']\n @notice = notice\n @guides = Guide.where(\"publish=?\",true).order(\"CREATED_AT DESC\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @guides }\n end\n end", "def devices(params={})\n res = @client.get(\"#{path}/devices\", params)\n\n res.json[\"devices\"].map{ |atts| ::M2X::Client::Device.new(@client, atts) } if res.success?\n end", "def index\n @offers = Offer.all\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n format.html { @offers }\n end\n end", "def index\n @driver_applications = DriverApplication.all\n end", "def show\n @hardware = Hardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hardware }\n end\n end", "def set_drivers_licesnse\n @drivers_licesnse = DriversLicesnse.find(params[:id])\n end", "def show\n @api_tracking = ApiTracking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_tracking }\n end\n end", "def driver_ids\n\t\tdrivers.map{|d| d.id.to_s + \"_\" + self.id.to_s}\n\tend", "def show\n @api_client = ApiClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_client }\n end\n end", "def show_by_hardware_id\n hardware_id = params[:id]\n hardware_type = params[:type]\n\n # optional\n lang_code = params[:lang]\n latitude = params[:lat]\n longitude = params[:lon]\n ble_major = params[:major]\n ble_minor = params[:minor]\n\n error = []\n if hardware_id.nil?\n error << 'id'\n end\n\n if hardware_type.nil?\n error << 'type'\n end\n\n # also require major und minor id by bluetooth beacons\n unless hardware_type.nil?\n if hardware_type == HardwaresHelper::TYPE_BLE\n if ble_major.nil?\n error << 'major'\n end\n\n if ble_minor.nil?\n error << 'minor'\n end\n end\n end\n\n if error.length > 0\n return_error_infos(400, 'Request values are missing', 'InvalidRequest', error)\n return\n end\n\n if hardware_type == HardwaresHelper::TYPE_BLE\n tag = Tag.show_by_ble_hardware_id(hardware_id, hardware_type, ble_major, ble_minor)\n else\n tag = Tag.show_by_hardware_id(hardware_id, hardware_type)\n end\n\n # add location to hardware\n unless latitude.nil? and longitude.nil? and tag.nil?\n tag.add_location_to_hardware(hardware_id, latitude, longitude)\n end\n\n # update scan counter\n unless tag.nil?\n tag_scanned(tag)\n end\n\n return_tag_infos(tag, lang_code)\n end", "def get_models_for_make_id_year\n render json: vehicle_service.get_models_for_make_id_year(params[:make_id], params[:make_year])\n end", "def nearby_drivers(args = {})\n make_request(\n http_method: :get,\n endpoint: path_for(:nearby_drivers),\n access_token: args.delete(:access_token),\n options: { query: args }\n )\n end", "def get(api, params={})\n url2json(:GET, \"#{@endpoint}#{api}\", params)\n end", "def show\n @api_haiku = Api::Haiku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_haiku }\n end\n end", "def show\n @ideium = Ideium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ideium }\n end\n end", "def update\n respond_with ApidDrive.update(params[:id], params[:apid_driver])\n rescue ActiveRecord::RecordNotFound\n respond_with ApidDrive::StateChangeError\n end", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def show\n @api_method = ApiMethod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_method }\n end\n end", "def api_object\n unless $api\n $api = FyberAPI.new(\n 'b07a12df7d52e6c118e5d47d3f9e60135b109a1f',\n {\n appid: 157,\n format: 'json',\n device_id: '2b6f0cc904d137be2e1730235f5664094b83',\n locale: 'de',\n ip: '109.235.143.113'\n }\n )\n end\n $api\n end", "def index\n\t\t\t\t# @reviews = Driver.find_by!(id: params[:driver_id]).driver_reviews#.order('created_at DESC').to_a\n\t\t\t\t@reviews = DriverReview.where(driver_id: params[:driver_id])\n\t\t\tend", "def data_providers_id_browse_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DataProvidersApi.data_providers_id_browse_get ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling DataProvidersApi.data_providers_id_browse_get\"\n end\n # resource path\n local_var_path = '/data_providers/{id}/browse'.sub('{' + 'id' + '}', 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', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BrainPortalSession']\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<FileInfo>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DataProvidersApi#data_providers_id_browse_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end" ]
[ "0.66801065", "0.66517365", "0.66517365", "0.66512454", "0.664052", "0.6602897", "0.6602897", "0.6591169", "0.6476339", "0.640531", "0.6326954", "0.6326954", "0.6318182", "0.6195097", "0.6136131", "0.61184335", "0.60221756", "0.60011137", "0.59053755", "0.5863376", "0.5785017", "0.57771754", "0.5772896", "0.5709422", "0.570523", "0.56899357", "0.5662959", "0.56520945", "0.56477416", "0.5645615", "0.5644804", "0.56232756", "0.5613101", "0.55330867", "0.5520593", "0.54971474", "0.5494987", "0.5478141", "0.5466453", "0.5449974", "0.5426125", "0.541982", "0.5413072", "0.5411337", "0.5393365", "0.5393365", "0.5388438", "0.5378489", "0.5378489", "0.5372293", "0.53698134", "0.5359115", "0.5354528", "0.5354528", "0.5354528", "0.5354528", "0.5352898", "0.53407276", "0.532948", "0.5327739", "0.5326234", "0.53207624", "0.5314647", "0.5311627", "0.5308805", "0.5308079", "0.529974", "0.5296273", "0.5296256", "0.52944773", "0.5287111", "0.52725464", "0.5270805", "0.5266793", "0.52475095", "0.5232291", "0.5230846", "0.52298445", "0.5222192", "0.5219724", "0.52186465", "0.5218537", "0.52129513", "0.5206856", "0.52026755", "0.52020484", "0.52013785", "0.5199312", "0.5191293", "0.5190704", "0.5178445", "0.5173773", "0.51574165", "0.5151403", "0.51424766", "0.5136177", "0.51341665", "0.51329184", "0.5125626", "0.51105106" ]
0.6257913
13
POST /apid_drivers POST /apid_drivers.json
def create respond_with :api,:v1, ApidDriver.create_or_update(params[:apid_driver]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\t\t\t\trespond_with Driver.create(params[:driver])\n\t\t\tend", "def add_drivers params\n @driver_hash = JSON.parse(params)\n\n @driver_hash['drivers'].each do |driver|\n add_driver(driver[\"id\"],driver[\"location\"])\n end\n true\n end", "def create\n # Logic to create a driver and submit to DB\n @driver = Driver.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, location: @driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @driver = Driver.new(driver_params)\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render action: 'show', status: :created, location: @driver }\n else\n format.html { render action: 'new' }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @driver = @event.drivers.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n\n for i in [email protected] do\n @waitlistrider = @event.riders.find_by_waitlist(true)\n @waitlistrider.update_driver(@driver.id) if @waitlistrider\n @waitlistrider.update_waitlist if @waitlistrider\n end\n\n @driver.update_full\n\n format.html { redirect_to [@event, @driver], notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, location: @driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @driver = Driver.create(driver_params)\n @user = current_user\n @driver.set_user!(current_user)\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render :show, status: :created, location: @driver }\n else\n format.html { render :new }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def driver_params\n params.require(:driver).permit(:driver_name, :driver_id, :driver_dob, :driver_address, :email, :phone_number, :trailer_capacity, :image)\n end", "def driver_params\n params.require(:driver).permit(:CNP, :FIRSTNAME, :SECONDNAME, :StartDate, :EndDate, :INFO, :DESCRIPTION, :active, images: [])\n end", "def driver_params\n params.require(:driver).permit(:name, :age, :city_id, :company_id)\n end", "def driver_params\n json_api_params(Driver,[:first_name,:last_name,:phone_no,:plant_id, :user_id,:enabled]).fetch(:attributes, {})\n end", "def driver_params\n params.require(:driver).permit(:user_id, :registration_number, :car_info)\n end", "def create\n @car = Car.find(params[:car_id])\n @driver = @car.drivers.create(params[:driver])\n redirect_to car_path(@car)\n end", "def driver_params\n params.require(:driver).permit(:name, :tel, :car_number)\n end", "def driver_params\n params.require(:driver).permit(:badge, :name)\n end", "def create\n @references_vehicle_driver = ReferencesVehicleDriver.new(references_vehicle_driver_params)\n\n respond_to do |format|\n if @references_vehicle_driver.save\n @dato = ReferencesVehicleDriver.last\n @dato.token = @dato.driver_id.to_s + @dato.VehiclePerUsuario_id.to_s + @dato.driver.identityCard.to_s\n @dato.save\n format.html { redirect_to profile_index_path, notice: 'References vehicle driver was successfully created.' }\n format.json { render :show, status: :created, location: @references_vehicle_driver }\n else\n format.html { render :new }\n format.json { render json: @references_vehicle_driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def driver_params\n params.require(:driver).permit(:name, :email, :phone, :location, :service_type, :password, :password_confirmation)\n end", "def create\n @driver_record = DriverRecord.new(params[:driver_record])\n respond_to do |format|\n if @driver_record.save\n format.html { redirect_to @driver_record, notice: 'Driver record was successfully created.' }\n format.json { render json: @driver_record, status: :created, location: @driver_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @driverslist = Driverslist.new(driverslist_params)\n\n respond_to do |format|\n if @driverslist.save\n format.html { redirect_to @driverslist, notice: 'Driverslist was successfully created.' }\n format.json { render :show, status: :created, location: @driverslist }\n else\n format.html { render :new }\n format.json { render json: @driverslist.errors, status: :unprocessable_entity }\n end\n end\n end", "def driverslist_params\n params.require(:driverslist).permit(:name)\n end", "def create\n @driver = Driver.new(driver_params)\n respond_to do |format|\n if @driver.save\n login_driver @driver\n format.html { redirect_to @driver, notice: \"Welcome #{@driver.name.upcase}. Your account was successfully created\" }\n format.json { render :show, status: :created, location: @driver }\n else\n format.html { render :new }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def driver_params\n params.require(:driver).permit(:license_plate_number)\n end", "def create\n @driver = Driver.new(driver_params)\n @driver.user_id = current_user.id\n\n url = \"https://dvlasearch.appspot.com/DvlaSearch?apikey=#{Rails.application.credentials.dvla[:dvla_api_key]}&licencePlate=#{@driver.registration_number}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n @hash = JSON.parse(response)\n\n if @hash.key?(\"make\")\n @driver.car_info = @hash[\"colour\"] + \" \" + @hash[\"make\"] + \" \" + @hash[\"model\"]\n else\n @driver.car_info = \"Registration number not linked to vehicle!!!\"\n end\n\n @driver.registration_number.upcase!\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Car information registered successfully!' }\n format.json { render :show, status: :created, location: @driver }\n else\n format.html { render :new }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_driver\n address = params[:newdriveraddress]\n\n coordinates = GoogleAPIGeocoder.do_geocode(address)\n\n if coordinates.nil?\n render json: {success: false, travellers: session[:travellers].to_json, msg: 'Unable to find the location of the given address for the new driver. Please check that it is correct.'}\n else\n driver = Driver.create(name: params[:newdrivername],\n email: params[:newdriveremail],\n address: address,\n number_of_passengers: params[:newdrivernumber_of_passengers],\n latitude: coordinates[0],\n longitude: coordinates[1])\n\n unless session[:travellers].nil?\n session[:travellers] << driver\n else\n travellers = []\n travellers << driver\n session[:travellers] = travellers\n end\n\n if current_user.nil? && !session[:trip].nil?\n session[:trip].travellers << driver\n end\n\n render json: session[:travellers].to_json\n end\n end", "def set_driverslist\n @driverslist = Driverslist.find(params[:id])\n end", "def create_driver name\n\t\tdriver = Driver.new name\n\t\t@drivers[driver.name] = driver\n\t\tdriver\t\t\n\tend", "def create\n @driver = Driver.new(driver_params)\n\n if @driver.images.count>0\n @driver.images.attach(params[:driver][:images])\n end\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render :show, status: :created, location: @driver }\n else\n format.html { render :new }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def driver_params\n params.fetch(:driver).permit(:image, :rut, :password, :email, :name, :lastname, :surname,:address, :commune, :state, :city, :country, :phone, :school, :work_child, :type_driver_license, :info_emergency, :enterprise_id)\n end", "def create\n @device.browsers.create!(browser_params)\n json_response(@device, :created)\n end", "def get_drivers\n drivers\n end", "def create\n\n if current_user\n @driver = Driver.new(driver_params)\n @driver.role = 1\n @driver.enterprise = current_user\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to enterprise_drivers_path, notice: 'Driver was successfully created.' }\n format.json { render :show, status: :created, location: @driver }\n else\n format.html { render :new }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to enterprise_drivers_path, alert: 'Debes completar tu perfil antes de crear Conductores!'\n end\n end", "def create_firmware_driver_distributable_with_http_info(firmware_driver_distributable, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FirmwareApi.create_firmware_driver_distributable ...'\n end\n # verify the required parameter 'firmware_driver_distributable' is set\n if @api_client.config.client_side_validation && firmware_driver_distributable.nil?\n fail ArgumentError, \"Missing the required parameter 'firmware_driver_distributable' when calling FirmwareApi.create_firmware_driver_distributable\"\n end\n # resource path\n local_var_path = '/api/v1/firmware/DriverDistributables'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(firmware_driver_distributable)\n\n # return_type\n return_type = opts[:debug_return_type] || 'FirmwareDriverDistributable'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"FirmwareApi.create_firmware_driver_distributable\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FirmwareApi#create_firmware_driver_distributable\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end", "def pending_drivers\n users = User.needing_driver_verification\n render :json => users, each_serializer: SlimPendingDriverSerializer, root: false, status: 200\n end", "def references_vehicle_driver_params\n params.require(:references_vehicle_driver).permit(:driver_id, :usuario_id, :VehiclePerUsuario_id, :fechaInicio, :fechaFin, :commission, :token, :description)\n end", "def drivers\n send :adapters\n end", "def create\n event = Event.find(params[:event_id])\n @driver = @current_user.drivers.build(params[:driver])\n @driver.event = event\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to event_url(@driver.event),\n notice: 'Driver was successfully allocated.' }\n format.json { render json: @driver, status: :created, location: @driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n expire_fragment \"event-#{@driver.event.id}\"\n end", "def add_driver id, location\n #return false unless null == @drivers[id]\n\n @drivers.merge!Hash[id, Integer(location)]\n puts(\"Added Driver #{id}, #{location}\")\n true\n end", "def set_driver\n id = params[:driver_id] || params[:id]\n @driver = Driver.find_by(id: id)\n end", "def create\n @shipment = Shipment.new(shipment_params)\n @shipment.purchase_order = PurchaseOrder.new(grand_total: 0, shipping: 0, sub_total: 0)\n @driver = nil\n if !(params[:shipment][:drivers].nil?)\n params[:shipment][:drivers].each do |d|\n @driver = Employee.find_by(id: d.to_i)\n @shipment.drivers << @driver\n end\n end\n respond_to do |format|\n if @shipment.save\n format.html { redirect_to @shipment, notice: 'Shipment was successfully created.' }\n format.json { render :show, status: :created, location: @shipment }\n else\n format.html { render :new }\n format.json { render json: @shipment.errors, status: :unprocessable_entity }\n end\n end\n end", "def vehicle_params\n params.require(:vehicle).permit(:api_id, :api_vehicle_company_id, :number, :status, :ifta, :vin, :make, :model, :year, :license_plate_state, :license_plate_number, :metric_units, :fuel_type, :prevent_auto_odometer_entry, :edl_device_id, :edl_identifier, :edl_model, :api_driver_id, :driver_first_name, :driver_last_name, :driver_username, :driver_email, :driver_internal_id, :driver_status, :driver_role)\n end", "def create\n @driver_log = DriverLog.new(driver_log_params)\n\n respond_to do |format|\n if @driver_log.save\n format.html { redirect_to @driver_log, notice: 'Driver log was successfully created.' }\n format.json { render :show, status: :created, location: @driver_log }\n else\n format.html { render :new }\n format.json { render json: @driver_log.errors, status: :unprocessable_entity }\n end\n end\n end", "def driver(driver_id)\n from_resource(\n :driver,\n connection.get(api_uri(\"drivers/#{driver_id}\"))\n )\n end", "def new\n @driver = Driver.new(:event_id => params[:event_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @driver }\n end\n end", "def create\n @drivers_licesnse = DriversLicesnse.new(drivers_licesnse_params)\n\n respond_to do |format|\n if @drivers_licesnse.save\n format.html { redirect_to @drivers_licesnse, notice: 'Drivers licesnse was successfully created.' }\n format.json { render :show, status: :created, location: @drivers_licesnse }\n else\n format.html { render :new }\n format.json { render json: @drivers_licesnse.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def update\n\t\t\t\trespond_with Driver.update(params[:id],params[:driver])\n\t\t\tend", "def set_driver\n cities = City.find(params[:city_id])\n @drivers = cities.drivers.find(params[:id])\n end", "def create\n @trip_driver = TripDriver.new(trip_driver_params)\n\n respond_to do |format|\n if @trip_driver.save\n format.html { redirect_to @trip_driver, notice: 'Trip driver was successfully created.' }\n format.json { render json: @trip_driver, status: :created, location: @trip_driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trip_driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ride = Ride.new(driver_ride_params.merge(\n driver: current_user,\n created_by: current_user,\n notification_subscriptions: [RideNotificationSubscription.new(\n user: current_user,\n app: :driver\n )],\n ))\n\n respond_to do |format|\n if @ride.save\n format.html { redirect_to driver_ride_path(@ride),\n notice: 'Ride was successfully created.' }\n format.json { render :show, status: :created, location: @ride }\n else\n format.html { render :new }\n format.json { render json: @ride.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @drivers = Driver.all\n end", "def index\n @drivers = Driver.all\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def driver_params\n params.require(:driver).permit(:name,:last_name,:user,:password, :password_confirmation,:email,:city_id, :picture)\n end", "def create\n @driver_profile = DriverProfile.new(driver_profile_params)\n\n respond_to do |format|\n if @driver_profile.save\n format.html { redirect_to @driver_profile, notice: 'Driver profile was successfully created.' }\n format.json { render :show, status: :created, location: @driver_profile }\n post_request\n else\n flash[:error] = \"#{@driver_profile.errors.full_messages.to_sentence}\"\n format.html { render :new }\n format.json { render json: @driver_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @route = Route.new(route_params)\n @route.driver_id = @driver.id\n respond_to do |format|\n if @route.save\n format.html { redirect_to driver_path(@route.driver_id ), notice: 'Route was successfully created.' }\n format.json { render :show, status: :created, location: @route }\n else\n format.html { render :new }\n format.json { render json: @route.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @driver_record = DriverRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @driver_record }\n end\n end", "def create\n\t\t\t\tcurrent_driver.create_car(car_params)\n\t\t\tend", "def create\n @driver_division = DriverDivision.new(driver_division_params)\n\n respond_to do |format|\n if @driver_division.save\n format.html { redirect_to @driver_division, notice: 'Driver division was successfully created.' }\n format.json { render action: 'show', status: :created, location: @driver_division }\n else\n format.html { render action: 'new' }\n format.json { render json: @driver_division.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize\n @drivers = []\n end", "def index\n respond_with ApidDriver.all\n end", "def post(api, params)\n url2json(:POST, \"#{@endpoint}#{api}\", params)\n end", "def create_trip trip, driver_name\n\t\tif @drivers.has_key? driver_name\t\t\t\n\t\t\t@drivers[driver_name].add_trip trip\n\t\telse\n\t\t\tputs \"No driver #{driver_name} registered, created a new driver\"\n\t\t\tdriver = self.create_driver driver_name\n\t\t\tdriver.add_trip trip\n\t\tend\t\n\tend", "def get_driver_details\n @resource = Resource.find(params[:id])\n @driver = Driver.find(AgencyStore.find_by_resource_id(params[:id]).driver_id)\n render :layout => false\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def initialize(driver, api)\n @driver = driver\n @api = api\n end", "def driver_params\n params.permit(:school_id, :username, :password, :vehicle_id)\n end", "def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def drivers\n @drivers ||= ActiveSupport::HashWithIndifferentAccess.new\n end", "def create\n @driver_journey = DriverJourney.new(driver_journey_params)\n\n respond_to do |format|\n if @driver_journey.save\n format.html { redirect_to journeys_path, notice: 'Driver journey was successfully created.' }\n format.json { render action: 'show', status: :created, location: @driver_journey }\n else\n format.html { render action: 'new' }\n format.json { render json: @driver_journey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @driver_application = DriverApplication.new(driver_application_params)\n \n # Always get the current time to save\n @driver_application.created_at = DateTime.current\n\n respond_to do |format|\n if @driver_application.save\n format.html { redirect_to @driver_application, notice: 'Driver application was successfully created.' }\n format.json { render :show, status: :created, location: @driver_application }\n else\n format.html { render :new }\n format.json { render json: @driver_application.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_api(path, params={}, headers={})\n headers.merge!('CONTENT_TYPE' => \"application/json\")\n post path, params, headers\nend", "def driver_license_params\n params.require(:driver_license).permit(:code, :name, :active, :verified, :country_id, :series_number,\n :category, :issued_by, :issued_code, :issued_date, :valid_to, :note)\n end", "def create\n @agencium = Agencium.new(agencium_params)\n\n respond_to do |format|\n if @agencium.save\n format.html { redirect_to @agencium, notice: 'Agencium was successfully created.' }\n format.json { render :show, status: :created, location: @agencium }\n else\n format.html { render :new }\n format.json { render json: @agencium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api = Api.new(api_params)\n current_user.apis << @api\n respond_to do |format|\n\n if @api.save\n format.html { redirect_to user_path(current_user), notice: 'Api-nyckeln har skapats' }\n format.json { render :show, status: :created, location: @api }\n else\n format.html { render :new }\n format.json { render json: @api.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_driver(name)\n path = File.expand_path(DIR + '/' + WSDL_PATHS[name])\n wsdl = SOAP::WSDLDriverFactory.new(path)\n driver = wsdl.create_rpc_driver\n # /s+(1000|0|9c9|fcc)\\s+/ => \"\"\n driver.wiredump_dev = STDOUT if @debug\n \n driver\n end", "def create\n @dapi = Dapi.new(dapi_params)\n\n respond_to do |format|\n if @dapi.save\n format.html { redirect_to @dapi, notice: 'Dapi was successfully created.' }\n format.json { render :show, status: :created, location: @dapi }\n else\n format.html { render :new }\n format.json { render json: @dapi.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize\n @drivers = Array.new\n end", "def supporter_params\n params.require(:api_supporter).permit(:name, :email, :phone)\n end", "def get_drivers\n return return_all_drivers\n end", "def save_driver\n authorize current_company\n current_company.update_attribute(:saved_drivers_ids, current_company.saved_drivers_ids + [params[:id].to_i])\n flash[:notice] = \"Driver added to saved for later.\"\n redirect_back fallback_location: root_path\n end", "def create_with_http_info(policy_activity_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriverAssignmentsApi.create ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriverAssignmentsApi.create\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/driverassignments'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s)\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json-patch+json', 'application/json', 'text/json', 'application/*+json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(opts[:'driver_assignment'])\n auth_names = opts[:auth_names] || ['Bearer']\n\n # return_type\n return_type = opts[:return_type] || 'DriverAssignment'\n\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 => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriverAssignmentsApi#create\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def driver\n @data[\"driver\"]\n end", "def ride_driver_params\n params.require(:trip_driver).permit(:user_id, :ride_id)\n end", "def add_device(serial)\n res = @client.post(\"#{path}/devices\", nil, { serial: serial }, \"Content-Type\" => \"application/json\")\n Device.new(@client, res.json) if res.success?\n end", "def create\n @device = Device.create!(device_params)\n json_response(@device, :created)\n end", "def create_agent_via_api(agent_type, opts = {})\n case agent_type\n when :person\n agent_json = if opts[:create_subrecords]\n build(:json_agent_person_full_subrec)\n else\n build(:json_agent_person)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/people\")\n when :corporate_entity\n agent_json = if opts[:create_subrecords]\n build(:json_agent_corporate_entity_full_subrec)\n else\n build(:json_agent_corporate_entity)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/corporate_entities\")\n when :family\n agent_json = if opts[:create_subrecords]\n build(:json_agent_family_full_subrec)\n else\n build(:json_agent_familly)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/families\")\n when :software\n agent_json = if opts[:create_subrecords]\n build(:json_agent_software_full_subrec)\n else\n build(:json_agent_software)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/software\")\n end\n\n response = JSONModel::HTTP.post_json(url, agent_json.to_json)\n json_response = ASUtils.json_parse(response.body)\n\n if json_response['status'] == 'Created'\n json_response['id']\n else\n -1\n end\nrescue StandardError => e\n -1\nend", "def new_provider(port,bool)\n stub_framework(bool)\n fill_in \"provider[name]\", :with => \"ec2-testprovider\"\n fill_in \"provider[url]\", :with => \"http://localhost:#{port}/api\"\n select(\"Amazon EC2\", :from => \"provider_provider_type_id\")\n click_button \"Create Provider\"\nend", "def set_driver\n return if params[:id] == 'submit_query'\n @driver = Driver.find(params[:id])\n end", "def get_firmware_driver_distributable_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FirmwareApi.get_firmware_driver_distributable_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling FirmwareApi.get_firmware_driver_distributable_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/firmware/DriverDistributables/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'FirmwareDriverDistributable'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"FirmwareApi.get_firmware_driver_distributable_by_moid\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FirmwareApi#get_firmware_driver_distributable_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end" ]
[ "0.67292213", "0.6542204", "0.64566", "0.6414626", "0.6359257", "0.61984324", "0.60098124", "0.5945948", "0.591286", "0.5858562", "0.58171153", "0.57804334", "0.57344794", "0.57307833", "0.57247764", "0.57038593", "0.5645948", "0.5642996", "0.56396645", "0.5632334", "0.5487429", "0.54815406", "0.5481321", "0.54693913", "0.5451937", "0.5450022", "0.5402496", "0.5394954", "0.53907746", "0.5341323", "0.53231955", "0.5319108", "0.5319108", "0.53090936", "0.52943087", "0.52796954", "0.5270181", "0.5253172", "0.5234658", "0.52221173", "0.51929754", "0.5182882", "0.5156874", "0.51493895", "0.51472545", "0.5146715", "0.5146715", "0.5146715", "0.5146715", "0.51421523", "0.51421523", "0.5133286", "0.5123374", "0.5117051", "0.5116837", "0.5063514", "0.5063514", "0.50543547", "0.5036034", "0.50186837", "0.49994147", "0.49835914", "0.49672583", "0.49613893", "0.49576572", "0.4953125", "0.49509317", "0.49399748", "0.49330124", "0.49217197", "0.49217197", "0.49217197", "0.49217197", "0.49217197", "0.49217197", "0.49208885", "0.49155724", "0.49155724", "0.48969674", "0.48955935", "0.48880157", "0.48820066", "0.48765442", "0.48620543", "0.48503163", "0.48410946", "0.4837808", "0.48377943", "0.48364908", "0.48364848", "0.48259917", "0.48180375", "0.48156005", "0.4812001", "0.4783435", "0.4769694", "0.47641057", "0.47587195", "0.47553828", "0.4752876" ]
0.70627916
0
PUT /apid_drivers/1 PUT /apid_drivers/1.json
def update respond_with ApidDrive.update(params[:id], params[:apid_driver]) rescue ActiveRecord::RecordNotFound respond_with ApidDrive::StateChangeError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n\t\t\t\trespond_with Driver.update(params[:id],params[:driver])\n\t\t\tend", "def create\n respond_with :api,:v1, ApidDriver.create_or_update(params[:apid_driver])\n end", "def update\n #@driver = Driver.find(params[:id])\n @driver = @event.drivers.find(params[:id])\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to [@event, @driver], notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Logic to edit a driver and submit to DB\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_driverslist\n @driverslist = Driverslist.find(params[:id])\n end", "def create\n @driver = @event.drivers.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n\n for i in [email protected] do\n @waitlistrider = @event.riders.find_by_waitlist(true)\n @waitlistrider.update_driver(@driver.id) if @waitlistrider\n @waitlistrider.update_waitlist if @waitlistrider\n end\n\n @driver.update_full\n\n format.html { redirect_to [@event, @driver], notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, location: @driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_driver\n id = params[:driver_id] || params[:id]\n @driver = Driver.find_by(id: id)\n end", "def set_driver\n cities = City.find(params[:city_id])\n @drivers = cities.drivers.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update_driver_details \n\t\tcurrent_user.license_plate = user_params[:license_plate]\n\t\tcurrent_user.car_model = user_params[:car_model]\n\t\tcurrent_user.save!\n\t\trender json: {\n\t\t\tstatus: 'succeess',\n\t\t\tmessage: 'Driver Details Updated!'\n\t\t}, status: 200\n\tend", "def update\n respond_to do |format|\n if @driverslist.update(driverslist_params)\n format.html { redirect_to @driverslist, notice: 'Driverslist was successfully updated.' }\n format.json { render :show, status: :ok, location: @driverslist }\n else\n format.html { render :edit }\n format.json { render json: @driverslist.errors, status: :unprocessable_entity }\n end\n end\n end", "def driver_params\n params.require(:driver).permit(:name, :age, :city_id, :company_id)\n end", "def set_driver\n @driver = Driver.find(params[:id])\n end", "def add_drivers params\n @driver_hash = JSON.parse(params)\n\n @driver_hash['drivers'].each do |driver|\n add_driver(driver[\"id\"],driver[\"location\"])\n end\n true\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n\n url = \"https://dvlasearch.appspot.com/DvlaSearch?apikey=#{Rails.application.credentials.dvla[:dvla_api_key]}&licencePlate=#{@driver.registration_number}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n @hash = JSON.parse(response)\n\n if @hash.key?(\"make\")\n @driver.car_info = @hash[\"colour\"] + \" \" + @hash[\"make\"] + \" \" + @hash[\"model\"]\n else\n @driver.car_info = \"Registration number not linked to vehicle.\"\n end\n\n @driver.registration_number.upcase!\n\n @driver.save!\n\n format.html { redirect_to @driver, notice: 'Details updated successfully.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ride_driver.update(ride_driver_params)\n format.html { redirect_to @ride_driver, notice: 'Ride driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ride_driver.errors, status: :unprocessable_entity }\n end\n end\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 add_driver id, location\n #return false unless null == @drivers[id]\n\n @drivers.merge!Hash[id, Integer(location)]\n puts(\"Added Driver #{id}, #{location}\")\n true\n end", "def update(attrs)\n attrs.each do |meth, value|\n send(\"#{meth}=\", value)\n end\n @driver.save\n end", "def update(attrs)\n attrs.each do |meth, value|\n send(\"#{meth}=\", value)\n end\n @driver.save\n end", "def update\n @driver_record = DriverRecord.find(params[:id])\n\n respond_to do |format|\n if @driver_record.update_attributes(params[:driver_record])\n format.html { redirect_to @driver_record, notice: 'Driver record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api\n @api = Api.find(params[:id])\n end", "def set_api\n @api = Api.find(params[:id])\n end", "def set_api\n @api = Api.find(params[:id])\n end", "def putDeviceInfo(info)\r\n params = {\r\n :software_version => info.swVersion,\r\n :serial_number => info.serialNb\r\n }\r\n res = apiPut(\"devices/#{info.deviceId}\", params)\r\n if res.status != 200\r\n $LOG.warn(\"Failed to put device info to backend! Status: #{res.status}, Response: #{res.body}\")\r\n end\r\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n # @driver.set_location_goride(params[:location])\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.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 save_driver\n authorize current_company\n current_company.update_attribute(:saved_drivers_ids, current_company.saved_drivers_ids + [params[:id].to_i])\n flash[:notice] = \"Driver added to saved for later.\"\n redirect_back fallback_location: root_path\n end", "def update\n respond_to do |format|\n if @references_vehicle_driver.update(references_vehicle_driver_params)\n format.html { redirect_to @references_vehicle_driver, notice: 'References vehicle driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @references_vehicle_driver }\n else\n format.html { render :edit }\n format.json { render json: @references_vehicle_driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update attrs\n put '', :body => {self.class.api_name => self.class.opts_to_query_opts(attrs)}\n end", "def set_api_v1_booking\n @api_v1_booking = Booking.find(params[:id])\n end", "def update_firmware(attributes = {})\n patch('replace', '/firmware', attributes)\n end", "def create\n\t\t\t\trespond_with Driver.create(params[:driver])\n\t\t\tend", "def update\n ethers, new_ethers = process_ethers(params[:asset])\n @asset = WirelessDevice.find(params[:id])\n asset_update(params[:asset], wireless_url, ethers, new_ethers)\n end", "def set_references_vehicle_driver\n @references_vehicle_driver = ReferencesVehicleDriver.find(params[:id])\n end", "def app_update\n \tapi_detail = ApiDetail.find_by(api_version: 'v1', device_type: 0)\n render_success(api_detail_result(api_detail)) \n end", "def update id, rssi, status, battery\n unless @sensors[id]\n @sensors[id] = Sensor.new(id)\n end\n @sensors[id].rssi = rssi\n @sensors[id].name = \"GSS_13M_??\"\n @sensors[id].group = \"GSS_13M\"\n @sensors[id].updated_time = Time.now\n @sensors[id].last_press_time = Time.now if status == 1\n @sensors[id].battery = battery\n end", "def set_api_v1_sighting\n @api_v1_sighting = Api::V1::Sighting.find(params[:id])\n end", "def app_update\n \tapi_detail = ApiDetail.find_by(api_version: 'v1', device_type: 0)\n render_success(api_detail_result(api_detail)) \n end", "def set_api_v1_resource\n @api_v1_resource = Api::V1::Resource.find(params[:id])\n end", "def driver_params\n params.require(:driver).permit(:user_id, :registration_number, :car_info)\n end", "def set_api_v1_scraper\n @api_v1_scraper = Api::V1::Scraper.find(params[:id])\n end", "def vehicle_params\n params.require(:vehicle).permit(:api_id, :api_vehicle_company_id, :number, :status, :ifta, :vin, :make, :model, :year, :license_plate_state, :license_plate_number, :metric_units, :fuel_type, :prevent_auto_odometer_entry, :edl_device_id, :edl_identifier, :edl_model, :api_driver_id, :driver_first_name, :driver_last_name, :driver_username, :driver_email, :driver_internal_id, :driver_status, :driver_role)\n end", "def set_driver_route\n @driver_route = DriverRoute.find_by_token!(params[:id])\n end", "def driver_params\n params.require(:driver).permit(:driver_name, :driver_id, :driver_dob, :driver_address, :email, :phone_number, :trailer_capacity, :image)\n end", "def set_api_v1_initiative_update\n @api_v1_initiative_update = Api::V1::InitiativeUpdate.find(params[:id])\n end", "def driver_params\n params.require(:driver).permit(:name, :tel, :car_number)\n end", "def update\n @trip_driver = TripDriver.find(params[:id])\n\n respond_to do |format|\n if @trip_driver.update_attributes(trip_driver_params)\n format.html { redirect_to @trip_driver, notice: 'Trip driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip_driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_ride_driver\n @ride_driver = RideDriver.find(params[:id])\n end", "def update\n respond_to do |format|\n if @drivers_licesnse.update(drivers_licesnse_params)\n format.html { redirect_to @drivers_licesnse, notice: 'Drivers licesnse was successfully updated.' }\n format.json { render :show, status: :ok, location: @drivers_licesnse }\n else\n format.html { render :edit }\n format.json { render json: @drivers_licesnse.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update_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 set_api_v1_company\n @api_v1_company = Api::V1::Company.find(params[:id])\n end", "def create\n @car = Car.find(params[:car_id])\n @driver = @car.drivers.create(params[:driver])\n redirect_to car_path(@car)\n end", "def update\n @driver_license_type = DriverLicenseType.find(params[:id])\n\n respond_to do |format|\n if @driver_license_type.update_attributes(params[:driver_license_type])\n format.html { redirect_to @driver_license_type, notice: 'Driver license type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver_license_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def driver(driver_id)\n from_resource(\n :driver,\n connection.get(api_uri(\"drivers/#{driver_id}\"))\n )\n end", "def set_api\n @api = Api.find(params[:id])\n rescue\n @api = Api.new\n end", "def update\n @adv = Advantage.find(params[:id])\n\n respond_to do |format|\n if @adv.update_attributes(params[:advantage])\n format.html { redirect_to @adv, notice: 'Advantage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @adv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @api_tag = Api::Tag.find(params[:id])\n\n respond_to do |format|\n if @api_tag.update_attributes(params[:api_tag])\n format.html { redirect_to @api_tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @driver = Driver.find(params[:id])\n @driver.user = @current_user\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to event_url(@driver.event),\n notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n expire_fragment \"event-#{@driver.event.id}\"\n end", "def driverslist_params\n params.require(:driverslist).permit(:name)\n end", "def set_api_v1_initiative\n @api_v1_initiative = Api::V1::Initiative.find(params[:id])\n end", "def update\n @platform = Platform.find(params[:id])\n banners = Banner.where(:id => params[:platform].delete(:banners))\n @platform.banners = banners\n\n respond_to do |format|\n if @platform.update_attributes(params[:platform])\n format.html { redirect_to @platform, notice: 'Platform was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @platform.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_firmware_driver_distributable_with_http_info(moid, firmware_driver_distributable, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FirmwareApi.update_firmware_driver_distributable ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling FirmwareApi.update_firmware_driver_distributable\"\n end\n # verify the required parameter 'firmware_driver_distributable' is set\n if @api_client.config.client_side_validation && firmware_driver_distributable.nil?\n fail ArgumentError, \"Missing the required parameter 'firmware_driver_distributable' when calling FirmwareApi.update_firmware_driver_distributable\"\n end\n # resource path\n local_var_path = '/api/v1/firmware/DriverDistributables/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(firmware_driver_distributable)\n\n # return_type\n return_type = opts[:debug_return_type] || 'FirmwareDriverDistributable'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"FirmwareApi.update_firmware_driver_distributable\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FirmwareApi#update_firmware_driver_distributable\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def set_api_v1_armor\n @armor = Armor.find(params[:id])\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def create\n # Logic to create a driver and submit to DB\n @driver = Driver.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, location: @driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_service(id, options={})\n self.class.put(\"/services/#{id}.json?apikey=#{apikey}\", :query => {:service => options}, :body => {})\n end", "def update_bridge_model(name, body={}, headers=default_headers)\n @logger.info(\"Updating the \\\"#{name}\\\" Bridge Model.\")\n put(\"#{@api_url}/models/#{encode(name)}\", body, headers)\n end", "def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end", "def crud_put(resource_name, service_name, primary_key_name, api_options = {})\n api_options = get_defaults(api_options)\n put '/'+resource_name+'/:'+primary_key_name do\n service = settings.send(service_name)\n\n # Must Exist\n return 404 unless service.exists_by_primary_key?(params[primary_key_name.to_sym])\n\n # Get The Data\n begin\n data = JSON.parse(request.body.read)\n rescue Exception => e\n return 422\n end\n\n # Valid Update?\n return 422 unless service.valid_update?(data)\n\n # Do Update\n record = service.update_by_primary_key(params[primary_key_name.to_sym],data)\n\n # Other Error\n return 500 if record.nil?\n\n # Return new Region\n JSON.fast_generate record\n end\n end", "def set_vehicle(id, params)\n fleet[id] = RoutificApi::Vehicle.new(id, params)\n end", "def app_update\n \tapi_detail = ApiDetail.find_by(api_version: 'v1-merchant', device_type: 0)\n render_success(api_detail_result(api_detail)) \n end", "def references_vehicle_driver_params\n params.require(:references_vehicle_driver).permit(:driver_id, :usuario_id, :VehiclePerUsuario_id, :fechaInicio, :fechaFin, :commission, :token, :description)\n end", "def create\n @driver = Driver.new(driver_params)\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render action: 'show', status: :created, location: @driver }\n else\n format.html { render action: 'new' }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_drivers_licesnse\n @drivers_licesnse = DriversLicesnse.find(params[:id])\n end", "def set_api(*args); end", "def set_api(*args); end", "def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end", "def driver_params\n params.require(:driver).permit(:name, :email, :phone, :location, :service_type, :password, :password_confirmation)\n end", "def update\n update_resource @ride, ride_params\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def set_api_v1_expense\n @api_v1_expense = Api::V1::Expense.find(params[:id])\n end", "def set_vendor\n @vendor = Vendor.find(params[:id])\n end", "def set_vendor\n @vendor = Vendor.find(params[:id])\n end", "def set_driver_application\n @driver_application = DriverApplication.find(params[:id])\n end", "def set_api_v1_item\n @api_v1_item = Item.find(params[:id])\n end", "def set_api_v1_design\n @api_v1_design = Api::V1::Design.find(params[:id])\n end", "def update(doc, server_dir, driver_dir, available_jars, number_instances)\n end", "def update\n @api = Api.find(params[:id])\n\n respond_to do |format|\n if @api.update_attributes(params[:api])\n format.html { redirect_to apis_url, notice: 'Api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.67831063", "0.66273797", "0.6190632", "0.5953544", "0.581342", "0.581342", "0.5705497", "0.56741136", "0.5632317", "0.5631887", "0.55777097", "0.5539444", "0.5539444", "0.5539444", "0.5539444", "0.55388117", "0.55388117", "0.5522386", "0.54935586", "0.54600024", "0.5442", "0.5431502", "0.5405829", "0.5390051", "0.5361699", "0.5359707", "0.5304702", "0.5287621", "0.5287621", "0.52769274", "0.52705467", "0.52682155", "0.52682155", "0.5267547", "0.525662", "0.52379066", "0.5215319", "0.52117515", "0.5197854", "0.5187593", "0.51736146", "0.5154904", "0.514383", "0.5141985", "0.5117521", "0.5111229", "0.5108435", "0.5106241", "0.5098797", "0.50971603", "0.5096794", "0.5095725", "0.506503", "0.5050532", "0.5049749", "0.5045721", "0.5037762", "0.5015561", "0.50112015", "0.49902573", "0.49588266", "0.494702", "0.49469024", "0.49448857", "0.4932827", "0.49324772", "0.49235994", "0.4921999", "0.49215364", "0.49013698", "0.48878163", "0.48851094", "0.48711008", "0.48689675", "0.48663017", "0.48646244", "0.4862189", "0.48568615", "0.4855745", "0.4854012", "0.48512957", "0.48499465", "0.48479116", "0.48458642", "0.48340628", "0.4832374", "0.4831601", "0.4831601", "0.48276502", "0.4826962", "0.48198974", "0.4818799", "0.48179975", "0.48112056", "0.48112056", "0.48088378", "0.48030418", "0.47997558", "0.47997135", "0.47978953" ]
0.6600777
2
DELETE /apid_drivers/1 DELETE /apid_drivers/1.json
def destroy respond_with ApidDrive.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n\t\t\t\trespond_with Driver.destroy(params[:id])\n end", "def destroy\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # Logic to delete a record\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\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 @ride_driver.destroy\n respond_to do |format|\n format.html { redirect_to @root }\n format.json { head :no_content }\n end\n end", "def destroy\n @driver_record = DriverRecord.find(params[:id])\n @driver_record.destroy\n\n respond_to do |format|\n format.html { redirect_to driver_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n conf.delete 'api'\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to enterprise_drivers_path(current_user), notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n api_client.delete(url)\n end", "def delete\n api(\"Delete\")\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete(vendor_id)\n @client.delete(\"/#{@model}/#{vendor_id}\")\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def destroy\n @driverslist.destroy\n respond_to do |format|\n format.html { redirect_to driverslists_url, notice: 'Driverslist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_client = ApiClient.find(params[:id])\n @api_client.destroy\n\n respond_to do |format|\n format.html { redirect_to api_clients_url }\n format.json { head :no_content }\n end\n end", "def delete_api(name)\n url = '/apis/' + name\n payload = {}\n process_kong_request(url, :DELETE, payload)\n end", "def destroy\n @api = Api.find(params[:id])\n @api.destroy\n\n respond_to do |format|\n format.html { redirect_to apis_url }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @api_method = ApiMethod.find(params[:id])\n @api_method.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def destroy\n @trip_driver = TripDriver.find(params[:id])\n @trip_driver.destroy\n\n respond_to do |format|\n format.html { redirect_to trip_drivers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @references_vehicle_driver.destroy\n respond_to do |format|\n format.html { redirect_to references_vehicle_drivers_url, notice: 'References vehicle driver was successfully destroyed.' }\n format.json { head :no_content }\n end\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(path, params={}, options={})\n request(:delete, api_path(path), params, options)\n end", "def destroy\n @dapi.destroy\n respond_to do |format|\n format.html { redirect_to dapis_url, notice: 'Dapi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api = Api.find(params[:id])\n @api.destroy\n\n respond_to do |format|\n format.html { redirect_to(apis_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end", "def destroy\n @drivers_licesnse.destroy\n respond_to do |format|\n format.html { redirect_to drivers_licesnses_url, notice: 'Drivers licesnse was successfully destroyed.' }\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(api, params)\n url2json(:DELETE, \"#{@endpoint}#{api}\", params)\n end", "def delete\n request(:delete)\n end", "def destroy\n id = params[:id]\n src = Tagaly3::SRC\n # Code to connect with API\n @uri = URI.parse(src)\n http = Net::HTTP.start(@uri.host,@uri.port)\n request = Net::HTTP::Delete.new(\"/adexchange/advertiser/advertisement/#{id}\")\n response = http.request(request)\n http.finish\n redirect_to '/ads/'\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete(url, headers={})\n RestClient.delete url, headers\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @beacon = Beacon.find(params[:id])\n @beacon.destroy\n\n respond_to do |format|\n format.html { redirect_to beacons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @device.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @api_haiku = Api::Haiku.find(params[:id])\n @api_haiku.destroy\n\n respond_to do |format|\n format.html { redirect_to api_haikus_url }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n @client.delete( name )\n end", "def destroy\n @adv = Advantage.find(params[:id])\n @adv.destroy\n\n respond_to do |format|\n format.html { redirect_to administration_advantages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url, flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n end\n end", "def destroy\n @bluetooth = Bluetooth.find(params[:id])\n @bluetooth.destroy\n\n respond_to do |format|\n format.html { redirect_to bluetooths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_tracking = ApiTracking.find(params[:id])\n @api_tracking.destroy\n\n respond_to do |format|\n format.html { redirect_to api_trackings_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @admin_agency = Admin::Agency.find(params[:id])\n @admin_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_agencies_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @driver_license_type = DriverLicenseType.find(params[:id])\n @driver_license_type.destroy\n\n respond_to do |format|\n format.html { redirect_to driver_license_types_url }\n format.json { head :no_content }\n end\n end", "def deleteEntityAdvertiser( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/advertiser\",params)\n end", "def destroy\n @driver_log.destroy\n respond_to do |format|\n format.html { redirect_to driver_logs_url, notice: 'Driver log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @asset = WirelessDevice.find(params[:id])\n asset_destroy(wireless_url)\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def call(id)\n client.delete(\"/api/rest/v1/api_keys/#{id}.json\")\n true\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @client.delete(@name)\n end", "def destroy\n @beacon_transmitter.destroy\n respond_to do |format|\n format.html { redirect_to beacon_transmitters_url }\n format.json { head :no_content }\n end\n end", "def delete(header = {})\n url = \"#{ApiClient.config.path}#{self.class.resource_path}/#{id}\"\n response = ApiClient::Dispatcher.delete(url, header)\n attributes = ApiClient::Parser.response(response, url)\n update_attributes(attributes)\n end", "def destroy\n @offer.destroy\n respond_to do |format|\n format.jsonapi { head :no_content }\n end\n end", "def destroy\n @offer.destroy\n respond_to do |format|\n format.jsonapi { head :no_content }\n end\n end", "def destroy\n @advertisement = Advertisement.find(params[:id])\n #if File.exists?(\"#{Rails.root}/#{@advertisement.filename}\")\n #File.delete(\"#{@advertisement.filename}\")\n #end\n @advertisement.destroy\n\n respond_to do |format|\n format.html { redirect_to advertisements_url }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lab_device = LabDevice.find(params[:id])\n @lab_device.destroy\n\n respond_to do |format|\n format.html { redirect_to lab_devices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api.destroy\n respond_to do |format|\n format.html { redirect_to apis_url, notice: 'Api was successfully destroyed.' }\n format.json { head :no_content }\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 delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end", "def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @driver_division.destroy\n respond_to do |format|\n format.html { redirect_to driver_divisions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qa_client = QaClient.find(params[:id])\n @qa_client.destroy\n\n respond_to do |format|\n format.html { redirect_to qa_clients_url }\n format.json { head :no_content }\n end\n end", "def delete\n delete_from_server single_url\n end", "def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end", "def destroy; delete end", "def destroy\n @device.destroy\n head :no_content\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end", "def delete\n\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 delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def destroy\n @cervejarium = Cervejarium.find(params[:id])\n @cervejarium.destroy\n\n respond_to do |format|\n format.html { redirect_to cervejaria_url }\n format.json { head :no_content }\n end\n end", "def destroy(params = {})\n client.delete(\"#{endpoint(params)}/#{attributes[:id]}\")\n end", "def destroy\n @dataload_ga = DataloadGa.find(params[:id])\n @dataload_ga.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_gas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @auto = Auto.find(params[:id])\n @auto.destroy\n\n respond_to do |format|\n format.html { redirect_to autos_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7346565", "0.7260004", "0.7176116", "0.711944", "0.69264615", "0.6875296", "0.6875296", "0.6875296", "0.68502605", "0.68502605", "0.68502605", "0.68502605", "0.68437195", "0.6812075", "0.6715202", "0.67142797", "0.67003924", "0.6668725", "0.6640283", "0.6589354", "0.6569689", "0.6557625", "0.6531916", "0.65290016", "0.6491087", "0.6484665", "0.6472974", "0.6464925", "0.64598095", "0.64454424", "0.6424788", "0.6391032", "0.6388305", "0.6377519", "0.6367648", "0.63532084", "0.6344192", "0.6329108", "0.63245285", "0.6322753", "0.6320246", "0.6316477", "0.631436", "0.6295409", "0.6289477", "0.628935", "0.6285028", "0.6251371", "0.62444407", "0.62371147", "0.62367135", "0.62365997", "0.6236546", "0.6236462", "0.62327623", "0.62327147", "0.623161", "0.6227417", "0.62231475", "0.6221562", "0.6219251", "0.62137145", "0.62093365", "0.6201819", "0.61906564", "0.61791927", "0.6170894", "0.61688244", "0.61655545", "0.6162084", "0.6160343", "0.6160343", "0.6159404", "0.61546427", "0.61456656", "0.6142787", "0.6142455", "0.6139044", "0.6135084", "0.6135084", "0.6129833", "0.6129138", "0.6123547", "0.6123547", "0.611897", "0.61181843", "0.61174536", "0.6111137", "0.61108506", "0.60963994", "0.609585", "0.6093021", "0.6091349", "0.60908055", "0.60906255", "0.6089664", "0.6086862", "0.6085116", "0.6081497", "0.6081172" ]
0.64356834
30
Add a new node to the graph. Node must not exist.
def add_node(n1) raise ArgumentError, "Duplicate node name #{n1.name}" if @nodes.find_index(n1) @nodes << n1 @incident_map[n1] = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_node(node)\n @nodes.add node\n end", "def add_node(n)\n @nodes.push n unless @nodes.include? n\n end", "def add_node(node)\n\t\t\tunless has_node?(node)\n\t\t\t\t@nodes[node] = new_node(node)\n\t\t\t\t@order += 1\n\t\t\tend\n\t\t\tself\n\t\tend", "def add_node(node)\n nodes[node.value] = node\n end", "def add(node)\r\n @nodes << node\r\n end", "def add_node(node); end", "def add_node(name, node)\n language.nodes[name] = node if name\n node\n end", "def addNode(node)\r\n\t\tif @nodes.nil?\r\n\t\t\t@nodes = [node]\r\n\t\telse\r\n\t\t\t@nodes << node\r\n\t\tend\r\n\tend", "def add_node(node)\n @nodes[node.id.to_i] = node\n node.db = self\n end", "def add_node(node)\n _clear_cache\n @pathway.graph[node] ||= {}\n self\n end", "def add_node(node)\n @nodes[node.uri] ||= node\n end", "def add_node(new_node)\n @nodes[new_node] ||= Array.new #only adds if not in graph\n @node_dir_ancestors[new_node] ||= Array.new\n end", "def add_node(graph, document)\n unless graph.node(document.key)\n graph.add(Turbine::Node.new(document.key, model: document))\n end\n end", "def node_add(node)\n raise Deployment::InvalidArgument.new self, 'Cluster can add only nodes!', node unless node.is_a? Deployment::Node\n return node_get node if node_present? node\n unless node.cluster == self\n node.cluster.node_remove node if node.cluster\n end\n nodes.store prepare_key(node), node\n node.cluster = self\n node\n end", "def add_node(data)\n\n\t\t# change tactics if we're adding the first node\n\t\tif @head.nil?\n\n\t\t\tadd_first_node(data)\n\n\t\telse\n\n\t\t\tnew_node = Node.new(data)\n\n\t\t\t# point the last node to our new one\n\t\t\[email protected] = new_node\n\n\t\t\t# set our new node as the official last node\n\t\t\t@last = new_node\n\n\t\tend\n\t\tputs \"Added node with the value: #{data}\"\n\tend", "def add_node! u, v = nil, l = nil\n if nodes.empty?\n add_vertex! u, l\n elsif u.is_a? _branch_type\n add_branch! u, nil, l\n elsif not v.nil?\n add_branch! u, v, l\n else\n # Ensure the connected constraint.\n raise RawTreeError, \"In order to add a node to the tree, you must specify another node to attach to.\"\n end\n end", "def add_node(node = {})\n @nodes.push Bark::Client.new node\n end", "def add_node(value, node=nil)\n new_node = Node.new(value)\n if node\n new_node.parent = node\n node.children << new_node\n else\n @head = new_node\n end\n end", "def add_node(object)\n if is_node?(object)\n node = object\n @nodes << object\n else\n node = Node.new(object)\n @nodes << node\n end\n\n node\n end", "def add_node node\n nodes << node\n node.scene = self\n end", "def create_node!\n node.save\n end", "def add_node(graph, document)\n unless graph.node(document.key)\n node = graph.add(Refinery::Node.new(document.key, model: document))\n establish_slots(node, document)\n end\n end", "def add_node(key, val)\n @store.append(key, val)\n end", "def add_node(value)\n if @head\n @head = Node.new value, @head\n else\n @head = Node.new value, nil\n end\n end", "def add_node(data)\n if @head.nil?\n add_first_node(data)\n else\n new_node = Node.new(data, nil)\n @tail.next = new_node\n @tail = new_node\n end\n # puts \"Added node with value: #{data}\"\n end", "def add_node( node )\n super( node )\n __add_node__( node )\n end", "def add(node)\n raise 'Node must be persisted!' unless node.persisted?\n # Traverse to the end\n last_link = nil\n each_link do |link|\n last_link = link\n end\n # Create a new link\n # If there is no last node, make the link the head\n # Otherwise, throw the link at the end\n link = Likewise::Node.create :ref_id => node.id\n if last_link.nil?\n self[:head_id] = link.id\n else\n last_link[:next_id] = link.id\n end\n # Increment our length, which is memoized\n element_added!\n end", "def insert_node(new_node_val)\n new_node = Node.new(new_node_val)\n @nodes << new_node\n @_node_map[new_node_val] = new_node\n new_node\n end", "def new_node(*args)\n add_node(build_node(*args))\n end", "def new_node\n id = @nodes.size\n node = Node.new(id: id)\n @nodes.push(node)\n id\n end", "def add_node(node)\n if node.respond_to?(:to_sym)\n node = Woodhouse::Layout::Node.new(node.to_sym) \n end\n expect_arg :node, Woodhouse::Layout::Node, node\n @nodes << node\n node\n end", "def add_node(node)\n #$DEBUG.puts \"Registering #{SNMPPass.num2oid(node.oid)} with #{node}\"\n @fields[node.oid]=node\n end", "def test_add_node\n node = Node.new(1, [2, 3])\n @graph.add_node(node)\n assert_equal(@graph.num_nodes, 1)\n end", "def insert_node(atlas_node_id, node_name, node)\n return if atlas_node_id.blank? || node_name.blank?\n current_node = TaxGenerator::TaxonomyNode.new(atlas_node_id, node_name)\n node << current_node\n current_node\n end", "def add_edge(node)\n @adj_nodes.push(node.position)\n end", "def add_node\n return if @node_name == nil\n unless node_exist? \n tool_hash = Hash[*@tool_properties.zip(@tool_values).flatten]\n new_node = {\n \"node_name\" => @node_name,\n \"tools\" => [\n tool_hash\n ]\n }\n @site_data[\"site\"][\"node\"] << new_node\n end\n end", "def add_node(taxonomy_node, node, options = {})\n tax_node = options[:skip_add].present? ? node : add_taxonomy_node(taxonomy_node, node)\n return unless taxonomy_node.children.any?\n taxonomy_node.xpath('./node').each do |child_node|\n add_node(child_node, tax_node) if tax_node.present?\n end\n end", "def add(*arguments)\n if arguments[0].is_a?(Node)\n if arguments[1]\n fail ArgumentError, 'The second argument must not be specified, when passing a VObject Node'\n end\n arguments[0].parent = self\n new_node = arguments[0]\n elsif arguments[0].is_a?(String)\n new_node = @root.create(*arguments)\n else\n fail ArgumentError, 'The first argument must either be a Node or a string'\n end\n\n name = new_node.name\n if @children.key?(name)\n @children[name] << new_node\n else\n @children[name] = [new_node]\n end\n\n new_node\n end", "def <<(node)\n @nodes = [] if !instance_variable_defined?(:@nodes) or @nodes.nil?\n raise \"argument to << must be a String or Ox::Node.\" unless node.is_a?(String) or node.is_a?(Node)\n @nodes << node\n end", "def add_child(node)\n node.build\n nodes << node\n end", "def add(item)\n\t\t\t@hash[item] = Node.new\n\t\tend", "def add_node(node)\n node.prev = head\n node.next = head.next\n\n head.next.prev = node\n head.next = node\n end", "def add_node(value)\n add_node_support(value, :linked_list)\n end", "def test_add_node_double\n node = Node.new(1, [1])\n @graph.add_node(node)\n # Assert\n assert_equal(1, @graph.num_nodes)\n end", "def n(name)\n return @graph.get_node(name) unless @graph.get_node(name.to_s).nil?\n @graph.add_nodes(name)\n end", "def add_taxonomy_node(taxonomy_node, node)\n atlas_node_id = taxonomy_node.attributes['atlas_node_id']\n node_name = taxonomy_node.children.find { |child| child.name == 'node_name' }\n return if atlas_node_id.blank? || node_name.blank?\n insert_node(atlas_node_id.value, node_name.content, node)\n end", "def add_node(node)\r\n raise \"you can only add node #{node.name} to a Proposed Deployment\" unless snapshot.proposed?\r\n NodeRole.create :node_id=>node.id, :snapshot_id=>snapshot_id, :role_id=>role_id\r\n end", "def add_node(p_node_text, p_node_type, p_parent_node = nil, p_node_color = nil)\n new_node = create_node(p_node_text, p_node_type, p_node_color)\n # add new node on top level per default\n if p_parent_node.nil?\n p_parent_node = @nodes[0]\n end\n p_parent_node[\"nodes\"].insert(0, new_node)\n return new_node\n end", "def insert_node(node)\n raise \"Node must be a leaf\" unless node.is_leaf?\n if (self.view) \n node.position = self.view.get_node_position(node)\n node.visible = self.view.get_node_visibility(node)\n node.search_value = self.view.get_node_search_value(node)\n end\n leafs << node\n end", "def add(key, value)\r\n \t\t\t# Create new node for key, value to be added and set next to head \r\n \t\t\t# and then set head to the new node\r\n \t\t\tn = Node.new(key, value, @head)\r\n \t\t\t@head = n\r\n \t\tend", "def add_to_neighbors(node)\n @neighbors << node\n end", "def add(value)\n\t\tif @head != nil \n\t\t\tcurrent = @head\n\t\t\twhile current.nnode != nil\n\t\t\t\tcurrent = current.nnode\n\t\t\tend\n\t\t\tcurrent.nnode = Node.new(value, nil)\n\t\telse\n\t\t\t@head = Node.new(value,nil)\n\t\tend\n\tend", "def create\n Souffle::Log.info \"#{@node.log_prefix} Creating a new node...\"\n provider.create_node(@node)\n end", "def add_edge(node, weight)\n @adjacent_nodes[node.value] = { weight: weight, node: node }\n self\n end", "def <<(node)\n existing = node_for(node.name)\n\n if existing\n children.delete(existing)\n\n self.children << (existing + node)\n else\n node.parent = self\n self.children << node\n node\n end\n end", "def new_node\n\t\t\traise NotImplementedError.new('#new_node must be implemented')\n\t\tend", "def add_node(word, definition)\n if @head.nil?\n add_first_node(word, definition)\n else\n new_node = Node.new(word, definition)\n @last.next = new_node\n @last = new_node\n end\n puts \"Added node with word: #{word} and defintion #{definition}\"\n end", "def add(value)\n current_node = @head\n while current_node.next != nil\n current_node = current_node.next\n end\n current_node.next = Node.new(value, nil)\n end", "def update_node(node)\n file = node_file(node)\n status = file.exist? ? \"update\" : \"add\"\n\n txn do\n (@path + \"nodes\").mkpath\n file.open(\"w\") do |f|\n f.print JSON.generate(\n node.as_json,\n object_nl: \"\\n\",\n indent: \" \",\n space: \" \"\n )\n end\n @repo.add file\n\n message = \"#{status} node #{node.fqn}\"\n @repo.commit message\n log << \"Database commit: #{message}\"\n end\n end", "def add_vertex(node)\n @structure[node] ||= []\n end", "def add(node, timing)\n if @nodedb.key? node\n # We do not merge because we don't have\n # timing information of the sub-nodes. That is\n # recorded in separate records.\n @nodedb[node].data << timing\n else\n metadata = NodeMetaData.new\n metadata << timing\n node.data = metadata\n @nodedb[node] = node\n\n merge_graph node\n end\n end", "def test_adding_node\n \n # Start a new graph with no nodes\n graph = Graph.new()\n \n new_vertex = { \"code\" => \"NYC\" ,\n \"name\" => \"New York\" ,\n \"country\" => \"US\" ,\n \"continent\" => \"North America\" ,\n \"timezone\" => -5 ,\n \"coordinates\" => { \"N\" => 41, \"W\" => 74 } ,\n \"population\" => 22200000 ,\n \"region\" => 3 }\n graph.add_node(new_vertex)\n \n assert_equal( graph.nodes().size, 1)\n assert_equal( graph.nodes().has_key?(\"NYC\"), true )\n assert_not_nil( graph.nodes[\"NYC\"] )\n assert_equal( graph.nodes[\"NYC\"].region, 3)\n assert_equal( graph.nodes[\"NYC\"].coordinates[\"N\"], 41)\n\n # Test adding illegal node\n bad_vertex = { \"useless\" => \"information\"}\n\n caught = false\n begin\n graph.add_node(bad_vertex)\n rescue\n caught = true\n end\n\n assert_equal( caught, true )\n\n missing_keys_vertex = { \"code\" => \"A\"}\n\n caught = false\n begin\n graph.add_node(bad_vertex)\n rescue\n caught = true\n end \n \n assert_equal( caught, true )\n\n end", "def AddNode(type, xpos, ypos, numRadios = 0)\n\tname = NodeName(xpos, ypos)\n\tnode = Orbit::Topology::Node.new(@lastId, name, type)\n\tnode.SetPos(xpos,ypos)\n\t@lastId=@lastId+1\n\t#let OMF know we have created this node\n\tDefineGroup(node)\n\t@nodes_by_name[name]=node\n\treturn node\n end", "def add_node(domain, node)\n redis.sadd(\"pubsub:#{domain}:nodes\", node)\n end", "def addNode(node, toListView:listView)\n @expandableRowToNodeMap[node.id] = node if node.expandable?\n listView.addNode(node)\n end", "def add(name, country, continent, timezone, coords, pop, region, node_city, edges=Array.new)\n node = Node.new(name, country, continent, timezone, coords, pop, region)\n @nodes[node_city] = node\n @edges[node_city] = edges\n self\n end", "def add(item)\n if @head == nil\n @head.data = item\n @head.next = nil\n @tail = @head\n else\n current = @head\n newItem = Node.new(item, nil)\n newItem.next = current\n @head = newItem\n end\n end", "def add_node kind, label, attrs\n @node_buffer << Node.new(\n kind: kind,\n label: label,\n attrs: attrs\n )\n end", "def <<(node)\n node.dispatcher = @dispatcher\n @nodes << node\n end", "def append(node)\n if next_node\n next_node.append(node)\n else\n next_node = node\n end\n end", "def add(*nodes)\n @nodes.push(*nodes)\n end", "def add_node(node, children: [], parents: [], attributes: {}, infos: nil, recursive: true)\n\t\t\tif infos.respond_to?(:call)\n\t\t\t\tinfo=infos.call(node)||{}\n\t\t\t\tchildren.concat([*info[:children]])\n\t\t\t\tparents.concat([*info[:parents]])\n\t\t\t\tattributes.merge!(info[:attributes]||{})\n\t\t\tend\n\t\t\tif node.is_a?(Node) and node.graph != self\n\t\t\t\tchildren.concat(node.children)\n\t\t\t\tparents.concat(node.parents)\n\t\t\tend\n\t\t\tgraph_node=new_node(node,**attributes)\n\t\t\tif recursive\n\t\t\t\tgraph_node.add_child(*children.map { |child| add_node(child) })\n\t\t\t\tgraph_node.add_parent(*parents.map { |parent| add_node(parent) })\n\t\t\telse\n\t\t\t\t#just add the children\n\t\t\t\tgraph_node.add_child(*children.map { |child| new_node(child) })\n\t\t\tend\n\t\t\tgraph_node\n\t\tend", "def add_node(id)\n @g[id] = Set.new\n end", "def add(key, data)\n node = Classifieds::ListNode.new(data)\n if @hash.has_key?(key)\n @hash[key] << node\n else\n @hash[key] = [node]\n end\n end", "def test_add_node\r\n reader = GraphReader.new('whatever')\r\n reader.add_node(0, 'A', [1])\r\n assert_equal reader.graph[0].letter, 'A'\r\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n else\n add_node(@root, new_node)\n end\n end", "def set_newnode\n @newnode = Newnode.find(params[:id])\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_node\n else\n add_helper(@root, new_node)\n end\n end", "def add(value)\n if head.nil?\n @head = Node.new(value)\n else\n current_node = head\n while current_node.next\n current_node = current_node.next\n end\n current_node.next = Node.new(value)\n end\n end", "def duplicate(node)\n raise \"Can't duplicate a node from another graph!\" if node.graph != self\n new_node = node.dup\n @nodes << new_node\n @changed = true\n new_node.out.each { |n| new_node.out.send(:__connect__, n) }\n new_node.in.clear\n new_node\n end", "def add(x)\n @contents.push x if x.is_a? Node\n end", "def create\n @node = Node.new(params[:node])\n\n respond_to do |format|\n if (@job.nodes << @node)\n flash[:notice] = 'Node was successfully created.'\n format.html { redirect_to job_url(@job) }\n format.xml { render :xml => @node, :status => :created, :location => @node }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add(val)\n get_node(val) #every new element that has to be added should point to a new node correponding to it.\n list_size = @elements.size\n last_element_index = list_size - 1\n @elements[last_element_index].next_node = list_size\n new_element_index = list_size\n @elements[new_element_index] = @node\n end", "def node_create(node, node_class=Deployment::Node)\n if node_present? node\n node = node_get node\n elsif node.is_a? Deployment::Node\n node = node_add node\n else\n node = node_class.new node, self\n node = node_add node unless node_present? node\n end\n node\n end", "def test_append_additional_node\n list = LinkedList.new\n\n list.append(\"Rhodes\", {\"pounds of food\" => 200})\n list.append(\"Hardy\", {\"pounds of food\" => 200})\n\n assert_instance_of Node, list.head.next_node\n end", "def add(key, value)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current]\n # update new value if key exists\n current_and_parent_pair[:current].value = value\n else\n new_node = TreeNode.new(key,value)\n parent = current_and_parent_pair[:parent]\n link_node_to_parent(parent, new_node)\n end\n end", "def <<(v)\n @head << Node.new(v)\n end", "def append\n new_node = Node.new\n\n if @head.nil? #aka empty list (no nodes)\n @head = new_node\n @tail = new_node\n @head.next_node = @tail\n @tail.next_node = nil #problem alert\n else\n @tail.next_node = new_node\n @tail = new_node\n @tail.next_node = nil #problem alert\n end\n end", "def add(key, value)\n new_node = TreeNode.new(key,value)\n \n if @root.nil?\n @root = new_node\n else \n add_helper(@root, key, value)\n end\n end", "def insert_node\n insert_node_helper(@root)\n end", "def add_node(key, value)\n node = Node.new(key, value)\n\n # if there is current no root node set for the tree we need to set it\n if root.nil?\n @root = node\n else\n # lets find where we need to place the node \n current = @root\n placed = false\n\n while not placed\n # get the property to travese, either left_child or right_child\n property = direction(node.key, current.key)\n\n # set a pointer to remember the previous loops node value and\n # change the current value current based on the property flag \n parent = current\n current = current.send(property)\n\n # if the node under examination is nil then this means we have found\n # a spot to place the current node and we set the placed flag to \n # true in order to exit out of the loop\n if current.nil?\n parent.send(property+'=', node)\n placed = true\n end\n end\n\n end\n end", "def insert(data)\n @head = Node.new(data, @head)\n end", "def add_edge(from_node, to_node)\n add_node(from_node)\n add_node(to_node)\n @nodes[from_node] << to_node\n @node_dir_ancestors[to_node] << from_node\n\n if self.has_cycle\n puts \"No longer DAG\"\n end\n end", "def create\n @node = Node.new(params[:node])\n\n respond_to do |format|\n if @node.save\n format.html { redirect_to @node, notice: 'Node was successfully created.' }\n format.json { render json: @node, status: :created, location: @node }\n else\n format.html { render action: \"new\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(data)\n node = Node.new(data: data)\n if head\n tail.next_node = node\n else\n @head = node\n end\n\n @tail = node\n self\n end", "def add_edge(nodeA, nodeB)\n nodeA.adjacents << nodeB\n nodeB.adjacents << nodeA\n\n @nodes << nodeA\n @nodes << nodeB\n end", "def add_to_tree(s, node)\n head, *tail = s\n # check whether an edge is in the node with for the head element\n edge = node.find_edge(head)\n if (edge.nil?)\n edge = Edge.new(head)\n node.add_edge(edge)\n end\n if (!tail.empty?) then add_to_tree(tail, edge.node) end\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n if !@root \n @root = new_node\n return \n end\n add_node(new_node, @root)\n\n end", "def add(name, node)\n raise ArgumentError.new unless name.is_a?(Token)\n raise ArgumentError.new unless node.is_a?(Node)\n\n # Should point to last added variable, as its the stack\n if node.respond_to?(:stack_slot)\n node.stack_slot = $curr_stack_slot\n $curr_stack_slot += node.type.get_stack_slot_size\n end\n\n # If there's another variable with same name in this scope, it's error\n if @members[name.value]\n semantic_error(name, \"duplicate variable `%s'\" % [name.value])\n else\n @members[name.value] = node\n end\n end", "def add(key, value)\n new_nodelet = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_nodelet \n else \n @root = add_helper(@root, new_nodelet)\n end \n end" ]
[ "0.82840943", "0.7709978", "0.76525205", "0.76296014", "0.76230377", "0.75886595", "0.75097567", "0.7504663", "0.74980867", "0.7435528", "0.74191654", "0.7239807", "0.7205008", "0.7144659", "0.7075337", "0.70538026", "0.70115465", "0.6991444", "0.69556624", "0.6930441", "0.68947995", "0.68682444", "0.6861347", "0.68526596", "0.68364984", "0.6826989", "0.68121976", "0.68069744", "0.67997193", "0.6732355", "0.670584", "0.66572803", "0.661537", "0.6599547", "0.6542498", "0.65243775", "0.65152526", "0.64938134", "0.6341538", "0.63021725", "0.6290877", "0.6287632", "0.6263137", "0.62440836", "0.6228305", "0.62274855", "0.6220395", "0.6211815", "0.61757255", "0.61617035", "0.6155654", "0.6147281", "0.61377215", "0.61317354", "0.61267006", "0.6116921", "0.609566", "0.6091043", "0.60895526", "0.60893875", "0.60631365", "0.605715", "0.6049879", "0.60369307", "0.6034322", "0.6029538", "0.6017845", "0.6012335", "0.6006148", "0.59904397", "0.5953822", "0.59456694", "0.5923886", "0.591432", "0.5908468", "0.59053206", "0.5890655", "0.5884019", "0.5882789", "0.5879112", "0.58775896", "0.587525", "0.58741105", "0.58686745", "0.58629495", "0.5848833", "0.5844671", "0.5829749", "0.5823247", "0.58176297", "0.58147", "0.5809794", "0.5802083", "0.5794904", "0.5794353", "0.5790483", "0.57791996", "0.5777284", "0.57728755", "0.57721853" ]
0.708124
14
Add a unidirectional edge to the graph. The end point must have valid nodes that are already added to the graph. parallel edges are possible. So the edge may have the same end points.
def add_edge(edge) @edges << edge add_node(edge.n1) unless @nodes.find_index(edge.n1) add_node(edge.n2) unless @nodes.find_index(edge.n2) @incident_map[edge.n1] << edge @incident_map[edge.n2] << edge end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_edge(direction, edge)\n opposite_adjacencies(direction, edge) << edge\n end", "def add_edge(e)\n add_vertex(e.from); add_vertex(e.to)\n (@from_store[e.from].add?(e) && @to_store[e.to].add(e) && e) || edge(e.from, e.to)\n end", "def add_undirected_edge(id1,id2)\n @g[id1] ||= Set.new\n @g[id2] ||= Set.new\n @g[id1] << id2\n @g[id2] << id1\n end", "def add_edge(e)\n @edges[e.from] << e\n end", "def add_edge!(from, to)\n protected_add_edge!(from, to)\n @edge_number += 1\n end", "def add_edge(source, target, edge = Edge.new)\n _clear_cache\n @pathway.append(Bio::Relation.new(source, target, edge))\n edge\n end", "def add_edge(x, y) # from x to y\n if @nodes.key?(x) and @nodes.key?(y)\n if @edges.key?(x)\n unless @edges[x].include?(y)\n @edges[x] << y\n end\n end\n if @back_edges.key?(y)\n unless @back_edges[y].include?(x)\n @back_edges[y] << x\n end\n end\n else\n raise RuntimeError.new \"#{x} and #{y} not both present\"\n end\n end", "def add_edge( edge )\n super( edge.source, edge.target, edge )\n __add_edge__( edge )\n end", "def add_edge(edge)\n @edges.push(edge)\n end", "def add_edge(u, v)\n raise NotImplementedError\n end", "def add_edge(left, right)\n left.blocked_by(right)\n right.blocking(left)\n \n @edges << [left, right]\n end", "def add_edge(start_vertex_name, end_vertex_name)\n\n # Check if graph is not empty\n if (@vertices.length == 0)\n raise GraphError.new('No edges can be added to an empty graph', GraphError::ERROR_ADD_EDGE_FAILURE)\n end\n\n first_vertex_index = find_index_for_vertex(start_vertex_name)\n second_vertex_index = find_index_for_vertex(end_vertex_name)\n\n if (first_vertex_index == nil)\n raise GraphError.new('Edge cannot be added. First vertex could not be found', GraphError::ERROR_ADD_EDGE_FAILURE)\n end\n\n if (second_vertex_index == nil)\n raise GraphError.new('Edge cannot be added. Second vertex could not be found', GraphError::ERROR_ADD_EDGE_FAILURE)\n end\n\n add_edge_by_indexes(first_vertex_index,second_vertex_index)\n end", "def add_edge(*e)\n raise InvalidArgumentError if e.size > 2\n \n e = [e] if e.size == 2\n @edges.add(e[0])\n end", "def add_edge(source, target = nil, label = nil)\n @reversal = nil\n if target\n edge = Puppet::Relationship.new(source, target, label)\n else\n edge = source\n end\n [edge.source, edge.target].each { |vertex| setup_vertex(vertex) unless vertex?(vertex) }\n @vertices[edge.source].add_edge :out, edge\n @vertices[edge.target].add_edge :in, edge\n @edges << edge\n true\n end", "def add_edge(x, y)\n\t\traise if @x_connections[x] != -1\n\t\traise if @y_connections[yIdx(y)] != -1\n\t\t\n\t\t@x_connections[x] = y\n\t\t@y_connections[yIdx(y)] = x\n\t\t\n\t\t@unconnected_x_vertices -= 1\n\t\t\n#\t\traise if @x_connected_vertices.member?(xy[0])\n#\t\traise if @y_connected_vertices.member?(xy[1])\n\t\n\tend", "def append_edge(edge)\n @meeting_edges << edge\n end", "def connect_endpoint(collection, edge)\n if collection.any? { |o| ! edge.equal?(o) && edge.similar?(o) }\n raise DuplicateEdgeError.new(self, edge)\n end\n\n collection.add(edge)\n end", "def add_edge(a,b)\n @adj_list[a][b] = 1\n end", "def check_add_edge(anEdge)\n anEdge\n end", "def add_edge(node)\n @adj_nodes.push(node.position)\n end", "def add_edge(edge)\n edge.each { |node| add_vertex(node) }\n @structure[edge[0]] << edge[1]\n end", "def add_edge(from_node, to_node)\n add_node(from_node)\n add_node(to_node)\n @nodes[from_node] << to_node\n @node_dir_ancestors[to_node] << from_node\n\n if self.has_cycle\n puts \"No longer DAG\"\n end\n end", "def r_edge(other_node)\n (self.edges << other_node) && (other_node.edges << self)\n self\n end", "def add_edge(from, to)\n from.adjacents << to\n end", "def new_edge(*args)\n add_edge(build_edge(*args))\n end", "def protected_add_edge!(from, to)\n @vertices[from] << to if @vertices.has_key?(from) && @vertices.has_key?(to)\n end", "def add_edge_force!(from, to)\n add_vertex!(from)\n add_vertex!(to)\n add_edge!(from, to)\n end", "def addDirectedEdge(edge_value)\n\t\tedge_vertices = []\n\t\tedge_vertices = edge_value.split(',')\n\t\t# Validate the user input\n\t\tif edge_vertices.size == 2\n\t\t\tsource = edge_vertices[0]\n\t\t\tdest = edge_vertices[1]\n\t\tif !hasVertex(source)\n\t\t\taddVertex(source);\n\t\tend\n\t\tif !hasVertex(dest)\n\t\t\taddVertex(dest)\n\t\tend\n\t\[email protected]!(\"#{source}\" => @graphSet.fetch(source)<< edge_vertices[1])\n\t\telse\n\t\t\tputs \"Invalid entry. Enter only alphabets\".red\n\t\tend\n\tend", "def add_directed_edge(id1,id2)\n @g[id1] ||= Array.new\n @g[id1] << id2\n end", "def add_edge(x, y, cost: 1)\n raise\n end", "def add_edge(vertex1, vertex2)\n if !@graph[vertex1] || !@graph[vertex2]\n raise InvalidVertexException, \"That vertex doesn't exist in the graph\"\n end\n @graph[vertex1].push(vertex2)\n @graph[vertex2].push(vertex1)\n self\n end", "def add_edge(element1, element2)\n index1 = self.dict[element1]\n index2 = self.dict[element2]\n raise Exception.new(\"Nodes not exist!\") unless index1 && index2\n\n head_node2 = self.adj_list_array[index2].head_node\n new_node1 = Node.new(element1, head_node2.next_node)\n head_node2.next_node = new_node1\n\n\n head_node1 = self.adj_list_array[index1].head_node\n new_node2 = Node.new(element2, head_node1.next_node)\n head_node1.next_node = new_node2\n\n self\n end", "def addEdge( from, to)\n addVertex( from )\n addVertex( to )\n @vertices[from] << to\n\t@vertices[from].uniq!\n end", "def add_edge(u,v)\n if @graph.has_key?(u)\n @graph[u] << v\n else\n @graph[u] = [v]\n end\n @graph[u].uniq!\n end", "def add_edge(src, dest, weight)\n @v << src if [email protected]?(src)\n @v << dest if [email protected]?(dest)\n new_edge = Edge.new(src,dest, weight)\n src.out_edges << new_edge\n dest.in_edges << new_edge\n @e << new_edge\n end", "def add_edge(from:, to:)\n msg = nil\n msg = \"vertex #{from} is not in graph\" unless @adj_list.include? from\n msg = \"vertex #{to} is not in graph\" unless @adj_list.include? to\n msg = \"edge alredy exists: #{from} -> #{to}\" if not @adj_list[from].nil? and @adj_list[from].include? to\n\n return if not msg.nil?\n\n @adj_list[from].push(to)\n # undirected edge is stored as 2 direct edges\n @num_of_edges = @num_of_edges + 1\n end", "def add_edge(source_vertex, destination_vertex)\n @adjacent_list[source_vertex].push(destination_vertex)\n @indegree[destination_vertex] += 1\n end", "def add_undirected_edge(vertex_a, vertex_b, weight)\n super(vertex_a, vertex_b, weight) if weight > 0\n end", "def add_edge(source, destiny, weigth)\n source, destiny, weigth = convert_values(source, destiny, weigth)\n\n add_vertex(source)\n add_vertex(destiny)\n\n make_edge(source, destiny, weigth)\n end", "def add_edge(x, y, type)\n debug_msg \"adding edge #{x}, #{y}, #{type}\"\n if self[x,y]\n unless self[x,y] == type\n @contradiction = true\n debug_msg \" \\tcontradiction\"\n throw :add_edge_throw, :contradiction\n else\n debug_msg \"\\ti know\"\n throw :add_edge_throw, :i_know\n end\n else\n super(x, y, type)\n end\n end", "def new_edge\n\t\t\traise NotImplementedError.new('#new_edge must be implemented')\n\t\tend", "def add_edge(from_vertex, to_vertex)\n begin\n self[from_vertex].out_edges << to_vertex\n self[to_vertex].in_edges << from_vertex\n rescue NoMethodError => e\n err_suffix = \"in add_edge(#{from_vertex}, #{to_vertex}).\"\n if self[from_vertex].nil?\n puts(\"No vertex with id #{from_vertex} \" << err_suffix)\n else\n puts(\"No vertex with id #{to_vertex} \" << err_suffix)\n end \n end\n end", "def safe_add_edge(x, y, type)\n catch(:add_edge_throw) do \n add_edge(x, y, type)\n end\n end", "def add_edge(edge)\n # pp @access_paths\n # pp edge\n added = false\n return added if @edges.include?(edge)\n visited_path = @access_paths.each_with_index.select{|p,idx| !(p & edge).empty? }\n if visited_path.count == 2\n # if the two vertexes are visited in 2 paths\n # We'll combine the 2 paths\n new_path =[]\n to_del_idx =[]\n visited_path.each do |p|\n idx = p[1]\n v_path = p[0]\n new_path = new_path + v_path\n to_del_idx << idx\n end\n @access_paths.delete_if.with_index{|p,idx| to_del_idx.include?(idx)}\n @access_paths << new_path\n @edges << edge unless @edges.include?(edge)\n added = true\n elsif visited_path.count == 1\n v_path = visited_path[0][0]\n # binding.pry\n if (v_path & edge).count() == 2\n # binding.pry\n # add edge only when it does not create cycle\n puts \"Refuse to add edge #{edge.to_s} as it create cycle\"\n else\n # v_path = visited_path[0][1]\n vertext = edge - v_path\n v_path = v_path + vertext\n idx = visited_path[0][1]\n @access_paths.delete_at(idx)\n @access_paths << v_path\n @edges << edge unless @edges.include?(edge)\n added = true\n end\n elsif visited_path.count == 0\n @access_paths << edge\n @edges << edge unless @edges.include?(edge)\n added = true\n end\n # puts \"added is #{added}\"\n\n return added\n\tend", "def addEdge (node, dist)\n\t\[email protected]([node, dist])\n\t\tnode.addOtherEdge(self, dist)\n\tend", "def addOtherEdge (node, dist)\n\t\[email protected]([node, dist])\n\tend", "def add_edge(nodeA, nodeB)\n nodeA.adjacents << nodeB\n nodeB.adjacents << nodeA\n\n @nodes << nodeA\n @nodes << nodeB\n end", "def add_edge(predecessor_uri, successor_uri)\n @nodes[predecessor_uri].add_edge(@nodes[successor_uri])\n end", "def connect edge\n self.add edge.src\n self.add edge.dst\n @nodes[edge.src] << edge\n edge\n end", "def find_or_add_edge(one, two)\n edge = find_edge(one, two)\n if edge\n edge.weight += 1\n edge\n else\n edges << Edge.new(one: one, two: two, weight: 1)\n edges.last\n end\n end", "def add_edge(node_a, node_b)\n node_a.adjacents << node_b\n node_b.adjacents << node_a\n end", "def add_edge(x, y)\n if([email protected]_key?(x)) then \n @g[x] = []\n end\n if(!@g[x].include? y) then\n @g[x] << y\n end\nend", "def add_edge(source, dest, weight)\n edges << Edge.new(source, dest, weight)\n end", "def add_edge(id1, id2)\n # YOUR WORK HERE\n end", "def add_edge(source, dest)\n if VERT_MAP.has_key? source\n VERT_MAP[source] << dest\n else\n VERT_MAP[source] = Set.new [dest]\n end\n end", "def addEdge( from_vertex, to_vertex)\n addVertex( from_vertex )\n addVertex( to_vertex )\n @vertices[from_vertex] << to_vertex\n end", "def add_edge(*edge_details)\r\n if (edge_details.length <3)||(edge_details.length>4)\r\n raise \"Error: Incorrect number of arguments in add_edge\"\r\n end # end if length\r\n @edges.push edge_details\r\n end", "def add_edge(target_node,value)\n edges[target_node] = Edge.new(target_node,value)\n end", "def add_edge(src, dest)\n # add a edge to the head\n @adjList[src] << dest\n # since this graph is not directed we need to do the oposite also\n # @adjList[dest] << src\n @edges += 1\n end", "def add_edge(source, destination, weight)\n super(source, destination, weight) if weight > 0\n end", "def reverse!(opts = {})\n iv = out_vertex\n ov = in_vertex\n id = element_id if opts[:reuse_id]\n new_label = opts.fetch(:label, label)\n props = properties\n delete!\n graph.create_edge id, ov, iv, new_label, props\n end", "def addEdge(u, v)\n\t\tadjList[u].push(v)\n\tend", "def add(edge)\n source = edge.source\n if @contained_vertices.include? source\n @vertex_array.at(source).add_edge(edge)\n else\n new_vertex = Vertex.new(source)\n new_vertex.add_edge(edge)\n @contained_vertices.push(source)\n if @vertex_array.size < source\n @vertex_array.insert(source, new_vertex)\n else\n @vertex_array[source] = new_vertex\n end\n end\n end", "def create_edge origin, destiny\n return GraphElements::EdgeDefault.new origin, destiny\n end", "def add_edge_by_indexes(start_vertex_index, end_vertex_index)\n\n @vertices[start_vertex_index].neighbours[end_vertex_index] = true\n @vertices[end_vertex_index].neighbours[start_vertex_index] = true\n\n self\n end", "def edge_up(from, to)\n @edges_up[from].store(to, true)\n end", "def add_adjacent(node)\n\t\t@adjacent << node unless node == nil\n\tend", "def add_edge(source, target, weight = 1)\r\n\t\tself.push source unless self.include?(source)\r\n\t\tself.push target unless self.include?(target)\r\n\t\[email protected] Edge.new(source, target, weight)\r\n\tend", "def edge!(edge, consumer, supplier, carrier)\n Qernel::Edge.new(\n edge_key(edge),\n consumer,\n supplier,\n carrier,\n edge.type,\n edge.reversed?,\n edge.groups\n )\n end", "def add_edge(from, to, cost)\n @edges << Edge.new(from, to, cost)\n end", "def add_vertices_from(edge)\n unless (@vertices << (@apical_vertices << edge.protein_1_id).last unless @vertices.include? edge.protein_1_id)\n @vertices << (@apical_vertices << edge.protein_2_id).last unless @vertices.include? edge.protein_2_id\n end\n edge\n end", "def add_edge(object_1, object_2)\n node_1 = check_object(object_1)\n node_2 = check_object(object_2)\n node_1.adjacents << node_2\n node_2.adjacents << node_1\n end", "def create_edge(node1, node2)\n @nodes[node1.position].add_edge(node2)\n @nodes[node2.position].add_edge(node1)\n end", "def edge_to_exit\n Edge.new(self, nil)\n end", "def add_edge( from_key, to_key, weight = 0 )\n add_vertex(from_key) unless @vertices.include? from_key\n add_vertex(to_key) unless @vertices.include? to_key\n @vertices[from_key].add_neighbor( @vertices[to_key], weight )\n end", "def add_edge(location, params = {})\n if self.has_edge? location\n self.edges[location].update(params)\n else\n edge = Explore::Models::Edge.new location, params\n @edges[edge.location] = edge\n end # if-else\n end", "def add_edge(from, to, character)\n validate_argument(from)\n validate_argument(to)\n\n edges = @vertices[from] || create_new(from)\n edges << { character => to }\n end", "def remove_edge(x, y)\n raise\n end", "def add_edge(node1, node2, weight)\n nodes[node1.value].add_edge(nodes[node2.value], weight)\n nodes[node2.value].add_edge(nodes[node1.value], weight)\n self\n end", "def add_edge(node_city_A, node_city_B, distance)\n @edges[node_city_A] << Edge.new(node_city_B, distance)\n end", "def edge_down(from, to)\n @edges_up[from].store(to, false)\n end", "def collect_edge! #:yields: source, target, edge\n _clear_cache\n @pathway.relations.each do |rel|\n newedge = yield rel.node[0], rel.node[1], rel.relation\n rel.edge = newedge\n @pathway.append(rel, false)\n end\n self\n end", "def test_add_edge\n @dgraph.add_edge('a', 'b');\n\n # 0 and 1 are indexes of vertex a and vertex b respectively\n assert(@dgraph.vertices[0].neighbours[1] == true && @dgraph.vertices[1].neighbours[0] == nil)\n end", "def entry_edge=(object)\n self.entry_edges.clear\n self.entry_edges << object\n end", "def connect(vertex1, vertex2, edge_attributes = {})\n self.vertices << vertex1 unless self.vertices.include? vertex1\n self.vertices << vertex2 unless self.vertices.include? vertex2\n edge = Edge.new(edge_attributes)\n self.edges << edge\n edge << vertex1 << vertex2\n end", "def add_edge(u, v, w)\n super(u,v)\n @weights[[u,v]] = w\n end", "def relax(edge)\n return if @distance_to[edge.to] <= @distance_to[edge.from] + edge.weight\n\n @distance_to[edge.to] = @distance_to[edge.from] + edge.weight\n @path_to[edge.to] = edge.from\n\n # If the node is already in this priority queue, the only that happens is\n # that its distance is decreased.\n @pq.insert(edge.to, @distance_to[edge.to])\n end", "def add_relation source_label, relation, destination_label, direction = '<->'\n # More popular nodes have more weigth\n @node_weights[source_label] += 1\n @node_weights[destination_label] += 1\n\n @edge_buffer << Edge.new(\n source_label: source_label,\n relation: relation,\n destination_label: destination_label,\n direction: direction\n )\n end", "def remove_edge(start_vertex_name, end_vertex_name)\n\n first_vertex_index = find_index_for_vertex(start_vertex_name)\n second_vertex_index = find_index_for_vertex(end_vertex_name)\n\n if (first_vertex_index == nil)\n raise GraphError.new('Edge removal error. First vertex could not be found', GraphError::ERROR_REMOVE_EDGE_FAILURE)\n end\n\n if (second_vertex_index == nil)\n raise GraphError.new('Edge removal error. Second vertex could not be found', GraphError::ERROR_REMOVE_EDGE_FAILURE)\n end\n\n remove_edge_by_indexes(first_vertex_index, second_vertex_index)\n end", "def addEdge from, to, directed, weight=nil\n\t\treturn false if !isNode?(to) || !isNode?(from)\n\t\tgetNode(from).addConnection(to,weight)\n\t\tgetNode(to).addConnection(from,weight) if(!directed)\n\tend", "def add_edge(u, v, weight = 1)\n\t\t@edges[u] = {} unless @edges.has_key?(u)\n\t\t@edges[v] = {} unless @edges.has_key?(v)\n\t\t@edges[u].update({v => Edge.new(u, v, weight)})\n\t\t@edges[v].update({u => Edge.new(v, u, weight)})\n\tend", "def add_edge(node, weight)\n @adjacent_nodes[node.value] = { weight: weight, node: node }\n self\n end", "def remove_edge(direction, edge)\n opposite_adjacencies(direction, edge).delete(edge)\n end", "def add_edge(from, to, cost)\n @vertices[from] = true unless @vertices.has_key? from\n @vertices[to] = true unless @vertices.has_key? to\n \n @edges_cost[from] = Hash.new() unless @edges_cost[from]\n @edges_cost[from].store(to, cost)\n\n @edges_up[from] = Hash.new() unless @edges_up[from]\n @edges_up[from].store(to, true)\n end", "def c_edge(other_node, wt = 0)\n (self.outbound_edges.add(other_node, wt) &&\n other_node.inbound_edges.add(self, wt))\n self\n end", "def add_edges(edges)\n edges.each do |edge|\n if [email protected]?(edge)\n @edges << edge\n\n edge.from.neighbours.push(edge.to) if !edge.from.neighbours.include? edge.to\n edge.to.neighbours.push(edge.from) if !edge.to.neighbours.include? edge.from\n\n @vertices << edge.from if !vertex_exist?(edge.from)\n @vertices << edge.to if !vertex_exist?(edge.to)\n end\n end\n\n build_adjacency_matrix.to_a\n end", "def make_edge(source, destiny, weigth)\n @vertices[source][destiny] = weigth\n @vertices[destiny][source] = weigth\n end", "def edge_to(target)\n Edge.new(self, target)\n end", "def edgesymbol\n directed ? '->' : '--'\n end", "def create_relationship(destiny, label, bidirectional=true, active=false)\n return false if destiny.nil? or destiny == self\n edge_class = ModelFabric.get_class(SocialFramework.edge_class)\n\n edge = edge_class.where([\"(origin_id = :origin_id AND destiny_id = :destiny_id OR \n destiny_id = :origin_id AND origin_id = :destiny_id) AND label = :label\",\n { origin_id: self.id, destiny_id: destiny.id, label: label }]).first\n\n if edge.nil?\n edge = edge_class.create origin: self, destiny: destiny, active: active,\n bidirectional: bidirectional, label: label\n\n return (not edge.nil?)\n end\n\n return false\n end" ]
[ "0.7474515", "0.72760797", "0.67912275", "0.6766652", "0.6747922", "0.6738925", "0.67329955", "0.67080563", "0.66677564", "0.6650507", "0.6546373", "0.64769053", "0.6438302", "0.6425793", "0.64153343", "0.63825625", "0.63232446", "0.6295457", "0.6293283", "0.6288033", "0.6281428", "0.62416714", "0.62291074", "0.6222759", "0.6159895", "0.6148249", "0.6142385", "0.61323154", "0.61227065", "0.6101513", "0.6096957", "0.60951054", "0.6088952", "0.60888124", "0.60880125", "0.6082443", "0.60603946", "0.6057427", "0.6049334", "0.6037528", "0.6024483", "0.602407", "0.6009803", "0.60041595", "0.59954834", "0.5967641", "0.5948365", "0.5902052", "0.5898609", "0.58828217", "0.58817804", "0.5874501", "0.5871189", "0.58612365", "0.5859531", "0.5839536", "0.58278453", "0.5784925", "0.5756415", "0.5703515", "0.56868273", "0.56461823", "0.56454504", "0.5628851", "0.5622288", "0.56095904", "0.55985427", "0.55873436", "0.55752957", "0.557164", "0.5564608", "0.5561284", "0.55353457", "0.55331284", "0.54901284", "0.54887277", "0.54871875", "0.5472726", "0.5469253", "0.5452142", "0.5446495", "0.54057384", "0.53845894", "0.53823656", "0.5374741", "0.5352049", "0.53252393", "0.5306674", "0.5293662", "0.528853", "0.52860874", "0.52849084", "0.52801967", "0.527554", "0.5275143", "0.52650696", "0.52624106", "0.52548707", "0.5249609", "0.5235511" ]
0.6560428
10
Debug hook, Check that the graph is consistent.
def check raise "Non unique node entries" unless nodes.uniq == nodes raise "Non unique edge entries" unless edges.uniq == edges @edges.each do |e| raise "self loop" if e.n1 == e.n2 raise "wrong order" unless e.n1 < e.n2 raise "edge not found in n1 incident list" unless @incident_map[e.n1].find_index(e) raise "edge not found in n2 incident list" unless @incident_map[e.n2].find_index(e) end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_07\n @dg = DiGraph.new([0,0],[6,0],[6,8],[2,6],[8,8],[3,4],[3,2],[3,9],[9,4],[9,6],[4,3],[4,8])\n @paths = Hash.new\n @paths[0] = [0]\n @paths[6] = [0,8]\n @paths[2] = [6]\n @paths[8] = [8]\n @paths[3] = [4,2,9]\n @paths[9] = [4,6]\n @paths[4] = [3,8]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(6);\n filled_dg = DiGraph.new(*fill(6));\n if (not filled_dg.equal?(received_dg))\n puts \"test_07 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 6\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end", "def debug?; end", "def debug?; end", "def test_06\n @dg = DiGraph.new([5,9],[0,3],[3,8],[8,9],[9,0])\n @paths = Hash.new\n @paths[5] = [9]\n @paths[0] = [3]\n @paths[3] = [8]\n @paths[8] = [9]\n @paths[9] = [0]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_06 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end", "def test_05\n @dg = DiGraph.new([0,7],[1,9],[1,4],[7,4],[7,0],[7,9],[3,7],[9,4],[9,7],[9,9],[4,1],[4,4],[4,7])\n @paths = Hash.new\n @paths[0] = [7]\n @paths[1] = [9,4]\n @paths[7] = [4,0,9]\n @paths[3] = [7]\n @paths[9] = [4,7,9]\n @paths[4] = [1,4,7]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_05 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end", "def debug\n @@debug ||= false\n end", "def debug; end", "def debug; end", "def debug; end", "def debug; end", "def debug?\n true\n end", "def debug?\n true\n end", "def force_debug\n self.level = :debug\n @level_frozen = true\n end", "def debug?\n false\n end", "def debug_through?\r\n return false\r\n end", "def debug(current_resolver_depth)\n # debug info will be returned if you call yield here, but it seems to be\n # broken in current Molinillo\n nil\n end", "def debug?\n @@debug\n end", "def dumpDebugState\n\t\tif(@hasMore)\n\t\t\tputs 'Has more solutions\\n'\n\t\telse\n\t\t\tputs 'No more solutions\\n'\n\t\tend\n\n\t\tputs \"availProofs #{@availProofs}\\n\"\n\t\tputs \"pengine #{@p.getID}\"\n\tend", "def debug?\n !!@debug # rubocop:disable Style/DoubleNegation\n end", "def debug?\n @@debug\n end", "def graph?\n true\n end", "def debug? ; $DEBUG ; end", "def test_next_state_is_different\n init_state = @game.build_graph\n refute_equal(init_state, @game.get_next_state(init_state))\n end", "def graph?\n false\n end", "def debug?\n @level <= 0\n end", "def debug?\n !!@debug\n end", "def debug?; @logger.debug? end", "def netDebug\n NetDebug.Trace(nil)\n NetDebug.Trace(true)\n NetDebug.Trace(false)\n NetDebug.Trace(getString)\n NetDebug.Trace(getWackyString)\n NetDebug.Trace(getArray)\n NetDebug.Trace(getMixedArray)\n NetDebug.Trace(getHash)\n NetDebug.Trace(getFixNum)\n NetDebug.Trace(getBigNum)\n NetDebug.Trace(getFloat)\n NetDebug.Trace(getXML)\n return true\n\tend", "def test_print_location_starting\n\t\ttest_main = Main.new(3, 1, 6)\n\t\tmocked_Graph = MiniTest::Mock.new(\"mocked graph\")\n\t\tmocked_Graph.expect(:get_curr_loc, Node.new(\"Enumerable Canyon\", 4, 5, 10))\n\t\ttest_main.print_location(mocked_Graph, 0)\n\t\tassert mocked_Graph\n\tend", "def debug_state\n super\n end", "def debug_state\n super\n end", "def debug?\n !!self.debug\n end", "def test_check_if_vertex_is_source_when_it_doesnt_exist\n assert(@dgraph.check_if_vertex_is_source('no_vertex') == false)\n end", "def reachable\n @vertices.each do |vk, is_up|\n if is_up\n print \"#{vk}\\n\"\n if @edges_up[vk]\n @edges_up[vk].each do |ek, up_too|\n if up_too\n print \" #{ek}\\n\"\n end\n end\n end\n end\n end\n end", "def debug! \n $DEBUG = true\n end", "def debug?\n\t\t!!@debuggable_status\n\tend", "def log_debug?\n @logger.debug?\n end", "def test_make_graph\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_graph = test_main.make_graph(test_graph)\n\t\tassert_equal test_graph.get_loc(\"Matzburg\").paths.length, 4\n\tend", "def test_check_if_vertex_is_source_when_not_source\n assert(@dgraph.check_if_vertex_is_source('c') == false && @dgraph.check_if_vertex_is_source('d') == false)\n end", "def debug_final_report\n\t\t\tsuper\n\t\t\tif @debug_level > 0\n\t puts \"Lowest OLD: \\t#{@lowest_old[0].to_a}\"\n\t puts \"Angle: \\t\\t#{@get_angle.(@current_point, @start_vector)}\"\n\t\t\tend\n\t\tend", "def merge_debug\n deep_merge_options[:merge_debug]\n end", "def with_debug\n @debug = true\n self\n end", "def test_new_graph_not_nil\n refute_nil(@graph)\n assert_kind_of(Graph, @graph)\n end", "def debug?\n $DEBUG\n end", "def print_graph\n @items.each do |item|\n puts \"#{item.inspect} depends on:\"\n\n predecessors = direct_predecessors_of(item)\n predecessors.each do |pred|\n puts \" #{pred.inspect}\"\n end\n puts \" (nothing!)\" if predecessors.empty?\n puts\n end\n end", "def test_node_change_log3\r\n Model.node_changes_to_log([:evidence, :doesnotexist])\r\n @mymodel = Model.new(1, \"rubylicious\") \r\n node_list = @mymodel.node_list \r\n\r\n node1 = node_list.add_node('autonum', 'node one', NODE);\r\n perfind2 = node_list.add_node('autonum', 'pi two', PERFIND); \r\n process3 = node_list.add_node('autonum', 'process three', PROCESS);\r\n process4 = node_list.add_node('autonum', 'process four', PROCESS); \r\n \r\n perfind2.evidence = 0.12\r\n process3.evidence = 0.34 \r\n process4.evidence = 0.56 \r\n \r\n i = 0\r\n while(ar = @mymodel.consume_next_node_change)\r\n assert_equal([0.12,0.12], ar[0].send(ar[1][0])) if ar[0] == perfind2\r\n assert_equal([0.34,0.34], ar[0].send(ar[1][0])) if ar[0] == process3 \r\n assert_equal([0.56,0.56], ar[0].send(ar[1][0])) if ar[0] == process4\r\n i += 1\r\n end\r\n \r\n assert_equal(3, i, 'Incorrect number of node changes were logged')\r\n end", "def test_check_if_vertex_is_source\n @dgraph = DirectedGraph.new\n vertex_a = Vertex.new('a')\n vertex_b = Vertex.new('b')\n vertex_c = Vertex.new('c')\n vertex_d = Vertex.new('d')\n @dgraph.add_vertex(vertex_a).add_vertex(vertex_b).add_vertex(vertex_c).add_vertex(vertex_d)\n @dgraph.add_edge('a', 'd').add_edge('d', 'c')\n\n assert(@dgraph.check_if_vertex_is_source('a') == true && @dgraph.check_if_vertex_is_source('b') == true)\n end", "def test_specific_info\n \n # Start a new graph with no vertices\n graph = Graph.new()\n \n # Add 2 vertices to the graph\n origin = { \"code\" => \"NYC\" ,\n \"name\" => \"New York\" ,\n \"country\" => \"US\" ,\n \"continent\" => \"North America\" ,\n \"timezone\" => -5 ,\n \"coordinates\" => { \"N\" => 41, \"W\" => 74 } ,\n \"population\" => 22200000 ,\n \"region\" => 3 }\n \n destination = { \"code\" => \"WAS\" ,\n \"name\" => \"Washington\" ,\n \"country\" => \"US\" ,\n \"continent\" => \"North America\" ,\n \"timezone\" => -5 ,\n \"coordinates\" => {\"N\" => 39, \"W\" => 77} ,\n \"population\" => 8250000 ,\n \"region\" => 3 } \n graph.add_node(origin)\n graph.add_node(destination)\n \n assert_equal(graph.get_specific_info(\"CHI\"), \"City doesn't exist in the graph.\")\n \n # Get information on Washington and check that correct information is\n # contained in the return value\n info = graph.get_specific_info(\"WAS\")\n \n assert_equal( info.include?(\"WAS\"), true )\n assert_equal( info.include?(\"Washington\"), true )\n assert_equal( info.include?(\"US\"), true )\n assert_equal( info.include?(\"North America\"), true )\n assert_equal( info.include?(\"N 39, W 77\"), true )\n assert_equal( info.include?(\"Population: 8250000\"), true )\n assert_equal( info.include?(\"Region: 3\"), true )\n assert_equal( info.include?(\"Direct Connections: WAS\"), false )\n \n # Add an edge and check if that information is reflected in the return value\n graph.add_edge(\"NYC\",\"WAS\" ,570)\n info = graph.get_specific_info(\"NYC\")\n \n assert_equal( info.include?(\"Direct Connections: WAS - 570\"), true)\n\n end", "def test_node_change_log2\r\n Model.node_changes_to_log([:evidence])\r\n @mymodel = Model.new(1, \"rubylicious\") \r\n node_list = @mymodel.node_list \r\n\r\n node1 = node_list.add_node('autonum', 'node one', NODE);\r\n perfind2 = node_list.add_node('autonum', 'pi two', PERFIND); \r\n process3 = node_list.add_node('autonum', 'process three', PROCESS);\r\n process4 = node_list.add_node('autonum', 'process four', PROCESS); \r\n \r\n perfind2.evidence = 0.12\r\n process3.evidence = 0.34 \r\n process4.evidence = 0.56 \r\n \r\n i = 0\r\n while(ar = @mymodel.consume_next_node_change)\r\n assert_equal([0.12,0.12], ar[0].send(ar[1][0])) if ar[0] == perfind2\r\n assert_equal([0.34,0.34], ar[0].send(ar[1][0])) if ar[0] == process3 \r\n assert_equal([0.56,0.56], ar[0].send(ar[1][0])) if ar[0] == process4\r\n i += 1\r\n end\r\n \r\n assert_equal(3, i, 'Incorrect number of node changes were logged')\r\n \r\n end", "def debug!\n return false if @debug_was_enabled_by # Prevent multiple calls\n\n config.debug ||= true # Enable debug mode in config if it wasn't enabled from other sources\n @debug_was_enabled_by = caller_locations(1, 1)[0].to_s\n\n configure do\n group :yabeda\n\n histogram :collect_duration,\n tags: %i[location], unit: :seconds,\n buckets: [0.0001, 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60].freeze,\n comment: \"A histogram for the time required to evaluate collect blocks\"\n end\n\n adapters.each_value(&:debug!)\n\n true\n end", "def assert\n raise \"Assertion failed !\" unless yield # if $DEBUG\nend", "def add_debug(node, message)\n puts \"[#{@lineno},#{@pos}]#{' ' * @productions.length}#{node}: #{message}\" if ::RDF::N3::debug?\n @options[:debug] << \"[#{@lineno},#{@pos}]#{' ' * @productions.length}#{node}: #{message}\" if @options[:debug].is_a?(Array)\n end", "def diagnostics; end", "def diagnostics; end", "def diagnostics; end", "def diagnostics; end", "def do_debug\n # debugging = true\n debugging = false\n puts yield if debugging\n end", "def debug!(*args)\n item = debug(*args)\n item.save\n item\n end", "def debug?\n severity == :DEBUG\n end", "def debug(*args); end", "def debug(*args); end", "def debug(*args); end", "def update_call_debug\n # do nothing\n end", "def graph_params_changed\n graph.keys.each do |mod|\n mod.graph_params_changed\n end \n end", "def debugging?\n\t\t(datastore['DEBUG'] || '') =~ /^(1|t|y)/i\n\tend", "def print_debug\n\t\tprint_divider\n\t\tputs \"Root Node: \\n\" + root.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Current Node: \\n\" + @current_node.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Attributes: \\n\" + attributes.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Children: \\n\" + children.to_xml\n\t\tprint_divider\n\tend", "def test_current_version\n check_current_version(current_nodes(:visible_node))\n check_current_version(current_nodes(:used_node_1))\n check_current_version(current_nodes(:used_node_2))\n check_current_version(current_nodes(:node_used_by_relationship))\n check_current_version(current_nodes(:node_with_versions))\n end", "def _debug_routing_tree\n\n puts self.path + \" - #{self.route_mode}\"\n @endpoints.each do |route|\n puts \"\\t#{route[:method].to_s.upcase} to ##{self.action_for route} (#{self.action_mode})\"\n end\n @subroutes.each do |k, subroute| subroute._debug_routing_tree end\n\n end", "def test_print_empty\n assert_output(\"Empty graph!\\n\") { @graph.print }\n end", "def debug?\n self[:debug] == 'true'\n end", "def restart_debug\n restart do\n debug\n end\n end", "def debug!\n self.severity = :DEBUG\n end", "def debug state=true\n @debug = state\n end", "def check_syntax_trace(context, schema, datum, depth, trace)\n return unless trace < 0\n depth.times { print \"*\" }\n print \"* #{context}\\n schema: #{schema.inspect[0 .. trace.abs]}\\n\"\n print \" datum: #{datum.inspect[0 .. trace.abs]}\\n\"\n end", "def debug?\n instance.options[:debug]\n end", "def debug?\n instance.options[:debug]\n end", "def debug(info)\n puts(info) if @debug\n end", "def debug?\n level <= DEBUG\n end", "def debug?; debug_abilities? || debug_authorize? || debug_authorize_blank?; end", "def log_denials\n @log_denials = true\n end", "def test_graphs(dsobj)\n errors = []\n dshash = get_dshash(dsobj)\n\n graph_types = Hash[\n 'graphs' => 'Graphs',\n 'ographs' => 'Overview Graphs',\n ]\n\n # iterate over the two graph types\n graph_types.keys.each { |type|\n\n # init/reinit the display hash\n display = {}\n\n puts graph_types[type] + \":\\n\"\n\n # iterate over each graph definition\n dshash[type].each { |test_graph|\n graphhash = get_graphhash(test_graph)\n\n puts ' - \"' + graphhash['name'] + '\" at display priority ' + graphhash['display']\n\n # does the y-axis label contain capital letters?\n case graphhash['yaxis']\n when /^IOPS$/ # We'll allow capital letters for IOPS\n break\n when /[A-Z]+/ # does the y-axis label contain capital letters?\n # yes -- record an error\n errors.push(\"#{type} #{graphhash['name']} has uppercase letters in the y-axis definition (#{graphhash['yaxis']})\")\n else\n next\n end\n\n # has this graph priority already been used?\n if ( display[graphhash['display']] )\n # yes -- record an error\n errors.push(type + ' \"' + graphhash['name'] +\n '\" is assigned the same display priority (' +\n graphhash['display'] + ') as \"' +\n display[graphhash['display']] + '\"')\n else\n # no -- store this priority in a hash for further testing\n display[graphhash['display']] = graphhash['name']\n end\n\n }\n\n puts \"=====================\\n\"\n }\n\n return(errors)\n end", "def debugging?\n Options[:debug]\n end", "def __debug(*args, **opt, &block)\n __debug_impl(*args, **opt, &block)\nend", "def debug?; @level <= DEBUG; end", "def debug?; @level <= DEBUG; end", "def debug_context_change\n Ruby.primitive :task_get_debug_context_change\n Kernel.raise PrimitiveFailure, \"primitive failed\"\n end", "def debug?\n @debug || ENV['HATCHET_DEBUG'] || false\n end", "def debug?\n level >= ASL_LEVEL_DEBUG\n end", "def checkNode()\n source_set = []\n neighbor_set = []\n $networks.each do |s, nb|\n source_set << s\n nb[\"neighbors\"].each do |s_, dist|\n neighbor_set << s_\n end\n end\n source_set.sort!\n source_set.uniq!\n neighbor_set.sort!\n neighbor_set.uniq!\n return source_set == neighbor_set\nend", "def graph?\n show?\n end", "def graph?\n show?\n end", "def debug?\n debugging || !ENV['DEBUG'].nil?\n end", "def assert_referential_integrity(hash)\n inventory_collection.fixed_foreign_keys.each do |x|\n next unless hash[x].nil?\n subject = \"#{hash} of #{inventory_collection} because of missing foreign key #{x} for \"\\\n \"#{inventory_collection.parent.class.name}:\"\\\n \"#{inventory_collection.parent.try(:id)}\"\n unless inventory_collection.assert_graph_integrity\n logger.warn(\"Referential integrity check violated, ignoring #{subject}\")\n return false\n else\n raise(\"Referential integrity check violated for #{subject}\")\n end\n end\n true\n end", "def test_node_change_log1\r\n @mymodel = Model.new(1, \"rubylicious\") \r\n node_list = @mymodel.node_list\r\n\r\n node1 = node_list.add_node('autonum', 'node one', NODE);\r\n perfind2 = node_list.add_node('autonum', 'pi two', PERFIND); \r\n process3 = node_list.add_node('autonum', 'process three', PROCESS);\r\n process4 = node_list.add_node('autonum', 'process four', PROCESS); \r\n\r\n process3.evidence = [0.2, 0.3]\r\n process4.evidence = [0.54, 0.777]\r\n \r\n assert(@mymodel.consume_next_node_change.nil?)\r\n end", "def before_graph_recalculation\n each_adapter(&:before_graph_recalculation!)\n end", "def debug?; run_options[:debug]; end", "def verifierCorrect()\n return @solution.equals(@partie.getCurrentGrid())\n end", "def debug(*args)\n color('35', *args) unless ENV.fetch('OVERCOMMIT_DEBUG') { '' }.empty?\n end", "def debug_mode\n @@debug_mode == 1\n end", "def assert_referential_integrity(hash)\n inventory_collection.fixed_foreign_keys.each do |x|\n next unless hash[x].nil?\n\n subject = \"#{hash} of #{inventory_collection} because of missing foreign key #{x} for \"\\\n \"#{inventory_collection.parent.class.name}:\"\\\n \"#{inventory_collection.parent.try(:id)}\"\n if inventory_collection.assert_graph_integrity\n raise(\"Referential integrity check violated for #{subject}\")\n else\n logger.warn(\"Referential integrity check violated, ignoring #{subject}\")\n return false\n end\n end\n true\n end" ]
[ "0.6164582", "0.61274487", "0.61274487", "0.61065865", "0.6023812", "0.5939961", "0.5928433", "0.5928433", "0.5928433", "0.5928433", "0.59103066", "0.59103066", "0.5855401", "0.5842462", "0.58193654", "0.578198", "0.57057947", "0.57056344", "0.56885743", "0.5688269", "0.56341106", "0.56309104", "0.55865616", "0.5560325", "0.55513394", "0.5532671", "0.55272377", "0.5520023", "0.549307", "0.5490705", "0.5490705", "0.54653376", "0.5445148", "0.5440937", "0.5440272", "0.5431836", "0.5427986", "0.5415514", "0.54099214", "0.54069245", "0.5379949", "0.5352122", "0.5349987", "0.5344676", "0.5330845", "0.53276503", "0.5322703", "0.53206265", "0.5310775", "0.5308652", "0.53050613", "0.53039527", "0.53014314", "0.53014314", "0.53014314", "0.53014314", "0.529016", "0.528803", "0.5287273", "0.52865446", "0.52865446", "0.52865446", "0.52863944", "0.5258932", "0.52411747", "0.52209663", "0.5198325", "0.5194547", "0.51897126", "0.51890904", "0.51842326", "0.5175324", "0.5174373", "0.51721096", "0.51693916", "0.51693916", "0.5160648", "0.51557344", "0.5145234", "0.51374686", "0.5135994", "0.5132632", "0.5130981", "0.5123471", "0.5123471", "0.5122907", "0.5113984", "0.5109876", "0.5105315", "0.5100006", "0.5100006", "0.50946665", "0.50927603", "0.50892395", "0.5084403", "0.5083988", "0.50827396", "0.5081765", "0.5079086", "0.50754297" ]
0.52606255
63
Generate a certificate for example.org, signed by ca_root_key
def generate_signed_cert unless @generated_signed_cert domains = %w(example.org www.example.org) key = OpenSSL::PKey::RSA.new(LetsCert::TEST::KEY_LENGTH) cert = OpenSSL::X509::Certificate.new cert.version = 2 cert.serial = 2 cert.issuer = OpenSSL::X509::Name.parse "/DC=letscert/CN=CA" cert.public_key = key.public_key cert.not_before = Time.now # 20 days validity cert.not_after = cert.not_before + 20 * 24 * 60 * 60 ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = cert domains.each do |domain| cert.add_extension(ef.create_extension('subjectAltName', "DNS:#{domain}", false)) end cert.sign(ca_root_key, OpenSSL::Digest::SHA256.new) @generated_signed_cert = [cert, domains] end @generated_signed_cert end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_ssl_cert\n\t\tcert_request = TEST_WORKDIR + 'example.csr'\n\t\tsigning_key = TEST_WORKDIR + 'example.key'\n\t\tcert = TEST_WORKDIR + 'example.crt'\n\n\t\tunless File.exist?( cert )\n\t\t\tsystem 'openssl', 'req',\n\t\t\t\t'-new', '-newkey', 'rsa:4096',\n\t\t\t\t'-days', '365', '-nodes', '-x509',\n\t\t\t\t'-subj', '/C=US/ST=Oregon/L=Portland/O=IT/CN=localhost',\n\t\t\t\t'-keyout', signing_key.to_s,\n\t\t\t\t'-out', cert.to_s\n\n\t\t\tsystem 'openssl', 'req',\n\t\t\t\t'-new',\n\t\t\t\t'-subj', '/C=US/ST=Oregon/L=Portland/O=IT/CN=localhost',\n\t\t\t\t'-key', signing_key.to_s,\n\t\t\t\t'-out', cert_request.to_s\n\n\t\t\tsystem 'openssl', 'rsa',\n\t\t\t\t'-in', signing_key.to_s,\n\t\t\t\t'-out', signing_key.to_s\n\n\t\t\tsystem 'openssl', 'x509',\n\t\t\t\t'-req', '-days', '365',\n\t\t\t\t'-in', cert_request.to_s,\n\t\t\t\t'-signkey', signing_key.to_s,\n\t\t\t\t'-out', cert.to_s\n\t\tend\n\tend", "def generate_ca_certificate\n generate_password unless password?\n\n host.generate_key unless host.key\n\n # Create a new cert request. We do this\n # specially, because we don't want to actually\n # save the request anywhere.\n request = Puppet::SSL::CertificateRequest.new(host.name)\n request.generate(host.key)\n\n # Create a self-signed certificate.\n @certificate = sign(host.name, :ca, request)\n\n # And make sure we initialize our CRL.\n crl()\n end", "def create_root_certificate(info = {})\n root_key = OpenSSL::PKey::RSA.new(RSA_KEY_SIZE)\n root_ca = create_certificate_skeleton(info)\n\n root_ca.issuer = root_ca.subject\n root_ca.public_key = root_key.public_key\n\n extensions = [\n ['basicConstraints', 'CA:TRUE', true],\n ['keyUsage', 'keyCertSign, cRLSign', true],\n ['subjectKeyIdentifier', 'hash', false],\n ['authorityKeyIdentifier', 'keyid:always', false],\n ]\n\n if info[:policy_constraints]\n extensions << [\n 'policyConstraints',\n info[:policy_constraints].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n if info[:policy_mapping]\n extensions << [\n 'policyMappings',\n info[:policy_mapping].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n add_certificate_extensions(root_ca, root_ca, *extensions)\n root_ca.sign(root_key, OpenSSL::Digest::SHA256.new)\n [root_ca, root_key]\n end", "def generate\n cert = OpenSSL::X509::Certificate.new\n configure(cert)\n add_extensions(cert)\n cert.sign(Billy.certificate_authority.key, OpenSSL::Digest::SHA256.new)\n end", "def generate_ca_data!\n self.private_key = OpenSSL::PKey::RSA.new(2048)\n public_key = private_key.public_key\n\n self.ca_cert = OpenSSL::X509::Certificate.new\n self.ca_cert.subject = self.ca_cert.issuer = self.subject # self-signed\n self.ca_cert.not_before = Time.now\n self.ca_cert.not_after = Time.now + 365 * 24 * 60 * 60 * 10 #TODO change from hardcoded 10 years\n self.ca_cert.public_key = public_key\n self.ca_cert.serial = 0x0\n self.next_serial = 0x1\n self.ca_cert.version = 2\n\n ef = OpenSSL::X509::ExtensionFactory.new\n ef.subject_certificate = ca_cert\n ef.issuer_certificate = ca_cert\n # TODO Make this changeable\n self.ca_cert.extensions = [\n ef.create_extension(\"basicConstraints\",\"CA:TRUE\", true),\n ef.create_extension(\"subjectKeyIdentifier\", \"hash\"),\n ]\n self.ca_cert.add_extension ef.create_extension(\"authorityKeyIdentifier\", \"keyid:always,issuer:always\")\n\n self.ca_cert.sign private_key, OpenSSL::Digest::SHA1.new\n end", "def create_intermediate_certificate(info = {})\n root_ca = info[:ca]\n root_key = info[:ca_key]\n\n key = OpenSSL::PKey::RSA.new(RSA_KEY_SIZE)\n\n cert = create_certificate_skeleton(info)\n cert.issuer = root_ca.subject # root CA is the issuer\n cert.public_key = key.public_key\n\n extensions = [\n ['basicConstraints', 'CA:TRUE', true],\n ['keyUsage', 'keyCertSign, cRLSign', true],\n AUTHORITY_INFO_ACCESS_EXTENSION,\n SUBJECT_INFO_ACCESS_EXTENSION,\n ['subjectKeyIdentifier', 'hash', false],\n ['authorityKeyIdentifier', 'keyid:always', false],\n ]\n\n if info[:policy_constraints]\n extensions << [\n 'policyConstraints',\n info[:policy_constraints].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n if info[:policy_mapping]\n extensions << [\n 'policyMappings',\n info[:policy_mapping].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n add_certificate_extensions(cert, root_ca, *extensions)\n cert.sign(root_key, OpenSSL::Digest::SHA256.new)\n [cert, key]\n end", "def create_leaf_certificate(info = {})\n root_ca = info[:ca]\n root_key = info[:ca_key]\n\n key = OpenSSL::PKey::RSA.new(RSA_KEY_SIZE)\n\n cert = create_certificate_skeleton(info)\n cert.issuer = root_ca.subject # root CA is the issuer\n cert.public_key = key.public_key\n\n extensions = [\n ['keyUsage', 'digitalSignature', true],\n ['subjectKeyIdentifier', 'hash', false],\n AUTHORITY_INFO_ACCESS_EXTENSION,\n ['authorityKeyIdentifier', 'keyid:always', false],\n ]\n\n unless info[:no_policies]\n extensions << [\n 'certificatePolicies',\n IdentityConfig.store.required_policies.first,\n false,\n ]\n end\n\n if info[:policy_constraints]\n extensions << [\n 'policyConstraints',\n info[:policy_constraints].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n if info[:policy_mapping]\n extensions << [\n 'policyMappings',\n info[:policy_mapping].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n add_certificate_extensions(cert, root_ca, *extensions)\n cert.sign(root_key, OpenSSL::Digest::SHA256.new)\n cert\n end", "def generate_test_client_cert(prefix=nil)\n cert = CertificateAuthority::Certificate.new\n cert.serial_number.number = cert_serial_number(provider.domain)\n cert.subject.common_name = [prefix, random_common_name(provider.domain)].join\n cert.not_before = yesterday\n cert.not_after = yesterday.advance(:years => 1)\n cert.key_material.generate_key(1024) # just for testing, remember!\n cert.parent = client_ca_root\n cert.sign! client_test_signing_profile\n yield cert.key_material.private_key.to_pem, cert.to_pem\n end", "def generate_intermediate_ca(dir)\n pki = create_chained_pki\n FileUtils.mkdir(dir) unless File.directory? dir\n pki.each do |name,cert|\n File.open(\"#{dir}/#{name}\",'w') do |f|\n f.write(cert.to_s)\n end\n end\n end", "def generate_ca(prefix,passphrase=nil)\n\n\t\t\toutdir=File.expand_path(File.dirname(\"#{prefix}a.b\"))\n\t\t\tFileUtils.mkdir_p(outdir)\n\n\t\t\t#\n\t\t\t# write key file\n\t\t\t#\n\t\t\t\n\t\t\tputs \"generating CA key...\"\n\t\t\tkey = OpenSSL::PKey::RSA.new(2048)\n\t\t\tcipher = OpenSSL::Cipher::Cipher.new('AES-128-CBC')\n\t\t\texp = passphrase ? key.export(cipher,passphrase) : key.export\n\t\t\tputs \"saving CA key...\"\n\t\t\tFile.open(make_filename(prefix,:key),\"w\") do |f|\n\t\t\t\tf.write(exp)\n\t\t\tend\n\t\t\t\n\t\t\t#\n\t\t\t# generate certificate\n\t\t\t#\n\t\t\t\n\t\t\tputs \"generating CA cert...\"\n\t\t\tca_name = OpenSSL::X509::Name.parse('CN=ca')\n\t\t\tca_cert = OpenSSL::X509::Certificate.new\n\t\t\tca_cert.serial = 0\n\t\t\tca_cert.version = 2\n\t\t\tca_cert.not_before = Time.at(0)\n\t\t\tca_cert.not_after = Time.at(0x7fffffff)\n\t\t\tca_cert.public_key = key.public_key\n\t\t\tca_cert.subject = ca_name\n\t\t\tca_cert.issuer = ca_name\n\n\t\t\textension_factory = OpenSSL::X509::ExtensionFactory.new\n\t\t\textension_factory.subject_certificate = ca_cert\n\t\t\textension_factory.issuer_certificate = ca_cert\n\n\t\t\textension_factory.create_extension 'subjectKeyIdentifier', 'hash'\n\t\t\textension_factory.create_extension 'basicConstraints', 'CA:TRUE', true\n\t\t\textension_factory.create_extension 'keyUsage', 'cRLSign,keyCertSign', true\n\n\t\t\tputs \"signing CA cert...\"\n\t\t\tca_cert.sign(key, OpenSSL::Digest::SHA1.new)\n\n\t\t\tputs \"saving CA cert...\"\n\t\t\tFile.open(make_filename(prefix,:cert),\"w\") do |f|\n\t\t\t\tf.write(ca_cert.to_pem)\n\t\t\tend\t\t\t\n\t\t\t\n\t\t\tputs \"wrote #{make_filename(prefix,:key)} and #{make_filename(prefix,:cert)}\"\n\t\t\t\n\t\tend", "def generate(name)\n raise ArgumentError, \"A Certificate already exists for %s\" % name if Puppet::SSL::Certificate.find(name)\n host = Puppet::SSL::Host.new(name)\n\n host.generate_certificate_request\n\n sign(name)\n end", "def gen_x509_cert(request, extension, info, key)\n raise TypeError, \"request must be a Ruby OpenSSL::X509::Request\" unless request.is_a?(::OpenSSL::X509::Request)\n raise TypeError, \"extension must be a Ruby Array\" unless extension.is_a?(Array)\n raise TypeError, \"info must be a Ruby Hash\" unless info.is_a?(Hash)\n raise TypeError, \"key must be a Ruby OpenSSL::PKey::EC object or a Ruby OpenSSL::PKey::RSA object\" unless key.is_a?(::OpenSSL::PKey::EC) || key.is_a?(::OpenSSL::PKey::RSA)\n\n raise ArgumentError, \"info must contain a validity\" unless info.key?(\"validity\")\n raise TypeError, \"info['validity'] must be a Ruby Integer object\" unless info[\"validity\"].is_a?(Integer)\n\n cert = ::OpenSSL::X509::Certificate.new\n ef = ::OpenSSL::X509::ExtensionFactory.new\n\n cert.serial = gen_serial\n cert.version = 2\n cert.subject = request.subject\n cert.public_key = request.public_key\n cert.not_before = Time.now\n cert.not_after = cert.not_before + info[\"validity\"] * 24 * 60 * 60\n\n if info[\"issuer\"].nil?\n cert.issuer = request.subject\n ef.issuer_certificate = cert\n extension << ef.create_extension(\"basicConstraints\", \"CA:TRUE\", true)\n else\n raise TypeError, \"info['issuer'] must be a Ruby OpenSSL::X509::Certificate object\" unless info[\"issuer\"].is_a?(::OpenSSL::X509::Certificate)\n\n cert.issuer = info[\"issuer\"].subject\n ef.issuer_certificate = info[\"issuer\"]\n end\n ef.subject_certificate = cert\n if openssl_config = __openssl_config\n ef.config = openssl_config\n end\n\n cert.extensions = extension\n cert.add_extension ef.create_extension(\"subjectKeyIdentifier\", \"hash\")\n cert.add_extension ef.create_extension(\"authorityKeyIdentifier\",\n \"keyid:always,issuer:always\")\n\n cert.sign(key, ::OpenSSL::Digest.new(\"SHA256\"))\n cert\n end", "def ssl_generate_certificate\n Rex::Socket::SslTcpServer.ssl_generate_certificate\n end", "def create_self_signed_cert(bits, cn, comment)\n rsa = OpenSSL::PKey::RSA.new(bits)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = 1\n name = OpenSSL::X509::Name.new(cn)\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n cert.not_after = Time.now + (365*24*60*60)\n cert.public_key = rsa.public_key\n cert.sign(rsa, OpenSSL::Digest::SHA1.new)\n return [cert, rsa]\nend", "def test_autocertgeneration\n ca = nil\n\n # create our ca\n assert_nothing_raised {\n ca = Puppet::Network::Handler.ca.new(:autosign => true)\n }\n\n # create a cert with a fake name\n key = nil\n csr = nil\n cert = nil\n hostname = \"test.domain.com\"\n assert_nothing_raised {\n cert = Puppet::SSLCertificates::Certificate.new(\n :name => \"test.domain.com\"\n )\n }\n\n # make the request\n assert_nothing_raised {\n cert.mkcsr\n }\n\n # and get it signed\n certtext = nil\n cacerttext = nil\n assert_nothing_raised {\n certtext, cacerttext = ca.getcert(cert.csr.to_s)\n }\n\n # they should both be strings\n assert_instance_of(String, certtext)\n assert_instance_of(String, cacerttext)\n\n # and they should both be valid certs\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(certtext)\n }\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(cacerttext)\n }\n\n # and pull it again, just to make sure we're getting the same thing\n newtext = nil\n assert_nothing_raised {\n newtext, cacerttext = ca.getcert(\n cert.csr.to_s, \"test.reductivelabs.com\", \"127.0.0.1\"\n )\n }\n\n assert_equal(certtext,newtext)\n end", "def create_self_signed_cert(bits, cn, aliases, comment)\n rsa = OpenSSL::PKey::RSA.new(bits)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = Time.now.to_i % (1 << 20)\n name = OpenSSL::X509::Name.new(cn)\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n cert.not_after = Time.now + (365 * 24 * 60 * 60)\n cert.public_key = rsa.public_key\n\n ef = OpenSSL::X509::ExtensionFactory.new(nil, cert)\n ef.issuer_certificate = cert\n cert.extensions = [\n ef.create_extension('basicConstraints', 'CA:FALSE'),\n ef.create_extension('keyUsage', 'keyEncipherment'),\n ef.create_extension('subjectKeyIdentifier', 'hash'),\n ef.create_extension('extendedKeyUsage', 'serverAuth'),\n ef.create_extension('nsComment', comment)\n ]\n aki = ef.create_extension('authorityKeyIdentifier',\n 'keyid:always,issuer:always')\n cert.add_extension(aki)\n cert.add_extension ef.create_extension('subjectAltName', aliases.map { |d| \"DNS: #{d}\" }.join(','))\n\n cert.sign(rsa, OpenSSL::Digest.new('SHA256'))\n\n [cert, rsa]\n end", "def create_certificate # :nodoc:\n child = DRb::Worm::Certificates.new @name, @key_size\n\n @key = child.create_key\n csr_pem = child.create_certificate_signing_request\n cert_pem = @ca.create_child_certificate csr_pem\n\n @certificate = OpenSSL::X509::Certificate.new cert_pem\n end", "def ca_cert\n \n end", "def endorsement_cert\r\n raw_cert = tag[Tem::ECert.ecert_tag_key].pack('C*')\r\n OpenSSL::X509::Certificate.new raw_cert\r\n end", "def sign_certificate\n sign_certificate_for(default)\n end", "def generate_application_certs(master, hosts, domain, skip_master = true)\n togen = []\n hosts.each do |host|\n next if (host['roles'].include?('master') and skip_master)\n\n fqdn = pfact_on(host, 'fqdn')\n if fqdn.include?('.')\n togen << fqdn\n else\n togen << host.hostname + '.' + domain\n end\n end\n\n create_remote_file(master, '/var/simp/environments/production/FakeCA/togen', togen.join(\"\\n\"))\n on(master, 'cd /var/simp/environments/production/FakeCA; ./gencerts_nopass.sh')\n end", "def createkey(hostname, pupmodule, pubfolder, prvfolder, subject, ca_key_file,\nca_crt_file, passphrase)\n return 'Already there' if\n File.exist?(\"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\")\n ca_key = OpenSSL::PKey::RSA.new File.read(ca_key_file), passphrase\n ca_cert = OpenSSL::X509::Certificate.new File.read ca_crt_file\n c=SignedCertificate.new(ca_key, ca_cert, subject)\n FileUtils.mkdir_p \"#{pubfolder}/#{pupmodule}/\"\n FileUtils.mkdir_p \"#{prvfolder}/#{hostname}/#{pupmodule}/\"\n #open \"#{pubfolder}/#{pupmodule}/#{hostname}.pub.pem\", 'w' do\n #|io| io.write c.key.public_key.to_pem end\n #open \"#{pubfolder}/#{pupmodule}/#{hostname}.csr.pem\", 'w' do\n #|io| io.write c.csr.to_pem end\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\", 'w' do\n |io| io.write c.cert.to_pem end\n open \"#{prvfolder}/#{hostname}/#{pupmodule}/#{hostname}.priv.pem\", 'w' do\n |io| io.write c.key.to_pem end\n 'OK'\nend", "def x509_certificate(value)\n OpenSSL::X509::Certificate.new value\n end", "def make_certs(config, verbose=false)\n FileUtils.mkdir_p config['certmaker']['outdir'], :verbose => verbose\n\n certs = CertificateSuiteGenerator.new(config['certs'], config['hostname'], config['certmaker']).certificates\n\n certs.each do |calias, ck|\n File.open(File.join(config['certmaker']['outdir'],calias+\"cert.pem\"),\"wb\") { |f| f.write ck[:cert] }\n File.open(File.join(config['certmaker']['outdir'],calias+\"key.pem\"),\"wb\") { |f| f.write ck[:key] }\n end\n\n end", "def certificate(common_name, pfx_file, key_type, password, optionals = {})\n command = []\n command << @adt_path\n command << \"-certificate\"\n command << \"-cn #{common_name}\"\n command << \"-ou #{optionals[:org_unit]}\" if !optionals[:org_unit].blank?\n command << \"-o #{optionals[:org]}\" if !optionals[:org].blank?\n command << \"-c #{optionals[:country]}\" if !optionals[:country].blank?\n command << key_type\n command << escape(pfx_file)\n command << password\n process(command)\n end", "def ssl\n if @options[\"ssl-gen-self-signed-certs\"]\n puts \"Generating private key and certificate\"\n args = [\n \"-C\", HOSTNAME,\n \"-n\", HOSTNAME,\n \"-o\", @options[\"ssl-organization\"],\n \"-u\", @options[\"ssl-organization-unit\"],\n \"-e\", @options[\"ssl-email\"],\n \"-c\", @options[\"ssl-country\"],\n \"-l\", @options[\"ssl-city\"],\n \"-s\", @options[\"ssl-state\"]\n ]\n Runner.exec(\"gensslcert\", args)\n end\n\n handle_own_certs @options[\"ssl-certs-dir\"].chomp \\\n unless @options[\"ssl-certs-dir\"].chomp.empty?\n\n key_file = \"/etc/apache2/ssl.key/#{HOSTNAME}-ca.key\"\n crt_file = \"/etc/apache2/ssl.crt/#{HOSTNAME}-ca.crt\"\n portus_key = \"/srv/Portus/config/server.key\"\n\n missing_file(key_file) unless File.exist?(key_file)\n missing_file(crt_file) unless File.exist?(crt_file)\n\n # Move key to portus dir, set permissions and create symlink\n # bsc#1022811\n FileUtils.cp(\n key_file,\n portus_key\n )\n FileUtils.chown(\"wwwrun\", \"www\", portus_key)\n FileUtils.chmod(0o440, portus_key)\n FileUtils.rm(key_file)\n FileUtils.ln_s(\n portus_key,\n key_file\n )\n\n FileUtils.cp(\n crt_file,\n \"/srv/www/htdocs\"\n )\n FileUtils.chmod(0o755, \"/srv/www/htdocs/#{HOSTNAME}-ca.crt\")\n FileUtils.cp(\n crt_file,\n \"/etc/pki/trust/anchors\"\n )\n Runner.exec(\"update-ca-certificates\")\n end", "def generate_certs(workspace_id, agent_guid)\n log.info('Generating certificate')\n\n # Create new private key of 2048 bits\n key = OpenSSL::PKey::RSA.new(2048)\n\n x509_version = 2 # enable X509 V3 extensions\n two_byte_range = 2**16 - 2 # 2 digit byte range for serial number\n year = 1 * 365 * 24 * 60 * 60 # 365 days validity for certificate\n\n # Generate CSR from new private key\n csr = OpenSSL::X509::Request.new\n csr.version = x509_version\n csr.subject = OpenSSL::X509::Name.new(\n [\n ['CN', workspace_id],\n ['CN', agent_guid],\n ['OU', 'Linux Monitoring Agent'], # TODO: Change this?\n ['O', 'Microsoft']\n ]\n )\n csr.public_key = key.public_key\n csr.sign(key, OpenSSL::Digest.new('SHA256'))\n\n # Self-sign CSR\n csr_cert = OpenSSL::X509::Certificate.new\n csr_cert.serial = SecureRandom.random_number(two_byte_range) + 1\n csr_cert.version = x509_version\n csr_cert.not_before = Time.now\n csr_cert.not_after = Time.now + year\n csr_cert.subject = csr.subject\n csr_cert.public_key = csr.public_key\n csr_cert.issuer = csr_cert.subject # self-signed\n ef = OpenSSL::X509::ExtensionFactory.new\n ef.subject_certificate = csr_cert\n ef.issuer_certificate = csr_cert\n csr_cert.add_extension(ef.create_extension('subjectKeyIdentifier', 'hash', false))\n csr_cert.add_extension(ef.create_extension('authorityKeyIdentifier', 'keyid:always', false))\n csr_cert.add_extension(ef.create_extension('basicConstraints', 'CA:TRUE', false))\n csr_cert.sign(key, OpenSSL::Digest.new('SHA256'))\n\n # Return key and cert\n [key, csr_cert]\n rescue => e\n error = e\n log.error(\"Error generating certs: #{error.message}\")\n exit\n end", "def create_self_signed_cert(bits, cn, comment)\n\trsa = OpenSSL::PKey::RSA.new(bits){|p,n|\n\t\tcase p\n\t\twhen 0; $stderr.putc \".\" # BN_generate_prime\n\t\twhen 1; $stderr.putc \"+\" # BN_generate_prime\n\t\twhen 2; $stderr.putc \"*\" # search good prime,\n\t\t\t# n = #of try,\n\t\t\t# data came from BN_generate_prime too\n\t\twhen 3; $stderr.putc \"\\n\" # found good prime, n == 0 - p, n == 1 - q,\n\t\t\t# data came from BN_generate_prime too\n\t\telse; $stderr.putc \"*\" # BN_generate_prime\n\t\tend\n\t}\n\tcert = OpenSSL::X509::Certificate.new\n\tcert.version = 2\n\tcert.serial = 1\n\tname = OpenSSL::X509::Name.new(cn)\n\tcert.subject = name\n\tcert.issuer = name\n\tcert.not_before = Time.now\n\tcert.not_after = Time.now + (365 * 24 * 60 * 60)\n\tcert.public_key = rsa.public_key\n\n\tef = OpenSSL::X509::ExtensionFactory.new(nil, cert)\n\tef.issuer_certificate = cert\n\tcert.extensions = [\n\t\tef.create_extension('basicConstraints', 'CA:FALSE'),\n\t\tef.create_extension('keyUsage', 'keyEncipherment'),\n\t\tef.create_extension('subjectKeyIdentifier', 'hash'),\n\t\tef.create_extension('extendedKeyUsage', 'serverAuth'),\n\t\tef.create_extension('nsComment', comment),\n\t]\n\taki = ef.create_extension('authorityKeyIdentifier', 'keyid:always, issuer:always')\n\tcert.add_extension(aki)\n\tcert.sign(rsa, OpenSSL::Digest::SHA1.new)\n\n\treturn [ cert, rsa ]\nend", "def generate(socket, distinguished_name)\n attributes = {\n :type => :client,\n :subject => distinguished_name\n }\n keypair, certificate = server.depot.generate_keypair_and_certificate(attributes)\n socket.write keypair.private_key.to_s\n socket.write certificate.certificate.to_s\n end", "def create_certificate\n create_app_cert(params['app_identifier'], params['cert'], params['pkey'])\n redirect_to \"/\", flash: { error_message: @error_message }\n end", "def test_generate_certs\n assert pki.server_cert.verify(pki.ca_cert.public_key)\n end", "def prepare_certificate(csr)\n cert = OpenSSL::X509::Certificate.new\n cert.subject = csr.subject\n cert.public_key = csr.public_key\n cert\n end", "def ssl_certificate\n @ssl_certificate ||= OpenSSL::X509::Certificate.new <<-CERT\n-----BEGIN CERTIFICATE-----\nMIIBQjCB7aADAgECAgEAMA0GCSqGSIb3DQEBBQUAMCoxDzANBgNVBAMMBm5vYm9k\neTEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUwIBcNMTExMTAzMjEwODU5WhgPOTk5\nOTEyMzExMjU5NTlaMCoxDzANBgNVBAMMBm5vYm9keTEXMBUGCgmSJomT8ixkARkW\nB2V4YW1wbGUwWjANBgkqhkiG9w0BAQEFAANJADBGAkEA8pmEfmP0Ibir91x6pbts\n4JmmsVZd3xvD5p347EFvBCbhBW1nv1GsbCBEFlSiT1q2qvxGb5IlbrfdhdgyqdTX\nUQIBATANBgkqhkiG9w0BAQUFAANBAAAB////////////////////////////////\n//8AMCEwCQYFKw4DAhoFAAQUePiv+QrJxyjtEJNnH5pB9OTWIqA=\n-----END CERTIFICATE-----\n CERT\n end", "def setup\n generate_ca_certificate unless @host.certificate\n end", "def create_certificate_set(**options)\n # we create the number of trusted roots, then for each root, the intermediates,\n # and for each intermediate, the leaves\n root_certs = []\n intermediate_certs = []\n leaf_certs = []\n root_options = options[:root_options] || {}\n intermediate_options = options[:intermediate_options] || {}\n leaf_options = options[:leaf_options] || {}\n options[:root_count].times do |root_index|\n root, root_key = create_root_certificate(\n dn: \"DC=com, DC=example, OU=ca, CN=Root #{root_index + 1}\",\n serial: root_index + 1,\n **root_options\n )\n root_cert_id = OpenSSL::OCSP::CertificateId.new(\n root, root, OpenSSL::Digest::SHA1.new\n )\n root_certs << {\n type: :root,\n certificate: Certificate.new(root),\n key: root_key,\n signing_cert_id: root_cert_id,\n cert_id: root_cert_id,\n }\n options[:intermediate_count].times do |intermediate_index|\n intermediate, intermediate_key = create_intermediate_certificate(\n dn: [\n 'DC=com',\n 'DC=example',\n 'OU=ca',\n \"CN=Intermediate #{root_index + 1}-#{intermediate_index + 1}\",\n ].join(' '),\n serial: intermediate_index + 1,\n ca: root,\n ca_key: root_key,\n **intermediate_options\n )\n intermediate_cert_id = OpenSSL::OCSP::CertificateId.new(\n intermediate, root, OpenSSL::Digest::SHA1.new\n )\n intermediate_certs << {\n type: :intermediate,\n certificate: Certificate.new(intermediate),\n key: intermediate_key,\n signing_cert_id: root_cert_id,\n cert_id: intermediate_cert_id,\n }\n options[:leaf_count].times do |leaf_index|\n cn_number = root_index * options[:intermediate_count] +\n intermediate_index * options[:leaf_count] +\n leaf_index\n leaf = create_leaf_certificate(\n dn: [\n 'DC=com',\n 'DC=example',\n 'OU=foo',\n \"CN=bar #{cn_number}\",\n ].join(' '),\n serial: leaf_index + 1,\n ca: intermediate,\n ca_key: intermediate_key,\n **leaf_options\n )\n leaf_cert_id = OpenSSL::OCSP::CertificateId.new(\n leaf, intermediate, OpenSSL::Digest::SHA1.new\n )\n leaf_certs << {\n type: :leaf,\n certificate: Certificate.new(leaf),\n signing_cert_id: intermediate_cert_id,\n cert_id: leaf_cert_id,\n }\n end\n end\n end\n root_certs + intermediate_certs + leaf_certs\n end", "def make_ca(config, verbose=false)\n unless config['certmaker'].has_key? 'customgoodca'\n puts \"CertMaker does not have a 'customgoodca' entry, so a CA will be regenerated every time.\"\n return\n end\n\n cacert = config['certmaker']['customgoodca']['certfile']\n cakey = config['certmaker']['customgoodca']['keyfile']\n\n if File.exist? cacert and File.exist? cakey\n puts \"CA and CA's key already exist.\"\n elsif File.exist? cacert and not File.exist? cakey\n raise \"CA certificate exists, but the key file does not exist?!\"\n elsif not File.exist? cacert and File.exist? cakey\n raise \"CA certificate does not exist, but the key file exists?!\"\n else\n puts \"Generating a new CA\"\n cacertdir = File.dirname(config['certmaker']['customgoodca']['certfile'])\n FileUtils.mkdir_p cacertdir, :verbose => verbose\n cakeydir = File.dirname(config['certmaker']['customgoodca']['keyfile'])\n FileUtils.mkdir_p cakeydir, :verbose => verbose\n csg = CertificateSuiteGenerator.new(config['certs'], config['hostname'], config['certmaker'])\n csg.generate_certificate('goodca',config['certs']['goodca'])\n cadata = csg.certificates['goodca']\n File.open(cacert,\"wb\") { |f| f.write cadata[:cert] }\n File.open(cakey,\"wb\") { |f| f.write cadata[:key] }\n puts \"New CA generated.\"\n puts \"Make sure you remove or comment out the passphrase in config.yml if you had one previously set!\"\n end\n end", "def to_x509()\n @cert\n end", "def generate_device_certificate!(csr)\n certificate = CertificateBuilder.build(csr)\n certificate.sign(RubyScep.configuration.ca_key, OpenSSL::Digest::SHA1.new)\n @device_certificate = certificate\n end", "def generate\n Puppet.info \"Creating a new SSL key for #{name}\"\n @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i)\n end", "def ca_cert()\n\t\tENV['CA_FILE'] || \"TestCA.crt\" # The CA cert File\n end", "def add_keycert(keycert_file); end", "def certificate_path\n\t\t\tFile.join(@root, \"#{@hostname}.crt\")\n\t\tend", "def ensure_ca_certificates\n final_state = run_machine(NeedCACerts.new, NeedKey)\n final_state.ssl_context\n end", "def sign_certificate(host)\n return if [master, dashboard, database].include? host\n \n hostname = Regexp.escape host.node_name\n \n last_sleep = 0\n next_sleep = 1\n (0..10).each do |i|\n fail_test(\"Failed to sign cert for #{hostname}\") if i == 10\n \n on master, puppet(\"cert --sign --all\"), :acceptable_exit_codes => [0,24]\n break if on(master, puppet(\"cert --list --all\")).stdout =~ /\\+ \"?#{hostname}\"?/\n sleep next_sleep\n (last_sleep, next_sleep) = next_sleep, last_sleep+next_sleep\n end\n end", "def test_storeAndSign\n ca = nil\n caserv = nil\n\n # make our CA server\n assert_nothing_raised {\n caserv = Puppet::Network::Handler.ca.new(:autosign => false)\n }\n\n # retrieve the actual ca object\n assert_nothing_raised {\n ca = caserv.ca\n }\n\n # make our test cert again\n key = nil\n csr = nil\n cert = nil\n hostname = \"test.domain.com\"\n assert_nothing_raised {\n cert = Puppet::SSLCertificates::Certificate.new(\n :name => \"anothertest.domain.com\"\n )\n }\n # and the CSR\n assert_nothing_raised {\n cert.mkcsr\n }\n\n # retrieve them\n certtext = nil\n assert_nothing_raised {\n certtext, cacerttext = caserv.getcert(\n cert.csr.to_s, \"test.reductivelabs.com\", \"127.0.0.1\"\n )\n }\n\n # verify we got nothing back, since autosign is off\n assert_equal(\"\", certtext)\n\n # now sign it manually, with the CA object\n x509 = nil\n assert_nothing_raised {\n x509, cacert = ca.sign(cert.csr)\n }\n\n # and write it out\n cert.cert = x509\n assert_nothing_raised {\n cert.write\n }\n\n assert(File.exists?(cert.certfile))\n\n # now get them again, and verify that we actually get them\n newtext = nil\n assert_nothing_raised {\n newtext, cacerttext = caserv.getcert(cert.csr.to_s)\n }\n\n assert(newtext)\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(newtext)\n }\n\n # Now verify that we can clean a given host's certs\n assert_nothing_raised {\n ca.clean(\"anothertest.domain.com\")\n }\n\n assert(!File.exists?(cert.certfile), \"Cert still exists after clean\")\n end", "def create\n # get the ca\n @authority = Certify::Authority.find(params[:certify_authority_id])\n\n # generate a new one\n @certificate = Certify::Certificate.new(params[:certificate])\n\n # generate the csr\n if (params[:csr] && params[:csr] != \"\")\n csr = Certify::Csr.new :data => params[:csr]\n else\n kp = Certify::KeyPair.find(params[:keypair][:id])\n csr = kp.generate_csr('CN=ca/DC=example')\n end\n\n # sign the csr\n @certificate = @authority.sign_csr(csr)\n\n # format\n respond_to do |format|\n if @certificate && @certificate.valid?\n format.html { redirect_to certify_authority_path(@authority), notice: 'Certificate was successfully created.' }\n format.json { render json: @certificate, status: :created, location: @certificate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @certificate.errors, status: :unprocessable_entity }\n end\n end\n end", "def certificate; end", "def certificate; end", "def build_create_certificate_request\n set_cert_contents\n add_encrypted_request_to_soap(encrypt_application_request)\n end", "def save_certificate(certificate)\n if !ENV['DYNO'].nil?\n Rails.logger.info('You are running this script on Heroku, please copy-paste certificates to your local machine')\n Rails.logger.info('and then follow https://devcenter.heroku.com/articles/ssl-endpoint guide:')\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-cert.pem ======\")\n puts certificate.to_pem\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-key.pem ======\")\n puts certificate.request.private_key.to_pem\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-chain.pem ======\")\n puts certificate.chain_to_pem\n\n Rails.logger.info(\"====== #{CONFIG[:domain]}-fullchain.pem ======\")\n puts certificate.fullchain_to_pem\n\n elsif File.directory?(File.join(Rails.root, CONFIG[:output_cert_dir]))\n Rails.logger.info('Saving certificates and key...')\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-cert.pem\"), certificate.to_pem)\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-key.pem\"), certificate.request.private_key.to_pem)\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-chain.pem\"), certificate.chain_to_pem)\n File.write(File.join(Rails.root, CONFIG[:output_cert_dir], \"#{CONFIG[:domain]}-fullchain.pem\"), certificate.fullchain_to_pem)\n else\n Rails.logger.error(\"Output directory: '#{File.join(Rails.root, CONFIG[:output_cert_dir])}' does not exist!\")\n end\n end", "def create\n # Revoke the old cert before creating a new one\n revoke_cert if certificate && private_key && check_cert_exists\n new_cert = create_cert\n client_cert_save(new_cert)\n end", "def openssl_create_csr(*args,&block)\n key = args[0][:key]\n name = OpenSSL::X509::Name.new [['CN', \"To be detailed\"]]\n req = OpenSSL::X509::Request.new\n req.version = 0\n req.subject = name\n req.public_key = key.public_key\n req.sign key, OpenSSL::Digest::SHA1.new\n req\n end", "def certificate_subject\n return \"CN=#{project.package_name}\" unless signing_identity\n\n store = machine_store? ? \"LocalMachine\" : \"CurrentUser\"\n cmd = [].tap do |arr|\n arr << \"powershell.exe\"\n arr << \"-ExecutionPolicy Bypass\"\n arr << \"-NoProfile\"\n arr << \"-Command (Get-Item Cert:/#{store}/#{cert_store_name}/#{thumbprint}).Subject\"\n end.join(\" \")\n\n shellout!(cmd).stdout.strip\n end", "def get_certificate(aliaz)\n\n end", "def use_bundled_cert!\n config.delete(:ssl_ca_directory)\n config.delete(:ssl_ca_store)\n config[:ssl_ca_bundle] = File.expand_path(File.join(\n File.dirname(__FILE__),\n '..',\n 'ca-bundle.crt'\n ))\n end", "def make_ssl_cert_file(cert_file)\n\n uri = URI(@cert_source_uri)\n\n Net::HTTP.start(uri.host) { |http|\n resp = http.get(uri.path)\n open(cert_file, \"w\") { |file|\n file.write(resp.body)\n }\n }\n end", "def cert_file\n write_file(\"request-#{domain}.crt\", cert.to_pem)\n end", "def create_sslcert\n converge_by(\"Create Cert #{new_resource}\") do\n Chef::Log.info \"Create #{new_resource}\"\n\n update_sslcert\n\n new_resource.updated_by_last_action(true)\n end\n end", "def ca_file; end", "def ca_file; end", "def create\n # Revoke the old cert before creating a new one\n cert = certificate_get\n priv_key = private_key_get\n if cert && priv_key\n revoke_cert\n end\n new_cert = create_cert\n client_cert_save(new_cert)\n end", "def openssl_generate_key(*args,&block)\n keypair = OpenSSL::PKey::RSA.new CaHelper.ca_config['key_size']\n end", "def prepare_azure_cert\n cycle_credential_artifact('well-known', 'api-cert', azure_properties['cert_file'], @seed_api_cert_path)\n end", "def cert; end", "def cert; end", "def cert; end", "def add_certificate(http); end", "def signing_request\n req = OpenSSL::X509::Request.new\n req.public_key = key.public_key\n req.subject = OpenSSL::X509::Name.new([['CN', domain]])\n req.sign(key, OpenSSL::Digest::SHA256.new)\n end", "def ca_key()\n\t\tENV['CA_KEY'] || nil # The CA private key File\n end", "def sign_certificate_for(host = [])\n hostnames = []\n hosts = host.is_a?(Array) ? host : [host]\n puppet_version = on(master, puppet('--version')).stdout.chomp\n hosts.each do |current_host|\n if [master, dashboard, database].include? current_host\n on current_host, puppet('agent -t'), acceptable_exit_codes: [0, 1, 2]\n\n if version_is_less(puppet_version, '5.99')\n on master, puppet(\"cert --allow-dns-alt-names sign #{current_host}\"), acceptable_exit_codes: [0, 24]\n else\n on master, \"puppetserver ca sign --certname #{current_host}\"\n end\n else\n hostnames << Regexp.escape(current_host.node_name)\n end\n end\n\n if hostnames.size < 1\n if version_is_less(puppet_version, '5.99')\n on master, puppet('cert --sign --all --allow-dns-alt-names'),\n acceptable_exit_codes: [0, 24]\n else\n on master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24]\n end\n return\n end\n\n while hostnames.size > 0\n last_sleep = 0\n next_sleep = 1\n 11.times do |i|\n if i == 10\n fail_test(\"Failed to sign cert for #{hostnames}\")\n hostnames.clear\n end\n\n if version_is_less(puppet_version, '5.99')\n on master, puppet('cert --sign --all --allow-dns-alt-names'), acceptable_exit_codes: [0, 24]\n out = on(master, puppet('cert --list --all')).stdout\n if hostnames.all? { |hostname| out =~ /\\+ \"?#{hostname}\"?/ }\n hostnames.clear\n break\n end\n else\n on master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24]\n out = on(master, 'puppetserver ca list --all').stdout\n if out !~ /.*Requested.*/ && hostnames.all? { |hostname| out =~ /\\b#{hostname}\\b/ }\n hostnames.clear\n break\n end\n end\n\n sleep next_sleep\n (last_sleep, next_sleep) = next_sleep, last_sleep + next_sleep\n end\n end\n host\n end", "def certificate_chain(private_key_alias, keystore_intermediate_path, keystore_authorizable_id)\n RubyAem::Resources::CertificateChain.new(@client, private_key_alias, keystore_intermediate_path, keystore_authorizable_id)\n end", "def run\n @type = (Cert.config[:development] ? DEVELOPMENT : DISTRIBUTION)\n file = find_existing_cert\n if file\n # We don't need to do anything :)\n ENV[\"CER_FILE_PATH\"] = file\n else\n create_certificate\n end\n rescue => ex\n error_occured(ex)\n end", "def sign!(signing_profile={})\n raise \"Invalid certificate #{self.errors.full_messages}\" unless valid?\n merge_profile_with_extensions(signing_profile)\n\n openssl_cert = OpenSSL::X509::Certificate.new\n openssl_cert.version = 2\n openssl_cert.not_before = self.not_before\n openssl_cert.not_after = self.not_after\n openssl_cert.public_key = self.key_material.public_key\n\n openssl_cert.serial = self.serial_number.number\n\n openssl_cert.subject = self.distinguished_name.to_x509_name\n openssl_cert.issuer = parent.distinguished_name.to_x509_name\n\n factory = OpenSSL::X509::ExtensionFactory.new\n factory.subject_certificate = openssl_cert\n\n #NB: If the parent doesn't have an SSL body we're making this a self-signed cert\n if parent.openssl_body.nil?\n factory.issuer_certificate = openssl_cert\n else\n factory.issuer_certificate = parent.openssl_body\n end\n\n factory.config = build_openssl_config\n\n # Order matters: e.g. for self-signed, subjectKeyIdentifier must come before authorityKeyIdentifier\n self.extensions.keys.sort{|a,b| b<=>a}.each do |k|\n e = extensions[k]\n next if e.to_s.nil? or e.to_s == \"\" ## If the extension returns an empty string we won't include it\n ext = factory.create_ext(e.openssl_identifier, e.to_s, e.critical)\n openssl_cert.add_extension(ext)\n end\n\n if signing_profile[\"digest\"].nil?\n digest = OpenSSL::Digest.new(\"SHA512\")\n else\n digest = OpenSSL::Digest.new(signing_profile[\"digest\"])\n end\n\n self.openssl_body = openssl_cert.sign(parent.key_material.private_key, digest)\n end", "def build_certificate_request\n set_body_contents\n end", "def build_certificate_request\n set_body_contents\n end", "def distrust_certs()\n process_certs(\"Explicitly distrusting certs\", CertTools.distrusted_certs_dir)\n end", "def cert_path; end", "def cert_path; end", "def configure(cert)\n req = signing_request\n cert.issuer = Billy.certificate_authority.cert.subject\n cert.not_before = days_ago(2)\n cert.not_after = days_from_now(2)\n cert.public_key = req.public_key\n cert.serial = serial\n cert.subject = req.subject\n cert.version = 2\n end", "def ca_cert_string\n @ca_cert_string ||= begin\n vcap_services[vcap_services.keys.first].first['credentials']['cacrt']\n end\n end", "def create_certificate\n visit CREATE_CERT_URL\n wait_for_elements(\"form[name='certificateSave']\")\n\n Helper.log.info \"Creating a new code signing certificate\"\n\n # select certificate type\n if @type == DEVELOPMENT\n app_store_toggle = first(\"input#type-development\")\n else\n app_store_toggle = first(\"input#type-iosNoOCSP\") || first(\"input#type-iosOCSP\")\n end\n \n if !!app_store_toggle['disabled']\n # Limit of certificates already reached\n raise \"Could not create another certificate, reached the maximum number of available certificates.\".red\n end\n\n app_store_toggle.click\n\n click_next # submit the certificate type\n sleep 2\n click_next # information about how to upload the file (no action required on this step)\n\n cert_signing_request = Cert::SigningRequest.get_path\n Helper.log.info \"Uploading the cert signing request '#{cert_signing_request}'\"\n\n wait_for_elements(\"input[name='upload']\").first.set cert_signing_request # upload the cert signing request\n sleep 1\n click_next\n\n sleep 3\n\n while all(:css, '.loadingMessage').count > 0\n Helper.log.debug \"Waiting for iTC to generate the profile\"\n sleep 2\n end\n\n Helper.log.info \"Downloading newly generated certificate\"\n sleep 2\n\n # Now download the certificate\n download_button = wait_for_elements(\".button.small.blue\").first\n url = download_button['href']\n\n path = File.join(Cert.config[:output_path], \"certificate.cer\")\n download_url(url, path)\n\n certificate_id = url.match(/.*displayId=(.*)&type.*/)[1]\n\n ENV[\"CER_FILE_PATH\"] = path\n ENV[\"CER_CERTIFICATE_ID\"] = certificate_id\n Helper.log.info \"Successfully downloaded latest .cer file to '#{path}' (#{certificate_id})\".green\n\n Cert::KeychainImporter::import_file(path) unless Cert.config[:skip_keychain_import]\n rescue => ex\n error_occured(ex)\n end", "def createkey(hostname, pupmodule, pubfolder, prvfolder)\n return 'Already there' if\n File.exist?(\"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\")\n key = SelfSignedCertificate.new(hostname)\n FileUtils.mkdir_p \"#{pubfolder}/#{pupmodule}/\"\n FileUtils.mkdir_p \"#{prvfolder}/#{hostname}/#{pupmodule}/\"\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.pub.pem\", 'w' do\n |io| io.write key.pub end\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\", 'w' do\n |io| io.write key.crt end\n open \"#{prvfolder}/#{hostname}/#{pupmodule}/#{hostname}.priv.pem\", 'w' do\n |io| io.write key.priv end\n 'OK'\nend", "def certificate(record)\n record.public_send(options[:certificate])\n end", "def cert_pem; end", "def certificate(serial_number)\n RubyAem::Resources::Certificate.new(@client, serial_number)\n end", "def ssl_ca_certificate_file\n super\n end", "def compile\n puts '-----> Creating TrustStore with container certificates'\n\n resolved_certificates = certificates\n with_timing(caption(resolved_certificates)) do\n unless use_jvm_trust_store?\n FileUtils.mkdir_p File.join(@app_dir, NEW_TRUST_STORE_DIRECTORY)\n end\n resolved_certificates.each_with_index { |certificate, index| add_certificate certificate, index }\n end\n end", "def x509_certificate_string\n t=self.metadata_nokogiri.clone\n t.remove_namespaces!\n the_xpath = \"//KeyDescriptor/KeyInfo/X509Data/X509Certificate\"\n node = t.xpath(the_xpath)\n if node.blank?\n raise \"Could not extract X509Certificate from #{site.name}\"\n else\n node.inner_text\n end\n end", "def create_certificate(domain_name)\n token = Digest::MD5.hexdigest(domain_name)\n response = $acm.request_certificate(\n domain_name: \"*.#{domain_name}\", \n validation_method:\"DNS\", \n subject_alternative_names: [domain_name], \n idempotency_token: token\n ) \n cert_data = $acm.describe_certificate certificate_arn: response.certificate_arn\n\n cname_records = cert_data.certificate.domain_validation_options.map do |rec|\n OpenStruct.new(name: rec.resource_record.name, value: rec.resource_record.value)\n end\n\n cname_records.uniq\nend", "def ca_file\n super\n end", "def ca_file\n super\n end", "def ca_cert\n @ca_cert ||= OpenSSL::X509::Certificate.new File.read(ca_cert_file)\n end", "def sign!(cert)\n openssl_cert = cert.cert # because model -> OpenSSL object\n openssl_cert.serial = self.next_serial\n cert.serial = self.next_serial\n openssl_cert.issuer = ca_cert.subject\n openssl_cert.sign private_key, OpenSSL::Digest::SHA1.new\n self.next_serial = self.next_serial + 1\n self.save\n nil\n end", "def certificate\n Base64.strict_encode64(parsed_certificate.to_der)\n end", "def x509\n @x509 ||= OpenSSL::X509::Certificate.new(as_pem)\n end", "def keycerts; end", "def with_certs_dir\n with_repository do |repository|\n certs_dir = \"#{repository}/certificates\"\n FileUtils.mkdir_p certs_dir\n File.write(\"#{certs_dir}/test_cert.crt\", 'Hello')\n yield certs_dir\n end\n end", "def gen_x509_request(subject, key)\n raise TypeError, \"subject must be a Ruby OpenSSL::X509::Name object\" unless subject.is_a?(::OpenSSL::X509::Name)\n raise TypeError, \"key must be a Ruby OpenSSL::PKey::EC or a Ruby OpenSSL::PKey::RSA object\" unless key.is_a?(::OpenSSL::PKey::EC) || key.is_a?(::OpenSSL::PKey::RSA)\n\n request = ::OpenSSL::X509::Request.new\n request.version = 0\n request.subject = subject\n request.public_key = key\n\n # Chef 12 backward compatibility\n ::OpenSSL::PKey::EC.send(:alias_method, :private?, :private_key?)\n\n request.sign(key, ::OpenSSL::Digest.new(\"SHA256\"))\n request\n end", "def own_signing_certificate\n application_response = extract_application_response(OP_PKI)\n at = 'xmlns|Certificate > xmlns|Certificate'\n node = Nokogiri::XML(application_response).at(at, xmlns: OP_XML_DATA)\n\n return unless node\n\n cert_value = process_cert_value node.content\n cert = x509_certificate cert_value\n cert.to_s\n end", "def get_certificate_chain(aliaz)\n\n end" ]
[ "0.75827795", "0.73909265", "0.7386241", "0.7341035", "0.72272605", "0.721721", "0.6991933", "0.6909108", "0.6772082", "0.67239326", "0.6607741", "0.6579856", "0.6563864", "0.6562421", "0.65318424", "0.6519538", "0.63676304", "0.63441074", "0.6337626", "0.6326589", "0.63220567", "0.63179266", "0.62828416", "0.62774915", "0.6277453", "0.62681353", "0.62632155", "0.6254409", "0.6211575", "0.62016237", "0.61961555", "0.61856604", "0.6129238", "0.6099854", "0.6067949", "0.6039047", "0.60343933", "0.60162765", "0.6013019", "0.60112464", "0.60089767", "0.5972407", "0.59634495", "0.59478295", "0.591559", "0.5913259", "0.5912632", "0.5912632", "0.5908427", "0.58901983", "0.5887913", "0.5866173", "0.5846113", "0.58415586", "0.58333004", "0.5826149", "0.58146876", "0.5802326", "0.5793874", "0.5793874", "0.57869005", "0.57859963", "0.5782308", "0.5781163", "0.5781163", "0.5781163", "0.57679784", "0.5764108", "0.5759851", "0.5728267", "0.5725474", "0.5724549", "0.5720851", "0.5712587", "0.5712587", "0.5711816", "0.5710084", "0.5710084", "0.57095754", "0.5695871", "0.56906885", "0.56900775", "0.5672233", "0.5671693", "0.56620747", "0.56527805", "0.56379366", "0.5634418", "0.5626332", "0.56169176", "0.56169176", "0.56111133", "0.56106704", "0.5609649", "0.5604185", "0.560371", "0.55931956", "0.5592735", "0.55879015", "0.5572146" ]
0.7454715
1
Never trust parameters from the scary internet, only allow the white list through.
def status_params params.require(:status).permit(:content,:picture) 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
Default voting If a user submits a post, he'll want to vote it up. mount_uploader :image, ImageUploader
def up_votes # We'll want a way to see only "up" or "down" votes self.votes.where(value: 1).count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uppost\n post = Post.find_by_id(params[:id])\n if !post.nil?\n post.vote(current_user, true)\n end\n end", "def cast_vote # :norobots:\n if image = find_or_goto_index(Image, params[:id].to_s)\n val = image.change_vote(@user, params[:value])\n Transaction.put_images(:id => image, :set_vote => val)\n if params[:next]\n redirect_to_next_object(:next, Image, params[:id].to_s)\n else\n redirect_to(:action => 'show_image', :id => id, :params => query_params)\n end\n end\n end", "def set_vote_pic\n @vote_pic = VotePic.find(params[:id])\n\t\tend", "def cast_vote\n image = find_or_goto_index(Image, params[:id].to_s)\n return unless image\n\n image.change_vote(@user, params[:value])\n if params[:next]\n redirect_to_next_object(:next, Image, params[:id].to_s)\n else\n redirect_with_query(action: \"show_image\", id: id)\n end\n end", "def vote\n\t\t@review = Review.find(params[:id])\n\n\t\tif params[:type] == 'up'\n\t\t\[email protected]_or_update_evaluation(:up_votes, 1, current_user)\n\t\tend\n\n\t\t# Both up and down votes affect total votes\n\t\[email protected]_or_update_evaluation(:total_votes, 1, current_user)\n\t\t\n\t\tflash[:success] = \"Thanks for voting!\"\n\t\tredirect_to :back\n\tend", "def upvote\n\t\tif vote_once\n\t\t\t@vote = @post.votes.create(user_id: current_user.id)\n\t\telse\n\t\t\t@vote = false\n\t\tend\n\t\tbyebug\n\t\trespond_to do |format|\n\t\t\tformat.js\n\t\tend\n\tend", "def set_up_vote\n @up_vote = UpVote.find(params[:id])\n end", "def vote\n\tend", "def vote\n @user = User.find(params[:vote][:user_id])\n return false unless verify_user?\n\n if params[:vote][:votable_type] == \"Post\"\n votable = Post.find(params[:vote][:votable_id])\n elsif params[:vote][:votable_type] == \"Comment\"\n votable = Comment.find(params[:vote][:votable_id])\n end\n\n vote = Vote.where(user: @user, votable: votable).first_or_initialize\n # This seems a little redundant, but I want to avoid tricky unnoticed typecasting\n is_upvote = params[:vote][:is_upvote] == \"true\" ? true : false\n if is_upvote == vote.is_upvote\n vote.destroy\n else\n vote.is_upvote = is_upvote\n vote.save\n end\n\n votable.reload_votes\n\n render text: \"\"\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def photo_params\n params.require(:vote).permit(:photo_id)\n end", "def set_voting\n @voting = Voting.find(params[:id])\n end", "def set_voting\n @voting = Voting.find(params[:id])\n end", "def set_voting\n @voting = Voting.find(params[:id])\n end", "def set_vote\n\t\t@vote = Vote.find_by_id(params[:id])\n\t\tif @vote.nil?\n\t\t\tredirect_to main_app.admin_voters_path, alert: I18n.t(\"activerecord.errors.models.vote.not_found\")\n\t\tend\n\tend", "def set_upvote\n @upvote = Upvote.find(params[:id])\n end", "def vote up\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def set_vote\n @vote = Vote.find(params[:id])\n end", "def vote\n value = params[:type] == \"up\" ? 1 : -1\n @post.add_or_update_evaluation(:votes, value, current_user)\n redirect_to :back\n end", "def upvote\n\t\t@product = Product.find(parms[:id])\n\t\t@vote = @product.votes.new(user_id: current_user)\n\t\tif @vote.save\n\t\t\tredirect_to products_path, notice: 'Post was succesfully upvoted'\n\t\telse\n\t\t\tredirect_to products_path, notice: 'You have already voted'\n\t\tend\n\tend", "def create_vote\n\t\tuser.votes.create(value: 1, post: self)\n\tend", "def vote\n value = params[:type] == \"up\" ? 1 : -1\n @mypost = Mypost.find(params[:id])\n @mypost.add_or_update_evaluation(:votes, value, current_user)\n redirect_to :back, notice: \"Thank you for voting!\"\nend", "def create_vote\r\n\t\tuser.votes.create(value: 1, post: self)\r\n\tend", "def photo_params\n params.require(:photo).permit(:user_id, :avatar, :body, :vote)\n end", "def auto_upvote\n upvote(self.user)\n end", "def upvote\n\t @post = Post.find(params[:id])\n\t @post.upvote_by current_user\n\t redirect_to root_path\n\n\tend", "def vote_params\n params.require(:vote).permit(:post_id, :up, :user_id)\n end", "def create_vote\n self.user.votes.create(value: 1, post: self)\n end", "def create_vote\n self.user.votes.create(value: 1, post: self)\n end", "def create_vote\n user.votes.create(value: 1, post: self)\n end", "def create\n @photo = Photo.new(photo_params)\n @photo.vote =0\n respond_to do |format|\n if @photo.save\n current_user.photos.push @photo\n format.html { redirect_to photos_path, notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n\n else\n format.html { render :new }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def vote_up\n update_votes(1)\n end", "def vote_pic_params\n params.require(:vote_pic).permit(:src)\n end", "def create\n @vote = Vote.new\n end", "def create\n @upvote = Upvote.new(upvote_params)\n @upvote.user_id = current_user.id\n if @upvote.comment_id?\n\t@comment = Comment.find(@upvote.comment_id)\n @user = User.find(@comment.user_id)\n @comment.update_attribute(:votes, @comment.votes + 1)\n else\n\t@post = Post.find(@upvote.post_id)\n\t@user = User.find(@post.user_id)\n\n end\n\n @user.update_attribute(:karma, @user.karma + 1)\n\n respond_to do |format|\n if @upvote.save\n\t\tif @upvote.post_id?\n\t\t\tformat.html { redirect_back(fallback_location: root_path) }\n\t\telse\n\t\t\tformat.html { redirect_to @upvote.comment.post }\n\t\tend\n format.json { render :show, status: :created, location: @upvote }\n else\n format.html { render :new }\n format.json { render json: @upvote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if(Post.find(params[:post_vote][:post_id]).user_id != params[:post_vote][:user_id]) # only vote if it's not the same user who wrote the post!\n @api_v1_post_vote=PostVote.find_by_post_id_and_user_id(params[:post_vote][:post_id], params[:post_vote][:user_id])\n if @api_v1_post_vote.nil?\n @api_v1_post_vote = PostVote.new(params[:post_vote])\n else\n @api_v1_post_vote.vote = params[:post_vote][:vote]\n end\n\n respond_to do |format|\n if @api_v1_post_vote.save\n #format.html { redirect_to @api_v1_post_vote, notice: 'Post vote was successfully created.' }\n format.json { render json: @api_v1_post_vote, status: :created }\n else\n # format.html { render action: \"new\" }\n format.json { render json: @api_v1_post_vote.errors.messages.values, status: 400 }\n end\n end\n else\n render json: \"Can't vote for yourself.\", status: 400\n end\n end", "def upvote\n\t\t@post = Post.find(params[:id])\n\t\[email protected]_by current_user\n\t\t\n\t\trespond_to do |format|\n\t format.html { redirect_back(fallback_location: root_path) }\n\t format.js\n\t end\n\tend", "def up_vote\n @post = Post.not_published.find(params[:id])\n vote = @post.moderator_votes.new(:up_vote => true)\n vote.user = current_user if logged_in?\n vote.session_id = session[:session_id]\n vote.save\n flash[:notice] = \"Thanks for your help moderating upcoming posts.\"\n redirect_to moderators_path\n end", "def upvote\n @post = Post.find_by(id: params[:id])\n # raise 'hell'\n\n # the following line to be uncommented when we go live to allow for 1 vote per user\n # Vote.find_or_create_by(post: @post, user: @current_user)\n # Vote.find_or_create_by(upvote: 1, post: @post, user: @current_user)\n Vote.create(upvote: 1, post: @post, user: @current_user)\n check_score()\n make_request()\n end", "def update_uploader\n self.uploader_id = Authorization.current_user.id unless self.uploader_id.present?\n end", "def vote\n if @current_worker and taskname = params[:task]\n displayed = params[:displayed] || []\n displayed = displayed.map { |el| el.to_i }\n\n flagged = params[:flagged] || []\n flagged = flagged.map { |el| el.to_i }\n\n approved = displayed - flagged\n\n approved.each do |fid|\n if foto = Photo.find_by_id(fid)\n foto.create_vote('pass', taskname, @current_worker)\n end\n end\n\n flagged.each do |fid|\n if foto = Photo.find_by_id(fid)\n foto.create_vote('fail', taskname, @current_worker)\n end\n end\n end\n\n redirect_to :action=>'review'\n end", "def vote\n if params[:source].blank? || params[:source_id].blank?\n render :json => {message: 'Missing image info'}, :status => 400\n return\n end\n\n # Process 500px photo vote request\n if params[:source] == Photo::FivehundredPX\n res = begin\n current_fivehundredpx_access_token.post(\"/photos/#{params[:source_id]}/vote?vote=1\")\n rescue Exception => e\n puts e.message\n puts e.backtrace.join(\"\\n\")\n {}\n end\n if !res.kind_of?(Net::HTTPSuccess) && !res.kind_of?(Net::HTTPForbidden)\n render :json => {message: \"Failed to vote.\"}, :status => 404\n return\n end\n end\n # Return success response\n render :json => {message: \"Successfully vote!\"}\n end", "def create_vote\n user.votes.create(value: 1, post: self)\n end", "def form_image_select(post)\n return image_tag post.image.url,\n id: 'image-preview',\n class: 'img-responsive'\n\n\nend", "def set_voteaction\n @voteaction = Voteaction.find(params[:id])\n end", "def set_upload\n @contest.upload.update_column(:image, nil) if params[:image_url].eql?(\"true\")\n @contest.upload.update_column(:file, nil) if params[:file_url].eql?(\"true\")\n end", "def create_vote\n \t\t#self.votes.create(value: 1, user: self.user )\n \t#\tvotes.create(value: 1, user: user )\n\t \tuser.votes.create(value: 1, post: self)\n \tend", "def set_image_upload\n @image_upload = ImageUpload.find(params[:id])\n end", "def new_vote(vote, votable, voter)\n vote == 'up' ? votable.upvote_by(voter) : votable.downvote_by(voter)\n change_carma(vote, votable, voter,\n ex_up: 2, ex_down: -1, ph_up: 4, ph_down: -2, usr: 1)\n flash[:notice] = 'Thank you for your vote.'\n end", "def vote\n return unless logged_in?\n @snippet = Snippet.find(params[:id])\n unless @snippet.voted_by_user?(current_user)\n @vote = Vote.new(:vote => params[:vote] == \"for\")\n @vote.user_id = current_user.id\n # @snippet.how_truthful = @snippet.votes_for / @snippet.votes_count\n @snippet.votes << @vote\n end\n end", "def show\n\t\t@vote_pic = VotePic.find(params[:id])\n end", "def downpost\n post = Post.find_by_id(params[:id])\n if !post.nil?\n post.vote(current_user, false)\n end\n end", "def create\n @post = Post.find(params[:postID])\n if (@post.checkIfVoted(@post.id.to_s, session[:user_id].to_s)[0]!=nil )\n redirect_to @post, notice: 'You have already voted for this post.'\n elsif @post.postUserID.to_s == session[:user_id].to_s\n redirect_to @post, notice: 'You can not vote for yourself'\n else\n @vote = Vote.new(params[:vote])\n @vote.postID = params[:postID]\n @vote.userID = session[:user_id]\n\n @post.increment(:votes)\n @post.save\n # @post.voted((@post.votes+1).to_s,@post.id.to_s)\n #@post.increment(votes)\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @post, notice: 'Vote successfully.' }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @vote = Vote.new(params[:vote])\n if user_signed_in?\n @vote.user_id = current_user.id\n @vote.save\n redirect_to root_path\n else\n @vote.user_id = nil # explicitly assign nil to prevent injection\n @vote.save\n redirect_to new_user_registration_path(vote_id: @vote.id, label: @vote.chicken ? 'cobra' : 'chicken')\n end\n end", "def form_image_select(post)\n return image_tag post.image.url(:medium),\n id: 'image-preview',\n class: 'img-responsive' if post.image.exists?\n image_tag 'placeholder.jpg', id: 'image-preview', class: 'img-responsive'\n end", "def vote\n #params[:answer_id][:vote]\n #it can be \"1\" or \"-1\"\n @post = Post.find(params[:post_id])\n @post.vote!(params[:post_id][:votes])\n redirect_to :action => 'index'\n end", "def create\n @vote = Vote.new(params[:vote])\n @vote.user_id = session[:user_id]\n if params[:type].eql? \"post\"\n @vote.post_id = params[:post_id]\n else\n @vote.comment_id = params[:comment_id]\n end\n @vote.save\n redirect_to post_url(Post.find(params[:post_id]))\n=begin\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def user_has_voted(post)\n if (current_user)\n if (post.voted_by?(current_user))\n 1\n else\n 0\n end\n else\n 2\n end\nend", "def set_uploader\n @uploader = Uploader.find(params[:id])\n end", "def set_Vote(value)\n set_input(\"Vote\", value)\n end", "def set_Vote(value)\n set_input(\"Vote\", value)\n end", "def submit\n if @vote.nil?\n if @answer.nil?\n flash[:notice] = t(\".no_answer_selected\")\n else\n @vote = ::Refinery::Polls::Vote.vote_by_ip(@answer, request.remote_ip)\n end\n end\n respond_to do |format|\n format.js\n format.html\n end\n end", "def vote_up insert_before_id=false\n register_vote :up, insert_before_id\nend", "def up\n\n respond_to do |format|\n begin\n current_user.vote_for(@voteable)\n flash.now[:success] = 'Your vote has been cast.'\n # render nothing: true, :status => 200\n format.js { render :action => \"control_update\" }\n rescue ActiveRecord::RecordInvalid\n format.js { render :action => \"control_update\" }\n flash.now[:error] = 'You cannot vote on your own content.'\n # render nothing: true, :status => 404\n end\n end\n end", "def vote\n # cancel previous votes\n if (reputation = @reputable.reputations.\n where(user_id: current_user.id).\n in(type: ['useful', 'useless']).first).present?\n @pre_vote_type = reputation.type\n reputation.destroy\n end\n\n # if previous vote type not equal current vote type, then vote\n if params[:vote_type] != @pre_vote_type\n @reputation = @reputable.reputations.create!({user: current_user, type: params[:vote_type]})\n end\n respond_to do |format|\n format.js\n end\n end", "def upvote\n @post.likes.create(user_id: current_user.id)\n\n respond_to do |format|\n format.html { redirect_to posts_path }\n format.js\n end\n end", "def image_params\n if params[:image].present?\n params.require(:image).permit(:file, :post_id)\n end\n end", "def create\n @vote = current_user.votes.build(vote_params)\n if @vote.save\n redirect_to @vote, notice: 'Vote was successfully submitted'\n else\n render action: 'new'\n end\n end", "def upload\n\t\t@musician = User.find_by_id(current_user)\n\t\tif !params[:user].nil?\n\t\t\[email protected] = params[:user][:avatar]\n\t\t\[email protected] = true\n\t\tend\n\n\t\tif @musician.save\n\t\t\tredirect_to musician_path(@musician)\n\t\telse\n\t\t\[email protected] = false if params[:user][:avatar]\n\t\t\trender 'show'\n\t\tend\n\tend", "def update_vote!(new_value)\n if @vote\n authorize @vote, :update?\n @vote.update_attribute(:value, new_value)\n else\n @vote = current_user.votes.build(value: new_value, post: @post)\n authorize @vote, :create?\n @vote.save\n end\n end", "def upvote\n @post = Post.find(params[:id])\n @post_count = Post.count\n @vote = Vote.new(user_id: session[:id], post_id: @post.id, score: 1)\n if @vote.save\n @post.update_attribute(:respect, @post.respect + 1)\n flash[:notice] = 'Post upvoted successfully'\n end\n redirect_to(action: 'index', topic_id: @topic.id)\n end", "def upvote\n @recording = Recording.find(params[:id])\n if @recording.voted_by?(current_user)\n current_user.unvote_for(@recording)\n current_user.vote_for(@recording)\n render partial: \"votecount\"\n else\n current_user.vote_for(@recording)\n render partial: \"votecount\"\n end\n end", "def uploader() @uploader ||= Flickr::Uploader.new(self) end", "def create\n @oldVote = current_user.votes.where(:musing_id => params[:vote][:musing_id]).first\n @musing = Musing.where(:id => params[:vote][:musing_id]).first\n\n\n if @oldVote\n @oldVoteUp = @oldVote.up\n @newVoteUp = params[:vote][:up]\n if (@oldVoteUp == true)\n if (@newVoteUp != false)\n @musing.votecount -=2\n @oldVote.update_attributes(:up => false)\n @oldVote.save\n @musing.save\n end\n else\n if (@newVoteUp != true)\n @musing.votecount +=2\n @oldVote.update_attributes(:up => true)\n @oldVote.save;\n @musing.save\n end\n end\n else\n @vote = current_user.votes.create(params[:vote])\n if @vote.up\n @musing.votecount += 1\n else\n @musing.votecount -= 1\n end\n end\n @musing.save\n redirect_to :back\n end", "def create\n @vote = @parent.votes.new\n# change this later for user login feature\n @vote.user_id = session[:user_id]\n\n respond_to do |format|\n if @vote.save\n @vote.update_post\n format.html { redirect_to :back, notice: 'Vote was successfully created.' }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def up\n vote_status = $redis.hget(\"#{@instance_type}:#{@instance.id}:votes\", current_user.id).to_i\n same_vote = vote_status != 1\n \n if current_user.credit > Settings.vote_up_limit and current_user.vote_per_day > 0 and same_vote\n if vote_status == -1\n @instance.update_attribute(:votes_count, @instance.votes_count + 1)\n @instance.user.update_attribute(:credit, @instance.user.credit + Settings.vote_down)\n current_user.update_attribute(:credit, current_user.credit + Settings.answer_voter_down) if @instance_type == \"answer\"\n current_user.update_attribute(:vote_per_day, current_user.vote_per_day + 1)\n end\n $redis.hset(\"#{@instance_type}:#{@instance.id}:votes\", current_user.id, 1)\n @instance.update_attribute(:votes_count, @instance.votes_count + 1)\n \n case @instance_type\n when \"question\"\n @instance.user.update_attribute(:credit, @instance.user.credit + Settings.question_vote_up)\n when \"answer\"\n @instance.user.update_attribute(:credit, @instance.user.credit + Settings.answer_vote_up)\n end\n \n current_user.update_attribute(:vote_per_day, current_user.vote_per_day - 1)\n \n case @instance_type\n when \"question\"\n record = Vote.where(:user_id => current_user.id, :question_id => @instance.id).first\n if record\n record.update_attribute(:value, 1)\n else\n Vote.create(:user_id => current_user.id, :question_id => @instance.id, :value => 1)\n end\n when \"answer\"\n record = Vote.where(:user_id => current_user.id, :answer_id => @instance.id).first\n if record\n record.update_attribute(:value, 1)\n else\n Vote.create(:user_id => current_user.id, :answer_id => @instance.id, :value => 1)\n end\n end\n end\n end", "def create\n @joke = current_user.jokes.build(joke_params)\n if @joke.save\n upvote_on_post\n redirect_to @joke\n else\n render 'new'\n end\n end", "def set_upload\n @upload = current_user.uploads.find(params[:id])\n end", "def voted\n\t\tcurrent_user = User.current_user\n\t\tunless current_user.blank?\n\t\t\tcurrent_user.voted?(self)\n\t\telse\n\t\t\tfalse\n\t\tend \n\tend", "def upvote(question)\n vote = Vote.new\n vote.user_id = self.id\n vote.question_id = question.id\n vote.question = true\n vote.save!\n end" ]
[ "0.63957137", "0.6270201", "0.62665915", "0.62225986", "0.5970969", "0.59567064", "0.59482086", "0.58975244", "0.58929807", "0.5888929", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.5881109", "0.58734185", "0.58449537", "0.58449537", "0.58449537", "0.5839266", "0.58330107", "0.5821914", "0.58160925", "0.58160925", "0.58160925", "0.5806195", "0.58034724", "0.570351", "0.569611", "0.5688244", "0.5678088", "0.5671794", "0.56511825", "0.5641274", "0.5630942", "0.5630942", "0.5599034", "0.55830115", "0.5582995", "0.55238104", "0.5523365", "0.55212224", "0.5518727", "0.5501407", "0.55004466", "0.54967856", "0.54957503", "0.5487126", "0.54800403", "0.5478989", "0.54773384", "0.5474035", "0.54734606", "0.54730546", "0.5470065", "0.5448006", "0.5440316", "0.5425586", "0.541452", "0.541153", "0.54067993", "0.53949195", "0.5389949", "0.5383034", "0.53803015", "0.53772837", "0.5372458", "0.5372458", "0.536417", "0.5359497", "0.53570545", "0.53439665", "0.5340146", "0.53317815", "0.533034", "0.5323104", "0.53184044", "0.5317359", "0.53118736", "0.5309214", "0.5301596", "0.52884483", "0.5285423", "0.5284579", "0.52806044", "0.527724", "0.5272551" ]
0.0
-1
Who ever created a post, should automatically be set to "voting" it up.
def create_vote self.user.votes.create(value: 1, post: self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @post = Post.new(params[:post])\n @post.user ||= current_user\n\n if @post.save\n Vote.vote_thusly_on_post_or_comment_for_user_because(1, @post.id, nil, current_user.id, nil)\n\n flash[:success] = \"Your post has been submitted successfully.\"\n\n redirect_to @post.comments_url\n else\n return render action: \"new\"\n end\n end", "def new_post(post)\n @user = post.wall_user\n @post = post\n\n mail to: @user.email, subject: \"Someone just posted on your wall.\", reply_to: post.poster.email\n end", "def getPostedBy\r\n\t\t\t\t\treturn @postedBy\r\n\t\t\t\tend", "def getPostedBy\r\n\t\t\t\t\treturn @postedBy\r\n\t\t\t\tend", "def create_vote\n user.votes.create(value: 1, post: self)\n end", "def create_vote\n\t\tuser.votes.create(value: 1, post: self)\n\tend", "def newPost(_, _, _, metaweblog_struct, _)\n post = Post.create(@db.content_path, metaweblog_struct)\n @db.refresh_post_paths\n\n run_user_cmd\n post['postid']\n end", "def create_vote\r\n\t\tuser.votes.create(value: 1, post: self)\r\n\tend", "def create\n @post = current_user.posts.new(params[:post])\n @post.edited_at = Time.current\n @post.published_at = Time.current if params[:publish]\n if @post.save\n flash[:success] = \"Post criado com sucesso.\"\n redirect_to admin_posts_path\n else\n @page_title = \"Novo Post\"\n render :action => 'new'\n end\n end", "def show\n if current_user\n @last_posted_at = Time.current\n end\n end", "def create_vote\n user.votes.create(value: 1, post: self)\n end", "def add_post\n if current_user.id.to_s == params[:user_id].to_s\n post = Post.new(:user_id => params[:user_id], :content => params[:content],\\\n :title => params[:title], :upvotes => 0, :downvotes => 0, :rank => 0)\n post.save!\n end\n end", "def new\n @post = Post.new\n @post.user ||= current_user\n end", "def create_date(post)\n \" created at: \" + post.created_at.strftime(\"%d %b. %Y\") + \" - \" + post.created_at.strftime(\"%H:%M\") \n end", "def posted_on\n \"Posted on \" + self.created_at.strftime(\"%A %m/%d/%Y\")\n end", "def create\n #initialize a new post object with the parameters submitted, validated by post_params\n @post = Post.new(post_params)\n \n isComment = false\n #check whether this is actually a comment, meaning it should have kind=2 and will need an originating post id\n if params[:kind].present?\n @post.kind = params[:kind].to_i\n @post.originatingPost_id = params[:originatingPost_id].to_i\n isComment = true\n \n #otherwise, it is a post, which optionally has tags\n else\n @post.kind = 0\n @tagsToAdd = params[:tagsToAdd].split(\" \")\n @tagsToAdd.each do |t|\n @post.tags << createTag(t)\n end\n end\n \n #either way, the currently logged in user should be logged as the creator of this post/comment\n @post.user = User.find(session[:user_id])\n \n if @post.save!\n if isComment\n redirect_to action: \"show\", :id => params[:originatingPost_id] #stay on the post's show page\n else\n redirect_to action: \"show\", :id => @post.id #go to this new post's show page\n end\n else\n redirect_to action: 'new' #upon failure, try again\n end\n end", "def create_vote\n \t\t#self.votes.create(value: 1, user: self.user )\n \t#\tvotes.create(value: 1, user: user )\n\t \tuser.votes.create(value: 1, post: self)\n \tend", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n @post.save\n redirect_to @post\n\n end", "def create\n @post.character = current_user.character\n authorize! :create, @post\n create! { posts_url }\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n flash[:notice] = 'Post was successfully created.' if @post.save\n redirect_to posts_url\n end", "def post\n @post ||= Post[post_id]\n end", "def create_post_owner_notification_of_reply(reply)\n return if reply.user.id == self.user.id # don't notify user of his own replies..\n if self.user.role == \"Poster\"\n url = \"wall_expert/#{self.id}\"\n else\n url = \"wall/#{self.id}\"\n end\n notify(self.user, \"Your post was commented on!\", \"#{reply.user.profile.full_name} commented on your post!\", :from => reply.user, :key => post_reply_notification_key(reply), :link => '#{url}?reply=#{reply.id}')\n end", "def add_post(post)\n post.author = self \n end", "def create\n post = Post.find(params[:post_id])\n Share.create(user_id: current_user.id, post_id: post.id)\n Post.find(post.id).update_attribute(:updated_at, Time.now)\n redirect_to posts_path\n end", "def add_post(post)\n post.author = self\n end", "def add_post(post)\n post.author = self\n end", "def add_post(post)\n post.author = self\n end", "def published_post\n if self.published && self.published_at.nil?\n self.published_at = Time.now\n end\n end", "def create_post_owner_notification_of_like(like)\n return if like.user.id == self.user.id # don't notify user of his own likes..\n case like.likeable.wallable.class.name\n when 'Recipe'\n url = \"recipes/#{self.wallable_id}\"\n when 'Tip'\n url = \"tips/#{self.wallable_id}\"\n else\n base_url = self.user.poster? ? \"wall_expert\" : \"wall\"\n url = !self.parent_post_id.nil? ? \"#{base_url}/#{self.parent_post_id}?reply=#{self.id}\" : \"#{base_url}/#{self.id}\"\n end\n notify(self.user, \"Your post was liked!\", \"#{like.user.profile.full_name} liked your post!\", :from => like.user, :key => post_like_notification_key(like), :link => url)\n end", "def new_blog_post\n\t\t# Get current time when post was created\n\t\tcurrent_time = Time.now\n\n\t\t# Name of the content creator\n\t\tputs \"Enter your name: \"\n\t\tblog_author = gets.chomp\n\n\t\t# Title of blog post\n\t\tputs \"Post title: \"\n\t\tblog_title=gets.chomp\n\n\t\t# Content of blog post\n\t\tputs \"Create a post: \"\n\t\tblog_content = gets.chomp\n\n\t\t# Create a blog post\n\t\tblogpost=Blog_post.new(current_time.to_s, blog_title, blog_author, blog_content)\n\tend", "def createPost(post)\n isSavePost = post.save\n end", "def create\n @resource = Post.find_by(user_id: current_user.id, url: params[\"post\"][\"url\"])\n if @resource.present?\n # refer article recentry or not\n @refer_recently = @resource.created_at > DateTime.now - 7.days\n else\n @resource = Post.create!(user_id: current_user.id, url: params[\"post\"][\"url\"], title: params[\"post\"][\"title\"])\n UsersPost.create! user_id: current_user.id, post_id: @resource.id\n @refer_recently = false\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user = current_user\n @post.score = 0\n @post.upvoters = \"[-1]\"\n @post.downvoters = \"[-2]\"\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n\n if params[:promote]\n curr_user = User.find(current_user.id)\n tel_numbers = curr_user.destring_favs(curr_user)\n tel_numbers.each do |id|\n user = User.find(id)\n TextMessage.new(\"#{curr_user.name} says #{params[:post][:content]}\", user.phone_no.to_s).send\n end\n end\n\n end", "def create\n @post = Post.new(params[:post])\n @post.user_id = current_user\n\n respond_to do |format|\n if @post.save\n \n # mixpanel track post created\n if Rails.env.production?\n #mixpanel.track 'Post Created', { :distinct_id => current_user.id }\n end\n \n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @postvote = Postvote.new(params[:id])\n @postvote.user_id = session[:user_id]\n @postvote.post_id = @@temp\n @postvote.time = Time.now\n @pst = Post.find(@postvote.post_id)\n @pst.attributes = {:time => Time.now} #Updates the time for the vote in the POST table as well. To record recent activity.\n respond_to do |format|\n if @postvote.save\n @pst.save\n format.html { redirect_to post_path(@pst), notice: 'You have voted for the current post' }\n format.json { render json: @postvote, status: :created, location: @postvote }\n else\n format.html { render action: \"new\", notice: 'Vote not recorded' }\n format.json { render json: @postvote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(params[:post])\n if @post.save\n redirect_to @post, notice: \"Post has been created\"\n else\n render :new\n end\n end", "def set_poster post, sentFlg\n sentFlg ? post.recipient : post.user\n end", "def fetch_create_post\n end", "def create\n @post = Post.new(post_params)\n @post.update_attribute(:user_id, current_user.id)\n \n if @post.save\n flash[:success] = \"Post Created\"\n redirect_to home_path\n \n else\n render action: 'new' \n \n end\n \n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n if @post.save\n success_post_create\n else\n error_post_save\n end\n end", "def create\n #Only the loged user can create posts for himself, not any other user.\n @post = @user.posts.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to [@user,@post], notice: @user.first_name + ', the post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n if @post.save\n redirect_to @post\n else\n render :new\n end\n end", "def create_initial_vote_for_author\n votes.create(:user => user, :value => 1)\n end", "def create\n @post = Post.new(post_params)\n @post.author = @current_user\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 action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_owner(params)\n if validate_post_owner(params)\n db = connect_to_db()\n db.results_as_hash = true\n \n result = db.execute('SELECT userId FROM posts where id=?', params[\"id\"].to_i)\n return result[0][0]\n else\n return false\n end\n end", "def create\n\t\t@post = Post.find(params[:post_id])\n @replyUserID = current_user.id\n\t\t@reply = @post.replies.create(reply_params)\n # puts line of code is here for checking if the user_id was being taken in \n # This was used in debugging when linking replies to a user_id. \n puts '////'\n puts @reply.inspect\n puts '////'\n if @reply.save\n redirect_to @post, notice: 'Reply was successfully created!' \n else\n render :new\n end\n\tend", "def welcome\n @post = Post.last_published\n end", "def create\r\n @post = Post.new(post_params)\r\n\r\n #-------add current_user to user_id-----------\r\n @post.user_id = current_user.id\r\n #---------------------------------------------\r\n \r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\r\n format.json { render :show, status: :created, location: @post }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @post = Post.new(params[:post])\n if current_user\n @post.user_id = current_user.id\n end\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to(root_path, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def print_created_by\n return \"This game was created by Kevin Tripp.\"\n end", "def get_poster_name post, sentFlg\n pname = set_poster(post, sentFlg).name rescue nil\n pname == @user.name ? 'Me' : pname\n end", "def create\n @post = Post.new(params[:post].merge!(:user => current_user))\n if @post.save\n flash[:notice] = 'Your post has been created.'\n redirect_to root_path\n else\n render action: \"new\"\n end\n end", "def initialize #initializes post belonging to author \r\n @post = author\r\n end", "def created_by\r\n\t\t\treturn \"Laura OMalley\"\r\n\t\tend", "def author_name\n self.posts.first.author_name\n end", "def set_post\n @post = Post.find(params[:id])\n @talk = @post.talk\n @originator_person = @post.person\n end", "def create\n @post = Post.new(name: params[:name],\n email: params[:email],\n year: params[:year],\n major: params[:major],\n Q1: params[:Q1],\n Q2: params[:Q2],\n Q3: params[:Q3],\n Q4: params[:Q4],\n Q5: params[:Q5],\n Q6: params[:Q6],\n user_id: @current_user.id)\n if @post.save\n flash[:notice] = \"Your answer has been recorded.\"\n redirect_to(\"/user/#{@current_user.id}\")\n else\n render(\"post/new\")\n end\n end", "def owner?(post_owner) # <= User object\n current_user == post_owner\n end", "def create\n @post.author = current_user\n\n if @post.save\n flash[:notice] = 'Post was successfully created.'\n end\n \n respond_with @post\n end", "def uppost\n post = Post.find_by_id(params[:id])\n if !post.nil?\n post.vote(current_user, true)\n end\n end", "def create\n @post = Post.new(params[:post])\n authorize! :create, @post\n unless params[:author].blank?\n @post.users << User.find(params[:author])\n end\n logger.debug \"Going to save #{Rails.logger.level} #{@post.title.inspect} #{params[:post]}\"\n respond_to do |format|\n if @post.save_post?\n logger.debug \"Saved successfully #{@post.title.inspect}\"\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n logger.debug \"Could not save #{@post.title.inspect}\"\n flash[:alert] = \"Slug cannot be created\"\n format.html { render 'new' }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n \n unless current_user.can_post\n redirect_to welcome_page_path\n end\n \n @post = Post.new\n @post.user = current_user\n @post.privly_application = params[:post][:privly_application]\n\n # Posts default to Private\n if params[:post][:public]\n @post.public = params[:post][:public]\n else\n @post.public = false\n end\n\n set_burn_date\n \n # The random token will be required for users other than the owner\n # to access the content. The model will generate a token before saving\n # if it is not assigned here.\n @post.random_token = params[:post][:random_token]\n \n @post.update_attributes(params[:post])\n \n respond_to do |format|\n if @post.save\n response.headers[\"X-Privly-Url\"] = @post.privly_URL\n format.any { render :json => get_json, \n :status => :created, :location => @post }\n else\n format.any { render :json => @post.errors, \n :status => :unprocessable_entity }\n end\n end\n end", "def is_the_author_of_the_post(post)\n post.author_id == current_author.id\n end", "def create\n if signed_in? && author_signed_in?\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n else\n redirect_to root_path\n end\n end", "def user_has_voted(post)\n if (current_user)\n if (post.voted_by?(current_user))\n 1\n else\n 0\n end\n else\n 2\n end\nend", "def create_post(message, author_name, author_email, author_url = nil, ip_address = nil, created_at = nil)\n new_post_hash = API.create_post(forum_key, id, message, author_name, author_email, author_url, ip_address, created_at)\n new_post = Post.new(new_post_hash.merge(default_hash))\n @posts << new_post if @posts\n new_post\n end", "def get_post_hour(post)\n if post\n post.published_at\n else\n Time.now()\n end\n end", "def add_post(post)\n @posts << post #pushes post into post array so that we can compare the author with that author\n post.author = self\nend", "def set_post\n @post = Post.find(params[:id])\n puts params[:view_by]\n if params[:view_by] == \"recent\"\n end\n end", "def new_post_notification(post)\n #author\n reciever = User.find_by_id post.user_id\n setup_email(reciever)\n @subject +=\"Новый пост в вашем сообществе\"\n body[:url] = RAILS_URL + \"posts/show/#{post.id}\"\n body[:post] = post\n end", "def post\n # TODO re-enable blog post creation. Requires a config file.\n #if @args.length > 0\n # new_post = BlogPost.new(@args.first, @config)\n #else\n # @stderr.puts 'create:post requires a filename. Try yuzu create:post \"Post Title Here\"'\n #end\n end", "def require_creator\n unless logged_in? && current_user = @post.user\n flash[:error] = \"Can't be done\"\n redirect_to root_path\n end\n end", "def new_post(post)\n @greeting = \"Hello! There has been a new post to your discussion on \" + post.discussion.topic + \" at rubydark.herokuapp.com. Please sign in to view the post.\"\n\n mail to: post.discussion.user.email\n end", "def create\r\n new_post = current_user.posts.new(post_params)\r\n new_post.save\r\n redirect_to post_path new_post\r\n end", "def add_post(post)\n @posts << post\n post.author = self\n @@post_count += 1\n end", "def add_post(post)\n @posts << post\n post.author = self\n @@post_count += 1\n end", "def owner\n if @post.author_id == @current_user.id && @current_user.baned == false\n else\n respond_to do |format|\n format.html { redirect_to posts_url, alert: 'У вас нет прав, зарегестрируйтесь.' }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user_id = current_user.id if current_user\n\n respond_to do |format|\n if @post.save\n PeterMailer.new_submit.deliver\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_ad\n # the post_ad method is defined in lib/post_o_matic.rb. the method creates a new listing on kingsnake.com\n # and returns true or false, depending on whether or not it was posted.\n is_posted = super\n if is_posted\n update_posted_ad!\n end\n is_posted\n end", "def create\n @post = Post.new(post_params)\n if ( @post.user_id != current_user.id )\n redirect_to posts_path, notice: 'Undifined user, post was not successfully created.'\n else\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def initialized_post_name\n \"src/_posts/#{Time.now.strftime(\"%Y-%m-%d\")}-welcome-to-bridgetown.md\"\n end", "def create\n @post = @current_user.posts.build(params[:post])\n if @post.save then\n Feed.create_post(@post)\n end\n end", "def create\n @post = Post.new(post_params)\n @post.url = url_with_protocol(@post.url)\n # If the user is not anonymous, change the username to the logged in user's email.\n if @post.username.blank?\n @post.username = current_user.email\n end\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @post = Post.find(params[:id])\n unless @post.user.id == current_user.id\n ahoy.track \"Read Post\", post_id: @post.id\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n if @post.save\n flash[:success] = \"Post was successfully saved\"\n redirect_to post_path(@post)\n else \n render 'new'\n end\n end", "def create\n redirect_to posts_path and return unless Mist.authorized?(:create_post, self)\n coerce_date(params[:post], 'published_at')\n @post = Mist::Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def can_create_comment?(post); true; end", "def create\n @post = Post.new params[:post].merge(:author => current_user)\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => t('posts.show.post_created')) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n if @post.save\n redirect_to post_path(@post)\n else\n render :new\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n \n respond_to do |format|\n if @post.save\n current_user.update(point: current_user.point + 1)\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n \n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @posts = Post.where(:user_id => current_user.id).order(\"created_at DESC\")\n #@posts = Post.all.order(\"created_at DESC\")\n #this post also saves lives\n #https://stackoverflow.com/questions/25831594/devise-how-to-show-users-post\n \n end", "def created_by\n user\n end", "def create\n @post = current_user.posts.create(params[:post])\n\n if @post.save\n flash[:success] = 'Post was successfully created.'\n redirect_to @post\n else\n render :new\n end\n\n end", "def setPostedBy(postedBy)\r\n\t\t\t\t\t@postedBy = postedBy\r\n\t\t\t\tend", "def setPostedBy(postedBy)\r\n\t\t\t\t\t@postedBy = postedBy\r\n\t\t\t\tend", "def create\n if current_user.admin\n @post = Post.new(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Postitus edukalt loodud!\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n\n else\n flash[:notice] = 'You dont have permission to do that!'\n redirect_to posts_path\n end\n\n end", "def camaleon_post_created_at_on_active(plugin)\n end", "def enter_created; end", "def create\n authorize! :create, @post\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6533024", "0.6496797", "0.6473395", "0.6473395", "0.63758665", "0.63555753", "0.63349676", "0.63148034", "0.6281884", "0.6266895", "0.6261689", "0.62605864", "0.6223895", "0.62026113", "0.6138418", "0.6128905", "0.6127989", "0.6061835", "0.60538024", "0.6016958", "0.60059834", "0.59975725", "0.59729064", "0.5946535", "0.59350455", "0.59350455", "0.59350455", "0.59279764", "0.5915884", "0.5914794", "0.5900248", "0.589306", "0.5891536", "0.5882223", "0.5871015", "0.5863804", "0.58594084", "0.58558226", "0.5846443", "0.58460706", "0.5835646", "0.5834965", "0.5833745", "0.58236194", "0.5823521", "0.5822631", "0.5821931", "0.5821698", "0.58166397", "0.5815468", "0.58132213", "0.58130807", "0.58085287", "0.58077693", "0.58036745", "0.5802011", "0.5799762", "0.5798799", "0.5794885", "0.5792755", "0.5775268", "0.5774801", "0.57498807", "0.574844", "0.57452404", "0.5743477", "0.5737893", "0.57337564", "0.5731061", "0.5724082", "0.57164234", "0.5715225", "0.57130516", "0.57077837", "0.57034075", "0.57034075", "0.57024264", "0.5701908", "0.56974924", "0.569499", "0.5693447", "0.56929785", "0.56714743", "0.56687236", "0.5663458", "0.56543636", "0.56543225", "0.56516576", "0.56485593", "0.56482935", "0.564672", "0.5644473", "0.5642562", "0.56420356", "0.56420356", "0.5634588", "0.5631305", "0.56311345", "0.5623798" ]
0.6344203
7
puts "Input string to encrypt..." text_to_cipher = gets.chomp puts "Input cipher offset..." cipher_offset = gets.chomp puts CaesarCipher.encrypt("in", 5) puts CaesarCipher.encrypt("hello.", 11)
def caesar_cipher(string, key) arr_string = string.downcase.split("") alpha = ("a".."z").to_a for i in arr_string do if alpha.include?(i) alpha_index = alpha.index(i) string_index = arr_string.index(i) if alpha_index + key > 25 key_change = alpha[alpha_index + key - 25 - 1] arr_string[string_index] = key_change else key_change = alpha[alpha_index + key] arr_string[string_index] = key_change end end end arr_string.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main\r\n\tputs \"Please, enter a string which you want to cipher!\"\r\n\tuser_string = gets.chomp\r\n\tputs \"Please, enter positive number\"\r\n\tuser_number = gets.chomp.to_i\r\n\r\n\tcaesar_cipher(user_string, user_number)\r\nend", "def caesar_cipher(offset, string)\n\talph = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\ti = 0\n\tnew_string = \"\"\n\tind = 0\n\n\tputs string.length \n\n\twhile i < string.length\n\t\t\n\t\t\n\t\t\n\t\tif string[i] == \" \"\n\t\t\tnew_string = new_string + \" \"\n\t\t\t\n\t\telse \n\t\t\tind = alph.index(string[i])\n\t\t\t\n\t\t\tif (ind + offset) > 25\n\t\t\t\tind = (ind + offset) - 26 \n\t\t\t\t\n\t\t\t\tnew_string = new_string + alph[(ind)]\n\t\t\t\t\n\t\t\telse \n\t\t\t\tnew_string = new_string + alph[(ind + offset)]\n\t\t\t\t\n\t\t\tend\n\t\tend\n\t\ti +=1\n\tend\n\n\treturn new_string\n\nend", "def plainTextInput()\n puts \"Please enter a single word (no spaces): \"\n word = gets.chomp #take user input\n puts \"The plain text word submission is: #{word}\"\n\n #begin encoding with user input\n textEncryptor(word, keyGenerator)\n\nend", "def caesar_cipher(caesar_string, shift_factor) \n alphabet = (\"a\"..\"z\").to_a\n new_string = \"\"\n\n caesar_string.each_char do |input|\n if input == \" \"\n new_string += \" \"\n else \n old_index = alphabet.find_index(input)\n new_index = (old_index + shift_factor) % alphabet.count\n new_string += alphabet[new_index]\n end\n end\n\nputs new_string.chomp\n\nend", "def encrypt(input_text, offset)\n # Error messages for: empty strings & offset == 0.\n raise ArgumentError, 'String must not be empty' if input_text == ''\n raise ArgumentError, 'Offset must not be zero' if offset == 0\n\n # Makes the input text uppercase letters only.\n input_text = input_text.upcase\n\n # Will hold all letters from input_text.\n text_list = []\n\n # Defines each letter with a number using index.\n letter_index = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\n\n # The encrypted text goes here.\n encrypted_text = ''\n\n # Stopping infinite loops.\n counter = 0\n\n # Sends each character in the input text in to their own element in an array(text_list).\n while counter < input_text.length\n text_list << input_text[counter]\n counter += 1\n end\n\n # Resets the counter.\n counter = 0\n\n # Goes through each character in the list.\n while counter < text_list.size\n # Resets the new_letter.\n new_letter = ''\n\n # Goes through the alphabet for comparison reasons.\n letter_index.each { |x|\n\n # Error message for: current element in array == nil.\n raise ArgumentError, 'Element must not be nil' if text_list[counter] == nil\n\n # Checks if current element in text_list is = to currently selected letter in the alphabet.\n if text_list[counter] == x\n\n # Declares a temporary variable to hold the new offset.\n temp = letter_index.index(text_list[counter]) + offset\n\n # Makes sure that the offset for a new letter isn't a value that is bigger than the lenght of the alphabet.\n if temp > letter_index.size - 1\n temp = temp - letter_index.size\n end\n\n # Declares which new letter whom is to be added to the encrypted text.\n new_letter = letter_index[temp]\n end\n }\n\n # Makes sure to keep spaces so the text don't get messy.\n if new_letter == ''\n new_letter = text_list[counter]\n end\n\n # Adds the new letter to the end of the encrypted text.\n encrypted_text += new_letter\n\n # Increments the counter.\n counter += 1\n end\n\n # Returns the encrypted text.\n return encrypted_text\nend", "def caesar_cipher(offset, string)\n\n result = \"\"\n\n array = string.split(\"\")\n\n i = 0\n\n while array.length > i\n\n ascii = array[i].ord\n p ascii\n\n if( array[i] != \" \") # keep space the same, do not add offset\n ascii += offset\n end\n\n if ascii >= 122 # IMPORTANT\n\n # look at note2self\n #\n back_round_from_a = ( ascii - \"a\".ord ) % 26\n #\n # look at note2self\n\n ascii = back_round_from_a + \"a\".ord\n # if x, i.e. x = 199 & offset = 3 so, total 122, then back_round_from_a = 0\n # Therefor, back_round_from_a + \"a\".ord === 0 + 97 => a\n\n end\n\n letter = ascii.chr\n p letter\n\n result += letter\n\n i += 1\n end # while\n\n p result\n\n return result\n\nend", "def caesar_cipher(string, shift)\nend", "def caesar_cipher(input, key)\n\ta = input.downcase\n\tputs a\n\tputs key\nend", "def caesar_cipher(str, shift)\n\nend", "def textEncryptor(keyword, cipherKey)\n cipherText = \"\"\n\n\n #algorithm that uses key to shift letters encrypting given word\n keyword.each_char do |letter|\n \n oldIndex = $alphabet.find_index(letter)\n newIndex = (oldIndex + cipherKey) % $alphabet.count\n cipherText += $alphabet[newIndex]\n \n end\n\n puts \"The cipher text is: #{cipherText}\"\n\n #begin deciphiring encoded text for human readable original word\n textDecryptor(cipherText, cipherKey)\n\nend", "def solve_cipher(input, shift=nil)\n\n# Setting -3 as defautl shift\n\tif shift.nil? \n\t\tshift = -3\n\tend\n\n\n# Positive numbers shift right and negative numbers shift left \n\tif shift < 0\n\t\tshift = -shift\n\tend\n\n\toutput = \"\"\n\t(input.split\"\").each do |letra|\n\n\t\t# Spaces remain as spaces\n\t\tif letra == \" \"\n\t\t\toutput << \" \"\n\n\t\t# a will be z in case of shift = 1\n\t\telsif letra == 'a'\n\t\t\tindice = 122 + shift\n\n\t\telse\n\t\t\tindice = letra.ord - shift\n\n\t\toutput << indice.chr\n\t\tend\n\tend\n\tputs output\nend", "def cypher(phrase = nil, offset = nil)\n if phrase == nil\n puts \"What phrase would you like to code?\"\n phrase = gets.chomp\n end\n if offset == nil \n puts \"How much would you like to offset it?\"\n offset = gets.chomp.to_i\n end\n #Sets up a container for the new phrase and splits the previous one\n new_phrase = []\n phrase = phrase.split(\"\")\n phrase.each do |letter|\n #checks if the current character is a letter. if not, it adds it to new_phrase without acting on it.\n if letter =~ /[A-Za-z]/\n #gets the ascii value of the letter then sets a new ascii value in offset_ascii for the cyphered letter.\n ascii = letter.ord\n offset_ascii = ascii + offset\n #This if statement takes the offset and checks to see if its outside the bounds of the upper or lowercase alphabet\n #it then corrects for the wraparound if necessary\n if letter.is_upper?\n if offset_ascii < 65\n offset_ascii += 26\n elsif offset_ascii > 90\n offset_ascii -= 26\n end\n elsif letter.is_lower?\n if offset_ascii < 97\n offset_ascii += 26\n elsif offset_ascii > 122\n offset_ascii -= 26\n end\n end\n #takes the ascii value and turns that into a letter, then pushes it to the new_phrase array\n new_letter = offset_ascii.chr\n new_phrase.push(new_letter) \n else\n new_phrase.push(letter)\n end\n end\n #joins new_phrase into a string and both prints it to the terminal and returns it so it can retain functionality if used in another program\n puts new_phrase.join(\"\")\n return new_phrase.join(\"\")\nend", "def caesar_cipher(text, step)\r\n\ttext.length.times do |number|\r\n\t\tcurrent_symbol = text[number]\r\n\t\ttext[number] = caesar_wrapper(current_symbol, step)\r\n\tend\r\n\tputs text\r\nend", "def control\n if ARGV.length != 3\n raise 'Usage: ruby solitaire.rb encrypt \"Message to be encrypted\" \"3, 25, 26, 28, 12, 49, 51, 4, 10, 36, 8, 22, 34, 39, 2, 23, 1, 47, 5, A, 17, 30, 48, 19, 45, 42, 46, 32, 21, B, 43, 35, 40, 37, 29, 44, 38, 14, 11, 16, 41, 15, 9, 24, 50, 7, 18, 33, 27, 52, 31, 13, 6, 20\"'\n end\n if ARGV[0] == 'encrypt'\n puts crypt :encrypt\n elsif ARGV[0] == 'decrypt'\n puts crypt :decrypt\n else\n raise \"unknown\"\n end\nend", "def intro()\r\nputs \"Greetings Agent. Encryption or decryption today? (e/d)\"\r\n\tconfirm = gets.chomp\r\n\tif confirm == \"e\"\r\n\t\tputs \"enter string for encryption\"\r\n\t\tinput = gets.chomp\r\n\t\tputs \"#{input} encrypted: #{encryption(input)}\" \r\n\telsif confirm == \"d\"\r\n\t\tputs \"enter string for decryption\"\r\n\t\tinput = gets.chomp\r\n\t\tputs \"#{input} decrypted: #{decryption(input)}\"\r\n\telse\r\n\t puts \"confirmed for decryption decryption protocol, 'swordfish'\"\r\n\t puts \"de-encrypt complete: #{decryption(encryption(\"swordfish\"))}\"\r\n\tend\r\nend", "def caesar_cipher(offset, string)\n words = string.split(\" \")\n\n word_idx = 0\n while word_idx < words.length\n word = words[word_idx]\n\n letter_idx = 0\n while letter_idx < word.length\n char_i = word[letter_idx].ord - \"a\".ord\n\n new_char_i = (char_i + offset) % 26\n word[letter_idx] = (\"a\".ord + new_char_i).chr\n\n letter_idx += 1\n end\n\n word_idx += 1\n end\n\n return words.join(\" \")\nend", "def decrypt(input_text, offset)\n\n # Takes original offset and inverts it.\n offset *= -1\n\n # Calls the encrypt function using the inverted offset to get the decrypted text, also makes the text lowercase.\n decrypted_text = encrypt(input_text, offset).downcase\n\n # Returns the decrypted text.\n return decrypted_text\nend", "def caesar_cipher (user_input_logic, shift_num)\n user_input_logic.pack(\"c*\")\nend", "def caesar_cipher(str, num)\n new_str = \"\"\n str.each_char { |c| new_str += shift_char(c, num) }\n new_str\nend", "def Caesar_cipher(input_string,input_shift)\n\n alphabet = ('a'..'z').to_a\n alphabetUpCase = ('A'..'Z').to_a\n\n input_string.each_char {|letter| \n if letter =~ /[A-Z]/\n new_letter_index = alphabetUpCase.index(letter) + input_shift\n if new_letter_index > 25\n new_letter_index -= 26\n puts alphabetUpCase[new_letter_index]\n else\n puts alphabetUpCase[new_letter_index]\n end\n elsif letter =~ /[a-z]/\n new_letter_index = alphabet.index(letter) + input_shift\n if new_letter_index > 25\n new_letter_index -= 25\n puts alphabet[new_letter_index]\n else\n puts alphabet[new_letter_index]\n end\n else\n puts letter\n end\n }\nend", "def caesar_cipher(input_string, shift_factor)\r\n positions = input_string.unpack('C*')\r\n shifted_positions = positions.map do |pos|\r\n case pos\r\n when (65..90), (97..122)\r\n shifted = pos + (shift_factor % 26) # use % 26 to account for shift factors over 26\r\n if (shifted > 90 && shifted < 97) || (shifted > 122) # loop around\r\n shifted = shifted - 26\r\n end\r\n pos = shifted\r\n else\r\n pos # ignore non-alphabet chars\r\n end\r\n end\r\n result_string = shifted_positions.pack('C*')\r\n puts result_string\r\nend", "def caesar_cipher(string, shift)\n begin\n shift = shift % 26\n new_string = \"\"\n letters = string.split('')\n letters.each do |i|\n if i >='a' && i <= 'z'\n encrypted = i.ord + shift\n if encrypted > 122 # ASCII for 'z'; wraps around to 'a'\n encrypted = encrypted - 26\n end\n elsif i >='A' && i <= 'Z'\n encrypted = i.ord + shift\n if encrypted > 90 # ASCII for 'Z'; wraps around to 'A'\n encrypted = encrypted - 26\n end\n else\n encrypted = i\n end\n new_string << encrypted.chr\n end\n return new_string\n rescue TypeError\n return \"Invalid shift factor. Please enter a number.\"\n end\nend", "def cipher(string, offset)\n\t#Splits the inputted string into an array of characters\n\tinput = string.split('') \n\t\n\t#This will store our output string\n\toutput = ''\n\t\n\t#First we define an array of letters to generate our hashes from\n\tletters = ('a'..'z').to_a \n\t\n\t#Generate the hash mapping numbers to letters\n\tnumToLetter = Hash.new()\n\tkey = 0\n\n\tloop do\n\t\tvalue = letters[key]\n\t\tnumToLetter[key] = value\n\t\tkey += 1\n\t\tbreak if key == 26\n\tend\n\t\n\t#BEGIN LOOP OF STRING\n\tposInString = 0 #i is a position tracker in the string\n\tloop do\n\t\tmakeUppercase = false #flag tracking case of letter\n\n\t\t#1) Determine if we are dealing with letter or punctuation\n\t\tif numToLetter.has_value?(input[posInString].downcase)\n\t\t\t#2) Determine case before we scramble the number.\n\t\t\tif !(numToLetter.has_value?(input[posInString]))\n\t\t\t\tmakeUppercase = true\n\t\t\tend\n\n\t\t\t#3) Determine the offsetted letter\n\t\t\thashKey = numToLetter.key(input[posInString].downcase)\n\t\t\tif (hashKey + offset) > 25\n\t\t\t\toffsetKey = (offset + hashKey) - 26\n\t\t\telsif (hashKey + offset) < 0\n\t\t\t\toffsetKey = 26 - (hashKey + offset)\n\t\t\telse\n\t\t\t\toffsetKey = hashKey + offset\n\t\t\tend\n\t\t\t\n\t\t\t#4)Set the value in the output!\n\t\t\tif makeUppercase\n\t\t\t\toutput[posInString] = numToLetter[offsetKey].upcase\n\t\t\telse\n\t\t\t\toutput[posInString] = numToLetter[offsetKey]\n\t\t\tend\n\n\t\telse #5) It wasn't a letter (aka inside our hash), just map the punctuation\n\t\t\toutput[posInString] = input[posInString]\n\t\tend\n\n\t\tposInString += 1\n\t\tbreak if posInString > (input.size - 1)\n\tend #END LOOP OF STRING\n\n\tputs \"You ciphered \\'\"+string+\"\\' into \\'\"+output+\"\\'\" \nend", "def encrypt(input)\n index = 0\n#loops through all the letters of the input string\nwhile index < input.length\n#declares if the input is a \"space\" then skip it\nif !(input[index] == \" \")\n#connects the end of the alphabet to the begin; full circle\n if input[index] == \"z\"\n input[index] = \"a\"\n #takes each letter from the input string moves to the next letter\n else input[index] = input[index].next!\n end\n end\n #moves to the next letter of the input string\n index += 1\nend\n\nputs input\nend", "def encrypt(content, offset)\n # Decrypting and crypting contains more or less the exact same code.\n # The difference between those two methods is that decrypting by default takes a positive offset\n # as negative in its calculations. That is why we, when calling the decrypting method, turn our offset\n # around. With that being said, we go from + to - or - to + before executing our method call.\n # As our encrypting method is supposed to return the encrypted content uppercase, \n # and decrypt returns the decrypted content lowercase, we call string's member method upcase.\n\n return decrypt(content, offset * -1).upcase\nend", "def caesar_cipher text, shift = 5 #shifts letters by 5 - by default\nletters = text.split(//)\nncrypted_string = \"\"\nletters.each do |x|\nif (x =~ /\\w/) && (x =~ /\\D/) && (x != \"_\") ##Checks with RegEx's whether the current array index' value is a word character + a non-digit character + not an underscore '_', so only a-z & A-Z letters pass the test and are affected by the following code.\nif x == x.upcase ##<-I do this so I can wrap back to A when Z's #ord index is exceeded. \"A\".ord == 65, \"Z\".ord == 90\nx = x.ord + shift\nif x > 90\nx -= 90\nx += 64\nend\nelsif x == x.downcase ##Same is done here for downcases as is done above for upcases. \"a\".ord == 97, \"z\".ord == 122\nx = x.ord + shift\nif x > 122\nx -= 122\nx += 96\nend\nend\nx.chr\nend\nncrypted_string << x\nend\nputs ncrypted_string\nend", "def caesar_cipher(text, shift=0)\n return text if shift == 0 || text == \"\" || shift.nil? || text.nil?\n standard_key_caps = (\"A\"..\"Z\").to_a\n standard_key_lower = (\"a\"..\"z\").to_a\n\n while shift < 0 do\n shift += 26\n end\n\n i = shift % 26\n\n\n shift_key_caps = []\n range = ('A'..'Z').to_a\n range.each do |x|\n shift_key_caps[i] = x\n i+=1\n i=0 if i >= 26\n end\n\n i=shift\n shift_key_lower = []\n range = ('a'..'z').to_a\n range.each do |x|\n shift_key_lower[i] = x\n i+=1\n i=0 if i >= 26\n end\n\n text_mod = \"\"\n text.each_char do |x|\n character = x\n if standard_key_caps.include?(x)\n offset = shift_key_caps.index(x)\n character = standard_key_caps[offset]\n elsif standard_key_lower.include?(x)\n offset = shift_key_lower.index(x)\n character = standard_key_lower[offset]\n end\n text_mod = text_mod + character\n end\n text_mod\nend", "def interface()\r\n\tputs \"Do you want to encrypt or decrypt?\"\r\n\tanswer = gets\r\n\tputs \"What is the password?\"\r\n\tpassword = gets\r\n\tif answer == \"encrypt\"\r\n\t\tputs encrypt(password)\r\n\telse\r\n\t\tputs decrypt(password)\r\n\tend\r\n\texit\r\nend", "def caesar_cipher(string, shift)\n alphabet = (\"a\"..\"z\").to_a\n\n result = \"\"\n string.each_char do |char|\n if char == \" \"\n result += \" \"\n else\n result += alphabet[(alphabet.index(char) + shift) % 26]\n end\n end\n\n return result\nend", "def caesar_cipher(string, shift_factor = 0)\n result = ''\n string.each_char do |char|\n # use cipher only if char is an uppercase or lowercase letter\n if char.ord.between?(65, 90) || char.ord.between?(97, 122)\n new_code = char.ord + shift_factor\n\n #ensure wrapping from Z to A or z to a\n new_code -= 26 if (new_code > 91 && char.ord < 91) || new_code > 122\n result += new_code.chr\n else\n result += char\n end\n end\n result\nend", "def caesar_cipher(text_to_cipher, key)\n # ensure key is a value between 0 and 25\n key = key % 26\n\n text_to_cipher.split(\"\").map do |character|\n if letter?(character)\n shift(character, key)\n else\n character\n end\n end.join(\"\")\n\nend", "def caesar_cipher(string, shift)\n\tstring = string.to_s\n\tshift = shift.to_i\n\tnew_string = \"\"\n\n\tstring.each_byte do |i|\n\t\tif (i > 64 && i < 91) #A-Z\n\t\t\tif (i+shift) > 90\n\t\t\t\tnew_string << (i+shift - 26).chr \n\t\t\telse\n\t\t\t\tnew_string << (i+shift).chr\n\t\t\tend\n\t\telsif (i > 96 && i < 123) #a-z\n\t\t\tif (i+shift) > 122\n\t\t\t\tnew_string << (i+shift - 26).chr\n\t\t\telse\n\t\t\t\tnew_string << (i+shift).chr\n\t\t\tend\n\t\telse\n\t\t\tnew_string << i.chr\n\t\tend\n\tend\n\n\tputs new_string\nend", "def caesar_cipher(string, shift)\n shifted = \"\"\n letters = (\"a\"..\"z\").to_a\n string.each_char do |char|\n old_idx = letters.find_index(char)\n if old_idx\n shifted << letters[(old_idx + shift) % 26]\n else\n shifted << \" \"\n end\n end\n\n shifted\nend", "def to_caesar_ciph(string, offset)\n raise ArgumentError, 'Argument must be less than 26' unless offset < 26\n key = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n string = string.downcase\n cipher = ''\n string.each_char do |e|\n if e == ' '\n cipher.concat(' ')\n else\n n = key.index(e) + offset\n if n >= 25\n n = key.index(e) + (offset - 26)\n end\n cipher.concat(key[n])\n end\n end\n cipher\nend", "def caesar_cipher(sentence, raw_offset)\r\n offset = raw_offset % 26\r\n sentence.gsub(/([a-zA-Z])/){|char| shift_the_letter(char.ord, offset).chr}\r\nend", "def inquiry\r\n puts \"Would you like to encrypt or decrypt it?\"\r\n choice = gets.chomp\r\n\r\n if choice == \"encrypt\"\r\n encrypt($random_word)\r\n elsif choice == \"decrypt\"\r\n decrypt($random_word)\r\n elsif choice == \"both\"\r\n decrypt(encrypt($random_word))\r\n else \r\n puts \"I didn't quite catch that... try again\"\r\n inquiry\r\n end\r\nend", "def caesar_cipher(string, shift_factor)\n\n\n upc_alphabet_arr = ('A'..'Z').to_a\n downc_alphabet_arr = ('a'..'z').to_a\n\n\n string_chars_arr = string.chars\n\n new_chars_arr = []\n\n string_chars_arr.each do |char|\n if upc_alphabet_arr.include?(char)\n new_index = (upc_alphabet_arr.index(char) + shift_factor)%26\n new_char = upc_alphabet_arr[new_index]\n\n new_chars_arr << new_char\n\n elsif downc_alphabet_arr.include?(char)\n new_index = (downc_alphabet_arr.index(char) + shift_factor)%26\n new_char = downc_alphabet_arr[new_index]\n\n new_chars_arr << new_char\n\n else \n new_chars_arr << char\n end\n end\n\n new_string = new_chars_arr.join(\"\")\n puts new_string\nend", "def main(argv)\n if argv.length >= 2\n caesar_cipher(argv[0], argv[1].to_i)\n else\n \"Usage: ruby cipher.rb \\\"<text-to-be-ciphered>\\\" <key-to-shift-letters>\"\n end\nend", "def solve_cipher(input, shift)\n words = input.split(\"\")\n \n string_container = \"\" \n words.each do | letter|\n \tif letter == \" \"\n \t\tstring_container += \" \"\n\n \telse\n \tstring_container += (letter.ord + shift).chr\n\tend\n end\n\tstring_container\n\t#your code goes here\nend", "def caesars_cipher(str, shift = 1)\n encrypted = ''\n\n ascii_nums = str.bytes\n ascii_nums.each do |i|\n encrypted << case i\n when 65..90\n ((i + shift - 65) % 26 + 65).chr\n when 97..122\n ((i + shift - 97) % 26 + 97).chr\n else\n i.chr\n end\n end\n encrypted\nend", "def caesar_cipher(string, shift)\n result = \"\"\n string.each_char do |ch|\n result += ch == \" \" ? ch : shift(ch, shift)\n end\n result\nend", "def caesar_cipher( input, rot )\n crypt = ''\n input.scan(/./) do |c|\n if !(c =~ /[A-Za-z]/).nil? # Only crypt the alphas.\n base_ord = c.match(/[A-Z]/).nil? ? 'a'.ord : 'A'.ord\n c = (((c.ord - base_ord + rot) % SPAN ) + base_ord).chr()\n end\n crypt << c\n end\n crypt\nend", "def encrypt(input)\n abc = \"abcdefghijklmnopqrstuvwxyz\"\n # 3. iterate through the string\n\tx = 0\n\twhile x < input.length\n whereabc = abc.index(input[x])\n # 4. change each character to the next character in the alphabet.\n \tif whereabc == 25\n \t\twhereabc = -1\n \tend #if\n\t\tinput[x] = abc[whereabc + 1]\n\t\tx += 1\n\tend #while\n input\nend", "def encrypt string\n string\n end", "def encrypt(password_str)\n\t# puts \"Enter text for encryption\"\n\t# password_str = gets.chomp\n\tindex = 0\n\twhile index < password_str.length \n\t\tpassword_str[index] = password_str[index].next\n\t\tindex +=1\n\tend\n\tpassword_str\nend", "def caesar_cipher(string=\"What a string!\",num=5)\n newstring=''\n string.scan(/./) do |x|\n asc=x.ord\n if (97..122).include?(asc)\n if asc>122-num\n asc=96+(num-(122-asc))\n else\n asc += num\n end\n elsif (65..90).include?(asc)\n if asc>90-num\n asc=64+(num-(90-asc))\n else\n asc += num\n end\n else\n asc=asc\n end\n new_character=asc.chr\n newstring=newstring + new_character\n end\n puts newstring\nend", "def caesarCipherEncryptor(string, key)\n new_letters = []\n new_key = key % 26\n alphabet = (\"abcdefghijklmnopqrstuvwxyz\").chars\n\n string.each_char do |letter|\n new_letters.append(get_new_letter(letter, new_key, alphabet))\n end\n return new_letters.join\nend", "def decrypt\n puts \"what would you like to decrypt?\"\n text = gets.chomp\n decrypt = text.split(\"\").collect {|letter| (letter.sum - 5).chr}\n puts decrypt.join\nend", "def textDecryptor(encodedText, cryptoKey)\n decryptedText = \"\"\n\n #algorithm that uses key to un-shift letters in encoded word to return to human readable form (original word)\n encodedText.each_char do |value|\n \n formerPosition = $alphabet.find_index(value)\n newPosition = (formerPosition - cryptoKey) % $alphabet.count\n decryptedText += $alphabet[newPosition]\n \n end\n puts \"The cipher text decrypted is: #{decryptedText}\"\n\nend", "def inquiry\n puts \"Would you like to encrypt or decrypt it?\"\n choice = gets.chomp\n\n if choice == \"encrypt\"\n encrypt($random_word)\n elsif choice == \"decrypt\"\n decrypt($random_word)\n elsif choice == \"both\"\n decrypt(encrypt($random_word))\n else \n puts \"I didn't quite catch that... try again\"\n inquiry\n end\nend", "def encipher(char, shift) \n if char >= 65 && char <= 90 \n index = char - 65\n shifted_char = (index + shift) % 26\n if shifted_char < 0 \n shifted_char += 26\n enciphered_char = shifted_char + 65\n else\n enciphered_char = shifted_char + 65\n end\n elsif char >= 97 && char <= 122\n index = char - 97\n shifted_char = (index + shift) % 26\n if shifted_char < 0\n shifted_char += 26\n enchiphered_char = shifted_char + 97\n else \n enciphered_char = shifted_char + 97\n end\n else\n char = char \n end\nend", "def get_phrase e_or_d\n if e_or_d.upcase == 'E'\n puts \"What text would you like to encrypt?\"\n else\n puts \"What text would you like to decrypt?\"\n end\nanswer = gets.chomp\nreturn answer\nend", "def caesar_cipher(string, shift)\n alphabet = Array('a'..'z')\n encrypter = Hash[alphabet.zip(alphabet.rotate(shift))]\n string.chars.map { |c| encrypter.fetch(c, \" \") }\nend", "def encrypt(str)\n index = 0\nwhile index < str.length\nprint str[index].next.sub(\"!\", \" \") #Learned that p did not work as well as print. Aslo used sub method to take out the space.\nindex += 1\nend\nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n new_string = \"\"\n str.chars.each do |char|\n if letters.include?(char)\n shift_position = (letters.index(char) + shift) % 26\n new_string += letters[shift_position]\n else\n new_string += char\n end\n end\n new_string\nend", "def caesar_cipher(str, shift)\n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n \n str.each_char do |char|\n if alpha.index(char)\n old_idx = alpha.index(char)\n new_str += alpha[(old_idx + shift) % 26]\n else\n new_str += char\n end\n end\n\n new_str\nend", "def edit(ciphertext, key, offset, new_text)\n plaintext = AES_128.decrypt(ciphertext, key, :mode => :CTR)\n plaintext[offset % plaintext.size, new_text.size] = new_text[0..plaintext.size] # Modulo so it wraps around to imitate a fixed-size buffer, such as a disk.\n\n AES_128.encrypt(plaintext, key, :mode => :CTR)\nend", "def prompt ()\nputs \"Do you want to encrypt or decrypt(e/d)\"\nmethod = gets.chomp\nputs \"Enter Password as a string\"\npass = gets.chomp\n if method == \"e\"\n puts encrypt(pass)\n else \n puts decrypt(pass) \n end \nend", "def caesar_cipher(string, shift)\n\n while shift > 26 #prevents users from accessing a value beyond the letters of ASCII table\n puts 'Sorry choose a number equal to or lower than 26'\n shift.gets.chomp.to_i\n end \n \nstring.chars.map {|char| #.chars seperates each symbol of the string (including spaces) into an array; .map 'maps' each element in the block with |char| representing the variable being targeted\n if char =~ (/\\w/) && char == char.upcase #the =~ is a 'match operator' used to match current char with \\w (any alphanumeric character) AND checks to see if char is uppercase\n char = char.ord + shift # .ord gives the ASCII value of the char + given shift num \n if char > 90 #if char is greater than 90, substract the total letters of alphabet to link char with appropriately shifted posotion \n char = (char - 26).chr #use chr to return it back to letter form \n else\n char.chr #if not greater than 90 (all char greater than 90 fall into lowercase category), simply return the .chr \n end\n elsif char =~ (/\\w/) && char == char.downcase #elsif char matches alphanumeric character AND downcase....\n char = char.ord + shift #.ord value +shift \n if char > 122 #if greater than lowercase z in ASCII table...\n char = (char - 26).chr \n else\n char.chr\n end\n else #if its not a letter just char it up some \n char\n \n end}.join #rejoin the .chars array as shifted string \n \nend", "def caesar_cipher(string, shift = DateTime.now.day) # I set shift to be the current day if I do not include a parameter for it\n string.tr Alphabet.join, Alphabet.map{ |array| array.rotate shift }.join # This looks at every single character in the string and uses .map to rotate the array to bascially let it shift how ever many times within the array to assign the new character to the string variable\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n \n\tstr.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n\n end\n return new_str\n\nend", "def encrypt phrase, key\n alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split(\"\")\n cipherbet = get_cipherbet key\n result = \"\"\n phrase.each_char do |letter|\n encrypted_letter = encrypt_letter alphabet, cipherbet, letter\n result = result + encrypted_letter\n end\n return result\nend", "def caesar_cipher(str, num)\r\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\r\n new_str = \"\"\r\n\r\n str.each_char do |char|\r\n old_idx = alphabet.index(char)\r\n new_idx = old_idx + num\r\n new_char = alphabet[new_idx % 26]\r\n new_str += new_char\r\n end\r\n\r\n return new_str\r\nend", "def caesar_cipher(str, shift)\n alphabet ||= ('a'..'z').to_a\n res = \"\"\n str.chars.each do |letter|\n if letter == \" \"\n res += letter\n else\n old_idx = alphabet.index(letter)\n new_idx = old_idx*shift % 26\n res += alphabet[new_idx]\n end\n end\n res\nend", "def caesar_cipher(input, shift)\n\toutput = \"\"\n\t\n\tinput.each_byte do |ascii|\n\t\t# Take each character's ASCII code\n\t\tif ascii >= 65 && ascii <= 90\n\t\t\t# If character is uppercase letter:\n\t\t\tascii -= 65 \t\t\t\t\t# Subtract to A=0, Z=25\n\t\t\tascii = (ascii + shift) % 26 \t# Shift with wrapping Z-to-A\n\t\t\tascii += 65\t\t\t\t\t\t# Add back to new ASCII code\n\t\t\toutput += ascii.chr\t\t\t\t# Add ASCII character to output\n\t\telsif ascii >= 97 && ascii <= 122\n\t\t\t# If character is lowercase letter:\n\t\t\tascii -= 97 \t\t\t\t\t# Subtract to a=0, z=25\n\t\t\tascii = (ascii + shift) % 26 \t# Shift with wrapping z-to-a\n\t\t\tascii += 97\t\t\t\t\t\t# Add back to new ASCII code\n\t\t\toutput += ascii.chr\t\t\t\t# Add ASCII character to output\n\t\telse\n\t\t\toutput += ascii.chr\t\t\t\t# Else just add character to output\n\t\tend\n\tend\n\toutput\nend", "def caesar_cipher(string, shift)\n lower = ('a'..'z')\n caesar_string = ''\n\n string.each_char do |char|\n shift.times { char = char.next } if lower.include?(char.downcase) # identify letters only\n caesar_string << char[-1]\n end\n caesar_string\nend", "def caesar_cipher(str, num)\n \talphabet = \"abcdefghijklmnopqrstuvwxyz\"\n \tcipher = \"\"\n\n\tstr.each_char do |char|\n \tletterPos = alphabet.index(char)\n \tnewPos = letterPos + num\n \tcipher += alphabet[newPos % 26] # mod so wraps arround\n end\n \n \treturn cipher\nend", "def caesar_cipher(word, shift) \n\n #Checks if 'word' is a String \n unless word.is_a? String\n return \"Input was not text\"\n end\n\n #Initializes a temp word\n new_word = \"\"\n\n #Creates an array of ascii numbers for each letter in 'word'\n word_array = word.codepoints.to_a\n\n #Loops over each letter in 'word' and manipulates\n for i in 0..word_array.length-1\n\n #Keeps track of the letter casing\n lowercase = false\n if word_array[i] >= 97 && word_array[i] <= 122\n lowercase = true\n else\n lowercase = false\n end\n\n #Adds the shift to the letter (checks if the character is a letter and not a symbol or space)\n if word_array[i] >= 65 && word_array[i] <= 122\n word_array[i] += shift\n end\n\n # Checks character ascii values\n if word_array[i] > 122 && lowercase == true\n word_array[i] -= 26\n elsif word_array[i] > 90 && lowercase == false\n word_array[i] -= 26\n end\n new_word += word_array[i].chr\n end\n return new_word\nend", "def vigenere_cipher(string, key_sequence, alphabet)\n #\n # your code goes here\n #\nend", "def crypt(text,key,operator = :+)\n index = 0\n text.upcase.each_byte.reduce(\"\") do |res, c|\n res << (65 + (c.send(operator, key[index % key.length].ord)) % 26).chr\n index += 1\n res\n end\nend", "def encrypt()\n\tputs \"What is your password?\"\n\tinput = gets.chomp\n\tpasswordlength = input.length\n\tfor i in 0...passwordlength\n\t if input[i] == 'z'\n\t input[i] = 'a'\n\t else\n\t\tinput[i] = input[i].next\n\t\tend\n\tend\nputs input\nend", "def caesar_cipher(str, shift)\n cipher = (\"a\"..\"z\").to_a\n\n result = \"\"\n str.chars.each do |char|\n if char == \" \"\n result << char\n else\n shifted_idx = cipher.index(char) * shift % cipher.length\n result << cipher[shifted_idx]\n end\n end\n result\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvxyz\"\n new_str = \"\"\n \n str.each_char do |char|\n old_idx = alphabet.index(char) # each items index on the alphabet\n\tnew_idx = old_idx + num\n\tnew_char = alphabet[new_idx % 26] # to ensure that results is always less than 26 e.g. 'z' + 4 will fail without this, will now return to 'a' + 4 = 'd'.\n\tnew_str += new_char\n\tend\n \n return new_str\n\nend", "def decrypt_caesar_cipher(string, shift = -@offset_value.to_i)\n alphabet = Array('a'..'z')\n encrypter = Hash[alphabet.zip(alphabet.rotate(shift))]\n string.chars.map { |c| encrypter.fetch(c, \" \") }\nend", "def vigenere_cipher(string, key_sequence)\n result = \"\"\n string.each_char.with_index do |c, idx|\n key_idx = idx % key_sequence.length\n key = key_sequence[key_idx]\n result << shift(c, key)\n end\n result\nend", "def caesar_cipher(string, shift_factor)\n output = \"\"\n string.scan (/./) do |i|\n if (\"a\"..\"z\").include? (i.downcase)\n shift_factor.times {i = i.next}\n end\n output << i[-1]\n end\n return output\nend", "def encrypt(encrypt_input)\r\n index_encrypt = 0\r\n encrypt_output = \"\"\r\n\r\n while index_encrypt < encrypt_input.length\r\n if encrypt_input[index_encrypt] == \"z\"\r\n encrypt_output[index_encrypt] = \"a\"\r\n elsif encrypt_input[index_encrypt] == \" \"\r\n encrypt_output[index_encrypt] = \" \"\r\n else\r\n encrypt_output[index_encrypt] = encrypt_input[index_encrypt].next\r\n end\r\n index_encrypt += 1\r\n end \r\n return encrypt_output\r\nend", "def caesar_cipher(string_to_cipher, shift)\n shifted_string = \"\"\n string_to_cipher.chars.map do |char|\n ascii = char.ord\n if ((65..90) === ascii || (97..122) === ascii) then \n ascii += shift \n if (ascii > 90 && ascii < 97) || (ascii > 122) then\n ascii -= 26\n end\n end\n shifted_string += ascii.chr\n\n end\n shifted_string\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n\n str.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n end\n\n return new_str\nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.each_char do |char|\n if char == \" \"\n encoded_str << \" \"\n next\n end\n\n old_idx = letters.find_index(char)\n new_idx = (old_idx + shift) % letters.count\n\n encoded_str << letters[new_idx]\n end\n\n encoded_str\nend", "def caesar_cipher(str, num)\n new_str = \"\"\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n str.each_char do |char|\n old_index = alphabet.index(char)\n new_index = old_index + num\n new_char = alphabet[new_index % 26] # MOST IMPORTANT STEP!!!!! THIS WILL ALSO TAKE CARE OF new_index > 26\n new_str += new_char\n end\n return new_str\nend", "def caesar_cipher(str, num)\n \tnew_str = \"\"\n\n \tstr.each_char do |c|\n new_letter = c.ord + num\n if new_letter > 122\n shift = ((new_letter - 96) % 26) + 96\n new_str += shift.chr\n else\n new_str += new_letter.chr\n end\n end\n return new_str\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n\n str.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n end\n\n return new_str\nend", "def caesar_cipher(str, shift)\n alph = (\"a\"..\"z\").to_a\n\n decode = \"\"\n\n str.chars.each do |letter|\n if letter == \" \"\n decode << letter\n end\n\n num = alph.find_index(letter)\n decode << alph[(num + shift) % 26]\n end\n\n decode\nend", "def encrypt(pass)\n counter = 0\n password = \"\"\n\n until counter == pass.length\n alphabet = \"abcdefghijklmnopqrstuvwxyza\"\n letter = alphabet.index(pass[counter]) + 1\n counter += 1\n password = alphabet[letter] + password\n\n end\n password.reverse\n end", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.chars.each do |char|\n if char == \" \"\n encoded_str += \" \"\n next\n end\n\n old_idx = letters.index(char)\n new_idx = (old_idx + shift) % letters.length\n encoded_str << letters[new_idx]\n end\n\n encoded_str\nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.each_char do |char|\n if char == \" \"\n encoded_str < \" \"\n next\n end\n old_idx = letters.find_index(char)\n new_idx = (old_idx + shift) % letters.count\n encoded_str << letters[new_idx]\n end\n encoded_str\nend", "def caesar_cipher(str, shift)\n letters = (\"a\"..\"z\").to_a\n\n encoded_str = \"\"\n str.split('').each do |char|\n if char == \" \"\n encoded_str << \" \"\n next\n end\n\n old_idx = letters.find_index(char)\n new_idx = (old_idx + shift) % letters.count\n\n encoded_str << letters[new_idx]\n end\n\n encoded_str\nend", "def edit(offset: ,with: )\n previous = ciphertext[0...offset]\n after = ciphertext[(offset + with.bytesize)..-1]\n edited = with.encrypt_ctr(nonce: nonce,\n key: key,\n start_counter: offset)\n previous + edited + after\n end", "def caesar_cipher(message, shift_key)\n result = \" \"\n message.each_char do |letter|\n if letter.ord.between?(65,90) || letter.ord.between?(97, 122)\n final_code = letter.ord + shift_key\n\n final_code -= 26 if (final_code > 91 && letter.ord < 91) || final_code > 122\n result += final_code.chr\n else\n result += letter\n end\n end\n return result\nend", "def caesarCipher(s, k)\n s.chars.map do |e|\n e = e.ord\n case e\n when 97..122\n e + k > 122 ? (e + k - 122 + 97 - 1) : e + k\n when 65..90\n e + k > 90 ? (e + k - 90 + 65 - 1) : e + k \n else\n e \n end\n end.map{|e| e.chr}.join\nend", "def caesar_cipher_encryptor(string, key)\n\talphabet = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)\n\tnew_alphabet = []\n\twrap_key = key % 26\n for char in string.split(\"\")\n new_index = alphabet.index(char) + wrap_key\n new_alphabet << alphabet[new_index % 26]\n\tend\n\tnew_alphabet.join(\"\")\nend", "def caesar_cipher2(message, offset)\n\n\toffset %= 26\n\tcipher = ''\n\n\t# Direction is relevant\n\tincrement = true if offset > 0\n\n\tif increment\n\t\tmessage.each_char do |c|\n\t\t\toffset.times do\n\t\t\t\tif c.match(/[A-Ya-y]/)\n\t\t\t\t\tc.next! # No wrap required on these letters, increment\n\t\t\t\telse\n\t\t\t\t\tif c.match(/Z/) #Wrap required\n\t\t\t\t\t\tc = 'A'; end\n\t\t\t\t\tif c.match(/z/)\n\t\t\t\t\t\tc = 'a'; end; end; end\n\t\t\tcipher << c # Insert scrambled character to output string\n\t\tend\n\telse # decrement\n\t\tmessage.each_char do |c|\n\t\t\toffset.abs.times do # Use absolute value, can't do a loop negative times!\n\t\t\t\tif c.match(/[B-Zb-z]/)\n\t\t\t\t\tc = (c.ord - 1).chr # Quick shuffling using ASCII value\n\t\t\t\telse\n\t\t\t\t\tif c.match(/A/) # Reverse wrap required\n\t\t\t\t\t\tc = 'Z'; end\n\t\t\t\t\tif c.match(/a/) \n\t\t\t\t\t\tc = 'z'; end; end; end\n\t\t\tcipher << c # Insert scrambled character to output string\n\t\tend\n\tend\n\n\treturn cipher\nend", "def caesar_cipher(str, num)\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n\n str.each_char.with_index do |char, i|\n shift = alphabet.index(char) + num # shifting num chars in the alphabet\n if shift > 26 # restart at 0 after index 26\n shift -= 26\n end\n str[i] = alphabet[shift]\n end\n\n str\nend", "def caesar_cipher(phrase, shift)\n shifted_array = phrase.chars.map {|char| shift_letter(char, shift)}\n new_phrase = shifted_array.join\nend", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n encrypted = \"\"\n\n message.each_char.with_index do |char, idx|\n shift = keys[idx % keys.length]\n encrypted += alphabet[(alphabet.index(char) + shift) % 26]\n end\n\n encrypted\nend", "def test_it_encrypts_a_sentence\n a = Encrypt.new(\"this is a test ..end..\")\n a.offset.date = \"080315\"\n a.key = EncryptionKey.new(\"12345\")\n assert_equal a.encrypt, \"b6f3s7pivwqpaf7jt3kotx\"\n end", "def solve_cipher(input, shift)\n\toutput = String.new\n i = 0\n while i<input.length\n \tif input[i].ord == 32\n \t\toutput[i] = input[i]\n \telse\n \tnum = input[i].ord + shift\n \toutput[i] = num.chr\n \tend\n \ti+=1\n end\n return output\nend", "def encrypt(plainText, key)\n shiftText(plainText, key)\n end", "def ceasar_cipher(phrase, shift)\n phrase.downcase!\n words = phrase.split(\" \")\n words.each do |word| #for each word in the sentence\n word.split(\"\").each_with_index do |letter, index| #for each letter in the word\n asciiValue = letter.ord\n if(asciiValue >= 97 && asciiValue <= 122) #if the value is a letter and not a character or digit\n\n newValue = asciiValue + shift\n \n if newValue > 122 #if it goes beyond z, loop around back to a\n difference = newValue - 122\n offset = 96+difference\n letter = offset.chr\n word[index] = letter\n else\n letter = newValue.chr \n word[index] = letter\n end\n end \n end\n end\n puts words.join(\" \")\nend", "def caesar_cipher(str, num)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n \n str.each_char do |char|\n old_idx = alphabet.index(char)\n new_idx = old_idx + num\n new_char = alphabet[new_idx % 26]\n new_str += new_char\n end\n \n return new_str\nend" ]
[ "0.73170644", "0.7271542", "0.7180676", "0.7167195", "0.71498686", "0.70933145", "0.7053305", "0.7040899", "0.70117795", "0.69665325", "0.69166696", "0.6911052", "0.6859404", "0.68502116", "0.684943", "0.6843077", "0.6827996", "0.67854136", "0.67701423", "0.67640656", "0.6687203", "0.667956", "0.6668897", "0.66657776", "0.66419435", "0.6640339", "0.6619597", "0.6607789", "0.65995705", "0.65969473", "0.65946466", "0.6591264", "0.6576006", "0.6573153", "0.6566975", "0.6566676", "0.65653497", "0.6560446", "0.65540886", "0.6548616", "0.6542262", "0.6526771", "0.6523263", "0.6516612", "0.6515234", "0.65131813", "0.64867705", "0.6484379", "0.6477679", "0.64718646", "0.646355", "0.6463199", "0.6461146", "0.64596444", "0.6457236", "0.6448973", "0.64461625", "0.6440019", "0.64335996", "0.6431356", "0.6425668", "0.6420656", "0.6409462", "0.6407783", "0.6407073", "0.6404871", "0.64018947", "0.63942397", "0.63929445", "0.6391716", "0.63896394", "0.6389624", "0.638691", "0.63867235", "0.63839066", "0.6382888", "0.63781595", "0.6371861", "0.6365012", "0.6361804", "0.63614243", "0.6358508", "0.635796", "0.6347682", "0.6340485", "0.63382775", "0.633273", "0.63325846", "0.6325685", "0.63246596", "0.6321657", "0.6318409", "0.6317601", "0.6303521", "0.6291544", "0.6287008", "0.62866265", "0.6284276", "0.6277169", "0.62761724", "0.6273542" ]
0.0
-1
menu items like 'invoke', not a proper mouse click
def click @automation_element.get_current_pattern(System::Windows::Automation::InvokePattern.pattern).invoke end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def click; end", "def click; end", "def click; end", "def clicked;end", "def press_menu\n driver.pressQuickMenuItem(text, true);\n end", "def nMenuItems _obj, _args\n \"_obj nMenuItems _args;\" \n end", "def menu # can do custom methods within a method/class\n end", "def click_menu_item(*items)\n items_as_applescript_array = items.map { |i|\n %(\"#{i.gsub('...', \"\\342\\200\\246\")}\")\n }.join(\", \")\n\n ascript = %Q`\n on menu_click(mList)\n local appName, topMenu, r\n if mList's length < 3 then error \"Menu list is not long enough\"\n\n set {appName, topMenu} to (items 1 through 2 of mList)\n set r to (items 3 through (mList's length) of mList)\n\n tell application \"System Events\" to my menu_click_recurse(r, ((process appName)'s (menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))\n end menu_click\n\n on menu_click_recurse(mList, parentObject)\n local f, r\n\n set f to item 1 of mList\n if mList's length > 1 then set r to (items 2 through (mList's length) of mList)\n\n tell application \"System Events\"\n if mList's length is 1 then\n click parentObject's menu item f\n else\n my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))\n end if\n end tell\n end menu_click_recurse\n\n menu_click({#{items_as_applescript_array}})\n `\n execute_applescript(ascript)\n end", "def selection_menu\n h = {\n a: :select_all,\n u: :unselect_all,\n s: :toggle_select,\n '*' => 'toggle_multiple_selection',\n 'x' => 'toggle_visual_mode',\n 'm' => 'toggle_selection_mode',\n v: :view_selected_files\n }\n menu 'Selection Menu', h\nend", "def showCommandingMenu _args\n \"showCommandingMenu _args;\" \n end", "def menu_selection \nend", "def show_menu element\n element.perform :show_menu\n end", "def main_menu\n h = {\n a: :ag,\n z: :z_interface,\n # f: :file_actions,\n b: :bookmark_menu,\n c: :create_menu,\n f: :filter_menu,\n o: :order_menu,\n s: :selection_menu,\n t: :toggle_menu,\n v: :view_menu,\n '`' => :goto_parent_dir,\n x: :extras\n }\n menu 'Main Menu', h\nend", "def click locator\r\n command 'click', locator\r\n end", "def click locator\r\n command 'click', locator\r\n end", "def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend", "def clicked(e)\n \n end", "def menu _command\n send_cmd(\"menu #{_command}\")\n end", "def createMenuItems(invocation)\n\n menu = []\n\n # Which part of the interface the user selects\n ctx = invocation.getInvocationContext()\n\n # Sitemap history, Proxy History, Request views, and Scanner will show menu item if selected by the user\n #@stdout.println('Menu TYPE: %s\\n' % ctx)\n if ctx == 5 or ctx == 6 or ctx == 2 or ctx == 7\n\n \t faradayMenu = JMenuItem.new(\"Send to Faraday\", nil)\n\n \t faradayMenu.addActionListener do |e|\n \t eventScan(invocation, ctx)\n \t end\n\n \t menu.push(faradayMenu)\n end\n\n return menu\n end", "def right_click(name, *args)\n widget(name, *args).right_click\n end", "def createMenuItems(invocation)\r\n \r\n menu = []\r\n\r\n # Which part of the interface the user selects\r\n ctx = invocation.getInvocationContext()\r\n\r\n # Sitemap history, Proxy History will show menu item if selected by the user\r\n @stdout.println('Menu TYPE: %s\\n' % ctx)\r\n if ctx == 5 or ctx == 6 or ctx == 7\r\n\r\n faradayMenu = JMenuItem.new(\"Send to Faraday\", nil)\r\n\r\n faradayMenu.addActionListener do |e|\r\n eventScan(invocation, ctx)\r\n end\r\n\r\n menu.push(faradayMenu)\r\n end\r\n \r\n return menu\r\n end", "def click(btn)\n not_supported \"anything other than left clicking\" unless btn == 'left'\n execute_applescript(%Q`\n tell application \"Extra Suites\"\n ES click mouse\n end tell\n `)\n end", "def clicked(mouse_event)\n end", "def main_menu\n h = { \n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :s => :sort_menu, \n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n :x => :extras\n }\n menu \"Main Menu\", h\nend", "def on_help(menu)\n end", "def right_click()\n right_mouse_down\n right_mouse_up\n stall :right_click\n end", "def view_menu\n h = {\n f: :select_from_visited_files,\n d: :select_from_used_dirs,\n b: :view_bookmarks,\n s: :list_selected_files,\n c: :child_dirs,\n r: :recent_files,\n t: :tree,\n e: :dirtree\n }\n menu 'View Menu', h\nend", "def addMenuItem _obj, _args\n \"_obj addMenuItem _args;\" \n end", "def click\n raise \"Must implement custom click method.\"\n end", "def mouse_up *args; end", "def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend", "def addMenu _obj, _args\n \"_obj addMenu _args;\" \n end", "def select_menu(path)\r\n menu_item(path).click\r\n end", "def interactive_menu\n loop do\n print_menu\n selection\n end\nend", "def print_menu\n puts \"Which action [list|add|delete|mark|idea|quit]?\"\nend", "def permissions_menu(name, text) #, target_class)\n define_method(name) {\n self.link(:text=>text).fire_event(\"onmouseover\")\n self.link(:text=>text).parent.div(:class=>\"lhnavigation_selected_submenu_image\").fire_event(\"onclick\")\n self.link(:id=>\"lhnavigation_submenu_user_permissions\").click\n self.class.class_eval { include ProfilePermissionsPopUp }\n }\n end", "def hcSelected _args\n \"hcSelected _args;\" \n end", "def rightclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)\n $marathon.click(componentName, true, o1, o2, o3, o4, o5)\nend", "def default_context_menu\n [\n :row_counter.action,\n \"-\",\n :ctrl_manage.action,\n :show_details.action, # The custom action defined below via JS\n \"-\", # Adds a separator\n *super # Inherit all other commands\n ]\n end", "def click_action\n raise NotImplementedError \"Subclasses must implement this method\"\n end", "def on_click\n\t\tend", "def build_menu(application_name, method_names)\n #take array of method names and turn into menu\n puts \"#{application_name.humanize}\"\n method_names.each_with_index {|method_name, index| puts \"#{index + 1}: #{method_name.to_s.humanize}\"}\n puts \"\\nPlease enter your selection:\"\nend", "def main_menu\n main_menu_options = {'Interact with Existing Kits' => :list_and_select_kit,\n 'Create a new Kit' => :prompt_kit_params, \n 'Quit' => :quit}\n \n op = @io.select_from_options(\"What would you like to do?\", main_menu_options)\n @operation_stack.unshift op\n \n # return nil, because there's nothing to pass onto the next method\n return\n end", "def rightclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)\n $marathon.click(componentName, true, o1, o2, o3, o4, o5)\nend", "def main_menu\n h = { \n \"1\" => :view_article,\n \"2\" => :view_comments,\n :f => :display_forum,\n :v => :view_menu,\n :r => :reload,\n :m => :fetch_more,\n :R => :reddit_options,\n :H => :hacker_options,\n :s => :sort_menu, \n :C => :config_menu,\n :a => :view_article,\n :c => :view_comments,\n :x => :extras\n }\n=begin\n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n=end\n\n menu \"Main Menu\", h\nend", "def mouse_down locator\r\n command 'mouseDown', locator\r\n end", "def mouse_down locator\r\n command 'mouseDown', locator\r\n end", "def quick_menuitem(how, what)\n if mac_internal? || (window_id != nil && window_id <= 0)\n QuickMenuItem.new(self, how, what, name == 'Opera' ? nil : name)\n else\n QuickMenuItem.new(self, how, what, window_id)\n end\n end", "def click()\n mouse_down\n mouse_up\n stall :click\n end", "def openContextPopup(pos, wItem)\n poRow = wItem.row\n poColumn = wItem.column\n process = taskItemAtRow(wItem.row).process\n\n menu = Qt::Menu.new\n insertDefaultActions(menu, poColumn, process)\n createPlayerMenu(menu, poColumn, process)\n action = menu.exec(pos)\n if action then\n $log.code { \"execute : '#{action.data.toString}'\" }\n cmd, exe = action.data.toString.split(/@/, 2)\n $log.code { \"cmd(#{cmd}), exe(#{exe})\" }\n if cmd =~ /^play/\n playMedia(cmd, process, exe)\n elsif self.respond_to?(cmd)\n self.method(cmd).call(process, wItem)\n else\n $log.warn { \"No method #{cmd} in contextmenu.\" }\n end\n end\n menu.deleteLater\n end", "def create_menu\n items = Hash.new\n # action shd be a hash\n # menu should have array of hashes (or just a string)\n #db = { :name => \"Databases\", :accelerator => \"M-d\", :enabled = true, :on_right => :get_databases }\n #or = { :name => \"Open Recent\", :accelerator => \"M-o\", :enabled = true, :on_right => :get_recent }\n #find_array = {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev}\n items[\"File >\"] = [\"Open ... C-o\" , \"Open Recent\", \"Databases\" , \"Tables\", \"Exit\"]\n items[\"Window >\"] = { \"Tile\" => nil, \"Find >\" => {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev},\n \"Edit\" => nil, \"Whatever\" => nil}\n items[\"Others >\"] = { \"Shell Output ...\" => :shell_output, \"Suspend ...\" => :suspend , \"View File\" => :choose_file_and_view}\n\n # in the case of generated names how will call back know that it is a db name or a table name\n # We get back an array containing the entire path of selections\n right_actions = {}\n right_actions[\"Databases\"] = Proc.new { Dir.glob(\"**/*.{sqlite,db}\") }\n right_actions[\"Tables\"] = :get_table_names\n\n ret = popupmenu items, :row => 1, :col => 0, :bgcolor => :cyan, :color => :white, :right_actions => right_actions\n # ret can be nil, or have a symbol to execute, or a String for an item with no leaf/symbol\n if ret\n alert \"Got #{ret}\"\n last = ret.last\n if last.is_a? Symbol\n if respond_to?(last, true)\n send(last)\n end\n end\n end\n\n return\n r = 1\n ix = popuplist( top , :title => \" Menu \" , :row => r, :col => 0, :bgcolor => :cyan, :color => :white)\n if ix\n value = top[ix]\n ix = popuplist( items[value] , :row => r + 2 + ix, :col => 10, :bgcolor => :cyan, :color => :white)\n end\nend", "def action\n case item.type\n when :switch, :bar\n toggle_item\n when :advanced\n process_method\n when :variable\n open_popup\n end\n end", "def hover_click(*args)\n if args.size == 1\n driver.action.click(element).perform\n else\n sym,id = args\n driver.action.click(driver.find_element(sym.to_sym,id)).perform\n end\n\n end", "def click(*args)\n\t\t\t# if no argument has been provided, click on the\n\t\t\t# window itself\n\t\t\th = (args.length == 0) ? @handle : child(args[0]).handle\n\t\t\t\n\t\t\trectangle = [0, 0, 0, 0].pack 'LLLL'\n\t\t\tget_window_rect h, rectangle\n\t\t\tleft, top, right, bottom = rectangle.unpack 'LLLL'\n\t\t\t\n\t\t\tcenter = [(left + right) / 2, (top + bottom) / 2]\n\t\t\tset_cursor_pos *center\n\t\t\t\n\t\t\tmouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0\n\t\t\tmouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0\n\t\tend", "def create_menu\n @tk_root.tk_item.native_item.bind('Command-r', -> { main_component.execute_sql(nil) })\n end", "def TreeView_SelectItem(hwnd, hitem) TreeView_Select(hwnd, hitem, TreeViewGetNextItem[:CARET]) end", "def click(id)\n\t\t\th = child(id).handle\n\t\t\t\n\t\t\trectangle = [0, 0, 0, 0].pack 'LLLL'\n\t\t\tget_window_rect h, rectangle\n\t\t\tleft, top, right, bottom = rectangle.unpack 'LLLL'\n\t\t\t\n\t\t\tcenter = [(left + right) / 2, (top + bottom) / 2]\n\t\t\tset_cursor_pos *center\n\t\t\t\n\t\t\tmouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0\n\t\t\tmouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0\n\t\tend", "def menu_press( menu_label )\n %x{osascript<<APPLESCRIPT\n activate application \"iPhone Simulator\"\n tell application \"System Events\"\n \tclick menu item \"#{menu_label}\" of menu \"#{Localize.t(:hardware)}\" of menu bar of process \"#{Localize.t(:iphone_simulator)}\"\n end tell\n APPLESCRIPT} \n end", "def action\n trigger :click\n end", "def main_menu_nav(main_menu_item)\n main_menu_items.each do |item|\n if item.text == main_menu_item\n item.click\n break\n end\n end\n end", "def updateMenuItem _obj, _args\n \"_obj updateMenuItem _args;\" \n end", "def createMenu _obj, _args\n \"_obj createMenu _args;\" \n end", "def clicked\n @menu_click_sound.play(0.7, 1, false)\n @buttonLogin.clicked\n @buttonClassicAI.clicked\n @buttonOttoAI.clicked\n @buttonHelp.clicked\n\n @buttonHelpLogin.clicked\n @buttonHelpClassicAI.clicked\n @buttonHelpOttoAI.clicked\n end", "def xtra_points_menu_link\n $tracer.trace(__method__)\n return ToolTag.new(a.className(create_ats_regex_string(\"AuthorizedFaq\")), __method__)\n end", "def _button_2_command(*args)\n\n end", "def _button_2_command(*args)\n\n end", "def on_context_item_selected(mi) # not yet used\n pos = mi.menu_info.position\n\n case mi.title.to_s\n when \"Edit\"\n edit @scripts_list[pos]\n when \"Execute\"\n begin\n execute IO.read(@scripts_list[pos]), \"[Running #{@scripts_list[pos]}]\"\n rescue\n toast \"#{@scripts_list[pos]} not found!\"\n end\n when \"Delete\"\n @confirm_delete = @scripts_list[pos]\n AlertDialog::Builder.new(@ruboto_java_instance).\n setMessage(\"Delete #{@confirm_delete}?\").\n setCancelable(false).\n setPositiveButton(\"Yes\", (proc{|d,w| my_dialog_click(d,w)})).\n setNegativeButton(\"No\", (proc{|d,w| my_dialog_click(d,w)})).\n create.\n show\n end\n\n true\n end", "def mouse_clicked(event)\n \n puts \"IN schemasTreeTable_mouse_clicked : #{event.inspect}\"\n puts \"MOUSE #{event.class} : #{event.getClickCount} : BUTTON #{event.getButton}\"\n\n # Double Click => EDIT\n if(event.getClickCount == 2)\n puts \"edit\"\n \n elsif( event.getButton == java.awt.event.MouseEvent::BUTTON3)\n \n transfer[:event] = event\n\n listener = PopupActionListener.new( self )\n\n items = [\"Select All\", \"Clear\"]\n\n listener.add_callback_method(\"Select All\", :select_all_action_performed )\n\n listener.add_callback(\"Clear\") do\n puts \"CLEAR SCHEMA SELECTION\"\n end\n\n pmenu = PopupMenuController.create_instance\n\n pmenu.open(event, items, listener )\n end\n end", "def select_with_click\n if mac_internal?\n press_menu\n else\n click\n end\n selected?\n end", "def assigned_menu\n\n end", "def action\n case item.type\n when :switch, :bar\n toggle_item\n when :advanced\n process_method\n when :variable\n open_popup\n else\n process_custom_method\n end\n end", "def main_menu\n puts \"(b) - basic calculator\"\n puts \"(a) - advanced calculator\"\n puts \"(q) - quit\"\nend", "def main_menu\n puts \"(b) - basic calculator\"\n puts \"(a) - advanced calculator\"\n puts \"(q) - quit\"\nend", "def select_menu(menuitems, keystroke=nil)\n $marathon.selectMenu(menuitems, keystroke)\nend", "def main_menu\n puts\"(b) - basic calculator\"\n puts\"(a) - advanced calculator\"\n puts\"(bmi) - body mass index\"\n puts\"(t) - trip calculator\"\n puts\"(m) - morgage\"\n puts\"(q) - quit\"\nend", "def create_menu_command\n\t @command_window = Window_MenuCommand.new\n\t @command_window.set_handler(:item, method(:command_item))\n\t @command_window.set_handler(:skill, method(:command_personal))\n\t @command_window.set_handler(:equip, method(:command_personal))\n\t @command_window.set_handler(:status, method(:command_personal))\n\t @command_window.set_handler(:save, method(:command_save))\n\t @command_window.set_handler(:game_end, method(:command_game_end))\n\t @command_window.set_handler(:cancel, method(:return_scene))\t\n\tend", "def getMenu(menu)\n end", "def TreeView_Select(hwnd, hitem, code) send_treeview_message(hwnd, :SELECTITEM, wparam: code, lparam: hitem) end", "def click_menu_item(bar, menu, item, timeout=nil)\r\n barElement = find_by_id_and_class(bar, \"ss-MainMenuBar\", timeout)\r\n menuElement = source_find_by_id_and_class(barElement, menu, \"gwt-MenuItem\", timeout)\r\n menuElement.click\r\n itemElement = find_by_id_and_class(item, \"gwt-MenuItem\", timeout)\r\n itemElement.click\r\n end", "def _button_3_command(*args)\n\n end", "def menu\nend", "def open_menu\n touch_screen_element menu_icon\n end", "def _button_4_command(*args)\n\n end", "def button_down_main_menu_presenter(id, window, state)\n case id\n when Gosu::MsLeft\n navigate_to(window, Presenter::HOW_TO_PRESENTER) if mouse_over_button(state[:buttons][:how_to], window.mouse_x, window.mouse_y)\n navigate_to(window, Presenter::MAZE_PRESENTER, { algorithm: MazeAlgorithm::DEPTH_FIRST}) if mouse_over_button(state[:buttons][:depth_first], window.mouse_x, window.mouse_y)\n navigate_to(window, Presenter::MAZE_PRESENTER, { algorithm: MazeAlgorithm::ITERATIVE_DIVISION}) if mouse_over_button(state[:buttons][:iterative_division], window.mouse_x, window.mouse_y)\n window.close if mouse_over_button(state[:buttons][:quit], window.mouse_x, window.mouse_y)\n end\nend", "def clicked\n @return.clicked\n end", "def ctrlActivate _args\n \"ctrlActivate _args;\" \n end", "def mouse_up locator\r\n command 'mouseUp', locator\r\n end", "def select_menu_item app, *path\n app.application.select_menu_item *path\n end", "def mouse_clicked\n\t\t# Send the mouse click to the Interaction Controller. It'll do the dirty work.\n\t\t@interaction_controller.mouse_clicked\n\t\tputs \"Editor#mouse_clicked\"\n\tend", "def click\n @mech.click self\n end", "def menu\n \nend", "def click(btn = 'left')\n compatible_call :click, btn\n end", "def tripleclick(btn)\n not_supported \"anything other than left clicking\" unless btn == 'left'\n execute_applescript(%Q`\n tell application \"Extra Suites\"\n ES click mouse\n ES click mouse\n ES click mouse\n end tell\n `)\n end", "def type\n \"mymenu\"\n end", "def nextMenuItemIndex _args\n \"nextMenuItemIndex _args;\" \n end", "def click\n `#{@el}.click() || Opal.nil`\n end", "def button_down; end", "def toggle_menu menu_text=nil\n unless menu_text\n h = { \n # :h => :toggle_hidden, \n :c => :toggle_case, :l => :toggle_long_list , \"1\" => :toggle_columns, \n :g => :use_gui_browser, :t => :use_text_browser}\n ch, menu_text = menu \"Toggle Menu\", h\n end\n case menu_text\n when :toggle_hidden\n $hidden = $hidden ? nil : \"D\"\n refresh\n when :toggle_case\n #$ignorecase = $ignorecase ? \"\" : \"i\"\n $ignorecase = !$ignorecase\n refresh\n when :toggle_columns\n $gviscols = 3 if $gviscols == 1\n $long_listing = false if $gviscols > 1 \n x = $grows * $gviscols\n $pagesize = $pagesize==x ? $grows : x\n when :use_gui_browser\n $open_command = $browser_gui || \"open\"\n when :use_text_browser \n $open_command = $browser_text || \"elinks\"\n\n when :toggle_long_list\n $long_listing = !$long_listing\n if $long_listing\n $gviscols = 1\n $pagesize = $grows\n else\n x = $grows * $gviscols\n $pagesize = $pagesize==x ? $grows : x\n end\n refresh\n end\nend", "def ctrlShown _args\n \"ctrlShown _args;\" \n end", "def build_menu(type)\n # Session Gtk::Menu\n menu_session = Gtk::Menu.new\n\n session_item_shell = Gtk::ImageMenuItem.new(\"Interact Session\")\n session_image_shell = Gtk::Image.new\n session_image_shell.set(Gtk::Stock::CONNECT, Gtk::IconSize::MENU)\n session_item_shell.set_image(session_image_shell)\n menu_session.append(session_item_shell)\n\n if (type == \"meterpreter\")\n meterpreter_separator = Gtk::SeparatorMenuItem.new\n menu_session.append(meterpreter_separator)\n\n # Meterpreter shell\n meterpreter_item_shell = Gtk::ImageMenuItem.new(\"Meterpreter Shell\")\n meterpreter_image_shell = Gtk::Image.new\n meterpreter_image_shell.set(Gtk::Stock::EXECUTE, Gtk::IconSize::MENU)\n meterpreter_item_shell.set_image(meterpreter_image_shell)\n # TODO\n # menu_session.append(meterpreter_item_shell)\n\n # sdapi/process\n meterpreter_proc_item_shell = Gtk::ImageMenuItem.new(\"Process\")\n meterpreter_proc_image_shell = Gtk::Image.new\n meterpreter_proc_image_shell.set(Gtk::Stock::INDEX, Gtk::IconSize::MENU)\n meterpreter_proc_item_shell.set_image(meterpreter_proc_image_shell)\n menu_session.append(meterpreter_proc_item_shell)\n\n # sdapi/fs\n meterpreter_fs_item_shell = Gtk::ImageMenuItem.new(\"Browse\")\n meterpreter_fs_image_shell = Gtk::Image.new\n meterpreter_fs_image_shell.set(Gtk::Stock::OPEN, Gtk::IconSize::MENU)\n meterpreter_fs_item_shell.set_image(meterpreter_fs_image_shell)\n menu_session.append(meterpreter_fs_item_shell)\n\n # Meterpreter shell signal\n meterpreter_item_shell.signal_connect('activate') do |item|\n if current = @selection.selected\n Msf::Ui::Gtk2::Console::Meterpreter.new(current)\n end\n end\n\n # Process signal\n meterpreter_proc_item_shell.signal_connect('activate') do |item|\n if current = @selection.selected\n Msf::Ui::Gtk2::Stdapi::Sys::Ps.new(current[O_SESSION])\n end\n end\n\n # Fs signal\n meterpreter_fs_item_shell.signal_connect('activate') do |item|\n if current = @selection.selected\n Msf::Ui::Gtk2::Stdapi::Fs.new(current[O_SESSION])\n end\n end\n end\n\n basic_separator = Gtk::SeparatorMenuItem.new\n menu_session.append(basic_separator)\n\n close_session_item_shell = Gtk::ImageMenuItem.new(\"Close Session\")\n close_session_image_shell = Gtk::Image.new\n close_session_image_shell.set(Gtk::Stock::CLOSE, Gtk::IconSize::MENU)\n close_session_item_shell.set_image(close_session_image_shell)\n menu_session.append(close_session_item_shell)\n\n session_item_shell.signal_connect('activate') do |item|\n if current = @selection.selected\n open_session(current)\n end\n end\n\n close_session_item_shell.signal_connect('activate') do |item|\n if session_iter = @selection.selected\n remove_session_iter(session_iter)\n end\n end\n\n return menu_session.show_all\n end" ]
[ "0.69734347", "0.69734347", "0.69734347", "0.6854282", "0.68469274", "0.6763902", "0.6715973", "0.66833013", "0.66774136", "0.6670237", "0.66370136", "0.65912074", "0.658327", "0.6581311", "0.6581311", "0.6520747", "0.65024436", "0.6489541", "0.64653593", "0.6464306", "0.64318746", "0.6402063", "0.6396109", "0.63892686", "0.63710105", "0.63421565", "0.6311672", "0.6308928", "0.629314", "0.6290953", "0.6236402", "0.6231436", "0.62186325", "0.6208328", "0.6194926", "0.6174141", "0.6172229", "0.61716413", "0.6166997", "0.61654603", "0.6162269", "0.6153625", "0.6136752", "0.6131735", "0.6127194", "0.612032", "0.612032", "0.6112523", "0.6112447", "0.6098232", "0.60923296", "0.60792404", "0.6077501", "0.60764325", "0.6062122", "0.6048634", "0.6041917", "0.6035629", "0.60339594", "0.60279185", "0.6027279", "0.60241294", "0.59981966", "0.59906507", "0.5990522", "0.5990522", "0.5989391", "0.59540147", "0.59523153", "0.59481", "0.59446", "0.5942148", "0.5942148", "0.5939872", "0.59257936", "0.59256256", "0.5922339", "0.59134525", "0.5906554", "0.59036213", "0.5897232", "0.5890469", "0.5884443", "0.58834046", "0.587984", "0.5864179", "0.5860904", "0.5860701", "0.586039", "0.5857712", "0.5844008", "0.58421844", "0.58379084", "0.5837645", "0.5834667", "0.5830303", "0.5828371", "0.58264005", "0.58250844", "0.5819576" ]
0.5848139
90
=begin Implement repeatingkey XOR Here is the opening stanza of an important work of the English language: Burning 'em, if you ain't quick and nimble I go crazy when I hear a cymbal Encrypt it, under the key "ICE", using repeatingkey XOR. In repeatingkey XOR, you'll sequentially apply each byte of the key; the first byte of plaintext will be XOR'd against I, the next C, the next E, then I again for the 4th byte, and so on. It should come out to: 0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272 a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f Encrypt a bunch of stuff using your repeatingkey XOR function. Encrypt your mail. Encrypt your password file. Your .sig file. Get a feel for it. I promise, we aren't wasting your time with this. =end Simply proceed modularly through the array and fixed_xor the corresponding bytes.
def repeat_key_xor(text, key) hex_text = text.unpack('H*').join #Unpack the key into its individual letters key_array = key.unpack('H2H2H2') out = hex_text.scan(/../).map.with_index { |a, i| fixed_xor(a, key_array[i.modulo(3)]) }.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeating_key_xor(string, key)\n counter = 0\n encrypted = []\n string.bytes.each do |byte|\n encrypted << (byte ^ key.bytes[counter])\n \n counter = counter == 2 ? 0 : counter += 1\n end\n # binding.pry\n encrypted.map{ |i| sprintf(\"%02x\", i) }.join.strip\n end", "def crypt(message, key)\n repeated_key = key * ((message.length+2) / key.length)\n\n #puts message.length\n #puts repeated_key.length\n \n (0..message.length-1).map{|i|\n message[i] ^ repeated_key[i]\n }\n\nend", "def break_repeat_key_xor_data(data, key_size)\n blocks = transpose_blocks(data, key_size)\n\n # Solve each block as if it was single-character XOR. For each block, the\n # single-byte XOR key that produces the best looking histogram is the\n # repeating-key XOR key byte for that block. Put them together and you have\n # the key.\n key = blocks.map do |idx, block|\n best_result = single_byte_xor_cipher(encode_hex(block))[0]\n key_part = best_result[0]\n [idx, key_part]\n end.\n sort_by{ |i| i[0] }.\n map{ |i| i[1].chr }.\n join(\"\")\n\n puts \"Probable key: '#{key}'\"\n key\nend", "def xor(input)\n key = 128\n output = input.split(//).collect {|e| [e.unpack('C').first ^ (key & 0xFF)].pack('C') }.join\n output = output.split(//).collect {|e| [e.unpack('C').first ^ (key - 27 & 0xFF)].pack('C') }.join\n Base64.strict_encode64(output)\nend", "def xor_string key, str\n\tarr = str.unpack(\"C*\").each_with_index.map do |ch, i| ch^(key[i%key.length]) end\n\tarr.pack(\"C*\")\nend", "def xor (keynum, pt, key)\n # get the individual key from the key schedule\n k = key[keynum,4]\n if $decrypt\n # reverse the reversed key to correct it\n k = k.reverse\n # run the key through the permputation if we are in the correct step\n if $permute\n k = permute(k, $perm)\n end\n end\n # xor the key and hex\n ret = k.hex ^ pt.hex\n # turn the number back into hex\n ret = ret.to_s(16)\n # pad the number with leading 0's\n while (ret.length < 4)\n ret.prepend(\"0\")\n end\n return ret\nend", "def xor_decrypt(bytes, password)\r\n decrypt = \"\"\r\n pw_index = 0 #keeps track of index to cycle password\r\n\r\n bytes.each do |i|\r\n decrypt += (i ^ password[pw_index]).to_s + \",\" #run xor operation\r\n pw_index += 1\r\n #loop over the password if it reaches its limit\r\n if pw_index > password.length - 1\r\n pw_index = 0\r\n end\r\n end\r\n #returns as a string of ascii values\r\n decrypt\r\nend", "def crack_xor\n key_size = (2..40).to_a\n data = Tools.get_data6\n binding.pry\n \n end", "def xor_c\n end", "def xordecrypt\n return match(@payload,@prefix,@keys,@keywords)\n end", "def xor_n\n value = next_byte\n xor_to_a value\n @clock += 2\n end", "def xor(bytes1, bytes2)\n bytes1.zip(bytes2).map { |b1, b2| b1 ^ b2 }\nend", "def xor(codes, string)\n Array.new([codes.size, string.size].min) { |i| codes[i] ^ string[i].ord }.map(&:chr).join\nend", "def xor_cypher(str)\n # try rewrite using Array#pack 'H*' or String#unpack\n str_byte_arr = str.scan(/../).map { |h| h.to_i(16) }\n processed_buffers = []\n \n #instead of taking two arrays, take in 1\n string_xor_ascii(processed_buffers, str_byte_arr)\n find_plaintext(processed_buffers)\n end", "def breakXORCipher(cipherText)\n scoredTexts = Hash.new\n \n #Try all ASCII keys from \n for i in 32..126 do\n keyChar = i.chr\n \n possiblePlaintext = hexToASCII(singleByteXOR(cipherText.upcase, keyChar))\n scoredTexts[keyChar] = scorePlaintext(possiblePlaintext)\n \n if(scoredTexts[keyChar] == possiblePlaintext.length)\n puts cipherText\n puts possiblePlaintext \n puts keyChar + \" scored \" + scoredTexts[keyChar].to_s\n end\n end\nend", "def calculate_doublepulsar_xor_key(s)\n x = (2 * s ^ (((s & 0xff00 | (s << 16)) << 8) | (((s >> 16) | s & 0xff0000) >> 8)))\n x & 0xffffffff # this line was added just to truncate to 32 bits\n end", "def singleByteXOR(hexStr, keyChar)\n #ASCII character -> 1 byte of binary (8 bit) -> 2-digit hex\n hexKeyChar = binToHex(decToBin(keyChar.ord).rjust(8, '0'))\n \n #XOR output (hex)\n xorOutput = \"\"\n \n i = 0\n begin\n #Take 2 characters of hex from input stream\n hexStrChunk = hexStr[i..(i+1)]\n \n xorOutput.concat(hex_XOR(hexStrChunk, hexKeyChar))\n \n i = i + 2\n end until i > hexStr.length - 1\n \n return xorOutput\nend", "def xor_a\n end", "def cipher(bytes, secret)\n ctext = Array.new(bytes)\n\n secret.each_index do |n|\n bytes.each_index do |i|\n ctext[i] = ctext[i] ^ secret[(n+secret[n]+i) % secret.length]\n end\n end\n\n return ctext\n end", "def xor_l\n end", "def xor(left, right)\n res = Array.new\n 0.upto(3) do |i|\n temp = left[i] ^ right[i]\n res << temp\n end\n res\n end", "def xor_e\n end", "def xor(first, second)\n first.bytes.zip(second.bytes).map{ |(a,b)| (a ^ b).chr }.join('')\n end", "def xor_b\n end", "def xor(b)\n r = []\n zip_bytes(b) { |i,j| r << (i ^ j) }\n Id.new r.length, false, r\n end", "def lookForXOR(fileName)\n cryptoLines = IO.readlines(fileName)\n \n cryptoLines.each do |c|\n breakXORCipher c.strip\n end\nend", "def decrypt(ciphertext, key)\n plaintext = []\n i = 0\n ciphertext.each_byte do |c|\n p = c ^ key[i % 3][0]\n i += 1\n plaintext << p.chr\n end\n return plaintext.join\nend", "def xor_d8\n end", "def xor_h\n end", "def xor_byte_strings(s1, s2) # :doc:\n s2 = s2.dup\n size = s1.bytesize\n i = 0\n while i < size\n s2.setbyte(i, s1.getbyte(i) ^ s2.getbyte(i))\n i += 1\n end\n s2\nend", "def xor_d\n end", "def crypt(block, key)\n key = key.bytes\n k = []\n k << key.first << key.last\n k = k.join.to_i\n block.map { |bit| bit.odd? ? bit ^ k : bit ^ (ROUNDS ^ k) }\n end", "def xor(x, y)\n\nend", "def challenge25(ciphertext, edit_proc)\n CryptUtil.xor(ciphertext, edit_proc.call(0, \"\\x00\" * ciphertext.bytesize))\n end", "def crypt(plaintext, key)\n ciphertext = String.new\n\n plaintext.chars.each_with_index do |c, i|\n ciphertext << \"%02x\" % (c.bytes[0] ^ key[i % key.length].bytes[0])\n end\n\n ciphertext\n end", "def repeated_block_encrypt(key, plain, iterations)\n key_length = key.length\n iterations.times do\n tf = Twofish.new(key)\n cipher = tf.encrypt(plain)\n assert_equal(plain, tf.decrypt(cipher))\n key = (plain + key)[0, key_length]\n plain = cipher\n end\n plain\n end", "def x_xor_y\n x = @x.content\n y = @y.content\n z = Array.new @z.length, 0\n\n @z.length.times { |i| z[i] = x[i] ^ y[i] }\n\n @z.content = z\n end", "def xor_bytes(bytes1, bytes2)\n results_in_bytes = (0...bytes1.length).map { |i| bytes1[i] ^ bytes2[i] }\n bytes_to_hex(results_in_bytes)\nend", "def otp(plaintext, key)\n results = pad_key normalize(plaintext), normalize(key)\n xor results.first, results.last\n end", "def xor(a, b)\n\tm = \"\"\n\tif a.length > b.length\n\t\tbig = a\n\t\tsmall = b\n\telse\n\t\tbig = b\n\t\tsmall = a\n\tend\n\t#a = a.to_i(16).to_s(2) # convert to binary\n\t#b = b.to_i(16).to_s(2) # convert to binary\n\t# xor each byte individually\n\tfor i in 0...(small.length)\n\t\tm << (a[i,1].to_i(16)^b[i,1].to_i(16)).to_s(16) # append to msg string in hex\n\tend\n\t# append the rest of the bigger string\n\t#for i in small.length...big.length\n\t#\tm << big[i].chr\n\t#end\n\treturn m\nend", "def ctr(text, key, nonce)\n text.\n bytes.\n each_slice(16).\n map.\n with_index do |block, block_index|\n keystream = _ecb_encrypt([nonce, block_index].pack(\"QQ\"), key)\n\n block.map.with_index do |byte, byte_index|\n byte ^ keystream[byte_index].ord\n end\n end.flatten.pack(\"C*\")\n end", "def potential_strings_from_single_char_xor(encoded_string)\n # for all bytes...\n (0..255).map do |decoded_char|\n # Create a hex string equal in length to the target\n decoding_string = bytes_to_hex([decoded_char] * encoded_string.length)\n\n DecodedString.new(\n decoded_char,\n xor_hex(encoded_string, decoding_string)\n )\n end\nend", "def xor(*args)\n args.inject(self, :^)\n end", "def xor_strings(s1, s2)\r\n s1.unpack('C*').zip(s2.unpack('C*')).map { |a, b| a ^ b }.pack('C*')\r\n end", "def decrypt_next_byte(column)\n solution = MatasanoLib::XOR.brute(column, 'ETAOIN SHRDLU,.')\n solution[:key]\nend", "def vigenere_cipher(message, keys)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n cycle = 0\n result = \"\"\n\n message.each_char do |char|\n result += alphabet[(alphabet.index(char) + keys[cycle % keys.length]) % alphabet.length]\n cycle += 1\n end\n\n return result\nend", "def fixedXOR(a = 0x1c0111001f010100061a024b53535009181c, b = 0x686974207468652062756c6c277320657965)\n if a.to_s(16).length == b.to_s(16).length\n res = a ^ b\n else\n # TODO: raise error\n res = 0\n puts \"error: diff size arguments\"\n end\n res\nend", "def odd_duplicates(array)\n xor = array.reduce(0, :^)\nend", "def str_xor(s1, s2)\n if s1.length != s2.length:\n minlen = [s1, s2].map(&:length).min\n s1 = s1[0...minlen]\n s2 = s2[0...minlen]\n end\n s1.bytes.zip(s2.bytes).map{ |b1, b2| b1 ^ b2 }.map(&:chr).join\nend", "def vigenere_cipher(word, key_seq_arr)\n return word if key_seq_arr.empty?\n \n ciphered = \"\"\n word.chars.each_with_index do |char, i|\n # Can't modulo/divide by zero, so take first key manually\n if i == 0 || key_seq_arr.length == 1\n ciphered += cipher_char(char, key_seq_arr.first)\n else\n curr_key = i % key_seq_arr.length\n ciphered += cipher_char(char, key_seq_arr[curr_key])\n end\n end\n\n ciphered\nend", "def xor_missing_element array1, array2\n return nil if array1.length == 0 && array2.length == 0\n result = 0\n (array1 + array2).each do |number|\n result ^= number\n end\n return result\nend", "def __xor_byte(o)\n\t\treturn Buffer.__new__(@bytes.map { |b| b ^ o })\n\tend", "def vigenere_cipher(msg, arr)\n alphabet = (\"a\"..\"z\").to_a\n new_msg = \"\"\n msg.each_char.with_index do |char, i|\n pos= alphabet.index(char)\n key = arr[i % arr.length]\n new_pos = (pos + key) % alphabet.length\n new_msg += alphabet[new_pos]\n end\n new_msg\nend", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n encrypted = \"\"\n\n message.each_char.with_index do |char, idx|\n shift = keys[idx % keys.length]\n encrypted += alphabet[(alphabet.index(char) + shift) % 26]\n end\n\n encrypted\nend", "def encryption_oracle\n # From an early-on AES-128-ECB exercise. 'YELLOW SUBMARINE' is the 128-bit key.\n ciphertext = URL::decode64('http://cryptopals.com/static/challenge-data/25.txt')\n plaintext = AES_128.decrypt(ciphertext, 'YELLOW SUBMARINE', :mode => :ECB)\n\n AES_128.encrypt(plaintext, AES_KEY, :mode => :CTR)\nend", "def vigenere_cipher(message, keys)\n alphabetic = (\"a\"..\"z\").to_a\n encrypted = \"\"\n\n message.each_char.with_index do |char, i|\n num = keys[i % keys.length]\n index = alphabetic.index(char)\n encrypted += alphabetic[(index + num) % 26]\n end\n \n encrypted\nend", "def encrypt(msg_array, rotor)\n encrypted_msg = []\n msg_array.each do |x|\n rotor.each do |key, value| \n if key == x\n encrypted_msg << value\n end\n end\n end\n encrypted_msg\nend", "def vigenere_cipher(message, keys)\n chars = message.split('')\n i = -1\n enc_chars = chars.map do |char|\n i = (i + 1) % keys.length\n encrypt_char(char, keys[i])\n end\n enc_chars.join\nend", "def vigenere_cipher(message, keys)\n key_idx = 0\n new_message = \"\"\n message.each_char do |char|\n new_message += cipher(char, keys[key_idx])\n key_idx = (key_idx + 1) % keys.length\n end\n\n new_message\nend", "def xor_hl\n end", "def crypt(text,key,operator = :+)\n index = 0\n text.upcase.each_byte.reduce(\"\") do |res, c|\n res << (65 + (c.send(operator, key[index % key.length].ord)) % 26).chr\n index += 1\n res\n end\nend", "def north_korean_cipher(coded_message)\n input = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the ruby docs.\n decoded_sentence = []\n \n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n \"g\" => \"c\",\n \"h\" => \"d\",\n \"i\" => \"e\", #pros- you have the key and value exactly as a certain thing. #cons- this is really long\n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\",\n \"m\" => \"i\",\n \"n\" => \"j\",\n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n \n input.each do |x| # What is #each doing here?\n found_match = false # Why would this be assigned to false from the outset? What happens when it's true?\n cipher.each_key do |y| # What is #each_key doing here? checking each key in hash\n if x == y # What is this comparing? each element in input array to each key in cipher hash. Where is it getting x? x is each element in the input array. Where is it getting y? each key in cipher hash What are those variables really?\n puts \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n decoded_sentence << cipher[y] #(pushes it to an array) == array.push(x)\n found_match = true\n break # Why is it breaking here?\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #What the heck is this doing? if x equals any of those characters a space will be inserted.\n decoded_sentence << \" \"\n found_match = true\n break\n elsif (0..9).to_a.include?(x) # Try this out in IRB. What does \" (0..9).to_a \" do? it takes 0 through 9 and makes each number an element of an array\n decoded_sentence << x\n found_match = true\n break\n end\n end\n if not found_match # What is this looking for?\n decoded_sentence << x\n end\n end\n decoded_sentence = decoded_sentence.join(\"\")\n \n if decoded_sentence.match(/\\d+/) #What is this matching? Look at Rubular for help. - any digit\n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } #He's been known to exaggerate...\n end\n return decoded_sentence # What is this returning? this returns the readable sentence\nend", "def vigenere_cipher(message, keys)\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n new_str = \"\"\n if keys.length == 1\n message.each_char do |char|\n alpha_idx = alpha.index(char)\n new_idx = (alpha_idx + keys[0]) % 26\n new_str += alpha[new_idx]\n end\n else\n new_keys = keys\n message.each_char do |char|\n alpha_idx = alpha.index(char)\n new_idx = (alpha_idx + new_keys[0]) % 26\n new_str += alpha[new_idx]\n new_keys.rotate!(1)\n end\n end\n new_str\n \nend", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n indices = message.split(\"\").map {|char| alphabet.index(char)}\n \n ciphered_message = \"\"\n indices.each_with_index do |n, i|\n shift_amount = keys[i % keys.length]\n new_index = (n + shift_amount) % alphabet.length\n ciphered_message += alphabet[new_index]\n end\n\n ciphered_message\nend", "def xor(e1, e2)\n eval_ex(e1) ^ eval_ex(e2)\n end", "def bit_xor(x, bits)\n bits.map{|b| x[b]}.reduce(:^)\n end", "def vigenere_cipher(message, keys)\n alpha = (\"a\"..\"z\").to_a\n count = 0\n message.each_char.with_index do |char, idx|\n pos = alpha.index(char)\n #rather than count we can do key alpha[(pos + key[idx % key.length] )% 26]\n message[idx] = alpha[(pos + keys[count]) % alpha.length]\n count += 1\n count = 0 if count == keys.length\n end\n message\nend", "def north_korean_cipher(coded_message) # \n input = coded_message.downcase.split(\"\") #Takes input, downcases it, and splits each individual element into an element of an array\n decoded_sentence = [] # creates an empty array called decoded_sentence \n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n \"g\" => \"c\", # Pros: This allows a direct translation for each key\n \"h\" => \"d\", # Cons: It's really long and inefficient \n \"i\" => \"e\", \n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\", \n \"m\" => \"i\",\n \"n\" => \"j\", \n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n \n input.each do |x| # Each is examining each element of the input array as x \n found_match = false # if found false it leaves that element of the input as the same and pushes it decoded_sentence\n cipher.each_key do |y| # Examining each key of the hash cipher \n if x == y # If statement comparing the input element (x) with the key of cipher hash (y) for match \n puts \"I am comparing x and y. X is #{x} and Y is #{y}.\" # puts string \n decoded_sentence << cipher[y] # Pushes cipher[y] into the array decoded_sentence\n found_match = true #marks match as true \n break # the value is found so it doesn't have to search through all the symbols\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #Replaces these symbols with a space\n decoded_sentence << \" \" #push space into decoded array \n found_match = true #marks match as true \n break # ends the loop for the symbols \n elsif (0..9).to_a.include?(x) # puts the values in the range in an array \n decoded_sentence << x #pushes number as is into decoded array\n found_match = true #mark match as true\n break # ends the loop for the range class\n end \n end\n if not found_match # if not true \n decoded_sentence << x #pushes the x into the decoded_sentence \n end\n end\n decoded_sentence = decoded_sentence.join(\"\") #takes elements from array and combines them into a string\n \n if decoded_sentence.match(/\\d+/) #finds matches for any numbers in the input \n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # takes that number and inserts it with an integer and divides it by 100 \n end \n return decoded_sentence # Returning string of decoded sentence \nend", "def north_korean_cipher(coded_message)\n input = coded_message.downcase.split(\"\") \n \n decoded_sentence = [] \n cipher = {\"e\" => \"a\", \n \"f\" => \"b\",\n \"g\" => \"c\",\n \"h\" => \"d\",\n \"i\" => \"e\",\n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\",\n \"m\" => \"i\",\n \"n\" => \"j\",\n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n\n input.each do |x| # Starting a very long each method-saying for each value the rest\n # of the code is going to be executed.\n found_match = false # There would be no way to actually tell if a statement was true\n # unless the default is set to false.\n cipher.each_key do |y| # Taking each key from cipher & applying the rest of the code.\n if x == y # Comparing the key and the value. X is the value. Y is the key.\n puts \"I am comparing x and y. X is #{x} and Y is #{y}.\" # prints to console\n decoded_sentence << cipher[y] # << adds element to existing array, but here it seems\n # that it is working to apply the cipher keys to the # decoded sentence.\n found_match = true # Signals if match was found, ie x==y.\n break # It is breaking because x and y can be compared infinitely.\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\"\n # Checking if any values are symbols.\n decoded_sentence << \" \" # Is applying blank space where any symbol appears.\n found_match = true # Signals if match was found, ie x==symbol.\n break # It is breaking because x can be checked infinitely.\n elsif (0..9).to_a.include?(x) # It's checking to see if x is an integer.\n decoded_sentence << x # Adds x(value) where integers are found.\n found_match = true # Signals if match was found, ie x==integer.\n break # It is breaking because x can be checked infinitely.\n end # If/elsif loop ends.\n end # The each method on y is finally ending.\n if not found_match # If x(value) isn't == to y(key), a symbol, or integer then...\n decoded_sentence << x # Apply the value to the decoded sentence.\n end # If statement ends\n end # The each method on x is finally ending.\n decoded_sentence = decoded_sentence.join(\"\") # Joins the sentence back together after\n # splitting it in order to disect each element.\n if decoded_sentence.match(/\\d+/) #What is this matching? * \\d+/ means 1 or more digits\n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # He's been known to exaggerate...\n end # This expands match- it subs\n # one or more digits for the block (basically # reducing every digit by a 1/100th)\n return decoded_sentence # Returns the answer sentence.\nend", "def aes_cbc_encrypt(buffer, key, iv)\n blocks = buffer.each_slice(key.size)\n previous_ciphertext_block = iv\n\n blocks.flat_map do |block|\n previous_ciphertext_block = aes_ecb_encrypt(\n xor_bytes(previous_ciphertext_block, block),\n key\n )\n\n previous_ciphertext_block\n end\nend", "def vigenere_cipher(message, keys)\n alpha = (\"a\"..\"z\").to_a\n new_string = \"\"\n message.each_char.with_index do |char, i|\n old_i = alpha.index(char)\n new_i = (old_i + keys[i % keys.length]) % 26\n new_string += alpha[new_i]\n end\n new_string\nend", "def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n new_msg = \"\"\n\n message.each_char.with_index do |char|\n old_pos = alphabet.index(char)\n new_pos = old_pos + keys[idx % keys.length]\n new_msg += alphabet[new_pos % alphabet.length]\n end\n\n new_msg\nend", "def vigenere_cipher(message, keys)\n alphabet = ('a'..'z').to_a\n array = []\n\n i = 0\n\n message.each_char do |char|\n idx = alphabet.index(char)\n array << alphabet[(idx + keys[i]) % 26]\n if i < keys.length - 1\n i += 1\n else\n i = 0\n end\n end\n array.join('')\n \nend", "def XOR(str1,str2)\n ret =\"\"\n str1.split(//).each_with_index do |c, i|\n ret[i] = (str1[i].ord ^ str2[i].ord).chr\n end\n return ret\nend", "def north_korean_cipher(coded_message)\n input = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the ruby docs.\n decoded_sentence = []\n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes? # I'm thinking using an array will clean this up a bit.\n \"g\" => \"c\", \n \"h\" => \"d\", \n \"i\" => \"e\", \n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\",\n \"m\" => \"i\",\n \"n\" => \"j\",\n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n \n input.each do |x| # What is #each doing here? It is iterating through the input array.\n found_match = false # Why would this be assigned to false from the outset? What happens when it's true?\n cipher.each_key do |y| # What is #each_key doing here? It is iterating through the cipher hash\n if x == y # What is this comparing? Where is it getting x? Where is it getting y? What are those variables really? These are just placeholder variables.\n puts \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n decoded_sentence << cipher[y]\n found_match = true\n break # Why is it breaking here? This is indicated that the code is finished searching for letters.\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #What the heck is this doing? This is telling it to push a space where the above characters are located.\n decoded_sentence << \" \"\n found_match = true\n break\n elsif (0..9).to_a.include?(x) # Try this out in IRB. What does \" (0..9).to_a \" do? This is converting the integers 0 through 9 into an array\n decoded_sentence << x\n found_match = true\n break\n end \n end\n if not found_match # What is this looking for? Not entirely sure, but it could be that it should push any character that isn't in any of the above arrays or hashes, such as punctuation marks.\n decoded_sentence << x\n end\n end\n decoded_sentence = decoded_sentence.join(\"\")\n \n if decoded_sentence.match(/\\d+/) #What is this matching? Look at Rubular for help. It is matching any digits it finds\n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } #He's been known to exaggerate...\n end \n return decoded_sentence # What is this returning? The finished decoded sentence. \nend", "def north_korean_cipher(coded_message)\n\tinput = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the ruby docs.\n\tdecoded_sentence = []\n\tcipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n\t\t\t\t\t\t\"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n\t\t\t\t\t\t\"g\" => \"c\", \n\t\t\t\t\t\t\"h\" => \"d\", \n\t\t\t\t\t\t\"i\" => \"e\", \n\t\t\t\t\t\t\"j\" => \"f\",\n\t\t\t\t\t\t\"k\" => \"g\",\n\t\t\t\t\t\t\"l\" => \"h\",\n\t\t\t\t\t\t\"m\" => \"i\",\n\t\t\t\t\t\t\"n\" => \"j\",\n\t\t\t\t\t\t\"o\" => \"k\",\n\t\t\t\t\t\t\"p\" => \"l\",\n\t\t\t\t\t\t\"q\" => \"m\",\n\t\t\t\t\t\t\"r\" => \"n\",\n\t\t\t\t\t\t\"s\" => \"o\",\n\t\t\t\t\t\t\"t\" => \"p\",\n\t\t\t\t\t\t\"u\" => \"q\",\n\t\t\t\t\t\t\"v\" => \"r\",\n\t\t\t\t\t\t\"w\" => \"s\",\n\t\t\t\t\t\t\"x\" => \"t\",\n\t\t\t\t\t\t\"y\" => \"u\",\n\t\t\t\t\t\t\"z\" => \"v\",\n\t\t\t\t\t\t\"a\" => \"w\",\n\t\t\t\t\t\t\"b\" => \"x\",\n\t\t\t\t\t\t\"c\" => \"y\",\n\t\t\t\t\t\t\"d\" => \"z\"}\n\t\n# This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n# the best data structure for this problem? What are the pros and cons of hashes?\n# \n# We automated this task with our own method that shifts letters automatically. It even allows you to\n# specify the amount the letters need to be shifted. This will output our needed hash, without having to\n# manually write every key/value pair.\n\n\tinput.each do |x| # iterate through each letter in the coded message (input is an array of all letters in order)\n\t\tfound_match = false # If found_match is set to true, the block code \"if not found_match\" will NEVER be executed\n\t\t\t\t\t\t\t\t\t\t\t\t # so the unmapped letter will not be added back to the decoded message\n\t\tcipher.each_key do |y| # iterate through each key in the hash table\n\t\t\tif x == y # compare the current letter in the coded message to the key in the hash table. If they are equals,\n\t\t\t\t\t\t\t\t # meaning the decoded letter is found, add the mapped value to the decoded message\n\t\t\t\tputs \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n\t\t\t\tdecoded_sentence << cipher[y]\n\t\t\t\tfound_match = true\n\t\t\t\tbreak # Once the decoded letter is found, break out of the loop and go for the next letter in the input message\n\t\t\telsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" # If any of these symbols is\n\t\t\t\t# found in the coded message, it is equivalent to a space. These are all OR statements, so if any are found to\n\t\t\t\t# be true, it will run the block of code.\n\t\t\t\tdecoded_sentence << \" \"\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\telsif (0..9).to_a.include?(x) # This puts all the numbers from 0 to 9 into an array and check if that array contains x\n\t\t\t\tdecoded_sentence << x\n\t\t\t\tfound_match = true\n\t\t\t\tbreak\n\t\t\tend \n\t\tend\n\t\tif not found_match # If some character not covered by any of the if statments is found in the coded message\n\t\t# that character is put into the decoded message\n\t\t\tdecoded_sentence << x\n\t\tend\n\tend\n\tdecoded_sentence = decoded_sentence.join(\"\")\n \n\tif decoded_sentence.match(/\\d+/) #Checks the decoded message for any numbers \n\t\tdecoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } # Replaces those numbers with a number divided by 100, because\n\t\t# he has been known to exaggerate about the amount of stuff he has\n\tend \n\treturn decoded_sentence # return the decoded message \nend", "def xor(*others)\n self.class.xor(self, *others)\n end", "def inv_xor(str1, str2)\n #result = ''\n #for i in 0..(str1.size - 1) do\n # result += mod_sub(str1[i].chr, str2[i].chr)\n #end\n #result\n\n # Probably slower than above:\n str1.split(//).zip(str2.split(//)).inject('') do |acc, ch| \n acc += mod_sub(ch.first, ch.last) \n end\n end", "def vigenere_cipher(message, keys)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n vigenere = \"\"\n\n message.each_char.with_index do |char, i|\n index = alphabet.index(char)\n key = keys[i % keys.length].to_i\n new_char = alphabet[(index + key) % 26] \n vigenere += new_char\n end\n\n vigenere\nend", "def rot(n = 1)\n mask = n.chr * (self.len / 2)\n mask = Plaintext.new(mask).hexc\n res = fixedXOR(self.hex, mask.hex)\n Hex.new(res)\n end", "def test_SimpleXor\n puts \"SUITE: test_SimpleXor\"\n\n puts \" TEST: (hex) CD enter, AB enter, xor\"\n click(\"buttonC\")\n click(\"buttonD\")\n click(\"buttonEnter\")\n click(\"buttonA\")\n click(\"buttonB\")\n click(\"buttonEnter\")\n click(\"buttonXor\")\n assertResultVal(\"line0\", (0xCD ^ 0xAB))\n\n click(\"buttonClrAll\")\n assertResultEmp(\"line0\")\n\n puts \" TEST: (hex) CD enter, AB, xor\"\n click(\"buttonC\")\n click(\"buttonD\")\n click(\"buttonEnter\")\n click(\"buttonA\")\n click(\"buttonB\")\n click(\"buttonXor\")\n assertResultVal(\"line0\", (0xCD ^ 0xAB))\n\n click(\"buttonClrAll\")\n assertResultEmp(\"line0\")\nend", "def caesar_cipher(message, n)\n\nend", "def vigenere_cipher(message, key)\n key_index = 0 \n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n\n message.each_char.with_index do|char,idx|\n new_str += alpha[(alpha.index(char) + key[key_index % key.length])%26]\n key_index += 1\n end\n new_str\nend", "def __xor_buffer(o)\n\t\te = o.__bytes.cycle\n\t\treturn Buffer.__new__(@bytes.map { |b| b ^ e.next })\n\tend", "def crypt(p0) end", "def vigenere_cipher(message, keys)\n alphabet = ('a'..'z').to_a\n vigenere_str = \"\"\n\n message.each_char.with_index do |char, idx|\n old_idx = alphabet.index(char)\n temp_key = keys.shift\n keys.push(temp_key)\n new_idx = (old_idx + temp_key) % 26\n vigenere_str += alphabet[new_idx]\n end\n vigenere_str\nend", "def dr_evils_cipher(coded_message)\n input = coded_message.downcase.split(\"\") # Check out this method in IRB to see how it works! Also refer to the Ruby docs.\n # it's setting the input to be the coded message that is now lower case and splits each input into a single letter\n decoded_sentence = []\n #setting decoded sentence to be an empty array\n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n \"g\" => \"c\",\n \"h\" => \"d\",\n \"i\" => \"e\",\n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\",\n \"m\" => \"i\",\n \"n\" => \"j\",\n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n# This is where the conversions for the code is stored in a hash.\n input.each do |x| # What is #each doing here?\n found_match = false # Why would this be assigned to false from the outset? What happens when it's true?\n\n # It is iterating over each item that was in the message to be decoded. It's false because it doesn't match the code that deciphers it. It means that it was the same which can't happen.\n\n cipher.each_key do |y| # What is #each_key doing here?\n if x == y # What is this comparing? Where is it getting x? Where is it getting y? What are those variables really?\n\n # It is iterating over the hash keys. It is comparing the message to be decoded to the key to see what letter it should change it too.\n\n decoded_sentence << cipher[y]\n found_match = true\n #When they match it's push the new deciphered lettter to the decoded sentence array.\n break # Why is it breaking here?\n #It's breaking so it can move onto the next letter to decipher.\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #What the heck is this doing?\n #It's making it so if there is a character that's not a letter it won't change it and just push it into the array.\n decoded_sentence << \" \"\n found_match = true\n break\n elsif (0..9).to_a.include?(x) # Try this out in IRB. What does \" (0..9).to_a \" do?\n #Similar as before but this is for numbers in an array and will add those as well.\n decoded_sentence << x\n found_match = true\n break\n end\n end\n if not found_match # What is this looking for?\n decoded_sentence << x\n # If there isn't anything that matches the previous checks it will just add it to decoded sentece.\n end\n end\n decoded_sentence = decoded_sentence.join(\"\")\n #What is this method returning?\n# It's returning the decoded sentence and joining everything back together.\nend", "def north_korean_cipher(coded_message)\n input = coded_message.downcase.split(\"\") # Turning every letter into a lower case letter and then splitting it into array\n decoded_sentence = []\n cipher = {\"e\" => \"a\", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash\n \"f\" => \"b\", # the best data structure for this problem? What are the pros and cons of hashes?\n \"g\" => \"c\", # An array would be beeter structure, we can automate the shiffting of the letters\n \"h\" => \"d\",\n \"i\" => \"e\",\n \"j\" => \"f\",\n \"k\" => \"g\",\n \"l\" => \"h\",\n \"m\" => \"i\",\n \"n\" => \"j\",\n \"o\" => \"k\",\n \"p\" => \"l\",\n \"q\" => \"m\",\n \"r\" => \"n\",\n \"s\" => \"o\",\n \"t\" => \"p\",\n \"u\" => \"q\",\n \"v\" => \"r\",\n \"w\" => \"s\",\n \"x\" => \"t\",\n \"y\" => \"u\",\n \"z\" => \"v\",\n \"a\" => \"w\",\n \"b\" => \"x\",\n \"c\" => \"y\",\n \"d\" => \"z\"}\n\n input.each do |x| # iterating over each input character\n found_match = false #when false the same character will be added to the solution\n cipher.each_key do |y| # iterating thruthe keys of cipher hash\n if x == y #if current character is equal to a hash key\n # puts \"I am comparing x and y. X is #{x} and Y is #{y}.\"\n decoded_sentence << cipher[y]\n found_match = true\n break #it will end the loop once it finds its match\n elsif x == \"@\" || x == \"#\" || x == \"$\" || x == \"%\"|| x == \"^\" || x == \"&\"|| x ==\"*\" #If it matach one of these characters it will add a space\n decoded_sentence << \" \"\n found_match = true\n break\n elsif (0..9).to_a.include?(x) # turns a range into an array and then checks if that array includes the input\n decoded_sentence << x\n found_match = true\n break\n end\n end\n if not found_match #If there is no match then add the character to the solution\n decoded_sentence << x\n end\n end\n decoded_sentence = decoded_sentence.join(\"\")\n\n if decoded_sentence.match(/\\d+/) #Finding all the didgits\n decoded_sentence.gsub!(/\\d+/) { |num| num.to_i / 100 } #Replace and divide by 100\n end\n return decoded_sentence # it sreturning the string\nend", "def vigenere_cipher(message, keys)\n new_string = ''\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n\n message.each_char.with_index do |char, idx|\n old_idx = alphabet.index(char)\n if keys.length == 1\n new_idx = keys[0]\n end\n new_idx = keys[idx % keys.length]\n new_pos = old_idx + new_idx\n new_string += alphabet[new_pos % 26]\n end\n\n new_string\nend", "def scramble( data )\n cipher = OpenSSL::Cipher::Cipher.new( @@algorithm )\n cipher.encrypt\n cipher.pkcs5_keyivgen( @@key, @@salt )\n @@salt + cipher.update( data ) + cipher.final\n end", "def xor_hex(a, b)\n raise \"Unequal buffers passed.\" if a.length != b.length\n (a.hex ^ b.hex).to_s(16)\nend", "def encrypted_string\n blocks = initial_string.chars.each_slice(16).map(&:join)\n\n nonce = SecureRandom.random_bytes(8)\n counter = [0] * 8\n counter_bytes = counter.pack('C*')\n encryption = nonce + counter_bytes\n\n blocks.each do |block|\n cipher_block = block ^ encrypt_block(nonce + counter_bytes)\n encryption << cipher_block\n counter[-1] += 1\n counter_bytes = counter.pack('C*')\n end\n\n encryption\n end", "def xor(a,b)\n (a | b) - (a & b)\n end", "def vigenereCipher(string, key, alphabet)\n aryStr = string.split(\"\")\n nStr = Array.new\n i = 0\n while i < aryStr.length\n j = 0\n while j < key.length\n nStr << (alphabet[(alphabet.index(aryStr[i]) + key[j])])\n j += 1\n i += 1\n end\n end\n return nStr.join('')\nend", "def encrypt_message pub_key, message\n p_key = pub_key.shuffle[0 .. pub_key.length / 2] # randomly select half the values\n sum = 0\n p_key.each{ |i| sum += i}\n return sum + message\nend", "def vigenere_cipher(str, arr)\n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n str.each_char.with_index do |char, i|\n pos = alpha.index(char)\n key = arr[i % arr.length]\n new_pos = (pos + key) % alpha.length\n new_str += alpha[new_pos]\n end\n new_str\nend", "def decrypt_message(message, pass)\n\tit = -1\n\treturn message.map{|c| c^pass[it = (it+1)%pass.length]}\nend", "def vigenere_cipher(string, key_sequence)\n result = \"\"\n string.each_char.with_index do |c, idx|\n key_idx = idx % key_sequence.length\n key = key_sequence[key_idx]\n result << shift(c, key)\n end\n result\nend", "def encryption_oracle(buffer)\n prefix_padding = rand(5..10).times.map { rand(0..255) }\n suffix_padding = rand(5..10).times.map { rand(0..255) }\n padded_buffer = pkcs7_pad(prefix_padding + buffer + suffix_padding, 16)\n key = 16.times.map { rand(0..255) }\n\n if rand(2).zero?\n puts 'Encrypting with ECB...'\n aes_ecb_encrypt(padded_buffer, key)\n else\n puts 'Encrypting with CBC...'\n iv = 16.times.map { rand(0..255) }\n aes_cbc_encrypt(padded_buffer, key, iv)\n end\nend", "def xorobfuscation(io)\n key, verification_bytes = io.read(4).unpack('vv')\n\n {\n key: key, # key (2 bytes): An unsigned integer that specifies the obfuscation key. See [MS-OFFCRYPTO], 2.3.6.2 section, the first step of initializing XOR array where it describes the generation of 16-bit XorKey value.\n verificationBytes: verification_bytes # verificationBytes (2 bytes): An unsigned integer that specifies the password verification identifier. See Password Verifier Algorithm.\n }\n end" ]
[ "0.78090715", "0.74087214", "0.70919377", "0.70691013", "0.70683056", "0.69675136", "0.6938875", "0.69280326", "0.6831876", "0.67813385", "0.67658955", "0.6741339", "0.6735909", "0.6733082", "0.66798353", "0.6665799", "0.6617876", "0.6600136", "0.6588627", "0.6586253", "0.65484595", "0.6500449", "0.6499012", "0.6498103", "0.64617443", "0.64320153", "0.64257526", "0.64029753", "0.6394581", "0.6394544", "0.63836306", "0.6375892", "0.63703346", "0.634252", "0.6244218", "0.62267697", "0.62232876", "0.6218631", "0.6207882", "0.620751", "0.61877096", "0.6157485", "0.6147091", "0.61393577", "0.6108658", "0.6065643", "0.60606104", "0.6050158", "0.6047983", "0.6038993", "0.60348475", "0.59815913", "0.5975669", "0.59690297", "0.59654254", "0.5950681", "0.5940969", "0.59259206", "0.59158576", "0.5888461", "0.5886085", "0.5880856", "0.58662885", "0.5861772", "0.58586603", "0.5854526", "0.58435315", "0.5827936", "0.578955", "0.57803017", "0.57651126", "0.5757944", "0.5757889", "0.5749663", "0.5749033", "0.5741411", "0.57410353", "0.57361573", "0.570646", "0.56980777", "0.5688808", "0.56865567", "0.56843466", "0.56762713", "0.56671745", "0.5666584", "0.5659943", "0.5645281", "0.563054", "0.5624143", "0.56230557", "0.56119025", "0.56115484", "0.5610925", "0.5609634", "0.5607895", "0.5592448", "0.55876595", "0.5586146", "0.5574495" ]
0.80354226
0
, :only => [:index, :edit, :destroy] GET /polygons GET /polygons.json
def index @polygons = Polygon.paginate(:page => params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @polygons } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n # example output:\n # {\"layers\":[{\"id\":14,\"name\":\"coutries\",\"number_of_polygons\":279}]}\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n end\n end", "def show\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @polygon }\n end\n end", "def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @polygon = Polygon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @polygon }\n end\n end", "def index\n @geometries = Geometry.all\n end", "def index\n @geos = Geo.all\n end", "def destroy\n @polygon = Polygon.find(params[:id])\n @polygon.destroy\n\n respond_to do |format|\n format.html { redirect_to polygons_url }\n format.json { head :no_content }\n end\n end", "def index\n @post_geos = current_user.settings.post_geos || []\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @post_geos }\n end\n end", "def shape\n=begin\n\t\tgeometries = Rails.cache.fetch(MEMORY_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])) {\n\t\t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n=end\n\t\tkey = FILE_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])\n\t\tgeometries = JsonCache.fetch_shape(key) {\n \t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n\n respond_to do |format|\n format.json { render json: geometries }\n end\n end", "def index\n @positions = Position.all.order :id\n @geojson = Hash.new\n\n @points = Position.geopoints\n @geojson = {\n type: 'FeatureCollection',\n features: @points\n }\n\n respond_to do |format|\n format.html\n format.json { render json: @geojson } # respond with the created JSON object\n end\n end", "def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"new\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @educacao = Educacao.new\n @educacaos = Educacao.all\n @modal = true\n\n factory = RGeo::GeoJSON::EntityFactory.instance\n features = []\n @educacaos.each do |edu|\n feature = factory.feature(edu.the_geom, nil, {id: edu.id, nome: edu.nome, email: edu.email, contato: edu.contato})\n features << feature\n end\n\n json_edu = RGeo::GeoJSON.encode factory.feature_collection(features)\n\n respond_to do |format|\n format.html\n format.json { render :json => json_edu }\n format.xml { render :xml => @educacaos }\n end\n end", "def show\n @layer = Layer.find(params[:id])\n areas_json = @layer.areas.map do |area|\n {area_id: area.id, polygon: area.polygon}\n end\n @result = {id: @layer.id, name: @layer.name, number_of_polygons: @layer.areas.count, areas: areas_json }\n\n base_url = \"#{request.protocol}#{request.host_with_port}\"\n permalink_hash = PermalinkController.generate_json(base_url, 'layers/show', @layer, @tolerance)\n @permalink = permalink_hash[:url]\n @data_json = permalink_hash[:data_json]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:layer => @layer, :data_json => @data_json, :permalink => @permalink} }\n format.topojson { render json: @layer.to_topojson }\n end\n end", "def index\n @zones= Zone.all\n\n @polyjson = []\n schoolpoints = []\n @zones.each do |zone|\n CoordinateZone.where(:zone_id => zone.id).each do |point|\n schoolpoints << { :zone => point.zone_id, :lng => point.longitud, :lat => point.latitud}\n end\n end\n # puts \"********schoolpoints***********\"\n # puts schoolpoints.inspect\n\n @polyjson = schoolpoints\n @polyjson = @polyjson.to_json\n end", "def index\n @shape_types = ShapeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shape_types }\n end\n end", "def index\n @trips = Trip.order(params[:sort].to_s + \" \" + params[:direction].to_s)\n @tripLocation = Trip.pluck(:id)\n @markers = Marker.where(\"trip_id in (?)\", @tripLocation)\n @gmaps_options = @markers.to_gmaps4rails\n\n @polylines_json = {}\n polylines = []\n\n @trips.each_with_index do |trip, i|\n polylines[i] = []\n trip.markers.each do |marker|\n polylines[i] += [{:lng=>marker.longitude.to_f, :lat=>marker.latitude.to_f}]\n end\n end\n \n @polylines_json = polylines.to_json\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end", "def index\n @computer_geometries = ComputerGeometry.all\n end", "def index\n @shape_text = UniqueShapeName.for_profiles\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shape_text }\n end\n end", "def edit\n find_map\n respond_with @map, :include => :waypoints\n end", "def show\n @bemap = Bemap.find(params[:id])\n @bemap_polylines = []\n @bemap_characters = []\n @bemap.characters.each do |v|\n @bemap_characters << { :lng => v[:longitude], :lat => v[:latitude]}\n end\n @bemap_polylines << @bemap_characters\n @bemap_polylines = @bemap_polylines.to_json\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bemap }\n end\n end", "def regions\n @regions = Region.all\n\n render json: @regions.to_json(:include => :vertices)\n end", "def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end", "def matching_indices\n ids = RegionLethality.get_regions(params[:max])\n @provinces = Province.where(id: ids)\n\n respond_to do |format|\n format.json do\n feature_collection = Province.to_feature_collection @provinces\n render json: RGeo::GeoJSON.encode(feature_collection)\n end\n\n format.html\n end\n end", "def index \n respond_to do |format|\n format.html do\n authenticate_user!\n if params[:all] != \"true\"\n @trails = Trail.where(source: current_user.organization)\n else\n @trails = Trail.all\n end\n end\n format.json do\n @trails = Trail.all\n entity_factory = ::RGeo::GeoJSON::EntityFactory.instance\n features = []\n @trails.each do |trail|\n # taking a trip to Null Island, because RGeo::GeoJSON chokes on empty geometry here\n feature = entity_factory.feature(RGeo::Geographic.spherical_factory.point(0,0), trail.id, trail.attributes)\n features.push(feature)\n end\n collection = entity_factory.feature_collection(features)\n my_geojson = RGeo::GeoJSON::encode(collection)\n render json: Oj.dump(my_geojson)\n end\n end\n end", "def index\n @map_layers = MapLayer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @map_layers }\n end\n end", "def index\n @geopoints = Geopoint.all\n @jsons = @geopoints.to_gmaps4rails\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @geopoints }\n end\n end", "def update\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n if @polygon.update_attributes(params[:polygon])\n format.html { redirect_to @polygon, notice: 'Polygon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @polygon.errors, status: :unprocessable_entity }\n end\n end\n end", "def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end", "def index\n @layers = Layer.all\n end", "def index\n @areas = Area.with_ordered_countries\n respond_with(@areas)\n end", "def index\n @cat_polies = CatPoly.all\n end", "def index\n #@world_maps = WorldMap.all\n\n respond_to do |format|\n format.html # index.erb.erb\n format.json { render json: @world_maps }\n end\n end", "def geo_choice\r\n if !params[:root].blank?\r\n if params[:root].to_i == 0\r\n # 用户选了不限地域\r\n @geos = [{:name => \"不限地域\", :id => 0}]\r\n else\r\n @root = Geo.find(params[:root])\r\n if @root.children.size > 0\r\n @geos = @root.children.collect{|r| {:name => r.name, :id => r.id} }\r\n else\r\n @geos = [ {:name => @root.name, :id => @root.id} ]\r\n end\r\n end\r\n else\r\n @geos = Array.new\r\n end\r\n render :partial => \"/geos/geo_selector\", :locals => { :object => params[:object], :method => params[:method] }\r\n end", "def create\n @polygon = Polygon.new(params[:polygon])\n\n respond_to do |format|\n if @polygon.save\n format.html { redirect_to @polygon, notice: 'Polygon was successfully created.' }\n format.json { render json: @polygon, status: :created, location: @polygon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @polygon.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @organizations = Organization.order_by_most_recent\n @json = gmap4rails_with_popup_partial(@organizations,'popup')\n @category_options = Category.html_drop_down_options\n end", "def show\n @polygon_mark = PolygonMark.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @polygon_mark }\n end\n end", "def index\n @ubigeos = Ubigeo.all\n end", "def index\n @group_areas = GroupArea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @group_areas }\n end\n end", "def index\n @properties = Property.all\n @json = @properties.to_gmaps4rails\n end", "def show\n @county = Entity.where(id: params[:id]).where(entity_type: 'County').first\n respond_with(@county) do |format|\n format.geojson { render text: @county.to_geojson }\n end\n end", "def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\n end", "def index\n locations = @project.locations.all\n render json: { locations: locations }\n end", "def index\n @pc_regions = PcRegion.all\n @title = 'PC Regions'\n @context_menu = {'new' => new_pc_region_path}\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pc_regions }\n end\n end", "def index\n @ozones = Ozone.all\n render json: @ozones\n end", "def index\n @regiones = Region.all\n\n render json: @regiones\n end", "def index\n permits = Permit.select('id, permit_type, applicant_name, start_date, end_date, address, application_data, city_name, ST_AsGeoJSON(geometry) AS geojson')\n .where(\"city_name = ? AND geometry IS NOT NULL AND address IS NOT NULL\", params[:city].upcase.gsub(/-/, \" \"))\n if permits\n respond_to do |format|\n format.json { render json: permits }\n end\n else\n respond_to do |format|\n format.json { render json: [], status: :bad_request }\n end\n end\n end", "def index\n @places = Place.all\n render json: @places , status: 403\n end", "def index\n \t@posts = Post.all\n\n @geojson = Array.new\n users = User.all\n users.each do |user|\n @geojson << {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [user.longitude, user.latitude]\n },\n properties: {\n name: user.restaurant,\n address: user.address,\n :'marker-color' => '#00607d',\n :'marker-symbol' => 'circle',\n :'marker-size' => 'medium'\n }\n }\n end\n \n respond_to do |format|\n format.html\n format.json { render json: @geojson }\n end\n end", "def index\n @areas = Area.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @areas }\n format.json {render :json => @areas}\n end\n end", "def analysePolygon(geojson, data_sources = [\"protected_areas\"])\n self.query_area_km2 = 0\n self.query_area_carbon_kg = 0\n self.save\n\n #convert geojson to wkt\n wkt = GeomHelper.geojson_to_wkt geojson\n query = [{:id => self.id, :the_geom => wkt}].to_json\n\n data_sources.each { |source|\n case source\n when \"coral\"\n url = \"http://localhost:4567/marine_search/coral\"\n field_setter = \"query_area_coral_km2=\"\n when \"mangroves\"\n url = \"http://localhost:4567/marine_search/mangroves\"\n field_setter = \"query_area_mangrove_km2=\"\n when \"sea_grass\"\n url = \"\"\n field_setter = \"query_area_sea_grass_km2=\"\n else\n next\n end\n\n res = nil\n begin\n res = JSON.parse Net::HTTP.post_form(URI.parse(url),:data => query).body\n rescue\n next\n end\n next unless res\n if res.include? \"error\"\n msg = \"Error fetching data from #{source} data source: \" + res[\"error\"]\n puts msg\n logger.error msg\n next\n end\n\n val = 0\n res[\"results\"].each{|item|val += item[\"overlapped_area\"].to_f}\n self.send field_setter, val\n self.save\n }\n\n if data_sources.include?( \"protected_areas\" )\n ok = true\n begin\n # call API\n url = \"http://protectedplanet.net/api2/geo_searches\"\n res = Net::HTTP.post_form(URI.parse(url),:data => query).body\n res = JSON.parse res\n rescue\n ok = false\n end\n\n if ok\n # populate DB with results\n res[\"results\"].each do |item|\n # This will be returned multiple times, but... it seems to be the only way to get it, other than calculating\n # locally. (Would that be so bad?.)\n self.query_area_km2 = item[\"query_area_km2\"].to_f\n self.query_area_carbon_kg = item[\"query_area_carbon_kg\"].to_f\n self.save\n\n item[\"protected_areas\"].each do |s|\n #ds = s['data_standard']\n #wkt = ds[\"GEOM\"]\n site = Site.create :tenement_id => id,\n :wdpaid => s['wdpaid'],\n :image => s['image'],\n :encoded_polyline_cache => s['epl'],\n :data_standard => s['data_standard'],\n :protected_carbon_kg => s['protected_carbon_kg'],\n :protected_area_km2 => s['protected_area_km2'],\n :query_area_protected_km2 => s['query_area_protected_km2'],\n :query_area_protected_carbon_kg => s['query_area_protected_carbon_kg']\n sql = \"UPDATE sites SET the_geom=ST_GeomFromText('#{s['simple_geom']}') where id=#{site.id}\"\n Site.connection.execute sql\n end\n end\n end\n end\n end", "def index\n\n @coral = Coral.find(params[:coral_id])\n @observation = Observation.find(params[:observation_id])\n @area = Area.find(params[:area_id])\n\n @touches = @area.touches.find(params[:area_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @touches }\n end\n end", "def index\n @estates = Estate.all\n @json = @estates.to_gmaps4rails\n respond_with(@estates)\n \n end", "def index\n @leaves = Leaf.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leaves }\n end\n end", "def index\n @map = Map.find(params[:map_id])\n if @map.kind == \"activity\"\n @locations = @map.locations.activity\n elsif @map.kind == \"news\"\n @locations = @map.locations.news\n else\n @locations = @map.locations\n end\n respond_to do |format|\n format.json { render :json => @locations.as_json(:include => :location_pin)}\n end\n end", "def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @temples }\n format.js {}\n end\n end", "def show\n @layers = Layer.where(:soil_id => params[:id])\n respond_to do |format|\n\t redirect_to @layers\n format.json { render json: @layers }\n end\n end", "def render_index_mapview\n static_geojson_file_loc = \"#{Rails.root}/#{GEOJSON_STATIC_FILE['filepath']}\"\n if Rails.env.to_s == 'production' && params[:action] == 'map' && File.exist?(static_geojson_file_loc)\n geojson_for_map = File.open(static_geojson_file_loc).first\n else\n geojson_for_map = serialize_geojson(map_facet_values)\n end\n render partial: 'catalog/index_mapview',\n locals: { geojson_features: geojson_for_map }\n end", "def edit\n @countries = Countr.all\n @states = []\n @cities = []\n if params[:country].present? or params[:state].present?\n @states = Stat.where(:countr_id => params[:country] )\n @cities = City.where(:stat_id => params[:state] )\n end\n if request.xhr?\n respond_to do |format|\n format.json {\n render json: {states: @states} if params[:country].present?\n render json: {cities: @cities} if params[:state].present?\n }\n end\n end\n end", "def index\n @dog_polies = DogPoly.all\n end", "def index\n @drawables = Drawable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drawables }\n end\n end", "def index\n @areas_skills = AreasSkill.all\n end", "def show\n @survey_area = SurveyArea.find(params[:id])\n @survey_areas = Array.new\n @survey_areas.push(@survey_area)\n @json = @survey_area.survey_locations.to_gmaps4rails\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_area }\n end\n end", "def new\n @polygon_mark = PolygonMark.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @polygon_mark }\n end\n end", "def areas\n @area = Area.new(geo_json: params.to_json)\n if @area.save\n json_response([id: @area.id], :created, :geo_json_recieved)\n else\n json_response(nil, :error, :db_error)\n end\n end", "def index\n @apartment_geopoints = ApartmentGeopoint.all\n end", "def show\n @client = Client.find(params[:id])\n @pets = @client.pets\n @json = @client.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def index\n @maps = current_user.owned_maps\n respond_with @maps, :include => :waypoints\n end", "def index\n @zones = Zone.all\n\n render json: @zones\n end", "def index\n @positives = Positive.all\n @positives_json= Positive.all.map(&:lonlat).as_json\n\n\n\n\n\n end", "def index\n @region = Region.find_by_id params[:region_id]\n @locations = @region.locations.select(\"id,name,region_id\")\n\n respond_with @locations #Location.select(\"id,name\")\n end", "def index\n @areas = Area.all\n end", "def index\n @zones = Zone.all\n render json: @zones\n #@zones\n end", "def destroy\n @geometry.destroy\n respond_to do |format|\n format.html { redirect_to geometries_url }\n format.json { head :no_content }\n end\n end", "def show\n @map = Map.find_by_id(params[:id])\n @saved_locations = @map.points.for_editing.to_json\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @map }\n end\n end", "def index\n @regions = parent.regions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @regions }\n format.js\t { render :partial => 'list', :layout => false }\n end\n end", "def index\n authorize! :admin, Coordenador\n \n @coordenadores = Coordenador.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @coordenadores }\n end\n end", "def index\n @survey_areas = SurveyArea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @survey_areas }\n end\n end", "def geo\n\t\tciudad = params[:id]\n\t\t@ubication = City.where(id: ciudad)\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @ubication }\n\t\tend\n\tend", "def index\n @cities = City.all\n\n render json: @cities\n end", "def index\n areas = if current_user.moderator?\n ProductionArea.where.not(state: 0).eager_load(:map_layer)\n else\n current_user.production_areas.eager_load(:map_layer).with_translations(I18n.locale)\n end\n @cabinet_production_areas = areas\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def index\n get_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cities }\n format.js\n end\n end", "def government_map\n @departments = @city.departments.government\n render action: :department_map\n end", "def index\n @areas = Area.all\n @target_users = User.where(User.arel_table[:location].not_eq nil)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @areas }\n end\n end", "def show\n @post_geo = current_user.post_geos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post_geo }\n end\n end", "def map\n if params[:mapid] == 'index'\n map_data = []\n projects = Project.where(user_id: current_user.id)\n projects.each do |project|\n if project.coordinates\n project_hash = {\n path: project_path(project),\n title: project.title.titleize,\n date: DateCreator.stringify(project.date),\n coordinates: project.coordinates\n }\n map_data << project_hash\n end\n end\n respond_to do |format|\n format.json { render :json => map_data }\n end\n end\n end", "def index\n if params.has_key?(:longitude) and params.has_key?(:latitude) and params.has_key?(:area)\n @spots = SkateSpot.all\n\n # render :json => { :status => :success, :data => JSON.parse(render_to_string('index.json')) }\n render :json => \"{\\\"status\\\":\\\"success\\\",\\\"data\\\":#{render_to_string('index.json').presence || 'null'}}\"\n else\n render :json => { :status => :unprocessable_entity }\n end\n end", "def index\n render json: @places\n end", "def new\n @area = Area.new\n @other_areas = Area.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def spawn_polygons\n\n @args.state.vertices.polygons.each do |polygon|\n\n # If we have a path defined, find it in our polygon list and update locations\n if polygon.key?(:path)\n\n # Then we need to create a new one\n else\n\n # Spawn it, and save the path of it\n new_poly = RegularPolygon.new(args, 64, polygon[:vertices])\n polygon[:path] = new_poly.path\n\n # Finally add it to our internal list\n @polygons << new_poly\n\n end\n\n end\n\n end", "def index\n render json: Lobby.all.as_json( only: [:id, :name] )\n end", "def index\n # To restrict so only views you occupations, see omrails, Add Associations . . ., 33:00\n @occupations = Occupation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @occupations }\n end\n end", "def index\n authorize @model, :index?\n\n # @collection = @model.all\n\n render json: Oj.dump(\n collection: @model.all\n )\n end", "def index\n @representante_athletes = current_user.organization.athletes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @representante_athletes }\n end\n end", "def index\n @city_areas = CityArea.all\n end", "def index\n @estacionamientos = Estacionamiento.all\n\n @json = Estacionamiento.all.to_gmaps4rails\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @estacionamientos }\n end\n end", "def index\n @projections= Projection.all\nend", "def show\n @trip = Trip.find(params[:id])\n @markers = @trip.markers\n @gmaps_options = @markers.to_gmaps4rails\n\n @polylines_json = {}\n polylines = [] \n polylines[0] = []\n @trip.markers.each do |marker|\n polylines[0] += [{:lng=>marker.longitude.to_f, :lat=>marker.latitude.to_f}]\n end\n\n \n @polylines_json = polylines.to_json\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end", "def partial() \"single/geometryfield\" ; end", "def index\n #@businesses = Business.paginate(page: params[:page])\n @businesses = Business.all;\n ggeojson = []\n @businesses.each do |business|\n \t ggeojson << {\n \t\ttype: \"Feature\",\n \t\tgeometry: {\n \t\t\ttype: \"Point\",\n \t\t\tcoordinates: [ business.longitude, business.latitude]\n \t\t},\n \t\tproperties:{\n \t\t\ttitle: business.name,\n \t\t\tdescription: business.tagline,\n \t\t\t:'marker-color' => \"#00607d\",\n \t\t\t:'maker-symbol' => \"circle\",\n \t\t\t:'marker-size' => \"medium\"\n \t\t}\n \t} \n end\n @geojson = ggeojson\n end" ]
[ "0.66198695", "0.65930706", "0.63809395", "0.6252743", "0.62404734", "0.623194", "0.6194731", "0.6190393", "0.60708237", "0.60525334", "0.60468924", "0.60019475", "0.59400785", "0.5934293", "0.5897333", "0.587534", "0.58630836", "0.5847473", "0.5795676", "0.5791273", "0.57826614", "0.5778331", "0.5767839", "0.575642", "0.57547677", "0.5752822", "0.57332677", "0.5728561", "0.5728554", "0.57090235", "0.568729", "0.5684425", "0.5668804", "0.5661439", "0.5660313", "0.56422657", "0.5638417", "0.5626583", "0.561189", "0.5583285", "0.55787516", "0.55724066", "0.55575883", "0.55350524", "0.552656", "0.55238545", "0.5523501", "0.55182254", "0.55146563", "0.5505572", "0.5503564", "0.5503265", "0.55012405", "0.5488424", "0.54835427", "0.5476583", "0.54731596", "0.5463875", "0.54581934", "0.5454216", "0.5452147", "0.54496104", "0.5449144", "0.5446564", "0.54461163", "0.5445695", "0.5430487", "0.5422565", "0.5421974", "0.5418925", "0.5415592", "0.54152364", "0.54146165", "0.5410219", "0.5407298", "0.54070616", "0.540116", "0.53970814", "0.5386883", "0.5379426", "0.53793037", "0.5366369", "0.5364459", "0.53593326", "0.5358832", "0.53569597", "0.53565246", "0.53540605", "0.5350052", "0.5347588", "0.5346047", "0.5340713", "0.53250283", "0.5323398", "0.53232163", "0.53129697", "0.5312702", "0.5311244", "0.53025866", "0.53000736" ]
0.7244158
0
GET /polygons/1 GET /polygons/1.json
def show @polygon = Polygon.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @polygon } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @polygons = Polygon.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @polygons }\n end\n end", "def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n # example output:\n # {\"layers\":[{\"id\":14,\"name\":\"coutries\",\"number_of_polygons\":279}]}\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n end\n end", "def shape\n=begin\n\t\tgeometries = Rails.cache.fetch(MEMORY_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])) {\n\t\t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n=end\n\t\tkey = FILE_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])\n\t\tgeometries = JsonCache.fetch_shape(key) {\n \t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n\n respond_to do |format|\n format.json { render json: geometries }\n end\n end", "def show\n @layer = Layer.find(params[:id])\n areas_json = @layer.areas.map do |area|\n {area_id: area.id, polygon: area.polygon}\n end\n @result = {id: @layer.id, name: @layer.name, number_of_polygons: @layer.areas.count, areas: areas_json }\n\n base_url = \"#{request.protocol}#{request.host_with_port}\"\n permalink_hash = PermalinkController.generate_json(base_url, 'layers/show', @layer, @tolerance)\n @permalink = permalink_hash[:url]\n @data_json = permalink_hash[:data_json]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:layer => @layer, :data_json => @data_json, :permalink => @permalink} }\n format.topojson { render json: @layer.to_topojson }\n end\n end", "def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end", "def simple_poly tolerance=0.001, precision = 4, bbox = false \n self.class.find_simple_geojson self.id, tolerance, precision, bbox\n end", "def simple_poly tolerance=0.001, precision = 4, bbox = false \n self.class.find_simple_geojson self.id, tolerance, precision, bbox\n end", "def geo(id)\n get \"/geo/id/#{id}.json\"\n end", "def new\n @polygon = Polygon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @polygon }\n end\n end", "def show\n @bemap = Bemap.find(params[:id])\n @bemap_polylines = []\n @bemap_characters = []\n @bemap.characters.each do |v|\n @bemap_characters << { :lng => v[:longitude], :lat => v[:latitude]}\n end\n @bemap_polylines << @bemap_characters\n @bemap_polylines = @bemap_polylines.to_json\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bemap }\n end\n end", "def show\n @county = Entity.where(id: params[:id]).where(entity_type: 'County').first\n respond_with(@county) do |format|\n format.geojson { render text: @county.to_geojson }\n end\n end", "def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"new\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @positions = Position.all.order :id\n @geojson = Hash.new\n\n @points = Position.geopoints\n @geojson = {\n type: 'FeatureCollection',\n features: @points\n }\n\n respond_to do |format|\n format.html\n format.json { render json: @geojson } # respond with the created JSON object\n end\n end", "def index\n @zones= Zone.all\n\n @polyjson = []\n schoolpoints = []\n @zones.each do |zone|\n CoordinateZone.where(:zone_id => zone.id).each do |point|\n schoolpoints << { :zone => point.zone_id, :lng => point.longitud, :lat => point.latitud}\n end\n end\n # puts \"********schoolpoints***********\"\n # puts schoolpoints.inspect\n\n @polyjson = schoolpoints\n @polyjson = @polyjson.to_json\n end", "def destroy\n @polygon = Polygon.find(params[:id])\n @polygon.destroy\n\n respond_to do |format|\n format.html { redirect_to polygons_url }\n format.json { head :no_content }\n end\n end", "def index\n @trips = Trip.order(params[:sort].to_s + \" \" + params[:direction].to_s)\n @tripLocation = Trip.pluck(:id)\n @markers = Marker.where(\"trip_id in (?)\", @tripLocation)\n @gmaps_options = @markers.to_gmaps4rails\n\n @polylines_json = {}\n polylines = []\n\n @trips.each_with_index do |trip, i|\n polylines[i] = []\n trip.markers.each do |marker|\n polylines[i] += [{:lng=>marker.longitude.to_f, :lat=>marker.latitude.to_f}]\n end\n end\n \n @polylines_json = polylines.to_json\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end", "def show\n @polygon_mark = PolygonMark.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @polygon_mark }\n end\n end", "def index\n @geopoints = Geopoint.all\n @jsons = @geopoints.to_gmaps4rails\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @geopoints }\n end\n end", "def show\n @trip = Trip.find(params[:id])\n @markers = @trip.markers\n @gmaps_options = @markers.to_gmaps4rails\n\n @polylines_json = {}\n polylines = [] \n polylines[0] = []\n @trip.markers.each do |marker|\n polylines[0] += [{:lng=>marker.longitude.to_f, :lat=>marker.latitude.to_f}]\n end\n\n \n @polylines_json = polylines.to_json\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end", "def geo\n\t\tciudad = params[:id]\n\t\t@ubication = City.where(id: ciudad)\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @ubication }\n\t\tend\n\tend", "def points_query\n # request.path => \"/points/123,-74.006605,40.714623\"\n query = request.path.split(\"/\").last.split(\";\")\n points = query.inject([]) do |r, _|\n id, lon, lat = _.split(\",\")\n r << {:id => id, :lon => lon, :lat => lat}\n end\n\n tolerance = params[:tolerance].to_f if params[:tolerance].present?\n\n lon_lats = points.map{|point| [point[:lon], point[:lat]] }\n areas = Area.polygon_contains_points(points, tolerance)\n points_in_area = []\n areas.each do |area|\n points = area.filter_including_points(points)\n area_as_json = {\n :layer_id => area.layer_id,\n :area_id => area.id,\n :points => points,\n :pointsWithinCount => points.count\n }\n points_in_area << area_as_json\n end\n\n if params['idsonly'] && params['idsonly'] == 'true'\n points_in_area.each { |p| p.delete(:points) }\n end\n\n result = {\n :points_in_area => points_in_area\n }\n\n # points_in_area = (\n # {id => id, layer_id => layer_id, area_id => area_id, points => ( {id => id, x =>x, y =>y}, {id => id, x =>x, y =>y}, ...)},\n # {id => id, layer_id => layer_id, area_id => area_id, points => ( {id => id, x =>x, y =>y}, {id => id, x =>x, y =>y}, ...)}\n # )\n render :json => result\n end", "def index\n @geos = Geo.all\n end", "def geo_choice\r\n if !params[:root].blank?\r\n if params[:root].to_i == 0\r\n # 用户选了不限地域\r\n @geos = [{:name => \"不限地域\", :id => 0}]\r\n else\r\n @root = Geo.find(params[:root])\r\n if @root.children.size > 0\r\n @geos = @root.children.collect{|r| {:name => r.name, :id => r.id} }\r\n else\r\n @geos = [ {:name => @root.name, :id => @root.id} ]\r\n end\r\n end\r\n else\r\n @geos = Array.new\r\n end\r\n render :partial => \"/geos/geo_selector\", :locals => { :object => params[:object], :method => params[:method] }\r\n end", "def index\n @geometries = Geometry.all\n end", "def show\n @survey_area = SurveyArea.find(params[:id])\n @survey_areas = Array.new\n @survey_areas.push(@survey_area)\n @json = @survey_area.survey_locations.to_gmaps4rails\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_area }\n end\n end", "def points_in_layer\n # request.path => \"/points/123,-74.006605,40.714623\" or \"/points/123,-74.006605,40.714623.json\"\n json_match = request.path.match('.json')\n query = request.path.gsub('.json', '').split(\"/\").last.split(\";\")\n points = query.inject([]) do |r, _|\n id, lon, lat = _.split(\",\")\n r << {:id => id, :lon => lon, :lat => lat}\n end\n\n points_in_area = Area.contains_points_in_layer_json(params[:layer_id].to_i, points, @tolerance)\n\n if params['idsonly'] && params['idsonly'] == 'true'\n points_in_area.each { |p| p.delete(:points) }\n end\n\n result = {\n :points_in_area => points_in_area\n }\n\n @layer = Layer.find(params[:layer_id])\n @result = result\n\n base_url = \"#{request.protocol}#{request.host_with_port}\"\n permalink_hash = PermalinkController.generate_json(base_url, 'layers/points_in_layer', @layer, @tolerance, @result)\n @permalink = permalink_hash[:url]\n @data_json = permalink_hash[:data_json]\n\n\n if json_match\n render json: @result\n else\n render 'points_in_layer'\n end\n end", "def analysePolygon(geojson, data_sources = [\"protected_areas\"])\n self.query_area_km2 = 0\n self.query_area_carbon_kg = 0\n self.save\n\n #convert geojson to wkt\n wkt = GeomHelper.geojson_to_wkt geojson\n query = [{:id => self.id, :the_geom => wkt}].to_json\n\n data_sources.each { |source|\n case source\n when \"coral\"\n url = \"http://localhost:4567/marine_search/coral\"\n field_setter = \"query_area_coral_km2=\"\n when \"mangroves\"\n url = \"http://localhost:4567/marine_search/mangroves\"\n field_setter = \"query_area_mangrove_km2=\"\n when \"sea_grass\"\n url = \"\"\n field_setter = \"query_area_sea_grass_km2=\"\n else\n next\n end\n\n res = nil\n begin\n res = JSON.parse Net::HTTP.post_form(URI.parse(url),:data => query).body\n rescue\n next\n end\n next unless res\n if res.include? \"error\"\n msg = \"Error fetching data from #{source} data source: \" + res[\"error\"]\n puts msg\n logger.error msg\n next\n end\n\n val = 0\n res[\"results\"].each{|item|val += item[\"overlapped_area\"].to_f}\n self.send field_setter, val\n self.save\n }\n\n if data_sources.include?( \"protected_areas\" )\n ok = true\n begin\n # call API\n url = \"http://protectedplanet.net/api2/geo_searches\"\n res = Net::HTTP.post_form(URI.parse(url),:data => query).body\n res = JSON.parse res\n rescue\n ok = false\n end\n\n if ok\n # populate DB with results\n res[\"results\"].each do |item|\n # This will be returned multiple times, but... it seems to be the only way to get it, other than calculating\n # locally. (Would that be so bad?.)\n self.query_area_km2 = item[\"query_area_km2\"].to_f\n self.query_area_carbon_kg = item[\"query_area_carbon_kg\"].to_f\n self.save\n\n item[\"protected_areas\"].each do |s|\n #ds = s['data_standard']\n #wkt = ds[\"GEOM\"]\n site = Site.create :tenement_id => id,\n :wdpaid => s['wdpaid'],\n :image => s['image'],\n :encoded_polyline_cache => s['epl'],\n :data_standard => s['data_standard'],\n :protected_carbon_kg => s['protected_carbon_kg'],\n :protected_area_km2 => s['protected_area_km2'],\n :query_area_protected_km2 => s['query_area_protected_km2'],\n :query_area_protected_carbon_kg => s['query_area_protected_carbon_kg']\n sql = \"UPDATE sites SET the_geom=ST_GeomFromText('#{s['simple_geom']}') where id=#{site.id}\"\n Site.connection.execute sql\n end\n end\n end\n end\n end", "def show\n @client = Client.find(params[:id])\n @pets = @client.pets\n @json = @client.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def index\n @shape_types = ShapeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shape_types }\n end\n end", "def show\n recorrido = Recorrido.find(params[:id].to_i)\n @polylines = []\n @stops = []\n # @shapes = Shape.all\n secuencias = recorrido.get_secuencias_of_the_hour\n\n secuencias.each_with_index do |s, i|\n @polylines[i] = []\n Shape.where(:code => s.code).first.points.each_with_index do |p, e|\n e == 0 ? @polylines[i] << {:strokeColor => '#000000', :icons => [], :lat => p.lat, :lng => p.lng } : @polylines[i] << {:lat => p.lat, :lng => p.lng }\n end\n s.stops.each do |stop|\n @stops << {:title => stop.code,\n :lat => stop.lat,\n :lng => stop.lng,\n :width => 12,\n :height => 14,\n :picture => \"../images/parada_12.png\", :type => 'stop',\n :type => 'stop',\n :ida => i,\n :description => render_to_string(:partial => \"/recorridos/stop_infowindow\", :locals => { :stop => stop})}\n end\n end\n\n\n respond_to do |format|\n format.js\n format.html\n format.json { render json: @recorrido }\n end\n end", "def index\n @post_geos = current_user.settings.post_geos || []\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @post_geos }\n end\n end", "def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\n end", "def create\n @polygon = Polygon.new(params[:polygon])\n\n respond_to do |format|\n if @polygon.save\n format.html { redirect_to @polygon, notice: 'Polygon was successfully created.' }\n format.json { render json: @polygon, status: :created, location: @polygon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @polygon.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @geopoint = Geopoint.find(params[:id])\n @json = @geopoint.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @geopoint }\n end\n end", "def spawn_polygons\n\n @args.state.vertices.polygons.each do |polygon|\n\n # If we have a path defined, find it in our polygon list and update locations\n if polygon.key?(:path)\n\n # Then we need to create a new one\n else\n\n # Spawn it, and save the path of it\n new_poly = RegularPolygon.new(args, 64, polygon[:vertices])\n polygon[:path] = new_poly.path\n\n # Finally add it to our internal list\n @polygons << new_poly\n\n end\n\n end\n\n end", "def search_coord_route\n sql_results = Route.select(\"ST_AsGeoJSON(path) as path\")\n .where(\"cod_route = ?\", \"#{params[:id]}\").to_sql\n\n resp = ActiveRecord::Base.connection.execute(sql_results).map do |value|\n ActiveSupport::JSON.decode(value[\"path\"])[\"coordinates\"]\n end\n render json: resp\n end", "def index\n @shape_text = UniqueShapeName.for_profiles\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shape_text }\n end\n end", "def polygon\n respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : []\n end", "def bounding_box_geojson\n return nil unless bounding_box\n {\n type: \"Polygon\",\n coordinates: [\n [\n [swlng.to_f, swlat.to_f],\n [swlng.to_f, nelat.to_f],\n [nelng.to_f, nelat.to_f],\n [nelng.to_f, swlat.to_f],\n [swlng.to_f, swlat.to_f]\n ]\n ]\n }\n end", "def update\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n if @polygon.update_attributes(params[:polygon])\n format.html { redirect_to @polygon, notice: 'Polygon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @polygon.errors, status: :unprocessable_entity }\n end\n end\n end", "def regions\n @regions = Region.all\n\n render json: @regions.to_json(:include => :vertices)\n end", "def index\n locations = @project.locations.all\n render json: { locations: locations }\n end", "def index\n @countries = Country.all\n\n render json: @countries\n end", "def index\n @zones = Zone.all\n\n render json: @zones\n end", "def get_json_from_openstreetmaps(key,val,constrain_to_usa = true)\n timeout = 20000\n bounds = \"#{CONTINENTAL_US[:s]},#{CONTINENTAL_US[:w]},#{CONTINENTAL_US[:n]},#{CONTINENTAL_US[:e]}\"\n bounds_string = constrain_to_usa ? \"(#{bounds})\" : \"\"\n\n #This string fetches all geometry of a way including center points, but does not restrict how many ways to download\n #str = \"data=[out:json][timeout:#{timeout}];way[\\\"#{key}\\\"=\\\"#{val}\\\"](#{bounds_string});foreach((._;>;);out center #{NUMBER_TO_DOWNLOAD};);\"\n\n #This string fetches almost all geometry of a way except for center points. Does restrict number to download. \n str = \"data=[out:json][timeout:#{timeout}][maxsize:1073741824];way[\\\"#{key}\\\"=\\\"#{val}\\\"]#{bounds_string};out count;out meta geom #{NUMBER_TO_DOWNLOAD};\"\n\n print str\n base_url = \"http://overpass-api.de/api/interpreter?\"\n url = \"#{base_url}#{URI.escape(str)}\"\n puts url\n response = Typhoeus.get(url, {followlocation: true, timeout: timeout})\n response.body\nend", "def index\n render json: @places\n end", "def index\n @areas = Area.with_ordered_countries\n respond_with(@areas)\n end", "def show\n @layers = Layer.where(:soil_id => params[:id])\n respond_to do |format|\n\t redirect_to @layers\n format.json { render json: @layers }\n end\n end", "def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html { render layout: false }\n format.json\n format.geojson\n end\n end", "def index\n @ozones = Ozone.all\n render json: @ozones\n end", "def matching_indices\n ids = RegionLethality.get_regions(params[:max])\n @provinces = Province.where(id: ids)\n\n respond_to do |format|\n format.json do\n feature_collection = Province.to_feature_collection @provinces\n render json: RGeo::GeoJSON.encode(feature_collection)\n end\n\n format.html\n end\n end", "def asigna_pixi_geojson\n file = File.read(Rails.root.join('public', 'topojson', \"#{tipo.estandariza}.geojson\"))\n json = JSON.parse(file)\n json[region_id.to_s]\n end", "def show\n @admin_geonode = Admin::Geonode.find(params[:id])\n @json = @admin_geonode.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_geonode }\n end\n end", "def index\n @educacao = Educacao.new\n @educacaos = Educacao.all\n @modal = true\n\n factory = RGeo::GeoJSON::EntityFactory.instance\n features = []\n @educacaos.each do |edu|\n feature = factory.feature(edu.the_geom, nil, {id: edu.id, nome: edu.nome, email: edu.email, contato: edu.contato})\n features << feature\n end\n\n json_edu = RGeo::GeoJSON.encode factory.feature_collection(features)\n\n respond_to do |format|\n format.html\n format.json { render :json => json_edu }\n format.xml { render :xml => @educacaos }\n end\n end", "def index \n respond_to do |format|\n format.html do\n authenticate_user!\n if params[:all] != \"true\"\n @trails = Trail.where(source: current_user.organization)\n else\n @trails = Trail.all\n end\n end\n format.json do\n @trails = Trail.all\n entity_factory = ::RGeo::GeoJSON::EntityFactory.instance\n features = []\n @trails.each do |trail|\n # taking a trip to Null Island, because RGeo::GeoJSON chokes on empty geometry here\n feature = entity_factory.feature(RGeo::Geographic.spherical_factory.point(0,0), trail.id, trail.attributes)\n features.push(feature)\n end\n collection = entity_factory.feature_collection(features)\n my_geojson = RGeo::GeoJSON::encode(collection)\n render json: Oj.dump(my_geojson)\n end\n end\n end", "def index\n #@world_maps = WorldMap.all\n\n respond_to do |format|\n format.html # index.erb.erb\n format.json { render json: @world_maps }\n end\n end", "def drawn_georeferences\n message = ''\n value = params['gr_geographic_item_attributes_shape']\n if value.blank?\n @georeferences = Georeference.where('false')\n else\n feature = RGeo::GeoJSON.decode(value, json_parser: :json)\n # isolate the WKT\n geometry = feature.geometry\n this_type = geometry.geometry_type.to_s.downcase\n geometry = geometry.as_text\n\n radius = feature['radius']\n case this_type\n when 'point'\n @georeferences = Georeference.with_project_id(sessions_current_project_id)\n .joins(:geographic_item)\n .where(GeographicItem.intersecting_radius_of_wkt_sql(geometry, radius)) # TODO: likely want within_radius_of_wkt_sql\n when 'polygon'\n @georeferences = Georeference.with_project_id(sessions_current_project_id)\n .joins(:geographic_item)\n .where(GeographicItem.contained_by_wkt_sql(geometry))\n else\n end\n if @georeferences.blank?\n message = 'no objects contained in drawn shape'\n end\n render_gr_select_json(message)\n end\n end", "def map\n respond_to do |format|\n format.html do\n @constituency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup').first\n\n @json_location = constituency_map_path(@constituency.graph_id, format: 'json')\n end\n\n format.json do\n @constituency = Parliament::Utils::Helpers::RequestHelper.filter_response_data(\n Parliament::Utils::Helpers::ParliamentHelper.parliament_request.constituency_map.set_url_params({ constituency_id: params[:constituency_id] }),\n Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('ConstituencyGroup')\n ).first\n\n raise ActionController::RoutingError, 'Not Found' unless @constituency.current?\n\n render json: GeosparqlToGeojson.convert_to_geojson(\n geosparql_values: @constituency.area.polygon,\n geosparql_properties: {\n name: @constituency.name,\n start_date: @constituency.start_date,\n end_date: @constituency.end_date\n },\n reverse: false\n ).geojson\n end\n end\n end", "def index\n @zones = Zone.all\n render json: @zones\n #@zones\n end", "def areas_json\n @json = {}\n @json[:id] = self.id\n @json[:country] = self.name\n @json[:country_lat] = self.lat\n @json[:country_lon] = self.lon\n\n @json[:iccas] = []\n self.sites.each do |site|\n site_details = {}\n site_details[:name] = site.name\n site_details[:url] = \"/sites/\" + site.id.to_s\n site_details[:lat] = site.lat\n site_details[:lng] = site.lon\n @json[:iccas] << site_details\n end\n return @json\n end", "def index\n @computer_geometries = ComputerGeometry.all\n end", "def index\n @properties = Property.all\n @json = @properties.to_gmaps4rails\n end", "def map\n respond_to do |format|\n format.html do\n @constituency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup').first\n\n @json_location = constituency_map_path(@constituency.graph_id, format: 'json')\n end\n\n format.json do\n @constituency = Parliament::Utils::Helpers::RequestHelper.filter_response_data(\n Parliament::Utils::Helpers::ParliamentHelper.parliament_request.constituency_map.set_url_params({ constituency_id: params[:constituency_id] }),\n Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('ConstituencyGroup')\n ).first\n\n raise ActionController::RoutingError, 'Not Found' unless @constituency.current?\n\n render json: GeosparqlToGeojson.convert_to_geojson(\n geosparql_values: @constituency.area.polygon,\n geosparql_properties: {\n name: @constituency.name,\n start_date: @constituency.start_date,\n end_date: @constituency.end_date\n },\n reverse: false\n ).geojson\n end\n end\n end", "def map\n @data = {}\n\n sheet = Sheet.where(:map_id => params[:map_id]).first\n\n if sheet != nil\n @data[:sheet] = sheet\n @data[:layer] = sheet.layer\n polys = sheet.polygons\n @data[:polygons] = polys.count\n @data[:addresses] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"address\").count\n @data[:colors] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"color\").count\n @data[:fixes] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"polygonfix\").count\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {\n render json: @data\n }\n end\n end", "def show\n @post_geo = current_user.post_geos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post_geo }\n end\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def to_geojson\n coordinates = @points.map { |point| [point.longitude, point.lattitude] }\n { 'type' => 'Polygon', 'coordinates' => [coordinates] }.to_json\n end", "def show\n @shape_type = ShapeType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shape_type }\n end\n end", "def max_polygons\n max = \"\\0\" * SIZEOF_INT\n FMOD.invoke(:Geometry_GetMaxPolygons, self, max, nil)\n max.unpack1('l')\n end", "def index\n @map_layers = MapLayer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @map_layers }\n end\n end", "def geo(place_id)\n get \"/geo/id/#{place_id}.json\"\n end", "def areas\n @area = Area.new(geo_json: params.to_json)\n if @area.save\n json_response([id: @area.id], :created, :geo_json_recieved)\n else\n json_response(nil, :error, :db_error)\n end\n end", "def index\n \t@posts = Post.all\n\n @geojson = Array.new\n users = User.all\n users.each do |user|\n @geojson << {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [user.longitude, user.latitude]\n },\n properties: {\n name: user.restaurant,\n address: user.address,\n :'marker-color' => '#00607d',\n :'marker-symbol' => 'circle',\n :'marker-size' => 'medium'\n }\n }\n end\n \n respond_to do |format|\n format.html\n format.json { render json: @geojson }\n end\n end", "def notes_geojson\n\t \t{ 'type' => 'FeatureCollection', \n\t \t 'features' => aw.notes_geo \n\t \t}\n\t \tend", "def get_fences(*args)\n\tfences = @@vars['access_token'].request(:get, \"/api/v3/geo_fences\", HEADERS)\n\tresult = nil\n\tif args.length > 0\n\t\taux = JSON[fences.body][args[0]]\n\t\tfor i in aux['shapes']\n\t\t\ti['points'] = []\n\t\tend\n\t\tresult = [aux.to_json]\n\n\telse\n\t\tresult = fences.body\n\tend\n\n\treturn result\nend", "def new\n @polygon_mark = PolygonMark.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @polygon_mark }\n end\n end", "def polygon(options={},&block)\n set RGhost::Polygon.new(options,&block)\n end", "def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @temples }\n format.js {}\n end\n end", "def points\n object.polygon.points\n end", "def show\n render json: @ozones\n end", "def sample_polygon\n polygon(200, [[10.0, 10.0], [180.0, 20.0], [160.0, 150.0], [100.0, 50.0], [20.0,180.0]])\nend", "def index\n #@businesses = Business.paginate(page: params[:page])\n @businesses = Business.all;\n ggeojson = []\n @businesses.each do |business|\n \t ggeojson << {\n \t\ttype: \"Feature\",\n \t\tgeometry: {\n \t\t\ttype: \"Point\",\n \t\t\tcoordinates: [ business.longitude, business.latitude]\n \t\t},\n \t\tproperties:{\n \t\t\ttitle: business.name,\n \t\t\tdescription: business.tagline,\n \t\t\t:'marker-color' => \"#00607d\",\n \t\t\t:'maker-symbol' => \"circle\",\n \t\t\t:'marker-size' => \"medium\"\n \t\t}\n \t} \n end\n @geojson = ggeojson\n end", "def index\n if params[:x1]\n @places = Place.by_bounds( params[:x1], params[:y1], params[:x2], params[:y2], params )\n end\n #@places = Place.without_nodes\n respond_with(@places)\n end", "def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end", "def country_api\n # endpoint = \"https://corona.lmao.ninja/countries\"\n endpoint = 'https://corona.lmao.ninja/v2/countries'\n response = HTTParty.get(endpoint)\n data = JSON.parse response.body\n res = data\n result =[]\n endpoint_all = \"https://corona.lmao.ninja/all\"\n response1 = HTTParty.get(endpoint_all)\n data1 = JSON.parse response1.body\n res1 = data1\n result<<{\n country: \"world\",\n cases: res1[\"cases\"],\n todayCases: res1[\"todayCases\"],\n deaths: res1[\"deaths\"],\n todayDeaths: res1[\"todayDeaths\"],\n recovered: res1[\"recovered\"],\n active: res1[\"active\"],\n critical: res1[\"critical\"],\n casesPerOneMillion: res1[\"casesPerOneMillion\"],\n deathsPerOneMillion: res1[\"deathsPerOneMillion\"],\n tests: res1[\"tests\"],\n testsPerOneMillion: res1[\"testsPerOneMillion\"],\n affectedCountries: res1[\"affectedCountries\"]\n }\n\n res.each do |country|\n result<<{\n country: country[\"country\"],\n lat: country[\"countryInfo\"][\"lat\"],\n long: country[\"countryInfo\"][\"long\"],\n flag: country[\"countryInfo\"][\"flag\"],\n cases: country[\"cases\"],\n todayCases: country[\"todayCases\"],\n deaths: country[\"deaths\"],\n todayDeaths: country[\"todayDeaths\"],\n recovered: country[\"recovered\"],\n active: country[\"active\"],\n critical: country[\"critical\"],\n casesPerOneMillion: country[\"casesPerOneMillion\"],\n deathsPerOneMillion: country[\"deathsPerOneMillion\"],\n tests: country[\"tests\"],\n testsPerOneMillion: country[\"testsPerOneMillion\"]\n }\n end\n render json: result\n end", "def index\n @ubigeos = Ubigeo.all\n end", "def show\n if user_id_params\n @geopoints = Geopoint.all.where(user_id: @user_id)\n render json: @geopoints\n else\n #not found\n render json: \"empty_error\", status: 423\n end\nend", "def get_feature_collection(params)\n http = Net::HTTP.new(@city_db_url, @port)\n http.read_timeout = 1000\n if @city_db_is_https\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n request = Net::HTTP::Post.new('/api/search.json')\n request.add_field('Content-Type', 'application/json')\n request.add_field('Accept', 'application/json')\n request.body = JSON.generate(params)\n request.basic_auth(ENV['URBANOPT_USERNAME'], ENV['URBANOPT_PASSWORD'])\n\n response = http.request(request)\n if response.code != '200' # success\n @runner.registerError(\"Bad response #{response.code}\")\n @runner.registerError(response.body)\n return {}\n end\n\n return JSON.parse(response.body, symbolize_names: true)\n end", "def index\n @estacionamientos = Estacionamiento.all\n\n @json = Estacionamiento.all.to_gmaps4rails\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @estacionamientos }\n end\n end", "def index\n @map = Map.find(params[:map_id])\n if @map.kind == \"activity\"\n @locations = @map.locations.activity\n elsif @map.kind == \"news\"\n @locations = @map.locations.news\n else\n @locations = @map.locations\n end\n respond_to do |format|\n format.json { render :json => @locations.as_json(:include => :location_pin)}\n end\n end", "def show\n @outdoor = Outdoor.find(params[:id])\n @json = Outdoor.find(params[:id]).to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @outdoor }\n end\n end", "def create_polylines\n if @itinerary.legs.nil?\n return []\n end\n\n polylines = []\n @itinerary.legs.each_with_index do |leg, index|\n polylines << {\n \"id\" => index,\n \"geom\" => leg['legGeometry'].nil? ? [] : leg['legGeometry'],\n \"options\" => get_leg_display_options(leg)\n }\n end\n\n return polylines\n end", "def index\n @group_areas = GroupArea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @group_areas }\n end\n end", "def index\n @places = Place.all\n render json: { places: @places }, methods: [:reviews, :visit_ids, :image_url_large]\n # render json: @places, methods: :reviews # return a place object not a places object as above\n end", "def show\n @loja = Loja.find(params[:id])\n\n\n\n @json = Loja.find(params[:id]).to_gmaps4rails\n @loja_concorrencia = LojaConcorrencium.all\n @outdoors = Outdoor.all\n @local_desportivo = LocalDesportivo.all\n\n @todos = Outdoor.all + Loja.all + Outro.all + LocalDesportivo.all + LojaConcorrencium.all\n\n @json = @todos.to_gmaps4rails\n\n @zone2 = Loja.first.latitude\n @zone1 = Loja.first.longitude\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @loja }\n end\n end", "def index\n @profiles = Profile.page(params[:page]).order(:updated_at => 'DESC')\n @json = @profiles.to_gmaps4rails\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @profiles }\n end\n end", "def index\n @drawables = Drawable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drawables }\n end\n end", "def show\n @taxon = Taxon.find(params[:id])\n @layers = @taxon.layers.page(page).per(25)\n @geo_contexts = @taxon.geo_contexts.page(page).per(25)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxon }\n end\n end", "def index\n @estates = Estate.all\n @json = @estates.to_gmaps4rails\n respond_with(@estates)\n \n end" ]
[ "0.7352029", "0.6623201", "0.6446067", "0.6316232", "0.6227232", "0.6203522", "0.61881876", "0.61881876", "0.6172934", "0.6171902", "0.6166581", "0.613502", "0.6070721", "0.59961194", "0.5974895", "0.59604883", "0.5848663", "0.584651", "0.5775503", "0.5707606", "0.5692639", "0.56714445", "0.566599", "0.5651481", "0.5634661", "0.56328565", "0.5623193", "0.560389", "0.558481", "0.5565373", "0.5564868", "0.5560154", "0.5526029", "0.5498434", "0.5485595", "0.5473228", "0.5467537", "0.5451299", "0.54478526", "0.54385394", "0.5421563", "0.5417103", "0.5399985", "0.5394388", "0.5387657", "0.5385397", "0.5384956", "0.53826755", "0.5380689", "0.5380403", "0.5366392", "0.5364084", "0.5350774", "0.53412396", "0.53396916", "0.53284425", "0.53279656", "0.53251994", "0.53047067", "0.52999574", "0.52977365", "0.52949417", "0.5289565", "0.52887505", "0.5277734", "0.5269978", "0.52699363", "0.52689296", "0.5267992", "0.5266743", "0.5262581", "0.5260416", "0.52545214", "0.52502453", "0.5248832", "0.5240746", "0.52350414", "0.5227319", "0.5222738", "0.521077", "0.52018964", "0.5200591", "0.52002406", "0.519408", "0.5183856", "0.5177611", "0.5166969", "0.516684", "0.5161813", "0.51600236", "0.51572245", "0.5156923", "0.5156802", "0.51545095", "0.51484627", "0.5148234", "0.5141424", "0.51391125", "0.5137254", "0.51293695" ]
0.6875102
1
GET /polygons/new GET /polygons/new.json
def new @polygon = Polygon.new respond_to do |format| format.html # new.html.erb format.json { render json: @polygon } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"new\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @polygon = Polygon.new(params[:polygon])\n\n respond_to do |format|\n if @polygon.save\n format.html { redirect_to @polygon, notice: 'Polygon was successfully created.' }\n format.json { render json: @polygon, status: :created, location: @polygon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @polygon.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @polygon_mark = PolygonMark.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @polygon_mark }\n end\n end", "def new\n @layer = Layer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @layer }\n end\n end", "def new\n @map = Map.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end", "def create\n @cat_poly = CatPoly.new(cat_poly_params)\n\n respond_to do |format|\n if @cat_poly.save\n format.html { redirect_to @cat_poly, notice: 'Cat poly was successfully created.' }\n format.json { render :show, status: :created, location: @cat_poly }\n else\n format.html { render :new }\n format.json { render json: @cat_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def spawn_polygons\n\n @args.state.vertices.polygons.each do |polygon|\n\n # If we have a path defined, find it in our polygon list and update locations\n if polygon.key?(:path)\n\n # Then we need to create a new one\n else\n\n # Spawn it, and save the path of it\n new_poly = RegularPolygon.new(args, 64, polygon[:vertices])\n polygon[:path] = new_poly.path\n\n # Finally add it to our internal list\n @polygons << new_poly\n\n end\n\n end\n\n end", "def new\n @area = Area.new\n @other_areas = Area.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def index\n @polygons = Polygon.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @polygons }\n end\n end", "def new\n @area = Area.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def new\n @area = Area.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def new\n @overlay = Overlay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @overlay }\n end\n end", "def new\n @smallmap = Smallmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @smallmap }\n end\n end", "def new\n @geopoint = Geopoint.new\n @lat = 13.7522222\n @lng = 100.4938889\n @json = '[{\"lng\": \"100.4938889\", \"lat\": \"13.7522222\"}]'\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @geopoint }\n end\n end", "def new\n @locationmap = Locationmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @locationmap }\n end\n end", "def new\n @map = current_user.maps.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end", "def new\n place = Place.new\n\n render json: place\n end", "def new\n @gmap = Gmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gmap }\n end\n end", "def new\n @county = County.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @county }\n end\n end", "def new\n @select_markers = return_markers\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end", "def new\n @tinymap = Tinymap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tinymap }\n end\n end", "def new\n @post_geo = current_user.post_geos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post_geo }\n end\n end", "def new\n @area_type = AreaType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area_type }\n end\n end", "def new\n @outdoor = Outdoor.new\n @json = Outdoor.new(params[:id]).to_gmaps4rails\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @outdoor }\n end\n end", "def create\n @polygon_mark = PolygonMark.new(:name => params[:name], :layer_id => params[:layer_id])\n \n respond_to do |format|\n if @polygon_mark.save\n @polygon_mark.the_geom = Polygon.from_coordinates([params[:coordinates]], 4269)\n @polygon_mark.save!\n format.html { redirect_to @polygon_mark, :notice => 'polygon mark was successfully created.' }\n format.json { render :json => @polygon_mark, :status => :created, :location => @polygon_mark }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @polygon_mark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @puzzle = Puzzle.new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puzzle }\n end\n end", "def new\n @group_map = GroupMap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group_map }\n end\n end", "def new\n @lot = Lot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lot }\n end\n end", "def new\n @drawing = Drawing.new\n\n render json: @drawing\n end", "def create\n @dog_poly = DogPoly.new(dog_poly_params)\n\n respond_to do |format|\n if @dog_poly.save\n format.html { redirect_to @dog_poly, notice: 'Dog poly was successfully created.' }\n format.json { render :show, status: :created, location: @dog_poly }\n else\n format.html { render :new }\n format.json { render json: @dog_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @admin_geonode = Admin::Geonode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_geonode }\n end\n end", "def new\n @path = Path.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @path }\n end\n end", "def new\n @mini_map_road = MiniMapRoad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mini_map_road }\n end\n end", "def new\n @patch = Patch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patch }\n end\n end", "def new\n @dimgeom = Dimgeom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dimgeom }\n end\n end", "def new\n @loja = Loja.new\n @json = Loja.new(params[:id]).to_gmaps4rails\n\n contacto = @loja.contactos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loja }\n end\n end", "def new\n @map_node = Map::Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map_node }\n end\n end", "def new\n @attribute_layer = AttributeLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attribute_layer }\n end\n end", "def new\n @location_url_map = LocationUrlMap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_url_map }\n end\n end", "def new\n @map = Map.find(params[:map_id])\n\n #@node = Node.new\n @node = @map.nodes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @node }\n end\n end", "def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end", "def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end", "def new\n @country_area = CountryArea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @country_area }\n end\n end", "def new\n @location = Location.new\n @json = @location.to_gmaps4rails\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def areas\n @area = Area.new(geo_json: params.to_json)\n if @area.save\n json_response([id: @area.id], :created, :geo_json_recieved)\n else\n json_response(nil, :error, :db_error)\n end\n end", "def new\n @breadcrumb = 'create'\n @area = Area.new\n @departments = departments_dropdown\n @workers = workers_dropdown\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def new\n @region = Region.new\n @object = [Division.first, @region]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @region }\n end\n end", "def new\n @mosttinymap = Mosttinymap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mosttinymap }\n end\n end", "def new\n @gpath = Gpath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gpath }\n end\n end", "def new\n @zone = Zone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zone }\n end\n end", "def new\n do_new_resource\n get_project_if_exists\n do_set_attributes\n do_authorize_instance\n\n # initialize lat/lng to Brisbane-ish\n @site.longitude = 152\n @site.latitude = -27\n respond_to do |format|\n format.html\n format.json { respond_new }\n end\n end", "def new\n #TODO\n @map = Map.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map }\n end\n end", "def new\n @point = Point.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @point }\n end\n end", "def new\n @collection_point = CollectionPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection_point }\n end\n end", "def new\n @shape_type = ShapeType.new\n # create the translation object for however many locales there are\n # so the form will properly create all of the nested form fields\n I18n.available_locales.each do |locale|\n\t\t\t@shape_type.shape_type_translations.build(:locale => locale)\n\t\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shape_type }\n end\n end", "def new\n @map = Map.new\n @map.user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end", "def new\n\t @location = Location.new\n\t @months = Month.all\n\t @countries = Location.all.map(&:country).uniq\n\n\t respond_to do |format|\n\t format.html # new.html.erb\n\t format.json { render json: @location }\n\t end\n\t end", "def new\n @point = Point.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @point }\n end\n end", "def show\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @polygon }\n end\n end", "def new\n @moretinymap = Moretinymap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @moretinymap }\n end\n end", "def new\n @map_layer = MapLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map_layer }\n end\n end", "def new\n @island = Island.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @island }\n end\n end", "def new\n @droparea = Droparea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @droparea }\n end\n end", "def new\n @criterion = Criterion.new\n render json: @criterion\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 @location_point = LocationPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_point }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end", "def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end", "def new\n @poi = Poi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poi }\n end\n end", "def new\n @road = Road.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @road }\n end\n end", "def new\n @japan_style = JapanStyle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @japan_style }\n end\n end", "def new\n @map = Map.new\n\n puts @saved_locations\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map }\n end\n end", "def new\n @coordinate = Coordinate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coordinate }\n end\n end", "def new\n @poi_type = PoiType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poi_type }\n end\n end", "def new\n @region = Region.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @region }\n end\n end", "def new\n @zona = Zona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zona }\n end\n end", "def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @researcharea = Researcharea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @researcharea }\n end\n end", "def new\n @locality = Locality.new\n @provinces = Province.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @locality }\n end\n end", "def new\n @clonet = Clonet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clonet }\n end\n end", "def create\n\n has = params[\"area\"].to_json\n data_has = JSON.parse(has)\n @zone = Zone.new();\n @zone.nombre_zona = params[\"nombre_zona\"]\n @zone.color = params[\"color\"]\n\n respond_to do |format|\n if @zone.save\n \n data_has.each do |geo|\n @coordenada = CoordinateZone.new()\n geo.each do |data|\n @coordenada.zone_id = @zone.id\n @coordenada.latitud = data[\"lat\"].to_f\n @coordenada.longitud = data[\"lng\"].to_f \n end\n @coordenada.save\n end\n\n format.html { redirect_to @zone, notice: 'Zone was successfully created.' }\n format.js \n # format.js { render js: \"window.location.href=#{ directories_path }\" }\n format.json { render :show, status: :created, location: @zone }\n \n else\n format.html { render :new }\n format.json { render json: @zone.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def new\n @glossary = Glossary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @glossary }\n end\n end", "def new\n @group_area = GroupArea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group_area }\n end\n end", "def new\n @draw = Draw.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @draw }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @toy_zone = ToyZone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @toy_zone }\n end\n end", "def new\n @gl = Gl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gl }\n end\n end", "def new\n @ridol = Ridol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ridol }\n end\n end", "def new\n @pointcode = Pointcode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pointcode }\n end\n end", "def new\n @spawner = Spawner.new\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spawner }\n end\n end", "def new\n @spatial_coverage = SpatialCoverage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spatial_coverage}\n end\n end", "def new\n @chef_mapping = ChefMapping.new\n @source = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chef_mapping }\n end\n end", "def new\n puts 'NEW METHOD'\n @pessoa = Pessoa.new\n @pessoa.enderecos.build\n 2.times { @pessoa.telefones.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pessoa }\n end\n end" ]
[ "0.6858009", "0.6700113", "0.66460365", "0.638145", "0.63777155", "0.6344747", "0.63346094", "0.6304163", "0.62628907", "0.62494093", "0.62494093", "0.62275547", "0.6196464", "0.61795276", "0.61472434", "0.6117554", "0.60944206", "0.6083274", "0.60822314", "0.60618806", "0.6049868", "0.6044826", "0.5985717", "0.59808946", "0.596254", "0.5939617", "0.59374034", "0.5935333", "0.59336364", "0.5932403", "0.5932008", "0.5914156", "0.5903156", "0.59014136", "0.5882864", "0.5882727", "0.58822614", "0.58809674", "0.58757776", "0.5874399", "0.5864067", "0.5864067", "0.58580023", "0.5855444", "0.5831258", "0.5830123", "0.58293813", "0.5825423", "0.58225435", "0.58221865", "0.58195215", "0.578856", "0.5785629", "0.5780859", "0.57762843", "0.57731575", "0.57720286", "0.57668215", "0.57662636", "0.5764782", "0.57565296", "0.57467645", "0.5737482", "0.57236636", "0.5719115", "0.5713217", "0.57118577", "0.57118577", "0.57118577", "0.57118577", "0.57118577", "0.57101846", "0.57065487", "0.57026577", "0.5697959", "0.5689758", "0.56891984", "0.56887114", "0.56845975", "0.56833726", "0.5675806", "0.5675614", "0.56730944", "0.5670404", "0.56598777", "0.565797", "0.56544936", "0.5642224", "0.5642224", "0.5642224", "0.5642224", "0.5642224", "0.56400657", "0.56391716", "0.5638568", "0.5636379", "0.56353223", "0.56322175", "0.5630037", "0.56299365" ]
0.7595767
0
POST /polygons POST /polygons.json
def create @polygon = Polygon.new(params[:polygon]) respond_to do |format| if @polygon.save format.html { redirect_to @polygon, notice: 'Polygon was successfully created.' } format.json { render json: @polygon, status: :created, location: @polygon } else format.html { render action: "new" } format.json { render json: @polygon.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"new\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cat_poly = CatPoly.new(cat_poly_params)\n\n respond_to do |format|\n if @cat_poly.save\n format.html { redirect_to @cat_poly, notice: 'Cat poly was successfully created.' }\n format.json { render :show, status: :created, location: @cat_poly }\n else\n format.html { render :new }\n format.json { render json: @cat_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @polygon_mark = PolygonMark.new(:name => params[:name], :layer_id => params[:layer_id])\n \n respond_to do |format|\n if @polygon_mark.save\n @polygon_mark.the_geom = Polygon.from_coordinates([params[:coordinates]], 4269)\n @polygon_mark.save!\n format.html { redirect_to @polygon_mark, :notice => 'polygon mark was successfully created.' }\n format.json { render :json => @polygon_mark, :status => :created, :location => @polygon_mark }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @polygon_mark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @dog_poly = DogPoly.new(dog_poly_params)\n\n respond_to do |format|\n if @dog_poly.save\n format.html { redirect_to @dog_poly, notice: 'Dog poly was successfully created.' }\n format.json { render :show, status: :created, location: @dog_poly }\n else\n format.html { render :new }\n format.json { render json: @dog_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n has = params[\"area\"].to_json\n data_has = JSON.parse(has)\n @zone = Zone.new();\n @zone.nombre_zona = params[\"nombre_zona\"]\n @zone.color = params[\"color\"]\n\n respond_to do |format|\n if @zone.save\n \n data_has.each do |geo|\n @coordenada = CoordinateZone.new()\n geo.each do |data|\n @coordenada.zone_id = @zone.id\n @coordenada.latitud = data[\"lat\"].to_f\n @coordenada.longitud = data[\"lng\"].to_f \n end\n @coordenada.save\n end\n\n format.html { redirect_to @zone, notice: 'Zone was successfully created.' }\n format.js \n # format.js { render js: \"window.location.href=#{ directories_path }\" }\n format.json { render :show, status: :created, location: @zone }\n \n else\n format.html { render :new }\n format.json { render json: @zone.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def areas\n @area = Area.new(geo_json: params.to_json)\n if @area.save\n json_response([id: @area.id], :created, :geo_json_recieved)\n else\n json_response(nil, :error, :db_error)\n end\n end", "def index\n @polygons = Polygon.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @polygons }\n end\n end", "def new\n @polygon = Polygon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @polygon }\n end\n end", "def spawn_polygons\n\n @args.state.vertices.polygons.each do |polygon|\n\n # If we have a path defined, find it in our polygon list and update locations\n if polygon.key?(:path)\n\n # Then we need to create a new one\n else\n\n # Spawn it, and save the path of it\n new_poly = RegularPolygon.new(args, 64, polygon[:vertices])\n polygon[:path] = new_poly.path\n\n # Finally add it to our internal list\n @polygons << new_poly\n\n end\n\n end\n\n end", "def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @polygon = Polygon.find(params[:id])\n @polygon.destroy\n\n respond_to do |format|\n format.html { redirect_to polygons_url }\n format.json { head :no_content }\n end\n end", "def create\n @post_geos = params[:post_geos].split(\"\\n\").map{|line| line.blank? ? nil : line.strip}.compact\n current_user.settings.post_geos = @post_geos\n\n respond_to do |format|\n format.html { redirect_to [:client,:post_geos], notice: 'Post category was successfully created.' }\n format.json { render json: @post_geo, status: :created, location: @post_geo }\n end\n end", "def cat_poly_params\n params.require(:cat_poly).permit(:dog_poly, :fish_poly)\n end", "def analysePolygon(geojson, data_sources = [\"protected_areas\"])\n self.query_area_km2 = 0\n self.query_area_carbon_kg = 0\n self.save\n\n #convert geojson to wkt\n wkt = GeomHelper.geojson_to_wkt geojson\n query = [{:id => self.id, :the_geom => wkt}].to_json\n\n data_sources.each { |source|\n case source\n when \"coral\"\n url = \"http://localhost:4567/marine_search/coral\"\n field_setter = \"query_area_coral_km2=\"\n when \"mangroves\"\n url = \"http://localhost:4567/marine_search/mangroves\"\n field_setter = \"query_area_mangrove_km2=\"\n when \"sea_grass\"\n url = \"\"\n field_setter = \"query_area_sea_grass_km2=\"\n else\n next\n end\n\n res = nil\n begin\n res = JSON.parse Net::HTTP.post_form(URI.parse(url),:data => query).body\n rescue\n next\n end\n next unless res\n if res.include? \"error\"\n msg = \"Error fetching data from #{source} data source: \" + res[\"error\"]\n puts msg\n logger.error msg\n next\n end\n\n val = 0\n res[\"results\"].each{|item|val += item[\"overlapped_area\"].to_f}\n self.send field_setter, val\n self.save\n }\n\n if data_sources.include?( \"protected_areas\" )\n ok = true\n begin\n # call API\n url = \"http://protectedplanet.net/api2/geo_searches\"\n res = Net::HTTP.post_form(URI.parse(url),:data => query).body\n res = JSON.parse res\n rescue\n ok = false\n end\n\n if ok\n # populate DB with results\n res[\"results\"].each do |item|\n # This will be returned multiple times, but... it seems to be the only way to get it, other than calculating\n # locally. (Would that be so bad?.)\n self.query_area_km2 = item[\"query_area_km2\"].to_f\n self.query_area_carbon_kg = item[\"query_area_carbon_kg\"].to_f\n self.save\n\n item[\"protected_areas\"].each do |s|\n #ds = s['data_standard']\n #wkt = ds[\"GEOM\"]\n site = Site.create :tenement_id => id,\n :wdpaid => s['wdpaid'],\n :image => s['image'],\n :encoded_polyline_cache => s['epl'],\n :data_standard => s['data_standard'],\n :protected_carbon_kg => s['protected_carbon_kg'],\n :protected_area_km2 => s['protected_area_km2'],\n :query_area_protected_km2 => s['query_area_protected_km2'],\n :query_area_protected_carbon_kg => s['query_area_protected_carbon_kg']\n sql = \"UPDATE sites SET the_geom=ST_GeomFromText('#{s['simple_geom']}') where id=#{site.id}\"\n Site.connection.execute sql\n end\n end\n end\n end\n end", "def create\n @floor = Floor.new(floor_params)\n\n respond_to do |format|\n if @floor.save\n editorData = @floor.editor_data\n editorData = editorData.split(\"<END>\").map{|i| i.split(\"<NEXT>\")}\n editorData.each do |obj|\n if obj[0] == 'submain'\n object = Room.new(name: obj[1],\n description: obj[2],\n capacity: obj[3],\n computers: obj[4],\n roomtype_id: Roomtype.all.where(id: obj[5].to_i)[0],\n floor_id: @floor.id)\n object.save\n elsif obj[0] == 'main'\n object = @floor\n end\n polygon = Polygon.new(imageable: object)\n polygon.save\n points = obj[6].split(\" \").map{|i| i.split(\",\")}\n for i in 0 ... points.size\n point = Point.create(ox: points[i][0].to_f,\n oy: points[i][1].to_f,\n priority: i,\n polygon: polygon\n )\n point.save\n end\n end\n\n format.html { redirect_to @floor, notice: t('flash.floor.create') }\n format.json { render :show, status: :created, location: @floor }\n else\n format.html { render :new }\n format.json { render json: @floor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n if @polygon.update_attributes(params[:polygon])\n format.html { redirect_to @polygon, notice: 'Polygon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @polygon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @campus = Campus.new(campus_params)\n\n respond_to do |format|\n if @campus.save\n # создание ассоциативных полигонов и точек с данным кампусом:\n # editorData = params['editorData']\n # editorData = editorData.map{ |i| i.split(' ').map{ |j| j.split(',') } }\n # editorData.each do |obj|\n # # type: editorData[i][-1].delete_at(-1).to_i\n #\n # if (obj[-1][-1].to_i == 1)\n # polygon = Polygon.new(imageable: @campus)\n # polygon.save\n # for i in 0 ... obj.size\n # point = Point.create(ox: obj[i][0].to_f,\n # oy: obj[i][1].to_f,\n # priority: i,\n # polygon: polygon\n # )\n # point.save\n # end\n # elsif(obj[-1][-1].to_i == 2)\n # building = Building.new(name: \"dfef\",\n # address: \"fgfggeg\",\n # description: \"wwfwfwf\",\n # campus_id: @campus.id)\n # building.save\n # polygon = Polygon.new(imageable: building)\n # polygon.save\n # for i in 0 ... obj.size\n # point = Point.create(ox: obj[i][0].to_f,\n # oy: obj[i][1].to_f,\n # priority: i,\n # polygon: polygon\n # )\n # point.save\n # end\n # end\n\n # создание ассоциативного с этим кампусом полигона:\n # polygon = Polygon.new(imageable: @campus)\n # polygon.save\n # for i in 0 ... obj.size\n # point = Point.create(ox: obj[i][0].to_f,\n # oy: obj[i][1].to_f,\n # priority: i,\n # polygon: polygon\n # )\n # point.save\n # end\n # end\n\n format.html { redirect_to campuses_path, notice: t('flash.campus.create') }\n format.json { render :show, status: :created, location: @campus }\n else\n format.html { render :new }\n format.json { render json: @campus.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @zones= Zone.all\n\n @polyjson = []\n schoolpoints = []\n @zones.each do |zone|\n CoordinateZone.where(:zone_id => zone.id).each do |point|\n schoolpoints << { :zone => point.zone_id, :lng => point.longitud, :lat => point.latitud}\n end\n end\n # puts \"********schoolpoints***********\"\n # puts schoolpoints.inspect\n\n @polyjson = schoolpoints\n @polyjson = @polyjson.to_json\n end", "def geographic_item_params\n params.require(:geographic_item).permit(:point, :line_string, :polygon, :multi_point, :multi_line_string, :multi_polygon, :geometry_collection, :created_by_id, :updated_by_id)\n end", "def create\n @location = Geolocation.new(params[:geolocation])\n @scene = Scene.new(:title => params[:title])\n @location.scenes << @scene\n @location.save\n @scene.save\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully create.'}\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\"}\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def dog_poly_params\n params[:dog_poly]\n end", "def create\n @note_features = request.parameters['_json'].map do |n|\n note = NoteFeature.new(n)\n note.save\n end\n # @note_features.each(&:save)\n render json: @note_features\n end", "def bounding_box_geojson\n return nil unless bounding_box\n {\n type: \"Polygon\",\n coordinates: [\n [\n [swlng.to_f, swlat.to_f],\n [swlng.to_f, nelat.to_f],\n [nelng.to_f, nelat.to_f],\n [nelng.to_f, swlat.to_f],\n [swlng.to_f, swlat.to_f]\n ]\n ]\n }\n end", "def poligon_params\n params.require(:poligon).permit(:coords, :name, :url, :year, :area_id, :color)\n end", "def test_is_polygon_with_polygon\n m = Sketchup.active_model\n ents = m.entities\n\n # Create a polygon\n center = [0, 0, 0]\n normal = [0, 0, 1]\n radius = 20\n nsides = 8\n ents.add_ngon center, normal, radius, nsides\n\n # Check poly edges\n m.entities.each do |e|\n if e.is_a? Sketchup::Edge and e.curve.respond_to? 'is_polygon?'\n assert_equal(true, e.curve.is_polygon?,\n 'Curve of polygon edge should be polygon.')\n end\n end\n end", "def create\n #return render json: params[:recursos]\n @area = Area.new(area_params)\n @count = 0\n save_multiples_recursos if params[:recursos][:status] == '1'\n respond_to do |format|\n if @area.save\n format.html { redirect_to areas_path, notice: 'El Área fue creada éxitosamente.' }\n format.json { render :show, status: :created, location: @area }\n else\n format.html { render :new }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def polygon(options={},&block)\n set RGhost::Polygon.new(options,&block)\n end", "def _update!\n self.class.repository_or_fail.createPolygon self\n end", "def create\n if geo_params\n point = @user.geopoints.build\n point[:lat] = @geopoint[:lat]\n point[:lon] = @geopoint[:lon]\n point[:battery] = @geopoint[:battery]\n point[:time] = @geopoint[:time]\n if point.save\n @user.update(lat: point[:lat], lon: point[:lon], time: point[:time])\n #geopoint saved successfuly\n render json: \"ok\", status: 200\n else\n #validate error\n render json: \"validate_error\", status: 422\n end\n else\n #NotFound user\n render json: \"empty_error\", status: 423\n end\nend", "def create\n @geo = Geo.new(geo_params)\n\n respond_to do |format|\n if @geo.save\n format.html { redirect_to @geo, notice: 'Geo was successfully created.' }\n format.json { render :show, status: :created, location: @geo }\n else\n format.html { render :new }\n format.json { render json: @geo.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @trips = Trip.order(params[:sort].to_s + \" \" + params[:direction].to_s)\n @tripLocation = Trip.pluck(:id)\n @markers = Marker.where(\"trip_id in (?)\", @tripLocation)\n @gmaps_options = @markers.to_gmaps4rails\n\n @polylines_json = {}\n polylines = []\n\n @trips.each_with_index do |trip, i|\n polylines[i] = []\n trip.markers.each do |marker|\n polylines[i] += [{:lng=>marker.longitude.to_f, :lat=>marker.latitude.to_f}]\n end\n end\n \n @polylines_json = polylines.to_json\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end", "def new\n @post_geo = current_user.post_geos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post_geo }\n end\n end", "def create\n map = Map.new;\n map.user_id = session[:user]['id']\n map.name = params['name']\n map.map_json = params['map_json']\n\n if map.save\n render json: {save: true, message: 'zapisano poprawnie mapę', callback: 'map'}\n else\n render json: {save: false, message: 'błąd podczas zapisu mapy', callback: 'map'}\n end\n end", "def points_query\n # request.path => \"/points/123,-74.006605,40.714623\"\n query = request.path.split(\"/\").last.split(\";\")\n points = query.inject([]) do |r, _|\n id, lon, lat = _.split(\",\")\n r << {:id => id, :lon => lon, :lat => lat}\n end\n\n tolerance = params[:tolerance].to_f if params[:tolerance].present?\n\n lon_lats = points.map{|point| [point[:lon], point[:lat]] }\n areas = Area.polygon_contains_points(points, tolerance)\n points_in_area = []\n areas.each do |area|\n points = area.filter_including_points(points)\n area_as_json = {\n :layer_id => area.layer_id,\n :area_id => area.id,\n :points => points,\n :pointsWithinCount => points.count\n }\n points_in_area << area_as_json\n end\n\n if params['idsonly'] && params['idsonly'] == 'true'\n points_in_area.each { |p| p.delete(:points) }\n end\n\n result = {\n :points_in_area => points_in_area\n }\n\n # points_in_area = (\n # {id => id, layer_id => layer_id, area_id => area_id, points => ( {id => id, x =>x, y =>y}, {id => id, x =>x, y =>y}, ...)},\n # {id => id, layer_id => layer_id, area_id => area_id, points => ( {id => id, x =>x, y =>y}, {id => id, x =>x, y =>y}, ...)}\n # )\n render :json => result\n end", "def edit_draw_polygon_with_http_info(request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: EditApi.edit_draw_polygon ...'\n end\n # verify the required parameter 'request' is set\n if @api_client.config.client_side_validation && request.nil?\n fail ArgumentError, \"Missing the required parameter 'request' when calling EditApi.edit_draw_polygon\"\n end\n # resource path\n local_var_path = '/image/edit/draw/polygon'\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/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(request)\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EditApi#edit_draw_polygon\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def to_geojson\n coordinates = @points.map { |point| [point.longitude, point.lattitude] }\n { 'type' => 'Polygon', 'coordinates' => [coordinates] }.to_json\n end", "def genShapeJson()\n shape = [] ;\n @shape.pointList.each{|point|\n pos = [point.x, point.y] ;\n shape.push(pos) ;\n }\n return shape ;\n end", "def add_polygon(options)\n polygon = Google::OptionsHelper.to_polygon(options)\n \n self.add_overlay polygon\n polygon.added_to_map self\n \n unless polygon.encoded?\n self.extend_track_bounds polygon.vertices\n end\n \n polygon\n end", "def create\n @fish_poly = FishPoly.new(fish_poly_params)\n\n respond_to do |format|\n if @fish_poly.save\n format.html { redirect_to @fish_poly, notice: 'Fish poly was successfully created.' }\n format.json { render :show, status: :created, location: @fish_poly }\n else\n format.html { render :new }\n format.json { render json: @fish_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def sample_polygon\n polygon(200, [[10.0, 10.0], [180.0, 20.0], [160.0, 150.0], [100.0, 50.0], [20.0,180.0]])\nend", "def update\n @polygon_mark = PolygonMark.find(params[:id])\n \n respond_to do |format|\n if @polygon_mark.update_attributes(:name => params[:name], :layer_id => params[:layer_id])\n @polygon_mark.the_geom = Polygon.from_coordinates(params[:coordinates], 4269)\n @polygon_mark.save!\n format.html { redirect_to @polygon_mark, :notice => 'polygon mark was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @polygon_mark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def shape\n=begin\n\t\tgeometries = Rails.cache.fetch(MEMORY_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])) {\n\t\t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n=end\n\t\tkey = FILE_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])\n\t\tgeometries = JsonCache.fetch_shape(key) {\n \t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n\n respond_to do |format|\n format.json { render json: geometries }\n end\n end", "def create\n @location = Location.new(params[:location])\n @location.save \n @hide_map = true\n if params[:subcategories] \n params[:subcategories].uniq.each do |subcategory| \n s = Subcategory.where(id: subcategory[:id]).first\n @location.subcategories << s if s\n end\n end\n respond_to do |format|\n if @location.valid?\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n data = []\n trace_params.each do |p|\n hash = {\n latitude: p[\"latitude\"],\n longitude: p[\"longitude\"]\n }\n data << hash\n end\n\n if Trace.upload_data(data)\n render json: {status: 'OK'}\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end", "def create\n @geo_datum = GeoDatum.new(geo_datum_params)\n\n respond_to do |format|\n if @geo_datum.save\n format.html { redirect_to @geo_datum, notice: 'Geo datum was successfully created.' }\n format.json { render :show, status: :created, location: @geo_datum }\n else\n format.html { render :new }\n format.json { render json: @geo_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_regions\n shapefile = create_shapefile\n shapefile_job = ShapefileJob.new(shapefile.data.path, shapefile.id)\n shapefile_job.perform\n Region.all\nend", "def create\n @filter = Filter.new(params[:filter])\n @area = Area.where(name: @filter.area).first\n @filter.polygon = @area.points\n\n @filter.name = \"#{@area.name} Listings\"\n\n respond_to do |format|\n if @filter.save\n format.html { redirect_to @filter, notice: 'Filter was successfully created.' }\n format.json { render json: @filter, status: :created, location: @filter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_create_table\n layer = create_poly_layer(@shape_ds)\n poly_feat = populate_poly_layer(layer)\n check_poly_layer(layer, poly_feat)\n end", "def create\n @idea = current_member.ideas.new(idea_params) \n respond_to do |format|\n sectors_params.delete(\"\")\n if @idea.save\n sectors_params.each do |k|\n @idea.sectors << Sector.find_by(id:k)\n end\n format.json { head :no_content }\n format.js\n else\n\n format.json { render :json => { :error => @idea.errors.full_messages }, :status => 422 }\n end\n \n end\n end", "def build_polygons_definition(p_hexagons)\n hexagons_source = p_hexagons.split(',')\n polygons = Array.new\n hexagons = Array.new\n hexagons_source.each { |h| hexagons << h.to_i}\n\n until hexagons.empty?\n polygon = Hash.new\n enveloppe = Array.new\n connections = Array.new\n node_stack = Array.new [hexagons.first]\n \n until node_stack.empty?\n connection_string = \"\"\n current_node = node_stack.pop\n enveloppe << current_node \n hexagons.delete(current_node)\n\n EDGES.each do |direction|\n adjacent_hexagon = adjacent(current_node, direction)\n\n if adjacent_hexagon == -1 then\n connection_string << \"0\"\n else \n if hexagons_source.include?(adjacent_hexagon.to_s) then\n connection_string << \"1\"\n node_stack << adjacent_hexagon unless node_stack.include?(adjacent_hexagon) or enveloppe.include?(adjacent_hexagon) \n else\n connection_string << \"0\"\n end \n end\n end \n \n connections << connection_string\n end\n\n polygon[:enveloppe] = enveloppe\n polygon[:connections] = connections\n polygons << polygon\n end \n\n return polygons \n end", "def geojson(fields)\n geojson = Array.new\n fields.each do |field|\n geojson << {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [field.longitude, field.latitude]\n },\n properties: {\n id: field.id,\n name: field.name,\n address: print_field(field),\n :'marker-color' => '#00607d',\n :'marker-symbol' => 'circle',\n :'marker-size' => 'medium',\n title: \"<a href=#{field_url(field)} data-no-turbolink><b>#{field.name}</b></a>\",\n description: print_field(field)\n }\n }\n end\n geojson\n end", "def post_page_polygon_annotations_with_http_info(name, page_number, annotations, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.post_page_polygon_annotations ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.post_page_polygon_annotations\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.post_page_polygon_annotations\"\n end\n # verify the required parameter 'annotations' is set\n if @api_client.config.client_side_validation && annotations.nil?\n fail ArgumentError, \"Missing the required parameter 'annotations' when calling PdfApi.post_page_polygon_annotations\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/annotations/polygon\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n post_body = @api_client.object_to_http_body(annotations)\n auth_names = ['JWT']\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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#post_page_polygon_annotations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @positions = Position.all.order :id\n @geojson = Hash.new\n\n @points = Position.geopoints\n @geojson = {\n type: 'FeatureCollection',\n features: @points\n }\n\n respond_to do |format|\n format.html\n format.json { render json: @geojson } # respond with the created JSON object\n end\n end", "def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @polygon_mark = PolygonMark.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @polygon_mark }\n end\n end", "def create\n @geopoint = Geopoint.new(params[:geopoint])\n\n respond_to do |format|\n if @geopoint.save\n format.html { redirect_to @geopoint, notice: 'Geopoint was successfully created.' }\n format.json { render json: @geopoint, status: :created, location: @geopoint }\n else\n format.html { render action: \"new\" }\n format.json { render json: @geopoint.errors, status: :unprocessable_entity }\n end\n end\n end", "def postgis_polygon_format(coordinates)\n ordinates = 'POLYGON (('\n ordinates += coordinates.gsub(\"0.0\", \" \").gsub(\",-\",\" -\").gsub(/, $/, \")\")\n ordinates += ')'\n end", "def create\n @shape_type = ShapeType.new(params[:shape_type])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeType.find(params[:parent_shape])\n\n respond_to do |format|\n\t\t\tif parent.nil?\n format.html { render action: \"new\" }\n format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t\telse\n\t\t\t\t# add the new shape type to the parent\n\t\t if parent.children.create(params[:shape_type])\n\t\t\t\t\tmsg = I18n.t('app.msgs.success_created', :obj => I18n.t('app.common.shape_type'))\n\t\t\t\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n\t\t format.html { redirect_to admin_shape_type_path(@shape_type), notice: msg }\n\t\t format.json { render json: @shape_type, status: :created, location: @shape_type }\n\t\t else\n\t\t format.html { render action: \"new\" }\n\t\t format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t end\n\t end\n end\n end", "def index\n @post_geos = current_user.settings.post_geos || []\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @post_geos }\n end\n end", "def map\n @data = {}\n\n sheet = Sheet.where(:map_id => params[:map_id]).first\n\n if sheet != nil\n @data[:sheet] = sheet\n @data[:layer] = sheet.layer\n polys = sheet.polygons\n @data[:polygons] = polys.count\n @data[:addresses] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"address\").count\n @data[:colors] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"color\").count\n @data[:fixes] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"polygonfix\").count\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {\n render json: @data\n }\n end\n end", "def update\n geos = params[:post_geos].split(\"\\n\").map{|line| line.blank? ? nil : line.strip}.compact\n current_user.settings.post_geos = geos\n\n respond_to do |format|\n format.html { redirect_to client_post_geos_path, notice: 'Post geos was successfully updated.' }\n format.json { head :no_content }\n end\n end", "def create\n @survey_area = SurveyArea.new(params[:survey_area])\n\n respond_to do |format|\n if @survey_area.save\n format.html { redirect_to @survey_area, notice: 'Survey area was successfully created.' }\n format.json { render json: @survey_area, status: :created, location: @survey_area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @drawing = Drawing.new(params[:drawing])\n\n if @drawing.save\n render json: @drawing, status: :created, location: @drawing\n else\n render json: @drawing.errors, status: :unprocessable_entity\n end\n end", "def create\n @map = Map.new(params[:map])\n @map.name = \"Map Created #{Time.now.strftime('at %I:%M%p')}\" if @map.name.blank?\n @map.description = \"No Description Provided\" if @map.description.blank?\n if points = params['markers']\n points.each do |marker_identifier, point|\n @map.points.build(:lat => point['lat'].to_f,:lng => point['lng'].to_f,:description =>point['description'], :marker_identifier => marker_identifier)\n end\n end\n respond_to do |format|\n if @map.save\n format.html { redirect_to(@map, :notice => 'Map was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create_regions bracket_json\n region_array = bracket_json[\"game_and_pick_list\"][\"regions\"]\n region_array.each do |region|\n Region.create({name: region['name']})\n end\n end", "def create\n @area = Area.new(area_params)\n @area.skus = params[:area][:skus]\n respond_to do |format|\n if @area.save\n format.html { redirect_to admin_areas_path, notice: 'Area was successfully created.' }\n format.json { render :show, status: :created, location: @area }\n else\n format.html { render :new }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_polylines\n if @itinerary.legs.nil?\n return []\n end\n\n polylines = []\n @itinerary.legs.each_with_index do |leg, index|\n polylines << {\n \"id\" => index,\n \"geom\" => leg['legGeometry'].nil? ? [] : leg['legGeometry'],\n \"options\" => get_leg_display_options(leg)\n }\n end\n\n return polylines\n end", "def create\n @mouth_shape = MouthShape.new(mouth_shape_params)\n\n respond_to do |format|\n if @mouth_shape.save\n format.html { redirect_to @mouth_shape, notice: 'La Forma de Boca ha sido creada exitosamente.' }\n format.json { render :show, status: :created, location: @mouth_shape }\n else\n flash[:danger] = \"No se ha podido Procesar la Operacion\"\n format.html { render :new }\n format.json { render json: @mouth_shape.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cat_poly.update(cat_poly_params)\n format.html { redirect_to @cat_poly, notice: 'Cat poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @cat_poly }\n else\n format.html { render :edit }\n format.json { render json: @cat_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @bemap = Bemap.find(params[:id])\n @bemap_polylines = []\n @bemap_characters = []\n @bemap.characters.each do |v|\n @bemap_characters << { :lng => v[:longitude], :lat => v[:latitude]}\n end\n @bemap_polylines << @bemap_characters\n @bemap_polylines = @bemap_polylines.to_json\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bemap }\n end\n end", "def validate_empty_map\n result = Array.new\n unless params[:cities].nil?\n params[:cities].each do |city_name|\n city = City.find_by_name( city_name )\n result.push({\n :title => city.name,\n :size => 10,\n :coord => [city.lon, city.lat]})\n end\n end\n render :json => result.to_json\n end", "def postLocation( location_id, type, country, language, name, formal_name, resolution, population, description, timezone, latitude, longitude, parent_town, parent_county, parent_province, parent_region, parent_neighbourhood, parent_district, postalcode, searchable_id, searchable_ids)\n params = Hash.new\n params['location_id'] = location_id\n params['type'] = type\n params['country'] = country\n params['language'] = language\n params['name'] = name\n params['formal_name'] = formal_name\n params['resolution'] = resolution\n params['population'] = population\n params['description'] = description\n params['timezone'] = timezone\n params['latitude'] = latitude\n params['longitude'] = longitude\n params['parent_town'] = parent_town\n params['parent_county'] = parent_county\n params['parent_province'] = parent_province\n params['parent_region'] = parent_region\n params['parent_neighbourhood'] = parent_neighbourhood\n params['parent_district'] = parent_district\n params['postalcode'] = postalcode\n params['searchable_id'] = searchable_id\n params['searchable_ids'] = searchable_ids\n return doCurl(\"post\",\"/location\",params)\n end", "def notes_geojson\n\t \t{ 'type' => 'FeatureCollection', \n\t \t 'features' => aw.notes_geo \n\t \t}\n\t \tend", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to areas_path, notice: 'Area was successfully created.' }\n format.json { render json: @area, status: :created, location: @area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def detect_invalid \n @shapes.each do |shape|\n if shape.is_polygon\n @convex_polygons << shape\n else\n @non_convex_polygons << shape\n end\n end \n end", "def polygon\n respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : []\n end", "def destroy\n @post_geo = current_user.post_geos.find(params[:id])\n @post_geo.destroy\n\n respond_to do |format|\n format.html { redirect_to [:client, :post_geos] }\n format.json { head :no_content }\n end\n end", "def parse_poly_holes\n raise StandardError, 'Polygon with Holes not supported'\nend", "def mouth_shape_params\n params.require(:mouth_shape).permit(:name)\n end", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to @area, notice: 'Area was successfully created.' }\n format.json { render json: @area, status: :created, location: @area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to @area, notice: 'Area was successfully created.' }\n format.json { render json: @area, status: :created, location: @area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dog_poly.update(dog_poly_params)\n format.html { redirect_to @dog_poly, notice: 'Dog poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @dog_poly }\n else\n format.html { render :edit }\n format.json { render json: @dog_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @map = Map.new(map_params)\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n else\n format.html { redirect_to maps_url }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @country_area = CountryArea.new(params[:country_area])\n\n respond_to do |format|\n if @country_area.save\n format.html { redirect_to @country_area, notice: 'Country area was successfully created.' }\n format.json { render json: @country_area, status: :created, location: @country_area }\n else\n format.html { render action: \"new\" }\n format.json { render json: @country_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @polygon }\n end\n end", "def geometry_params\n params.require(:geometry).permit(:room_id, :geometry)\n end", "def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n # example output:\n # {\"layers\":[{\"id\":14,\"name\":\"coutries\",\"number_of_polygons\":279}]}\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n end\n end", "def create\n points = params[:solution][:points_earned]\n unless current_user.posse.current_solution?\n solution = current_user.posse.solutions.create(solution_params)\n current_user.posse.add_points(points.to_i)\n end\n render json: solution\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 geo_params\n params.require(:geo).permit(:country, :expectancy)\n end", "def district_area_params\n params.require(:district_area).permit(:name, :initialZipCode, :lastZipCode, :surfaceArea, :population, :density, :shape, :latitude, :longitude, :city_id)\n end", "def gen_shapes\n input_file = ARGV[0].nil? ? \"example.dat\" : ARGV[0]\n shapes_json = gen_json(input_file)\n shapes_json[:geometry][:shape].map do |shape_json|\n Shape.new(shape_json)\n end\n end", "def create\n @layer = Layer.new(layer_params)\n\n respond_to do |format|\n if @layer.save\n format.html { redirect_to @layer, notice: 'Layer was successfully created.' }\n format.json { render :show, status: :created, location: @layer }\n else\n format.html { render :new }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @geometry = Geometry.new(geometry_params)\n\n respond_to do |format|\n if @geometry.save\n format.html { redirect_to @geometry, notice: 'Geometry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @geometry }\n else\n format.html { render action: 'new' }\n format.json { render json: @geometry.errors, status: :unprocessable_entity }\n end\n end\n end", "def correct_geo_coords\n coords = params.seek :geo, :geojson, :geometry, :coordinates\n if coords\n array = GeosHelper.geo_coords_to_array(coords)\n params[:geo][:geojson][:geometry][:coordinates] = array\n end\n end", "def set_district_area\n \n\t r = open(\"http://localhost:3001/district_areas/\" + params[:id] + \".json\").read\n\t #r = open(\"http://floating-chamber-80486.herokuapp.com/district_areas/1.json\").read\n\t hash = JSON.parse(r)\n\t upzsJSON = hash[\"upzs\"]\n\t hash.delete(\"url\")\n\t hash.delete(\"upzs\")\n\t p hash\n\t p upzsJSON\n\t @district_area = DistrictArea.new(hash)\n\t p @district_area.inspect\n\t \n\t upzsJSON.each do |currentUPZ|\n\t\t@district_area.upzs << Upz.new(currentUPZ)\n\t\tend\n\trescue \n\t\t p \"EL RECURSOO NO EXISTEEEEEE\"\n\t\trender json: {}, status: :ok\n\tend", "def create\n @breadcrumb = 'create'\n @area = Area.new(params[:area])\n @area.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @area.save\n format.html { redirect_to @area, notice: crud_notice('created', @area) }\n format.json { render json: @area, status: :created, location: @area }\n else\n @departments = departments_dropdown\n @workers = workers_dropdown\n format.html { render action: \"new\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sub_area = SubArea.new(sub_area_params)\n\n respond_to do |format|\n if @sub_area.save\n format.html { redirect_to @sub_area, notice: 'Sub area was successfully created.' }\n format.json { render :show, status: :created, location: @sub_area }\n else\n format.html { render :new }\n format.json { render json: @sub_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_geonode = Admin::Geonode.new(params[:admin_geonode])\n\n respond_to do |format|\n if @admin_geonode.save\n format.html { redirect_to @admin_geonode, notice: 'Geonode was successfully created.' }\n format.json { render json: @admin_geonode, status: :created, location: @admin_geonode }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_geonode.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @apartment_geopoint = ApartmentGeopoint.new(apartment_geopoint_params)\n\n respond_to do |format|\n if @apartment_geopoint.save\n format.html { redirect_to @apartment_geopoint, notice: 'Apartment geopoint was successfully created.' }\n format.json { render action: 'show', status: :created, location: @apartment_geopoint }\n else\n format.html { render action: 'new' }\n format.json { render json: @apartment_geopoint.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.65228736", "0.595164", "0.59452856", "0.59246415", "0.5849152", "0.5825079", "0.58121926", "0.5754164", "0.57329005", "0.56419456", "0.5603118", "0.55640477", "0.5562892", "0.5518842", "0.5409137", "0.536409", "0.5304422", "0.5299539", "0.5267293", "0.52190936", "0.51827794", "0.51649386", "0.51597154", "0.5159194", "0.51489735", "0.5143983", "0.51352966", "0.5095846", "0.5092515", "0.5068791", "0.50683475", "0.5061221", "0.50603414", "0.50570166", "0.5054479", "0.505447", "0.50524026", "0.5018075", "0.5014518", "0.50112796", "0.499899", "0.49959517", "0.49949005", "0.49937618", "0.49932137", "0.49872494", "0.49847066", "0.49677104", "0.4957448", "0.4926158", "0.4912226", "0.49023125", "0.48891973", "0.48881522", "0.4887096", "0.48810247", "0.48637518", "0.48506823", "0.48478383", "0.48369226", "0.48363888", "0.48287782", "0.4821983", "0.48183414", "0.48155057", "0.48012525", "0.47954652", "0.4788081", "0.47764587", "0.47712973", "0.4771294", "0.47567475", "0.47519502", "0.47514886", "0.4749526", "0.47488114", "0.4748677", "0.47479385", "0.4742555", "0.47423643", "0.47423643", "0.4741456", "0.47394228", "0.47352648", "0.47279453", "0.4727576", "0.4726124", "0.47216043", "0.47141406", "0.47068492", "0.46998936", "0.46988764", "0.46970505", "0.4693445", "0.46923667", "0.46913242", "0.4689347", "0.46886727", "0.468086", "0.4680761" ]
0.6749226
0
PUT /polygons/1 PUT /polygons/1.json
def update @polygon = Polygon.find(params[:id]) respond_to do |format| if @polygon.update_attributes(params[:polygon]) format.html { redirect_to @polygon, notice: 'Polygon was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @polygon.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def _update!\n self.class.repository_or_fail.createPolygon self\n end", "def update\n respond_to do |format|\n if @cat_poly.update(cat_poly_params)\n format.html { redirect_to @cat_poly, notice: 'Cat poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @cat_poly }\n else\n format.html { render :edit }\n format.json { render json: @cat_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @polygon_mark = PolygonMark.find(params[:id])\n \n respond_to do |format|\n if @polygon_mark.update_attributes(:name => params[:name], :layer_id => params[:layer_id])\n @polygon_mark.the_geom = Polygon.from_coordinates(params[:coordinates], 4269)\n @polygon_mark.save!\n format.html { redirect_to @polygon_mark, :notice => 'polygon mark was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @polygon_mark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dog_poly.update(dog_poly_params)\n format.html { redirect_to @dog_poly, notice: 'Dog poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @dog_poly }\n else\n format.html { render :edit }\n format.json { render json: @dog_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @polygon = Polygon.find(params[:id])\n @polygon.destroy\n\n respond_to do |format|\n format.html { redirect_to polygons_url }\n format.json { head :no_content }\n end\n end", "def update!(**args)\n @polygon_shape_id = args[:polygon_shape_id] if args.key?(:polygon_shape_id)\n @rest_of_world_polygon_shape_id = args[:rest_of_world_polygon_shape_id] if args.key?(:rest_of_world_polygon_shape_id)\n @rights_status = args[:rights_status] if args.key?(:rights_status)\n @self_polygon_shape_id = args[:self_polygon_shape_id] if args.key?(:self_polygon_shape_id)\n @trust_prop = args[:trust_prop] if args.key?(:trust_prop)\n @water_removed_polygon_shape_id = args[:water_removed_polygon_shape_id] if args.key?(:water_removed_polygon_shape_id)\n end", "def update!(**args)\n @geometries = args[:geometries] if args.key?(:geometries)\n @id = args[:id] if args.key?(:id)\n @type = args[:type] if args.key?(:type)\n end", "def create\n @polygon = Polygon.new(params[:polygon])\n\n respond_to do |format|\n if @polygon.save\n format.html { redirect_to @polygon, notice: 'Polygon was successfully created.' }\n format.json { render json: @polygon, status: :created, location: @polygon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @polygon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"new\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # checks if user is authorized\n if authorise(request)\n # operation parameter tells what put operation should be done on vertex\n operation = params[:operation]\n case operation\n when 'connection'\n update_connection(params[:from_vertex_id], params[:to_vertex_id])\n when 'transformation'\n update_transformation(params[:id], params[:pos_x], params[:pos_y], params[:width],\n params[:height], params[:z_index])\n when 'attribute'\n update_attribute(params[:id], params[:name], params[:estimated_time], params[:clue],\n params[:description])\n else\n render json: { success: false, message: 'Operation does not exist' }, status: :bad_request\n end\n else\n render json: { success: false, message: 'Unauthorized' }, status: 401\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end", "def update!(**args)\n @geometries = args[:geometries] if args.key?(:geometries)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @rest_of_world_polygon = args[:rest_of_world_polygon] if args.key?(:rest_of_world_polygon)\n @self_polygon = args[:self_polygon] if args.key?(:self_polygon)\n end", "def update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend", "def update\n respond_to do |format|\n if @geometry.update(geometry_params)\n format.html { redirect_to @geometry, notice: 'Geometry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @geometry.errors, status: :unprocessable_entity }\n end\n end\n end", "def spawn_polygons\n\n @args.state.vertices.polygons.each do |polygon|\n\n # If we have a path defined, find it in our polygon list and update locations\n if polygon.key?(:path)\n\n # Then we need to create a new one\n else\n\n # Spawn it, and save the path of it\n new_poly = RegularPolygon.new(args, 64, polygon[:vertices])\n polygon[:path] = new_poly.path\n\n # Finally add it to our internal list\n @polygons << new_poly\n\n end\n\n end\n\n end", "def update\n respond_to do |format|\n if @fish_poly.update(fish_poly_params)\n format.html { redirect_to @fish_poly, notice: 'Fish poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish_poly }\n else\n format.html { render :edit }\n format.json { render json: @fish_poly.errors, status: :unprocessable_entity }\n end\n end\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 create_method\n :put_json\n end", "def index\n @polygons = Polygon.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @polygons }\n end\n end", "def update\n @territory = Territory.find(params[:id])\n @territories = Territory.all\n success = true\n shapes = params[:territory][:shape] # all the shapes are saved when a territory changes\n params[:territory][:shape] = params[:territory][:shape][params[:id]] # the shape of the territory we're updating\n success &&= @territory.update_attributes(params[:territory]) # update all attributes of the territory\n @territories.each do |t|\n success &&= t.update_attribute(:shape, shapes[t.id.to_s]) # and the shape of the others\n end\n respond_to do |format|\n if success\n format.html do\n flash[:notice] = 'Territory was successfully updated.'\n redirect_to(@territory)\n end\n format.xml { head :ok }\n format.js do\n render :update do |page|\n page << notify_msg(\"The territory was updated!\")\n # refresh the territories list\n page['territories-list'].replace_html render(:partial => 'list',\n :locals => {:territories => Territory.find(:all)})\n # re-enable the submit button and change it's title\n page['territory_submit'].enable()\n page['territory_submit'].value = 'Save'\n end\n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @territory.errors, :status => :unprocessable_entity }\n format.js do\n render :update do |page|\n page << notify_error(\"The territory could not be updated!\");\n end\n end\n end\n end\n end", "def update\n geos = params[:post_geos].split(\"\\n\").map{|line| line.blank? ? nil : line.strip}.compact\n current_user.settings.post_geos = geos\n\n respond_to do |format|\n format.html { redirect_to client_post_geos_path, notice: 'Post geos was successfully updated.' }\n format.json { head :no_content }\n end\n end", "def shape\n=begin\n\t\tgeometries = Rails.cache.fetch(MEMORY_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])) {\n\t\t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n=end\n\t\tkey = FILE_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])\n\t\tgeometries = JsonCache.fetch_shape(key) {\n \t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n\n respond_to do |format|\n format.json { render json: geometries }\n end\n end", "def new\n @polygon = Polygon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @polygon }\n end\n end", "def set_cat_poly\n @cat_poly = CatPoly.find(params[:id])\n end", "def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n @geopoint = Geopoint.find(params[:id])\n\n respond_to do |format|\n if @geopoint.update_attributes(params[:geopoint])\n format.html { redirect_to @geopoint, notice: 'Geopoint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @geopoint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @shape_type = ShapeType.find(params[:id])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeType.find(params[:parent_shape])\n\n respond_to do |format|\n\t\t\tif parent.nil?\n\t format.html { render action: \"edit\" }\n\t format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t\telse\n\t\t\t\t# see if the parent shape changed\n\t\t\t\tanc_ary = @shape_type.ancestry.split(\"/\")\n\t\t\t\tif (anc_ary.length == 1 && parent.id.to_s == anc_ary[0]) || parent.id.to_s == anc_ary[anc_ary.length-1]\n\t\t\t\t\t# parent shape did not change, do nothing\n\t\t\t\telse\n\t\t\t\t\t# parent shape did change. update the ancestry value\n\t\t\t\t\tnew_anc = parent.ancestor_ids.join(\"/\")\n\t\t\t\t\tnew_anc += \"/\" + parent.id.to_s\n\t\t\t\t\tparams[:shape_type][:ancestry] = new_anc\n\t\t\t\tend\n\n\t\t if @shape_type.update_attributes(params[:shape_type])\n\t\t\t\t\tmsg = I18n.t('app.msgs.success_updated', :obj => I18n.t('app.common.shape_type'))\n\t\t\t\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n\t\t format.html { redirect_to admin_shape_type_path(@shape_type), notice: msg }\n\t\t format.json { head :ok }\n\t\t else\n\t\t format.html { render action: \"edit\" }\n\t\t format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t end\n\t end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def edit_draw_polygon_with_http_info(request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: EditApi.edit_draw_polygon ...'\n end\n # verify the required parameter 'request' is set\n if @api_client.config.client_side_validation && request.nil?\n fail ArgumentError, \"Missing the required parameter 'request' when calling EditApi.edit_draw_polygon\"\n end\n # resource path\n local_var_path = '/image/edit/draw/polygon'\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/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(request)\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EditApi#edit_draw_polygon\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @mouth_shape.update(mouth_shape_params)\n format.html { redirect_to @mouth_shape, notice: 'La Forma de Boca ha sido actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @mouth_shape }\n else\n flash[:danger] = \"No se ha podido Procesar la Operacion\"\n format.html { render :edit }\n format.json { render json: @mouth_shape.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_array_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/arrays/{arrayId}\"\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 set_dog_poly\n @dog_poly = DogPoly.find(params[:id])\n end", "def put(path, data = {})\n request 'PUT', path, body: data.to_json\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 http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def show\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @polygon }\n end\n end", "def update\n @map = Map.find(params[:id])\n\n respond_to do |format|\n #if @map.update_attributes(params[:map])\n if @map.update_attributes(height: params[:height], width: params[:width])\n format.html { redirect_to @map, notice: 'Map was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @apartment_geopoint.update(apartment_geopoint_params)\n format.html { redirect_to @apartment_geopoint, notice: 'Apartment geopoint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @apartment_geopoint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end", "def update\n if params[:recursos][:status] == '1'\n @count = count_of_resource\n save_multiples_recursos\n end\n respond_to do |format|\n if @area.update(area_params)\n format.html { redirect_to @area, notice: 'El Área fue modificada éxitosamente.' }\n format.json { render :show, status: :ok, location: @area }\n else\n format.html { render :edit }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "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 api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def put(*args)\n request :put, *args\n end", "def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n if spot = SkateSpot.where(:id => params[:id]).first and info = parse_input(params)\n if info.has_key?(:alt_names)\n info[:alt_names].map! { |n| SpotName.find_or_create_by(:name => n, :spot => spot) }\n end\n\n if info[:name]\n info[:name] = SpotName.find_or_create_by(:name => info[:name], :spot => spot) \n end\n\n if info.has_key?(:obstacles)\n info[:obstacles].map! { |o|\n Obstacle.find_or_create_by(:type => ObstacleType.where(:name => o['type']).first, :geometry => o['geometry'], :spot => spot)\n }\n end\n\n render :json => { :status => (spot.update(info) == true ? :success : :unprocessable_entity) }\n else\n render :json => { :status => :unprocessable_entity }\n end\n\n rescue ActiveRecord::RecordNotSaved\n render :json => { :status => :unprocessable_entity }\n end", "def update\n @map = Map.find_by_id(params[:id])\n new_points = []\n if points = params['markers']\n points.each do |marker_identifier,point|\n new_points << @map.points.build(:marker_identifier => marker_identifier, :lat => point['lat'], :lng => point['lng'],:description =>point['description'])\n end\n end\n @map.points = new_points \n respond_to do |format|\n if @map.update_attributes(params[:map])\n format.html { redirect_to(@map, :notice => 'Map was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @map.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(id:, url_variables:, body:)\n ensure_service_document\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def analysePolygon(geojson, data_sources = [\"protected_areas\"])\n self.query_area_km2 = 0\n self.query_area_carbon_kg = 0\n self.save\n\n #convert geojson to wkt\n wkt = GeomHelper.geojson_to_wkt geojson\n query = [{:id => self.id, :the_geom => wkt}].to_json\n\n data_sources.each { |source|\n case source\n when \"coral\"\n url = \"http://localhost:4567/marine_search/coral\"\n field_setter = \"query_area_coral_km2=\"\n when \"mangroves\"\n url = \"http://localhost:4567/marine_search/mangroves\"\n field_setter = \"query_area_mangrove_km2=\"\n when \"sea_grass\"\n url = \"\"\n field_setter = \"query_area_sea_grass_km2=\"\n else\n next\n end\n\n res = nil\n begin\n res = JSON.parse Net::HTTP.post_form(URI.parse(url),:data => query).body\n rescue\n next\n end\n next unless res\n if res.include? \"error\"\n msg = \"Error fetching data from #{source} data source: \" + res[\"error\"]\n puts msg\n logger.error msg\n next\n end\n\n val = 0\n res[\"results\"].each{|item|val += item[\"overlapped_area\"].to_f}\n self.send field_setter, val\n self.save\n }\n\n if data_sources.include?( \"protected_areas\" )\n ok = true\n begin\n # call API\n url = \"http://protectedplanet.net/api2/geo_searches\"\n res = Net::HTTP.post_form(URI.parse(url),:data => query).body\n res = JSON.parse res\n rescue\n ok = false\n end\n\n if ok\n # populate DB with results\n res[\"results\"].each do |item|\n # This will be returned multiple times, but... it seems to be the only way to get it, other than calculating\n # locally. (Would that be so bad?.)\n self.query_area_km2 = item[\"query_area_km2\"].to_f\n self.query_area_carbon_kg = item[\"query_area_carbon_kg\"].to_f\n self.save\n\n item[\"protected_areas\"].each do |s|\n #ds = s['data_standard']\n #wkt = ds[\"GEOM\"]\n site = Site.create :tenement_id => id,\n :wdpaid => s['wdpaid'],\n :image => s['image'],\n :encoded_polyline_cache => s['epl'],\n :data_standard => s['data_standard'],\n :protected_carbon_kg => s['protected_carbon_kg'],\n :protected_area_km2 => s['protected_area_km2'],\n :query_area_protected_km2 => s['query_area_protected_km2'],\n :query_area_protected_carbon_kg => s['query_area_protected_carbon_kg']\n sql = \"UPDATE sites SET the_geom=ST_GeomFromText('#{s['simple_geom']}') where id=#{site.id}\"\n Site.connection.execute sql\n end\n end\n end\n end\n end", "def update\n @rooms_for_draw = []\n\n respond_to do |format|\n if @floor.update(floor_params)\n\n editorData = @floor.editor_data\n editorData = editorData.split(\"<END>\").map{|i| i.split(\"<NEXT>\")}\n editorData.each do |obj|\n if obj[7] == 'edit'\n # Обновление точек:\n\n Point.all.where(polygon_id: obj[6]).each{ |point| point.destroy }\n points = obj[8].gsub(\", \", \",\").split(\" \").map{ |j| j.split(',') }\n for i in 0 ... points.size\n point = Point.create(ox: points[i][0].to_f,\n oy: points[i][1].to_f,\n priority: i,\n polygon_id: obj[6]\n )\n point.save\n end\n\n if obj[0] == 'submain'\n # Обновление аудиторий:\n room = Room.all.where(id: Polygon.all.where(id: obj[6].to_i)[0].imageable_id)[0]\n room.update(name: obj[1],\n description: obj[2],\n capacity: obj[3],\n computers: obj[4],\n roomtype_id: Roomtype.all.where(id: obj[5].to_i)[0]\n )\n end\n elsif obj[7] == 'destroy'\n Point.all.where(polygon_id: obj[6]).each{ |point| point.destroy }\n if obj[0] == 'submain'\n # raise (\"#{obj[6]}\")\n room = Room.all.where(id: Polygon.all.where(id: obj[6].to_i)[0].imageable_id)[0]\n room.destroy\n end\n elsif obj[7] == 'new'\n if obj[0] == 'submain'\n object = Room.new(name: obj[1],\n description: obj[2],\n capacity: obj[3],\n computers: obj[4],\n roomtype_id: Roomtype.all.where(id: obj[5].to_i)[0],\n floor_id: @floor.id)\n object.save\n elsif obj[0] == 'main'\n object = @floor\n end\n polygon = Polygon.new(imageable: object)\n polygon.save\n points = obj[8].gsub(\", \", \",\").split(\" \").map{ |j| j.split(',') }\n for i in 0 ... points.size\n point = Point.create(ox: points[i][0].to_f,\n oy: points[i][1].to_f,\n priority: i,\n polygon: polygon\n )\n point.save\n end\n end\n end\n\n format.html { redirect_to @floor, notice: t('flash.floor.update') }\n format.json { render :show, status: :ok, location: @floor }\n else\n format.html { render :edit }\n format.json { render json: @floor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ontology.update(ontology_params)\n format.html { redirect_to @ontology, notice: 'Ontology was successfully updated.' }\n format.json { render :show, status: :ok, location: @ontology }\n else\n format.html { render :edit }\n format.json { render json: @ontology.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client.update(client_params)\n render json: @client\n end", "def create_method\n :http_put\n end", "def create_method\n :http_put\n end", "def update\n @place = Place.find(params[:id])\n\n if @place.update(place_params)\n render :json => {:success => true}\n else\n render :json => {:success => false, :errors => [\"Update failed.\"]}\n end\n end", "def update\n trip = Trip.find_by_id(params[:trip_id])\n trip.title = params[:title]\n trip.city = params[:city]\n trip.state = params[:state]\n trip.country = params[:country]\n trip.start_date = params[:start_date]\n trip.end_date = params[:end_date]\n trip.description = params[:description]\n trip.link = params[:link]\n if params[:photo_base]\n trip.photo = params[:photo_base]\n end\n trip.save!\n render json: trip\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def create\n @cat_poly = CatPoly.new(cat_poly_params)\n\n respond_to do |format|\n if @cat_poly.save\n format.html { redirect_to @cat_poly, notice: 'Cat poly was successfully created.' }\n format.json { render :show, status: :created, location: @cat_poly }\n else\n format.html { render :new }\n format.json { render json: @cat_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_geo_db\n json = JSON.parse params[:features]\n @theme_map = ThemeMap.find(params[:theme_map][:id])\n gjson = RGeo::GeoJSON.decode( json, json_parser: :json )\n gjson.each do |feature|\n line = nil\n f_id = feature.properties[\"id\"]\n if f_id != nil\n line = UserLine.find(f_id)\n else\n line = UserLine.new\n end\n line.text = feature.properties[\"text\"]\n line.number = feature.properties[\"number\"]\n line.amount = feature.properties[\"amount\"]\n line.name = feature.properties[\"name\"]\n line.user_id = @current_user_id\n line.map_layer_id = 100 # @theme_map.interactive_layer_id\n wkt_string = feature.geometry.as_text\n g_factory = RGeo::Cartesian::Factory.new(srid: 3857)\n line.geometry = g_factory.parse_wkt(wkt_string)\n line.save # update_attributes(user_line_params)\n end\n render :js => 'alert(\"saved\");'\n end", "def update_geo_places\n unless(params[:place] && params[:topic_id] && params[:location_id])\n render_error \"incorrect params\"\n return\n end\n\n @topic = Topic.find(params[:topic_id])\n if current_user.guardian.ensure_can_edit!(@topic)\n render status: :forbidden, json: false\n return\n end\n\n# passing in location_id might be redundant as with updates, place should already have location_id\n location_id = params[:location_id].to_s\n # below is a workaround check while I still have some places in db\n # that are arrays\n # binding.pry\n # if @topic.geo.places.class == Array\n unless (@topic.geo.places.class == Hash) && (@topic.geo.places['sorted_ids'])\n @topic.geo.places = {\n 'sorted_ids' => []\n }\n @topic.geo.save\n end\n\n unless @topic.geo.places['sorted_ids'].include? location_id\n @topic.geo.places['sorted_ids'].push location_id\n end\n\n place = JSON.parse params[:place]\n# place param is now passed as a string ( json.stringyfy client side)\n# - allowing jquery to process the payload resulted in nested arrays getting converted to hashes\n# http://stackoverflow.com/questions/25856959/parsing-json-with-jquery-turns-array-into-hash\n# with json parse above, probably don't need below check anymore\n place['longitude'] = place['longitude'].to_f\n place['latitude'] = place['latitude'].to_f\n place['location_id'] = location_id\n\n # should do some checks to prevent injection attacks\n @topic.geo.places[location_id] = place\n # topic_places = @topic.geo.places || []\n\n @topic.geo.save!\n return render_json_dump @topic.geo.as_json\n\n end", "def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n format.html { redirect_to @area, notice: 'Area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n format.html { redirect_to @area, notice: 'Area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n format.html { redirect_to @area, notice: 'Area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def areas\n @area = Area.new(geo_json: params.to_json)\n if @area.save\n json_response([id: @area.id], :created, :geo_json_recieved)\n else\n json_response(nil, :error, :db_error)\n end\n end", "def create\n @polygon_mark = PolygonMark.new(:name => params[:name], :layer_id => params[:layer_id])\n \n respond_to do |format|\n if @polygon_mark.save\n @polygon_mark.the_geom = Polygon.from_coordinates([params[:coordinates]], 4269)\n @polygon_mark.save!\n format.html { redirect_to @polygon_mark, :notice => 'polygon mark was successfully created.' }\n format.json { render :json => @polygon_mark, :status => :created, :location => @polygon_mark }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @polygon_mark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request(:put, *args)\n end", "def cat_poly_params\n params.require(:cat_poly).permit(:dog_poly, :fish_poly)\n end", "def update\n authorize! :update, Concepto\n if params[:concepto][:tipo_ids]\n params[:concepto][:tipo_ids] = params[:concepto][:tipo_ids].map { |k, _v| k }\n else\n params[:concepto][:tipo_ids] = []\n end\n\n respond_to do |format|\n if @concepto.update(concepto_params)\n\n\n format.html { redirect_to @concepto, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos del concepto fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @concepto }\n else\n format.html { render :edit } if params[:concepto][:tipo_ids]\n format.json { render json: @concepto.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n find_map\n respond_with @map, :include => :waypoints\n end", "def update!(**args)\n @geometry_id = args[:geometry_id] if args.key?(:geometry_id)\n end", "def update\n @lens = Lens.find(params[:id])\n attrb = select_params(lens_params)\n # linear_data is an array of Objects of Components Properties\n # that needs to be deserialized correctly\n attrb[\"linear_data\"] = JSON.parse(attrb[\"linear_data\"])\n lens = Lens.update(attrb)\n \n # @lens.update(lens_params)\n # render inline: \"<%= @lens.id %>\"\n end", "def update\n place = Place.find(params[:id])\n\n if place.update_attributes(params[:place])\n head :no_content\n else\n render json: place.errors, status: :unprocessable_entity\n end\n end", "def assign_tenants_to_circle(args = {}) \n body_put(\"/tenantcircles.json/tenants/#{args[:circleId]}\", args[:array_of_ids])\nend", "def update\n @overlay = Overlay.find(params[:id])\n\n respond_to do |format|\n if @overlay.update_attributes(params[:overlay])\n format.html { redirect_to @overlay, notice: 'Overlay was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @overlay.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @county = County.find(params[:id])\n\n respond_to do |format|\n if @county.update_attributes(params[:county])\n format.html { redirect_to @county, notice: 'County was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @county.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render_json :status => :forbidden and return unless @collection.write?(@user, @client)\n if !params[:collection]\n render_json :status => :bad_request, :messages => \"Tried to update collection with no data.\" and return\n end\n @collection.update_attributes(params[:collection].slice(:metadata, :read_only, :title, :tags, :priv))\n render_json :entry => @collection.to_hash(@user, @client) and return\n end", "def update\n respond_to do |format|\n @area.skus = params[:area][:skus]\n if @area.update area_params\n format.html { redirect_to admin_areas_path, notice: 'Area was successfully updated.' }\n format.json { render :show, status: :ok, location: @area }\n else\n format.html { render :edit }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @geotopics = args[:geotopics] if args.key?(:geotopics)\n end", "def update\n\n # @zone = Zone.find(params[:id])\n # @zone.nombre_zona = params[\"nombre_zona\"]\n @coordenada = CoordinateZone.where('zone_id = ?', @zone.id)\n @coordenada.each do |cz|\n cz.destroy\n end\n\n respond_to do |format|\n if @zone.update #(zone_params)\n format.html { redirect_to @zone, notice: 'Zone was successfully updated.' }\n format.js \n format.json { render :show, status: :ok, location: @zone }\n else\n format.html { render :edit }\n format.json { render json: @zone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @ontology.update(ontology_params)\n\t\t\t\tformat.html { redirect_to @ontology, notice: 'Ontology was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\tformat.json { render json: @ontology.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @layer.update(layer_params)\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render :show, status: :ok, location: @layer }\n else\n format.html { render :edit }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @grid.squares[params[:x]][params[:y]] = params[:color]\n\n render json: { status: \"OK\" }\n end", "def update\n @admin_geonode = Admin::Geonode.find(params[:id])\n\n respond_to do |format|\n if @admin_geonode.update_attributes(params[:admin_geonode])\n format.html { redirect_to @admin_geonode, notice: 'Geonode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_geonode.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @zonas = Zona.all\n @zona.update_attributes(zona_params)\n end", "def update\n if @collection.update(collection_params)\n render json: @collection, status: :ok#, location: @collection\n else\n render json: @collection.errors, status: :unprocessable_entity\n end\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def hard_save\n args = request_params\n @uncommitted = save_and_remove_all(args[:map_id], args[:round])\n render json: @uncommitted\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def update\n json_update(category,category_params, Category)\n end", "def update\n if params[:place_id]\n @safe_house = Place.find(params[:place_id])\n place_id_present = true\n end\n\n respond_to do |format|\n if place_id_present && @safe_house.update_attributes( :name => params[:name],\n :zombie_probability => params[:zombie_probability],\n :latitude => params[:latitude],\n :longitude => params[:longitude],\n :has_weapons => params[:has_weapons],\n :has_food => params[:has_food],\n :has_people => params[:has_people])\n format.json { render :json => { :status => \"OK\", :response => {:updated => true} }}\n else\n format.json { render :json => { :status => \"Error\", :response => {} }}\n end\n end\n end", "def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end" ]
[ "0.6826295", "0.61088365", "0.60923445", "0.6087015", "0.5892075", "0.58629286", "0.58038306", "0.57993364", "0.57139134", "0.5695231", "0.56512505", "0.56227225", "0.55273837", "0.5494119", "0.546989", "0.5374367", "0.5350406", "0.53445464", "0.533678", "0.5335534", "0.53236765", "0.530024", "0.529457", "0.52755433", "0.5256625", "0.5241793", "0.52096105", "0.5206808", "0.52047724", "0.51905715", "0.5188993", "0.51856047", "0.5179323", "0.5175545", "0.5163839", "0.51583254", "0.5131132", "0.5119518", "0.51192695", "0.51187557", "0.5101941", "0.5098467", "0.5095463", "0.5083511", "0.5081608", "0.50798357", "0.507452", "0.50680745", "0.5067204", "0.50611204", "0.5056928", "0.5054891", "0.5046494", "0.504026", "0.5033099", "0.50285923", "0.5025295", "0.5022685", "0.5021346", "0.50150794", "0.50150794", "0.5011192", "0.5008106", "0.5004278", "0.5003043", "0.4999766", "0.49914104", "0.4987461", "0.4987461", "0.4987461", "0.49831542", "0.49812678", "0.49801284", "0.4977436", "0.4972787", "0.49725395", "0.49664584", "0.4961392", "0.49606666", "0.49542958", "0.4948434", "0.4931659", "0.49281114", "0.49280268", "0.49251884", "0.49211675", "0.49158427", "0.4912629", "0.4909781", "0.4905273", "0.49042028", "0.49020988", "0.49005592", "0.48985097", "0.48951557", "0.48951557", "0.48951557", "0.48940194", "0.4889685", "0.48840472" ]
0.6763483
1
DELETE /polygons/1 DELETE /polygons/1.json
def destroy @polygon = Polygon.find(params[:id]) @polygon.destroy respond_to do |format| format.html { redirect_to polygons_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @geometry.destroy\n respond_to do |format|\n format.html { redirect_to geometries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @post_geo = current_user.post_geos.find(params[:id])\n @post_geo.destroy\n\n respond_to do |format|\n format.html { redirect_to [:client, :post_geos] }\n format.json { head :no_content }\n end\n end", "def destroy\n @geopoint = Geopoint.find(params[:id])\n @geopoint.destroy\n\n respond_to do |format|\n format.html { redirect_to geopoints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @map.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @geo.destroy\n respond_to do |format|\n format.html { redirect_to geos_url, notice: 'Geo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_geonode = Admin::Geonode.find(params[:id])\n @admin_geonode.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_geonodes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @polygon_mark = PolygonMark.find(params[:id])\n @polygon_mark.destroy\n \n respond_to do |format|\n format.html { redirect_to polygon_marks_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 @apartment_geopoint.destroy\n respond_to do |format|\n format.html { redirect_to apartment_geopoints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cat_poly.destroy\n respond_to do |format|\n format.html { redirect_to cat_polies_url, notice: 'Cat poly was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @business_geopoint.destroy\n respond_to do |format|\n format.html { redirect_to business_geopoints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shape_type = ShapeType.find(params[:id])\n @shape_type.destroy\n\n\t\tmsg = I18n.t('app.msgs.success_deleted', :obj => I18n.t('app.common.shape_type'))\n\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n respond_to do |format|\n format.html { redirect_to admin_shape_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @geo_datum.destroy\n respond_to do |format|\n format.html { redirect_to geo_data_url, notice: 'Geo datum was successfully destroyed.' }\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 @dog_poly.destroy\n respond_to do |format|\n format.html { redirect_to dog_polies_url, notice: 'Dog poly was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @geographic_item.destroy\n respond_to do |format|\n format.html { redirect_to geographic_items_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Location.delete(params[\"id\"])\n end", "def destroy\n @map.destroy\n\n respond_to do |format|\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@ru = request.original_url\n @ru = request.protocol + request.host_with_port + \"/layers/#{params['id']}\"\n @annotationLayer = AnnotationLayer.where(layer_id: @ru).first\n #authorize! :delete, @annotation_layer\n if @annotationLayer.version.nil? || @annotationLayer.version < 1\n @annotationLayer.version = 1\n end\n if !version_layer @annotationLayer\n errMsg = \"Annotation Layer could not be updated: \" + @problem\n render :json => { :error => errMsg },\n :status => :unprocessable_entity\n end\n @annotationLayer.destroy\n request.format = \"json\"\n respond_to do |format|\n format.html { redirect_to annotation_layers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @overlay = Overlay.find(params[:id])\n @overlay.destroy\n\n respond_to do |format|\n format.html { redirect_to overlays_url }\n format.json { head :ok }\n end\n end", "def destroy\n @map.destroy\n respond_to do |format|\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @map.destroy\n respond_to do |format|\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @map.destroy\n respond_to do |format|\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spatial_coverages = SpatialCoverages.find(params[:id])\n @spatial_coverages.destroy\n\n respond_to do |format|\n format.html { redirect_to spatial_coverage_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @core_area.destroy\n respond_to do |format|\n format.html { redirect_to core_areas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @country_area = CountryArea.find(params[:id])\n @country_area.destroy\n\n respond_to do |format|\n format.html { redirect_to country_areas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n get_map\n @map.destroy\n\n respond_to do |format|\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mini_map_road = MiniMapRoad.find(params[:id])\n @mini_map_road.destroy\n\n respond_to do |format|\n format.html { redirect_to mini_map_roads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @layer = Layer.find(params[:id])\n @layer.destroy\n\n respond_to do |format|\n format.html { redirect_to layers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])\n @gethotelstaticdatagd.destroy\n\n respond_to do |format|\n format.html { redirect_to gethotelstaticdatagds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mouth_shape.destroy\n respond_to do |format|\n format.html { redirect_to mouth_shapes_url, notice: 'La Forma de Boca ha sido eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @smallmap = Smallmap.find(params[:id])\n @smallmap.destroy\n\n respond_to do |format|\n format.html { redirect_to smallmaps_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @roadmap.destroy\n respond_to do |format|\n format.html { redirect_to roadmaps_url, notice: 'Roadmap wurde erfolgreich gelöscht' }\n format.json { head :no_content }\n end\n end", "def destroy\n @geo_country = Geo::Country.find(params[:id])\n @geo_country.destroy\n\n respond_to do |format|\n format.html { redirect_to(geo_countries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @map_area = MapArea.find(params[:id])\n @map_area.destroy\n\n respond_to do |format|\n format.html { redirect_to(map_areas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @map_area = MapArea.find(params[:id])\n @map_area.destroy\n\n respond_to do |format|\n format.html { redirect_to(map_areas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dimgeom = Dimgeom.find(params[:id])\n @dimgeom.destroy\n\n respond_to do |format|\n format.html { redirect_to dimgeoms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @map = Map.find(params[:id])\n @map.destroy\n\n respond_to do |format|\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @area_attribute.destroy\n respond_to do |format|\n format.html { redirect_to area_attributes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @county = County.find(params[:id])\n @county.destroy\n\n respond_to do |format|\n format.html { redirect_to counties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tinymap = Tinymap.find(params[:id])\n @tinymap.destroy\n\n respond_to do |format|\n format.html { redirect_to tinymaps_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete_pathway\n pathway = Pathway.find(params[:pathway_par])\n current_user.pathways.delete(pathway)\n if current_user.pathways.size < 1\n respond_to do |format|\n format.html { redirect_to '/saved#pathways' }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @area = Area.find(params[:id])\n @area.destroy\n\n respond_to do |format|\n format.html { redirect_to areas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @area = Area.find(params[:id])\n @area.destroy\n\n respond_to do |format|\n format.html { redirect_to areas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @area = Area.find(params[:id])\n @area.destroy\n\n respond_to do |format|\n format.html { redirect_to areas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vertices_scene1.destroy\n respond_to do |format|\n format.html { redirect_to vertices_scene1s_url, notice: 'Vertices scene1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end", "def destroy\n # @observation = Observation.find(params[:observation_id])\n @area = Area.find(params[:area_id])\n @touch = @area.touches.find(params[:id])\n\n\n # @touch = Touch.find(params[:id])\n @touch.destroy\n\n respond_to do |format|\n format.html { redirect_to coral_observation_area_path(@area.observation.coral, @area.observation, @area), notice: 'Area was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end", "def destroy\n @geoname = Geoname.find(params[:id])\n @geoname.destroy\n\n respond_to do |format|\n format.html { redirect_to(geonames_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @collection.destroy\n\n render json: @collection, status: :ok#, location: @collection\n end", "def destroy\n @subset.destroy\n respond_to do |format|\n format.html { redirect_to subsets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gethotel = Gethotel.find(params[:id])\n @gethotel.destroy\n\n respond_to do |format|\n format.html { redirect_to gethotels_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @zona = Zona.find(params[:id])\n @zona.destroy\n\n respond_to do |format|\n format.html { redirect_to zone_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_map.destroy\n\n respond_to do |format|\n format.html { redirect_to group_maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(server_id: Integer(params[:id]))\r\n directory = Rails.root.join('app','assets','locations');\r\n\r\n path = File.join(directory, @location.image)\r\n File.delete(path)\r\n @location.destroy\r\n mv = MapsVersion.first\r\n mv.version = mv.version+1\r\n mv.save\r\n respond_to do |format|\r\n format.html { redirect_to locations_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @locationmap = Locationmap.find(params[:id])\n @locationmap.destroy\n\n respond_to do |format|\n format.html { redirect_to locationmaps_url }\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 @map_layer = MapLayer.find(params[:id])\n @map_layer.destroy\n\n respond_to do |format|\n format.html { redirect_to(map_layers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @survey_area = SurveyArea.find(params[:id])\n @survey_area.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_areas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @glo_collection.destroy\n respond_to do |format|\n format.html { redirect_to glo_collections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attribute_layer = AttributeLayer.find(params[:id])\n @attribute_layer.destroy\n\n respond_to do |format|\n format.html { redirect_to attribute_layers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concept_map = ConceptMap.find(params[:id])\n @concept_map.destroy\n\n respond_to do |format|\n format.js {render :nothing => true}\n format.html { redirect_to conecpt_maps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: DELETE_SUCCESS }\n format.json { head :no_content }\n end\n end", "def destroy\n @map.destroy\n\n head :no_content\n end", "def destroy\n\t\tFile.delete(@ontology.url)\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to ontologies_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @ontology.destroy\n respond_to do |format|\n format.html { redirect_to ontologies_url, notice: 'Ontology was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @geocach = Geocach.find(params[:id])\n @geocach.destroy\n\n respond_to do |format|\n format.html { redirect_to geocaches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @geofence.destroy\n respond_to do |format|\n format.html { redirect_to geofences_url, notice: 'Geofence was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @area_type = AreaType.find(params[:id])\n @area_type.destroy\n\n respond_to do |format|\n format.html { redirect_to area_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pol.destroy\n respond_to do |format|\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 @structure_drawing.destroy\n respond_to do |format|\n format.html { redirect_to project_sub_project_structure_drawings_path(@project, @sub_project), notice: 'Structure drawing was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gmap = Gmap.find(params[:id])\n @gmap.destroy\n\n respond_to do |format|\n format.html { redirect_to gmaps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @trein_coord_pedag.destroy\n respond_to do |format|\n format.html { redirect_to trein_coord_pedags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @layer.destroy\n respond_to do |format|\n format.html { redirect_to layers_url, notice: 'Layer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @world_map = WorldMap.find(params[:id])\n @world_map.destroy\n\n respond_to do |format|\n format.html { redirect_to world_maps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mosttinymap = Mosttinymap.find(params[:id])\n @mosttinymap.destroy\n\n respond_to do |format|\n format.html { redirect_to mosttinymaps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @crop.destroy\n respond_to do |format|\n format.html { redirect_to crops_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @moretinymap = Moretinymap.find(params[:id])\n @moretinymap.destroy\n\n respond_to do |format|\n format.html { redirect_to moretinymaps_url }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def remove(*paths)\n json_op(:remove, self, *paths)\n end", "def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @counties = County.all\n @county = County.find(params[:id])\n @county.destroy\n end", "def destroy\n @lab_area.destroy\n respond_to do |format|\n format.html { redirect_to lab_areas_url, notice: 'Lab area was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @subway = Subway.find(params[:id])\n @subway.destroy\n\n respond_to do |format|\n format.html { redirect_to subways_url }\n format.json { head :ok }\n end\n end", "def destroy\n @area.destroy\n respond_to do |format|\n format.html { redirect_to areas_url, notice: 'El Área fue eliminada éxitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @countries = Countries.find(params[:id])\n @countries.destroy\n\n respond_to do |format|\n format.html { redirect_to(countries_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.6596842", "0.6481396", "0.64797837", "0.6337303", "0.63017017", "0.62546587", "0.6242979", "0.6229377", "0.62050515", "0.6199542", "0.61053884", "0.6094234", "0.6087038", "0.6079646", "0.60688704", "0.6068016", "0.60649145", "0.60514265", "0.6039525", "0.603931", "0.60300106", "0.60300106", "0.60300106", "0.6021198", "0.5998286", "0.5993202", "0.59902465", "0.5963157", "0.5947041", "0.5934168", "0.5931306", "0.5920599", "0.5918099", "0.5916667", "0.58862716", "0.58774173", "0.5874236", "0.5874236", "0.5867145", "0.5862634", "0.585653", "0.5853406", "0.58502805", "0.5847496", "0.5846216", "0.5834731", "0.58319914", "0.58319914", "0.58319914", "0.5831194", "0.5824471", "0.5819389", "0.58146346", "0.5810535", "0.5806048", "0.5803263", "0.57976025", "0.57949084", "0.57897264", "0.57812357", "0.5777028", "0.57756996", "0.57755643", "0.5770833", "0.57690424", "0.57660246", "0.57659876", "0.57614744", "0.57560843", "0.57552844", "0.57542944", "0.5750844", "0.5747007", "0.57426655", "0.5734687", "0.57325506", "0.57308525", "0.5728417", "0.57265276", "0.57226616", "0.57226616", "0.5711695", "0.5711481", "0.5708617", "0.57013136", "0.5700704", "0.56974995", "0.56964517", "0.5690584", "0.5689431", "0.5686398", "0.5681368", "0.5680049", "0.5679913", "0.5673255", "0.56718856", "0.56649727", "0.5664326", "0.5663598", "0.565915" ]
0.748428
0
Steps: List fibonacci numbers Add if they are even Return sum of even < 4000000
def problem_two first_num = 1 #Let first number be 1 second_num = 1 #we need this to make 2nd num sum = 0 while sum < 4000000 first_num, second_num = second_num, first_num + second_num if first_num.even? sum += first_num end end sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_even_fibonacci_numbers(num)\n even_fibonacci_numbers = fibonacci_numbers(num).select{|number| number.even?}\n even_fibonacci_numbers.inject(:+)\nend", "def fibonacci(p2, p1, sum)\n next_number = p2 + p1\n return sum if next_number >= 4000000\n sum += next_number if next_number.even?\n fibonacci p1, next_number, sum\nend", "def fibonacci\n\n # write a fibonacci sequence\n # make an array\n fibonacci_sequence = [1, 2, 3, 5, 8]\n while true\n the_length = fibonacci_sequence.count - 1\n if fibonacci_sequence[the_length] + fibonacci_sequence[the_length - 1] > 4000000\n break\n end\n fibonacci_sequence << (fibonacci_sequence[the_length] + fibonacci_sequence[the_length - 1])\n end\n # p fibonacci_sequence\n\n # find the even numbers in an array\n # find if a particular number is even\n # make a loop to check them all\n even_array = []\n fibonacci_sequence.each do |number|\n if number % 2 == 0\n even_array << number\n else\n end\n end\n\n p even_array\n\n sum = 0\n even_array.each do |number|\n sum += number\n end\n\n p sum\nend", "def fib_arry\n arr = [1, 1]\n a = 0\n b = 1\n while arr[a] + arr[b] <= 4000000\n arr << (arr[a] + arr[b])\n a += 1\n b += 1\n end\n # step 2 determine which are even\n evens = arr.select { |num| num.even? }\n # step 3 sum\n puts \"This is the sum of all even fibonacci numbers less than 4,000,000: #{evens.reduce(:+)}\"\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 fibonacci\n first = 1\n second = 2\n sum = second\n\n while sum < 4000000 do\n third = first + second\n first = second\n second = third\n\n sum += third if third.even?\n end\n puts sum\nend", "def even_fib\n x=[0,1]\n i = 0\n a = []\n\n while x.last < 4000000\n x.push(x[i] + x[i+1])\n i += 1\n end\n\n x.pop\n\n x.each do |blah|\n if blah.even?\n a.push(blah)\n end\n \n end\n\n a.reduce(:+)\n\nend", "def fibonacci\n\n n1 = 1\n n2 = 2\n n3 = n1 + n2\n sum = 1\n \n (2..4000000).each do |i|\n n1 = n2\n n2 = n3\n n3 = n1 + n2\n\n if n2 % 2 == 0 \n sum += n2\n end\n puts \"number: #{i}\"\n end\n\n sum\n\nend", "def fibonacci\n\tresults, first, second, current = 0, 1, 2, 2\n\twhile current <= 4000000\n\t\tif current % 2 == 0\n\t\t\tresults += current\n\t\tend\n\t\tcurrent = first + second\n\t\tfirst, second = second, current\n\tend\n\treturn results\nend", "def four_million_fibonacci()\n arr = [1, 2]\n num = 0\n even_sum = 2\n\n while num < 4000000 do\n num = arr[-1] + arr[-2]\n arr << num\n if num % 2 == 0 \n even_sum += num \n end\n end\n\n puts even_sum\nend", "def problem_two\n fibs(4_000_000).select { |n| n.even? }.reduce(&:+)\n end", "def even_fibs_sum(num)\n fibs = [0,1]\n \n while fibs.max < num\n nexty = fibs[-1] + fibs[-2]\n fibs << nexty\n end\n \n sum = 0\n fibs.map {|x| sum += x if x.even? }\n \n return sum\nend", "def even_fibonacci_sum(limit)\n fib_seq = fibonacci_sequence(limit)\n sum = 0\n fib_seq.each{|fib_num| fib_num%2 == 0 ? (sum += fib_num) : ()}\n\n return sum\nend", "def fib \n arr = [0, 1]\n\n while arr[-1] + arr[-2] <= 4_000_000\n arr << arr[-1] + arr[-2]\n end\n arr.select(&:even?).inject(:+)\nend", "def fibonacci\n @sequence = [1,1]\n x = 0\n while (@sequence[x+1] < 4e+6)\n @sequence << @sequence[x] + @sequence[x+1]\n x += 1\n end\n even? x\nend", "def even_fibonacci_number(n)\n sum = 0\n fib1 = 0\n fib2 = 1\n while fib2 < n\n temp = fib1\n fib1 = fib2\n fib2+=temp\n sum += fib2 if fib2.even?\n end\n p sum\nend", "def even_fibonacci_sum(limit)\n array = [0, 1]\n array << (array[-1] + array[-2]) while (array[-1] + array[-2]) < limit\n array.select(&:even?).reduce(:+)\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 euler2\n fibs = [1, 2]\n sum = 2\n fn = 0\n\n while fn < 4000000\n\n fn = fibs[fibs.length-1] + fibs[fibs.length-2]\n fibs.push(fn)\n\n if fn % 2 == 0\n sum = sum + fn\n end\n\n end\n\nend", "def sum_even_fibonacci(max)\r\n arr = [1,2]\r\n while arr[-1] + arr[-2] <= max\r\n arr << arr[-1] + arr[-2]\r\n end\r\n total = 0\r\n arr.each { |x| total += x if x.even? }\r\n total\r\nend", "def even_fibonacci_sum(limit)\n fibs = [1, 2]\n even_fibs = 2\n next_fib = 3\n\n while next_fib < limit\n fibs << next_fib\n #binding.pry\n even_fibs += next_fib if next_fib % 2 == 0\n next_fib += fibs[-2]\n end\n even_fibs\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 sumOfEvenFibonacciNumbersUnderN(n)\n\n return 0 if n <= 2 \n \n fibonacci = [0,1]\n total = 0\n\n until fibonacci.last >= n\n \tfibonacci << fibonacci.last + fibonacci[-2]\n \ttotal += fibonacci[-1] if fibonacci[-1].even? \n end\n\n total \n\nend", "def even_fibonacci_numbers\n a = 1\n b = 2\n\n total = b # b= 2, even number.\n\n while b < 4_000_000\n c = b\n b = a + b\n a = c\n if b % 2 == 0\n total += b\n end\n end\n puts total\nend", "def even_fibonacci(number)\n even_sum = 0\n fib1 = 1\n fib2 = 2\n fib_count = 0\n\n if number < 3\n even_sum = 0\n else\n while fib_count < number\n if fib2 % 2 === 0\n even_sum += fib2\n end\n fib_count = fib1 + fib2\n fib1 = fib2\n fib2 = fib_count\n end\n end\n\n puts even_sum\n return even_sum\nend", "def sum_of_even_fib(max)\n sum = 0\n fib = [0, 1, 1]\n\n while fib.last < max\n next_term = fib[-1] + fib[-2]\n fib << next_term\n sum += next_term if next_term.even?\n end\n\n puts sum\nend", "def sum_fib_evens(max)\n sum = 0\n n = 1\n while fibonacci(n) < max\n if fibonacci(n).even?\n sum += fibonacci(n)\n end\n n += 1\n end\n return sum\nend", "def fiboEvenSum(max)\n sequence([1,2], max).inject(0) do | sum, i |\n if i%2 == 0 \n sum + i\n else\n sum\n end\n end\nend", "def even_fibonnaci_numbers(number)\n first = 1\n second = 1\n fibonnaci = first + second\n total = 0\n\n until fibonnaci > number\n total += fibonnaci if fibonnaci.even?\n\n first = second\n second = fibonnaci\n fibonnaci = first + second\n end\n\n return total\nend", "def fib\n sum = 0\n a = 1\n b = 2\n while b < 4000000\n sum += b if b % 2 == 0\n a, b = b, a + b\n # sum += b if b % 2 == 0\n end\n puts sum\nend", "def sumOfEvenFibonacci(n)\n\t# sum of f(2),f(5),f(8),f(11),f(14),etc is needed. f(5) is 8, f(6) is 13, f(7) is 21\n\tsum = 10\n\tfn2 = 8\n\tfn1 = 13\n\tfn = 21\n\ti = 8\n\twhile (fn < n)\n\t\tif i % 3 == 0 then sum = sum + fn end\n\t\tfn2 = fn1\n\t\tfn1 = fn\n\t\tfn = fn1 + fn2\n\t\ti += 1\n\tend\n\treturn sum\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 fib_even_sum(n)\n fib_arr = [1, 1]\n sum = 0\n\n until fib_arr[-1] >= n\n fib_arr << (fib_arr[-2] + fib_arr[-1])\n sum += fib_arr[-2] if fib_arr[-2].even?\n end\n\n sum\nend", "def even_fibonacci_numbers(maxNumber)\n\n sum = 0\n\n previous_num = 1\n current_num = 2\n\n while(current_num < maxNumber)\n\n if(even?(current_num))\n sum += current_num\n end\n\n temp_current_num = current_num\n current_num += previous_num\n previous_num = temp_current_num\n\n end\n\n return sum\n\nend", "def fiboEvenSum(number)\n\tsum = 0\n\tpreviousDigit = 1\n\tfiboDigit = 0;\n\n\twhile fiboDigit < number\n\t\ttemp = fiboDigit\n\t\tfiboDigit += previousDigit\n\t\tpreviousDigit = temp\n\t\tif fiboDigit % 2 == 0\n\t\t\tsum += fiboDigit \n\t\tend\n\tend \n\tsum\nend", "def fibsum(n)\n\tsum = 0\n\tfib = [1,2]\n\ttest = fib[-1]\n\twhile test <= n:\n\t\tsum += test if test % 2 == 0\n\t\tfib << test + fib[-2]\n\t\tfib.shift\n\t\ttest = fib[-1]\n\tend\n\tp sum\nend", "def fibbernacho(number)\n\t\n\tprimer = [0,1,1]\n\tn= 0\n\tevensum = 0\nwhile n <=100 && primer.last < 5000000\n\tprimer << (primer.last + primer[-2])\n\tprimer.last\n\t\tif primer.last % 2 == 0\n \t\t evensum += primer.last\n\t\tend\n\tn+=1\n\tend\n\tputs \"The sum of all even Fibbonacci numbers in the sequence up to #{number} is #{evensum}\"\n\tputs \"The value chain: #{primer.inspect}\"\nend", "def fibonacci_numbers\n fibonacci_snapshot = [1,2]\n fibonacci_results = []\n loop do\n return fibonacci_results if fibonacci_snapshot[1] > 4_000_000\n fibonacci_snapshot << fibonacci_snapshot.reduce(:+)\n fibonacci_results << fibonacci_snapshot[0]\n fibonacci_snapshot.shift\n end\nend", "def even_fib_sum(array)\n# finds sum of array's even-valued terms\n array.select{ |i| i.even? }.reduce(&:+)\nend", "def sum_even_fib_terms(max)\n sum = 0\n \n # initialize sequence\n t0 = 1\n t1 = 2\n \n while t1 < max\n if t1 % 2 == 0\n sum += t1\n end\n\n # advance to next term in the sequence\n t2 = t0 + t1\n t0 = t1\n t1 = t2\n end\n\n sum\nend", "def Fibonacci_max()\n\ts = [1,1]\n\tputs s\n\tx = s.last\n\teven_sum = 0\n\twhile x < 4000000 \n\t\tc = s.count\n\t\tn = s[c-2]+s[c-1]\n\t\ts.push(n)\n\t\teven_sum = even_sum + n if n%2 == 0\n\t\tx = s.last\n\tend\t\n\ts.delete(s.last)\n\tputs even_sum\n\nend", "def fibonnaci_even(limit)\n fibonnacci = [1, 1]\n (1...limit).each { fibonnacci << fibonnacci.last(2).sum }\n fibo_even = fibonnacci.select { |num| num.even? }.sum\nend", "def sum_of_even_fibonaccis(limit)\n # Fibonacci sequence starts with 1,2\n holder = [1,2]\n\n # Adding the last 2 elements of the array together\n while (holder[-1] + holder[-2]) < limit\n # Push the sum of the last 2 numbers into the existing array\n holder << holder[-1] + holder[-2]\n # Repeat the while loop\n end\n # Return the array, but select only the even numbers and add them together\n return holder.select { |num| num.even? }.reduce(:+)\nend", "def even_fibonacci(limit)\r\n start = [1, 2]\r\n\r\n start << start.last(2).inject(:+) while start[-1] < limit\r\n\r\n start.select { |number| number.even? }.inject(:+)\r\nend", "def fibs_sum(n)\n return 1 if n == 1 || n == 2\n sum = 0\n sum += (fibs_sum(n - 1) + fibs_sum(n - 2))\n \n \nend", "def even_valued_number(x)\n fib_array = [0,1]\n x.times do\n fib_array << fib_array[-1] + fib_array[-2]\n end\n fib_array.find_all{ |number| number % 2 == 0}.reduce(:+)\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n - 1) + fibs_sum(n - 2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fib_sum(n)\n return n if ( 0..1 ).include? n\n ( fib_sum( n - 1 ) + fib_sum( n - 2 ) )\nend", "def is_fibonacci?(num)\n\tnum == 0 || num == 1\n\tfb_pair = [2,3]\n\n\twhile fb_pair.inject(:+) < num do\n\t\tfb_nxt_num = fb_pair.inject(:+)\n\t\tfb_pair.shift \n\t\tfb_pair << fb_nxt_num\n\tend\n\n\tfb_pair[0] + fb_pair[1] == num\n\nend", "def even_fibs(limit)\n a = []\n i = 0\n j = 1\n \n while j < limit do\n i, j = j, i+j\n a << j if j.even?\n end\n a.sum\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def fibs_sum(n)\n\nend", "def sum_even_fib(upper_limit)\n sum = fib0 = 0\n fib = 1\n while (fib < upper_limit)\n sum+= fib if(fib%2 == 0)\n temp = fib0\n fib0 = fib\n fib+= temp\n end \n sum\nend", "def even_fib_sum(n)\n f = ->(x){ x < 2 ? x : f[x-1] + f[x-2] }\n\n value =f[2]\n res = cnt = 0\n while value <= n\n res+=value if value.even?\n cnt+=1\n value=f[cnt]\n end\n res\nend", "def fibonacci_seq(max)\n first = 1\n second = 2\n sum = 2 # accounts for the first fibonacci pair\n while((first + second) < max)\n third = first + second\n first = second\n second = third\n sum += third if third.even?\n end\n puts sum\nend", "def evenFibs(num2)\n sumArray = []\n fib_index = 3\n a, b = 1, 1\n\n # push Fibonacci to array \n while fib_index <= num2\n c = a + b\n a = b\n b = c\n fib_index += 1\n\n if ((c % 2) == 0)\n sumArray.push c\n end\n end\n\n d = sumArray.inject(:+)\n\n puts d.to_s\n\nend", "def even_fibonacci(n)\n\tif n == 0\n\t\treturn 0\n\telsif n == 1\n\t\treturn 2\n\telse\n\t\treturn 4*even_fibonacci(n-1)+even_fibonacci(n-2)\n\tend\nend", "def fibs fib1 = 0, fib2 = 1\r\n fib1, fib2 = fib2, fib1 + fib2\r\n return 0 if fib1 > 4e6\r\n fib1 % 2 == 0 ? fibs(fib1, fib2) + fib1 : fibs(fib1, fib2)\r\nend", "def fibonacci_sum(limit)\r\n\tsum = 0\r\n\tprev_term = 1\r\n\tcurr_term = 2\r\n\twhile curr_term <= limit \r\n\t\tsum += curr_term if curr_term % 2 == 0\r\n\t\thold = curr_term\r\n\t\tcurr_term += prev_term\r\n\t\tprev_term = hold\r\n\tend\r\n\treturn sum\r\nend", "def even_fibs_recursive(num, term1 = 1, term2 = 2, sum = 2)\n \n next_term = term1 + term2\n return sum if next_term >= num\n\n sum += next_term if next_term % 2 == 0\n\n even_fibs_recursive(num, term2, next_term, sum)\n\nend", "def fibs_sum(n) # my version\n return 1 if n == 1\n return 2 if n == 2\n\n current = single_fib(n)\n current += fibs_sum(n - 1)\nend", "def fibSum someNumber\n currentNumber = 2\n lastNumber = 1\n sum = 0\n while currentNumber < someNumber\n sum += currentNumber if currentNumber % 2 == 0\n tempNumber = currentNumber\n currentNumber += lastNumber\n lastNumber = tempNumber\n end\n puts sum\nend", "def fib(first, second)\n temp_sum = first + second\n @sum += temp_sum if (temp_sum % 2).zero?\n first = second\n second = temp_sum\n\n fib(first, second) if temp_sum < 4000000\nend", "def fibevensum xmax\n a, b = 1, 2\n sum = 0\n while a < xmax\n sum += a if a.even?\n a, b = b, a + b\n end\n sum\nend", "def fib(n)\n #if n > 4000000\n #\treturn puts n\n #end\n return n if (0..1).include? n\n fib(n-1) + fib(n-2) if n > 1\nend", "def even_fibonacci(limit, current, prev, sum = 0)\n return sum if current >= limit\n\n sum += current if (current % 2).zero?\n current, prev = current + prev, current\n even_fibonacci(limit, current, prev, sum)\nend", "def sum_fibs(number)\n sum, previous_num, current_num = 0, 1, 0\n\n while current_num <= number\n sum += current_num if current_num.odd?\n current_num, previous_num = previous_num, (current_num + previous_num)\n end\n\n sum\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n [fib(n-1),fib(n-2)].reduce(:+)\n\t\nend", "def even_fibo_summer(upper_limit)\n f0 = 0\n f1 = 1\n sum = 0\n\n loop do\n f2 = f0 + f1\n break if f2 > upper_limit\n # puts \"f2 is #{f2}\"\n sum += f2 if (f2 % 2 == 0)\n # puts \" sum is #{sum}\"\n f0 = f1\n f1 = f2\n # puts \" f0 is now #{f0} and f1 is now #{f1}\"\n end\n\n puts \"The sum of the even-valued Fibonacci numbers under #{upper_limit} is #{sum}.\"\nend", "def fib(sum, curr, prev)\n if curr > 4_000_000\n puts sum\n return\n end\n if curr % 2 == 0\n sum += curr\n end\n fib(sum, prev + curr, curr)\nend", "def sum_of_fib(n)\n return fib(n+2)-1;\nend", "def sum_evens max_number\n fibonacci_array.each do |value|\n even_number_array << value if value.even?\n end\n even_number_array.sum\n end", "def generate_fibonacci_numbers(limit)\n i = 1\n fibonacci_numbers = [0, 1]\n sum = 0\n check = true\n\n while check == true do\n if fibonacci_numbers[i - 1] + fibonacci_numbers[i] > limit\n check = false\n else\n fibonacci_numbers << fibonacci_numbers[i - 1] + fibonacci_numbers[i]\n end\n\n i += 1\n end\n\n # return fibonacci_numbers.inspect\n\n fibonacci_numbers.each do |fib|\n if fib % 2 == 0\n sum += fib\n end\n end\n\n return sum\nend", "def fibs(n)\n list = [0, 1]\n if n == 0\n return []\n elsif n == 1\n return [0]\n elsif n == 2\n return [0, 1]\n else \n counter = 2\n while counter < n\n sum = 0\n list.each_with_index do |element, index|\n if index >= list.length - 2\n sum += element\n end\n end\n list.push(sum)\n counter += 1\n end\n end\n return list\nend", "def solution(number)\n sum = 2\n return 2 if number <= 2\n\n first_fib_num = 1\n second_fib_num = 2\n next_fib_num = 3\n count = 0\n\n while next_fib_num <= number\n if count == 3\n sum += next_fib_num\n count = 0\n end\n\n next_fib_num = first_fib_num + second_fib_num\n first_fib_num = second_fib_num\n second_fib_num = next_fib_num\n count += 1\n end\n p sum\nend", "def fibonacci(num)\n fib_nums = []\n (0...num).each do |i|\n if i == 0 || i == 1\n fib_nums << 1\n next\n end\n fib_nums << fib_nums[i-2] + fib_nums[i-1]\n end\n return fib_nums\nend", "def fibonacci_fast_doubling(n)\n return 1 if n <= 2\n\n nums = []\n while n > 0\n nums << n\n n /= 2\n end\n\n a = 0 # F(n) = F(0)\n b = 1 # F(n + 1) = F(1)\n\n until nums.empty?\n n = nums.pop\n c = a * ((2 * b) - a) # c = F(2n)\n d = b**2 + a**2 # d = F(2n + 1)\n if n.odd?\n a = d\n b = c + d\n else\n a = c\n b = d\n end\n end\n a\nend", "def fibonacci_evens_sum(limit)\n arr = []\n a,b = 0,1\n #While 'a' is less than the specified limit, the value of each subsequent number is the sum of the previous two,\n #creating the Fibonacci sequence.\n while a < limit\n arr << a\n a, b = b, a + b\n end\n #When the limit is reached the 'select' method returns an array of 'num's that are divisible by 2 with no remainder.\n #The 'reduce' method then adds every item in the returned array together. The 'reduce' method is just an alias for the \n #'inject' method, so they can be used interchangeably.\n sum = arr.select {|num| num % 2 == 0}.reduce(:+)\n puts sum\nend", "def fib(num_terms) \n last=0 #last value on the fibonacci sequence\n current=1 #last value plus itself\n term=0\n fib_even_number=0 #sum of even-valued numbers\n i=0 \n \n until i==num_terms #loop to retrieve fibonacci numbers\n term=last+current\n if i ==0 #esthetic if to have a fist term with no extra comma\n print \"#{term}\"\n else\n print \", #{term}\"\n end #if\n if term%2==0 #loop to retrieve even-valued numbers and add them\n fib_even_number+=term\n end #if\n last=current\n current=term\n i+=1\n end #until\n print \"\\n The sum of the even-valued numbers is: #{fib_even_number}\"\nend", "def fib(a, b, num)\n\tarr = []\n\tfib_num = 0\n\twhile fib_num < num\n\t\tfib_num = a + b\n\t\tarr << fib_num if fib_num < num\n\t\ta = b\n\t\tb = fib_num\n\tend\n\tadd_only_even(arr)\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n \n\n fib(n - 1) + fib(n - 2)\nend", "def naive_fib(number)\n return -1 if number < 0\n return 0 if number == 0# && (@operations += 1)\n return 1 if number == 1# && (@operations += 1)\n naive_fib(number-1) + naive_fib(number-2)\nend", "def fibonacci(number)\n if number < 2\n puts \"if: #{number}\" #sum comes from here... 8 x 1\n number\n else\n puts \"else: #{number} ==> #{number-1} + #{number-2}\"\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fib(n) (n<=2) ? 1 : (fib(n-2)+fib(n-1)) end", "def fibs(n) ; PHI**n - PHA**n ; end", "def get_all_fibs(num)\n a = 1; b = 2; c = 0;\n fibs = [a, b];\n while ((c = a + b) < num)\n fibs << c;\n a = b;\n b = c;\n end\n fibs.select {|x| x.even?}.inject(:+)\nend", "def calevensum\n @total = 0\n @i = 0\n \n while true\n @num = fib(@i)\n @i += 1;\n \n if @num < @max\n if @num % 2 == 0\n @total += @num\n end\n else\n break\n end\n end\n \n puts \"Sum = #{@total}!\"\n end", "def is_fibonacci?(num)\n fibonacci = [0,1]\n sum = 0\n while sum < num\n sum = fibonacci[-1] + fibonacci[-2]\n fibonacci.push(sum)\n end\n num == sum\nend", "def fibonacci(number)\n\tfibo = 0\n\tnumber1 = 0\n\tnumber2 = 1\n\tsum = 0\n\twhile(fibo < number)\n\t\tif(fibo < 2)\n\t\t\tfibo += 1\n\t\telse\n\t\t\tif(fibo % 2 == 0)\n\t\t\t\tsum += fibo\n\t\t\tend\n\t\t\tnumber1 = number2\n\t\t\tnumber2 = fibo\n\t\t\tfibo = (number2 + number1)\n\t\tend\n\tend\n\treturn sum\nend", "def fibs(num)\n array = []\n 0.upto(num) do |i|\n array << i if i.zero? || i == 1\n array << array[i - 1] + array[i - 2] if i > 1\n end\n array\nend", "def fibo(n)\n\n first = 0\n second = 1\n total = 0\n\n (1...n).each do\n total = first + second\n first = second\n second = total\n end\n return total\nend", "def nthFibonacci (n)\r\n # Your code here\r\n f = [0, 1, 1, 2, 3, 5, 8]\r\n if n < 7\r\n return f[n]\r\n end\r\n\r\n t = 6\r\n fn = 8\r\n\r\n while t < n\r\n fn = (fn * PHI).round(0)\r\n t += 1\r\n end\r\n\r\n return fn\r\nend", "def sum_of_fib_evens(limit_num)\n first = 1\n second = 2\n third = 3\n sum_evens = 2\n \n loop do\n first = second\n second = third\n third = first + second\n break if third > limit_num\n sum_evens += third if third.even?\n end\n \n sum_evens\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n return 1 if n == 2\n # return 2 if n == 3\n fib(n - 1) + fib(n - 2)\nend" ]
[ "0.8183116", "0.81647253", "0.8162808", "0.8140191", "0.8104084", "0.80710554", "0.80452245", "0.8018586", "0.8002838", "0.8002159", "0.7944863", "0.79199064", "0.7898868", "0.7892157", "0.78717613", "0.7871002", "0.78633225", "0.78596723", "0.7839053", "0.7823375", "0.781449", "0.77996665", "0.7792458", "0.7783854", "0.7729398", "0.7727074", "0.77224374", "0.7713582", "0.7698779", "0.7665862", "0.7625603", "0.76162523", "0.7613312", "0.75948703", "0.75832283", "0.7571102", "0.7555633", "0.7549394", "0.7534599", "0.75338817", "0.75321686", "0.7528454", "0.7527113", "0.7526083", "0.7519968", "0.7512773", "0.75020367", "0.7498935", "0.7498935", "0.7498935", "0.7498935", "0.7470824", "0.7457355", "0.7456021", "0.745391", "0.745391", "0.745391", "0.745391", "0.745391", "0.74515414", "0.7444138", "0.7432177", "0.7427223", "0.7419719", "0.74084395", "0.7400233", "0.7378036", "0.7373993", "0.7372681", "0.73711795", "0.7353134", "0.73426974", "0.7340374", "0.73379254", "0.73364216", "0.7317999", "0.7300729", "0.72963065", "0.7290491", "0.72422826", "0.72409075", "0.7228969", "0.72197914", "0.7203235", "0.7199436", "0.71862197", "0.7184499", "0.7178155", "0.7173511", "0.71725976", "0.7169135", "0.71626264", "0.7159784", "0.7159705", "0.71403784", "0.7137535", "0.7134832", "0.7132554", "0.7114156", "0.7101583", "0.70935524" ]
0.0
-1
Checks the AtomPub server at +uri+ for sanity. ==== Options uri the URI of the AtomPub server. Required. username an optional username for authentication password if a username is provided, a password is required. See Ape::Authent for more information. service_doc an optional service document. It'll be used instead of getting it from the uri. requested_e_coll a preferred entry collection to check requested_m_coll a preferred media collection to check
def check(uri, username=nil, password=nil, service_doc = nil, requested_e_coll = nil, requested_m_coll = nil) @authent = Authent.new(username, password) @reporter.header = uri ::Ape.conf[:REQUESTED_ENTRY_COLLECTION] = requested_e_coll if requested_e_coll ::Ape.conf[:REQUESTED_MEDIA_COLLECTION] = requested_m_coll if requested_m_coll begin might_fail(uri, service_doc) rescue Exception @reporter.error(self, "Ouch! Ape fall down go boom; details: " + "#{$!}\n#{$!.class}\n#{$!.backtrace}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_uri(uri)\n response = RestClient.get BASE_URI, :params => { :doc => uri, :out => 'json' }\n @json = JSON.parse(response.body)\n @errors = retrieve_errors\n end", "def validate_uri(uri)\n return validate({:doc => uri})\n end", "def validate_uri( uri, dir, doc )\n # do not retry external uris that have already been validated\n return if @valid_uris.include? uri.to_s\n\n return validate_relative_uri(uri, dir, doc) if uri.relative?\n return validate_external_uri(uri, dir, doc) if uri.respond_to? :open\n\n # otherwise, post a warning that the URI could not be validated\n @log.warn \"could not validate URI '#{uri.to_s}'\"\n end", "def validate_external_uri( uri, dir, doc )\n return unless @validate_externals\n\n if @invalid_uris.include? uri.to_s\n @log.error \"could not open URI '#{uri.to_s}'\"\n return\n end\n\n begin\n uri.open {|_| nil}\n @valid_uris << uri.to_s\n rescue Exception\n @log.error \"could not open URI '#{uri.to_s}'\"\n @invalid_uris << uri.to_s\n end \n end", "def verify_uri_acessibility uri\n res = Net::HTTP.get_response URI(uri)\n res.is_a? Net::HTTPSuccess\nend", "def check_collector_uri!\n raise ArgumentError, 'collector URI must be initialized' if @collector_uri.nil?\n end", "def validate_uri(uri)\n validate_text(Net::HTTP.get(URI.parse(uri)))\n end", "def initialize(uri)\n if uri.start_with?('mongodb://')\n uri = uri[10..-1]\n else\n raise MongoArgumentError, \"MongoDB URI must match this spec: #{MONGODB_URI_SPEC}\"\n end\n\n hosts, opts = uri.split('?')\n parse_options(opts)\n parse_hosts(hosts)\n validate_connect\n end", "def validate_uri(uri)\n return validate({:uri => uri})\n end", "def validate_uri(uri)\n unless uri.is_a?(String)\n return false\n end\n\n unless uri.slice(GIT_REGEXP).nil?\n return true\n end\n\n unless uri.slice(SCP_REGEXP).nil?\n return true\n end\n\n false\n end", "def validate_uri(uri)\n unless uri.is_a?(String)\n return false\n end\n\n unless uri.slice(SSH_REGEXP).nil?\n return true\n end\n\n unless uri.slice(GIT_REGEXP).nil?\n return true\n end\n\n false\n end", "def check_uri(uri)\n curl = Curl::Easy.new(uri)\n curl.ssl_verify_peer = false\n curl.follow_location = true\n curl.headers['User-Agent'] = 'static-site-generator-comparison-0.1.0.0'\n curl.headers['Accept'] = 'text/html,application/xhtml+xml,application/xml'\n begin\n curl.perform\n rescue Exception => e\n puts \"#{uri}: failed to curl\"\n raise e\n end\n\n unless curl.response_code == 200\n raise \"#{uri}: #{curl.response_code} response\"\n end\nend", "def query_user_for_uri\n input_uri = nil\n puts \"\\n* First, we need a valid uri.\"\n input_uri = valid_uri\n return input_uri\nend", "def verify_connection!(uri); end", "def valid?(uri)\n uri ||= default_uri\n\n uri.host = @default_host if uri.host.nil?\n\n real_domain = domain =~ /^\\./ ? domain[1..-1] : domain\n !!((!secure? || (secure? && uri.scheme == 'https')) &&\n uri.host =~ Regexp.new(\"#{'^' if @exact_domain_match}#{Regexp.escape(real_domain)}$\", Regexp::IGNORECASE))\n end", "def check (uri)\n return nil unless @enabled\n\n # FIXME check some time limits around this\n cache_name = translate_uri(uri)\n \n file = File.join(@directory, cache_name)\n File.exist?(file) and File.open(file) do |f|\n return OpenStruct.new(:body => f.read, :cache_file => file)\n end\n end", "def validate_server(name)\n return true unless name # if no name is provided, just go with the defaults\n\n valid = name.is_a? String\n begin\n u = URI.parse(name)\n valid = false unless u.is_a?(URI::HTTP) || u.is_a?(URI::HTTPS)\n rescue URI::InvalidURIError\n valid = false\n end\n valid || raise(Exceptions::InvalidOptions, 'Invalid server')\n end", "def validate_server(name)\n return true unless name # if no name is provided, just go with the defaults\n valid = name.is_a? String\n begin\n u = URI.parse(name)\n valid = false unless u.class == URI::HTTP || u.class == URI::HTTPS\n rescue URI::InvalidURIError\n valid = false\n end\n valid || raise(Exceptions::InvalidOptions, 'Invalid server')\n end", "def uri! uri, verb, http_version\n rv = Wrapper.msc_process_uri txn_ptr, (strptr uri), (strptr verb), (strptr http_version)\n rv == 1 or raise Error \"msc_process_uri failed for #{[uri, verb, http_version].inspect}\"\n\n intervention!\n end", "def validate\n unless self.uri.blank?\n self.uri = \"http://#{self.uri}\" unless URI.parse(self.uri).absolute? \n end\n rescue\n errors.add(:uri, \"malformed uri -- please check it\")\n end", "def probe_api_path(uri, path)\n uri = URI.join(uri, path)\n request = RestClient::Resource.new(uri.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)\n begin\n request.get\n rescue RestClient::Exception => exception\n response = exception.response\n logger.error \"#{self.class.name}#probe_api_path: exception probing uri: '#{uri}'. Exception: #{$ERROR_INFO}\"\n return false if response.nil?\n if response.code == 401\n www_authenticate = response.headers[:www_authenticate]\n if www_authenticate =~ /^Basic realm=\"?(RESTAPI|ENGINE)\"?$/\n return true\n end\n end\n end\n false\n end", "def check(uri,res)\r\n @results[:checked][uri]=true\r\n if res.code==\"404\"\r\n @results[:uris404] << uri\r\n return []\r\n elsif res.code==\"200\"\r\n @results[:uris200] << uri\r\n if uri.host != @baseURI.host or res['content-type'] != 'text/html'\r\n \t return []\r\n end\r\n links = @linkfinder.getLinks(res.body)\r\n [email protected](links,uri)\r\n returnedLinks=[]\r\n links.each {|link| \r\n if link.scheme != \"http\"\r\n\t @results[:urisNonHTTP] << link\r\n\telse\r\n\t if not @results[:checked].include? link\r\n @results[:checked][link]=true\r\n returnedLinks << link\r\n end\r\n\tend\r\n }\r\n return returnedLinks\r\n else\r\n @results[:urisUnknown] << {:code => res.code, :uri => uri}\r\n end\r\n return []\r\n end", "def process_request(uri)\n request = Net::HTTP::Get.new(uri)\n connection = Net::HTTP.start(uri.hostname, uri.port, use_ssl: https?(uri))\n\n connection\n .request(request)\n .tap(&method(:validate_response!))\n end", "def initialize(uri, options = nil)\n # lazy-load expensive gem code\n require 'addressable/uri'\n\n @uri = uri\n @uri_obj = parse(uri)\n @options = options || {}\n @options.freeze\n\n if @options['user']\n @user = @options['user']\n end\n\n if @options['password']\n @password = @options['password']\n end\n\n if @options['port']\n @port = @options['port']\n end\n\n if @options['protocol']\n @protocol = @options['protocol']\n end\n\n if @options['host']\n @host = @options['host']\n end\n\n # WARNING: name should never be updated\n @name = @options['name'] || @uri\n end", "def within_realm? uri\n uri = URI.parse(uri.to_s)\n realm = URI.parse(self.realm)\n return false unless uri.absolute?\n return false unless uri.path[0, realm.path.size] == realm.path\n return false unless uri.host == realm.host or realm.host[/^\\*\\./]\n # for wildcard support, is awkward with URI limitations\n realm_match = Regexp.escape(realm.host).\n sub(/^\\*\\./,\"^#{URI::REGEXP::PATTERN::URIC_NO_SLASH}+.\")+'$'\n return false unless uri.host.match(realm_match)\n return true\n end", "def check\n # we want to handle cases where the port/target isn't open/listening gracefully\n begin\n # only catch the response if we're going to use it, in this case we do for the version\n # detection.\n res = send_request_cgi(\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'method' => 'GET'\n )\n # gracefully handle if res comes back as nil, since we're not guaranteed a response\n # also handle if we get an unexpected HTTP response code\n fail_with(Failure::UnexpectedReply, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n fail_with(Failure::UnexpectedReply, \"#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}\") if res.code == 200\n\n # here we're looking through html for the version string, similar to:\n # Version 1.2\n /Version: (?<version>[\\d]{1,2}\\.[\\d]{1,2})<\\/td>/ =~ res.body\n\n if version && Gem::Version.new(version) <= Gem::Version.new('1.3')\n vprint_good(\"Version Detected: #{version}\")\n Exploit::CheckCode::Appears\n end\n rescue ::Rex::ConnectionError\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n end\n Exploit::CheckCode::Safe\n end", "def ensure_uri(uri)\n raise ArgumentError, \"ensure_uri: uri may not be nil\" if uri.nil?\n is_uri?(uri) ? uri : URI.parse(uri)\n end", "def acceptable_from_uri?(uri)\n uri = URI(uri)\n\n host = DomainName.new(uri.host)\n\n # RFC 6265 5.3\n if host.hostname == @domain\n true\n elsif @for_domain # !host-only-flag\n host.cookie_domain?(@domain_name)\n else\n @domain.nil?\n end\n end", "def validate_uri(uri)\n unless uri.is_a?(String)\n return false\n end\n\n unless uri.slice(HG_REGEXP).nil?\n return true\n end\n\n false\n end", "def infer_scm_from_uri\n if @uri\n if (@scm = SCM.infer_from_uri(@uri))\n return true\n end\n end\n\n return false\n end", "def perform_discovery(uri)\n begin\n parsed_uri = URI::parse(uri)\n if parsed_uri.scheme.nil?\n return discover_site(uri)\n end\n return discover_user(parsed_uri.host, uri)\n rescue\n # If we fail, just return nothing and fallback on default discovery mechanisms\n return nil\n end\n end", "def validate\n return false unless @digest_parts.any? # RUBY\n\n a2 = @request.method + ':' + @digest_parts['uri']\n\n if @digest_parts['qop'] == 'auth-int'\n # Making sure we support this qop value\n return false unless @qop & QOP_AUTHINT\n\n # We need to add an md5 of the entire request body to the A2 part of the hash\n body = @request.body_as_string\n @request.body = body\n\n a2 << ':' + ::Digest::MD5.hexdigest(body)\n else\n # We need to make sure we support this qop value\n return false unless @qop & QOP_AUTH\n end\n\n a2 = ::Digest::MD5.hexdigest(a2)\n valid_response = ::Digest::MD5.hexdigest(\"#{@a1}:#{@digest_parts['nonce']}:#{@digest_parts['nc']}:#{@digest_parts['cnonce']}:#{@digest_parts['qop']}:#{a2}\")\n\n @digest_parts['response'] == valid_response\n end", "def validate(hydra, &on_complete)\n raise 'link has no queue to use' if not @queue\n\n puts \"querying #{uri}\" if @opts[:verbose]\n\n tries = 0\n\n begin\n #\t\t\trequest = Typhoeus::Request.new(uri.to_s, method: (@opts[:duplicate] ? :get : :method), auth_method: :auto, proxy_auth_method: :auto)\n opts = {\n headers: @@HTTP_header.merge(@opts[:duplicate] ? {} : { 'Accept' => 'text/html,application/xhtml+xml,application/xml,text/css,text/javascript' }),\n }\n\n # set up the proxy and proxy auth on the request if necessary\n proxy = self.proxy\n if proxy\n puts \"using proxy #{proxy[2]}:#{proxy[3]}@#{proxy[0]}:#{proxy[1]}\" if @opts[:verbose]\n opts.proxy = \"http://#{proxy[0]}:#{proxy[1]}\"\n if not proxy[2].empty?\n opts.proxy_username, opts.proxy_password = proxy[2], proxy[3]\n elsif @@userpass_list[:proxy]\n opts.proxy_username, opts.proxy_password = @@userpass_list[:proxy]\n end\n end\n\n # set up the auth on the request if necessary\n if uri.userinfo\n opts.username = uri.user\n opts.password = uri.password\n elsif @@userpass_list[uri.host]\n opts.username, opts.password = @@userpass_list[uri.host]\n end\n\n request = Typhoeus::Request.new(uri.to_s, opts)\n\n request.on_complete {|response|\n puts 'processing response from ' + uri.to_s if @opts[:verbose]\n\n if response.code == 401 or response.code == 407\n # the request requires authentication so ask the user for username and password\n # XXX there's a race here between setting userpass_list, queuing the request, and then an intervening request checking the unconfirmed userpass at the code above\n host = (response.code == 401 ? uri.host : :proxy)\n puts 'asking for ' + uri.to_s\n userpass = LinkToLoad.ask_for_userpass((host == :proxy ? 'proxy for ' : '') + uri.to_s)\n if userpass.empty?\n @@userpass_list[host] = false\n process_response(response)\n else\n @@userpass_list[host] = userpass\n if host == :proxy\n $stderr.puts \"setting proxy auth: #{userpass}\"\n request.proxy_username, request.proxy_password = userpass\n else\n request.username, request.password = userpass\n end\n hydra.queue(request)\n end\n else\n process_response(response)\n end\n\n on_complete\n }\n\n hydra.queue(request)\n rescue OpenURI::HTTPError\n @queue.invalidate(InvalidURI::General_error, msg: \"#{$!.class} - #{$!}\")\n rescue Timeout\n tries += 1\n retry unless tries > 2\n @queue.invalidate(InvalidURI::Timeout)\n end\n end", "def validate_relative_uri( uri, dir, doc )\n return validate_anchor(uri, doc) if uri.path.empty?\n\n path = if uri.path =~ %r/^\\//\n ::File.join(::Webby.site.output_dir, uri.path)\n else\n ::File.join(dir, uri.path)\n end\n path = ::File.join(path, 'index.html') if ::File.extname(path).empty?\n\n uri_str = path.dup\n (uri_str << '#' << uri.fragment) if uri.fragment\n return if @valid_uris.include? uri_str\n\n if test ?f, path\n valid = if uri.fragment\n validate_anchor(uri, Hpricot(::File.read(path)))\n else true end\n @valid_uris << uri_str if valid\n else\n @log.error \"invalid URI '#{uri.to_s}'\"\n end\n end", "def [](uri = nil)\n return @collection unless uri\n\n begin\n parsed_uri = URI.parse uri\n rescue URI::InvalidURIError\n raise ArgumentError, \"(#{uri}) is not a uri\"\n end\n\n raise ArgumentError, \"(#{uri}) does not contain theplatform in it.\" unless parsed_uri.host&.include? \"theplatform\"\n\n c = create_connection parsed_uri unless @collection.include? parsed_uri.host\n @collection.push c\n @collection.last\n c\n end", "def uri_available?(uri)\n open(uri) rescue false\n end", "def verify\n @request = Net::HTTP::Get.new(@uri.path)\n @request.basic_auth @username, @password\n\n @response = @http.request(@request)\n @response.code.to_i == 200\n\n rescue Errno::ETIMEDOUT, Exception\n false\n end", "def uri?\n !!@uri\n end", "def uri?\n !!@uri\n end", "def exists?(uri)\n uri = URI.parse(uri) if uri.is_a? String\n begin\n self.propfind(uri.path)\n rescue Net::HTTPServerException => e\n return false if(e.to_s =~ /404/)\n end\n return true\n end", "def uri_eligible?(uri)\n eligible = uri =~ /#{Regexp.escape(@config[:base_url])}/\n debug \"Islandora uri eligible: #{uri}\" if eligible\n eligible\n end", "def find_by_uri(uri, principal_prefix)\n end", "def valid_uri?\n !self.contentable.blank? || !self.uri_path.blank?\n end", "def verify_url!\n fail InvalidUrlException unless uri.to_s =~ URI::regexp\n fail UnsupportedFileException if !valid_readers_format? && !valid_file_format?\n end", "def check\n\n # get enriched entity\n require_enrichment\n uri = _get_entity_name\n headers = {\n Referer: \"#{uri}\"\n }\n\n # check if vuln\n response = http_request :get, \"#{uri}?displayName=whatever&filepath=../../boot.ini\", nil, headers\n if response.code.to_i == 200 && response.body_utf8 =~ /operating systems/\n _log \"Vulnerable!\"\n return \"Retrieved contents of boot.ini file: #{response.body_utf8}\"\n end\n\n # if original URI didn't work, lets try the default url\n _log \"Testing at /vsaPres/web20/core/Downloader.ashx\"\n uri_obj = URI(uri)\n endpoint = \"#{uri_obj.scheme}://#{uri_obj.hostname}:#{uri_obj.port}/vsaPres/web20/core/Downloader.ashx?displayName=whatever&filepath=../../boot.ini\"\n response = http_request :get, endpoint, nil, headers\n if response.code.to_i == 200 && response.body_utf8 =~ /operating systems/\n _log \"Vulnerable!\"\n return \"Retrieved contents of boot.ini file: #{response.body_utf8}\"\n end\n end", "def validate_anchor( uri, doc )\n return false if uri.fragment.nil?\n\n anchor = '#' + uri.fragment\n if doc.at(anchor).nil?\n @log.error \"invalid URI '#{uri.to_s}'\"\n false\n else true end\n end", "def realm(uri); end", "def here?(uri)\n current_server.here?(uri) rescue false\n # (current_server.uri rescue nil) == uri\n end", "def cas_server_is_up?\n uri = URI.parse(login_url)\n \n log.debug \"Checking if CAS server at URI '#{uri}' is up...\"\n \n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = (uri.scheme == 'https')\n https.verify_mode = (@force_ssl_verification ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE)\n \n begin\n raw_res = https.start do |conn|\n conn.get(\"#{uri.path}?#{uri.query}\")\n end\n rescue Errno::ECONNREFUSED => e\n log.warn \"CAS server did not respond! (#{e.inspect})\"\n return false\n end\n \n log.debug \"CAS server responded with #{raw_res.inspect}:\\n#{raw_res.body}\"\n \n return raw_res.kind_of?(Net::HTTPSuccess)\n end", "def allows?(uri)\n return true if everyone_allowed_everywhere?\n return false if noone_allowed_anywhere\n return true if current_agent_allowed?(uri) \n end", "def fetch_xml(uri)\n http = Net::HTTP.new(uri.host, uri.port)\n\n if uri.scheme == 'https'\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n http.read_timeout = GoogleCustomSearch.configuration.timeout\n\n request = Net::HTTP::Get.new(uri.request_uri)\n request.initialize_http_header({ 'User-Agent' => user_agent })\n\n response = http.request(request)\n\n raise GoogleCustomSearch::InvalidRequest if response.code.match(/[34]\\d{2}/)\n raise GoogleCustomSearch::ServerError if response.code.match(/5\\d{2}/)\n\n response.body\n end", "def run\n @uri = urlize()\n validate_content validate_url( @uri, 'rt' ).read\n end", "def verify_access\n authenticate_or_request_with_http_basic(\"Documents Realm\") do |username, password|\n username == 'rdi' && password == 'btc'\n end\n end", "def fetch_server(uri)\n @server[uri]\n end", "def is_uri?(uri)\n URI::Generic===uri\n end", "def matches?(uri)\n !expired? && valid?(uri) && uri.path.start_with?(path)\n end", "def on_request_uri(cli, request)\n\t\tprint_status(\"#{cli.peerhost} is trying to request our malicious file...\")\n\t\tprint_status(\"#{request.uri}\")\n\tend", "def setup_request(uri)\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\n end", "def require_master_collection(args)\n args = args.to_sym if args.is_a?(String)\n\n args_are_not_a_valid_hash =\n !args.is_a?(Hash) ||\n args.empty? ||\n !Set[*args.keys].subset?(Set[:restrict_to, :max, :min])\n\n if !args.is_a?(Symbol) && args_are_not_a_valid_hash\n fail_test(\"The require_master_collection DSL structure accepts ether a String/Symbol that specifies the collection, or a non-empty Hash consisting of only the keys :max or :min. You passed-in an argument of type #{args.class} with value #{args}.\")\n end\n\n server_version = puppetserver_version_on(master)\n server_collection = puppet_collection_for(:puppetserver, server_version)\n msg_prefix = \"This master is set up with a puppetserver from the #{server_collection} collection.\"\n\n if args.is_a?(Symbol)\n collection = args.to_s\n\n unless collection.include?(server_collection)\n skip_test(msg_prefix + \"\\nThis test requires a puppetserver from the #{collection} collection. Skipping the test ...\")\n end\n\n return\n end\n\n # At this part of the method, we are guaranteed that at least one of\n # min_collection and max_collection are specified\n min_collection = args[:min]\n max_collection = args[:max]\n\n if min_collection.nil?\n # only max_collection is specified\n if collection_cmp(max_collection, server_collection) < 0\n skip_test(msg_prefix + \" This test requires a puppetserver from the #{max_collection} collection or older. Skipping the test ...\")\n end\n # only min_collection is specified\n elsif max_collection.nil?\n if collection_cmp(server_collection, min_collection) < 0\n skip_test(msg_prefix + \" This test requires a puppetserver from the #{min_collection} collection or newer. Skipping the test ...\")\n end\n elsif collection_cmp(server_collection, min_collection) < 0 || collection_cmp(max_collection, server_collection) < 0\n # both min_collection and max_collection are specified\n skip_test(msg_prefix + \" This test requires a puppetserver that's from the #{min_collection} collection or newer, but not newer than the #{max_collection} collection. Skipping the test ...\")\n end\n end", "def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend", "def with_uri_credentials(uri); end", "def object_exists?(uri)\n url = uri\n request = Request.new(\"Get\", url)\n response = request.perform\n exists = (response and response.code.to_i == 200) ? true : false\n exists\n end", "def is_red_herring?(uri)\n org_data_root = \"http://data.artsapi.com/id/organisations/\"\n\n !!([\n \"#{org_data_root}hotmail-com\",\n \"#{org_data_root}hotmail-co-uk\",\n \"#{org_data_root}live-com\",\n \"#{org_data_root}live-co-uk\",\n \"#{org_data_root}outlook-com\",\n \"#{org_data_root}outlook-co-uk\",\n \"#{org_data_root}gmail-com\",\n \"#{org_data_root}gmail-co-uk\",\n \"#{org_data_root}googlemail-com\",\n \"#{org_data_root}googlemail-co-uk\"\n ].include?(uri))\n end", "def valid?\n value.present? && uri.present?\n end", "def validate_uri(url)\n return validate({:url => url})\n end", "def valid_recipient_url?\r\n begin\r\n response_object = REXML::XPath.first(document, \"/p:Response\", { \"p\" => PROTOCOL })\r\n recipient = response_object.attribute('Recipient').value\r\n raise SA1005Exception unless recipient == settings.assertion_consumer_service_url\r\n rescue RuntimeError => exp\r\n Rails.logger.error \"#{exp.class} - #{exp.message}\"\r\n return false\r\n else\r\n return true\r\n end\r\n end", "def read_uri(uri)\n puts \"Making MCO service request: #{uri.to_s}\"\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri)\n request['Avalon-Api-Key'] = Rails.application.secrets[:avalon_token]\n http.request(request)\n end", "def external_user?\n case uri_options[:auth_mech]\n when :mongodb_x509, :aws\n true\n when nil, :scram, :scram256\n false\n else\n raise \"Unknown auth mechanism value: #{uri_options[:auth_mech]}\"\n end\n end", "def assure_uri(resource)\n resource.retrieve! unless resource['uri']\n raise IncompleteResource, \"#{resource.class}: #{resource['name']} not found\" unless resource['uri']\n end", "def open_server(uri, config, first=true)\n @protocol.each do |prot|\n begin\n return prot.open_server(uri, config)\n rescue DRbBadScheme\n end\n end\n if first && (config[:auto_load] != false)\n auto_load(uri, config)\n return open_server(uri, config, false)\n end\n raise DRbBadURI, 'can\\'t parse uri:' + uri\n end", "def do_request(uri, parse, method = \"GET\", args = {})\n uri = URI(uri)\n\n case method\n when \"POST\"\n req = Net::HTTP::Post.new(uri.request_uri)\n when \"PATCH\"\n req = Net::HTTP::Post.new(uri.request_uri)\n else\n req = Net::HTTP::Get.new(uri.request_uri)\n end\n\n if not args.empty?\n req.body = args.to_json\n end\n\n req.basic_auth AUTH[\"user\"], AUTH[\"pw\"]\n\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme.eql? \"https\"\n http.use_ssl = true\n end\n res = http.start do |http| http.request(req) end\n if parse\n res = JSON.parse(res.body)\n else\n res = res.body\n end\n res\n end", "def verify_connection!(uri)\n if default_options.persistent? && uri.origin != default_options.persistent\n raise StateError, \"Persistence is enabled for #{default_options.persistent}, but we got #{uri.origin}\"\n end\n\n # We re-create the connection object because we want to let prior requests\n # lazily load the body as long as possible, and this mimics prior functionality.\n return close if @connection && ([email protected]_alive? || @connection.expired?)\n\n # If we get into a bad state (eg, Timeout.timeout ensure being killed)\n # close the connection to prevent potential for mixed responses.\n return close if @state == :dirty\n end", "def initialize uri\n\t\tset_proxy ENV['http_proxy'] if ENV['http_proxy']\n\t\t\t\t\t\t\n\t\tif uri.class == String\n\n\t\t\tunless uri =~ /^https?:\\/\\//\n\t\t\t\turi = \"http://#{uri}\"\n\t\t\tend\n\n\t\t\turi = URI.parse uri\n\n\t\tend\n\t\t@uri = uri\n\t\tif [email protected] || \"\" == @uri.path.strip\n\t\t\[email protected]=\"/\"\n\t\tend\n\n\n\t\t@request_headers={}\n\t\t@response_headers={}\n\t\t@cookies=[]\n\t\t@response_handlers=RESPONSE_HANDLERS.clone\n\t\t@follow_num_redirects=5\n\n\t\tif @uri.user\n\t\t\tbasic_authentication @uri.user, @uri.password\n\t\tend\n\n\tend", "def check_for_neo4j(neo4j_uri)\n begin\n http = Net::HTTP.new(neo4j_uri.host, neo4j_uri.port)\n request = Net::HTTP::Get.new(neo4j_uri.request_uri)\n request.basic_auth(neo4j_uri.user, neo4j_uri.password) if (neo4j_uri.user)\n response = http.request(request)\n\n if response.code != '200'\n abort \"Sad face. Neo4j does not appear to be running. #{neo4j_uri} responded with code: #{response.code}\"\n end\n rescue\n abort \"Sad face. Neo4j does not appear to be running at #{neo4j_uri} (\" + $!.to_s + ')'\n end\n puts \"Awesome! Neo4j is available at #{neo4j_uri}\"\nend", "def parse_arguments(args)\n raise UsageError, \"usage is: obsoleteUriChecker.rb <directory_root> <obsolete_uri_file> <known_exceptions_file> [complete]\" unless (3..4).include?(args.length)\n\n\tif args[3]\n\t\traise UsageError, \"If provided, the 4th argument must be 'complete'\" unless args[3].downcase == 'complete'\n\t\tcomplete = true\n\telse\n\t\tcomplete = false\n\tend\n\t\n directory_root = args[0]\n raise UsageError, \"Directory '#{directory_root}' does not exist.\" unless File.exist?(directory_root)\n raise UsageError, \"Directory '#{directory_root}' is not a directory.\" unless File.directory?(directory_root)\n\n obsolete_uri_file = args[1]\n raise UsageError, \"File '#{obsolete_uri_file}' does not exist.\" unless File.exist?(obsolete_uri_file)\n obsolete_uris = ObsoleteUris.new(obsolete_uri_file)\n\n known_exceptions_file = args[2]\n raise UsageError, \"File '#{known_exceptions_file}' does not exist.\" unless File.exist?(known_exceptions_file)\n known_exceptions = KnownExceptions.new(directory_root, known_exceptions_file)\n\n return directory_root, obsolete_uris, known_exceptions, complete\n end", "def invalid_uri!(string)\n msg = %{\nThe given connection string is invalid:\n #{string.gsub(/[^:]+@/, '<password>@')}\n\nMongoDB connection strings must be of the format:\n mongodb://host:port/database\n\nFor authentication, include username and password before host:\n mongodb://username:password@host:port/database\n\nFor Replica Sets, include multiple host:port entries:\n mongodb://host:port,host2:port2/database\n\nFor options, use query string syntax with the option value:\n mongodb://host:port/database?safe=true&max_retries=30&timeout=5\n }\n raise Errors::InvalidMongoURI, msg\n end", "def from_uri(uri)\n uri = get_uri_from_uri(uri)\n Discodactyl.log.debug(\"got xrd host-meta uri: #{uri}\") if Discodactyl.log\n begin\n raw = uri.open\n rescue OpenURI::HTTPError => error\n if error.io.status[1] == 'Not Found'\n error.io.base_uri = uri\n raise HostMetaHTTPError.new(error.message, error.io)\n else\n raise\n end\n rescue ::SocketError => error\n raise HostMetaSocketError.new(error.message, uri.host, uri.port)\n end\n self.parse raw\n end", "def queryOS(args)\n begin\n p = Hash.new\n uri = URI(args[:entrypoint])\n p[\"header\"] = {'Content-type'=>'application/json','Accept-type'=>'application/json','X-Auth-Token'=>args[:token]}\n case args[:component].to_s\n when \"Nova\"\n p[\"port\"] = uri.port || 8774\n\tp[\"path\"] = uri.path\n when \"Glance\"\n p[\"port\"] = uri.port || 9292\n p[\"path\"] = uri.path || \"/v1\"\n when \"Volume\"\n p[\"port\"] = uri.port || 8776\n\tp[\"path\"] = uri.path\n when \"Swift\" \n p[\"port\"] = uri.port || 8080\n\tp[\"path\"] = uri.path\n when \"Keystone\"\n p[\"port\"] = uri.port || 35357\n p[\"path\"] = uri.path || \"/v2/tokens\"\n when \"Cloud\"\n p[\"port\"] = uri.port || 8773\n p[\"path\"] = uri.path || \"/services/Cloud\"\n p[\"header\"] = {'Content-type'=>'application/xml','Accept-type'=>'application/xml'}\n else\n return false\n end\n p[\"location\"] = uri.host || \"\"\n p[\"path\"] = p[\"path\"] + args[:path] || uri.path\n p[\"request\"] = args[:request] || \"\"\n os = Net::HTTP.new(p[\"location\"],p[\"port\"])\n if uri.scheme == \"https\"\n os.use_ssl = true\n else\n os.use_ssl = false\n end\n resp = nil\n case args[:method].to_s\n when \"post\"\n resp = os.post(p[\"path\"], p[\"request\"], p[\"header\"])\n when \"get\"\n resp = os.get(p[\"path\"], p[\"header\"])\n when \"update\"\n resp = os.put(p[\"path\"], p[\"request\"], p[\"header\"])\n when \"delete\"\n resp = os.delete(p[\"path\"], p[\"header\"])\n end\n newdata = false\n if resp.code.to_i >= 200 and resp.code.to_i < 300\n if args[:component].to_s == \"Cloud\"\n newdata = resp.body\n else\n\t if args[:method].to_s == \"delete\"\n\t newdata = true\n else\n newdata = JSON resp.body\n end\n end\n end\n os = nil\n p = nil\n return newdata\n rescue Errno::EHOSTUNREACH\n false\n end\n end", "def here?(uri)\n @exported_uri.include?(uri)\n end", "def check_for_neo4j(neo4j_uri)\n begin\n http = Net::HTTP.new(neo4j_uri.host, neo4j_uri.port)\n request = Net::HTTP::Get.new(neo4j_uri.request_uri)\n request.basic_auth(neo4j_uri.user, neo4j_uri.password) if (neo4j_uri.user)\n response = http.request(request)\n\n if (response.code != \"200\")\n abort \"Sad face. Neo4j does not appear to be running. #{neo4j_uri} responded with code: #{response.code}\"\n end\n rescue\n abort \"Sad face. Neo4j does not appear to be running at #{neo4j_uri} (\" + $!.to_s + \")\" \n end\n puts \"Awesome! Neo4j is available at #{neo4j_uri}\"\nend", "def valid_endpoint(ep)\n if ep == nil\n raise ArgumentError, \"Request: An endpoint must be set\", caller\n elsif not ep.is_a? String\n raise TypeError, \"Request: An endpoint must be a string\", caller\n elsif ep.length == 0 # If endpoint was set to \"\"\n raise TypeError, \"Request: Endpoint cannot be empty\", caller\n elsif ep[0] != '/'\n raise ArgumentError, \"Request: Endpoint must begin with a '/'\", caller\n end\n\n # If we make it to here, we're good - so just return the endpoint\n ep\n end", "def initialize( uri, options = {} )\n @uri = uri\n @addr = \"#{@uri.host}:#{@uri.port}\"\n @options = options\n @closed = false\n end", "def current_agent_allowed?(uri)\n # be a good net citizen and set your user-agent!\n if @user_agent.nil? || @user_agent.empty?\n # log to logger that the user agent wasn't set\n log('*'*5 + ' ROBOTO: cannot determine if your bot is allowed since you did not ser the user-agent. \n Set it in the open_r options hash like so\n \\'user-agent\\' => \\'YOUR BOT\\'s NAME\\' and try again.')\n return false\n end\n \n # This will also bring us the user-agent * (for everyone) and any matches we find\n user_agents = @perms.keys.select {|k| (@user_agent == k) || (@user_agent.include?(k.gsub(/(\\*.*)/, ''))) }\n user_agents.each do |ua|\n @perms[ua]['disallow'].each do |r|\n return true if r == ''\n return false if r == '/' || uri.include?(r) || uri.include?(r.gsub(/\\*/, ''))\n end\n end\n \n # the uri isn't specifially disallowed for this user-agent \n # so let it through\n true\n end", "def has_connection_with?(uri)\n get_connected_uri.include?(uri)\n end", "def check_server\n raise Exception.new(\"Could not reach Apocalypse server please check the address and port and try again.\") unless server_reachable?\n end", "def initialize(uri, options = {})\n raise Errors::InvalidURI if invalid_uri?(uri)\n @uri = uri\n @options = DEFAULTS.merge(options)\n raise Errors::InvalidFormat if invalid_format?(@options[:format])\n @repo = nil\n @data = {}\n fetch_repo\n setup_data_hash\n end", "def propertyElementURI_check(el)\n if (CORE_SYNTAX_TERMS + [RDF_NS.Description.to_s] + OLD_TERMS).include?(el.uri.to_s)\n warn = \"Invalid use of rdf:#{el.name}\"\n add_debug(el, warn)\n raise InvalidPredicate.new(warn) if @strict\n end\n end", "def invalid_uri?(uri)\n uri.grep(/^(#{PROTOCOLS.join('|')}):\\/\\/\\w/).empty?\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 valid?\n !( @definition.nil? && @uri.nil? )\n end", "def open_uri_or_path(uri, &block)\n if file_uri?(uri)\n open(get_file_uri_path(uri), &block)\n else\n connection_options = {\n \"User-Agent\" => \"RubyGems/#{Gem::RubyGemsVersion} #{Gem::Platform.local}\"\n }\n\n if @proxy_uri\n http_proxy_url = \"#{@proxy_uri.scheme}://#{@proxy_uri.host}:#{@proxy_uri.port}\" \n connection_options[:proxy_http_basic_authentication] = [http_proxy_url, unescape(@proxy_uri.user)||'', unescape(@proxy_uri.password)||'']\n end\n\n uri = URI.parse uri unless URI::Generic === uri\n unless uri.nil? || uri.user.nil? || uri.user.empty? then\n connection_options[:http_basic_authentication] =\n [unescape(uri.user), unescape(uri.password)]\n end\n\n open(uri, connection_options, &block)\n end\n end", "def can_access(u)\n if $config.options['debug']\n puts(\"ident: #{@ident} vs. #{u.ident}\")\n puts(\" host: #{@host} vs. #{u.rhost}\")\n puts(\" cert: #{@certfp} vs. #{u.certfp}\")\n puts(\" acct: #{@account} vs. #{u.su}\")\n puts(\"matc1: #{Match.match(@ident, u.ident, true)}\")\n puts(\"matc2: #{Match.match(@host, u.rhost, true)}\")\n puts(\" cert: #{(u.certfp && @certfp && u.certfp == @certfp)}\")\n puts(\" acct: #{u.su && @account && u.su == @account}\")\n end\n #identmatch = match(@ident, u.ident, true)\n #hostmatch = match(@host, u.rhost, true)\n #certfpmatch = u.certfp && @certfp && u.certfp\n Match.match(@ident, u.ident, true) && (Match.match(@host, u.rhost, true) ||\n Match.match(@host, u.ip, true))\n ((u.certfp && @certfp && u.certfp == @certfp) ||\n (u.su && @account && u.su == @account)) &&\n # Invalid O:line\n !(!@account && !@certfp)\n end", "def validate_uri(url)\n !!URI.parse(url)\n end", "def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end", "def check_uri\n \tif current_user.nil? and !/^www/.match(request.host) and !/^localhost/.match(request.host)\n \t\tredirect_to request.protocol + \"www.\" + request.host_with_port + request.fullpath\n \tend\n end", "def uri_option(uri, config, first=true)\n @protocol.each do |prot|\n begin\n uri, opt = prot.uri_option(uri, config)\n # opt = nil if opt == ''\n return uri, opt\n rescue DRbBadScheme\n end\n end\n if first && (config[:auto_load] != false)\n auto_load(uri, config)\n return uri_option(uri, config, false)\n end\n raise DRbBadURI, 'can\\'t parse uri:' + uri\n end", "def term_id_expects_uri?\n return false if term_config.nil? || !(term_config.key? :term_id)\n term_config[:term_id] == \"URI\"\n end", "def uri_parse(uri)\n\t\t\tif uri == ''\n\t\t\t\tprint_error(\"URI required\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tregexstr = '^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?'\n\n\t\t\tregexurl = Regexp.new(regexstr, false)\n\t\t\tret = regexurl.match(uri)\n\n\t\t\treturn ret\n\t\tend", "def initialize(uri)\n raise ArgumentError, \"No blank URI allowed here\" if(uri.to_s.blank?)\n @uri = N::URI.new(uri)\n end", "def add_auth(uri, user, password, realm = T.unsafe(nil), domain = T.unsafe(nil)); end" ]
[ "0.5805499", "0.5657943", "0.5632669", "0.54668003", "0.5301297", "0.5278516", "0.52320725", "0.5227043", "0.5212603", "0.51234555", "0.5104248", "0.5096873", "0.5093398", "0.50643986", "0.50492966", "0.5000894", "0.49676612", "0.4963593", "0.49631557", "0.49418417", "0.48437443", "0.48372585", "0.4810683", "0.48069632", "0.48035893", "0.47881", "0.47782248", "0.47603083", "0.4737605", "0.47292608", "0.4704248", "0.46655247", "0.46456555", "0.46405664", "0.46202847", "0.46021605", "0.45986542", "0.45913708", "0.45913708", "0.45819", "0.45600197", "0.45583725", "0.4529828", "0.45179516", "0.45084032", "0.45035422", "0.44985017", "0.44951874", "0.4488469", "0.44788656", "0.44588366", "0.4434797", "0.44338655", "0.44264123", "0.44235983", "0.44222015", "0.44163948", "0.44085592", "0.440396", "0.44038126", "0.44031614", "0.4376048", "0.43627256", "0.43522444", "0.43466118", "0.43455222", "0.43366176", "0.4318351", "0.43085623", "0.42965287", "0.4293179", "0.42910346", "0.42826065", "0.4281418", "0.42800686", "0.42783543", "0.42703703", "0.42702168", "0.42568198", "0.42488483", "0.42486766", "0.42484885", "0.42470238", "0.42457432", "0.42267036", "0.42260814", "0.4223326", "0.42212915", "0.42155135", "0.42115915", "0.4205116", "0.42014506", "0.4197527", "0.41926727", "0.41900963", "0.41883227", "0.41881055", "0.41871893", "0.4183317", "0.41776067" ]
0.75422734
0
added from ActionView::Base with additional call to registerView added in there not proud of the solution but need to quickly establish access to the base class from within the template to pick up some gui widget metadata used to control the navigation
def _pick_template(template_path) return template_path if template_path.respond_to?(:render) path = template_path.sub(/^\//, '') if m = path.match(/(.*)\.(\w+)$/) template_file_name, template_file_extension = m[1], m[2] else template_file_name = path end # OPTIMIZE: Checks to lookup template in view path if template = self.view_paths["#{template_file_name}.#{template_format}"] template elsif template = self.view_paths[template_file_name] template elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) && (template = self.view_paths["#{template_file_name}.#{first_render.format_and_extension}"]) template elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"] @template_format = :html template else template = ActionView::Template.new(template_path, view_paths) template.registerView(self) if self.class.warn_cache_misses && logger logger.debug "[PERFORMANCE] Rendering a template that was " + "not found in view path. Templates outside the view path are " + "not cached and result in expensive disk operations. Move this " + "file into #{view_paths.join(':')} or add the folder to your " + "view path list" end template end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_view\n #debugger\n self.becomes(self.type.constantize).get_view\n end", "def add_view\n super\n end", "def view_instance\n # view = if controller.response.template\n # controller.response.template\n # else\n View.new controller, master_helper_module\n # end\n \n # view.extend Extensions::View\n end", "def get_view\n\t\treturn \"control_widget\"\n\tend", "def view_instance\n view = ActionView::Base.new(controller.class.view_paths, {}, controller)\n view.extend master_helper_module\n end", "def get_view\n\t\treturn \"content_widget\"\n\tend", "def view_name\n self.class.view_name\n end", "def view_info\n super\n end", "def view_context\n ActionView::Base.new\n end", "def view_renderer; end", "def view_renderer; end", "def renderer_for(action)\n active_admin_namespace.view_factory[\"#{action}_page\"]\n end", "def _view; end", "def view\n @_view\n end", "def create_base\n @base = UI::GenericBase.new(@viewport, BUTTON_TEXTS.collect { |txt| get_text(txt) }, BUTTON_KEYS)\n end", "def initialize_template_class(response)\n super\n klass = self.class\n while klass && klass != Target::BaseController\n if klass.to_s.underscore =~ /\\/(\\w+)_controller$/\n response.template.aux_paths ||= []\n response.template.aux_paths << \"#{RESTORE_ROOT}/modules/#{$1}/views\"\n end\n klass = klass.superclass\n end\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end", "def render_custom_navigation\n if lookup_context.template_exists?('admin/shared/_custom_navigation')\n render 'admin/shared/custom_navigation'\n end\n end", "def create_base_ui\n @base_ui = UI::GenericBase.new(@viewport, button_texts)\n end", "def move_view\n super\n end", "def initialize_template_class(response)\n super\n klass = self.class\n while klass && klass != Wizard::BaseController\n if klass.to_s.underscore =~ /\\/(\\w+)_controller$/\n response.template.aux_paths ||= []\n response.template.aux_paths << \"#{RESTORE_ROOT}/modules/#{$1}/views\"\n end\n klass = klass.superclass\n end\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name, content|\n view.content_for name, content\n end\n end\n end", "def sub_view\n page(NavTabBarPage).select_storytab(\"Action\")\n page(NavTabBarPage).flag_handler(\"Cancel\")\n page(NavTabBarPage).select_storytab(\"Action\")\n page(NavTabBarPage).sub_handler\n page(SubmissionPage).verify_page_elements\n page(SubmissionPage).select_action(\"Submissions\")\n page(SubmissionPage).select_action(\"Comments\")\n page(MorePage).backpage\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end", "def view(page, *)\n rails_render(action: page.tr(\"-\", \"_\"), layout: true) ||\n rails_render(html: super.html_safe, layout: true)\n end", "def initialize(view_context)\n @view_context = view_context\n super\n end", "def add_navbar_widgets\n view_context.render \"shared/widgets\", :context => 'mainlist', :position => 'navbar'\n end", "def create_base_ui\n @base_ui = UI::GenericBase.new(@viewport, button_texts)\n @mouse_button_cancel = @base_ui.ctrl.last\n end", "def loc_view\n \n end", "def view\n self.class.name.underscore\n end", "def rendered_views=(_arg0); end", "def view_layouts_base_content(context = {})\n return '' if Setting.plugin_redmine_tagging[:wiki_pages_inline] == \"1\"\n\n return '' unless context[:controller].is_a? WikiController\n\n request = context[:request]\n return '' unless request.parameters\n\n project = Project.find_by_identifier(request.parameters['id'])\n return '' unless project\n\n page = project.wiki.find_page(request.parameters['page'])\n return '' unless page\n\n tag_context = project.identifier.gsub('-', '_')\n tags = ''\n\n if request.parameters['action'] == 'index'\n tags = page.tag_list_on(tag_context).sort.collect {|tag|\n link_to(\"#{tag}\", {:controller => \"search\", :action => \"index\", :id => project, :q => tag, :wiki_pages => true, :issues => true})\n }.join('&nbsp;')\n\n tags = \"<h3>#{l(:field_tags)}:</h3><p>#{tags}</p>\" if tags\n end\n\n if request.parameters['action'] == 'edit'\n tags = page.tag_list_on(tag_context).sort.collect{|tag| tag.gsub(/^#/, '')}.join(' ')\n tags = \"<p id='tagging_wiki_edit_block'><label>#{l(:field_tags)}</label><br /><input id='wikipage_tags' name='wikipage_tags' size='120' type='text' value='#{h(tags)}'/></p>\"\n\n ac = ActsAsTaggableOn::Tag.find(:all,\n :conditions => [\"id in (select tag_id from taggings\n where taggable_type in ('WikiPage', 'Issue') and context = ?)\", tag_context]).collect {|tag| tag.name}\n ac = ac.collect{|tag| \"'#{escape_javascript(tag.gsub(/^#/, ''))}'\"}.join(', ')\n\n tags += javascript_include_tag 'jquery-1.4.2.min.js', :plugin => 'redmine_tagging'\n tags += javascript_include_tag 'tag.js', :plugin => 'redmine_tagging'\n\n tags += <<-generatedscript\n <script type=\"text/javascript\">\n var $j = jQuery.noConflict();\n $j(document).ready(function() {\n $j('#tagging_wiki_edit_block').insertAfter($j(\"#content_text\").parent().parent());\n $j('#wikipage_tags').tagSuggest({ tags: [#{ac}] });\n });\n </script>\n generatedscript\n end\n\n return tags\n end", "def method_missing(sym, *args, &block)\n if matches = sym.to_s.match(/^.*(?=_view$)|view$/)\n return Tanuki::Loader.run_template(\n {},\n self,\n matches[0].to_sym,\n *args,\n &block\n )\n end\n super\n end", "def widget\n end", "def widget\n end", "def target_view_path\n super\n end", "def help_controller\n OptionalViewHelper.instance\n end", "def view_context\n super.tap do |view|\n (@_content_for_layout || {}).each do |name, content|\n view.content_for name, content\n end\n end\n end", "def view_layouts_base_content(context={})\n return '' if wiki_pages_inline_tags?\n\n return '' unless context[:controller].is_a?(WikiController)\n\n request = context[:request]\n\n return '' unless request.parameters\n\n project = Project.find_by_identifier(request.parameters['project_id'])\n return '' unless project\n\n page = project.wiki.find_page(request.parameters['id'])\n\n tag_context = ContextHelper.context_for(project)\n tags = ''\n\n if page && request.parameters['action'] == 'index'\n tags = page.tag_list_on(tag_context).sort_by { |t| t.downcase }.map do |tag|\n link_to(tag, {\n controller: 'search',\n action: 'index',\n project_id: project,\n q: tag_without_sharp(tag),\n wiki_pages: true,\n issues: true })\n end.join('&nbsp;')\n\n tags = \"<h3>#{ l(:field_tags) }:</h3><p>#{ tags }</p>\" if tags\n end\n\n action = request.parameters['action']\n\n if action == 'edit' || (!page && action == 'show')\n if page\n tags = TagsHelper.to_string(page.tag_list_on(tag_context))\n else\n tags = \"\"\n end\n\n tags = \"<p id='tagging_wiki_edit_block'><label>#{l(:field_tags)}</label><input id='wiki_page_tags' name='wiki_page[tags]' size='120' type='text' value='#{h(tags)}'/></p>\"\n\n ac = ActsAsTaggableOn::Tag.where(\n \"id in (select tag_id from taggings where taggable_type in ('WikiPage', 'Issue') and context = ?)\",\n tag_context\n ).collect { |tag| tag.name }\n\n ac = ac.collect { |tag| \"'#{escape_javascript(tag.gsub(/^#/, ''))}'\" }.join(', ')\n\n tags += javascript_include_tag 'tag', plugin: 'redmine_tagging'\n\n tags += <<-generatedscript\n <script type=\"text/javascript\">\n $(document).ready(function() {\n //$('#tagging_wiki_edit_block').insertAfter($(\"#content_text\"))\n $('#tagging_wiki_edit_block').insertBefore($(\"#wiki_page_parent_id\").parent())\n $('#wiki_page_tags').tagSuggest({ tags: [#{ac}] })\n })\n </script>\n generatedscript\n end\n\n return tags\n end", "def load_view\r\n @view = XamlReader.load_from_path view_path if File.exists? view_path\r\n @view ||= view_name.to_s.gsub(/(.*::)+/, '').classify.new \r\n @view\r\n end", "def ar_view\n view = nil\n\n if params[:view]\n view = self.class.ar_views[params[:view].to_sym] ||\n self.class.ar_model.interfaces[:rest].views[params[:view].to_sym]\n end\n\n view ||= self.class.ar_views[action_name.to_sym] ||\n self.class.ar_model.interfaces[:rest].views[action_name.to_sym] ||\n View.new(:anonymous)\n view\n end", "def inherit_view_paths\n self.class.inherit_view_paths\n end", "def shareview\n # set default\n @template = 'slideshow_customv3'\n if @view_options.has_key?(params[:v].to_i) \n @template = 'slideshow_customv'+ params[:v] \n end\n # the main share view\n # pulls in the child view\n render 'shareshow' \n \n end", "def view_renderer\n @_view_renderer ||= ActionView::Renderer.new(lookup_context)\n end", "def viewDidLoad\n super\n configure_view\n end", "def method_missing(method, *args, &block)\n if @view.respond_to?(method)\n (class << self; self; end).class_eval do\n delegate method, to: :@view\n end\n self.send method, *args, &block\n else\n super\n end\n end", "def initialize_template_class_with_engine_additions(assigns)\n # I'd like to just return this, but I get problems finding methods in helper\n # modules if the method implemention from the regular class is not called\n # \n # ActionView::Base.new(ActionController::Base.view_paths.dup, assigns, self)\n renderer = initialize_template_class_without_engine_additions(assigns)\n renderer.finder.view_paths = ActionController::Base.view_paths.dup\n renderer\n end", "def widget(target, assigns = {}, options = {}, &block)\n assigns.merge!(:component => @component) {|_,old,_| old } if target.is_a? Class\n super target, assigns, options, &block\n end", "def handle_base\n title\n end", "def show_template\n self.template\n end", "def show_template\n self.template\n end", "def show\n super\n end", "def show\n super\n end", "def view_context\n @view_context\n end", "def find\n self.class.find(@view.layout)\n end", "def base\n raise \"Override the base() method in your controller to define the faceting model/context\"\n end", "def view_renderer\n @view_renderer ||= ::ActionView::Renderer.new(lookup_context)\n end", "def _h\n @view_context\n end", "def view\n unless is_parent_layout?\n return parent_layout.view\n end\n @view ||= build_view\n end", "def render(*args)\n super *args\n end", "def view_class_name\n view_class_components.join('_').camelize.sub(/^Layouts/, '')\n end", "def view()\n @view\n end", "def build_custom_view_resolver\n if custom_view_resolver.present?\n Kernel.const_get(custom_view_resolver).new(self)\n else\n nil\n end\n end", "def user_template\n super\n end", "def title_view\n (ActionController::Base.helpers.link_to self[:title], ApplicationController.helpers.edit_url(self.class.base_class, self)).html_safe\n end", "def store_preferred_view\r\n return if %w[default online_contents collection_context child_components].include?(params[:view])\r\n\r\n super\r\n end", "def render(item_container)\n # Add support for a dom_class attribute on the parent element\n item_container.dom_class = \"\"\n item_container.dom_class = options.delete(:dom_class) if options.has_key?(:dom_class)\n item_container.dom_id = options.delete(:dom_id) if options.has_key?(:dom_id)\n item_container.dom_class += has_icons ? \" simple-navigation__with-icons\" : \" simple-navigation__without-icons\"\n item_container.dom_class += has_toggles ? \" simple-navigation__with-toggles\" : \" simple-navigation__without-toggles\"\n super\n end", "def render(*args)\n load_metas_for_current_slug\n super\n end", "def view\n @view ||= returning Cell::View.new(view_paths, {}, @controller) do |v|\n v.cell = self\n v.helper_module = self.class.master_helper_module\n end\n end", "def after_view_setup\n end", "def template\n lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths)\n ActionView::Base.new(lookup_context, {}, ApplicationController.new)\n end", "def content_controller\n self\n end", "def layout_container_class\n if params[:controller] == \"events\" && params[:action] == \"show\"\n \"event container\"\n else\n \"container\"\n end\n end", "def build_custom_view_resolver\n if custom_view_resolver.present?\n Kernel.const_get(custom_view_resolver).new(self)\n end\n end", "def _\n\t\tviewStack = self.instance_variable_get(\"@hooViews\");\n\t\treturn viewStack.last;\n\tend", "def configure_views\n helpers do\n def find_template(views, name, engine, &block)\n _, dir = views.detect { |k,v| engine == Tilt[k] }\n dir ||= views[:default]\n super(dir, name, engine, &block)\n end\n end\n end", "def page_class\n current_template.classify.constantize\n end", "def inherit_views?\n self.class.inherit_views?\n end", "def control_panel_link\n $tracer.trace(__method__)\n return ToolTag.new(a.className(\"/view-control-panel/\"), __method__)\n end", "def method_missing(method, *args, &block) \n return super unless part(method)\n part(method).render\n end", "def base_class; end", "def init(context={})\n\n app = context[:app]\n \n # View models\n ::Model::ViewModel.new(:content, 'content', ContentManagerSystem::Content, :view_template_contents,\n [::Model::ViewModelField.new(:_id, 'id', :string),\n ::Model::ViewModelField.new(:title, 'title', :string),\n ::Model::ViewModelField.new(:path, 'path', :string),\n ::Model::ViewModelField.new(:alias, 'alias', :string),\n ::Model::ViewModelField.new(:summary, 'summary', :string),\n ::Model::ViewModelField.new(:type, 'type', :string),\n ::Model::ViewModelField.new(:creation_date, 'creation_date', :date),\n ::Model::ViewModelField.new(:creation_user, 'creation_user', :string)])\n \n ::Model::ViewModel.new(:term, 'term', ContentManagerSystem::Term, :view_template_terms,\n [::Model::ViewModelField.new(:id, 'id', :serial),\n ::Model::ViewModelField.new(:description, 'description', :string)])\n\n ::Model::ViewModel.new(:profile, 'profile', Users::Profile, :view_template_profiles,[]) \n\n # View renders \n teaser_preprocessor = Proc.new do |data, context, render_options|\n data.map { |element| CMSRenders::Factory.get_render(element, context, 'teaser').render({}, [:ignore_complements, :ignore_blocks]) }\n end\n\n slider_preprocessor = Proc.new do |data, context, render_options|\n data.map { |element| CMSRenders::Factory.get_render(element, context, 'justphoto').render({}, [:ignore_complements, :ignore_blocks]) }\n end\n\n term_hierarchy_preprocessor = Proc.new do |data, context, render_options|\n separator = render_options['separator'] || \"&nbsp;&middot;&nbsp;\"\n data.map do |element| \n terms = []\n terms << \"<a href=\\\"#{render_options['prefix']}/#{element.id}\\\">\"\n terms << \"#{element.description}</a>\"\n while not element.parent.nil?\n element = element.parent\n terms << separator\n terms << \"<a href=\\\"#{render_options['prefix']}/#{element.id}\\\">#{element.description}</a>\"\n end\n render_result = \"<div class=\\\"term-hierarchy-container #{render_options['container_class']}\\\">\" << terms.reverse.join << \"</div>\"\n end\n \n end\n\n ::Model::ViewRender.new(:teaser, 'teaser', ::Model::ViewStyle::VIEW_STYLE_TEASER, teaser_preprocessor)\n ::Model::ViewRender.new(:thumbnail, 'thumbnail', Model::ViewStyle::VIEW_STYLE_THUMBNAIL)\n\n end", "def view_to_url(view, parent = nil)\n association = view_to_association(view, parent)\n if association.nil?\n controller, action = db_to_controller(view.db)\n if controller == \"ems_cloud\" && action == \"show\"\n return ems_clouds_path\n end\n if controller == \"ems_infra\" && action == \"show\"\n return ems_infras_path\n end\n if controller == \"ems_physical_infra\" && action == \"show\"\n return ems_physical_infras_path\n end\n if controller == \"ems_container\" && action == \"show\"\n return ems_containers_path\n end\n if controller == \"ems_network\" && action == \"show\"\n return ems_networks_path\n end\n if controller == \"ems_storage\" && action == \"show\"\n return ems_storages_path\n end\n\n if request[:controller] == 'service' && view.db == 'GenericObject'\n action = 'show'\n return url_for_only_path(:action => action, :id => params[:id]) + \"?display=generic_objects&generic_object_id=\"\n end\n if @explorer\n # showing a list view of another CI inside vmx\n if %w[SecurityGroup\n SecurityPolicy\n SecurityPolicyRule\n FloatingIp\n NetworkRouter\n NetwokrService\n NetworkPort\n CloudNetwork\n CloudSubnet\n LoadBalancer\n CloudVolume].include?(view.db)\n return url_for_only_path(:controller => controller, :action => \"show\") + \"/\"\n elsif [\"Vm\"].include?(view.db) && parent && request.parameters[:controller] != \"vm\"\n # this is to handle link to a vm in vm explorer from service explorer\n return url_for_only_path(:controller => \"vm_or_template\", :action => \"show\") + \"/\"\n elsif %w[MiqWidget\n ConfigurationScript\n MiqReportResult].include?(view.db) &&\n %w[report].include?(request.parameters[:controller])\n suffix = ''\n if params[:tab_id] == \"saved_reports\" || params[:pressed] == \"miq_report_run\" || params[:action] == \"reload\"\n suffix = x_node\n end\n return \"/\" + request.parameters[:controller] + \"/tree_select?id=\" + suffix\n elsif %w[User MiqGroup MiqUserRole Tenant].include?(view.db) &&\n %w[ops].include?(request.parameters[:controller])\n if @tagging\n return false # when tagging Users, Groups, Roles and Tenants, the table is non-clickable\n else\n return \"/\" + request.parameters[:controller] + \"/tree_select/?id=\" + x_node.split(\"-\")[1]\n end\n elsif view.db == \"MiqServer\" &&\n %w[ops report].include?(request.parameters[:controller])\n return \"/\" + request.parameters[:controller] + \"/tree_select/?id=\" + TREE_WITH_TAB[active_tab]\n elsif %w[ScanItemSet\n MiqSchedule\n PxeServer\n PxeImageType\n Storage\n CustomizationTemplate].include?(view.db) &&\n %w[ops pxe report].include?(params[:controller])\n return \"/#{params[:controller]}/tree_select/?id=#{TreeBuilder.get_prefix_for_model(view.db)}\"\n else\n return url_for_only_path(:action => action) + \"/\" # In explorer, don't jump to other controllers\n end\n else\n controller = case controller\n when 'template_cloud'\n 'vm_cloud'\n when 'template_infra'\n 'vm_infra'\n when 'miq_ae_domain'\n 'miq_ae_class'\n else\n controller\n end\n\n return url_for_only_path(:controller => 'restful_redirect', :model => 'ExtManagementSystem') if controller == 'ext_management_system'\n\n return url_for_only_path(:controller => controller, :action => action, :id => nil) + \"/\"\n end\n else\n # need to add a check for @explorer while setting controller incase building a link for details screen to show items\n # i.e users list view screen inside explorer needs to point to vm_or_template controller\n return url_for_only_path(:controller => parent.kind_of?(VmOrTemplate) && !@explorer ? parent.class.base_model.to_s.underscore : request.parameters[\"controller\"],\n :action => association,\n :id => parent.id) + \"?#{@explorer ? \"x_show\" : \"show\"}=\"\n end\n end", "def js_class_name\n action = \n case action_name\n when 'create' then 'New'\n when 'update' then 'Edit'\n else action_name\n end.camelize\n \"Views.#{self.class.name.gsub('::', '.').gsub(/Controller$/, '')}.#{action}View\"\n end", "def view; end", "def show\n render @current_template\n end", "def show\n if dark_side?\n @navigation_entry = NavigationEntry.find(params[:id])\n else\n @navigation_entry = NavigationEntry.find(params[:id], :include => :container)\n @navigation_entry_parent = @navigation_entry.parent\n @current_navigation_entry = @navigation_entry\n load_misc_stuffs\n @container = @navigation_entry.container\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @navigation_entry }\n end\n end", "def show_template\n :show\n end", "def show_template\n :show\n end", "def method_missing(method, *args, &block)\n view.send(method, *args, &block)\n end", "def view_context\n super.tap { |actual_view_context| actual_view_context.content_for :meta_description, @page.meta_description }\n end", "def form_view\n end", "def default\r\n can_view, msg = dc_user_can_view(@parent, @page)\r\n return msg unless can_view\r\n\r\n html = \"<div class=\\\"#{@page.div_class} #{@opts[:div_class]}\\\">\"\r\n html << dc_page_edit_menu() if @opts[:edit_mode] > 1\r\n @parent.page_title = @page.title.blank? ? @page.subject : @page.title\r\n html << @page.body\r\n # render poll if defined\r\n if @page.dc_poll_id\r\n @opts.merge!(poll_id: @page.dc_poll_id, return_to: @parent.request.url, method: nil)\r\n comment = DcPollRenderer.new(@parent, @opts)\r\n html << \"<div class='wrap row'>#{comment.render_html}</div>\"\r\n @css << \"\\n#{comment.render_css}\"\r\n end\r\n # also add iframe\r\n html << iframe() << '</div>'\r\nend", "def initialize_template_class(assigns)\n ActionView::Base.new(template_path, assigns, self)\n end", "def render(name, **args)\n\t\t\n\t\tif Core::DEBUG\n\t\t\tputs \"Loading view...\"\n\t\tend\n\n\t\tname = Core::VIEW + name\n\n\t\tfilePath = Core::viewPath(name)\n\n\t\tself.loadFile(filePath, \"View\")\n\n\t\t## Will retrieve class constant name for dynamic instanciation\n\t\tviewName = Object.const_get(name)\n\n\t\tview = viewName.new()\n\n\t\t## Force children controller and view\n\t\t## to run parent initialize if overriden.\n\t\tCore::forceParentInit(self)\t\n\t\tCore::forceParentInit(view)\n\n\t\t## Set values sent from previous view in\n\t\t## content of current view.\n\t\targs.each{\n\t\t\t|key, value|\n\t\t\t@content[key.to_s] = value\n\t\t}\n\n\t\tself.setProperties(view)\n\n\t\t## Collect content from controller and send it to view\n\t\tview.controller = self\n\t\tview.controller.run()\n\t\tview.content = @content.clone()\n\n\t\t## Refer controller methods in view for easier\n\t\t## call.\n\t\tself.class.instance_methods(false).each() do |method|\n\t\t\tif !view.class.method_defined?(method)\n\t\t\t\tview.define_singleton_method(method) do |*arguments|\n\t\t\t\t\tself.controller.send(method, *arguments)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t## Will render view with content retrieved in controller\n\t\tview.setInstanceVars()\n\t\tview.run()\n\n\t\tFenetre::css(:priorite => \"PRIORITY_APPLICATION\")\n\n\t\t## Display content builded in view with Gtk\n\t\tview.window.show_all\n\tend", "def execute\n view.add_control target, controller.current_view.instance\n end", "def initialize(view)\n @view = view\n end", "def render_widget(*args)\n @view_assigns = extract_state_ivars_for(root[args.first]) do\n @last_invoke = root.render_widget(*args)\n end\n \n @last_invoke\n end", "def include_abingo_views\n\t\tmodule_eval ABingoCampingPlugin::Views.abingo_view_helpers\n\t\tmodule_eval ABingoCampingPlugin::Views.common_abingo_views\n\n\t\tmodule_eval do\n\t\t\tapp_module_name = self.to_s.split(\"::\").first\t\n\t\t\tmab_class_name = \"#{app_module_name}::Mab\"\t\n\t\t\tmab_class = mab_class_name.constantize\n\n#\t\t\tunless mab_class.public_instance_methods.include? 'register' \n#\t\t\t\tmodule_eval ABingoCampingPlugin::Views.register_view\n#\t\t\tend\n\t\tend\n\t\t\n\tend", "def render view = nil\n view ||= self.class.name.sub('Controller', '').underscore\n template = Sidewalk::ControllerMixins::ViewTemplates.template(view)\n if template.nil?\n raise ScriptError.new(\"Unable to find a template for #{view}\")\n end\n template.render(self)\n end", "def page_template\n self_template || inherited_template || DEFAULT_TEMPLATE\n end" ]
[ "0.67603225", "0.6627405", "0.6395054", "0.63627064", "0.6322792", "0.6261792", "0.6139669", "0.6131248", "0.60864604", "0.60620207", "0.60620207", "0.59203887", "0.58636576", "0.58585614", "0.57804656", "0.5751333", "0.5714061", "0.5712798", "0.5711969", "0.56857693", "0.5684876", "0.56838495", "0.5667144", "0.5664331", "0.56346375", "0.56298643", "0.5629003", "0.56276274", "0.560097", "0.56006396", "0.5586727", "0.5555328", "0.5529547", "0.5528621", "0.5528621", "0.55285573", "0.55186874", "0.55151117", "0.5496916", "0.5494633", "0.5479865", "0.5475053", "0.54653525", "0.54645896", "0.54576004", "0.54411566", "0.54382306", "0.54199183", "0.5415549", "0.5406202", "0.5406202", "0.5400429", "0.5400429", "0.53953964", "0.5386917", "0.53860956", "0.53823155", "0.53719234", "0.536295", "0.5356364", "0.5353615", "0.53497845", "0.53424066", "0.534098", "0.5340686", "0.5332615", "0.5332284", "0.533056", "0.53263247", "0.53185445", "0.5316079", "0.53101426", "0.53076637", "0.52914166", "0.52905977", "0.5279738", "0.5273202", "0.5269347", "0.5269198", "0.5262286", "0.52605176", "0.5254767", "0.5251557", "0.5241931", "0.52319336", "0.5231646", "0.5230639", "0.5226313", "0.5226313", "0.521743", "0.5203797", "0.51993966", "0.51957107", "0.51917934", "0.5177482", "0.5175149", "0.5172925", "0.516067", "0.51536703", "0.5153629", "0.5151645" ]
0.0
-1
GET /assets GET /assets.xml
def index @assets = Asset.find(:all) respond_to do |format| format.html # index.rhtml format.xml { render :xml => @assets.to_xml } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @assets = assets.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets.to_xml }\n end\n end", "def list_assets\n get('/video/v1/assets')\n end", "def index\n @car = Car.find(params[:car_id])\n @assets = @car.assets\n\n respond_to do |format|\n format.xml {render xml: @assets}\n format.json {render json: @assets}\n end\n end", "def index\n\t @assets = @campaign.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def index\n @asset = Asset.find(params[:asset_id])\n @tags = @asset.tags\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tags }\n end\n end", "def index\n @assets = @org.assets\n end", "def index\n @user_assets = UserAsset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_assets }\n end\n end", "def index\n @assets = Asset.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assets }\n format.xml { render xml: @assets }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.xml {render xml: @asset}\n format.json {render json: @asset}\n end\n end", "def index\n\t\t@assets = Asset.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @assets }\n\t\tend\n\tend", "def show\n @asset = Resource.find(params[:id])\n \n respond_to do |format|\n format.html { render :xml => @asset }# index.html.erb\n format.xml { render :xml => @asset }# index.xml.builder\n format.json { render :json => @asset }# index.xml.builder\n end\n end", "def asset(id, params = {})\n get \"assets/#{id}\", {query: params}\n end", "def index\n @assets = Asset.all\n end", "def index\n @assets = Asset.all\n end", "def index\n @assets = Asset.search(params[:search], params[:page])\n @stages = Stage.find(:all)\n\n respond_to do |format|\n format.html #index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset.to_xml }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @asset.to_xml }\n end\n end", "def assets\n []\n end", "def index\n @artefact = Artefact.find(params[:artefact_id])\n\n @assets = @artefact.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assets }\n end\n end", "def show\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => asset_manager_asset_tag_path(@asset, @tag) }\n end\n end", "def index\n @assets = Asset.paginate :page => params[:page], :per_page => 30, :order => 'name'\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def show\n\t\t@asset = @campaign.assets.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def index\n @course_assets = CourseAsset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @course_assets }\n end\n end", "def assets\n \n if !params[:path].blank? or !params[:format].blank?\n if get_from_asset_folder\n return\n else\n render_404 and return\n end\n end\n end", "def index\n @asset_files = AssetFile.all\n end", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\n end\n end", "def get(*args)\n params = arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{owner}/#{repo}/releases/assets/#{id}\" , params)\n end", "def index\n @assets = Resource.where(nil)\n @assets = @assets.oidTest(params[:oid]) if params[:oid].present?\n @assets = @assets.urlTest(params[:retrievalurl]) if params[:retrievalurl].present?\n @assets = @assets.objectTypeTest(params[:objecttype]) if params[:objecttype].present?\n @assets = @assets.eventTypeTest(params[:eventtype]) if params[:eventtype].present?\n @assets = @assets.langTypeTest(params[:lang]) if params[:lang].present?\n @assets = @assets.searchDescription(params[:search]) if params[:search].present?\n @assets = @assets.isActive() unless params[:showinactive] == 'true'\n \n respond_to do |format|\n format.html { render :xml => @assets }# index.html.erb\n format.xml { render :xml => @assets }# index.xml.builder\n format.json { render :json => @assets }# index.xml.builder\n end\n end", "def index\n @asset_categories = AssetCategory.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asset_categories }\n end\n end", "def assets(query = {})\n resp =\n _instrument 'entries', type: 'Asset', query: query do\n get('assets', query)\n end\n resp.assert_ok!\n end", "def show\n\t\t@asset = Asset.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @asset }\n\t\tend\n\tend", "def assets; end", "def assets; end", "def assets; end", "def get_assets(category = nil)\r\n # Prepare query url.\r\n _path_url = '/gem_assets'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'category' => category\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\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)\r\n decoded.map { |element| Asset.from_hash(element) }\r\n end", "def index\n assets = Asset.unscoped.\n editable_by(@context).\n accessible_by_private.\n eager_load(user: :org).\n includes(:taggings).\n search_by_tags(params.dig(:filters, :tags))\n\n render_assets_list assets\n end", "def show\n @asset = Asset.find(params[:id])\n @assets = @uploadable.assets\n respond_to do |format|\n format.html\n format.json { render json: @asset}\n end\n end", "def index_ajax\n @assets = Asset.find(:all)\n render :back => '/app'\n end", "def show\n @user_asset = UserAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_asset }\n end\n end", "def index\n @assets = Asset.find(:all, :conditions => \"thumbnail IS NULL\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def index\n @assets = current_user.assets.all\n end", "def asset(asset_id)\n get \"/video/v1/assets/##{asset_id}\"\n end", "def index\n begin\n\n @assets = Asset.where(asset_params)\n\n render template: 'assets/index', status: :ok\n rescue Exception => e\n Rails.logger.error(\"Encountered an error while indexing #{e}\")\n render json: {:message=> e.to_s}.to_json, status: :not_found\n end\n end", "def assets(page = 1, order = :oldest)\n Dropio::Resource.client.assets(self, page, order)\n end", "def index\n @assets = @uploadable.assets\n end", "def index\n #@assets = Asset.all\n @search = Asset.search(params[:q])\n @assets = @search.result\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset_item = AssetItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_item }\n end\n end", "def assets\n @assets ||= []\n end", "def index\n @asset_disposals = AssetDisposal.with_permissions_to(:edit).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asset_disposals }\n end\n end", "def index\n @client_assets = ClientAsset.all\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @assettrack = Assettrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assettrack }\n end\n end", "def retrieve(controller = '', action = '', options = {})\n options = { :full => false, :tagged => false, :shallow => false }.update(options)\n\n @assets = []\n @parsed_manifests = []\n @controller = controller\n @action = action\n @shallow_retrieval = options[:shallow]\n\n retrieve_controller_assets\n retrieve_action_assets if @action != ''\n @assets.uniq!\n\n @assets.map! { |asset| PathInfo.new(asset).abs } if options[:full]\n @assets.map! { |asset| tag(\"/#{asset.rel}\") } if options[:tagged]\n\n @assets\n end", "def list_assets\n # Refresh state of assets, if needed\n User.sync_assets!(@context)\n\n ids = unsafe_params[:ids]\n assets = if unsafe_params[:editable]\n Asset.closed.editable_by(@context).accessible_by_private\n else\n Asset.closed.accessible_by(@context)\n end\n\n unless ids.nil?\n fail \"The 'ids' parameter needs to be an Array of String asset ids\" unless ids.is_a?(Array) && ids.all? { |id| id.is_a?(String) }\n assets = assets.where(uid: ids)\n end\n\n if unsafe_params[:scopes].present?\n check_scope!\n assets = assets.where(scope: unsafe_params[:scopes])\n end\n\n result = assets.order(:name).map do |asset|\n describe_for_api(asset, unsafe_params[:describe])\n end\n\n unless ids.nil?\n # This would happen if an asset becomes inaccessible\n # For now silently drop the asset -- allows for asset deletion\n # raise unless ids.size == result.size\n end\n\n render json: result\n end", "def get\n raise_method_not_available(__method__, 'is nested asset') if nested_asset?\n assets = client.get(asset_type)\n assets.map { |data| self.new_from_payload(data) }\n end", "def show\n begin\n render template: 'assets/show', status: :ok\n rescue Exception => e\n render json: {:message=> e.to_s}.to_json, status: :not_found\n end\n end", "def retrieve_action_assets\n action_path = PathInfo.new(\"#{app_path.to_s}/#{@controller}\")\n single_action_path = PathInfo.new(\"#{action_path}/#{@action}.#{asset_extension}\")\n indexed_action_path = PathInfo.new(\"#{action_path}/#{@action}\")\n manifest = nil\n\n manifest = single_action_path if FileTest.exist?(single_action_path)\n\n action_index = \"#{indexed_action_path}/index.#{asset_extension}\"\n manifest = PathInfo.new(action_index) if FileTest.exist?(action_index)\n\n @assets.concat(retrieve_assets_from(manifest)) unless manifest.nil?\n\n if FileTest.exist?(indexed_action_path)\n auto_required_assets = Dir[\"#{action_path}/#{@action}/**/*.#{asset_extension}\"]\n\n @assets.concat(auto_required_assets.map{ |ass| PathInfo.new(ass).rel })\n else\n @assets << manifest.rel unless manifest.nil?\n end\n end", "def index\n @asset_data = AssetData.all\n end", "def index\n if params[:tag]\n @assets = Asset.tagged_with(params[:tag]).page(params[:page]).per_page(15)\n else\n @assets = Asset.order(\"created_at desc\").page(params[:page]).per_page(15)\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assets }\n format.js\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.js\n format.json { render :json => @asset }\n format.xml { render :xml => @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n @categories = Category.all(order: 'created_at')\n @assets = Asset.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def index\n @expenses = Expense.all\n # @assets = Asset.all\n @assets = current_user.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n end\n end", "def assets\n content_mappings.collect{|mapping| mapping.asset }\n end", "def index\n #@assets = Asset.all\n respond_to do |format|\n format.html\n format.json { render json: AssetsDatatable.new(view_context) }\n end \n end", "def index\n @asset_info_adjustments = AssetInfoAdjustment.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asset_info_adjustments }\n format.xml { render xml: @asset_info_adjustments }\n end\n end", "def index\n @urls = Url.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @urls}\n format.json { render json: @urls }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @imports }\n end\n end", "def assets\r\n\t\t@graph_by_id.map{ |id,graph_element| asset_for_el(graph_element) }\r\n\tend", "def show\n @asset_category = AssetCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_category }\n end\n end", "def content\r\n if assets.url.start_with?(\"/\")\r\n IO.read(Rails.public_path.to_s+assets.url.sub(/\\?.+/,\"\"))\r\n else\r\n open(URI.parse(assets.url)).read\r\n end\r\n end", "def show\n @course_asset = CourseAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @course_asset }\n end\n end", "def index \n @assets = current_user.assets \n end", "def show\n\n @asset_company = AssetCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_company }\n end\n end", "def assets\n @assets ||= Assets.new(self)\n end", "def list_assets_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AssetsApi.list_assets ...'\n end\n # resource path\n local_var_path = '/video/v1/assets'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'live_stream_id'] = opts[:'live_stream_id'] if !opts[:'live_stream_id'].nil?\n query_params[:'upload_id'] = opts[:'upload_id'] if !opts[:'upload_id'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'ListAssetsResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['accessToken']\n\n new_options = opts.merge(\n :operation => :\"AssetsApi.list_assets\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AssetsApi#list_assets\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @gallery_asset = GalleryAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery_asset }\n end\n end", "def show\n #@assets = @project.assets.all\n\n end", "def show\n @asset_disposal = AssetDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_disposal }\n end\n end", "def show\n @global_asset = GlobalAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @global_asset }\n end\n end", "def index\n @image_sets = ImageSet.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @image_sets }\n end\n end", "def index\n @cassetes = Cassete.all\n end", "def index\n @avatar_twitters = AvatarTwitter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @avatar_twitters }\n end\n end", "def index\n @asset_files = current_user.asset_files\n end", "def assets_manifest; end", "def assets_manifest; end", "def index\n @assets = Asset.all\n @category = Category.all\n end", "def index\n @snapshots = current_account.snapshots.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @snapshots }\n end\n end", "def response(env)\n if not @paths.is_a?(Array)\n @config.rack_file.not_found\n else\n @paths.inject([200, {}, '']) do |sum, path|\n # Fetch the response\n item = Stapler::Asset.new(@config, path).response(env)\n\n # Add the file title\n sum[2] << \"\\n\\n\\n/***** #{path} *****/\\n\\n\\n\"\n\n if item[0] != 200\n sum[2] << \"/* [#{item[0]}] Asset problem */\\n\\n\\n\"\n else\n # Headers are merged\n sum[1].merge!(item[1])\n # Body is concatenated\n sum[2] << Stapler::Utils.response_body(item)\n end\n\n # Return the response\n sum\n end\n end\n end", "def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resources }\n end\n end", "def index\n @accounts = Account.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accounts }\n end\n end", "def index\n @accounts = Account.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accounts }\n end\n end", "def index\n @accounts = Account.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accounts }\n end\n end", "def show\n @c_asset = CAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @c_asset }\n end\n end" ]
[ "0.766882", "0.7315963", "0.71050686", "0.7104809", "0.6935153", "0.6924257", "0.69046664", "0.68881136", "0.68466556", "0.67834485", "0.6737458", "0.66746676", "0.66599834", "0.66599834", "0.66415435", "0.66150415", "0.66150415", "0.6613453", "0.6604568", "0.65537506", "0.6547545", "0.6513303", "0.6510884", "0.64976466", "0.64870214", "0.64860797", "0.6468762", "0.64455223", "0.63910425", "0.636944", "0.6338586", "0.6336506", "0.63127965", "0.630564", "0.630564", "0.630564", "0.6296672", "0.6278837", "0.62670285", "0.6251537", "0.6240185", "0.623766", "0.62057716", "0.6183579", "0.6173359", "0.6164531", "0.61477643", "0.61454713", "0.6134218", "0.6134218", "0.6134218", "0.6134218", "0.6134218", "0.61206996", "0.61056304", "0.60585344", "0.605234", "0.604263", "0.6035909", "0.602857", "0.6017784", "0.6017475", "0.60037124", "0.597319", "0.5967462", "0.5956864", "0.5955366", "0.594722", "0.5942929", "0.5924357", "0.59188473", "0.5918187", "0.5880102", "0.58783466", "0.5873838", "0.5863537", "0.5853359", "0.5836274", "0.5825815", "0.5823954", "0.5822942", "0.5811645", "0.581121", "0.5799366", "0.57975173", "0.5773", "0.5755326", "0.5753689", "0.57525253", "0.5751595", "0.5740378", "0.57396394", "0.573591", "0.5722599", "0.5717952", "0.5706047", "0.57054967", "0.57054967", "0.57054967", "0.5698627" ]
0.7255824
2
GET /assets/1 GET /assets/1.xml
def show @asset = Asset.find(params[:id]) respond_to do |format| format.html # show.rhtml format.xml { render :xml => @asset.to_xml } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @assets = assets.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets.to_xml }\n end\n end", "def index\n @assets = Asset.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @assets.to_xml }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.xml {render xml: @asset}\n format.json {render json: @asset}\n end\n end", "def show\n @asset = Resource.find(params[:id])\n \n respond_to do |format|\n format.html { render :xml => @asset }# index.html.erb\n format.xml { render :xml => @asset }# index.xml.builder\n format.json { render :json => @asset }# index.xml.builder\n end\n end", "def index\n @car = Car.find(params[:car_id])\n @assets = @car.assets\n\n respond_to do |format|\n format.xml {render xml: @assets}\n format.json {render json: @assets}\n end\n end", "def index\n\t @assets = @campaign.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset.to_xml }\n end\n end", "def asset(id, params = {})\n get \"assets/#{id}\", {query: params}\n end", "def index\n @asset = Asset.find(params[:asset_id])\n @tags = @asset.tags\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tags }\n end\n end", "def list_assets\n get('/video/v1/assets')\n end", "def index\n @user_assets = UserAsset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_assets }\n end\n end", "def show\n\t\t@asset = @campaign.assets.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def show\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => asset_manager_asset_tag_path(@asset, @tag) }\n end\n end", "def index\n @assets = @org.assets\n end", "def index\n @assets = Asset.find(:all, :conditions => \"thumbnail IS NULL\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def index\n @assets = Asset.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assets }\n format.xml { render xml: @assets }\n end\n end", "def index\n @assets = Asset.search(params[:search], params[:page])\n @stages = Stage.find(:all)\n\n respond_to do |format|\n format.html #index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\n end\n end", "def index\n @assets = Asset.paginate :page => params[:page], :per_page => 30, :order => 'name'\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def assets\n \n if !params[:path].blank? or !params[:format].blank?\n if get_from_asset_folder\n return\n else\n render_404 and return\n end\n end\n end", "def asset(asset_id)\n get \"/video/v1/assets/##{asset_id}\"\n end", "def index\n @assets = Asset.all\n end", "def index\n @assets = Asset.all\n end", "def show\n @user_asset = UserAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_asset }\n end\n end", "def show\n\t\t@asset = Asset.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @asset }\n\t\tend\n\tend", "def index\n @artefact = Artefact.find(params[:artefact_id])\n\n @assets = @artefact.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assets }\n end\n end", "def index\n\t\t@assets = Asset.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @assets }\n\t\tend\n\tend", "def index\n @course_assets = CourseAsset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @course_assets }\n end\n end", "def show\n @asset_item = AssetItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_item }\n end\n end", "def index\n @assets = Resource.where(nil)\n @assets = @assets.oidTest(params[:oid]) if params[:oid].present?\n @assets = @assets.urlTest(params[:retrievalurl]) if params[:retrievalurl].present?\n @assets = @assets.objectTypeTest(params[:objecttype]) if params[:objecttype].present?\n @assets = @assets.eventTypeTest(params[:eventtype]) if params[:eventtype].present?\n @assets = @assets.langTypeTest(params[:lang]) if params[:lang].present?\n @assets = @assets.searchDescription(params[:search]) if params[:search].present?\n @assets = @assets.isActive() unless params[:showinactive] == 'true'\n \n respond_to do |format|\n format.html { render :xml => @assets }# index.html.erb\n format.xml { render :xml => @assets }# index.xml.builder\n format.json { render :json => @assets }# index.xml.builder\n end\n end", "def show\n @asset = Asset.find(params[:id])\n @assets = @uploadable.assets\n respond_to do |format|\n format.html\n format.json { render json: @asset}\n end\n end", "def index\n @asset_files = AssetFile.all\n end", "def show\n @assettrack = Assettrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assettrack }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def index\n @asset_categories = AssetCategory.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asset_categories }\n end\n end", "def index_ajax\n @assets = Asset.find(:all)\n render :back => '/app'\n end", "def index\n begin\n\n @assets = Asset.where(asset_params)\n\n render template: 'assets/index', status: :ok\n rescue Exception => e\n Rails.logger.error(\"Encountered an error while indexing #{e}\")\n render json: {:message=> e.to_s}.to_json, status: :not_found\n end\n end", "def get(*args)\n params = arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{owner}/#{repo}/releases/assets/#{id}\" , params)\n end", "def show\n @gallery_asset = GalleryAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery_asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n response.headers['X-Accel-Redirect'] = @asset.asset.url\n response.headers[\"Content-Type\"] = @asset.asset_content_type\n response.headers['Content-Disposition'] = \"attachment; filename=#{@asset.asset_file_name}\" \n response.headers['Content-Length'] = @asset.asset_file_size\n render :nothing => true\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @imports }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.js\n format.json { render :json => @asset }\n format.xml { render :xml => @asset }\n end\n end", "def show\n @asset_category = AssetCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_category }\n end\n end", "def show\n @course_asset = CourseAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @course_asset }\n end\n end", "def show\n begin\n render template: 'assets/show', status: :ok\n rescue Exception => e\n render json: {:message=> e.to_s}.to_json, status: :not_found\n end\n end", "def show\n @download = Download.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @download }\n end\n end", "def show\n @download = Download.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @download }\n end\n end", "def index\n @assets = @uploadable.assets\n end", "def assets\n []\n end", "def show\n @global_asset = GlobalAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @global_asset }\n end\n end", "def index\n #@assets = Asset.all\n @search = Asset.search(params[:q])\n @assets = @search.result\n end", "def show\n @asset_disposal = AssetDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_disposal }\n end\n end", "def show\n\n @asset_company = AssetCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_company }\n end\n end", "def assets; end", "def assets; end", "def assets; end", "def index\n @urls = Url.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @urls}\n format.json { render json: @urls }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n @categories = Category.all(order: 'created_at')\n @assets = Asset.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end", "def retrieve_action_assets\n action_path = PathInfo.new(\"#{app_path.to_s}/#{@controller}\")\n single_action_path = PathInfo.new(\"#{action_path}/#{@action}.#{asset_extension}\")\n indexed_action_path = PathInfo.new(\"#{action_path}/#{@action}\")\n manifest = nil\n\n manifest = single_action_path if FileTest.exist?(single_action_path)\n\n action_index = \"#{indexed_action_path}/index.#{asset_extension}\"\n manifest = PathInfo.new(action_index) if FileTest.exist?(action_index)\n\n @assets.concat(retrieve_assets_from(manifest)) unless manifest.nil?\n\n if FileTest.exist?(indexed_action_path)\n auto_required_assets = Dir[\"#{action_path}/#{@action}/**/*.#{asset_extension}\"]\n\n @assets.concat(auto_required_assets.map{ |ass| PathInfo.new(ass).rel })\n else\n @assets << manifest.rel unless manifest.nil?\n end\n end", "def get\n raise_method_not_available(__method__, 'is nested asset') if nested_asset?\n assets = client.get(asset_type)\n assets.map { |data| self.new_from_payload(data) }\n end", "def index\n @image_sets = ImageSet.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @image_sets }\n end\n end", "def show\n @c_asset = CAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @c_asset }\n end\n end", "def show\n @attached_asset = AttachedAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attached_asset }\n end\n end", "def index\n @asset_disposals = AssetDisposal.with_permissions_to(:edit).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asset_disposals }\n end\n end", "def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end", "def index\n @client_assets = ClientAsset.all\n end", "def show\n @stage = Stage.find(params[:id])\n @assets = @stage.assets.paginate :per_page => 12, :page => params[:page],\n :conditions => ['title like ?', \"%#{params[:search]}%\"],\n :order => 'title'\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stage }\n end\n end", "def new\n @asset = Asset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def new\n @asset = Asset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def index\n @content_title = @title = 'Search for Wireless Devices'\n @asset_params = params.dup\n respond_to do |format|\n format.html do \n @assets = WirelessDevice.paginated_collection(Asset.per_page, params, Asset.search_rules, Asset.find_options(params[:tag]))\n render :template => 'assets/index.rhtml'\n end\n format.text do \n @assets = WirelessDevice.find_queried(:all, params, Asset.search_rules, Asset.find_options(params[:tag]))\n render :template => 'assets/index.text.erb'\n end\n end\n end", "def available\n @singles = SingleAudioAsset.find(:all, :conditions => \"status = 'available'\")\n respond_to do |format|\n format.xml { render :xml => @singles.to_xml }\n end\n end", "def show\n @asset_request = AssetRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset_request }\n end\n end", "def index\n @materials = Material.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @materials }\n end\n end", "def index\n @snapshots = current_account.snapshots.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @snapshots }\n end\n end", "def show\n @asset_info_adjustments = AssetInfoAdjustment.where(:asset_id => params[:id])\n @asset_cost_adjustments = AssetCostAdjustment.where(:asset_id => params[:id])\n @asset_transfers = @asset.asset_transfers\n @asset_categorization_item = @asset.asset_categorization_item\n @accessory_adjusting_assets = @asset.accessory_adjusting_assets\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n format.xml { render xml: @asset }\n end\n end", "def assets(page = 1, order = :oldest)\n Dropio::Resource.client.assets(self, page, order)\n end", "def show\n @budget_src = BudgetSrc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @budget_src }\n end\n end", "def index\n @content_title = @title = 'Search for Network Devices'\n @asset_params = params.dup\n respond_to do |format|\n format.html do \n @assets = NetDevice.paginated_collection(Asset.per_page, params, Asset.search_rules, Asset.find_options(params[:tag]))\n render :template => 'assets/index.rhtml'\n end\n format.text do \n @assets = NetDevice.find_queried(:all, params, Asset.search_rules, Asset.find_options(params[:tag]))\n render :template => 'assets/index.text.erb'\n end\n end\n end", "def new\n @asset = Asset.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def index\n @file_attachments = FileAttachment.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_attachments }\n end\n end", "def show\n @svg_file = Cmtool::SvgFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @svg_file }\n end\n end", "def assets(query = {})\n resp =\n _instrument 'entries', type: 'Asset', query: query do\n get('assets', query)\n end\n resp.assert_ok!\n end", "def response(env)\n if not @paths.is_a?(Array)\n @config.rack_file.not_found\n else\n @paths.inject([200, {}, '']) do |sum, path|\n # Fetch the response\n item = Stapler::Asset.new(@config, path).response(env)\n\n # Add the file title\n sum[2] << \"\\n\\n\\n/***** #{path} *****/\\n\\n\\n\"\n\n if item[0] != 200\n sum[2] << \"/* [#{item[0]}] Asset problem */\\n\\n\\n\"\n else\n # Headers are merged\n sum[1].merge!(item[1])\n # Body is concatenated\n sum[2] << Stapler::Utils.response_body(item)\n end\n\n # Return the response\n sum\n end\n end\n end", "def show\n @images_index = ImagesIndex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @images_index }\n end\n end", "def index\n @asset_data = AssetData.all\n end", "def index\n @images = @owner.images\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @images }\n end\n end", "def index\n #@assets = Asset.all\n respond_to do |format|\n format.html\n format.json { render json: AssetsDatatable.new(view_context) }\n end \n end", "def retrieve(controller = '', action = '', options = {})\n options = { :full => false, :tagged => false, :shallow => false }.update(options)\n\n @assets = []\n @parsed_manifests = []\n @controller = controller\n @action = action\n @shallow_retrieval = options[:shallow]\n\n retrieve_controller_assets\n retrieve_action_assets if @action != ''\n @assets.uniq!\n\n @assets.map! { |asset| PathInfo.new(asset).abs } if options[:full]\n @assets.map! { |asset| tag(\"/#{asset.rel}\") } if options[:tagged]\n\n @assets\n end", "def index\n @avatar_twitters = AvatarTwitter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @avatar_twitters }\n end\n end", "def index\n @stats = Stat.where(:match_id => params[:match_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stats }\n end\n end", "def index\n @xml_samples = XmlSample.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @xml_samples }\n format.xml { render xml: @xml_samples }\n end\n end", "def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resources }\n end\n end", "def index\n @asset_info_adjustments = AssetInfoAdjustment.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asset_info_adjustments }\n format.xml { render xml: @asset_info_adjustments }\n end\n end" ]
[ "0.740832", "0.70975775", "0.7013955", "0.6968848", "0.6896635", "0.6886804", "0.6811859", "0.6811859", "0.67383313", "0.6697305", "0.6668664", "0.66502386", "0.66199934", "0.6602234", "0.6557599", "0.6534046", "0.64878243", "0.6468242", "0.6429968", "0.6393348", "0.6350668", "0.6341228", "0.6337665", "0.63152593", "0.63152593", "0.6311886", "0.63060117", "0.6271567", "0.6271196", "0.6269018", "0.626373", "0.62243587", "0.6182886", "0.6163465", "0.6160623", "0.61512965", "0.61512965", "0.61512965", "0.61512965", "0.61512965", "0.60636055", "0.6044459", "0.60413194", "0.603437", "0.6014044", "0.5995813", "0.5977621", "0.5951643", "0.59453857", "0.59451777", "0.59430647", "0.59073156", "0.5877187", "0.5877187", "0.58703876", "0.5855424", "0.5853169", "0.58444285", "0.58396155", "0.57893246", "0.5786113", "0.5786113", "0.5786113", "0.5771464", "0.57689375", "0.57671803", "0.5760603", "0.57433903", "0.5734795", "0.5729795", "0.57155293", "0.57137424", "0.57081807", "0.5686467", "0.56619537", "0.56619537", "0.56575274", "0.56536454", "0.5652318", "0.5650092", "0.56490684", "0.56468004", "0.564576", "0.5645717", "0.5642805", "0.564216", "0.56379765", "0.56344867", "0.563302", "0.5629305", "0.56287813", "0.5615479", "0.561545", "0.5615082", "0.5608749", "0.56044334", "0.5590856", "0.5583551", "0.5582563", "0.55715925" ]
0.68244594
6
POST /assets POST /assets.xml
def create @asset = Asset.new(params[:asset]) respond_to do |format| if @asset.save flash[:notice] = 'Asset was successfully created.' format.html { redirect_to asset_url(@asset) } format.js # render create.rjs << added for P/C >> format.xml { head :created, :location => asset_url(@asset) } else format.html { render :action => "new" } format.js # render create.rjs << added for P/C >> format.xml { render :xml => @asset.errors.to_xml } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @asset = assets.build(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n format.html { redirect_to user_asset_url(@asset) }\n format.xml { head :created, :location => user_asset_url(@asset) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors.to_xml }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(@asset, :notice => 'Asset was successfully created.') }\n format.xml { render :xml => @asset, :status => :created, :location => @asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n #format.html { redirect_to(@asset) }\n format.html { redirect_to(assets_url) }\n format.xml { render :xml => @asset, :status => :created, :location => @asset }\n\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = @org.assets.build(asset_params)\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to [@asset.org, @asset], notice: 'Asset was successfully created.' }\n format.json { render :show, status: :created, location: [@asset.org, @asset] }\n else\n format.html { render :new }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_asset(url, params = {})\n post '/video/v1/assets', {\n input: url\n }.merge(params)\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: I18n.t('controllers.create_success', name: @asset.class.model_name.human) }\n format.json { render json: @asset, status: :created, location: @asset }\n format.xml { render xml: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n format.xml { render xml: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n @countries = Country.find(:all)\n \n respond_to do |format|\n if @asset.save\n format.html { redirect_to(asset_manager_asset_path(@asset), :notice => 'Asset was successfully created.') }\n format.xml { render :xml => @asset, :status => :created, :location => @asset }\n else\n format.html { render :action => :new, :notice => 'Asset was not created.' }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(asset_params)\n\t\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render :show, status: :created, location: @asset }\n else\n format.html { render :new }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n @asset = Asset.create!(asset_param)\n json_response(@asset, :created)\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to assets_url, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n respond_to do |format|\n @asset_tag = AssetTag.new(asset_tag_params)\n puts @asset_tag.inspect\n\n if @asset_tag.save(validate: false)\n format.html { redirect_to @asset_tag, notice: 'Asset tag was successfully created.' }\n format.json { render :show, status: :created, location: @asset_tag }\n AssetTag.reindex\n else\n format.html { render :new }\n format.json { render json: @asset_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #debugger\n blog = blog_params[:name]\n @user = User.find(session[:user_id])\n\n params[:image][:attached_assets_attrs].each do |item|\n ImgGroup.post item[:asset], @user, blog\n end\n\n respond_to do |format|\n format.html { render action: 'done' }\n format.json { render text: 'All posted.', status: :created, location: @image }\n end\n end", "def index\n @assets = assets.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets.to_xml }\n end\n end", "def create\n @asset_file = AssetFile.new(asset_file_params)\n\n respond_to do |format|\n if @asset_file.save\n format.html { redirect_to @asset_file, notice: 'Asset file was successfully created.' }\n format.json { render :show, status: :created, location: @asset_file }\n else\n format.html { render :new }\n format.json { render json: @asset_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(asset_params)\n\n respond_to do |format|\n if @asset.save\n # format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n flash[:notice] = 'Fotoet blev oprettet.'\n format.html { redirect_to assets_url, notice: 'Fotoet blev oprettet.' }\n format.json { render action: 'show', status: :created, location: @asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n repo = assets_repo\n\n file = (params.has_key?(:file)) ? params[:file] : false\n @v_asset = repo.create file\n\n respond_to do |format|\n if @v_asset.save\n format.html { redirect_to @v_asset, notice: 'V asset was successfully created.' }\n format.json { render json: @v_asset, status: :created, location: @v_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @v_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if request.format == :xml\n super\n else\n passed_values = params[:asset]\n @asset = Asset.create(\n :g_u_i_d => passed_values[:g_u_i_d],\n :tag => passed_values[:tag],\n :name => passed_values[:name],\n :i_d_in_info_source => passed_values[:i_d_in_info_source],\n :status => \"1\",\n :model => Model.find_by_guid(passed_values[:model]),\n :manufacturer => Manufacturer.find_by_guid(passed_values[:manufacturer]),\n :serial_number => passed_values[:serial_number])\n Notification.create(\n :message => \"Created an Asset via HTML CRUD utility (create Asset form)\", \n :operation => \"Create\",\n :ccom_entity => @asset.guid,\n :about_user => User.find_by_id(session[:user_id]),\n :database => ActiveRegistry.find_database(session[:user_id])\n ) \n if object_type = ObjectType.find_by_guid(passed_values[:object_type])\n @asset.update_attributes(:object_type => object_type)\n else\n @asset.update_attributes(:object_type => ObjectType.undetermined)\n end\n \n ref_valid_network = ValidNetwork.find_by_guid(passed_values[:valid_network])\n valid_network = ref_valid_network.nil? ? nil : ref_valid_network.dup_entity(:gen_new_guids => true)\n @asset.update_attributes( :valid_network => valid_network)\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = \"Asset was saved into database at #{@asset.last_edited}\"\n format.html { redirect_to(@asset) }\n else\n @types = get_all_asset(:object_type)\n @manufacturers = get_all_asset(:manufacturer)\n @models = get_all_asset(:model)\n @networks = define_networks()\n format.html { render :action => \"new\" }\n end\n end\n end\n end", "def create\n @attached_asset = AttachedAsset.new(params[:attached_asset])\n\n respond_to do |format|\n if @attached_asset.save\n format.html { redirect_to @attached_asset, notice: 'Attached asset was successfully created.' }\n format.json { render json: @attached_asset, status: :created, location: @attached_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attached_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n format.html { redirect_to(admin_assets_url) }\n format.xml { render :xml => @asset, :status => :created, :location => admin_asset_url(@asset) }\n format.js { render :json => @asset, :status => 200, :location => admin_asset_url(@asset) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n format.js { render :json => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(asset_params)\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to edit_asset_path(@asset), notice: 'Asset was successfully created.' }\n format.json { render action: 'edit', status: :created, location: @asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = current_user.assets.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n track_activity @asset\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project_asset = ProjectAsset.new(params[:project_asset])\n\n respond_to do |format|\n if @project_asset.save\n format.html { redirect_to(@project, :notice => 'ProjectAsset was successfully created.') }\n format.xml { render :xml => @project_asset, :status => :created, :location => @project_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset_item = AssetItem.new(params[:asset_item])\n\n respond_to do |format|\n if @asset_item.save\n flash[:notice] = 'AssetItem was successfully created.'\n format.html { redirect_to(asset_items_url) }\n format.xml { render :xml => @asset_item, :status => :created, :location => @asset_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset_allocate = AssetAllocate.new(asset_allocate_params)\n\n respond_to do |format|\n if @asset_allocate.save\n format.html { redirect_to @asset_allocate, notice: 'Asset allocate was successfully created.' }\n format.json { render :show, status: :created, location: @asset_allocate }\n else\n format.html { render :new }\n format.json { render json: @asset_allocate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @admin_section = true\n @user_asset = UserAsset.new(params[:user_asset])\n\n respond_to do |format|\n if @user_asset.save\n format.html { redirect_to(@user_asset, :notice => 'File(s) were successfully uploaded.') }\n format.xml { render :xml => @user_asset, :status => :created, :location => @user_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @e_asset = EAsset.new(e_asset_params)\n\n respond_to do |format|\n if @e_asset.save\n format.html { redirect_to @e_asset, notice: 'E asset was successfully created.' }\n format.json { render :show, status: :created, location: @e_asset }\n else\n format.html { render :new }\n format.json { render json: @e_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n begin\n @asset = Asset.create!(asset_params)\n render template: 'assets/show', status: :created\n rescue Exception => e\n render json: {:message=> e.to_s}.to_json, status: :internal_server_error\n end\n end", "def create\n @stage = Stage.new(params[:stage])\n\n respond_to do |format|\n if @stage.save\n format.html { redirect_to(asset_manager_stage_path(@stage), :notice => 'Stage was successfully created.') }\n format.xml { render :xml => @stage, :status => :created, :location => @stage }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @stage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n\t @assets = @campaign.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def create_file(file_name, asset_path, update_source)\n response_name = \"#{response_name}\"\n # * 1) BASE URL\n base_url = 'https://dev-cascade.chapman.edu/api/v1/'.to_s\n\n # * 2) REST API ACTION\n # https://wimops.chapman.edu/wiki/WWW#Key_Links\n # https://www.hannonhill.com/cascadecms/latest/developing-in-cascade/rest-api/index.html\n rest_action = 'create/'.to_s # ! KEEP TRAILING SLASH\n\n # * 3) ASSET TYPE\n # this is easy to find in cascade's edit/preview url.\n # ie https://dev-cascade.chapman.edu/entity/open.act?id=7f74b81ec04d744c7345a74906ded22a&type=page\n asset_type = 'file/' # ! KEEP TRAILING SLASH\n\n # * 4) ASSET PATH OR ID\n # you can also use its path (ie \"Chapman.edu/_cascade/formats/modular/widgets/1-column\")... but.. whitespace.\n asset_path = \"#{asset_path}\" # ! NO TRAILING SLASH\n\n # * 5) SECRETS\n # set these in environment_variables.yml\n cascade_username = '?u=' + ENV['CASCADE_USERNAME']\n cascade_password = '&p=' + ENV['CASCADE_PASSWORD']\n cascade_api_key = '?apiKey=' + ENV['CASCADE_API_KEY']\n\n update_source = \"#{update_source}\"\n\n data = File.read(update_source)\n p data\n\n response_body = data\n\n url_post =\n base_url + rest_action + asset_type + asset_path + cascade_api_key\n\n # 👹Editing assets unfortunately requires PATH, SITENAME, ID. This can be obtained by reading the asset's response.body 👆\n # HTTParty.post(url_post, body: { asset: { xmlBlock: { xml: data, path: \"_cascade/blocks/html/0-write-test\", parentFolderId: parent_folder_id, siteName: \"Chapman.edu\", id: \"365ae5dec0a81e8a20b1d746fd3e0778\" } } }.to_json)\n\n p HTTParty.post(\n url_post,\n body: {\n \"asset\": {\n \"file\": {\n \"text\": data,\n \"rewriteLinks\": false,\n \"maintainAbsoluteLinks\": false,\n \"shouldBePublished\": true,\n \"shouldBeIndexed\": true,\n # \"lastPublishedDate\": \"Jul 15, 2020, 12:56:28 AM\",\n \"lastPublishedBy\": \"cbryant\",\n \"expirationFolderRecycled\": false,\n \"metadataSetId\": \"6fef14a3c04d744c610b81da9d165a27\",\n \"metadataSetPath\": \"Default\",\n \"metadata\": {},\n \"reviewOnSchedule\": false,\n \"reviewEvery\": 180,\n # \"parentFolderId\": \"fd5121b0c04d744c42ab23aa0aba0ba8\",\n \"parentFolderPath\": \"_assets\",\n # \"lastModifiedDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"lastModifiedBy\": \"mthomas\",\n # \"createdDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"createdBy\": \"mthomas\",\n # \"path\": \"#{asset_path}#{file_name}\",\n # \"siteId\": \"6fef14a3c04d744c610b81dac0a8d082\",\n \"siteName\": \"Chapman.edu\",\n \"tags\": [],\n \"name\": file_name,\n # \"id\": \"2ba09c01c0a81e4b0015d01bfd25ea78\"\n }\n },\n \"success\": true\n }.to_json\n )\n # p \"🎉 View changes at https://dev-cascade.chapman.edu/entity/open.act?id=#{\n # asset_id\n # }&type=#{asset_type}\".chomp('/')\nend", "def index\n @car = Car.find(params[:car_id])\n @assets = @car.assets\n\n respond_to do |format|\n format.xml {render xml: @assets}\n format.json {render json: @assets}\n end\n end", "def create\n # @asset = @attachable.assets.new(params[:asset])\n @asset = @attachable.assets.build(asset_params)\n\n respond_to do |format|\n if @asset.save\n format.html {\n render :json => [@asset.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json { render json: {files: [@asset.to_jq_upload]}, status: :created, location: @upload }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(asset_params)\n\n respond_to do |format|\n if @asset.save\n tokens = @asset.name.split\n num_elements = tokens.size\n tokens.each do |token|\n AssetTermIndex.create(term: token.downcase, origin_string_size: num_elements, asset_id: @asset.id)\n end\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_asset\n asset = AssetService.create(@context, unsafe_params)\n\n render json: { id: asset.uid }\n end", "def create\n @fixed_asset = FixedAsset.new(fixed_asset_params)\n\n respond_to do |format|\n if @fixed_asset.save\n format.html { redirect_to @fixed_asset, notice: 'Fixed asset was successfully created.' }\n format.json { render :show, status: :created, location: @fixed_asset }\n else\n format.html { render :new }\n format.json { render json: @fixed_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.find(params[:asset_id])\n \t@tag = @asset.tags.build(params[:tag])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(asset_manager_asset_tag_path(@asset, @tag), :notice => 'Tag was successfully created.') }\n format.xml { render :xml => asset_manager_asset_tag_path(@asset, @tag), :status => :created, :location => @tag }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset_data = AssetData.new(asset_data_params)\n if @asset_data.save\n respond_with @asset_data, notice: 'Asset data was successfully created.'\n else\n render :new\n end\n end", "def create\n\t\t@asset = Asset.new(params[:asset])\n\n\t\trespond_to do |format|\n\t\t\tif @asset.save\n\t\t\t\tformat.html { redirect_to @asset.page, notice: 'Boom, asset created.' }\n\t\t\t\t# format.json { render json: @asset, status: :created, location: @asset }\n\t\t\t\t# @template = render(:partial => 'assets/form', :locals => { :asset => @asset })\n\t\t\t\t# format.json { render json: @template, status: :created, location: @asset }\n\t\t\t\tformat.json { render :json => { :template => render_to_string(:partial => 'assets/form', :formats => [:html], :locals => { :asset => @asset }) } }\n\n\n\t\t\telse\n\t\t\t\tformat.html { render action: \"Create new asset\" }\n\t\t\t\tformat.json { render json: @asset.errors, status: :unprpcessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @asset = Asset.new(params[:asset])\n @asset.parse_meta\n if @asset.id? && Asset.exists?(@asset.id)\n @asset = Asset.find(@asset.id)\n @asset.user_id = nil\n @asset.submitted = true\n @asset.revision = false\n @asset.approved = false\n @asset.checked_out = false\n success = @asset.update_attributes(params[:asset])\n else\n success = @asset.save\n end\n\n respond_to do |format|\n if success\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_asset_to_stage\n if !params[:asset_ids].nil?\n @stage = Stage.find(session[:stage_id])\n asset_set = Set.new\n params[:asset_ids].each do |asset_id|\n asset_set.add(Asset.find(asset_id.to_i))\n end\n asset_set.each do |new_asset|\n @stage.assets.each do |current_asset|\n if current_asset.id == new_asset.id\n asset_set.delete(new_asset)\n break\n end\n end\n end\n \n asset_set.each do |asset|\n @stage.assets << asset\n end\n \n if @stage.save\n redirect_to :back, :notice =>\"Successfully added to the stage.\"\n else\n redirect_to :back, :error => \"Assets were not added to the stage.\"\n end\n else\n redirect_to :back, :alert => \"No assets were selected\"\n end\n end", "def create\n @asset_request = AssetRequest.new(params[:asset_request])\n\n respond_to do |format|\n if @asset_request.save\n format.html { redirect_to @asset_request, notice: 'Asset request was successfully created.' }\n format.json { render json: @asset_request, status: :created, location: @asset_request }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset_status = AssetStatus.new(asset_status_params)\n\n respond_to do |format|\n if @asset_status.save\n format.html { redirect_to @asset_status, notice: 'Asset status was successfully created.' }\n format.json { render :show, status: :created, location: @asset_status }\n else\n format.html { render :new }\n format.json { render json: @asset_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.new(project_params)\n\t#@project.assets.build\n respond_to do |format|\n if @project.save\n if params[:assets] && params[:assets]['attachment'] \n params[:assets]['attachment'].each do |a|\n @asset = @project.assets.create!(:attachment => a,:assetable_id => @project.id,:user_id=>@project.user.id) \n end\n end\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else #if save else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end #respond to \n end", "def create\n @asset = current_user.asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def asset_params\n params.require(:asset).permit()\n end", "def index\n @assets = Asset.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @assets.to_xml }\n end\n end", "def create\n @asset = OtherAsset.new(params[:asset])\n asset_create('other', others_url)\n end", "def create\n @assettrack = Assettrack.new(params[:assettrack])\n\n respond_to do |format|\n if @assettrack.save\n flash[:notice] = 'Assettrack was successfully created.'\n format.html { redirect_to(@assettrack) }\n format.xml { render :xml => @assettrack, :status => :created, :location => @assettrack }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @assettrack.errors, :status => :unprocessable_entity }\n end\n end\n end", "def asset_params\n params.require(:asset).permit(:serial, :company_id, :identification, :certificate, :calibration_date, :due_date, :visa_address, :model_id, :reclassification, :use_reclassification, :avaliable, :calibrated_by)\n end", "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def create\n @asset = Asset.new(params[:asset])\n\n if @asset.save\n respond_to do |format|\n format.html do\n render json: [@asset.to_jq_upload].to_json,\n content_type: 'text/html',\n layout: false\n end\n format.json do\n render json: [@asset.to_jq_upload].to_json\n end\n end\n else\n render json: [{ error: 'custom_failure' }], status: 304\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(\"/admin/posts/#{@asset.post_id}\", :notice => 'Gravado com Sucesso') } \n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def upload_asset(filename, data)\n r = request('UploadAsset', { :filename => filename, :data => data })\n \n result = { :status => r['status'] == ' ok ', :key => r['key'] }\n \n return result\n end", "def add_assets\n num_files = params[:count].to_i\n \n @new_assets = []\n @new_assets_html = []\n num_files.times do |file_num|\n # recreate the file key from the current index\n file = params[\"file-\"+file_num.to_s]\n @asset = Asset.new(:name => file.original_filename)\n @asset.save\n @asset.save_file(file)\n \n @new_assets.push(@asset)\n # render the html to add to the page for the json response\n asset_html = render_to_string :partial => \"shared/asset.html.haml\", :locals => { :asset => @asset }\n @new_assets_html.push(asset_html)\n end\n\n respond_to do |format|\n format.html { redirect_to assets_url, notice: 'Asset was successfully created.' }\n format.json { render json: {:assets => @new_assets, :assets_html => @new_assets_html, status: :created} }\n end\n\n end", "def index\n @asset = Asset.find(params[:asset_id])\n @tags = @asset.tags\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tags }\n end\n end", "def asset_params\n params.require(:asset).permit(:asset_type, :asset_tag, :serial_nr, :po, :po_date, :price, :lifecycle, :make, :model, :priority, transfers_attributes: [:date, :asset_id, :employee_id, :location_id, :room])\n end", "def create\n @primary_asset = PrimaryAsset.new(primary_asset_params)\n\n respond_to do |format|\n if @primary_asset.save\n format.html { redirect_to @primary_asset, notice: 'Primary asset was successfully created.' }\n format.json { render :show, status: :created, location: @primary_asset }\n else\n format.html { render :new }\n format.json { render json: @primary_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload_xml_file(file_name, xml)\n # Creates directory if it doesn't exist\n create_upload_dir\n # Save file to server's uploads dir\n file_to_upload = File.open(Rails.root.join('public', 'uploads', file_name), \"wb\")\n file_to_upload.write(xml)\n file_to_upload.close()\n end", "def asset_params\n params.require(:asset).permit(:user_id, :asset)\n end", "def new\n @asset = Asset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def new\n @asset = Asset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def create\n @customer_asset = CustomerAsset.new(params[:customer_asset])\n\n respond_to do |format|\n if @customer_asset.save\n format.html { redirect_to @customer_asset, notice: 'Customer asset was successfully created.' }\n format.json { render json: @customer_asset, status: :created, location: @customer_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @c_asset = CAsset.new(params[:c_asset])\n\n authorize! :create, @c_asset\n respond_to do |format|\n if @c_asset.save\n format.html { redirect_to c_assets_path, :notice => 'C asset was successfully created.' }\n format.json { render :json => @c_asset, :status => :created, :location => @c_asset }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @c_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @asset = Asset.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def create\n @admin_section = true\n\n @course_asset = CourseAsset.new(params[:course_asset])\n\n respond_to do |format|\n if @course_asset.save\n format.html { redirect_to(@course_asset, :notice => 'File(s) were successfully uploaded.') }\n format.xml { render :xml => @course_asset, :status => :created, :location => @course_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @asset = Asset.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n format.xml { render xml: @asset }\n end\n end", "def push_assets\n PUSH_ASSETS\n end", "def index\n @user_assets = UserAsset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_assets }\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\t\[email protected]_id = params[:campaign_id]\n\n file_dir = \"#{FILE_STORAGE_PATH}/#{@campaign.id}\"\n file_path = \"#{file_dir}/#{@asset.name}\"\n rescue_file_path = \"#{FILE_STORAGE_PATH}/#{@asset.name}\"\n\n if !File.exists?(file_dir) and !File.directory?(file_dir)\n Dir.mkdir(file_dir)\n if !File.exists?(file_dir)\n flash[:error] = \"Directory #{file_dir} creation failed. Uploading the file to the global storage area.\"\n file_path = rescue_file_path\n end\n end\n\n if @asset.save!\n\t\t @asset.path = file_path\n\t\t @asset.url = FILE_URL_TEMPLATE.sub(':campaign_id', @campaign.id.to_s).sub(':asset_id',@asset.id.to_s)\n\t\t File.open(file_path, \"wb\") do |f|\n\t\t\t f.write(params[:asset][:path].read) unless params[:asset][:path].nil?\n\t\t end\n end\n \n\t\trespond_to do |format|\n \tif @asset.save\n flash[:notice] = \"File #{@asset.name} has been successfully added to the campaign #{@campaign.name}.\"\n\t\t\t\tformat.html { redirect_to(campaign_assets_url([@campaign, @asset])) }\n\t format.xml { render :xml => @asset, :status => :created, :location => @asset }\n else\n \tformat.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\t\n\tend", "def save(env)\n locals = {title: params['title'], attachment: params['attachment']}\n [201, {}, haml(:saved, :locals => locals )]\n end", "def create\n @gallery_asset = GalleryAsset.new(params[:gallery_asset])\n\n respond_to do |format|\n if @gallery_asset.save\n flash[:notice] = 'GalleryAsset was successfully created.'\n format.html { redirect_to(@gallery_asset) }\n format.xml { render :xml => @gallery_asset, :status => :created, :location => @gallery_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gallery_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @game_asset = GameAsset.new(game_asset_params)\n @game_asset.user_id = current_user.id\n @game_asset.make_public = false\n @game_asset.file_uploaded = false\n @game_asset.downloaded_times = 0\n\n respond_to do |format|\n if @game_asset.save\n format.html { redirect_to asset_file_upload_game_asset_path(@game_asset), notice: '素材の仮登録が完了しました。引き続き素材ファイルをアップロードして下さい。' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @cassete = Cassete.new(cassete_params)\n\n respond_to do |format|\n if @cassete.save\n format.html { redirect_to @cassete, notice: 'Cassete was successfully created.' }\n format.json { render :show, status: :created, location: @cassete }\n else\n format.html { render :new }\n format.json { render json: @cassete.errors, status: :unprocessable_entity }\n end\n end\n end", "def assets; end", "def assets; end", "def assets; end", "def index\n @artefact = Artefact.find(params[:artefact_id])\n\n @assets = @artefact.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assets }\n end\n end", "def post(data)\n response_data = []\n data.each do |xml|\n req = send_request(xml)\n\n if req[:code].to_i.between?(200, 201)\n response_data << req[:data]\n else\n if req[:code] == \"401\"\n raise ResponseError, \"Could not authenticate with the Pomegranate API. Ensure that your credentials are correct.\"\n elsif req[:code] == \"400\"\n raise ResponseError, \"Bad asset value formatting. Please reformat and try again.\"\n else\n raise StandardError, \"An unknown error has occured.\"\n end\n response_data = false\n break\n end\n end\n\n response_data\n end", "def asset_params\n params.require(:asset).permit(:file, :name, :html, :width, :height)\n end", "def save\n return if @content.nil?\n put_rest \"extra/#{@name}\", @content, :content_type => \"application/octet-stream\"\n end", "def new\n @artefact = Artefact.find(params[:artefact_id])\n @asset = @artefact.assets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n end\n end", "def create\n @articy_draft = ArticyDraft.new\n\n file = params[:articy_draft][:file]\n @articy_draft.xml = file\n @articy_draft.notes = params[:articy_draft][:notes]\n\n respond_to do |format|\n if @articy_draft.save\n format.html { redirect_to root_path, notice: 'Articy Draft XML was successfully created.' }\n format.json { render action: 'show', status: :created, location: @articy_draft }\n else\n format.html { render action: 'new' }\n format.json { render json: @articy_draft.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @assets = @attachable.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assets.map{|upload| upload.to_jq_upload } }\n end\n end", "def create\n @genbank_file = GenbankFile.new(params[:genbank_file])\n\n respond_to do |format|\n if @genbank_file.save\n format.xml { render :xml => @genbank_file, :status => :created, :location => @genbank_file }\n format.json { render :json => @genbank_file, :status => :created, :location => @genbank_file }\n else\n format.xml { render :xml => @genbank_file.errors, :status => :unprocessable_entity }\n format.json { render :json => @genbank_file.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @article = Article.new\n @article.assets.build\n @assets = @article.assets\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @article }\n end\n end", "def create\n @archive_asset = @archive.archive_assets.build(archive_asset_params)\n if @archive_asset.save\n redirect_to archive_archive_assets_url(@archive),\n notice: flash_message(:create, model: ArchiveAsset)\n else\n render :new\n end\n end", "def index\n @assets = Asset.search(params[:search], params[:page])\n @stages = Stage.find(:all)\n\n respond_to do |format|\n format.html #index.html.erb\n format.xml { render :xml => @assets }\n end\n end", "def create\n \n @character = current_user.characters.new(params[:character])\n @assets = Asset.where(:company_id => current_user.company_id)\n respond_to do |format|\n format.html do\n if @character.save!\n unless params[:assets].blank?\n params[:assets].each do|a|\n asset = Asset.find_by_name(a)\n @character.assets << asset\n end\n end\n redirect_to characters_path, notice: 'Character was successfully created.'\n else\n render action: \"new\"\n end\n end\n format.js do\n if @character.save\n format.json { render json: @character, status: :created, location: @character }\n else\n format.json { render json: @character.errors, status: :unprocessable_entity }\n end\n\n end\n end\n end", "def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x|\n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x|\n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end", "def create\n @barcode_asset = BarcodeAsset.new(barcode_asset_params)\n\n respond_to do |format|\n if @barcode_asset.save\n format.html { redirect_to @barcode_asset, notice: 'Barcode asset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @barcode_asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @barcode_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path = '/files/', params = {})\n request :post, path, params\n end", "def asset_params\n params[:asset].permit(:file_url, :title, :description)\n end", "def add_assets_to_asset_set(client, asset_resource_names, asset_set_resource_name, customer_id)\n operations = asset_resource_names.map do |asset_resource_name|\n client.operation.create_resource.asset_set_asset do |asa|\n asa.asset = asset_resource_name\n asa.asset_set = asset_set_resource_name\n end\n end\n\n response = client.service.asset_set_asset.mutate_asset_set_assets(\n customer_id: customer_id,\n operations: operations,\n )\n resource_name = response.results.first.resource_name\n puts \"Created asset set asset with resource name '#{resource_name}'\"\nend", "def create\n @asset_scrapping_entry = AssetScrappingEntry.new(asset_scrapping_entry_params)\n\n respond_to do |format|\n if @asset_scrapping_entry.save\n format.html { redirect_to @asset_scrapping_entry, notice: 'Asset scrapping entry was successfully created.' }\n format.json { render :show, status: :created, location: @asset_scrapping_entry }\n else\n format.html { render :new }\n format.json { render json: @asset_scrapping_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def asset_params\n params.require(:asset).permit(:title, :value)\n end", "def create\n record = Asset.new(params[:record])\n respond_to do |format|\n if record.save\n format.html \n format.json { render json: {} }\n else\n format.html { render action: \"new\" }\n format.json { render json: {} }\n end\n end\n end", "def assets\n []\n end", "def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x| \n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x| \n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end", "def ok_response asset, type, env\n asset = 'svg' == type ? asset.to_svg : asset.to_png\n [ 200, headers(env, asset, type, asset.length), [asset] ]\n end" ]
[ "0.6193998", "0.6134211", "0.6111537", "0.59586036", "0.5951087", "0.5928681", "0.5899147", "0.58949196", "0.5881975", "0.58126974", "0.5795135", "0.5778651", "0.57770455", "0.57389474", "0.57338536", "0.5731263", "0.5700603", "0.5698594", "0.5691174", "0.5639266", "0.5636452", "0.56232715", "0.56024617", "0.55902743", "0.5569412", "0.55631155", "0.5562733", "0.5553953", "0.55419767", "0.5521393", "0.5478463", "0.54707193", "0.5438367", "0.5437298", "0.5432064", "0.54317355", "0.54291475", "0.54265094", "0.5422217", "0.54015625", "0.5388951", "0.53696024", "0.53661287", "0.5362057", "0.53572035", "0.53540695", "0.5353548", "0.5344401", "0.5301252", "0.52993584", "0.52854645", "0.528351", "0.52823836", "0.52630955", "0.525636", "0.52376664", "0.5233354", "0.5227272", "0.5225103", "0.51975936", "0.5193199", "0.5193199", "0.51912546", "0.51833075", "0.51831055", "0.51678705", "0.51655155", "0.51607627", "0.51491123", "0.5142847", "0.5139712", "0.51378393", "0.51308835", "0.51301163", "0.5126864", "0.5126864", "0.5126864", "0.5123981", "0.51178575", "0.51175797", "0.51098394", "0.5105371", "0.50975317", "0.50894624", "0.50822693", "0.50797206", "0.50751895", "0.50588346", "0.5056704", "0.504838", "0.5047916", "0.5043304", "0.5041628", "0.5036235", "0.50338256", "0.5027758", "0.5027572", "0.5020313", "0.5018186", "0.5013445" ]
0.5408696
39
PUT /assets/1 PUT /assets/1.xml
def update @asset = Asset.find(params[:id]) respond_to do |format| if @asset.update_attributes(params[:asset]) flash[:notice] = 'Asset was successfully updated.' format.js # render update.rjs << added for P/C >> format.html { redirect_to asset_url(@asset)} format.xml { head :ok } else format.js # render update.rjs << added for P/C >> format.html { render :action => "edit" } format.xml { render :xml => @asset.errors.to_xml } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @asset = Asset.find(params[:id])\n \n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n flash[:notice] = 'Asset was successfully updated.'\n format.html { redirect_to(@asset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to(@asset, :notice => 'Asset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n flash[:notice] = \"File #{@asset.name} was successfully updated.\"\n format.html { redirect_to(campaign_assets_url(@campaign)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: I18n.t('controllers.update_success', name: @asset.class.model_name.human) }\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n format.xml { render xml: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n @artefact = Artefact.find(params[:artefact_id])\n\n @asset = @artefact.assets.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(asset_params)\n format.html { redirect_to artefact_path(@artefact), notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n flash[:notice] = 'Asset was successfully updated.'\n format.html { redirect_to user_asset_url(@asset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors.to_xml }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html do\n flash[:notice] = 'Asset was successfully updated.'\n redirect_to(admin_assets_url)\n end\n format.xml { head :ok }\n format.js { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n format.js { render :json => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n find_asset\n @asset.update!(asset_params)\n\n render json: @asset, adapter: :json\n end", "def put(path = '/files/', params = {})\n request :put, path, params\n end", "def update!(**args)\n @asset = args[:asset] if args.key?(:asset)\n @resource_name = args[:resource_name] if args.key?(:resource_name)\n @status = args[:status] if args.key?(:status)\n end", "def update\n record = Asset.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def update!(**args)\n @asset = args[:asset] if args.key?(:asset)\n @asset_set = args[:asset_set] if args.key?(:asset_set)\n @resource_name = args[:resource_name] if args.key?(:resource_name)\n @status = args[:status] if args.key?(:status)\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset }\n else\n format.html { render :edit }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@asset = Asset.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tif @asset.update_attributes(params[:asset])\n\t\t\t\tformat.html { redirect_to @asset.page, notice: 'Boom, asset updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @post.errors, status: :unprpcessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @user_asset = UserAsset.find(params[:id])\n\n respond_to do |format|\n if @user_asset.update_attributes(params[:user_asset])\n format.html { redirect_to(@user_asset, :notice => 'User asset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to [@asset.org, @asset], notice: 'Asset was successfully updated.' }\n format.json { render :show, status: :ok, location: [@asset.org, @asset] }\n else\n format.html { render :edit }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = OtherAsset.find(params[:id])\n asset_update(params[:asset], others_url)\n end", "def update\n @pic = Asset.find(params[:id])\n\n respond_to do |format|\n if @pic.update_attributes(params[:asset])\n format.html { redirect_to new_admin_assets_path, notice: 'ok' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = current_user.assets.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n track_activity @asset\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to root_path, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n #format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.html { redirect_to assets_url, notice: 'Fotoet blev opdateret.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @asset = args[:asset] if args.key?(:asset)\n end", "def update\n @stage = Stage.find(params[:id])\n\n respond_to do |format|\n if @stage.update_attributes(params[:stage])\n format.html { redirect_to(asset_manager_stage_path(@stage), :notice => 'Stage was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => :edit }\n format.xml { render :xml => @stage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to(asset_manager_asset_tags_path(@tag.asset_id), :notice => 'Tag was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def reindex_asset! asset_or_tag\n asset = get_asset_or_tag asset_or_tag\n http_get(\"/api/admin/solr/asset/#{asset.tag}\") do |response|\n parse_response response, :expects => 200\n end\n\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to edit_asset_path(@asset), notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @fixed_asset.update(fixed_asset_params)\n FixedAsset.reindex\n format.html { redirect_to @fixed_asset, notice: 'Fixed asset was successfully updated.' }\n format.json { render :show, status: :ok, location: @fixed_asset }\n else\n format.html { render :edit }\n format.json { render json: @fixed_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @assettrack = Assettrack.find(params[:id])\n\n respond_to do |format|\n if @assettrack.update_attributes(params[:assettrack])\n flash[:notice] = 'Assettrack was successfully updated.'\n format.html { redirect_to(@assettrack) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @assettrack.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @attached_asset = AttachedAsset.find(params[:id])\n\n respond_to do |format|\n if @attached_asset.update_attributes(params[:attached_asset])\n format.html { redirect_to @attached_asset, notice: 'Attached asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attached_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n respond_to do |format|\n if @asset_file.update(asset_file_params)\n format.html { redirect_to @asset_file, notice: 'Asset file was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_file }\n else\n format.html { render :edit }\n format.json { render json: @asset_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @record = Asset.find(params[:id])\n @record.update_attributes(params[:@record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def update\n # If attributes are empty i.e. all removed, returns empty hash\n params[:asset][:updated_tag_attributes] ||= {}\n params[:asset][:updated_caption_attributes] ||= {}\n params[:asset][:updated_credit_attributes] ||= {}\n @asset = Asset.find(params[:id])\n \n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to(asset_manager_asset_path(@asset), :notice => 'Asset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => :edit }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @e_asset.update(e_asset_params)\n format.html { redirect_to @e_asset, notice: 'E asset was successfully updated.' }\n format.json { render :show, status: :ok, location: @e_asset }\n else\n format.html { render :edit }\n format.json { render json: @e_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project_asset.update(params[:project_asset])\n format.html { redirect_to(@project, :notice => 'ProjectAsset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit_asset\n @asset = Asset.find(params[:id])\n end", "def update\n @asset_request = AssetRequest.find(params[:id])\n\n respond_to do |format|\n if @asset_request.update_attributes(params[:asset_request])\n format.html { redirect_to @asset_request, notice: 'Asset request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @audio_file = AudioFile.find(params[:id])\n\n respond_to do |format|\n if @audio_file.update_attributes(params[:audio_file])\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.xml { render :xml => @audio_file.errors, :status => :unprocessable_entity }\n format.json { render :json => @audio_file.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def put(*args)\n request(:put, *args)\n end", "def update\n @course_asset = CourseAsset.find(params[:id])\n\n respond_to do |format|\n if @course_asset.update_attributes(params[:course_asset])\n format.html { redirect_to(@course_asset, :notice => 'Course asset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def save\n return if @content.nil?\n put_rest \"extra/#{@name}\", @content, :content_type => \"application/octet-stream\"\n end", "def update\n @vip = Vip.find(params[:id])\n\n # Better way to do update. Assign the values first, then save them.\n @vip.attributes=params[:vip]\n @vip.asset.attributes=params[:asset]\n \n respond_to do |format|\n if @vip.save and @vip.asset.save\n flash[:notice] = 'Vip was successfully updated.'\n format.html { render :action => \"edit\" }\n #format.html { redirect_to(@vip) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vip.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_put\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 contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end", "def update!(**args)\n @asset = args[:asset] if args.key?(:asset)\n @campaign = args[:campaign] if args.key?(:campaign)\n @resource_name = args[:resource_name] if args.key?(:resource_name)\n @status = args[:status] if args.key?(:status)\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def update\n respond_to do |format|\n if @asset_tag.update(asset_tag_params)\n format.html { redirect_to @asset_tag, notice: 'Asset tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_tag }\n else\n format.html { render :edit }\n format.json { render json: @asset_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def set_asset\n @asset = @org.assets.find(params[:id])\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 set_asset\n @asset = Asset.find(params[:id])\n end", "def update\n @asset_file = current_user.asset_files.find(params[:id]) \n\n respond_to do |format|\n if @asset_file.update(asset_file_params)\n format.html { redirect_to @asset_file, notice: 'File was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_file }\n else\n format.html { render :edit }\n format.json { render json: @asset_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, opts = {})\n request(:put, path, opts).body\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to session.delete(:return_to) || request.referer || edit_asset_path(@asset), notice: 'Asset was successfully updated.' }\n format.json { render json: { asset: @asset, assigned_to: @asset.user_id ? User.find(@asset.user_id).name : nil } }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, options={})\n request :put, path, options\n end", "def update\n respond_to do |format|\n if @atricle.update(atricle_params)\n format.html { redirect_to @atricle, notice: \"Atricle was successfully updated.\" }\n format.json { render :show, status: :ok, location: @atricle }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @atricle.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def create_file(file_name, asset_path, update_source)\n response_name = \"#{response_name}\"\n # * 1) BASE URL\n base_url = 'https://dev-cascade.chapman.edu/api/v1/'.to_s\n\n # * 2) REST API ACTION\n # https://wimops.chapman.edu/wiki/WWW#Key_Links\n # https://www.hannonhill.com/cascadecms/latest/developing-in-cascade/rest-api/index.html\n rest_action = 'create/'.to_s # ! KEEP TRAILING SLASH\n\n # * 3) ASSET TYPE\n # this is easy to find in cascade's edit/preview url.\n # ie https://dev-cascade.chapman.edu/entity/open.act?id=7f74b81ec04d744c7345a74906ded22a&type=page\n asset_type = 'file/' # ! KEEP TRAILING SLASH\n\n # * 4) ASSET PATH OR ID\n # you can also use its path (ie \"Chapman.edu/_cascade/formats/modular/widgets/1-column\")... but.. whitespace.\n asset_path = \"#{asset_path}\" # ! NO TRAILING SLASH\n\n # * 5) SECRETS\n # set these in environment_variables.yml\n cascade_username = '?u=' + ENV['CASCADE_USERNAME']\n cascade_password = '&p=' + ENV['CASCADE_PASSWORD']\n cascade_api_key = '?apiKey=' + ENV['CASCADE_API_KEY']\n\n update_source = \"#{update_source}\"\n\n data = File.read(update_source)\n p data\n\n response_body = data\n\n url_post =\n base_url + rest_action + asset_type + asset_path + cascade_api_key\n\n # 👹Editing assets unfortunately requires PATH, SITENAME, ID. This can be obtained by reading the asset's response.body 👆\n # HTTParty.post(url_post, body: { asset: { xmlBlock: { xml: data, path: \"_cascade/blocks/html/0-write-test\", parentFolderId: parent_folder_id, siteName: \"Chapman.edu\", id: \"365ae5dec0a81e8a20b1d746fd3e0778\" } } }.to_json)\n\n p HTTParty.post(\n url_post,\n body: {\n \"asset\": {\n \"file\": {\n \"text\": data,\n \"rewriteLinks\": false,\n \"maintainAbsoluteLinks\": false,\n \"shouldBePublished\": true,\n \"shouldBeIndexed\": true,\n # \"lastPublishedDate\": \"Jul 15, 2020, 12:56:28 AM\",\n \"lastPublishedBy\": \"cbryant\",\n \"expirationFolderRecycled\": false,\n \"metadataSetId\": \"6fef14a3c04d744c610b81da9d165a27\",\n \"metadataSetPath\": \"Default\",\n \"metadata\": {},\n \"reviewOnSchedule\": false,\n \"reviewEvery\": 180,\n # \"parentFolderId\": \"fd5121b0c04d744c42ab23aa0aba0ba8\",\n \"parentFolderPath\": \"_assets\",\n # \"lastModifiedDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"lastModifiedBy\": \"mthomas\",\n # \"createdDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"createdBy\": \"mthomas\",\n # \"path\": \"#{asset_path}#{file_name}\",\n # \"siteId\": \"6fef14a3c04d744c610b81dac0a8d082\",\n \"siteName\": \"Chapman.edu\",\n \"tags\": [],\n \"name\": file_name,\n # \"id\": \"2ba09c01c0a81e4b0015d01bfd25ea78\"\n }\n },\n \"success\": true\n }.to_json\n )\n # p \"🎉 View changes at https://dev-cascade.chapman.edu/entity/open.act?id=#{\n # asset_id\n # }&type=#{asset_type}\".chomp('/')\nend", "def update\n respond_to do |format|\n if @atricle.update(atricle_params)\n format.html { redirect_to @atricle, notice: 'Atricle was successfully updated.' }\n format.json { render :show, status: :ok, location: @atricle }\n else\n format.html { render :edit }\n format.json { render json: @atricle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @svg_file = Cmtool::SvgFile.find(params[:id])\n\n respond_to do |format|\n if @svg_file.update_attributes(svg_file_params)\n format.html { redirect_to(cmtool.svg_files_path, :notice => I18n.t('cmtool.action.update.successful', :model => Cmtool::SvgFile.model_name.human)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @svg_file.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit\n @asset = Asset.find(params[:id])\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def update\n respond_to do |format|\n if @primary_asset.update(primary_asset_params)\n format.html { \n\t redirect_to @primary_asset, notice: 'Primary asset was successfully updated.' \n\t}\n format.json { render :show, status: :ok, location: @primary_asset }\n else\n format.html { \n\t render :edit }\n format.json { render json: @primary_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @old_ID = @asset.id\n asset_params[:id] = nil\n #get all activities from the asset and update their asset id\n @asset_activities = @asset.asset_activities\n if @asset = Asset.create(asset_params) \n #keep track of old assetID id for current asset\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content } \n #turn off current revision\n @old_revision_id = Revision.find_by(asset_id: @old_ID)\n #create revision record\n @new_revision = Revision.new()\n #inset new revision into table\n @new_revision.old_revision_id = @old_revision_id\n @new_revision.asset_id = @asset.id\n @new_revision.save()\n #update the activity ID that pertains to the asset ID\n @asset_activities.update_all(:asset_id => @asset.id)\n\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer_asset = CustomerAsset.find(params[:id])\n\n respond_to do |format|\n if @customer_asset.update_attributes(params[:customer_asset])\n format.html { redirect_to @customer_asset, notice: 'Customer asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @asset_set = args[:asset_set] if args.key?(:asset_set)\n @customer = args[:customer] if args.key?(:customer)\n @resource_name = args[:resource_name] if args.key?(:resource_name)\n @status = args[:status] if args.key?(:status)\n end", "def update\n respond_to do |format|\n if @asset_status.update(asset_status_params)\n format.html { redirect_to @asset_status, notice: 'Asset status was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_status }\n else\n format.html { render :edit }\n format.json { render json: @asset_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fixed_asset.update(fixed_asset_params)\n format.html { redirect_to @fixed_asset, notice: 'Fixed asset was successfully updated.' }\n format.json { render :show, status: :ok, location: @fixed_asset }\n else\n format.html { render :edit }\n format.json { render json: @fixed_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_asset\n @asset = Asset.find(params[:id])\n end", "def set_asset\n @asset = Asset.find(params[:id])\n end", "def set_asset\n @asset = Asset.find(params[:id])\n end", "def set_asset\n @asset = Asset.find(params[:id])\n end", "def set_asset\n @asset = Asset.find(params[:id])\n end", "def set_asset\n @asset = Asset.find(params[:id])\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @aviso = Aviso.find(params[:id])\n\n respond_to do |format|\n if @aviso.update_attributes(params[:aviso])\n format.html { redirect_to(@aviso, :notice => 'Aviso fue modificado exitosamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @aviso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset_allocate.update(asset_allocate_params)\n format.html { redirect_to @asset_allocate, notice: 'Asset allocate was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_allocate }\n else\n format.html { render :edit }\n format.json { render json: @asset_allocate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6663411", "0.6543097", "0.6458288", "0.64563084", "0.62763244", "0.6273026", "0.62198365", "0.6209169", "0.6209169", "0.6209169", "0.6172505", "0.6096301", "0.5975409", "0.5963124", "0.59567297", "0.59267664", "0.5914408", "0.5910384", "0.5907817", "0.5900452", "0.58916783", "0.5891502", "0.5885955", "0.5870746", "0.5859199", "0.5850832", "0.58300906", "0.58247215", "0.57908285", "0.5790277", "0.5779032", "0.57703805", "0.57664394", "0.5747624", "0.5742303", "0.57307434", "0.57201314", "0.5715791", "0.57066154", "0.56985754", "0.5691317", "0.5691078", "0.5689048", "0.5677058", "0.56736207", "0.567104", "0.56317973", "0.56184703", "0.56004256", "0.5565732", "0.55647355", "0.5546552", "0.55346346", "0.5523917", "0.5523462", "0.55121803", "0.5511427", "0.5504585", "0.55043477", "0.55043477", "0.55043477", "0.54989594", "0.5484873", "0.54749876", "0.54707724", "0.546737", "0.54662925", "0.5451842", "0.5451842", "0.54508823", "0.54396665", "0.5437174", "0.5437174", "0.5437174", "0.5437174", "0.5437174", "0.5437174", "0.5437174", "0.5437174", "0.5436187", "0.5423677", "0.5417793", "0.54125303", "0.54064065", "0.54025173", "0.54021627", "0.5386032", "0.5379788", "0.5370783", "0.5367878", "0.53675795", "0.5367497", "0.5367497", "0.5367497", "0.5367497", "0.5367497", "0.5364668", "0.5359958", "0.53589994", "0.53578323" ]
0.574395
34
DELETE /assets/1 DELETE /assets/1.xml
def destroy @asset = Asset.find(params[:id]) @asset.destroy respond_to do |format| format.js # render destroy.rjs << added for P/C >> format.html { redirect_to assets_url } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(assets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(assets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(assets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n \n respond_to do |format|\n format.html { redirect_to(asset_manager_assets_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy()\n\n respond_to do |format|\n format.html { redirect_to(campaign_assets_url([@campaign, @asset])) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to user_assets_url() }\n format.xml { head :ok }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset_item = AssetItem.find(params[:id])\n @asset_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(asset_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(asset_manager_asset_tags_path(@asset)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_assets_url) }\n format.js { render :nothing => true }\n format.xml { head :ok }\n end\n end", "def destroy\n @attached_asset = AttachedAsset.find(params[:id])\n @attached_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to attached_assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project_asset.destroy\n respond_to do |format|\n format.html do\n flash[:notice] = \"Asset deleted\"\n redirect_to(@project)\n end\n format.xml { head :ok }\n end\n end", "def destroy(v_asset)\n File.delete(v_asset.path)\n end", "def destroy\n @advertisement = Advertisement.find(params[:id])\n #if File.exists?(\"#{Rails.root}/#{@advertisement.filename}\")\n #File.delete(\"#{@advertisement.filename}\")\n #end\n @advertisement.destroy\n\n respond_to do |format|\n format.html { redirect_to advertisements_url }\n format.json { head :no_content }\n end\n end", "def delete\n begin \n # file_assets\n file_assets.each do |file_asset|\n file_asset.delete\n end\n # We now reload the self to update that the child assets have been removed...\n reload()\n # Call ActiveFedora Deleted via super \n super()\n rescue Exception => e\n raise \"There was an error deleting the resource: \" + e.message\n end\n end", "def destroy\n @asset = Resource.find(params[:id])\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to admin_resources_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset = current_user.assets.find(params[:id])\n @asset.destroy\n track_activity @asset\n\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n record = Asset.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @assettrack = Assettrack.find(params[:id])\n @assettrack.destroy\n\n respond_to do |format|\n format.html { redirect_to(assettracks_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @file = Asset.find_by(uid: params[:id])\n unless @file.editable_by?(@context)\n type = :warning\n text = \"You have no permission to deleted this Asset \\\"#{@file.prefix}\\\"\"\n path = api_assets_path\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n return\n end\n\n UserFile.transaction do\n @file.reload\n\n if @file.license.present? && [email protected]?\n type = :error\n text = \"This asset contains a license, and has been included in one or more apps. \" \\\n \"Deleting it would render the license inaccessible to these apps, \" \\\n \"breaking reproducibility. You can either first remove the license \" \\\n \"(allowing these existing apps to run without requiring a license) \" \\\n \"or contact the precisionFDA team to discuss other options.\"\n path = api_asset_path(@file)\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n return\n end\n @file.destroy\n end\n\n DNAnexusAPI.new(@context.token).call(@file.project, \"removeObjects\", objects: [@file.dxid])\n\n type = :success\n text = \"Asset \\\"#{@file.prefix}\\\" has been successfully deleted\"\n path = api_assets_path\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n end", "def destroy\n repo = assets_repo\n repo.destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to v_assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Asset.find(params[:id])\n @record.trash\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @file_version.destroy\n head :no_content\n end", "def destroy\n @gallery_asset = GalleryAsset.find(params[:id])\n @gallery_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(gallery_assets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset_file.destroy\n respond_to do |format|\n format.html { redirect_to asset_files_url, notice: 'Asset file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @primary_asset.destroy\n respond_to do |format|\n format.html { redirect_to primary_assets_url, notice: 'Primary asset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n ImagesIndex.delete params[:id]\n respond_to do |format|\n format.html { redirect_to(\"/images_indices\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url, notice: 'Asset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @material_apoyo = MaterialApoyo.find(params[:id])\n\n begin\n File.delete(@material_apoyo.url)\n @material_apoyo.destroy\n flash[:mensaje] = \"Archivo Eliminado del sistema.\"\n rescue Exception => e\n flash[:mensaje] = \"Error al intentar eliminar. #{e.message}\"\n end\n respond_to do |format|\n format.html { redirect_to material_apoyos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n head :no_content\n end", "def destroy\n @asset = OtherAsset.find(params[:id])\n asset_destroy(others_url)\n end", "def destroy\n @bes_asset.destroy\n respond_to do |format|\n format.html { redirect_to bes_assets_url, notice: 'Asset was successfully deleted!' }\n format.json { head :no_content }\n end\n end", "def remove_asset_from_stage\n @stage = Stage.find(params[:id])\n params[:asset_ids].each { |asset|\n @stage.assets.delete(Asset.find(asset)) }\n if @stage.save\n redirect_to :back, :notice =>\"Successfully deleted from stage.\"\n else\n redirect_to :back, :notice => \"An error occured\"\n end\n end", "def destroy\n @image_path = ImagePath.find(params[:id])\n @image_path.destroy\n\n respond_to do |format|\n format.html { redirect_to(image_paths_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @e_asset.destroy\n respond_to do |format|\n format.html { redirect_to e_assets_url, notice: 'E asset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_file \n #pp \"deleting file_asset: path is\" + full_filepath\n File.delete(full_filepath) if File.exists?(full_filepath)\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to org_assets_url(@asset.org), notice: 'Asset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @svg_file = Cmtool::SvgFile.find(params[:id])\n @svg_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(cmtool.svg_files_url, notice: I18n.t('cmtool.action.destroy.successful', model: Cmtool::SvgFile.model_name.human)) }\n format.xml { head :ok }\n end\n end", "def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end", "def destroy\n @misc_asset.destroy\n respond_to do |format|\n format.html { redirect_to misc_assets_url, notice: 'Misc asset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(attachments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(attachments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @audio_file = AudioFile.find(params[:id])\n @audio_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end", "def delete_media\n\n @asset = Asset.find(params[:id])\n @asset.destroy\n flash[:notice] = \"Project files have been deleted\"\n\n respond_to do |format|\n format.html { redirect_to @project, notice: 'Files have been deleted.' }\n end\n\n end", "def destroy\n @assetstatus.destroy\n respond_to do |format|\n format.html { redirect_to assetstatuses_url, notice: '删除成功!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_asset = ClientAsset.find(params[:id])\n client_name = @client_asset.client_name\n @client_asset.deleted = true\n @client_asset.deleted_at = Time.now\n @client_asset.save\n #@client_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to client_assets_url, notice: \"#{client_name}'s asset was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@asset = Asset.find(params[:id])\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to @asset.page }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def rm(*path)\n super; on_success{ nil }\n end", "def destroy\n @asset_request = AssetRequest.find(params[:id])\n @asset_request.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to(avisos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @c_asset = CAsset.find(params[:id])\n authorize! :destroy, @c_asset\n @c_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to c_assets_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @img = Img.find(params[:id])\n @img.destroy\n\n respond_to do |format|\n format.html { redirect_to(imgs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @download = Download.find(params[:id])\n @download.destroy\n\n respond_to do |format|\n format.html { redirect_to(downloads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @download = Download.find(params[:id])\n @download.destroy\n\n respond_to do |format|\n format.html { redirect_to(downloads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset_disposal = AssetDisposal.find(params[:id])\n @asset_disposal.destroy\n\n respond_to do |format|\n format.html { redirect_to(asset_disposals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @upload = Upload.find(params[:id])\n @upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(uploads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @upload = Upload.find(params[:id])\n @upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(uploads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @store = Store.get(params[:id])\n @asset=Asset.all(:store_id => @store.id)\n unless @asset.nil?\n @asset.each do |asset|\n if asset.assetable_type == \"image\"\n @image=Image.get(asset.assetable_id)\n @image.destroy unless @image.nil?\n elsif asset.assetable_type == \"video\"\n @video=Video.get(asset.assetable_id)\n File.delete(RAILS_ROOT+\"/public/movies/\"[email protected]_file_name) if File.exist?(RAILS_ROOT+\"/public/movies/\"[email protected]_file_name)\n @video.video_image.destroy\n File.delete(RAILS_ROOT+\"/public/video_image/\"[email protected]_image.source_file_name) if File.exist?(RAILS_ROOT+\"/public/video_image/\"[email protected]_image.source_file_name)\n @video.destroy unless @video.nil?\n end\n\n end\n \n end\n Asset.all.destroy\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to(stores_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @upload_file = UploadFile.find(params[:id])\n @upload_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(upload_files_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @razdel1 = Razdel1.find(params[:id])\r\n @razdel1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(razdel1s_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n #@asset = Asset.find(params[:id])\n if @asset && @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url, notice: I18n.t('controllers.destroy_success', name: @asset.class.model_name.human) } \n format.json { head :no_content }\n format.xml { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to assets_url, notice: I18n.t('controllers.destroy_fail', name: @asset.class.model_name.human) }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end\n end", "def destroy\n @arc = Arc.find(params[:id])\n @arc.destroy\n\n respond_to do |format|\n format.html { redirect_to(arcs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.photo.destroy\n @asset.save\n redirect_to :back\n end", "def destroy\n @file_upload = FileUpload.find(params[:id])\n @file_upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(file_uploads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n File.delete(Rails.root.join(\"app\",'assets','images',@photo.path))\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n if @asset.destroy\n flash[:success] = 'Asset removed'\n redirect_to assets_path\n else\n flash[:danger] = 'Failed to remove asset ' + @asset.product_serial\n redirect_to asset_path(@asset) # TODO: is this really neaded ?\n end\n end", "def rm path\n end", "def destroy\n # The correct implementation, with garbage collection:\n # if params.has_key?(:container_id)\n # container = ActiveFedora::Base.load_instance(params[:container_id]) \n # container.file_objects_remove(params[:id])\n # FileAsset.garbage_collect(params[:id])\n # else\n \n # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)\n ActiveFedora::Base.load_instance(params[:id]).delete \n flash[:notice] = \"Deleted #{params[:id]} from #{params[:container_id]}.\"\n \n if !params[:container_id].nil?\n redirect_params = {:controller => \"catalog\", :action => \"edit\", :id => params[:container_id], :anchor => \"file_assets\"}\n end\n redirect_params ||= {:action => 'index', :q => nil , :f => nil}\n \n redirect_to redirect_params\n \n end", "def destroy\n @score_file = ScoreFile.find(params[:id])\n @score_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(score_files_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @file_upload = FileUpload.find(params[:id])\n @file_upload.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(file_uploads_url) }\n wants.xml { head :ok }\n end\n end", "def destroy\n @xlink = Xlink.find(params[:id])\n @xlink.destroy\n\n respond_to do |format|\n format.html { redirect_to xlinks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @upload = Upload.find(params[:id])\n @upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_uploads_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @global_asset = GlobalAsset.find(params[:id])\n @global_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_global_assets_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @budget_src = BudgetSrc.find(params[:id])\n @budget_src.destroy\n\n respond_to do |format|\n format.html { redirect_to(budget_srcs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n \n album_path = ALBUMS_ROOT + @album.name\n if(File.exists?(album_path))\n FileUtils.remove_dir(album_path)\n end\n\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.js {render :layout => false}\n format.json { head :no_content }\n end\n end", "def delete\n model.delete_attachment(@path)\n end", "def destroy\n @asset_tag = AssetTag.find(params[:id])\n @asset_tag.destroy\n render json: {}\n \n end", "def destroy\n @attachment = Attachment.find_by_name(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :ok }\n end\n end", "def destroy\n File.unlink(@resource[:path])\n Puppet.debug \"deleted file #{@resource[:path]}\"\n end", "def destroy\n #FIXME: Double check auth is working for deletion. Also, maybe should only delete if not associated with any experiments.\n @data_file.destroy\n \n respond_to do |format|\n format.html { redirect_to(data_files_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @testfile.destroy\n respond_to do |format|\n format.html { redirect_to materials_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @yml_file = Cmtool::YmlFile.find(params[:id])\n @yml_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(cmtool.yml_files_url, notice: I18n.t('cmtool.action.destroy.successful', model: Cmtool::YmlFile.model_name.human)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @acre = Acre.find(params[:id])\n @acre.destroy\n\n respond_to do |format|\n format.html { redirect_to(acres_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @action_file = ActionFile.find(params[:id])\n @action_file.destroy\n\n respond_to do |format|\n format.html { redirect_to action_files_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb.destroy\n\n head :no_content\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(server_id: Integer(params[:id]))\r\n directory = Rails.root.join('app','assets','locations');\r\n\r\n path = File.join(directory, @location.image)\r\n File.delete(path)\r\n @location.destroy\r\n mv = MapsVersion.first\r\n mv.version = mv.version+1\r\n mv.save\r\n respond_to do |format|\r\n format.html { redirect_to locations_url }\r\n format.json { head :no_content }\r\n end\r\n end" ]
[ "0.7382295", "0.7382295", "0.7382295", "0.732427", "0.71312577", "0.7078632", "0.6886374", "0.6871242", "0.6871242", "0.6871242", "0.6871242", "0.6816481", "0.6816481", "0.6816481", "0.6816481", "0.6816481", "0.6812131", "0.6791939", "0.6786161", "0.6743924", "0.67189544", "0.6712612", "0.66561466", "0.6644451", "0.6640114", "0.66398424", "0.66133994", "0.6607505", "0.65992314", "0.6598179", "0.6591946", "0.6589131", "0.6578158", "0.65755", "0.6571808", "0.65686107", "0.65577507", "0.6542462", "0.6538062", "0.65348774", "0.6519948", "0.6508363", "0.6504419", "0.6501507", "0.6500519", "0.6498146", "0.6488955", "0.6480814", "0.64793056", "0.6449296", "0.6449296", "0.6444664", "0.6427467", "0.64246106", "0.64179045", "0.6413722", "0.641371", "0.6409207", "0.64082974", "0.6401802", "0.640073", "0.6397183", "0.6387095", "0.6378304", "0.6362152", "0.635901", "0.635901", "0.63458776", "0.6344693", "0.6344693", "0.6335274", "0.6334295", "0.6333599", "0.6331654", "0.63276047", "0.63249767", "0.63248694", "0.63237745", "0.63235384", "0.632298", "0.6320623", "0.63177675", "0.63157624", "0.6315615", "0.6314441", "0.6306391", "0.63014835", "0.6301075", "0.6296052", "0.62883717", "0.6283983", "0.62775564", "0.6276546", "0.62737554", "0.62720937", "0.62717235", "0.62694347", "0.62676185", "0.62626064", "0.6256344" ]
0.6651413
23
Creates `num` of each ContentBase subclass for helping with Sphinx tests
def make_content(num=nil, options=nil) num ||= 1 options ||= {} @generated_content = [] ContentBase::CONTENT_CLASSES.each do |klass| @generated_content.push FactoryGirl.create_list( klass.to_s.underscore.to_sym, num.to_i, options ) end @generated_content = @generated_content.flatten end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_type_counts\n vars = \"\"\n Repo::REPO_TYPES.each do |t|\n vars << \"@#{t}_count = #{t.camelize.constantize}.count;\"\n end\n eval(vars)\n end", "def class_count\n @_count ||= \"(#{classes.size}/#{vedeu_classes.size})\"\n end", "def auto_increment\n @@count_class_instances += 1\n end", "def count\n # implement in subclasses\n end", "def num_children\n super\n end", "def inherited(base)\n base.send :create_dynamic_classes\n super\n end", "def populate klass, n = klass::COUNT\n n.times.map {\n o = klass.new self\n yield o if block_given?\n o }\n end", "def num_types\n return @num_types unless @num_types.nil?\n @num_types = ((num_types_m1 + 1) % 65536)\n @num_types\n end", "def subclasses; end", "def subclasses; end", "def instantiate_subclasses(klass); end", "def gems_count\n Recommendable.config.ratable_classes.inject(0) do |sum, klass|\n sum + gemd_count_for(klass)\n end\n end", "def superclass_count(node)\n count = 0\n n = node\n while n = n.superclass\n count += 1\n end\n count\n end", "def disgems_count\n Recommendable.config.ratable_classes.inject(0) do |sum, klass|\n sum + disgemd_count_for(klass)\n end\n end", "def full_count\n @clazz.count\n end", "def type_count\n type_count = {}\n self.each do |go|\n if type_count[go.class].nil?\n type_count[go.class] = 1\n else\n type_count[go.class] += 1\n end\n end\n return type_count\n end", "def initialize #every time a new instance is created this number will be incremented. Instance method\n @@total_blogPosts+=1\n end", "def index_of(kind)\n case kind\n when 'static'\n inc_static\n (@static_count - 1).to_s\n when 'field'\n inc_field\n (@field_count - 1).to_s\n when 'argument'\n inc_arg\n (@arg_count - 1).to_s\n when 'var'\n inc_var\n (@var_count - 1).to_s\n end\n end", "def initialize(n)\n @name = n \n @@count += 1 # WHENEVER A NEW DOG INSTANCE IS CREATED THIS COUNTER GOES UP.\n end", "def instance_count\n repository.files(:pattern => /.rb/).map do |file|\n content = repository.read(file)\n count_calls(:def,content)\n end.sum\n end", "def class_count\n repository.files(:pattern => /.rb/).map do |file|\n content = repository.read(file)\n count_calls(:defs,content)\n end.sum\n end", "def add_new_instances(count)\n Output.new(current_instances + parent.create_instances(count), []) \n end", "def field_count\n super\n end", "def create_complete_knowledge_base(params)\n params[:entity_types] = [params[:entity_types]] unless params[:entity_types].is_a?(Array)\n\n generate_statistics_from_nif(params[:entity_types], params[:entity_count], params[:demand_reload])\n\n params[:entity_types].each { |type|\n generate_literal_statistics(type)\n }\n\n params[:entity_types].each { |type|\n generate_knowledge_base_for_entity(type, params[:identify_identical_predicates])\n }\n end", "def bases; end", "def increment_instances\n @lotus_instances ||= 0\n @lotus_instances += 1\n end", "def count\n __types__.count\n end", "def count\n [super || 1, 1].max\n end", "def factory(klass, how_many = reps)\n how_many.times.collect { klass.generate }\n end", "def generate_instances(supervisor, quantity = self.quantity)\n quantity.times.map { |i| create_instance(supervisor) }\n end", "def generate_all_classes_index(site)\n puts \"55555555555555555555555555555555555555555555555555555555\"\n allClasses = AllClassesIndex.new(site, site.source, \"/pages/classes\")\n allClasses.render(site.layouts, site.site_payload)\n allClasses.write(site.dest)\n\n site.pages << allClasses\n site.static_files << allClasses\n end", "def num_bases\n self.map { |chr,n| n }.sum\n end", "def magic_numbers(count)\nend", "def build_indices\n template_cache = RDoc::Cache.instance\n\n @info.each do |toplevel|\n @files << RDoc::Generator::File.new(template_cache, toplevel, @options,\n RDoc::Generator::FILE_DIR)\n end\n\n RDoc::TopLevel.all_classes_and_modules.each do |cls|\n build_class_list(template_cache, cls, @files[0], RDoc::Generator::CLASS_DIR)\n end\n end", "def create_counter\n i = 0\n obj = Object.new\n (class << obj; self ; end ).class_eval {\n define_method(:inc, lambda { i += 1 } )\n define_method(:dec, lambda { i -= 1 } )\n }\n obj\nend", "def type_count\n @game_objects.type_count\n end", "def initialize (num=200)\n @num = num\n end", "def create_class(domain, klass, mindevcount)\n modify_class(domain, klass, mindevcount, :create)\n end", "def classes; end", "def random_objects_with_max(max, model_type)\n number_of_objects = Random.rand(1..max)\n objects = []\n number_of_objects.times do |index|\n objects[index] = create(model_type)\n end\n objects\nend", "def _subclasses\n @_subclasses ||= []\n end", "def inherited(base)\n base.class_eval do\n @name = nil\n @unknown_inc = 0\n @fields = [ ]\n @fields_by_name = {}\n @field_components_by_name = {}\n @klass = nil\n\n record_name self.name.gsub(\"::\",\"_\") if self.name\n end\n end", "def build_actions\n base_actions.each do |action|\n action[:count].times do\n @actions << action[:klass].new\n end\n end\n end", "def count\n raise NotImplementedError\n end", "def instance_name(num=nil)\n num = next_instance_to_start if num.nil?\n sprintf '%s_%03d' % [name, num]\n end", "def default_count\n 1\n end", "def create_class(classname, superclass); end", "def subclasses\n @subclasses ||= []\n end", "def create_singletons\n count_items\n create_item_sets\n end", "def _match_class_max_Integer\n 9223372036854775807\n end", "def create_records(klass, count)\n RecordCountChangeMatcher.new.for(klass).by(count)\n end", "def subunits=(n)\n self.base_factor = 10**n\n end", "def int(max_int)\n NumGen.new max_int\n end", "def process_feature_types(n)\n feature_ids_with_object_types_added = Array.new\n delete_types = self.fields.delete('feature_types.delete')\n feature_object_types = self.feature.feature_object_types \n feature_object_types.clear if !delete_types.blank? && delete_types.downcase == 'yes'\n 0.upto(n) do |i|\n prefix = i>0 ? \"#{i}.feature_types\" : 'feature_types'\n feature_type_id = self.fields.delete(\"#{prefix}.id\")\n next if feature_type_id.blank?\n category = Category.find(feature_type_id)\n if category.nil?\n puts \"Feature type #{feature_type_id} not found.\"\n next\n end\n feature_object_type = feature_object_types.where(:category_id => category.id).first\n if feature_object_type.nil?\n feature_object_type = feature_object_types.create(:category => category, :skip_update => true)\n feature_ids_with_object_types_added << self.feature.id if !feature_ids_with_object_types_added.include? self.feature.id\n end\n if feature_object_type.nil?\n puts \"Couldn't associate feature type #{feature_type_id} to feature #{self.feature.pid}\"\n next\n end\n self.add_date(prefix, feature_object_type)\n self.add_info_source(prefix, feature_object_type)\n self.add_note(prefix, feature_object_type)\n 1.upto(8) do |j|\n field_prefix = \"#{prefix}.#{j}\"\n self.add_info_source(field_prefix, feature_object_type)\n self.add_date(field_prefix, feature_object_type)\n self.add_note(field_prefix, feature_object_type)\n end\n end\n return feature_ids_with_object_types_added\n end", "def initialize(number, options = {})\n @number = number\n @type = options[:type] || 'Unknown'\n @model = options[:model] || 'Unknown'\n @number_of_wagons = options[:number_of_wagons] || 0\n end", "def subclasses\n @subclasses ||= []\n end", "def initialize(type)\n @type = type\n @age = 0\n @@cats_count += 1 # it will plus 1 each time Cat class is initialized.\n end", "def generate_class_index(site, base, dir, path, lang)\n # puts \"666666666666666666666666666666666666666666666666 base \" + base\n # puts \"666666666666666666666666666666666666666666666666 dir \" + dir\n # puts \"666666666666666666666666666666666666666666666666 path \" + path\n cLaSs = ClassIndex.new(site, base, dir, path, lang)\n if cLaSs.data['active']\n # puts \"77777777777777777777777777777777777777777777777777777777\"\n cLaSs.render(site.layouts, site.site_payload)\n cLaSs.write(site.dest)\n\n site.pages << cLaSs\n site.static_files << cLaSs\n end\n\n end", "def initialize(number)\n \n @@all << self\n end", "def initialize\n @@counter += 1\n super(sprintf(\"_%02d\", @@counter),0)\n end", "def count_objects\n\n count = 0\n\n Find.find(@basepath) do |path|\n\n next unless File.exist? path\n next if File.stat(path).directory?\n\n count += 1 if path[-5..-1] == '.yaml'\n end\n\n count\n end", "def attr_set_integer(attr_type, number)\n #This is a stub, used for indexing\n end", "def init\n self.position = self.class.count if position.nil?\n end", "def default_childs_number\n @@default_childs_number ||= 1\n end", "def boot_classes\n classes = space.classes\n type_names.each do |name , vars|\n cl = object_with_type Parfait::Class\n cl.instance_type = @types[name]\n @types[name].object_class = cl\n @types[name].instance_methods = object_with_type Parfait::List\n cl.instance_methods = object_with_type Parfait::List\n #puts \"instance_methods is #{cl.instance_methods.class}\"\n cl.name = name\n classes[name] = cl\n end\n # superclasses other than default object\n supers = { :Object => :Kernel , :Kernel => :Value,\n :Integer => :Value , :BinaryCode => :Word }\n type_names.each do |classname , ivar|\n next if classname == :Value # has no superclass\n clazz = classes[classname]\n super_name = supers[classname] || :Object\n clazz.set_super_class_name super_name\n end\n end", "def count\n self.class.count(self)\n end", "def create_array(base_type, element_count, size = 0)\n if base_type.respond_to?(:name)\n base_type = base_type.name\n end\n return build(\"#{base_type}[#{element_count}]\", size)\n end", "def count\n defined_types.size\n end", "def count_classes\n case object.notices_count\n when 0..1 then [\"count-one\"]\n when 2..5 then [\"count-two\"]\n when 5..16 then [\"count-five\"]\n when 16..64 then [\"count-sixteen\"]\n when 64..128 then [\"count-sixty-four\"]\n else [\"count-very-many\"]\n end\n end", "def increment_use_count\n if @temporary \n @instance_count += 1\n end\n return\n end", "def _match_class_convert_Integer(value)\n value = super\n value if value <= _match_class_max_Integer\n end", "def test_type_for(org_num)\n\ttest_type = OrderType.create(title: \"Template-#{org_num}-#{rand(1000)+1}\", organization_id: org_num)\n\tcats = {1 => [1,2,3], 2 => [1,2,3], 3 => [1,2,3]}\n\tcats.each_pair do |key, values|\n\t\tcat = Category.create(name: \"Category #{org_num}-#{key}\", order_type_id: test_type.id)\n\t\tvalues.each do |t|\n\t\t\tTask.create(description: \"Task #{org_num}-#{key}-#{t}\", category_id: cat.id)\n\t\tend\n\tend\nend", "def create_classes\n bpmn_xml.class_names_with_same_bpmn_id_as_topic.each do |class_name|\n template 'bpmn_class.rb.template',\n File.join(model_path, module_name.underscore, \"#{class_name.underscore}.rb\"), class_name: class_name\n end\n end", "def generate_model(ngram_count)\n raise \"#{self.class} should be subclassed\"\n ngram_count # never called, supresses unused variable warning\n end", "def plus_one(type)\n case type\n when \"association\" then @num_associations = @num_associations + 1\n when \"builtin\" then @num_builtin = @num_builtin + 1\n when \"unknown\" then @num_unknown = @num_unknown + 1\n when \"validator\" then @num_validator = @num_validator + 1; @num_custom = @num_custom + 1\n when \"model_defined\" then @num_model_defined = @num_model_defined + 1; @num_custom = @num_custom + 1\n when \"gem\" then @num_gem = @num_gem + 1\n end\n @total_validators = @total_validators + 1 \n end", "def create_numeric(name, **options)\n register(NumericType.new_submodel(typename: name, registry: self, **options))\n end", "def initialize(base)\n @base = base\n end", "def initialize phenotype_count, orthogroup_count, storage_count\n # Make sure to provide storage_count + phenotype_count as the initial capacity, since otherwise a resize will be needed.\n super([phenotype_count, orthogroup_count], 0, capacity: storage_count+phenotype_count+1, stype: :yale, dtype: :byte)\n @skip_table = {}\n end", "def how_many(klass)\n JSON.parse(@client.raw_read(resource: klass, summary: \"count\").response[:body])[\"total\"].to_i\n end", "def inherited(base)\n subclasses << base\n super(base)\n end", "def set_beds_count\n beds_layout = layout_items.find { |item| item.number == code_for(:beds) }\n double_beds = 0\n single_beds = 0\n sofa_beds = 0\n\n meta_data['LayoutExtendedV2'].each do |entry|\n item = entry['Item']\n num = entry['NumberOfItems']\n\n case beds_layout.items[item]\n when /double/i, /2.pers/\n double_beds += num\n when /sofa/\n sofa_beds += num\n when /single/i, /1.pers/\n single_beds += num\n end\n end\n\n property.number_of_double_beds = double_beds\n property.number_of_single_beds = single_beds\n property.number_of_sofa_beds = sofa_beds\n end", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def initialize universe, fixture_class=nil\n klass, size = *case fixture_class\n when Class then [fixture_class, (NUM_CHANNELS / fixture_class.channels.size)]\n when Hash then fixture_class.to_a.flatten\n else; [nil, NUM_CHANNELS]\n end\n\n address = -1\n newborn = super(size) do\n klass.new universe, *klass.channels.map{address+=1} if klass\n end\n newborn.universe = universe\n end", "def pop_taxonomy (count, ptype = 'species')\n\n print \"Creating #{count} \"; print \"#{count > 1 ? ptype.pluralize : ptype} in \".green; print \"#{Rails.env}\".green.bold; print \" database \".green\n\n # include all of the factories in spec\n Dir['./spec/factories/*.rb'].each { |f| require f.to_s }\n\n dval = [ (count / 10), 1 ].max\n for i in 1..count\n place = make_taxon(ptype)\n if i % dval == 0\n print('.'.green)\n end\n end\n puts \" done!\".green.bold\n end", "def number_of_types\n return GameData::Type.all.size\n end", "def number_of_types\n return GameData::Type.all.size\n end", "def get_num_pages\n record_count = @model_class.count\n if record_count % @items_per_page == 0\n (record_count / @items_per_page)\n else\n (record_count / @items_per_page) + 1\n end\n end", "def test_0020_size\n @@log.debug \"test_0020_size starts\" if @@log.debug?\n assert_equal(4, @list.size)\n @list << Person.new(\"Robert\", \"NMN\", \"Zimmerman\", 5)\n assert_equal(5, @list.size)\n @@log.debug \"test_0020_size ends\" if @@log.debug?\n end", "def getCounts\n result = {}\n @classes.each do |c|\n count = 0\n ObjectSpace.each_object(c){ count += 1 }\n result[c] = count\n end\n result\n end", "def object_count\n 0\n end", "def numid; end", "def initialize()\n\t\t@@obj_count += 1\n\tend", "def base_class; end", "def test_subclass_name\n bo1 = Pt::Boundary::MyA.new(\"\\n===\\n\")\n assert_equal \"Part::Boundary::MyA\", bo1.subclass_name\n assert_equal \"Boundary::MyA\", bo1.subclass_name(index_ini: 1)\n assert_equal \"MyA\", bo1.subclass_name(index_ini: 2)\n\n ss = PlainText::Part::Section::Subsection.new [\"abc\"]\n assert_equal \"Part::Section::Subsection\", ss.subclass_name\n assert_equal \"Section::Subsection\", ss.subclass_name(index_ini: 1)\n end", "def initialize(name)\n @@count += 1\n @name = name #このクラス内であれば使用できる\n end", "def initialize(hostname, params={})\n if hostname.include?(\".\")\n @hostname = hostname\n else\n @hostname = hostname + \".tumblr.com\"\n end\n @num = params[:num] || 20\n @num = 50 if @num > 50\n @type = params[:type]\n @total = request(:start => 0, :num => 0).posts.total\n end", "def number_of(type)\n game_entities.select{|entity| entity.class == type }.size\n end", "def classes\n @class_ids.collect { |idx| BClass.store[idx] }\n end", "def records_count\n @klass.all.size\n end" ]
[ "0.6032869", "0.59820944", "0.5652937", "0.5564144", "0.54795355", "0.5430587", "0.541258", "0.5403861", "0.5333603", "0.5333603", "0.53129375", "0.5307838", "0.52916", "0.52844983", "0.5279191", "0.52667797", "0.5260656", "0.5229471", "0.5216411", "0.51934385", "0.5188417", "0.51733035", "0.51531935", "0.51062167", "0.5104773", "0.51007456", "0.50934315", "0.50904316", "0.5089408", "0.5088489", "0.5060413", "0.50464636", "0.50355244", "0.50160193", "0.50125176", "0.5003282", "0.49879473", "0.49755216", "0.49599442", "0.49527612", "0.49489817", "0.4938735", "0.49247646", "0.49241894", "0.49164864", "0.49113116", "0.4909044", "0.49055156", "0.48892832", "0.48891878", "0.4888949", "0.4884235", "0.48812804", "0.487568", "0.48747504", "0.486591", "0.48652905", "0.48650694", "0.48605922", "0.485616", "0.48484388", "0.4843376", "0.48417738", "0.48400572", "0.48364657", "0.48358148", "0.48342076", "0.48315656", "0.4818103", "0.48125893", "0.47995412", "0.47930047", "0.47918546", "0.47799852", "0.47741", "0.4773035", "0.47554764", "0.47506708", "0.47504133", "0.47485152", "0.47468197", "0.47465682", "0.47465682", "0.47435617", "0.47425082", "0.47383472", "0.47383472", "0.47364622", "0.4734935", "0.47260937", "0.47208345", "0.47183546", "0.47118708", "0.47114632", "0.47093654", "0.47091693", "0.46921948", "0.4690361", "0.46902817", "0.4689811" ]
0.63118696
0
Sometimes the index takes too long, but we want to actually test the sphinx results. This method will help for slower computers, for example, that take longer to run the index. Usage: ts_retry(2) do
def ts_retry(attempts=1, &block) attempt = 0 begin yield block rescue RSpec::Expectations::ExpectationNotMetError => e attempt += 1 if attempt > attempts raise e else sleep 0.5 retry end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retry_query\n Rails.logger.info('Retrying EDS Search')\n @attempts += 1\n search(@query[:term], @query[:profile], @query[:facets],\n @query[:page], @query[:per_page])\n end", "def reset_index\n ElasticMapper.index_name = \"elastic_mapper_tests\"\n index = ElasticMapper.index\n server = ElasticMapper.server\n\n index.delete rescue nil # ignore exceptions.\n\n server.refresh\n\n index.create({\n :settings => {\n :number_of_shards => 1,\n :number_of_replicas => 0\n }\n })\n\n # Why do both? Doesn't hurt, and it fixes some races\n server.refresh\n index.refresh\n \n # Sometimes the index isn't instantly available\n (0..40).each do\n idx_metadata = server.cluster.request(:get, :state)[:metadata][:indices][index.name]\n i_state = idx_metadata[:state]\n \n break if i_state == 'open'\n \n if attempts_left < 1\n raise \"Bad index state! #{i_state}. Metadata: #{idx_metadata}\" \n end\n\n sleep 0.1\n end\n\nend", "def reindex!\n indexed if generate_solr_index\n end", "def reindex_later(**args)\n Spotlight::ReindexJob.perform_later(self, **args)\n end", "def perform\n ThinkingSphinx::Connection.take do |client|\n indices.each do |index|\n client.update index, ['sphinx_deleted'], {@document_id => [1]}\n end\n end\n rescue Riddle::ConnectionError\n # If it fails here, so be it.\n ensure\n true\n end", "def test_search_with_many_results\n internal = @service.indexes.fetch(\"_internal\")\n internal.refresh()\n if internal.fetch(\"totalEventCount\").to_i < 150\n fail(\"Need at 150 events in index _internal for this test.\")\n end\n\n job = @service.jobs.create(\"search index=_internal | head 150\")\n while !job.is_done?()\n sleep(0.1)\n end\n\n stream = job.results(:count => 0)\n results = Splunk::ResultsReader.new(stream)\n count = 0\n results.each do |event|\n count += 1\n end\n assert_equal(150, count)\n\n stream = job.preview(:count => 0)\n results = Splunk::ResultsReader.new(stream)\n count = 0\n results.each do |event|\n count += 1\n end\n assert_equal(150, count)\n end", "def index_corruption?; end", "def trigger_reindexing\n # Read baseline reindexing status — very first reindexing is a no-op in the reindexer controller\n response = http_request(URI(application_url + \"reindexing\"), {})\n assert(response.code.to_i == 200, \"Request should be successful\")\n previous_reindexing_timestamp = get_json(response)[\"clusters\"][\"search\"][\"ready\"][\"test\"][\"readyMillis\"]\n\n # Trigger reindexing through reindexing API in /application/v2, and verify it was triggered\n response = http_request_post(URI(application_url + \"reindex\"), {})\n assert(response.code.to_i == 200, \"Request should be successful\")\n\n response = http_request(URI(application_url + \"reindexing\"), {})\n assert(response.code.to_i == 200, \"Request should be successful\")\n current_reindexing_timestamp = get_json(response)[\"clusters\"][\"search\"][\"ready\"][\"test\"][\"readyMillis\"]\n assert(previous_reindexing_timestamp.nil? || previous_reindexing_timestamp < current_reindexing_timestamp,\n \"Previous reindexing timestamp (#{previous_reindexing_timestamp}) should be after current (#{current_reindexing_timestamp})\")\n end", "def delayed_index(model)\n config = ThinkingSphinx::Configuration.instance\n rotate = ThinkingSphinx.sphinx_running? ? \" --rotate\" : \"\"\n\n output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file}#{rotate} #{model.delta_index_names.join(' ')}`\n\n\n model.sphinx_indexes.select(&:delta?).each do |index|\n output += `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file}#{rotate} --merge #{index.core_name} #{index.delta_name} --merge-dst-range sphinx_deleted 0 0`\n end unless ENV['DISABLE_MERGE'] == 'true'\n\n puts output unless ThinkingSphinx.suppress_delta_output?\n\n true\n end", "def reindex\n Sunspot.index!\n # puts 'reindexed'\n end", "def retry!\n raise 'Not implemented!'\n end", "def index_search\n return\n #Search for data if search comes in\n if params[:search] != nil\n #Delete any temp search docs so we don't search them too \n Document.destroy_all(:name => ENV['temp_search_doc'])\n \n #start recording run time\n data_stime = Time.now() #start time\n \n d = document_search_data_couch(params[:search], params.has_key?(\"lucky_search\"))\n data_etime = Time.now() #end time\n data_ttime = data_etime - data_stime #total time\n \n #start recording run time\n doc_stime = Time.now() #start time\n \n c=Collection.find_or_create_by_name(\"Recent Searches\")\n c.save\n \n @temp_search_document = Document.new\n @temp_search_document.name = ENV['temp_search_doc']\n @temp_search_document.collection = c\n @temp_search_document.stuffing_data = d\n @temp_search_document.stuffing_is_search_doc = TRUE\n @temp_search_document.save\n \n#TODO: taking out document searching for now, because it is so slow! \n=begin \n doc_etime = Time.now() #end time\n doc_ttime = doc_etime - doc_stime #total time\n \n @documents = Document.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 5, :page => params[:page])\n\n flash[:notice]=\"Searched data in #{data_ttime} seconds, searched document names in #{doc_ttime}.\"\n=end\n @documents = []\n flash[:notice]=\"Searched data in #{data_ttime} seconds.\"\n else\n @documents = Document.all.paginate(:per_page => 5, :page => params[:page])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def reindex\n custom_breadcrumbs_for(admin: true,\n leaf: 'Start search index refresh')\n\n render :reindex, layout: 'admin/application', locals: { success: nil, errors: [] }\n end", "def restart\n running_nodes = get_running_nodes()\n\n puts \"Running nodes: #{running_nodes}\"\n\n if running_nodes.empty?\n start_node 1\n exit\n end\n\n if running_nodes.count > 1\n abort \"still restarting. try again after some minutes\"\n end\n\n running_node = running_nodes.first.to_i\n\n running_nodes[1..-1].each do |i|\n stop_node i\n end\n\n new_node = running_node == 1 ? 2 : 1\n start_node new_node\n\n puts \"Wait some seconds for starting new node\"\n sleep 10\n\n abort('cluster health is not green') unless wait_cluster_health_green()\n\n stop_node running_node\n\n puts \"Elasticsearch restarted successfully.\"\nend", "def retry\n self.solved(:retry)\n end", "def incompatible_indexing_directive\n if $client.version_support.es_version_2_x?\n {_wait_for_active_shards: 10}\n else\n {_consistency: \"all\"}\n end\nend", "def retry\n super\n end", "def add_to_index?(url)\n print &quot;\\n- indexing #{url}&quot;\n t0 = Time.now\n page = Page.find(scrub(url))\n \n # if the page is not in the index, then index it\n if page.new_record? then\n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts &quot; [new] - (#{dsize.to_i} words)&quot;\n doc_words.each_with_index { |w, l|\n printf(&quot;\\r\\e - %6.2f%&quot;,(l*100/dsize))\n loc = Location.new(:position =&gt; l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n }\n }\n \n # if it is but it is not fresh, then update it\n elsif not page.fresh? then\n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts &quot; [refreshed] - (#{dsize.to_i} words)&quot;\n page.locations.destroy!\n doc_words.each_with_index { |w, l|\n printf(&quot;\\r\\e - %6.2f%&quot;,(l*100/dsize))\n loc = Location.new(:position =&gt; l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n }\n }\n page.refresh\n \n #otherwise just ignore it\n else\n puts &quot; - (x) already indexed&quot;\n return false\n end\n t1 = Time.now\n puts &quot; [%6.2f sec]&quot; % (t1 - t0)\n return true\n end\n \n # scrub the given link\n def scrub(link, host=nil)\n unless link.nil? then\n return nil if DO_NOT_CRAWL_TYPES.include? link[(link.size-4)..link.size] or link.include? '?' or link.include? '/cgi-bin/' or link.include? '&amp;' or link[0..8] == 'javascript' or link[0..5] == 'mailto'\n link = link.index('#') == 0 ? '' : link[0..link.index('#')-1] if link.include? '#'\n if link[0..3] == 'http'\n url = URI.join(URI.escape(link))\n else\n url = URI.join(host, URI.escape(link))\n end\n return url.normalize.to_s\n end\n end\n \n # do the common indexing work\n def index(url)\n open(url, &quot;User-Agent&quot; =&gt; USER_AGENT){ |doc|\n h = Hpricot(doc)\n title, body = h.search('title').text.strip, h.search('body')\n %w(style noscript script form img).each { |tag| body.search(tag).remove}\n array = []\n body.first.traverse_element {|element| array &lt;&lt; element.to_s.strip.gsub(/[^a-zA-Z ]/, '') if element.text? }\n array.delete(&quot;&quot;)\n yield(array.join(&quot; &quot;).words, title)\n }\n end\nend\n \n$stdout.sync = true\nspider = Spider.new\nspider.start\n", "def work()\n # FIXME : .rel[...].get doesn't update $client.rate_limit...\n\n rate_limit = $client.rate_limit\n dbgp \"#{rate_limit.remaining} API calls left.\"\n\n # A little buffer in case we use a feature from octokit\n # which doesn't update rate_limit on `$client`.\n if rate_limit.remaining < 5 then\n reset = rate_limit.resets_in + 10\n puts \"💤 zleepy timez (back in #{reset} seconds)\"\n sleep(reset)\n end\n\n begin\n yield\n rescue Octokit::BadGateway, Octokit::InternalServerError => e\n puts \"Uuuh... github is having a bad time :( #{e.response_status}\"\n pp \"=====\"\n pp \"=====\"\n pp e.response_body\n pp \"=====\"\n pp e.response_headers\n pp \"=====\"\n pp \"=====\"\n sleep 10\n retry\n end\nend", "def reindex\n # We would need to set this explicitly to re-index\n if BoolENV[\"REINDEX_SOLR\"]\n Sunspot.session = Sunspot::SessionProxy::Retry5xxSessionProxy.new(Sunspot.session)\n reindex_options = { :batch_commit => false }\n Dir.glob(Rails.root.join('app/models/**/*.rb')).each { |path| require path }\n sunspot_models = Sunspot.searchable\n sunspot_models.each do |model|\n model.solr_reindex(reindex_options)\n end\n end\n end", "def retry_options\n {tries: 15, sleep: 1}\n end", "def fail_fast\n @fail_fast\n end", "def verbose_on_error(index)\n be_verbose(index) if not @succeeded\n end", "def retry_method(retry_time=1.minute)\n log(:info, \"Retrying in #{retry_time} seconds\")\n $evm.root['ae_result'] = 'retry'\n $evm.root['ae_retry_interval'] = retry_time\n exit MIQ_OK\n end", "def update_works_index_timestamp!\n t = Time.now.to_i.to_s\n REDIS_GENERAL.set(redis_works_index_key, t)\n return t\n end", "def reindex!\n self.__elasticsearch__.update_document if self.published?\n end", "def reindex!\n logger.debug \"Updating #{self.name} (#{self.id}) to Solr directly...\"\n indexed if generate_solr_index\n end", "def perform_indexes(first_modified)\n client = PurlFetcher::Client::Reader.new('', 'purl_fetcher.first_modified' => first_modified)\n client.each_slice(1000) do |batch|\n batch.each do |record, _change|\n IndexFullTextContentJob.perform_later(record.druid)\n end\n\n ts = batch.map { |_, change| Time.zone.parse(change['updated_at']) if change['updated_at'] }.max\n yield ts if ts\n end\n\n yield client.range['last_modified']\n end", "def retry\n raise \"#{@error_msg_prefix} must be passed a block\" unless block_given?\n\n attempts = 0\n start_time = Time.now\n begin\n attempts += 1\n yield attempts\n rescue InfluxError => e\n if attempts > @max_retries\n @api_client.log(:error, 'Maximum retry attempts reached.')\n raise e\n end\n\n if (Time.now - start_time) * 1000 > @max_retry_time\n @api_client.log(:error, \"Maximum retry time #{@max_retry_time} ms exceeded\")\n raise e\n end\n\n raise e if (e.code.nil? || e.code.to_i < 429) && !_connection_error(e.original)\n\n timeout = if e.retry_after.nil? || e.retry_after.empty?\n get_backoff_time(attempts)\n else\n (e.retry_after.to_f * 1000) + @jitter_interval * rand\n end\n\n message = 'The retriable error occurred during writing of data. '\\\n \"Reason: '#{e.message}'. Retry in: #{timeout.to_f / 1000}s.\"\n\n @api_client.log(:warn, message)\n sleep timeout / 1000\n retry\n end\n end", "def timeout_safe # :block\n error_n = 0\n begin\n $stderr.puts(\" try get same page again...\") if error_n > 0\n yield\n rescue Errno::EBADF, Timeout::Error\n error_n += 1\n error_name = $!.class.to_s\n if error_n >= 3\n $stderr.puts \"#{error_name} ERROR #3\"\n raise $!\n end\n sleep_for = error_n * 5\n $stderr.puts \"#{error_name} ERROR ##{error_n}, sleep #{sleep_for} seconds before next attempt\"\n sleep sleep_for\n retry\n end\nend", "def search_from_fresh_index( query, page )\n begin\n @search_data = @index.search( query, page )\n return true\n rescue IndexSearchError => error\n @errors.push({\n :highlight => \"The search term you used has caused an error on the search engine, please try another search term without any special characters in it.\",\n :full_text => error\n })\n return false\n end\n end", "def test_retries_failed_temporary\n service_def = { \"DummyService\" => \n { \"type\" => \"DummyService\",\n \"priority\" => 3, \n \"responses\" => [\n { \"service_type_value\" => \"fulltext\",\n \"display_text\" => \"created\"\n }\n ]\n }\n }\n config = {\"default\" => {\"services\" => service_def}}\n\n\n with_service_config(config) do \n retry_after = 10\n original_updated_at = Time.now - retry_after - 1\n\n request = fake_umlaut_request(\"/?foo=bar\")\n request.dispatched_services.create(\n :status => DispatchedService::FailedTemporary,\n :service_id => \"DummyService\",\n :updated_at => original_updated_at\n )\n\n collection = Collection.new(request, \n ServiceStore.global_service_store.determine_services,\n Confstruct::Configuration.new(:requeue_failedtemporary_services_in => retry_after))\n collection.dispatch_services!.join\n\n ds = request.dispatched_services(true).find {|ds| ds.service_id == \"DummyService\"}\n\n assert ds, \"DispatchedService does not exist for DummyService\"\n assert ds.status == DispatchedService::Successful, \"DispatchedService not marked successful\"\n assert ds.updated_at > original_updated_at, \"DispatchedService updated_at not updated\"\n\n assert request.service_responses.to_a.find {|sr| sr.service_id == \"DummyService\" }, \"ServiceResponse not created\"\n end\n end", "def retry_block_until_true\n (0..RETRY_COUNT).each do\n return if yield\n sleep RETRY_STEP\n end\n Puppet.debug get_cluster_debug_report if is_online?\n fail \"Execution timeout after #{RETRY_COUNT * RETRY_STEP} seconds!\"\n end", "def recreate!\n client = EsClient.new(@url, @index_name)\n client.create_index(@index)\n client.bulk_index(@data)\n end", "def expire_index!\n raise NotImplementedError\n end", "def retry!\n raise RetryMessage\n end", "def check_index_walk\n if first['index_walk']\n @cost = limit\n add_message(\"index_walk\")\n end\n end", "def retry_before_failing\n sleeping(NODE_QUERY_WAIT_TIME).seconds.between_tries.failing_after(MAX_NODE_QUERY_RETRIES).tries do\n yield\n end\n yield\n end", "def refresh_index\n Elastic::Rebound.client.refresh({:index => @index_name})\n end", "def optimize_start_get_answerers *args\n sleep(5)\n \n # A solution for when nelder mead reaches a negative number\n args.each do |a|\n if a < 0\n return 999999999999\n end\n end\n \n mlt_parsed_partial_config = {\n 'mlt.mindf' => args[0].to_i,\n 'mlt.minwl' => args[1].to_i,\n 'mlt.maxqt' => args[2].to_i,\n 'titleBoost' => args[3],\n 'tagsBoost' => args[4]\n }\n \n # Use this to optimize get questions\n body_query_answerer_parsed_partial_config = {\n #'mindf' => args[5].to_i,\n #'bodyboost' => args[6]\n }\n \n # Use this to optimize get answerers\n body_query_question_parsed_partial_config = {\n 'mindf' => args[5].to_i,\n 'bodyboost' => args[6]\n }\n \n update_engine_config mlt_parsed_partial_config, body_query_answerer_parsed_partial_config, body_query_question_parsed_partial_config\n (number_of_good_questions, number_of_bad_questions) = start_get_answerers(@questions)\n number_of_questions = number_of_good_questions + number_of_bad_questions\n puts\n puts \"##############################################\"\n puts\n puts \"#{Time.now} Result for config #{mlt_parsed_partial_config} AND #{body_query_answerer_parsed_partial_config} AND #{body_query_question_parsed_partial_config} is: #{number_of_bad_questions} / #{number_of_questions}\"\n puts\n puts \"##############################################\"\n puts\n \n open('results.txt', 'a') { |f|\n f << \"#{Time.now} Result for config #{mlt_parsed_partial_config} AND #{body_query_answerer_parsed_partial_config} AND #{body_query_question_parsed_partial_config} is: #{number_of_bad_questions} / #{number_of_questions} \\n\"\n }\n \n return number_of_bad_questions\n end", "def reindex!\n find(:all).each { |r| r.update_index(true) }\n end", "def perform\n config = ThinkingSphinx::Configuration.instance\n \n output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} --rotate #{index}`\n puts output unless ThinkingSphinx.suppress_delta_output?\n \n true\n end", "def make_title_searchable\n address = create_title_addressbase_data(@title)\n create_elasticsearch_addressbase_data(address)\n sleep($ELASTICSEARCH_SLEEP.to_f) # elasticsearch changes take a moment\n create_lr_urpn_mapping_data(@title[:lr_uprns])\nend", "def populate_background_index!(name)\n # make an index with a new client (in this thread, to avoid query check race after)\n name.freeze\n index = $client.dup.index(name)\n docs = index.docs(\"widget\")\n\n # do some busy work in background thread to generate bulk-indexing tasks we\n # can query at the caller. return the thread ref so caller can join on it\n Thread.new do\n 100.times.each do |i|\n docs.bulk do |d|\n (1..500).each do |j|\n d.index \\\n :foo => \"foo_#{i}_#{j}\",\n :bar => \"bar_#{i}_#{j}\",\n :baz => \"baz_#{i}_#{j}\"\n end\n end\n index.refresh\n end\n end\nend", "def retry_function; FlowConstants.exponential_retry_function; end", "def refresh_index index\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_refresh\")\n req = Net::HTTP::Post.new(uri)\n run(uri, req)\n end", "def create_elasticsearch_index\n unless index.exists?\n if index_name[/(.*)_alias$/]\n name_prefix = $1\n found_untimestamped_index = false\n timestamped_index_name = nil\n timestamp = nil\n Tire::Index.all.each do |index_name|\n if index_name[Regexp.new(\"^#{name_prefix}$\")]\n # ^^ look for an index without the _alias prefix in its name\n found_untimestamped_index = true\n elsif index_name[Regexp.new(\"^#{name_prefix}_(\\\\d{14})$\")] && (timestamp.blank? || $1.to_i > timestamp.to_i)\n # ^^ look for an index with a timestamp in its name, and store the newest one (timestamp)\n timestamp = $1\n timestamped_index_name = index_name\n end\n end\n if timestamp.present?\n response = Tire::Alias.create({name: index_name, indices: [timestamped_index_name]})\n log_alias_create(index_name, timestamped_index_name, response)\n elsif found_untimestamped_index\n response = Tire::Alias.create({name: index_name, indices: [name_prefix]})\n log_alias_create(index_name, name_prefix, response)\n else\n new_index = Tire.index(\"#{index_name.sub(/_alias$/, Time.now.strftime(\"_%Y%m%d%H%M%S\"))}\")\n response = new_index.create(:mappings => mapping_to_hash, :settings => settings)\n if log_index_create(response)\n response = Tire::Alias.create({name: index_name, indices: [new_index.name]})\n log_alias_create(index_name, new_index.name, response)\n end\n end\n else\n new_index = index\n response = new_index.create(:mappings => mapping_to_hash, :settings => settings)\n log_index_create(response)\n end\n end\n\n rescue *Tire::Configuration.client.__host_unreachable_exceptions => e\n STDERR.puts \"Skipping index creation, cannot connect to Elasticsearch\",\n \"(The original exception was: #{e.inspect})\"\n false\n end", "def touch_index_timestamp\n self.index_timestamp = Time.now\n end", "def restart( timeout = 5 )\n stop( timeout )\n start\n end", "def works_index_timestamp\n REDIS_GENERAL.get(redis_works_index_key) || update_works_index_timestamp!\n end", "def lock_timeout_retries; end", "def scroll\n\n # Execute the query on the '@index/@type' data\n # - search_type: 'scan' => do not compute ES score; do not sort documents\n # - scroll: '1m' => how long to keep the search context alive (1 minute)\n # - size: 1000 => how many documents each scroll request returns (per shard)\n # - filter on: 'lang' == <lang>, array 'site' includes {...} (@query)\n # - _source: [ ... ], => recover only requested fields (not entire entry)\n\n begin\n res = @client.search(\n index: \"#{@index}\",\n type: \"#{@type}\",\n scroll: '5m',\n search_type: 'scan',\n size: 1000,\n body: \"#{@query}\",\n _source: @source,\n )\n rescue => e\n raise Xi::ML::Error::CaughtException, \\\n \"Exception encountered when executing query: #{e.message}\"\n end\n\n # scroll the ES results\n @logger.info('Scroll the results ...')\n begin\n while (res = @client.scroll(scroll: '5m', scroll_id: res['_scroll_id']))\\\n && !res['hits']['hits'].empty?\n\n res['hits']['hits'].each do |doc|\n yield doc\n end\n end\n rescue => e\n raise Xi::ML::Error::CaughtException, \\\n \"Exception encountered when scrolling results #{e.message}\"\n end\n end", "def calculate_retry_after(env); end", "def restart\n if @time < @next_restart\n log.info \"synapse: at time #{@time} waiting until #{@next_restart} to restart\"\n return\n end\n\n @next_restart = @time + @restart_interval\n @next_restart += rand(@restart_jitter * @restart_interval + 1)\n\n # do the actual restart\n res = `#{opts['reload_command']}`.chomp\n unless $?.success?\n log.error \"failed to reload haproxy via #{opts['reload_command']}: #{res}\"\n return\n end\n log.info \"synapse: restarted nginx\"\n\n @restart_required = false\n end", "def assure_existing_couch_index\n if (doc = database.get(\"_design/CouchSphinxIndex\") rescue nil)\n return if (ver = doc['version']) and ver == CouchSphinx::VERSION\n\n database.delete_doc(doc)\n end\n\n all_couchrests = {\n :map => 'function(doc) {\n if(doc[\"couchrest-type\"] && (doc[\"created_at\"] || doc[\"updated_at\"])) {\n var date = doc[\"updated_at\"];\n \n if(date == null)\n date = doc[\"created_at\"];\n\n emit(doc._id, doc);\n }\n }'\n }\n\n couchrests_by_timestamp = {\n :map => 'function(doc) {\n if(doc[\"couchrest-type\"] && (doc[\"created_at\"] || doc[\"updated_at\"])) {\n var date = doc[\"updated_at\"];\n \n if(date == null)\n date = doc[\"created_at\"];\n\n emit(Date.parse(date), doc);\n }\n }'\n }\n\n database.save_doc({\n \"_id\" => \"_design/CouchSphinxIndex\",\n :lib_version => CouchSphinx::VERSION,\n :views => {\n :all_couchrests => all_couchrests,\n :couchrests_by_timestamp => couchrests_by_timestamp\n }\n })\n end", "def suppress_reindex\n self.suppress_reindex_trigger = true\n end", "def suppress_reindex\n self.suppress_reindex_trigger = true\n end", "def suppress_reindex\n self.suppress_reindex_trigger = true\n end", "def retry_on_transient_error\n (options.retry_count.to_i + 1).times do |n|\n logger.debug \"Attempt ##{n}\"\n begin\n result = yield\n rescue Fog::Compute::AWS::Error => e\n sleep_seconds = options.retry_interval * (n+1)\n logger.warn \"Received AWS error: #{e}\"\n logger.warn \"Sleeping #{sleep_seconds} seconds before retrying\"\n sleep sleep_seconds\n else\n return result\n end\n end\n nil\n end", "def retry_post(*args)\n delay = 1\n\n begin\n post(*args)\n rescue TooFastError => error\n sleep delay\n delay *= 2\n retry\n end\n end", "def querytest_failing_common\n wait_for_hitcount(\"query=test&streaming.selection=true\", 28, 10)\n end", "def retry_execution(retry_message, times = AgentConfig.max_packages_install_retries)\n count = 0\n success = false\n begin\n count += 1\n success = yield\n @audit.append_info(\"\\n#{retry_message}\\n\") unless success || count > times\n end while !success && count <= times\n success\n end", "def solr_reindex options = {}\n SolrPowered.with_timeout(1800) {\n\n if options[:delete_first] != false\n # remove ALL of this class' records from the solr index\n SolrPowered.client.delete_all(\"solr_type:#{solr_type}\")\n end\n\n # ActiveRecord handles STI find in a very odd way. Given the following\n # STI setup:\n #\n # Staff < Member < Person < ActiveRecord::Base\n #\n # If you perform a find on Member or Staff the find will be scoped with\n # the type column being the class name which is being searched. However,\n # if you perform the same find on Person, instead of scoping where type\n # would = 'Person', it leaves the type column out, returning all objects\n # \n # This is not desireable as we have different associations, different\n # solr_attrs, solr_methods and solr_assocs in each of the inherited \n # classes, we need to eager load different columns, create different\n # documents, etc.\n # \n # Therefor we ALWAYS add the class name (when type is present) to the\n # find. This does result in a douple tpye condition in some STI\n # queries, but that is preferable to the alternative of not scoping.\n if self.column_names.include?('type')\n cond = [\"#{self.table_name}.type = ?\", self.to_s]\n end\n\n # re-index the records, one large chunk at a time\n find_in_batches(\n :conditions => cond,\n :include => self.solr_eager_loaded_associations\n ) do |objects|\n documents = objects.select(&:solr_saveable?).collect(&:solr_document)\n SolrPowered.client.add(*documents) unless documents.empty?\n end\n\n# page = 0\n# batch_size = options[:batch_size] || 1000\n# begin\n# objects = find(:all,\n# :conditions => cond,\n# :include => self.solr_eager_loaded_associations,\n# :limit => batch_size, \n# :offset => page * batch_size\n# )\n# documents = objects.select(&:solr_saveable?).collect(&:solr_document)\n# SolrPowered.client.add(*documents) unless documents.empty?\n# page += 1\n# end until objects.length != batch_size\n }\n\n end", "def add_to_index?(url)\n print \"\\n- indexing #{url}\" \n t0 = Time.now\n page = Page.find(scrub(url))\n \n # if the page is not in the index, then index it\n if page.new_record? then \n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts \" [new] - (#{dsize.to_i} words)\"\n doc_words.each_with_index { |w, l| \n printf(\"\\r\\e - %6.2f%\",(l*100/dsize))\n loc = Location.new(:position => l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n }\n }\n \n # if it is but it is not fresh, then update it\n elsif not page.fresh? then\n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts \" [refreshed] - (#{dsize.to_i} words)\"\n page.locations.destroy!\n doc_words.each_with_index { |w, l| \n printf(\"\\r\\e - %6.2f%\",(l*100/dsize))\n loc = Location.new(:position => l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n } \n }\n page.refresh\n \n #otherwise just ignore it\n else\n puts \" - (x) already indexed\"\n return false\n end\n t1 = Time.now\n puts \" [%6.2f sec]\" % (t1 - t0)\n return true \n end", "def test_no_request_retry_when_timeout_between_varnish_and_nginx_timeout\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-between-varnish-timeout\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/between-varnish-timeout\", http_options)\n assert_response_code(504, response)\n\n # Ensure that the backend has only been called once.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-between-varnish-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-between-varnish-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n end", "def redd_try(tries = 0)\n tries += 1\n yield\n rescue ::Redd::Error::InvalidOAuth2Credentials\n puts $ERROR_INFO.inspect, $ERROR_POSITION\n raise if tries > TRY_LIMIT\n reconnect\n sleep(30 * (tries**2))\n retry\n rescue ::Redd::Error::RateLimited => error\n puts \"Rate Limited by Reddit #{error.time}\"\n sleep(error.time)\n retry\n rescue ::Redd::Error => error\n # 5-something errors are usually errors on reddit's end.\n puts $ERROR_INFO.inspect\n raise error unless (500...600).cover?(error.code)\n retry\n rescue ::Faraday::SSLError\n puts $ERROR_INFO.inspect\n retry\n rescue ::Faraday::ConnectionFailed\n puts $ERROR_INFO.inspect, $ERROR_POSITION\n retry\n end", "def index_new\n raise InvalidDbError if @stale\n super\n end", "def refresh_indices\n response = client.admin.indices.prepare_refresh([@index].to_java(:string)).execute.action_get\n end", "def with_limited_retry(opts)\n tries = opts.fetch :tries\n exceptions = Array(opts.fetch(:exceptions))\n\n return if tries == 0\n\n begin\n yield\n rescue *exceptions\n Chef::Log.warn('Bad response, try again...')\n if (tries -= 1) > 0\n sleep 1\n retry\n end\n end\n end", "def reindex_places\n return true if skip_indexing\n places.each_with_index do |p,i|\n # Queue jobs with a little offset we don't end up running intense API\n # calls at the same time\n p.delay(\n run_at: ( 1.day + i.minutes ).from_now,\n priority: INTEGRITY_PRIORITY,\n queue: \"slow\",\n unique_hash: { \"Place::elastic_index\": p.id }\n ).elastic_index!\n end\n true\n end", "def refresh\n super do |modified|\n return unless modified\n @indexer.generate_index #TODO: update_index?\n end\n end", "def bulk_index_returns_create_for_new_documents?\n $client.version_support.es_version_2_x?\nend", "def retry_delay\n 30\n end", "def retry_later\n @meta[Cworked_at] = nil\n @meta[Crt_count] += 1\n @meta[Crt_at] = Time.now.utc + (queue.rt_at_interval * @meta[Crt_count])\n put_meta\n\n rcache.lpush(queue.retries_cache_key, trx_id)\n rcache.lrem(queue.working_cache_key, 0, trx_id)\n end", "def retry_service(e) # e == rescued error\n\t\t\tif self.tries <= 10\n\t\t\t\tself.tries += 1\n\t\t\t\t# puts \"Connection issues... retrying in 3 seconds\"\n\t\t\t\tsleep(3)\n\t\t\t\tself.call_service\n\t\t\telse\n\t\t\t\tputs \"Backtrace: #{e.backtrace}\"\n\t\t\t\tputs \"BIG TIME ERROR getting: #{self.url}\"\n\t\t\tend\n\t\tend", "def index\n @slow_things = SlowThing.all\n respond_with @slow_things if stale? @slow_things, public: true\n end", "def retry_job\n # get items\n query = AnalysisJobsItem.failed_for_analysis_job(id)\n\n # batch update\n query.find_in_batches(batch_size: AnalysisJob.batch_size) do |items|\n items.each(&:retry!)\n end\n end", "def test_failing_job_with_retry()\n # FIXME: check that the job has been effectively tried twice\n # FIXME: test a job working the second time\n assert_nothing_thrown() do\n s = generate_spawner(1, false, 1, @jobs_log_file, @spawner_log_file)\n generate_tasks_addition(s, 1, true, 2) {plop}\n end\n end", "def index_delta\n if ThinkingSphinx::Configuration.environment == \"test\" ||\n !ThinkingSphinx.deltas_enabled?\n return true\n end\n \n configuration = ThinkingSphinx::Configuration.new\n system \"indexer --config #{configuration.config_file} --rotate #{self.class.name.downcase}_delta\"\n \n true\n end", "def expire_index!\n raise TypeError, \"can't modify immutable index\"\n end", "def verbose_on_success(index)\n be_verbose(index)\n end", "def reindex!\n Student.update_recent_student_assessments!\n end", "def raise_index!\n @index += 1\n end", "def perform\n index\n true\n end", "def do_local_indexing(solr_doc); end", "def retry_change_requests; end", "def retry_change_requests; end", "def sleep_before_retry_on_limit_error\n sleep 15\n end", "def rebuild_index\n aaf_index.rebuild_index\n end", "def keep_trying_to(title)\n begin\n yield\n rescue Exception => e\n log \"failed to #{title} -- retry in #{RETRY_WAIT} seconds\"\n log e.message\n log e.backtrace\n sleep RETRY_WAIT\n retry\n end\n end", "def lazy_search_twitter()\n @refresh_url = \"#{@api_endpoint_twitter}#{@response['refresh_url']}\" unless (@response.nil? || @response['refresh_url'].nil? || @response['refresh_url'].empty?)\n if @refresh_url\n #FIXME persist the refresh url - server restart would be a pain elsewise\n search_url = \"#{@refresh_url}&result_type=#{@result_type}&rpp=#{@results_per_page}\"\n @log.info \"lazy search using '#{search_url}'\" #workaround to get refresh url logged w/ the Daemons gem\n @response = http_get search_url\n else\n @log.debug \"regular search using '#{@search_term}'\"\n @response = search_twitter()\n end\n end", "def restart_failed_jobs\n res = Messaging::JobReview.restart_failed_jobs!\n\n flash.now[:notice] = \"Restarted #{res} #{'job'.pluralize(res)}\"\n index\n end", "def run_failed; end", "def test_generate_succeeds\n Index.generate(TEST_FILE, index_filename)\n end", "def trythreetimes\n tries = 0\n begin\n yield\n rescue Exception => e \n tries += 1\n logger \"Error: #{e.message}\"\n if tries < 3\n logger \"Waiting 5 seconds and trying again...\"\n sleep(5)\n retry\n end\n logger \"Giving up and ending program!\"\n abort\n end\nend", "def verify_index\n setup_index\n raise Exceptions::ElasticsearchError('Index not found') unless index_exists?\n end", "def run_all_indexers\n run_all_indexers_orig\n $pui.run_index_round\n end", "def reindex_everything(repo, query = '')\n i = 0\n repo.search(query) do |object|\n next if object.pid.start_with?('fedora-system:')\n i += 1\n next if i < start_at\n puts \"I: #{i}\"\n begin\n @solr_conn.add index_digital_object(object)\n rescue Rubydora::FedoraInvalidRequest => e\n puts \"ERROR #{e}\"\n end\n @solr_conn.commit(softCommit: true) if i % 100 == 0\n end\n @solr_conn.commit\nend", "def fail_with_throttler(exception)\n if @throttled\n redis.hmset(\"throttler:jobs:#{@throttler_uuid}\", \"ended_at\", Time.now.to_i)\n end\n fail_without_throttler(exception)\n end", "def failsafe_timeout\n super\n end" ]
[ "0.6350596", "0.6008212", "0.60057944", "0.5838339", "0.5789068", "0.5756824", "0.56251746", "0.55956846", "0.55131274", "0.55067295", "0.5465428", "0.5431075", "0.5363156", "0.5356042", "0.53560334", "0.5323898", "0.52845746", "0.52670664", "0.52548444", "0.5248886", "0.5241389", "0.52300006", "0.52171016", "0.5210808", "0.5193005", "0.5171269", "0.5154786", "0.5147849", "0.5134702", "0.5132961", "0.5124925", "0.5118767", "0.5109401", "0.51079655", "0.51079285", "0.5105738", "0.51035416", "0.51020455", "0.5100651", "0.5094318", "0.50880104", "0.50800586", "0.5075086", "0.5073536", "0.5065289", "0.5064247", "0.50591755", "0.5056483", "0.5042726", "0.50409526", "0.5032862", "0.5031696", "0.50122154", "0.5003809", "0.5001769", "0.5001499", "0.5001499", "0.5001499", "0.50002563", "0.49999493", "0.49955758", "0.49935427", "0.4992938", "0.49889717", "0.4976769", "0.49719924", "0.4963859", "0.4953885", "0.4946368", "0.49382573", "0.4936824", "0.49362132", "0.4932635", "0.49259415", "0.49215844", "0.49202007", "0.49197894", "0.49084014", "0.4892291", "0.48911732", "0.4889314", "0.48858634", "0.48839676", "0.48831037", "0.4877745", "0.48709977", "0.48709977", "0.48675492", "0.48666218", "0.48633334", "0.48630437", "0.4861367", "0.48511997", "0.4843728", "0.48406675", "0.48400718", "0.48371738", "0.48341492", "0.4821832", "0.47996974" ]
0.55046666
10
GET /api/v1/questions GET /api/v1/questions.json
def index @api_v1_questions = Api::V1::Question.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def questions\n self.class.get(\"/2.2/questions\", @options)\n end", "def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions }\n end\n end", "def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend", "def index\n @my_questions = MyQuestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_questions }\n end\n end", "def index\n render_json(current_user.created_questions)\n end", "def show\n @questions = Question.find(params[:id])\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = @questionable.questions\n end", "def index\n render json: @test_module.test_questions, status: :ok\n end", "def index\n url = @httpIp + '/pet.com/api/question/getAllQuestions'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n # @questions = JSON.parse(response, object_class: OpenStruct)\n @questions = Kaminari.paginate_array(JSON.parse(response, object_class: OpenStruct)).page(params[:page]).per(7)\n end", "def show\n @questions = Question.all\n end", "def index\n @questions = Question.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.json { render :text => @questions.to_json }\n format.xml { render :xml => @questions.to_xml }\n end\n end", "def index\n if get_event\n @v1_questions = @event.questions\n render json: @v1_questions\n else\n @v1_questions = V1::Question.all\n render json: @v1_questions\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def index\n find_questions\n end", "def index\n @question_categories = QuestionCategory.with_questions()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_categories }\n end\n end", "def index\n @users = Question.users\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questions\n end", "def list\n @questions = Question.paginate(page: params[:page], per_page: 10)\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 show\n \t\tquestion = Question.find(params[:id])\n \t\tputs \"QUESTION: #{question.name}\"\n \t\trender json: question\n \tend", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end", "def show\n render_json @question\n end", "def questions\n object.questions.map do |question|\n QuestionSerializer.new(question)\n end\n end", "def index\n @questions = Question.all # Model.all is a method built into active record used to return all records of that model\n end", "def show\n if @v1_question\n render json: @v1_question\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def index\n @questions = @subsection.questions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def index\n if params[:aspect_id]\n @questions = Aspect.find(params[:aspect_id]).questions.all\n else\n @questions = Question.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def show\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_question }\n end\n end", "def show\n @test_question = TestQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @test_question }\n end\n end", "def index\n @survey_questions = get_survey_questions\n end", "def index\n @survey_questions = get_survey_questions\n end", "def index\n @questions = Question.accessible_by(current_ability)\n\n respond_with @questions\n end", "def show\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questions_option }\n end\n end", "def manage_question(body)\n upload_questions(JSON.parse(body)['questions'])\n get_questions\nend", "def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n questionnaire_ids = @course.questionnaire_ids\n elsif @instance\n questionnaire_ids = @instance.questionnaire_ids\n else\n questionnaire_ids = []\n end\n\n # Collect question_ids that are used in those questionnaires\n question_ids = Set.new\n Questionnaire.where(:id => questionnaire_ids).find_each do |questionnaire|\n question_ids.merge(questionnaire.question_ids)\n end\n\n @questions = Question.find(question_ids.to_a)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions.to_json }\n end\n end", "def show\n @question_category = QuestionCategory.with_questions(question_category_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_category }\n end\n end", "def index\n @questions = Question.all\n @question = Question.new\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end", "def index\n render status: :ok, json: @simple_question_alternatives\n end", "def index\n @questions = Question.all\n render :index\n end", "def index\n @question_answers = Question::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_answers }\n end\n end", "def index\n @questions = @quiz.questions.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questions }\n end\n end", "def index\n \n # @questions = Question.all\n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.xml { render :xml => @questions }\n #end\n \n end", "def show\n # id from url comes in as :id key of params hash\n @question = Question.find(params[:id])\n\n @answers = @question.answers.order(created_at: :desc)\n end", "def show\n @qa = Qa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :xml => @qa.to_json(:include => [:answer, :question]) }\n end\n end", "def index\n #if we search throught questions by tags, for example:\n # localhost:3000/questions?tag=Action \n if params[:tag]\n @tag = Tag.find_or_initialize_by(name: params[:tag])\n @questions = @tag.questions.all.all_with_answer_counts.order('updated_at DESC')\n # curl -H \"Accept: application/json\" http://localhost:3000/questions\n respond_to do |format|\n format.html { render }\n format.json { render json: @questions }\n end\n else\n @questions = Question.all.all_with_answer_counts.order('updated_at DESC')\n respond_to do |format|\n format.html { render }\n format.json { render json: @questions }\n end\n end\n end", "def index\n @questions = Question.search(params).page(params[:page]).per(10)\n @question = Question.new\n end", "def questions\r\n return @questions \r\nend", "def index\n @test_questions = TestQuestion.all\n end", "def index\n @test_questions = TestQuestion.all\n end", "def show\n @question = current_node.questions.find(params[:id])\n @question.viewed!(request.remote_ip)\n @answers = (@question.answers.page params[:page]).order_by(current_order)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def question\n Question.find_by_id(questions_id)\n end", "def index\n @questions = Question.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questions }\n end\n end", "def index\n @questions = @page.questions.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questions }\n end\n end", "def index\n @answers = @question.answers\n respond_with( @answers )\n end", "def index\n @user = current_user\n @questions = @user.questions.all\n end", "def show\n @cards_question = Cards::Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cards_question }\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questions }\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questions }\n end\n end", "def show\n @questionset = Questionset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionset }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @question_set = QuestionSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_set }\n end\n end", "def index\n @questions = Question.order(updated_at: :desc).paginate(page:params[:page])\n end", "def index\n @questions = Question.all \n @message = get_data[:message]\n @specialist_id = get_data[:specialist_id]\n @patient_id = get_data[:patient_id]\n end", "def question\n @posts = Post.all\n end", "def questions\n \n end", "def show\n @critical_question = CriticalQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_question }\n end\n end", "def index\n @question_templates = QuestionTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_templates }\n end\n end", "def new\n @my_question = MyQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @my_question }\n end\n end" ]
[ "0.8588737", "0.7651844", "0.763648", "0.758824", "0.74159724", "0.7267644", "0.7215423", "0.7208577", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.71890163", "0.7163702", "0.7130938", "0.71104604", "0.7107706", "0.7067489", "0.7064738", "0.70620275", "0.7013861", "0.7011481", "0.6985624", "0.6972479", "0.6971333", "0.6971333", "0.6971333", "0.6953387", "0.6945425", "0.69384956", "0.6921302", "0.6914158", "0.6914158", "0.6905517", "0.6890657", "0.6889452", "0.68888724", "0.68841034", "0.6879147", "0.68350303", "0.68234974", "0.6796345", "0.6796345", "0.67953867", "0.67429006", "0.6735178", "0.6732167", "0.67172366", "0.6713402", "0.6708645", "0.66992503", "0.6688309", "0.66724634", "0.66690403", "0.66545606", "0.6643465", "0.66157806", "0.6611341", "0.6605603", "0.6598328", "0.65909576", "0.65840703", "0.65840703", "0.6575011", "0.6572217", "0.6570616", "0.655767", "0.65513545", "0.6547766", "0.6523368", "0.65195024", "0.65195024", "0.6504632", "0.6502152", "0.6502152", "0.6502152", "0.6502152", "0.6502152", "0.6489077", "0.6486032", "0.6482057", "0.64782196", "0.64755374", "0.64745843", "0.6470297", "0.64669937" ]
0.78128016
1
GET /api/v1/questions/1 GET /api/v1/questions/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def questions\n self.class.get(\"/2.2/questions\", @options)\n end", "def index\n @api_v1_questions = Api::V1::Question.all\n end", "def show\n if @v1_question\n render json: @v1_question\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions }\n end\n end", "def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end", "def index\n @my_questions = MyQuestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_questions }\n end\n end", "def index\n if get_event\n @v1_questions = @event.questions\n render json: @v1_questions\n else\n @v1_questions = V1::Question.all\n render json: @v1_questions\n end\n end", "def show\n \t\tquestion = Question.find(params[:id])\n \t\tputs \"QUESTION: #{question.name}\"\n \t\trender json: question\n \tend", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend", "def set_api_v1_question\n @api_v1_question = Api::V1::Question.find(params[:id])\n end", "def show\n @questions = Question.find(params[:id])\n end", "def index\n render_json(current_user.created_questions)\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_question }\n end\n end", "def index\n render json: @test_module.test_questions, status: :ok\n end", "def show\n @test_question = TestQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @test_question }\n end\n end", "def index\n url = @httpIp + '/pet.com/api/question/getAllQuestions'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n # @questions = JSON.parse(response, object_class: OpenStruct)\n @questions = Kaminari.paginate_array(JSON.parse(response, object_class: OpenStruct)).page(params[:page]).per(7)\n end", "def show\n render_json @question\n end", "def index\n @questions = @questionable.questions\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def index\n @questions = Question.all\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def show\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questions_option }\n end\n end", "def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end", "def index\n if params[:aspect_id]\n @questions = Aspect.find(params[:aspect_id]).questions.all\n else\n @questions = Question.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def index\n @questions = Question.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.json { render :text => @questions.to_json }\n format.xml { render :xml => @questions.to_xml }\n end\n end", "def question\n Question.find_by_id(questions_id)\n end", "def index\n find_questions\n end", "def show\n @base_question = BaseQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @base_question }\n end\n end", "def show\n @questions = Question.all\n end", "def show\n @question_category = QuestionCategory.with_questions(question_category_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_category }\n end\n end", "def index\n render status: :ok, json: @simple_question_alternatives\n end", "def show\n @questionset = Questionset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionset }\n end\n end", "def index\n @question_categories = QuestionCategory.with_questions()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_categories }\n end\n end", "def index\n @users = Question.users\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @questionnaire }\n end\n end", "def show\n @question_set = QuestionSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_set }\n end\n end", "def create\n @v1_question = V1::Question.new(v1_question_params)\n\n if @v1_question.save\n render json: @v1_question, status: :created\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def index\n @questions = @subsection.questions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def show\n @critical_question = CriticalQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_question }\n end\n end", "def show\n @intake_question = IntakeQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @intake_question }\n end\n end", "def show\n @survey_question = SurveyQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @survey_question }\n end\n end", "def new\n @my_question = MyQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @my_question }\n end\n end", "def show\n @form = Form.where(id: params[:id]).includes(:questions => :answers).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @form }\n end\n end", "def manage_question(body)\n upload_questions(JSON.parse(body)['questions'])\n get_questions\nend", "def show\n @question = current_node.questions.find(params[:id])\n @question.viewed!(request.remote_ip)\n @answers = (@question.answers.page params[:page]).order_by(current_order)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quest }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @qa = Qa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :xml => @qa.to_json(:include => [:answer, :question]) }\n end\n end", "def show\n # id from url comes in as :id key of params hash\n @question = Question.find(params[:id])\n\n @answers = @question.answers.order(created_at: :desc)\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @question }\n end\n end", "def create\n @api_v1_question = Api::V1::Question.new(api_v1_question_params)\n\n respond_to do |format|\n if @api_v1_question.save\n format.html { redirect_to @api_v1_question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_question }\n else\n format.html { render :new }\n format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questions\n end", "def new\n #@question = Question.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @knowledge_points = KnowledgePoint.all\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @question }\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 show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end", "def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end", "def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end", "def get_random\n @question = Question.get_random\n\n unless @question\n render json: { error: \"random question can't be found\" }.to_json, status: 404\n end\n end", "def show\n @cards_question = Cards::Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cards_question }\n end\n end", "def show\n @question_response = QuestionResponse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_response }\n end\n end", "def show\n @category_question = CategoryQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category_question }\n end\n end", "def index\n @questions = Question.all # Model.all is a method built into active record used to return all records of that model\n end", "def index\n @questions = Question.accessible_by(current_ability)\n\n respond_with @questions\n end", "def index\n @questions = Question.all\n @question = Question.new\n end", "def api_v1_question_params\n params.fetch(:api_v1_question, {})\n end", "def show\n @question_tag = QuestionTag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_tag }\n end\n end", "def index\n @question_answers = Question::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_answers }\n end\n end", "def show\n @question_type = QuestionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_type }\n end\n end", "def show\n @answer = Answer.find(params[:id])\n question_id = @answer.question\n @body = @answer.body\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end", "def show\n @poll_question = PollQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_question }\n end\n end" ]
[ "0.79932857", "0.7755646", "0.73663837", "0.7310721", "0.72957736", "0.7263938", "0.7195237", "0.7045953", "0.70385146", "0.7029269", "0.7023901", "0.70228696", "0.70228696", "0.70228696", "0.7015446", "0.6999904", "0.69779843", "0.69776154", "0.69692695", "0.69692695", "0.6956784", "0.69410634", "0.69259286", "0.6866615", "0.6819874", "0.681322", "0.6789231", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67554075", "0.67446303", "0.6721893", "0.67125076", "0.6708657", "0.670449", "0.66806155", "0.6653661", "0.66437465", "0.6643684", "0.66436076", "0.66405827", "0.6631277", "0.6627289", "0.662536", "0.6620001", "0.661177", "0.659279", "0.65884054", "0.657594", "0.6560987", "0.6558924", "0.6558393", "0.6557554", "0.65533066", "0.6552387", "0.6547543", "0.6546891", "0.6546891", "0.6546891", "0.6546891", "0.6546891", "0.6539072", "0.65193325", "0.6516962", "0.6503344", "0.64958006", "0.6483627", "0.64817464", "0.6480957", "0.6475184", "0.6475184", "0.6474537", "0.64673424", "0.645516", "0.64507794", "0.64332217", "0.6431631", "0.64305073", "0.64201003", "0.6418664", "0.6416863", "0.6415118", "0.640382", "0.63983333", "0.6389378" ]
0.0
-1
POST /api/v1/questions POST /api/v1/questions.json
def create @api_v1_question = Api::V1::Question.new(api_v1_question_params) respond_to do |format| if @api_v1_question.save format.html { redirect_to @api_v1_question, notice: 'Question was successfully created.' } format.json { render :show, status: :created, location: @api_v1_question } else format.html { render :new } format.json { render json: @api_v1_question.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @question = Question.new(params[:question])\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully created.' }\n format.json { render json: @question, status: :created, location: @question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n if @question.save\n render json: @question\n else\n render status: 400, nothing: true\n end\n end", "def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @v1_question = V1::Question.new(v1_question_params)\n\n if @v1_question.save\n render json: @v1_question, status: :created\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def manage_question(body)\n upload_questions(JSON.parse(body)['questions'])\n get_questions\nend", "def create\n @question = SurveyQuestion.new(question_params)\n if @question.save\n render json: @question\n else\n render json: @question.errors.full_messages.join(\", \"), status: :unprocessable_entity\n end\n end", "def questions\n self.class.get(\"/2.2/questions\", @options)\n end", "def create\n question = @current_user.question.create!(question_params)\n render json: { question: question }\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to questions_path, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_question\n form_param = params.require(:form).permit(:id)\n\n render json: Question.add_new_question(form_param)\n end", "def create\n @add_question = AddQuestion.new(add_question_params)\n\n respond_to do |format|\n if @add_question.save\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @add_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_params\n params.require(:question).permit(:title, :body)\n #require returns question array\n #of everything being posted, work with the questions part, and allow these two things to be submitted\n end", "def create\n @test_question = TestQuestion.new(params[:test_question])\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, :notice => 'Test question was successfully created.' }\n format.json { render :json => @test_question, :status => :created, :location => @test_question }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @test_question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.create!(question_params.merge({user_id: 1}))\n if question_params[:answers]\n question_params[:answers].with_indifferent_access.each do |answer|\n Answer.create!(name: answer[:name], question_id: @question.id)\n end\n end\n @question.prepare\n @question.broadcast\n render json: @question, status: :created\n end", "def create\n @question = Question.new(params[:question])\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render json: @question, status: :created, location: @question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the answer by calling self.id\n new_question.content = question_hash['question'] #adding all necessary column data to this question object/row\n new_question.create_answers(question_hash)\n new_question.quiz_id = self.id\n new_question.save #send the newly created question to the database\n end", "def create\n @test_question = TestQuestion.new(test_question_params)\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, notice: 'Test question was successfully created.' }\n format.json { render :show, status: :created, location: @test_question }\n else\n format.html { render :new }\n format.json { render json: @test_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @test_question = TestQuestion.new(test_question_params)\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, notice: 'Test question was successfully created.' }\n format.json { render :show, status: :created, location: @test_question }\n else\n format.html { render :new }\n format.json { render json: @test_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n respond_to do |format|\n if @question.save\n # format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render json: @question, status: :created, location: @question }\n else\n # format.html { render :new }\n format.json { render json: @question.errors, status: :bad_request }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: \"Question was successfully created.\" }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(question_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: NoticeMessages::SUCCESS_CREATE_QUESTION }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t# Finding the current surgeon \n\tsurgeon = current_user\n\t# creating the question with current surgeon\n\tquestion = surgeon.questions.new(question_params)\n\tif question.save\n\t# response to the JSON\n\t\trender json: { success: true,message: \"Question Successfully Created.\", response: QuestionSerializer.new(question).as_json(root: false) },:status=>200\n else\n render :json=> { success: false, message: question.errors },:status=> 203\n end\n\tend", "def create\t\n\tquestion_param = question_params.merge(:words => in_words(question_params[\"answer\"].to_i))\n @question = Question.new(question_param)\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n\t#=end\n end", "def create\n @quiz = current_user.quizzes.build(quiz_params)\n\n @quiz.questions.each do |q|\n if q.question_type == \"free_answer\"\n q.answers = []\n end\n end\n\n puts @quiz.questions\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to current_user, notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_params\n # params.require(:tst).permit(:name, :description, :status, :contributors)\n params.require(:question).permit(:name, :description, :status, :hint, :image_url, :explanation, :kind, :correct_response, :pause_at)\n end", "def question_params\n params.require(:question).permit(:title, :body, :answer)\n end", "def create\n @question = current_user.questions.new(params[:question])\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: params.inspect}#'Question was successfully created.' }\n format.json { render json: @question, status: :created, location: @question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\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 create\n @my_question = MyQuestion.new(params[:my_question])\n\n respond_to do |format|\n if @my_question.save\n format.html { redirect_to @my_question, notice: 'My question was successfully created.' }\n format.json { render json: @my_question, status: :created, location: @my_question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @my_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @api_v1_questions = Api::V1::Question.all\n end", "def create\n result = Question.new.create_question(question_params)\n if result\n return render json: {message: 'Question was created succesfully', error: false}\n else\n return render json: {message: 'Error: Question was not created succesfully', error: true}\n end\n end", "def handle_post(body)\n make_response(200, validate_questions(body))\nend", "def question_params\n params.require(:question).permit(:title, :answer)\n end", "def question_params\n params.require(:question).permit(:content, :response_type_id, :parent_id, :category_id, :groups,\n :version_independent_id, :description, :other_allowed, :subcategory_id,\n concepts_attributes: [:id, :value, :display_name, :code_system],\n data_collection_methods: [])\n end", "def question(data)\n xml = xml_root(\"questions\")\n\n arrayed(data).each do |name|\n xml.root << (XML::Node.new(\"question\") << name)\n end\n\n send_and_process('questions/add', 'questions/question', xml)\n end", "def question_params\n params.require(:question).permit(:title, :body, :answer, :tag_list, :slug)\n end", "def create\n\t\t@question = Question.create(params[:question])\n\t\[email protected] = current_user\n\t\trespond_to do |format|\n\t\t\tif @question.save\n\t\t\t\tformat.html { redirect_to @question, notice: 'Question was successfully created.' }\n\t\t\t\tformat.json { render json: @question, status: :created, location: @question }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @question.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def question_params\n params.require(:question).permit(:question)\n end", "def question_params\n params.require(:question).permit(:question, :answer)\n end", "def question_params\n params.require(:question).permit(:question, :answer)\n end", "def create\n @question = Question.new(question_params)\n respond_to do |format|\n if @question.save\n format.html { redirect_to new_question_url, notice: \"已经成功创建题目:#{@question.title}.\" }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_params\n params.require(:question).permit(:title, :body, :user_id, :tag_list, :question_id)\n end", "def index\n render_json(current_user.created_questions)\n end", "def create\n @quiz = Quiz.new(quiz_params)\n questions_arr.each do |i|\n question = Question.new(question_params(i))\n choices_arr(i).each do |j|\n choice = Choice.new(choice_params(j))\n choice.save\n question.choices << choice\n end\n @quiz.questions << question\n end\n\n if @quiz.save\n User.find(params[:user_id]).quizzes << @quiz\n render json: @quiz, status: :created, location: @quiz\n else\n render json: @quiz.errors, status: :unprocessable_entity\n end\n end", "def add_new_questions\n questionnaire_id = params[:id]\n # If the questionnaire is being used in the active period of an assignment, delete existing responses before adding new questions\n if AnswerHelper.check_and_delete_responses(questionnaire_id)\n flash[:success] = 'You have successfully added a new question. Any existing reviews for the questionnaire have been deleted!'\n else\n flash[:success] = 'You have successfully added a new question.'\n end\n\n questionnaire = Questionnaire.find(questionnaire_id)\n current_num_of_questions = questionnaire.questions.size\n max_seq = 0\n Questionnaire.find(questionnaire_id).questions.each do |question|\n if !question.seq.nil? && question.seq > max_seq\n max_seq = question.seq\n end\n end\n ((current_num_of_questions + 1)..(current_num_of_questions + params[:question][:total_num].to_i)).each do\n max_seq += 1\n # Create question object based on type using question_factory\n question = question_factory(params[:question][:type], questionnaire_id, max_seq)\n if question.is_a? ScoredQuestion\n question.weight = params[:question][:weight]\n question.max_label = Question::MAX_LABEL\n question.min_label = Question::MIN_LABEL\n end\n\n if Question::SIZES.key?(question.class.name)\n question.size = Question::SIZES[question.class.name]\n end\n if Question::ALTERNATIVES.key?(question.class.name)\n question.alternatives = Question::ALTERNATIVES[question.class.name]\n end\n\n begin\n question.save\n rescue StandardError => e\n flash[:error] = e.message\n end\n end\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end", "def new\n @questions = Question.all\n @question = Question.new\n @answers = @question.answers.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def create\n workout = Workout.find params[:workout_id]\n result = Question.create(workout, { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n @question = result[:question]\n\n respond_to do |format|\n unless @question.persisted?\n format.json { render :json => @question.errors.full_messages, :status => :unprocessable_entity }\n else\n format.json { render :json => @question.as_json({:include => :answers}) }\n end\n \n end\n\n end", "def create\n filtered_params = filter_params(question_params)\n @question = @form.questions.new(filtered_params)\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to admin_form_questions_path, notice: 'Вопрос успешно создан' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @question.save\n @question_link = QuizQuestion.create!(:qtype => params[:qtype], :qid => @question.id, :quizid => params[:quizid], :points => params[:points])\n @question_link.save\n @question.update(:questionid => @question_link.id)\n @quiz = Quiz.find_by_id(params[:quizid])\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_params\n params.require(:question).permit(:question, :answer, :status_id)\n end", "def question_params\n params.require(:question).permit(:title, :content)\n end", "def question_params\n params.require(:question).permit(:title, :content)\n end", "def question_params\n params.require(:question).permit(:title, :content)\n end", "def question_params\n params.require(:question).permit(:title, :content)\n end", "def question_params\n params.require(:question).permit()\n end", "def create\n #before_action :set_tag\n #ログインしているユーザーが質問を作る\n @question = current_user.questions.build(question_params)\n # respond_to: リクエストされるフォーマットがHTML形式の場合とJSON形式の場合で処理を分けることができる\n respond_to do |format|\n if @question.save\n # TODO: 経験値機能の処理\n # current_user.get_exp(10)\n # current_user.check_level_up\n format.html { redirect_to @question, notice: \"質問を投稿しました\" }\n format.json { render :show, status: :created, location: @question }\n else\n #savaできなかった場合\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_mod\n if params[:title] != nil && params[:content] != nil && params[:subId] != nil && params[:userId] != nil && params[:groupId] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n @question.subId = params[:subId].to_i\n @question.userId = params[:userId].to_i\n @question.groupId = params[:groupId].to_i\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/createQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully created\"\n redirect_to questions_path\n\n end\n end", "def question_params\n params.require(:question).permit(:title, :content, :tags, :tag_list)\n end", "def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend", "def index\n render json: @test_module.test_questions, status: :ok\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def create\n authorize_action_for Question\n @question = current_user.questions.new(question_params)\n @question.user = current_user\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_params\n params.require(:question).permit(:title, :content)\n end", "def question_params\n params.require(:question).permit(:id, :user_id, :question, :explanation, :tags, :hint, :worth, :active, :qtype, :test_id)\n end", "def new\n @test_question = TestQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @test_question }\n end\n end", "def questions\n \n end", "def create\n @time_series_question = @time_series.questions.build(params[:time_series_question])\n\n respond_to do |format|\n if @time_series_question.save\n format.html { redirect_to time_series_question_path(@owner, @time_series, @time_series_question), flash: {success: t('app.msgs.success_created', :obj => t('mongoid.models.time_series_question.one'))} }\n format.json { render json: @time_series_question, status: :created, location: @time_series_question }\n else\n @datasets = @time_series.datasets.sorted\n\n # get the list of questions for each dataset in the time series that are not already in the time series\n @questions = {}\n @datasets.each do |dataset|\n @questions[ts_dataset.dataset_id.to_s] = ts_dataset.dataset.questions.for_analysis_not_in_codes(@time_series.questions.codes_for_dataset(dataset.dataset_id))\n end\n\n add_common_options\n\n @is_new = true\n\n format.html { render action: \"new\" }\n format.json { render json: @time_series_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.new(params[:question])\n\n respond_to do |format|\n if @question.save(params[:question])\n format.html { redirect_to new_question_url, notice: 'questions was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def question_params\n params.require(:question).permit(:title, :content, :q)\n end", "def create\n @question = Question.new(question_params)\n \n unless params[:tags].nil?\n @question.tags = Tag.find(params[:tags])\n end\n \n respond_to do |format|\n if @question.save\n format.html { redirect_to admin_question_path(@question), notice: 'Question was successfully created.' }\n format.json { render action: 'show', status: :created, location: @question }\n else\n @tags = Tag.all\n format.html { render action: 'new' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cards_question = Cards::Question.new(params[:cards_question])\n\n respond_to do |format|\n if @cards_question.save\n format.html { redirect_to @cards_question, notice: 'Question was successfully created.' }\n format.json { render json: @cards_question, status: :created, location: @cards_question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cards_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n #@question = Question.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end", "def question_params\n params.require(:question).permit(:question, :name, :email)\n end", "def question_params\n params.require(:question).permit(:body)\n end", "def create\n @room = Room.new(room_params)\n \n respond_to do |format|\n if @room.save\n trivia_category = (@room.category.eql? \"any\") ? '' : \"category=\" + @room.category\n \n questions_response = RestClient::Request.execute(\n method: :get,\n url: 'https://opentdb.com/api.php?amount=7&type=multiple&' + trivia_category\n )\n questions = JSON.parse(questions_response)['results']\n\n questions.each do |question|\n Question.create(\n :problem => question['question'],\n :category => question['category'],\n :correct_answer => question[\"correct_answer\"],\n :incorrect_answer_one => question[\"incorrect_answers\"][0],\n :incorrect_answer_two => question[\"incorrect_answers\"][1],\n :incorrect_answer_three => question[\"incorrect_answers\"][2],\n :room_id => @room.id\n )\n end\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to question_answer_url(@question, @answer), notice: \"Answer was successfully created.\" }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def questions=(value)\n @questions = value\n end", "def new\n @question = current_user.questions.new\n\t2.times do\n\t @question.choices.build\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def create\n @question = Question.new(question_params)\n link_response_sets(params)\n\n if @question.all_versions.count >= 1\n if @question.not_owned_or_in_group?(current_user) || @question.prev_not_owned_or_in_group?(current_user)\n render(json: @question.errors, status: :unauthorized) && return\n elsif @question.all_versions.last.status == 'draft'\n render(json: @question.errors, status: :unprocessable_entity) && return\n end\n @question.version = @question.most_recent + 1\n end\n assign_author\n if @question.save\n render :show, status: :created, location: @question\n else\n # @categories = Category.all\n render json: @question.errors, status: :unprocessable_entity\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @question }\n end\n end" ]
[ "0.7403698", "0.7302256", "0.7193526", "0.71894675", "0.7154693", "0.7065109", "0.70428145", "0.6877065", "0.68398523", "0.68280333", "0.68256307", "0.6820573", "0.6810663", "0.6805841", "0.677892", "0.6776349", "0.67584056", "0.67504466", "0.67504466", "0.67504466", "0.67504466", "0.67504466", "0.67504466", "0.67504466", "0.67504466", "0.67504466", "0.67504466", "0.67499965", "0.67398435", "0.6737367", "0.6737367", "0.6723194", "0.6718799", "0.66809034", "0.66538227", "0.66482234", "0.6646652", "0.66401166", "0.662379", "0.6622991", "0.66023415", "0.65830153", "0.6565197", "0.6564767", "0.6543119", "0.65255535", "0.6524818", "0.65245765", "0.6523476", "0.6510946", "0.650273", "0.64998233", "0.64998233", "0.6490094", "0.64871293", "0.6481018", "0.64705664", "0.6462069", "0.6451703", "0.64505327", "0.64403", "0.64391476", "0.64309007", "0.6422865", "0.6422865", "0.6422865", "0.6422865", "0.6421953", "0.6411784", "0.6402074", "0.6399507", "0.63948935", "0.63938916", "0.6388426", "0.6388426", "0.6388426", "0.6388426", "0.6388426", "0.63855296", "0.6384159", "0.63833684", "0.63811624", "0.6379952", "0.63765216", "0.63760746", "0.6374337", "0.6372918", "0.63707834", "0.6369759", "0.63654727", "0.6351866", "0.63486046", "0.6345103", "0.6340682", "0.63360596", "0.63346165", "0.63332146", "0.63292426", "0.6326451", "0.63232315" ]
0.7252838
2
PATCH/PUT /api/v1/questions/1 PATCH/PUT /api/v1/questions/1.json
def update respond_to do |format| if @api_v1_question.update(api_v1_question_params) format.html { redirect_to @api_v1_question, notice: 'Question was successfully updated.' } format.json { render :show, status: :ok, location: @api_v1_question } else format.html { render :edit } format.json { render json: @api_v1_question.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render :action => \"edit\" }\n # format.json { render :json => @question.errors, :status => :unprocessable_entity }\n # end\n end\n end", "def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.json { render :json => 'Question updated OK' }\n format.xml { head :ok }\n else\n format.json { render :json => @question.errors }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to new_question_path, notice: 'questions was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n question = Question.find_by!(id: params[:id])\n if question\n question.name = params[:name]\n question.description = params[:description]\n question.user_id = params[:user_id]\n question.category_id = params[:category_id]\n question.zavrseno = params[:zavrseno]\n question.uposlenik_id = params[:uposlenik_id]\n question.save\n render json: question, status: 200 \n else\n render json: { errors: \"This link is invalid.\"}, status: 404\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_correct_answer\n question_params = params.permit(:question_id, :question_type_id, :option_id)\n \n render json: Question.update_correct_option(question_params)\n end", "def update\n question = Question.find(params[:id])\n authorize question\n\n new_version = question.template.generate_version?\n\n old_question_ids = {}\n if new_version\n # get a map from option number to id\n old_number_to_id = {}\n question.question_options.each do |opt|\n old_number_to_id[opt.number] = opt.id\n end\n\n # get a map from question versionable id to old id\n question.template.questions.each do |q|\n old_question_ids[q.versionable_id] = q.id\n end\n end\n\n question = get_modifiable(question)\n\n question_id_map = {}\n if new_version\n # params now out of sync (after versioning) with the question_options\n # so when we do the question.update it'll mess up\n # need to remap params to keep them consistent\n old_to_new_opts = {}\n question.question_options.each do |opt|\n old_id = old_number_to_id[opt.number]\n old_to_new_opts[old_id.to_s] = opt.id.to_s\n end\n\n question.template.questions.each do |q|\n question_id_map[old_question_ids[q.versionable_id].to_s] = q.id.to_s\n end\n end\n\n # rewrite the question_option ids so they match the new\n # version of the question\n # and also rewrite the remove_data question ids\n attrs = question_params\n attrs = update_option_ids(attrs, old_to_new_opts) if new_version && !attrs['question_options_attributes'].nil?\n\n # Need to reattach the incoming annotation's and question_options to the\n # modifiable (versioned) question\n attrs = transfer_associations(attrs, question) if new_version\n\n # If the user unchecked all of the themes set the association to an empty array\n # add check for number present to ensure this is not just an annotation\n attrs[:theme_ids] = [] if attrs[:theme_ids].blank? && attrs[:number].present?\n if question.update(attrs)\n if question.update_conditions(sanitize_hash(params['conditions']),\n old_to_new_opts, question_id_map)\n flash.now[:notice] = success_message(question, _('updated'))\n end\n else\n flash.now[:alert] = flash.now[:alert] = failure_message(question, _('update'))\n end\n if question.section.phase.template.customization_of.present?\n redirect_to org_admin_template_phase_path(\n template_id: question.section.phase.template.id,\n id: question.section.phase.id,\n section: question.section.id\n )\n else\n redirect_to edit_org_admin_template_phase_path(\n template_id: question.section.phase.template.id,\n id: question.section.phase.id,\n section: question.section.id\n )\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n @question.update_attributes(params[:question])\n render :json => @question.id if @question.save\n # respond_to do |format|\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n # end\n # end\n end", "def update\n @test_question = TestQuestion.find(params[:id])\n\n respond_to do |format|\n if @test_question.update_attributes(params[:test_question])\n format.html { redirect_to @test_question, :notice => 'Test question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @test_question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n #@question = Question.find(params[:id])\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: t('alert.question.update_success', default: 'Question was successfully updated.') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @question.status == 'published' || @question.version_independent_id != question_params[:version_independent_id]\n render json: @question.errors, status: :unprocessable_entity\n else\n update_response_sets(params)\n @question.update_concepts('Question')\n @question.updated_by = current_user\n if @question.update(question_params)\n @question.groups.each do |group|\n @question.add_to_group(group.id)\n end\n render :show, status: :ok, location: @question\n else\n @categories = Category.all\n render json: @question.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n if @my_question.update_attributes(params[:my_question])\n format.html { redirect_to @my_question, notice: 'My question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to edit_question_path(@question), notice: 'Question was successfully updated.' }\n format.json\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question.course, notice: 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @question\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, :notice =>'Question was successfully updated.' }\n format.json { render :show, :status => :ok, :location => @question }\n else\n format.html { render :edit }\n format.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_question_content\n question_params = params.require(:question).permit(:id, :content)\n\n render json: Question.update_question_content(question_params)\n end", "def update\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n if @questions_option.update_attributes(params[:questions_option])\n format.html { redirect_to @questions_option, notice: 'Questions option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @questions_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_question\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\t@found = 0\n\t\t\tquizzes.each do |quiz|\n\t\t\t\tif(quiz.questions.exists?(:id => params[:question_id]))\n\t\t\t\t\t@found = @found + 1\n\t\t\t\tend \n\t\t\tend\n\t\t\tif (@found > 0)\n\t\t\t\tquestion = Question.find(params[:question_id])\n\t\t\t\tif (question.update(question_params))\n\t\t\t\t\trender json: { success: true, data: { :question => question }, info:{} }, status: 200\n\t\t\t\telse\n\t\t\t\t\trender json: { error: question.errors }, status: 422 \n\t\t\t\tend\t\n\t\t\telse\n\t\t\t\trender json: { error:\"Question is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n if (@question.question_type.short_text? || @question.question_type.open_ended_text?)\n path = survey_path(params[:survey_id])\n else\n path = survey_question_path(params[:survey_id],@question.id)\n end\n format.html { redirect_to path, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_question\n @api_v1_question = Api::V1::Question.find(params[:id])\n end", "def update_question_type\n form_params = params.require(:form).permit(:question_id, :question_type)\n\n render json: Question.update_question_type(form_params)\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_question\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to :planner, notice: 'Question was successfully updated.' }\n format.json { respond_with_bip(@question) }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: \"Question was successfully updated.\" }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def manage_question(body)\n upload_questions(JSON.parse(body)['questions'])\n get_questions\nend", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'La pregunta fue modificada correctamente.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize_action_for @question\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n qp = question_params\n if qp[:question_type] == \"vignette\" or qp[:question_type] == \"nonchoice\"\n qp[:answer] = \"\"\n end\n\n respond_to do |format|\n if @question.update(qp)\n format.html { redirect_to paper_questions_path(question_params[:paper_id],question_params[:id]), notice: '題目已被成功編輯' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { redirect_to edit_paper_question_path, notice: '上傳檔案大小不可超過500KB' }\n format.json { render json: paper_questions_path.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @admin_question\n\n respond_to do |format|\n if @admin_question.update(admin_question_params)\n format.html { redirect_to @admin_question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@question = Question.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @question.update_attributes(params[:question])\n\t\t\t\tformat.html { redirect_to @question, notice: 'Question was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @question.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to [@category, @question], notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # before_action :set_question\n #before_action :set_tag\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: \"更新しました\" }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @test_question.update(test_question_params)\n format.html { redirect_to @test_question, notice: 'Test question was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_question }\n else\n format.html { render :edit }\n format.json { render json: @test_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_question_with_http_info(question_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: QuestionsApi.update_question ...'\n end\n # verify the required parameter 'question_id' is set\n if @api_client.config.client_side_validation && question_id.nil?\n fail ArgumentError, \"Missing the required parameter 'question_id' when calling QuestionsApi.update_question\"\n end\n allowable_values = [30, 60, 120, 180, 240, 300, 600]\n if @api_client.config.client_side_validation && opts[:'answer_time'] && !allowable_values.include?(opts[:'answer_time'])\n fail ArgumentError, \"invalid value for \\\"answer_time\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/questions/{questionId}'.sub('{' + 'questionId' + '}', CGI.escape(question_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data', 'application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n form_params['text'] = opts[:'text'] if !opts[:'text'].nil?\n form_params['answer_time'] = opts[:'answer_time'] if !opts[:'answer_time'].nil?\n form_params['video'] = opts[:'video'] if !opts[:'video'].nil?\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Question' \n\n # auth_names\n auth_names = opts[:auth_names] || ['basicAuth', 'bearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: QuestionsApi#update_question\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @question_set = QuestionSet.find(params[:id])\n\n respond_to do |format|\n if @question_set.update_attributes(params[:question_set])\n format.html { redirect_to @question_set, notice: 'Question set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update_existing_quiz_question(course_id,quiz_id,id,question__question_name__,question__question_text__,question__question_type__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :question__question_name__,\n :question__question_text__,\n :question__quiz_group_id__,\n :question__question_type__,\n :question__position__,\n :question__points_possible__,\n :question__correct_comments__,\n :question__incorrect_comments__,\n :question__neutral_comments__,\n :question__text_after_answers__,\n :question__answers__,\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"quiz_id is required\" if quiz_id.nil?\n raise \"id is required\" if id.nil?\n raise \"question__question_name__ is required\" if question__question_name__.nil?\n raise \"question__question_text__ is required\" if question__question_text__.nil?\n raise \"question__question_type__ is required\" if question__question_type__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :quiz_id => quiz_id,\n :id => id,\n :question__question_name__ => question__question_name__,\n :question__question_text__ => question__question_text__,\n :question__question_type__ => question__question_type__\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/quizzes/{quiz_id}/questions/{id}\",\n :course_id => course_id,\n :quiz_id => quiz_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 QuizQuestion.new(response)\n end", "def update\n @survey_question = SurveyQuestion.find(params[:id])\n\n respond_to do |format|\n if @survey_question.update_attributes(params[:survey_question])\n format.html { redirect_to survey_questions_path(@survey_question.survey_id),\n notice: 'Survey question was successfully updated.' }\n #format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n #format.json { render json: @survey_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @questionset = Questionset.find(params[:id])\n\n respond_to do |format|\n if @questionset.update_attributes(params[:questionset])\n format.html { redirect_to @questionset, notice: 'Questionset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @questionset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @add_question.update(add_question_params)\n format.html { redirect_to @add_question, notice: 'Add question was successfully updated.' }\n format.json { render :show, status: :ok, location: @add_question }\n else\n format.html { render :edit }\n format.json { render json: @add_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n @cards_question = Cards::Question.find(params[:id])\n\n respond_to do |format|\n if @cards_question.update_attributes(params[:cards_question])\n format.html { redirect_to @cards_question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cards_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n format.js { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n format.js { head :unprocessable_entity }\n end\n end\n end", "def update_score\n question_params = params.require(:question).permit(:id, :score)\n\n render json: Question.update_score(question_params)\n end", "def update\n @question = @quiz.questions.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n flash[:notice] = 'Question was successfully updated.'\n format.html { redirect_to(quiz_questions_path(@quiz)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n\n respond_to do |format|\n if @multiple_choice_question.update_attributes(params[:multiple_choice_question])\n format.html { redirect_to @multiple_choice_question, notice: 'Multiple choice question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @multiple_choice_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n filtered_params = filter_params(question_params)\n\n respond_to do |format|\n if @question.update(filtered_params)\n format.html { redirect_to admin_form_questions_path, notice: 'Вопрос успешно обновлен' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if params[:tags].nil?\n @question.tags = []\n else\n @question.tags = Tag.find(params[:tags])\n end\n\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to admin_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n redirect_to \"/\"\n\n # respond_to do |format|\n # if @question.update(question_params)\n # format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n # format.json { render :show, status: :ok, location: @question }\n # else\n # format.html { render :edit }\n # format.json { render json: @question.errors, status: :bad_request }\n # end\n # end\n end", "def update\n @question = Question.find(params[:id])\n \n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @b_question.update(b_question_params)\n format.html { redirect_to @b_question }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @b_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey = Survey.find(params[:id])\n success = @survey.update_attributes(params[:survey])\n \n puts \"UPDATE: Survey:#{@survey.id} - #{@survey.name}\"\n # Load the JSON Survey form data.\n survey_questions = ActiveSupport::JSON.decode(@survey.survey_data)\n #y survey_questions\n \n update_questions(@survey, survey_questions)\n \n # Render a response.\n respond_to do |format|\n if success\n format.html { redirect_to(@survey, :notice => 'Survey was successfully updated.') }\n format.xml { head :ok }\n format.js { head :ok}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @survey.errors, :status => :unprocessable_entity }\n format.js { render :json => @survey.errors, :status => :error }\n end\n end\n end", "def update\n respond_to do |format|\n if @mongo_question.update(mongo_question_params)\n format.html { redirect_to @mongo_question, notice: 'Mongo question was successfully updated.' }\n format.json { render :show, status: :ok, location: @mongo_question }\n else\n format.html { render :edit }\n format.json { render json: @mongo_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @template_question.update(template_question_params)\n format.html { redirect_to @template_question, notice: 'Template question was successfully updated.' }\n format.json { render :show, status: :ok, location: @template_question }\n else\n format.html { render :edit }\n format.json { render json: @template_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @examquestion.update(examquestion_params)\n format.html { redirect_to @examquestion, notice: 'Examquestion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @examquestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.js\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @intake_question = IntakeQuestion.find(params[:id])\n\n respond_to do |format|\n if @intake_question.update_attributes(params[:intake_question])\n format.html { redirect_to @intake_question, notice: 'Intake question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @intake_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @base_question = BaseQuestion.find(params[:id])\n\n respond_to do |format|\n if @base_question.update_attributes(params[:base_question])\n format.html { redirect_to @base_question, notice: 'Base question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @base_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey_question.update(survey_question_params)\n @survey_question = SurveyQuestion.new\n @survey_questions = SurveyQuestion.all \n # respond_to do |format|\n # if @survey_question.update(survey_question_params)\n # format.html { redirect_to @survey_question, notice: 'Survey question was successfully updated.' }\n # format.json { render :show, status: :ok, location: @survey_question }\n # else\n # format.html { render :edit }\n # format.json { render json: @survey_question.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n @critical_question = CriticalQuestion.find(params[:id])\n\n respond_to do |format|\n if @critical_question.update_attributes(params[:critical_question])\n format.html { redirect_to @critical_question, notice: 'Critical question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @poll_question = PollQuestion.find(params[:id])\n\n respond_to do |format|\n if @poll_question.update_attributes(params[:poll_question])\n format.html { redirect_to @poll_question, notice: 'Poll question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7259023", "0.7165158", "0.7044536", "0.7006729", "0.6907968", "0.68261033", "0.6800151", "0.6750449", "0.67404205", "0.6726497", "0.6671826", "0.6671826", "0.6671826", "0.6671826", "0.6671826", "0.66649675", "0.66295034", "0.66005725", "0.65971416", "0.6596202", "0.6590358", "0.658767", "0.6554726", "0.6548356", "0.6548356", "0.6548356", "0.6528892", "0.65124995", "0.6511771", "0.6505818", "0.6489239", "0.64623725", "0.64566416", "0.64547545", "0.6443116", "0.64402026", "0.6439582", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.64382005", "0.6428744", "0.6420517", "0.64081526", "0.637245", "0.6340061", "0.6338232", "0.63314235", "0.6323727", "0.630777", "0.6306857", "0.6299497", "0.62909997", "0.62890494", "0.62839615", "0.6244202", "0.62306255", "0.62306255", "0.6228136", "0.62269413", "0.6221854", "0.62196606", "0.62185955", "0.6212606", "0.6210177", "0.6199038", "0.61943287", "0.61848176", "0.6181756", "0.6180009", "0.6173457", "0.61673963", "0.61590034", "0.61570305", "0.61556774", "0.61473274", "0.6130413", "0.61156505", "0.6115215", "0.6108361", "0.6107816", "0.6105448", "0.6100377", "0.60973984", "0.6095908", "0.60932946" ]
0.7117659
2
DELETE /api/v1/questions/1 DELETE /api/v1/questions/1.json
def destroy @api_v1_question.destroy respond_to do |format| format.html { redirect_to api_v1_questions_url, notice: 'Question was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted question successfully'}, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end", "def destroy\n #@question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_question = TestQuestion.find(params[:id])\n @test_question.destroy\n\n respond_to do |format|\n format.html { redirect_to test_questions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_url(params[:survey_id]) }\n format.json { head :no_content }\n end\n end", "def delete_question\n question_params = params.permit(:id, :form_id, :question_type_id)\n\n render json: Question.delete_question(question_params)\n end", "def destroy\n @question.active = [email protected]\n\n questions_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, questions_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully deleted\"\n redirect_to questions_path\n end", "def destroy\n @my_question = MyQuestion.find(params[:id])\n @my_question.destroy\n\n respond_to do |format|\n format.html { redirect_to my_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n\tend", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to admin_questions_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionable = @question.questionable\n @question.destroy\n respond_to do |format|\n format.html\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @examquestion.destroy\n respond_to do |format|\n format.html { redirect_to examquestions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @base_question = BaseQuestion.find(params[:id])\n @base_question.destroy\n\n respond_to do |format|\n format.html { redirect_to base_questions_url }\n format.json { head :no_content }\n end\n end", "def delete\n question = QuestionTest.where(test_id: params[:test_id], question_id: params[:id])\n if question.delete_all\n return render json: {message: 'Question was removed succesfully.', error: false}\n else\n return render json: {message: 'Error: Something went wrong. Question was not removed.', error: true}\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @b_question.destroy\n respond_to do |format|\n format.html { redirect_to questions_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'La pregunta ha sido eliminada!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_question = SurveyQuestion.find(params[:id])\n @survey_question.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_questions_url }\n # format.json { head :no_content }\n end\n end", "def destroy\n\n @question.destroy\n \n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'DNS was successfully removed.' }\n format.json { head :no_content }\n \nend\n end", "def destroy\n @test_question.destroy\n respond_to do |format|\n format.html { redirect_to test_questions_url, notice: 'Test question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_question.destroy\n respond_to do |format|\n format.html { redirect_to test_questions_url, notice: 'Test question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n head :no_content\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: \"Question was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, :notice => 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @critical_question = CriticalQuestion.find(params[:id])\n @critical_question.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @add_question.destroy\n respond_to do |format|\n format.html { redirect_to add_questions_url, notice: 'Add question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionset = Questionset.find(params[:id])\n @questionset.destroy\n\n respond_to do |format|\n format.html { redirect_to questionsets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to category_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, @admin_question\n\n @admin_question.destroy\n respond_to do |format|\n format.html { redirect_to admin_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n\n @question.destroy\n \n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to paper_questions_path, notice: '題目已被成功刪除' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n @tutorial_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n @multiple_choice_question.destroy\n\n respond_to do |format|\n format.html { redirect_to multiple_choice_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to admin_form_questions_path, notice: 'Вопрос успешно удалена' }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionstatu.destroy\n respond_to do |format|\n format.html { redirect_to questionstatus_index_path, notice: 'Mytest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @intake_question = IntakeQuestion.find(params[:id])\n @intake_question.destroy\n\n respond_to do |format|\n format.html { redirect_to intake_questions_url }\n format.json { head :ok }\n end\n end", "def delete\n supprimer = QuestionOuverteService.instance.supprimerQuestion(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: '質問を削除しました' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @question\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @quest = Quest.find(params[:id])\n @quest.destroy\n\n respond_to do |format|\n format.html { redirect_to quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @question_set = QuestionSet.find(params[:id])\n @question_set.destroy\n\n respond_to do |format|\n format.html { redirect_to question_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: '削除しました。' }\n format.json { head :no_content }\n end\n end", "def destroy\n @quiz.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: '質問を削除しました' }\n format.json { head :no_content }\n end\n end", "def destroy\n redirect_to \"/\"\n # @question.destroy\n # respond_to do |format|\n # format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def destroy\n @questions_option = QuestionsOption.find(params[:id])\n @questions_option.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_response = QuestionResponse.find(params[:id])\n @question_response.destroy\n\n respond_to do |format|\n format.html { redirect_to question_responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_question.destroy\n @survey_questions = SurveyQuestion.all\n # @survey_question.destroy\n # respond_to do |format|\n # format.html { redirect_to survey_questions_url, notice: 'Survey question was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def destroy\n @question_answer = Question::Answer.find(params[:id])\n @question_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to question_answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cards_question = Cards::Question.find(params[:id])\n @cards_question.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_type = QuestionType.find(params[:id])\n @question_type.destroy\n\n respond_to do |format|\n format.html { redirect_to question_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.8252109", "0.8090987", "0.776588", "0.776588", "0.77635974", "0.7758693", "0.7757807", "0.7757807", "0.7757807", "0.7757807", "0.7757807", "0.7757807", "0.7756929", "0.7732027", "0.77263165", "0.77263165", "0.77263165", "0.77263165", "0.77263165", "0.77263165", "0.7720597", "0.7717457", "0.76376915", "0.7619349", "0.7610805", "0.76061267", "0.7597259", "0.75882614", "0.7575582", "0.7567734", "0.75394005", "0.75284445", "0.7522105", "0.75126207", "0.75126207", "0.7510529", "0.7482363", "0.74676037", "0.7458913", "0.7458913", "0.7429392", "0.7415783", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7410447", "0.7381022", "0.7376926", "0.7370778", "0.73576194", "0.7353166", "0.735264", "0.73525816", "0.73453766", "0.7342608", "0.73410976", "0.73407364", "0.73334336", "0.7329132", "0.7329129", "0.7326266", "0.7325229", "0.73140013", "0.7310269", "0.73084193", "0.72991264", "0.7291371", "0.72901064", "0.72869605", "0.728073", "0.72800875", "0.7275998", "0.7274742", "0.7274464", "0.7274024", "0.72699976", "0.72641385", "0.72641385", "0.72641385", "0.72641385", "0.72641385", "0.72641385" ]
0.8159502
1
Use callbacks to share common setup or constraints between actions.
def set_api_v1_question @api_v1_question = Api::V1::Question.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def 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 revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\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\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup(&block)\n define_method(:setup, &block)\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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def 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 setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def duas1(action)\n action.call\n action.call\nend", "def call\n setup_context\n super\n end" ]
[ "0.6165422", "0.60457647", "0.5946384", "0.5916027", "0.58905005", "0.583495", "0.5777223", "0.56995213", "0.56995213", "0.56532377", "0.5621348", "0.5422839", "0.54118705", "0.54118705", "0.54118705", "0.53935355", "0.5379617", "0.53577393", "0.53407264", "0.53398263", "0.53316694", "0.53116405", "0.52972704", "0.5296464", "0.529617", "0.52609056", "0.52449894", "0.52388823", "0.52388823", "0.52388823", "0.52388823", "0.52388823", "0.52339035", "0.52324325", "0.52277064", "0.5221976", "0.5219301", "0.52134573", "0.5207571", "0.52070796", "0.51770556", "0.517467", "0.51727664", "0.51673347", "0.51603955", "0.51581466", "0.515401", "0.51533973", "0.5152852", "0.5143863", "0.5140699", "0.513394", "0.5113603", "0.5113603", "0.51126283", "0.5110439", "0.51070756", "0.50922215", "0.50881314", "0.50826275", "0.50788856", "0.50678945", "0.5055518", "0.5052638", "0.5049997", "0.5049997", "0.50348604", "0.5026469", "0.50217324", "0.50154436", "0.5013927", "0.50015604", "0.50013465", "0.49973735", "0.49900484", "0.49900484", "0.49862546", "0.4981161", "0.49783245", "0.49772155", "0.49678212", "0.49645492", "0.49579585", "0.49572104", "0.49550694", "0.4954394", "0.4952923", "0.49466532", "0.49427935", "0.49338013", "0.4931052", "0.49276745", "0.4927467", "0.4924998", "0.49223173", "0.49208498", "0.49184024", "0.49167758", "0.49163175", "0.4916066", "0.49157935" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def api_v1_question_params params.fetch(:api_v1_question, {}) 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
Deliver all the sms messages marked with this as its sms service provider
def deliver Outbound.deliver(delivery_options.merge(:conditions => ['sms_service_provider_id = ?', self.provider_id])) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deliver\n xml = Clockwork::XML::SMS.build_multiple( self.messages )\n http_response = Clockwork::HTTP.post( Clockwork::API::SMS_URL, xml, @use_ssl )\n responses = Clockwork::XML::SMS.parse_multiple( self.messages, http_response )\n end", "def deliver\n #inform_interceptors\n if delivery_handler\n delivery_handler.deliver_sms(self) { do_delivery }\n else\n do_delivery\n end\n inform_observers\n self\n end", "def deliver(sms)\n new.deliver!(sms)\n end", "def deliver(sms)\n create_sms(sms).submit()\n end", "def deliver_sms(sms) #:nodoc:\r\n ActiveSupport::Notifications.instrument(\"deliver.sms_carrier\") do |payload|\r\n set_payload_for_sms(payload, sms)\r\n yield # Let Sms do the delivery actions\r\n end\r\n end", "def deliver_message(options)\n self.sms_service_provider||= default_service_provider\n\n # set the actual message if it differs; not a before_save to reduce the\n # overhead of checking for all commits\n self.actual_message = substituted_draft_message\n\n result = (self.sms_service_provider).send_sms(self)\n self.unique_id = result[:unique_id] if result.is_a?(Hash)\n \n result\n end", "def inform_observers(sms)\n @@delivery_notification_observers.each do |observer|\n observer.delivered_sms(sms)\n end\n end", "def deliver!(sms = @sms) #:nodoc:\n raise \"no SMS object available for delivery!\" unless sms\n logger.info \"Sending SMS: #{sms} via #{sms.delivery}\" unless logger.nil?\n \n begin\n send(\"perform_delivery_#{sms.delivery}\", sms) if perform_deliveries\n rescue Exception => e \n raise e if raise_delivery_errors\n end\n \n logger.info \"SMS Sent!\" unless logger.nil?\n return sms\n end", "def twilio_broadcast_queue!(client,members)\n client.account.sms.messages.list.each do |sms|\n\t\t\t# only look at messages that twilio has recieved\n\t\t\tif sms.direction == 'inbound'\n \tif TextMessages.count(:sms_id => sms.sid) == 0\n \t# spam it to others\n \tmembers.each do |name,info|\n \tif info[:phone] != sms.from\n \ttwilio_send_text_message!(client,info[:phone],sms.body)\n \tend\n \tend\n \t\tTextMessages.create(:sms_id => sms.sid)\n \t\tend\n\t\t\tend\n end\n end", "def deliver_sms(params)\n#puts \"**** Message#deliver_sms; params=#{params}\"\n sms_gateway = params[:sms_gateway]\n phone_number_array = @contact_info.map {|c| c[:phone]}.compact.uniq\n phone_numbers = phone_number_array.join(',')\n assemble_sms()\n#puts \"**** sms_gateway.deliver #{sms_gateway} w #{phone_numbers}: #{sms_only}\"\n #******* CONNECT TO GATEWAY AND DELIVER MESSAGES \n gateway_reply = \n sms_gateway.deliver(phone_numbers, sms_only)\n#puts \"**** gateway_reply=#{gateway_reply}\"\n #******* PROCESS GATEWAY REPLY (INITIAL STATUSES OF SENT MESSAGES) \n gtw_msg_id = nil\n if phone_number_array.size == 1\n # SINGLE PHONE NUMBER \n if gateway_reply =~ /ID: (\\w+)/\n gtw_msg_id = $1\n gtw_msg_id = gateway_reply[4..99] # Temporary workaround as $1 doesn't work on Heroku\n msg_status = MessagesHelper::MsgSentToGateway\n else\n gtw_msg_id = gateway_reply # Will include error message\n msg_status = MessagesHelper::MsgError\n end\n # Mark the message to this member as being sent\n self.sent_messages[0].update_attributes(:gateway_message_id => gtw_msg_id, \n :msg_status => msg_status)\n else\n # MULTIPLE PHONE NUMBERS\n # Get the Clickatell reply and parse into array of hash like {:id=>'asebi9xxke...', :phone => '2345552228372'}\n#puts \"**** gateway_reply=#{gateway_reply}\"\n msg_statuses = gateway_reply.split(\"\\n\").map do |s|\n if s =~ /ID:\\s+(\\w+)\\s+To:\\s+([0-9]+)/\n {:id => $1, :phone => $2} \n else\n {:id => nil, :phone => nil, :error => s}\n end\n end\n # Make array to associate members with their numbers\n @member_phones = self.members.map {|m| {:phone => m.primary_phone, :member => m} }\n # Update the sent_message records to indicate which have been accepted at Gateway \n msg_statuses.each do |s|\n#puts \"**** s[:id]=#{s[:id]}, s[:phone]=#{s[:phone]}\"\n if s[:id] && s[:phone]\n # Find the right member by matching phone numbers\n member = @member_phones.find{|m| m[:phone]==s[:phone]}[:member]\n # Find the right sent_message by matching member & message\n sent_message = SentMessage.where(:member_id=>member.id, :message_id=>self.id).first\n # Update the sent_message\n sent_message.update_attributes(\n :gateway_message_id => s[:id], \n :msg_status=> MessagesHelper::MsgSentToGateway\n )\n end\n end\n # Any sent_messages not now marked with gateway_message_id and msg_status must have errors\n sent_messages.each do |m| \n m.update_attributes(:msg_status=> MessagesHelper::MsgError) if m.msg_status.nil?\n end\n end\n end", "def deliver(params={})\n puts \"**** Message#deliver\" if params[:verbose]\n#puts \"**** Message#deliver response_time_limit=#{self.response_time_limit}\"\n save! if self.new_record?\n deliver_email() if send_email\n deliver_sms(:sms_gateway=>params[:sms_gateway] || default_sms_gateway) if send_sms\n end", "def deliver(should_clean = true)\n clean if should_clean\n self.push_data = self.push_data.gsub('[MESSAGE_ID]', self.id.to_s)\n temp_receipts = recipients.map { |r| build_receipt(r, 'inbox', false) }\n if temp_receipts.all?(&:valid?)\n temp_receipts.each(&:save!) #Save receipts\n Alerter::MessageDispatcher.new(self, recipients).call\n #self.recipients = nil\n end\n\n return temp_receipts if temp_receipts.size > 1\n temp_receipts.first\n end", "def process_outgoing\n @logger.debug(\"Processing outgoing.\")\n # Outgoing messages\n to_send = OSms.find(\n :all,\n :conditions => [\n \"status IS NULL \" +\n \" AND (delayed_at <> ? OR delayed_at IS NULL)\" +\n \" AND (send_at <= NOW() OR send_at IS NULL) \",\n Counter.instance.date\n ],\n :order => \"created_on,id ASC\"\n )\n\n to_send.each do |sms|\n begin\n Counter.instance.increment\n @phone.sms(sms.number, sms.message)\n rescue ATPhone::Number::Invalid, \\\n ATPhone::SMS::Message::TooLong => e\n @logger.error(\"#{sms.to_s} sending failed: #{e}.\")\n @logger.debug(sms.inspect)\n @logger.debug(e.inspect)\n\n sms.status = 'FAIL'\n sms.info = \"Error sending SMS: #{e}\"\n # We cannot send more messages today\n rescue DayCounter::NotAllowed\n @logger.info(\"SMS delayed, max \" +\n \"#{Counter.instance.max_per_day}/day: #{sms.to_s}.\")\n @logger.debug(sms.inspect)\n \n sms.delayed_at = Counter.instance.date\n sms.info = \"Delayed because \" +\n \"#{Counter.instance.max_per_day} messages per day \" +\n \"limit reached for #{Counter.instance.date}\"\n else\n @logger.info(\"SMS sent: #{sms.to_s}\")\n @logger.debug(sms.inspect)\n\n sms.sent = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n sms.status = 'SENT'\n ensure\n sms.save!\n end\n end\n end", "def deliver(numbers=@numbers, body=@body)\n # NB: message#deliver_sms currently sends numbers as a string, not an array.\n if numbers.is_a? String\n @numbers = numbers.gsub(\"+\",\"\").split(/,\\s*/) # Convert to array so we can do \"each\"\n else\n @numbers = numbers\n end\n @body = body # ...\n raise('No phone numbers given') unless @numbers\n raise('No message body') unless @body\n iron_worker_client ||= IronWorkerNG::Client.new\n @numbers.each do |number|\n#puts \"****Delivering to number=#{number}\"\n begin\n iron_worker_client.tasks.create(\"twilio_worker\",\n {:sid => @account_sid,\n :token => @auth_token,\n :from => @phone_number,\n :to => number.with_plus,\n :message => @body\n }\n )\n end \n end\n AppLog.create(:code => \"SMS.sent.#{@gateway_name}\", :description=>\"Queued #{@numbers.count} messages.\")\n @gateway_reply = nil\n super\n end", "def send_sms_message(text, to, from)\n deliver_message_via_carrier(text, to, from)\nend", "def deliver_messages\n ensure_threads_running!\n\n @queue << [:deliver_messages, nil]\n\n nil\n end", "def deliver(message, _options = {})\n raise ArgumentError, \"too many recipients, max. is #{MAX_RECIPIENT}\" if message.to.length > MAX_RECIPIENT\n\n # perform request\n @obh_client.send_sms(post_params(message))\n message.to\n end", "def deliver_message_via_carrier(text, to, from)\n SMS_CARRIER.deliver_message(text, to, from)\nend", "def index\n @sms_sends = SmsSend.all\n end", "def send_pending_messages\n self.mailbox.conversations.where(mailboxer_label_id: Mailboxer::Label::INFORMATION.id).each do |conversation|\n # Get the message that should have been sent\n message = conversation.messages.first\n # Select the admin who should receive the message\n recipient = message.recipients.detect{ |recipient| recipient.is_a? Admin }\n MailboxerMessageMailer.delay(queue: 'mailers').new_message_email_to_admin(message, recipient)\n end\n nil\n end", "def sms_action documents\n to = \"#{params[:to].gsub(/[^\\d]/, '')}@#{params[:carrier]}\"\n mail = RecordMailer.sms_record(documents, { to: to, config: blacklight_config }, url_options)\n if mail.respond_to? :deliver_now\n mail.deliver_now\n else\n mail.deliver\n end\n end", "def deliver(message, *mobiles, **opts)\n attrs = {\n msg: message,\n numbers: numbers(mobiles),\n url_callback: callback\n }.merge(opts)\n rest.get(:sendsms, attrs)['data']\n end", "def deliver\n User.all.each do |user|\n UserMailer.send_message(user,self).deliver\n end\n end", "def sms\n @sms ||= TermuxRubyApi::SubSystems::Sms.new(self)\n end", "def deliver\r\n mandrill = Mandrill::API.new(api_key)\r\n mandrill.messages.send(message, async, ip_pool, send_at)\r\n end", "def process_incoming\n @logger.debug(\"Processing incoming.\")\n # Incoming messages\n msgs = @phone.messages\n msgs.each do |msg|\n @logger.info(\"Incoming Sms: #{msg.to_s}.\")\n @logger.debug(msg.inspect)\n sms = ISms.new({\n :number => msg.number,\n :message => msg.message,\n })\n\n if sms.save\n @logger.info(\"Sms saved to SQL: #{sms.to_s}.\")\n @logger.debug(sms.inspect)\n \n msgs.delete(msg)\n @logger.info(\"Sms deleted from phone: #{msg.to_s}.\")\n @logger.debug(msg.inspect)\n end\n end\n end", "def receive_sms\n @view = \"sms\"\n @body = params[\"Body\"]\n @phone_number = params[\"From\"]\n set_user_create_message_parse_and_point\n end", "def call\n users_to_notify.uniq.each do |recipient|\n Hyrax::MessengerService.deliver(user, recipient, message.html_safe, subject)\n\n mailer = workflow_message_mailer(to: recipient)\n mailer.send(mailer_method).deliver_later if mailer.respond_to?(mailer_method)\n end\n end", "def send_by_sms\n\t\t# ActionMailer deliverya\n\t\trecipeintNumberRaw = params[:mobile_number].gsub!(/[^0-9]/,'')\n\t\trecipeintNumberFormatted = params[:mobile_number]\n\t\t@listing = Listing.find(params[:listing_id])\n\n\t\tsms_message = 'Click to view the listing on ' + @listing.address_1 + ' ' + @listing.address_2 + ' ' + @listing.city + ' ' + @listing.state + ' ' + listing_url(@listing)\n\n\t\tsms_fu = SMSFu::Client.configure(:delivery => :action_mailer)\n\t\tsms_fu.deliver(recipeintNumberRaw, params[:carrier][0] , sms_message, :from => '[email protected]')\n\t\treturn_response = { \"status\" => \"ok\", \"number\" => recipeintNumberFormatted }\n\t\trender :json => return_response.to_json, :callback => params[:callback]\n\n\tend", "def send_sms(number, subject, carrier, message)\n SMSMailer.sms_mailer(number, subject, carrier, message).deliver_now\n end", "def deliver_now\n processed_smser.handle_exceptions do\n message.deliver\n end\n end", "def deliver(message, options = {})\n raise ArgumentError, \"too many recipients, max. is #{MAX_RECIPIENT} (current: #{message.to.length})\" if message.to.length > MAX_RECIPIENT\n\n # Prepare request\n options = prepare_options options\n http = http_client options\n request = http_request post_params(message, options)\n\n # Log as `curl` request\n self.class.logger.debug \"curl -X#{request.method} '#{endpoint}' -d '#{request.body}'\"\n\n # Perform request\n resp = http.request(request)\n\n # Handle errors\n raise ServiceError, \"endpoint did respond with #{resp.code}\" unless resp.code.to_i == 200\n raise ServiceError, \"unable to deliver message to all recipients (CAUSE: #{resp.body.strip})\" unless resp.body.split(\"\\n\").all? { |l| l =~ /Result_code: 00/ }\n\n # extract Nth-SmsIds\n resp['X-Nth-SmsId'].split(',')\n end", "def deliver_now!\n processed_smser.handle_exceptions do\n message.deliver!\n end\n end", "def deliver\n #find all the abonnes emails\n @abonnes = Abonne.all.collect(&:email)\n # Sends the newsletter to each one\n @abonnes.each do |abonne|\n NewsletterMailer.deliver_newsletter(abonne, self)\n end\n # Set the delivered_at time to now\n self.update_attribute(:delivered_at, Time.now)\n end", "def flush!\n clear!.each do | message |\n @transport.send_message(message)\n end\n self\n end", "def received\n @messages = Message.sent_to current_user\n end", "def new; send_sms; end", "def process\n # abort if the SMS in question is from one of the incoming SMS numbers\n return if all_incoming_numbers.include?(incoming_msg.from)\n\n self.reply = handle_reply\n self.forward = handle_forward\n end", "def update_snack_queue\n\n order_ids = params[:undelivered_order_ids]\n cart_ids = params[:cart_ids]\n @subscription_id = params[:subscription_id]\n\n orders = []\n @all_carts_full = Cart.is_carts_full?(cart_ids)\n\n if @all_carts_full\n\n order_ids.each do |key, order_id|\n orders.push(order_id)\n order = Spree::Order.where(id: order_id).first\n cart = Cart.where(id: cart_ids[key.to_i]).first\n order_line_items = cart.get_line_items_for_order\n order.pack_line_items(order_line_items, current_user.id, \"USD\", request.remote_ip)\n order.update_total_and_item_total\n #cart.destroy\n end\n\n order = Spree::Order.where(id: order_ids[\"0\"]).first\n result = queue_update_mail_params(order)\n VeganMailer.snack_queue_update_mail(result).deliver\n\n else\n\n end #end of complete if condition.\n end", "def send_bulk_sms(message)\n client = IronWorkerNG::Client.new\n client.tasks.create('master_email', payload)\n payload = {}\n payload['message'] = message\n client.tasks.create('master_sms', payload)\nend", "def deliver\n return if sent?\n\n begin\n provider = \"#{service.capitalize}Service\".constantize\n provider.new.send(receiver, message)\n\n update_attributes(sent: true)\n rescue NameError\n false\n end\n end", "def deliver\n china_mobile? ? send_via_smsbao_gateway : send_via_nexmo_gateway\n end", "def deliver(numbers=@numbers, body=@body, message_id=nil, log=nil)\n # NB: message#deliver_sms currently sends numbers as a string, not an array.\n#puts \"**** Delivering Twilio with @background=#{@background}, numbers=#{numbers}\"\n if numbers.is_a? String\n @numbers = numbers.gsub(\"+\",\"\").split(/,\\s*/) # Convert to array so we can do \"each\"\n else\n @numbers = numbers\n end\n @body = body # ...\n raise('No phone numbers given') unless @numbers\n raise('No message body') unless @body\n # Use delivery system based on the parameter @background [i.e. background processing type]\n case @background\n when /iron/i\n @numbers.count > 1 ? deliver_ironworker : deliver_direct(message_id)\n when /dj|delay.*job/i\n @numbers.count > 1 ? deliver_delayed_job(message_id) : deliver_direct(message_id)\n else\n deliver_direct(message_id)\n end\n AppLog.create(:code => \"SMS.deliver.#{@gateway_name}\", :description=>\"background=#{@background || 'none'}, count = #{@numbers.count} messages\")\n super\n end", "def redelivered; @message_impl.getRedelivered; end", "def sent\n @messages = Message.sent_by current_user\n end", "def send_now(mnobj = nil, recipient_sms_numbers: nil, generated_text: nil, importance: nil, logger: nil)\n logger ||= Rails.logger\n\n importance ||= self.class.importance\n\n resp = []\n if recipient_sms_numbers\n logger.info 'Sending sms to a defined set of recipients'\n elsif mnobj\n logger.info \"Sending sms for #{mnobj.id}\"\n else\n raise FphsException, 'No message notification or recipient list set for SMS send'\n end\n\n recipient_sms_numbers ||= mnobj.recipient_sms_numbers\n generated_text ||= mnobj.generated_text\n\n raise FphsException, 'No recipients to SMS' unless recipient_sms_numbers&.present?\n\n recipient_sms_numbers.each do |sms_number|\n val = PhoneValidation.validate_sms_number_format sms_number, no_exception: true\n\n if val\n res = send_sms sms_number, generated_text, importance\n resp << { aws_sns_sms_message_id: res.message_id } if res\n else\n resp << { error: BadFormatMsg }\n end\n end\n\n resp.to_json\n end", "def sms\n reply = TwilioService.new.process_inbound_sms(params)\n render_twiml_message(reply) if reply\n end", "def notify_recipients\n self.send_at(scheduled_at, :queued_message_sending)\n end", "def notify_recipients\n self.send_at(scheduled_at, :queued_message_sending)\n end", "def process_msgs\n end", "def populate_topic(lst)\n # puts \"list is #{lst}\"\n arg_hash = {:host => 'localhost'}\n # self.sms_sender=SmscManager::SmsSendTopic.new(arg_hash) \n lst.each {|key, val| \n # txt=line[1] ||\n # if value set then send it else send default text value \n txt2 = val==nil ? self.text : val\n dst = key\n # puts \"text is #{txt2} dest is #{dst}\"\n send_it(txt2,dst) if SmscManager::Sms.check_destination(dst)\n \n # puts \" dst is #{dst}\" \n }\n \n sleep(2) # should we wait till we get receipts for all?\n puts \"populate topic sent #{self.sent}\"\n sleep(self.attempts*0.5+1) if self.sent!=self.attempts\n puts \"populate topic sent after sleep #{self.sent}\"\n #self.sms_sender.disconnect_stomp\n end", "def send_sms_in_groups(recipient_numbers, body)\n sent_messages = []\n recipient_numbers.in_groups_of(purchased_numbers.length) do |group|\n group.compact.each_index do |i|\n begin\n sent_messages << send_message(\n to: group[i],\n from: purchased_numbers[i],\n body: body)\n rescue Twilio::REST::RequestError => e\n Airbrake.notify(e)\n # Nullify phone number if it is invalid\n User.delay.nullify_phone_number!(group[i]) if e.code == 21211\n end\n end\n # TODO: remove the delay once 'short phone number' is purchased\n # Twilio 'long phone numbers' have a limitation of\n # one sms per second per phone\n sleep 2\n end\n sent_messages\n end", "def put_messages()\n #\n for i in 1..@max_msgs do\n message = \"Go Sox #{i}!\"\n @@log.debug \"#{message}\"\n @client.publish(@queue_name, message, \n {\"persistent\" => true, \"client-id\" => @client_id, \n \"reply-to\" => @queue_name} )\n end\n @client.close\n @@log.debug(\"queue_put completes\")\n end", "def sms(body, to: nil, from: nil, method: nil, action: nil, status_callback: nil, **keyword_args)\n append(Sms.new(\n body,\n to: to,\n from: from,\n method: method,\n action: action,\n status_callback: status_callback,\n **keyword_args\n ))\n end", "def queue_contacts\n @contacts.where(contact_type: 'PBX', direction: 'I', forwarded_to_agent: nil, call_ended: nil).where.not(service_id: 120)\n end", "def populate_topic(lst)\n # puts \"list is #{lst}\"\n self.arg_hash = {:host => 'localhost'}\n #self.mms_sender=MmscManager::MmsSendTopic.new(arg_hash) \n lst.each {|key| \n \n dst = key\n send_it(dst) #if SmscManager::Sms.check_destination(dst)\n \n }\n \n sleep(2) # should we wait till we get receipts for all?\n puts \"populate topic sent #{self.sent}\"\n sleep(self.attempts*0.5+1) if self.sent!=self.attempts\n puts \"populate topic sent after sleep #{self.sent}\"\n # self.mms_sender.disconnect_stomp\n end", "def sms(options = {})\r\n return @_message if @_sms_was_called && options.blank?\r\n\r\n m = @_message\r\n\r\n # Call all the procs (if any)\r\n default_values = {}\r\n self.class.default.each do |k,v|\r\n default_values[k] = v.is_a?(Proc) ? instance_eval(&v) : v\r\n end\r\n\r\n # Handle defaults\r\n options = options.reverse_merge(default_values)\r\n\r\n # Set configure delivery behavior\r\n wrap_delivery_behavior!(options.delete(:delivery_method), options.delete(:delivery_method_options))\r\n\r\n # Assign all options except body, template_name, and template_path\r\n assignable = options.except(:body, :template_name, :template_path)\r\n assignable.each { |k, v| m[k] = v }\r\n\r\n # Render the templates and blocks\r\n m.body = response(options)\r\n @_sms_was_called = true\r\n\r\n m\r\n end", "def twilio_broadcast!(client,tos,msg)\n # spam it to others\n tos.each do |name,info|\n twilio_send_text_message!(client,info[:phone],msg)\n end\n end", "def send_sms\n status = self.status\n if status.upcase == 'INTERVENTION'\n self.message\n end\n end", "def index\n @sms_sends = SmsSend.order(\"created_at DESC\").page(params[:page]).per(10)\n end", "def deliver_to_queue\n @deliver_to_queue\n end", "def send_to_multiple(receiver_ids, pars)\n @receivers = receiver_ids.reject(&:blank?).map { |id| User.find(id) }\n @messages = @receivers.map do |user|\n Message.create sender: current_user,\n receiver: user,\n content: pars[:content]\n end\n flash[:info] = \"Your message has been sent\"\n end", "def deliver(message, options = {})\n options = options.reverse_merge default_options\n to = recipient.respond_to?(:call) ? recipient.call(message) : recipient\n message.body message.body.encode(options[:charset]) if options[:charset].presence\n ActionMailerSMSMailer.forward_sms(to, message, options.compact).deliver_now\n message.to\n end", "def index\n @sms_retrievals = SmsRetrieval.all\n end", "def call\n users_to_notify.uniq.each do |recipient|\n workflow_message_mailer(to: recipient).send(mailer_method).deliver_later\n end\n end", "def send_text(sms, phones)\n phones.each do |phone|\n post_response = Faraday.post do |request|\n request.url \"https://api.twilio.com/2010-04-01/Accounts/#{ACCOUNT_SID}/SMS/Messages.json\"\n request.headers['Authorization'] = \"Basic \" + Base64.strict_encode64(\"#{ACCOUNT_SID}:#{AUTH_TOKEN}\")\n request.body = URI.encode_www_form({'From' => PHONE_NUMBER, 'To' => phone.phone_number, 'Body' => sms.message})\n end\n end\n end", "def send_sms!(msg)\n return false unless sms_alerts and phone_number_is_valid? and not mobile_carrier.blank?\n PersonMailer.send_sms(self, msg).deliver\n end", "def sms\n # Give Twilio the TwiML payload instructions\n twiml_payload\n end", "def sms\n @response, @documents = get_solr_response_for_field_values(SolrDocument.unique_key,params[:id])\n if request.post?\n url_gen_params = {:host => request.host_with_port, :protocol => request.protocol}\n tinyPass = request.protocol + request.host_with_port + catalog_path(params['id'])\n tiny = tiny_url(tinyPass)\n if params[:to]\n phone_num = params[:to].gsub(/[^\\d]/, '')\n unless params[:carrier].blank?\n if phone_num.length != 10\n flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', :to => params[:to])\n else\n email = RecordMailer.sms_record(@documents, {:to => phone_num, :carrier => params[:carrier], :callnumber => params[:callnumber], :location => params[:location], :tiny => tiny}, url_gen_params)\n end\n\n else\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')\n end\n else\n flash[:error] = I18n.t('blacklight.sms.errors.to.blank')\n end\n\n unless flash[:error]\n email.deliver\n flash[:success] = \"Text sent\"\n redirect_to catalog_path(params['id']) unless request.xhr?\n end\n end\n unless !request.xhr? && flash[:success]\n respond_to do |format|\n format.js { render :layout => false }\n format.html\n end\n end\n end", "def new_sms_updates(content, tonumber)\n\[email protected] do |message|\n\tRails.logger.debug(message.body)\n\tend\n end", "def tick \n mailer.messages.each do |request| \n response = mailer.new_message(:to => request.from, \n :from => settings.service.default_sender)\n\n process_request(request, response) && response.deliver\n end\n rescue StandardError => e\n logger.fatal(\"SERVER ERROR\") { \"#{e.inspect}\\n\" + e.backtrace.join(\"\\n \") }\n raise\n end", "def deliver_email\n#puts \"**** deliver_email: emails=#{emails}\"\n emails = @contact_info.map {|c| c[:email]}.compact.uniq\n self.subject ||= 'Message from SIM Nigeria'\n id_for_reply = self.following_up || id # a follow-up message uses id of the original msg\n#puts \"**** Messages#deliver_email response_time_limit=#{response_time_limit}\"\n outgoing = Notifier.send_group_message(:recipients=>emails, :content=>self.body, \n :subject => subject, :id => id_for_reply , :response_time_limit => response_time_limit, \n :bcc => true, :following_up => following_up) # send using bcc:, not to:\nraise \"send_email with nil email produced\" if outgoing.nil?\n outgoing.deliver\n # Mark all as being sent, but only if they have an email address\n # This is terribly inefficient ... need to find a way to use a single SQL statement\n sent_messages.each do |sm| \n sm.update_attributes(:msg_status => MsgSentToGateway) if sm.member.primary_email\n end\n end", "def send_sms(params)\n self.current_params = params\n response = send_request(params)\n smart_response(response.parsed_response)\n end", "def im(*messages)\n @@jabbers[@from].deliver @rcpt_to || @headers['To'], messages.join\n end", "def resend_sms_token\n unless_sms_confirmed { send_sms_token }\n end", "def perform_deliveries\n @asq.deliveries.each(&:deliver)\n end", "def send_followup(params={})\n @contact_info = sent_messages.map do |sm| # including only sent_messages w/o response\n m = sm.member # member to whom this message was sent\n if m.msg_status < MessagesHelper::MsgDelivered\n {:member => m, :phone => m.primary_phone, :email => m.primary_email} \n else\n nil\n end\n end\n deliver_email if send_email\n deliver_sms(:sms_gateway=>params[:sms_gateway]) if send_sms\n end", "def get_messages\n @connection.search(@filter).each do |message|\n body = @connection.fetch(message, \"RFC822\")[0].attr[\"RFC822\"]\n begin\n @processor.process(body)\n rescue StandardError => error\n Mailman.logger.error \"Error encountered processing message: #{message.inspect}\\n #{error.class.to_s}: #{error.message}\\n #{error.backtrace.join(\"\\n\")}\"\n next\n end\n @connection.store(message, \"+FLAGS\", @done_flags)\n end\n # Clears messages that have the Deleted flag set\n @connection.expunge\n end", "def fallback_to_twilio\n sms.output = :twilio\n sms.deliver\n end", "def reply_to_all(delivery, reply_body, subject = nil)\n msg = delivery.message\n recipients = msg.recipients.clone()\n if(msg.sender != self)\n recipients.delete(self)\n if(!recipients.include?(msg.sender))\n recipients << msg.sender\n end\n end\n return reply(delivery.conversation, recipients, reply_body, subject)\n end", "def send_to_all\n User.newsletters_allowed.each do |user|\n UserMailer.delay.new_newsletter(user, self)\n end\n end", "def sms\n \t\n \t#flash[:notice] = params\n \t#redirect_to root_path\n\n TwilioTextMessenger.new( params[:phone], params[:message]).call\n \t\n end", "def deliver(options={})\n options||={}\n deliver_method = options.delete(:bang) ? :deliver! : :deliver\n\n error_messages = outbounds.inject([]) do |error_messages, o|\n next(error_messages) if o.delivered?\n unless o.send(deliver_method, options)\n error_messages << \"Message could not be delivered to: #{o.phone_number.human_display}\"\n end\n error_messages\n end\n \n self.update_attribute(:status, error_messages.blank? ? 'PROCESSED' : 'FAILED')\n error_messages.each { |msg| errors.add_to_base(msg) }\n error_messages.blank?\n end", "def deliver_message\n return unless @recipients\n append_delivery_notes\n @recipients.reject{|r| r==self.user}.each do |usr|\n usr.user_notifications.create(self.attributes)\n usr.save\n end\n self.save!\n self.user.save!\n end", "def messages\n @logger.log(\"Getting messages from phone.\")\n \n # Get a list of messages\n msg = nil\n msgs = ATPhone::SMS.new(self)\n\n # Turn on text mode\n send(\"AT+CMGF=1\")\n \n resp = send(\"AT+CMGL\")\n resp.each_line do |line|\n # If it is a message header\n if line[0..5] == '+CMGL:'\n # Add formed message to list\n msgs[msg.index] = msg unless msg.nil?\n \n # Create new message from phone data\n index, status, number = line[7..-1].split(',')\n msg = ATPhone::SMS::Message.new(\n \"\",\n number.strip.gsub('\"', ''),\n index.to_i,\n status.strip.gsub('\"', '')\n )\n # If it's not a command, then it's text\n elsif not msg.nil?\n msg.message += line\n end\n end\n\n # Add last message\n msgs[msg.index] = msg unless msg.nil?\n\n msgs\n end", "def markmsgdelivered(msgid)\n req(\"markmsgdelivered\", \"\", \"\", msgid, \"\")\n end", "def send_sms(sms, options={})\n send_to_phone(sms.phone_number, sms.actual_message, options)\n end", "def deliver(message, _options = {})\n raise ArgumentError, \"too many recipients, max. is #{MAX_RECIPIENT}\" if message.to.length > MAX_RECIPIENT\n\n from = message.from.present? ? message.from.to_s : from_number.to_s\n\n raise ArgumentError, 'no from number given on new message or the transport given' if from.empty?\n\n client = Twilio::REST::Client.new(account_sid, auth_token)\n messages = prepare_numbers(message.to).map do |n|\n client.messages.create(\n from: from,\n to: n,\n body: message.body\n )\n end\n numbers = messages.map do |result|\n result.try(:to)\n end\n NumberList.new.push numbers.compact\n end", "def send(p)\n options = {} \n\n p.each do |k,v|\n\n case k\n when :reply_path\n # Automatically request delivery receipt if reply path is set\n options[sym_to_param(:confirm_delivery)] = 'on'\n options[sym_to_param(k)] = v\n when :scheduled_for\n # Set timestamp correctly for :scheduled_for\n options[sym_to_param(k)] = v.strftime('%Y%m%d%H%M%S')\n else\n options[sym_to_param(k)] = v\n end\n\n end\n\n res = self.class.post('/submit_sm', :basic_auth => @auth, :body => JSON.dump(options))\n\n responses = []\n res['sms'].each do |r|\n responses << Dialogue::Toolkit::Sms::Response.new(r)\n end\n\n responses\n end", "def send_notifications\n\t\tphones_sent_to = []\n\t\temails_sent_to = []\n\t\tgather_recipients.each do |recipient|\n\t\t\trecipient.phone_numbers.each do |phone_number|\n\t\t\t\tnext if phones_sent_to.include? phone_number\n\t\t\t\tphones_sent_to << phone_number\n\t\t\t\tresponse = Auth::TwoFactorOtp.send_transactional_sms_new({\n\t\t\t\t\t:to_number => phone_number,\n\t\t\t\t\t:template_name => REPORT_UPDATED_TEMPLATE_NAME,\n\t\t\t\t\t:var_hash => {:VAR1 => self.patient.first_name, :VAR2 => self.patient.last_name, :VAR3 => self.pdf_url, :VAR4 => self.created_by_user.organization.name },\n\t\t\t\t\t:template_sender_id => REPORT_UPDATED_SENDER_ID\n\t\t\t\t})\n\t\t\tend\n\t\t\tunless recipient.email_ids.blank?\n\t\t\t\temail = OrderMailer.report(recipient,self,self.created_by_user,(recipient.email_ids - emails_sent_to))\n\t \temail.deliver_now\n\t \temails_sent_to << recipient.email_ids\n\t \temails_sent_to.flatten!\n \tend\n \tend\n\tend", "def sms_side_effects\n old_observers = SmsCarrier::Sms.class_variable_get(:@@delivery_notification_observers)\n old_delivery_interceptors = SmsCarrier::Sms.class_variable_get(:@@delivery_interceptors)\n yield\n ensure\n SmsCarrier::Sms.class_variable_set(:@@delivery_notification_observers, old_observers)\n SmsCarrier::Sms.class_variable_set(:@@delivery_interceptors, old_delivery_interceptors)\n end", "def create_sent_messages \n target_members = self.members +\n (Group.members_in_multiple_groups(to_groups_array) & # an array of users\n Member.those_in_country)\n @contact_info = target_members.map {|m| {:member => m, :phone => m.primary_phone, :email => m.primary_email}}\n # Remove members from @contact_info if they do not have the needed contact info (phone or email)\n # We may want to keep track of those people since they _should_ get the message but we don't have\n # the necessary info to get it to them by the specified routes (phone or email).\n case\n when self.send_sms && !self.send_email\n @contact_info.delete_if {|c| c[:phone].nil?}\n when !self.send_sms && self.send_email\n @contact_info.delete_if {|c| c[:email].nil?}\n when self.send_sms && self.send_email\n @contact_info.delete_if {|c| c[:email].nil? && c[:phone].nil?}\n end\n self.members = @contact_info.map {|c| c[:member]}\n end", "def listen_for_messages\n @queue.subscribe do |_delivery_info, _metad5ata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end", "def send_family_summaries\n @title = 'Send summaries'\n date_selection_filter = [\"summary_sent IS ? OR (? - summary_sent) > ?\", nil,\n Date.today, Settings.family.info_summary_interval]\n recipients = Family.those_active.where(date_selection_filter)\n @messages = []\n recipients.each do |family|\n if family.email\n @messages << Notifier.send_family_summary(family) \n family.update_attribute(:summary_sent, Date.today)\n#puts \"**Summary_sent set to #{family.reload.summary_sent}\"\n end\n end\n @messages.each {|m| m.deliver}\n flash[:notice] = \"Sent #{@messages.count} family summary messages\"\n redirect_to families_path\n end", "def deliver(reply = false, should_clean = true)\n self.clean if should_clean\n\n #Receiver receipts\n temp_receipts = recipients.map { |r| build_receipt(r, 'inbox') }\n\n #Sender receipt\n sender_receipt = build_receipt(sender, 'sentbox', true)\n\n temp_receipts << sender_receipt\n\n if temp_receipts.all?(&:valid?)\n temp_receipts.each(&:save!)\n Mailboxer::MailDispatcher.new(self, recipients).call\n\n conversation.touch if reply\n\n self.recipients = nil\n\n on_deliver_callback.call(self) if on_deliver_callback\n end\n sender_receipt\n end", "def set_sms_send\n @sms_send = SmsSend.find(params[:id])\n end", "def set_sms_send\n @sms_send = SmsSend.find(params[:id])\n end", "def send_user_status_sms\n user = User.find_by(:id => self.user_id)\n user.send_status_sms\n end", "def receive_sms\n uninitialize_sms\n body = params[:Body]\n phone_number = normalize_phone params[:From].strip\n @problem_text = body.split\n action = sms_parsing(body).downcase\n if action == \"join\"\n sms_create_account\n return\n elsif Account.find_by_phone_number(phone_number) == nil\n sms_send(params[:From], \"Please first create an account by texting the word 'join'.\")\n return\n end\n if !@sms_error\n case action\n when /^add$/,/^insert$/\n sms_create\n when /^accept$/\n sms_accept_problem\n when /^get$/\n @offset = false\n sms_get(0)\n when /^edit$/\n sms_edit\n when /^delete$/, /^destroy$/\n sms_delete\n when /^next$/\n offset = session[\"offset\"]\n if offset == nil\n sms_error(\"Sorry, there is no saved session right now. Please first text \\\"GET\\\" with @location !skill %number of texts you want to allow.\")\n else\n @offset = true\n sms_get(offset)\n end\n when /^detail$/, /^details$/, /^describe$/\n sms_detail\n when /^account$/\n forgot_acc\n when /^change$/\n sms_change_password\n when /^password$/\n forgot_password\n# when /^skill$/, /^skills$/\n# sms_skill\n when /^keywords$/, /^key$/, /^keys$/, /^help$/\n sms_keywords\n when /^explain$/\n sms_explain\n else\n if is_num?(action)\n session[:received_confirmation] = action\n sms_confirm_acc\n else\n sms_wrong_keyword\n end\n end\n end\n render :nothing => true\n end", "def tick \n mailer.messages.each do |request| \n response = mailer.new_message(:to => request.from, \n :from => settings.service.default_sender)\n \n begin\n apps.each do |app|\n app.call(:request => request, \n :response => response, \n :settings => settings,\n :logger => logger)\n end\n rescue StandardError => e\n logger.info(\"FAIL\") { e.to_s }\n logger.debug(\"FAIL\") { \"#{e.inspect}\\n\"+e.backtrace.join(\"\\n \") }\n\n if settings.service.raise_exceptions\n raise\n else\n next\n end\n end\n\n response.deliver\n end\n rescue Exception => e\n logger.fatal(\"Caught exception: #{e}\\n\\n#{e.backtrace.join(\"\\n\")}\")\n raise\n end" ]
[ "0.72850764", "0.69843453", "0.6950221", "0.6770076", "0.6458194", "0.6195543", "0.61663157", "0.6090142", "0.60884774", "0.60609865", "0.6017061", "0.5958864", "0.5947048", "0.5935357", "0.59302646", "0.59207046", "0.58750004", "0.5869881", "0.58133775", "0.57955253", "0.576257", "0.57406384", "0.57168084", "0.5682922", "0.5668205", "0.5666126", "0.56506777", "0.56182563", "0.5611369", "0.56016684", "0.5596979", "0.5572147", "0.55675393", "0.5523512", "0.55218184", "0.5518827", "0.5498558", "0.5493253", "0.54634494", "0.5447717", "0.54268557", "0.54062676", "0.5374479", "0.53714615", "0.5364756", "0.53641933", "0.53576064", "0.53551096", "0.53551096", "0.53394186", "0.53350896", "0.53348273", "0.5331285", "0.5327601", "0.5325086", "0.52907676", "0.5274217", "0.52659607", "0.5249544", "0.52351457", "0.52295977", "0.5225418", "0.52248496", "0.5220335", "0.52148867", "0.5189574", "0.5182248", "0.5179387", "0.5169891", "0.51673347", "0.5161686", "0.51559395", "0.51506907", "0.5149519", "0.5148934", "0.5147351", "0.5140178", "0.5138754", "0.5134799", "0.51295745", "0.51278025", "0.5123453", "0.51197785", "0.5119566", "0.5119523", "0.51185644", "0.51119673", "0.51060486", "0.5096807", "0.5077693", "0.5071104", "0.5069628", "0.5065786", "0.5063472", "0.50632554", "0.5062904", "0.5062904", "0.50582105", "0.5055565", "0.50484055" ]
0.7601357
0
Sends a message to a phone number directly to the provider. No validations are performed +phone_number+ the exact string text to send +message+ the string message to send +options+ additional options to be used by the provider
def send_message(phone_number, message, options={}) raise SmsOnRails::SmsError.new("Override send_message in subclass #{self.class}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_to_phone(phone_obj, message, options={})\n\n if options[:skip_validation]\n phone_text = phone_obj.is_a?(ActiveRecord::Base) ? format_phone_number(phone_number) : phone_obj\n return send_message(phone_text, message, options)\n end\n\n phone_number = phone_obj.is_a?(ActiveRecord::Base) ? phone_obj :\n find_or_create_phone_number(phone_obj, options)\n\n assert_message_options!(phone_number, message, options)\n send_message(format_phone_number(phone_number), message, options)\n end", "def send_text(number, message)\n @client.api.account.messages.create(\n to: number,\n from: 'add phone number',\n body: message\n )\n end", "def send_sms(to_phone_number, message)\n # message = {to:, from:, body: \"Hello\\n\\nWorld\"}\n # binding.pry\n @@client.messages.create(\n from: @@from,\n to: to_phone_number,\n body: message\n )\n end", "def twilio_send_text_message!(client,phone_num,msg)\n begin\n sms = client.account.sms.messages.create(\n :from => TWILIO_PHONE,\n :to => phone_num,\n :body => msg)\n rescue Exception => e\n puts \"Problems with twilio:\\n#{e}\"\n end\n end", "def create_basic_message(phone_number, message, options={})\n #validate phone number\n { :PhoneNumberToDial => phone_number,\n :TextToSay => message,\n :LicenseKey => @license_key,\n :CallerID => options[:caller_id_number] || '1-866-665-4386',\n :CallerIDname => options[:caller_id_name] || 'CDYNE Notify',\n :VoiceID => options[:voice_id] || 2 }\n end", "def send_message(phone_number, message)\n command = Command.new('SendSMSBasic', license_key)\n MessageStatus.new(\n Response.parse(\n command.execute({:PhoneNumber => phone_number, :Message => message})\n )[\"SmsReturn\"]\n )\n end", "def send_sms phone, message\n message = URI.escape message\n response = RestClient.get \"#{sender_base_url}/?from=#{@from}&to=#{phone}&text=#{message}&pass=#{@application_pass}\"\n @response = Response.new response\n end", "def send_sms(sms, options={})\n send_to_phone(sms.phone_number, sms.actual_message, options)\n end", "def send_free_message(kind, phone_number = params[:phone_number])\n raise \"Phone_number is not given\" if phone_number.blank?\n \n messaging = Messaging.new\n messaging.send(\"send_free_#{kind}\", normalize_phone(phone_number), @iphone)\n \n render :text => \"\"\n end", "def send phone_number\n account = CLIENT.account \n message = account.sms.messages.create({from: TAKEAWAY_NUMBER , to: phone_number, body: \"Thanks for your order! It shall arrive no later than #{@delivery_time.strftime(\"%H\")}:#{@delivery_time.strftime(\"%M\")}.\"})\n message.body\n end", "def perform(message, to_number)\n logger.info \"Sending message to #{to_number}\"\n TwilioService.new({\n to: to_number,\n msg: message\n }).send_sms\n end", "def send_sms number, message, opts={}\r\n wait =!(opts[:nowait] || false)\r\n encode = opts[:encode] || :ascii\r\n sender = opts[:sender] || false\r\n datetime = opts[:date] || false\r\n\r\n case encode\r\n when :binary || :base64\r\n encode = 'B'\r\n when :unicode\r\n encode = 'U'\r\n else # :ascii\r\n encode = ''\r\n end\r\n\r\n if sender\r\n sender = \"#{sender} \"\r\n custom = 'F'\r\n else\r\n custom = ''\r\n end\r\n\r\n if datetime\r\n datetime = \"#{datetime} \"\r\n date = 'D'\r\n else\r\n date = ''\r\n end\r\n\r\n cmd_raw \"#{date}#{custom}#{encode}SUBMIT\", \"#{datetime}#{sender}#{number} #{message}\"\r\n\r\n if wait\r\n wait_for last_label\r\n return false if @response_cmd.eql? 'NOOK'\r\n return \"#{@response_args[0]}.#{@response_args[1]}\".to_f\r\n end\r\n end", "def huzzah\n # ===========================================================================\n # 6. Send an SMS Message to 415-555-1212\n # uses a HTTP POST, and a new variable t for the information (because it needs \"Body\")\n \n account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)\n \n t = {\n 'From' => CALLER_ID,\n 'To' => phone,\n 'Body' => message\n }\n resp = account.request(\"/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages\",\n \"POST\", t)\n end", "def send(user, number, message, phone=nil)\n phone = Behaviour.select_phone(number, user['behaviour']) if phone.nil?\n if phone #se fizer match com os existentes\n `gammu-smsd-inject -c ~/.sms/gammu-smsdrc-#{phone} TEXT #{number} -text \"#{message}\"` # send to daemon\n #LOGIT que foi para a fila\n else \n #LOGIT que alguem tentou mas nao foi para a fila\n end\n end", "def send_message\n unless message_sent\n twilio_client.messages.create(\n from: ENV.fetch(\"TWILIO_PHONE_NUMBER\"),\n to: contact.phone_number,\n body: content,\n )\n update(message_sent: true)\n end\n end", "def notify(custom_message, phone_number)\n account_sid = ENV['TWILIO_ACCOUNT_SID']\n auth_token = ENV['TWILIO_AUTH_TOKEN']\n client = Twilio::REST::Client.new(account_sid, auth_token)\n message = client.messages.create from: ENV['TWILIO_PHONE_NUMBER'], to: '+1' + phone_number, body: custom_message\n end", "def send_message(to:, body:)\n twilio_client.api.account.messages.create(\n from: ENV['TWILIO_PHONE_NUMBER'],\n to: \"+1#{to}\",\n body: body\n )\n end", "def send\n if @to.nil? || @from.nil? || @message.nil?\n raise ArgumentError, \"You need to include 'to' and 'from' numbers and a message to send an SMS\"\n end\n to = @to.gsub(\" \",\"\")\n from = @from.gsub(\" \",\"\")\n parameters = {\n \"sms-send-to\" => to,\n \"sms-send-from\" => from,\n \"sms-message\" => @message[0..159]\n }\n request = @browser.post(\"#{VoipfoneClient::API_POST_URL}?smsSend\", parameters)\n response = parse_response(request)\n if response == \"ok\"\n return true\n else\n raise VoipfoneAPIError, response\n end\n end", "def send_sms(message)\n api_response = \"\"\n if !self.mobile.blank?\n txtlocal = Txtlocal.find_by_sms_type(Txtlocal::GROUP_CHAT)\n if !txtlocal.nil?\n txtlocal.message_contents = message\n api_response = txtlocal.send_sms(self.mobile)\n end\n else\n api_response = \"You have not provided any mobile number. Please go to your 'Account' to set up a mobile number\"\n end\n return api_response\n end", "def send_text(text, phone)\n account_sid = ENV[\"ACCOUNT_SID\"]\n auth_token = ENV[\"AUTH_TOKEN\"]\n client = Twilio::REST::Client.new account_sid, auth_token\n\n account = client.account\n message = account.sms.messages.create({\n :from => ENV[\"PHONE\"],\n :to => phone,\n :body => text})\n puts message\n end", "def sms(number, message, sec=SMS_SEND_TIMEOUT)\n @logger.log(\"Sending message.\")\n\n msg = ATPhone::SMS::Message.new(message, number)\n \n # Turn on text mode\n send(\"AT+CMGF=1\")\n # Specify number\n raw_send(\"AT+CMGS=\\\"#{msg.number}\\\"\\r\")\n # send message\n raw_send(msg.text + EOM, sec)\n end", "def reply_to_sender(phone_number, msg)\n msg = msg[0..MAX_MSG_PAYLOAD-1]\n org = get_system_org\n org.send_direct(org.system_user, phone_number, msg)\n end", "def send_sms_message(text, to, from)\n deliver_message_via_carrier(text, to, from)\nend", "def send_text\n Rails.logger.info \"Sending \\\"#{text}\\\" to #{number}...\"\n Twilio::Sms.message(TWILIO_CONFIG['caller_id'], number, text)\n end", "def send_text_message(text_message)\n number_to_send_to = text_message.receiver\n message = text_message.content\n twilio_sid = \"AC50070372767bdf26a090b08007bba07f\"\n twilio_token = \"8ae1cdbb08d55b99cab34174c3cd8bbb\"\n twilio_phone_number = \"2245209581\"\n @twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token\n @twilio_client.account.sms.messages.create(\n :from => \"+1#{twilio_phone_number}\",\n :to => number_to_send_to,\n :body => message\n )\n \n end", "def send_sms(fromNumber)\n begin\n bodyParams = {\n from: { phoneNumber: fromNumber },\n to: [{ phoneNumber: RECIPIENT }],\n # To send group messaging, add more (max 10 recipients) 'phoneNumber' object. E.g.\n #\n #to: [\n # { phoneNumber: RECIPIENT },\n # { phoneNumber: 'Recipient-Phone-Number' }\n # ],\n text: 'Hello World!'\n }\n endpoint = \"/restapi/v1.0/account/~/extension/~/sms\"\n resp = $platform.post(endpoint, payload: bodyParams)\n puts (\"SMS sent. Message id: \" + resp.body['id'].to_s)\n check_message_status(resp.body['id'])\n rescue StandardError => e\n puts (e)\n end\nend", "def send_sms_verification_code\n number_to_send_to = phone_number\n verification_code = phone_verification_code\n sms_message_body = I18n.t(\"devise.phone.message_body\", :verification_code => verification_code)\n\n sms = Sms.new\n sms.phone_number = number_to_send_to\n sms.message = sms_message_body\n return false unless sms.send!\n\n true\n end", "def phone_call(message)\n Ruboty::Call::Actions::Call.new(message).call\n end", "def twilio\n @number = params[:phone_number]\n \n #Text message info\n t = {\n \n 'From' => CALLER_ID,\n 'To' => @number,\n 'Body' => (\"Visit uhpartments.com when you walk through an apartment\")\n }\n\n begin\n account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)\n resp = account.request(\"/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages\",\n 'POST',\n t)\n resp.error! unless resp.kind_of? Net::HTTPSuccess\n rescue StandardError => bang\n #This area will be called if an error happens with the Twilio API\n flash[:alert] = \"Bad number.\"\n redirect_to({ :action => :home })\n \n return\n end\n\n redirect_to({ :action => :home, :alert => \"SMS sent.\" })\n end", "def send_text_message(body)\n if self.mobile.present?\n begin\n TWILIO_CLIENT.messages.create(from: ENV['TWILIO_PHONE_NUMBER'], to: self.mobile, body: body)\n rescue Twilio::REST::RequestError => e\n puts \"Twilio Error: #{e.message}\"\n end\n end\n end", "def send_to_phone\n if params[:level_source] && params[:phone] && (level_source = LevelSource.find(params[:level_source]))\n send_sms(level_source, params[:phone])\n render status: :ok, nothing: true\n else\n render status: :not_acceptable, nothing: true\n end\n end", "def reply_to_sender(phone_number, msg)\n Rails.logger.debug('TropoController::reply_to_sender')\n #get_system_org.create_gateway!.send_raw(phone_number, msg)\n @tropo.say(msg)\n end", "def send_sms(number, subject, carrier, message)\n SMSMailer.sms_mailer(number, subject, carrier, message).deliver_now\n end", "def send_message\n response = RestClient::Request.new(\n :method => :post,\n :url => \"https://api.twilio.com/2010-04-01/Accounts/#{ENV['TWILIO_ACCOUNT_SID']}/Messages.json\",\n :user => ENV['TWILIO_ACCOUNT_SID'],\n :password => ENV['TWILIO_AUTH_TOKEN'],\n :payload => { :Body => body,\n :To => Contact.find(self.contact_id).number,\n :From => ENV['USER_NUMBER'] }\n ).execute\n end", "def text(options, params, object_name, format=\"\")\n body = \"\"\n if format.empty?\n outgoing_text_option = @account.outgoing_text_options.where(:name => object_name).first\n # Find the format string from fields that were passed.\n body = outgoing_text_option.build_text(object_name, params)\n else\n body = format\n end\n\n from_phone_number = options[:from_phone_number]\n phone_number = options[:phone_number]\n\n begin\n twilio_account.sms.messages.create(:from => from_phone_number, :to => phone_number, :body => body)\n rescue\n Rails.logger.error \"Unable to send SMS...: #{$!.message}\"\n Rails.logger.error $!.backtrace.join(\"\\n\")\n raise\n end\n ::SmsExtension::Message.create(:from => from_phone_number, :to => phone_number, :body => body)\n end", "def sms number, message\n response = @connection.cmd \"String\" =>\"sms send #{number} #{message}\", \"Match\" => /OK|KO:(.*)/, \"Timeout\" => 5\n if response.chomp == \"OK\"\n true\n else\n raise response.chomp.sub \"KO:\",''\n end\n end", "def perform (msg, to_phone, from_phone=ENV['ST_MAIN_NO'], type=SMS, next_sequence={})\n if type == MMS\n # send MMS to user\n begin\n mms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed MMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n else # SMS\n begin\n sms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed SMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n end\n end", "def send(txt, to, options = {})\n options.default = nil\n api_request(\"sendSms.php\", {\n txt: txt,\n to: to,\n idGroup: options[:idGroup],\n source: options[:source],\n flash: options[:flash],\n dateTimeSend: options[:dateTimeSend],\n onlydelivery: options[:onlydelivery],\n use_alfasource: options[:use_alfasource],\n discountID: options[:discountID],\n channel: options[:channel]\n })\n end", "def sms_to(phone_number, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end", "def send!(message)\n if(self.msisdn_number.blank?)\n if(info = get_sim_info)\n self.update_attribute(:msisdn_number, response[:msisdn])\n end\n end\n\n JasperSmsGateway.send(self.msisdn_number, message)\n end", "def send_to_phone\n if params[:level_source] && params[:phone] && (level_source = LevelSource.find(params[:level_source]))\n send_sms(level_source_url(level_source), params[:phone])\n elsif params[:channel_id] && params[:phone] && ProjectsController::STANDALONE_PROJECTS.include?(params[:type])\n url =\n if params[:type] == 'weblab'\n \"https://codeprojects.org/#{params[:channel_id]}\"\n else\n polymorphic_url([\"#{params[:type]}_project_share\", 'projects'], channel_id: params[:channel_id])\n end\n send_sms(url, params[:phone])\n else\n head :not_acceptable\n end\n end", "def send_code\n return :blank_phone if self.phone.blank?\n self.generate_code\n SMS3.sendto self.phone, \"您的KickTempo手机验证码为:#{self.varified_code}。\"\n end", "def assert_message_options!(phone_number, message, options)\n raise SmsOnRails::SmsError.new(\"Invalid or undefined phone number: #{phone_number.human_display}\") unless phone_number && phone_number.valid?\n raise SmsOnRails::SmsError.new(\"No message specified\") unless message\n raise SmsOnRails::SmsError.new(\"Message is too long. #{message}\") if message.length > self.class.max_characters\n check_white_list!(phone_number)\n check_do_not_send!(phone_number)\n end", "def sms(phone_number, **params)\n\n self.post(VERIFY_SMS_RESOURCE,\n phone_number: phone_number,\n **params)\n end", "def phone_input(method, options)\n basic_input_helper(:phone_field, :phone, method, options)\n end", "def sms(phone_number)\n mp \"[BP Deprecated] use app.launch(sms: #{phone_number}) over app.sms\"\n launch(sms: phone_number)\n end", "def send_confirmation_sms\n SmsApi.send_sms \"+1#{self.phone}\", \"Your confirmation code for StreetEats is #{self.phone_confirmation_code}\"\n end", "def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n recipient_phone = Phone.find_by_number(@message.number)\n \t recipient_phone ||= User.create!.phones.create!(:number => @message.number)\n @message.send_SMS(@message.raw_message, recipient_phone, \"\", @message.app.id)\n format.html { redirect_to messages_path, notice: 'Message was successfully sent.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_text(message, site_id)\n s1 = Caboose::Setting.where(:site_id => site_id, :name => \"twilio_account_sid\").first\n account_sid = s1 ? s1.value : nil\n s2 = Caboose::Setting.where(:site_id => site_id, :name => \"twilio_auth_token\").first\n auth_token = s2 ? s2.value : nil\n s3 = Caboose::Setting.where(:site_id => site_id, :name => \"twilio_from_number\").first\n twilio_number = s3 ? s3.value : nil\n send_to = self.cell_phone.blank? ? (self.direct_work_phone.blank? ? self.other_phone : self.direct_work_phone) : self.cell_phone\n send_to = '205-657-0937' if Rails.env.development? # Billy's cell\n if account_sid && auth_token && twilio_number && !send_to.blank? && !message.blank?\n @client = Twilio::REST::Client.new account_sid, auth_token\n begin\n message = @client.messages.create(\n body: message,\n to: \"+1#{send_to.gsub(/[(\\- )]/, '')}\",\n from: \"#{twilio_number}\"\n )\n rescue\n Caboose.log(\"invalid phone number\")\n end\n end\n end", "def deliver(message, _options = {})\n raise ArgumentError, \"too many recipients, max. is #{MAX_RECIPIENT}\" if message.to.length > MAX_RECIPIENT\n\n # perform request\n @obh_client.send_sms(post_params(message))\n message.to\n end", "def send(phone, message)\n url = get_url\n url.query = get_data(phone, message)\n \n https = Net::HTTP.new(url.host, url.port)\n https.use_ssl = (url.scheme == 'https')\n \n res = https.get(url.request_uri)\n \n if res.code.to_i != 200\n raise Exception.new(\"Server responded with HTTP \" + res.code)\n end\n \n if res.body != OK\n raise Exception.new(get_error_message(res.body))\n end\n end", "def send_twilio_mms\n # Get your Account Sid and Auth Token from twilio.com/user/account\n\n account_sid = 'add your account sid'\n auth_token = 'add your auth token'\n\n # set up a client to talk to the Twilio REST API\n client = Twilio::REST::Client.new account_sid, auth_token\n\n\n mms_message_body = \"name:#{self.contact.name}\"\n mms_message_body += \"\" #quick way to create spacing inbetween txt lines\n mms_message_body += \"phone: #{self.contact.phone_number}\"\n mms_message_body += \"\" #quick way to create spacing inbetween txt lines\n mms_message_body += \"#{self.message}\"\n end", "def send_message\n Pony.mail({\n :from => params[:email], \n :to => '[email protected]',\n :subject => params[:email] + \" has contacted you - Phone: \" + params[:phone], \n :body => params[:email] + params[:message],\n :via => :smtp,\n :via_options => {\n :address => 'smtp.gmail.com', \n :port => '587', \n :enable_starttls_auto => true,\n :user_name => 'info_the_lodge',\n :password => 'secret',\n :authentication => :plain,\n :domain => 'localhost.localdomain'\n }}) \n end", "def to(phone, content, options)\n send_with_block do\n res = Net::HTTP.post_form(URI.parse(URL),\n userCode: options[:username],\n userPass: options[:password],\n DesNo: phone,\n Msg: content,\n Channel: 0)\n result res.body\n end\n end", "def send_joke\r\n client = Twilio::REST::Client.new Rails.application.secrets.twilio_account_sid, Rails.application.secrets.twilio_auth_token\r\n message = client.messages.create from: '347-933-6917', to: params[:phone_number], body: Joke.pick_joke\r\n redirect_to :back\r\n end", "def create_outgoing_message(phone_number, body, message_id = nil, outgoing_count = nil)\n if phone_number.can_receive_email? && allow_email_gateway? &&\n (! allow_commercial_gateway? || prefer_email? )\n to = \"#{phone_number.number}@#{phone_number.provider_email}\"\n from = \"#{name}@mmptext.info\"\n elsif allow_commercial_gateway? && phone_number.can_receive_gateway? && incoming_phone_number.present?\n to = phone_number.number\n from = incoming_phone_number.phone_number\n else\n raise \"List & subscriber settings make sending message impossible for number #{phone_number.number} [list: #{name}].\"\n end\n\n Resque.enqueue(OutgoingMessageJob, id, to, from, body, message_id, outgoing_count)\n end", "def send_text(call_job)\n from = '+18015131966'\n\n req_params = {\n from: from,\n to: call_job.phone,\n status_callback: \"#{ENV['CALL_SERVICE_URL']}twilio/provider_text_status_callback.xml\",\n body: call_job.body\n }\n\n if Rails.env == \"development\"\n url = \"http://127.0.0.1:4567/send_text\"\n RestClient.post url, req_params\n else\n client = Twilio::REST::Client.new(ENV[\"TWILIO_SID\"], ENV[\"TWILIO_TOKEN\"])\n\n account = client.account\n message = account.sms.messages.create(req_params)\n end\n end", "def send_message(arg1, arg2)\n account_sid = 'AC5XXXXXXXXXXXXXXXXXXX' # place twilio sid here\n auth_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX' # place twilio auth token here\n client = Twilio::REST::Client.new(account_sid, auth_token)\n \n from = '' # Your Twilio number\n to = arg1 # Your mobile phone number\n \n client.messages.create(\n from: from,\n to: to,\n body: arg2\n )\n\n end", "def send_sms_token\n if(self.phone?)\n generate_sms_token! if self.sms_confirmation_token.nil?\n ::Devise.sms_sender.send_sms(self.phone, I18n.t(:\"devise.sms_activations.sms_body\", :sms_confirmation_token => self.sms_confirmation_token, :default => self.sms_confirmation_token))\n else\n self.class.sms_confirmation_keys.each do |key|\n self.errors.add(key, :no_phone_associated)\n end\n false\n end\n end", "def send_message(kind, phone_number = params[:phone_number], email = params[:email], location_id = nil)\n raise \"Neither email nor phone_number were given\" if phone_number.blank? && email.blank?\n\n # If the location isn't mentioned explicitly, use the one this user is assigned to\n location_id ||= choose_location\n \n result = { }\n \n # Send message and / or e-mails\n messaging = Messaging.new(current_account)\n unless phone_number.blank?\n session_message = messaging.send(\"send_#{kind}\", normalize_phone(phone_number), location_id)\n result[:message_id] = session_message.id\n end\n messaging.send(\"send_#{kind}_email\", normalize_email(email), location_id) unless email.blank?\n\n # Add usage info\n result[:usage] = usage_info\n \n render :text => result.to_json\n end", "def send_verification(phone:)\n raise StandardError, \"Phone can't be blank\" if phone.blank?\n raise StandardError, \"Please enter a valid phone\" unless PhoneValidator.valid?(phone)\n\n # check if a code was already sent to this phone number\n existing_code = redis.get(phone_key(phone))\n if existing_code\n\n # if a code was already sent, we need to check\n # that time has passed before re-sending it\n # we don't want to allow users to send too many SMS\n # because they cost money and could be abused\n too_early = redis.get(resend_key(phone)).present?\n\n raise StandardError, \"Can't resend a code this soon\" if too_early\n\n # verify that the maximum number of attempts was not yet reached\n attempts = redis.get(attempts_key(phone)).to_i\n raise StandardError, \"You reached the maximum number of attempts, please wait\" if attempts > MAX_ATTEMPTS\n\n # if time has passed, we re-send the same code\n code = existing_code\n else\n # generate N digit code\n code = SecureRandom.random_number(10 ** CODE_LENGTH).to_s.rjust(CODE_LENGTH, \"0\")\n\n # save this code in redis under the given phone number\n redis.set(phone_key(phone), code, ex: EXPIRATION, nx: true)\n # set attempts to 0\n redis.set(attempts_key(phone), \"0\", ex: EXPIRATION, nx: true)\n end\n\n # reset a timer for being able to send a code for a given phone number\n redis.set(resend_key(phone), \"true\", ex: TIME_BEFORE_RESEND, nx: true)\n\n content = \"Verification code: #{code}\"\n # actually send the SMS using twilio or some other service\n Messenger.call(phone: phone, message: content)\n end", "def send_free_confirmation(phone_number, iphone)\n service_layer.send_message(phone_number, MessageBuilder::free_confirmation, false)\n iphone.increment!(:sent)\n end", "def sending_message(to, msg)\n\t begin\n\t\t @client = Twilio::REST::Client.new @account_sid, @auth_token\n\t\t data = {\n\t\t\t\t:from => \"+\" + Rails.application.secrets.from_number.to_s, \n\t\t\t\t:to => to,\n\t\t\t\t:body => msg, \n\t\t\t}\n\t\t\tputs data.inspect\n\t\t\[email protected](data)\n\t\trescue\n raise \"Message not send\"\n\t\tend\n end", "def add_tel(s=nil, number: s)\n @to_s = 'tel:' + number\n end", "def phone_to(phone_number, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end", "def send_sms(content, tonumber)\n tonumber = format(tonumber);\n \tbegin\n @client.messages.create({\n \t :from => @from_number,\n \t :to => tonumber,\n \t :body => content,\n })\n rescue Twilio::REST::RequestError => e\n message = I18n.t(\"errors.sms_not_sent\")\n rescue NoMethodError => e\n message = I18n.t(\"errors.sms_not_sent\")\n else\n message = I18n.t(\"notice.success\")\n end\n\n return message\n\n end", "def phone_number_send_code(phone_number, email, type = \"sms\")\n return_code, response = send_command(\"phone_number/send_code\", token, \n {:phone_number => phone_number, :email => email})\n return response[\"request_id\"] if return_code == \"200\"\n raise ArgumentError, response[\"error\"]\n end", "def deliver_message_via_carrier(text, to, from)\n SMS_CARRIER.deliver_message(text, to, from)\nend", "def deliver_message(options)\n self.sms_service_provider||= default_service_provider\n\n # set the actual message if it differs; not a before_save to reduce the\n # overhead of checking for all commits\n self.actual_message = substituted_draft_message\n\n result = (self.sms_service_provider).send_sms(self)\n self.unique_id = result[:unique_id] if result.is_a?(Hash)\n \n result\n end", "def reply_to_sender_with_error(phone_number, msg)\n reply_to_sender(phone_number, msg)\n msg = \"\" if Rails.env=='production' # do not show error messages in UI in production\n return msg, true\n end", "def sms\n \t\n \t#flash[:notice] = params\n \t#redirect_to root_path\n\n TwilioTextMessenger.new( params[:phone], params[:message]).call\n \t\n end", "def add_phone_number(phone_number)\n return if self.has_number?(phone_number)\n puts \"adding number: \" + phone_number.number \n self.save\n self.list_memberships.create! :phone_number_id => phone_number.id\n if(self.use_welcome_message?)\n puts \"has welcome message, and creating outgoing message\"\n welcome_message = self.custom_welcome_message\n create_outgoing_message( phone_number, welcome_message )\n end \n end", "def set_PhoneNumber(value)\n set_input(\"PhoneNumber\", value)\n end", "def sms_message(number,\r\n message,\r\n country_code = nil)\r\n # Prepare query url.\r\n _path_url = '/sms-message'\r\n _query_builder = Configuration.get_base_uri\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 }\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'output-case' => 'camel',\r\n 'number' => number,\r\n 'message' => message,\r\n 'country-code' => country_code\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: _parameters\r\n )\r\n CustomQueryAuth.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)\r\n SMSMessageResponse.from_hash(decoded)\r\n end", "def new; send_sms; end", "def calculate(message, phone)\n \n puts message.to\n end", "def send_message\n if message.present?\n sender.send_message(receiver, message, I18n.t(\"activity.verb.#{ contact_verb }.#{ receiver.subject_type }.message\", :name => sender.name))\n end\n end", "def make_phone_call(number, international_code = '+254', area_code = 7)\n puts \"calling #{international_code}-#{area_code}#{number}\"\nend", "def send_fax(options = {})\n params = options.merge(to: @fax_number, string_data: 'test')\n @send_fax_response = Phaxio.send_fax(params)\n sleep(5)\n end", "def deliver(message, options = {})\n options = options.reverse_merge default_options\n to = recipient.respond_to?(:call) ? recipient.call(message) : recipient\n message.body message.body.encode(options[:charset]) if options[:charset].presence\n ActionMailerSMSMailer.forward_sms(to, message, options.compact).deliver_now\n message.to\n end", "def send_message(recipient, message_text, opts={})\n valid_options = opts.only(:from)\n valid_options.merge!(:req_feat => '48') if valid_options[:from]\n response = execute_command('sendmsg',\n {:to => recipient, :text => message_text}.merge(valid_options)\n ) \n parse_response(response)['ID']\n end", "def send_my_message\n account_sid = 'ACe330ba04d082392df4cb3511dcb72cec'\n auth_token = '2008ea097713e401a16c54029058da82'\n @client = Twilio::REST::Client.new account_sid, auth_token\n @client.account.messages.create(\n :from => @from,\n :to => @to,\n :body => @body\n )\n end", "def reply # acts as endpoint\n \tmessage_body = params[\"Body\"] # grab params from Twilio's request\n \tfrom_number = params[\"From\"]\n \tboot_twilio\n \tsms = @client.messages.create( # send to inbound number made by end user\n from: Rails.application.secrets.twilio_from_number,\n to: from_number,\n body: \"Hello there, thanks for texting me. Your number is #{from_number}.\"\n \t)\n end", "def send_test_sms(campaign_id, phone_number, opts = {})\n send_test_sms_with_http_info(campaign_id, phone_number, opts)\n nil\n end", "def send_sms!(msg)\n return false unless sms_alerts and phone_number_is_valid? and not mobile_carrier.blank?\n PersonMailer.send_sms(self, msg).deliver\n end", "def call\n account_sid = 'ACe330ba04d082392df4cb3511dcb72cec'\n auth_token = '2008ea097713e401a16c54029058da82'\n\n # set up a client to talk to the Twilio REST API\n @client = Twilio::REST::Client.new account_sid, auth_token\n\n @client.account.messages.create(\n :from => '+18152642023',\n :to => @number,\n :body => 'hahahayolo'\n )\n end", "def make_phone_call(number, international_code = 1, area_code = 646)\n puts \"Calling #{international_code}-#{area_code}-#{number}\"\nend", "def send_sms(cmatch, tstamp, number, expiration)\n\n # Primary provider\n #\n nexmo_reponse = begin\n nexmo = Nexmo::Client.new('371f3e5d', 'e3218b70')\n token_url = create_token_url(cmatch, tstamp)\n record_token(cmatch, tstamp, expiration)\n sms_primary_response = nexmo.send_message({\n from: '13059298586',\n to: number,\n text: cmatch\n })\n json :sms_status => \"sent\",\n :token => cmatch,\n :token_url => token_url,\n :phone_number => number,\n :token_generated => tstamp,\n :token_expires => tstamp + expiration\n rescue\n send_sms_twilio(cmatch, tstamp, number, expiration)\n end\nend", "def send(message, options = {})\n message_format = options[:message_format] ? options[:message_format] : 'text'\n notify = options[:notify] ? options[:notify] : false\n\n response = self.class.post(@api.send_config[:url],\n :query => { :auth_token => @token },\n :body => {\n :message => message,\n :message_format => message_format,\n :notify => notify\n }.send(@api.send_config[:body_format]),\n :headers => @api.headers\n )\n ErrorHandler.response_code_to_exception_for :user, user_id, response\n true\n end", "def twilio\n account_sid = ENV[\"TWILIO_SID\"]\n auth_token = ENV['TWILIO_TOKEN']\n client = Twilio::REST::Client.new account_sid, auth_token\n\n from = \"8452633595\"\n\n client.account.messages.create(\n :from => from,\n :to => self.phone,\n :body => \"#{self.title} - #{self.full_desc} ($#{self.price})\"\n )\n puts \"Sent message\"\n end", "def create\n to = params[:to]\n\n unless to\n raise IOError, \"Incorrect params for sending text message\" \n end\n\n @client = Twilio::REST::Client.new(\n CONFIG[:twilio_account_sid],\n CONFIG[:twilio_auth_token])\n\n @account = @client.account\n @message = @account.sms.messages.create({\n :from => CONFIG[:twilio_phone_number],\n :to => to,\n :body => \"Happy Mining! #{CONFIG[:ios_app_link]}\"}) \n\n rescue => ex\n handle_exception(ex)\n ensure\n respond_to do |format|\n format.json\n end\n end", "def send_conference_code!\n send_sms!(\n self[:phone],\n I18n.t('activerecord.attributes.concern.sns_snsable.conference_code',\n did: dialer.did, conference_code: dialer.conference_code)\n )\n ApplicationMailer.email_conference_code(self).deliver_later\n end", "def notifyViaSMS(number, message, api, user, password)\n result = nil\n message = CGI.escape message\n request = \"/http/sendmsg?api_id=#{api}&user=#{user}&password=#{password}&to=#{number}&text=#{message}&from=RIVR\" \n Net::HTTP.start( 'api.clickatell.com', 80 ) { |http| result = http.get(request).body } \n return result \n end", "def send_message(**opts, &with_communication_do)\n raise NotImplementedError\n end", "def shape_phone_number\n self.phone_number = twilio_format phone_number\n end", "def set_phone phone, key\n opts = {:single_quoted => false}\n params = {\n :query => {\n \"ClientToken\" => self.token,\n \"PhoneNumber\" => Type::String.safe_value(phone, opts),\n \"PersonKey\" => Type::String.safe_value(key, opts)\n }\n }\n\n put 'set_phone.php', params\n end", "def fallback_to_twilio\n sms.output = :twilio\n sms.deliver\n end", "def message\n account_sid = ENV['TWILIO_ACCOUNT_SID'] \n auth_token = ENV['TWILIO_AUTH_TOKEN'] \n client = Twilio::REST::Client.new(account_sid, auth_token)\n\n from = ENV['TWILIO_PHONE_NUMBER']\n to = '+15145037764' # Your mobile phone number\n\n client.messages.create(\n from: from,\n to: to,\n body: \"The Elevator '#{self.id}', Serial Number '#{self.serial_number}' needs an intervention\" \n )\n end", "def phone_number\n element_with_value('PhoneNumber', opts[:phone_number])\n end", "def phone_number\n \"(#{Helpers::FakeIt.area_code}) #{Helpers::FakeIt.exchange_code}-#{Helpers::FakeIt.subscriber_number}\"\n end" ]
[ "0.8076961", "0.7327399", "0.72555643", "0.71731424", "0.7172145", "0.7094982", "0.7071273", "0.7059622", "0.70495224", "0.7027857", "0.6943535", "0.6899074", "0.689207", "0.6848091", "0.68376344", "0.67783016", "0.674744", "0.67085665", "0.670839", "0.6684886", "0.6682523", "0.665141", "0.6645283", "0.66358614", "0.6618662", "0.66098565", "0.6609031", "0.6583875", "0.65477395", "0.6534373", "0.65299594", "0.6526725", "0.6525438", "0.6501997", "0.6498759", "0.6481787", "0.6432465", "0.64284384", "0.6423723", "0.6423457", "0.64029676", "0.64007944", "0.63978565", "0.6374257", "0.6368229", "0.6349715", "0.6323465", "0.6270078", "0.6241822", "0.62211686", "0.62192", "0.6202139", "0.6186477", "0.61525863", "0.61420476", "0.61305135", "0.61253244", "0.61241686", "0.6120415", "0.60995036", "0.608916", "0.60850054", "0.607619", "0.607329", "0.6062144", "0.6058753", "0.6058181", "0.60516524", "0.6038716", "0.60272706", "0.60129845", "0.60066646", "0.60065633", "0.60041654", "0.59957063", "0.59888154", "0.5985925", "0.59662807", "0.5947568", "0.5947037", "0.5944357", "0.5942965", "0.59360045", "0.59357035", "0.59350204", "0.591859", "0.5915296", "0.5914745", "0.59065306", "0.5889774", "0.58869505", "0.5881163", "0.58810866", "0.5871654", "0.58606607", "0.58558565", "0.5848383", "0.5840824", "0.58391356", "0.5823042" ]
0.7171992
5
Sends a message to a phone number active record object or string and performs validation on the phone_number +phone_number+ can be either a phone number active record obj or a string text. Strings are converted to phone_number objects +message+ the message to send +options+ additional options to be used by the provider ===Options :skip_validation skips validation and sends the message directly to the provider
def send_to_phone(phone_obj, message, options={}) if options[:skip_validation] phone_text = phone_obj.is_a?(ActiveRecord::Base) ? format_phone_number(phone_number) : phone_obj return send_message(phone_text, message, options) end phone_number = phone_obj.is_a?(ActiveRecord::Base) ? phone_obj : find_or_create_phone_number(phone_obj, options) assert_message_options!(phone_number, message, options) send_message(format_phone_number(phone_number), message, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n recipient_phone = Phone.find_by_number(@message.number)\n \t recipient_phone ||= User.create!.phones.create!(:number => @message.number)\n @message.send_SMS(@message.raw_message, recipient_phone, \"\", @message.app.id)\n format.html { redirect_to messages_path, notice: 'Message was successfully sent.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_sms_verification_code\n number_to_send_to = phone_number\n verification_code = phone_verification_code\n sms_message_body = I18n.t(\"devise.phone.message_body\", :verification_code => verification_code)\n\n sms = Sms.new\n sms.phone_number = number_to_send_to\n sms.message = sms_message_body\n return false unless sms.send!\n\n true\n end", "def send_sms(to_phone_number, message)\n # message = {to:, from:, body: \"Hello\\n\\nWorld\"}\n # binding.pry\n @@client.messages.create(\n from: @@from,\n to: to_phone_number,\n body: message\n )\n end", "def send_message(phone_number, message, options={})\n raise SmsOnRails::SmsError.new(\"Override send_message in subclass #{self.class}\")\n end", "def send_free_message(kind, phone_number = params[:phone_number])\n raise \"Phone_number is not given\" if phone_number.blank?\n \n messaging = Messaging.new\n messaging.send(\"send_free_#{kind}\", normalize_phone(phone_number), @iphone)\n \n render :text => \"\"\n end", "def assert_message_options!(phone_number, message, options)\n raise SmsOnRails::SmsError.new(\"Invalid or undefined phone number: #{phone_number.human_display}\") unless phone_number && phone_number.valid?\n raise SmsOnRails::SmsError.new(\"No message specified\") unless message\n raise SmsOnRails::SmsError.new(\"Message is too long. #{message}\") if message.length > self.class.max_characters\n check_white_list!(phone_number)\n check_do_not_send!(phone_number)\n end", "def valid_phone_number\n\t\tnumber = self.number.scan(/\\d/).join('')\n\t\tnumber[0] = '' if number[0] == \"1\"\n\n\t\tif number.length != 10\n\t\t\terrors.add(:phone, \"must be a valid 10 digit phone number\")\n\t\telse\n\t\t\tself.number = number\n\t\tend\n\tend", "def shape_phone_number\n self.phone_number = twilio_format phone_number\n end", "def twilio_send_text_message!(client,phone_num,msg)\n begin\n sms = client.account.sms.messages.create(\n :from => TWILIO_PHONE,\n :to => phone_num,\n :body => msg)\n rescue Exception => e\n puts \"Problems with twilio:\\n#{e}\"\n end\n end", "def coerce_phone(value, options = {})\n value ? coerce_string(value).upcase.gsub(/[^+0-9A-Z]/,'') : nil\n end", "def send_text(number, message)\n @client.api.account.messages.create(\n to: number,\n from: 'add phone number',\n body: message\n )\n end", "def coerce_phone(value, options = {})\n value = coerce_string(value, options)\n value ? value.upcase.gsub(/[^+0-9A-Z]/, \"\") : nil\n end", "def sms(phone_number, **params)\n\n self.post(VERIFY_SMS_RESOURCE,\n phone_number: phone_number,\n **params)\n end", "def pp_phone_validate(phone_number, iso_country_code = nil)\n request = {\n phone_number: phone_number\n }\n request[:iso_country_code] = iso_country_code if iso_country_code\n\n aws_pinpoint_client.phone_number_validate(\n number_validate_request: request\n )\n end", "def normalize_phone(phone_number)\n raise \"Phone number is blank\" if phone_number.blank?\n raise \"Invalid phone number\" unless /^\\+?1?\\d{10}$/ =~ phone_number.strip\n SmsToolkit::PhoneNumbers.normalize(phone_number)\n end", "def twilio\n @number = params[:phone_number]\n \n #Text message info\n t = {\n \n 'From' => CALLER_ID,\n 'To' => @number,\n 'Body' => (\"Visit uhpartments.com when you walk through an apartment\")\n }\n\n begin\n account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)\n resp = account.request(\"/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages\",\n 'POST',\n t)\n resp.error! unless resp.kind_of? Net::HTTPSuccess\n rescue StandardError => bang\n #This area will be called if an error happens with the Twilio API\n flash[:alert] = \"Bad number.\"\n redirect_to({ :action => :home })\n \n return\n end\n\n redirect_to({ :action => :home, :alert => \"SMS sent.\" })\n end", "def create_basic_message(phone_number, message, options={})\n #validate phone number\n { :PhoneNumberToDial => phone_number,\n :TextToSay => message,\n :LicenseKey => @license_key,\n :CallerID => options[:caller_id_number] || '1-866-665-4386',\n :CallerIDname => options[:caller_id_name] || 'CDYNE Notify',\n :VoiceID => options[:voice_id] || 2 }\n end", "def send phone_number\n account = CLIENT.account \n message = account.sms.messages.create({from: TAKEAWAY_NUMBER , to: phone_number, body: \"Thanks for your order! It shall arrive no later than #{@delivery_time.strftime(\"%H\")}:#{@delivery_time.strftime(\"%M\")}.\"})\n message.body\n end", "def send_to_phone\n if params[:level_source] && params[:phone] && (level_source = LevelSource.find(params[:level_source]))\n send_sms(level_source, params[:phone])\n render status: :ok, nothing: true\n else\n render status: :not_acceptable, nothing: true\n end\n end", "def send_verification(phone:)\n raise StandardError, \"Phone can't be blank\" if phone.blank?\n raise StandardError, \"Please enter a valid phone\" unless PhoneValidator.valid?(phone)\n\n # check if a code was already sent to this phone number\n existing_code = redis.get(phone_key(phone))\n if existing_code\n\n # if a code was already sent, we need to check\n # that time has passed before re-sending it\n # we don't want to allow users to send too many SMS\n # because they cost money and could be abused\n too_early = redis.get(resend_key(phone)).present?\n\n raise StandardError, \"Can't resend a code this soon\" if too_early\n\n # verify that the maximum number of attempts was not yet reached\n attempts = redis.get(attempts_key(phone)).to_i\n raise StandardError, \"You reached the maximum number of attempts, please wait\" if attempts > MAX_ATTEMPTS\n\n # if time has passed, we re-send the same code\n code = existing_code\n else\n # generate N digit code\n code = SecureRandom.random_number(10 ** CODE_LENGTH).to_s.rjust(CODE_LENGTH, \"0\")\n\n # save this code in redis under the given phone number\n redis.set(phone_key(phone), code, ex: EXPIRATION, nx: true)\n # set attempts to 0\n redis.set(attempts_key(phone), \"0\", ex: EXPIRATION, nx: true)\n end\n\n # reset a timer for being able to send a code for a given phone number\n redis.set(resend_key(phone), \"true\", ex: TIME_BEFORE_RESEND, nx: true)\n\n content = \"Verification code: #{code}\"\n # actually send the SMS using twilio or some other service\n Messenger.call(phone: phone, message: content)\n end", "def text(options, params, object_name, format=\"\")\n body = \"\"\n if format.empty?\n outgoing_text_option = @account.outgoing_text_options.where(:name => object_name).first\n # Find the format string from fields that were passed.\n body = outgoing_text_option.build_text(object_name, params)\n else\n body = format\n end\n\n from_phone_number = options[:from_phone_number]\n phone_number = options[:phone_number]\n\n begin\n twilio_account.sms.messages.create(:from => from_phone_number, :to => phone_number, :body => body)\n rescue\n Rails.logger.error \"Unable to send SMS...: #{$!.message}\"\n Rails.logger.error $!.backtrace.join(\"\\n\")\n raise\n end\n ::SmsExtension::Message.create(:from => from_phone_number, :to => phone_number, :body => body)\n end", "def phone_input(method, options)\n basic_input_helper(:phone_field, :phone, method, options)\n end", "def send_sms(sms, options={})\n send_to_phone(sms.phone_number, sms.actual_message, options)\n end", "def send(user, number, message, phone=nil)\n phone = Behaviour.select_phone(number, user['behaviour']) if phone.nil?\n if phone #se fizer match com os existentes\n `gammu-smsd-inject -c ~/.sms/gammu-smsdrc-#{phone} TEXT #{number} -text \"#{message}\"` # send to daemon\n #LOGIT que foi para a fila\n else \n #LOGIT que alguem tentou mas nao foi para a fila\n end\n end", "def validate_to_input\n if inbound_request? && !account.phone_numbers.where(number: to).exists?\n errors.add(:to, I18n.t('errors.messages.parameter_not_found'))\n end\n end", "def perform (msg, to_phone, from_phone=ENV['ST_MAIN_NO'], type=SMS, next_sequence={})\n if type == MMS\n # send MMS to user\n begin\n mms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed MMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n else # SMS\n begin\n sms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed SMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n end\n end", "def notify(custom_message, phone_number)\n account_sid = ENV['TWILIO_ACCOUNT_SID']\n auth_token = ENV['TWILIO_AUTH_TOKEN']\n client = Twilio::REST::Client.new(account_sid, auth_token)\n message = client.messages.create from: ENV['TWILIO_PHONE_NUMBER'], to: '+1' + phone_number, body: custom_message\n end", "def set_and_validate_sms\n sms_service.validate_params\n end", "def standardized_sms_phone_number\n PhoneParser.normalize(sms_phone_number)\n end", "def reply_to_sender_with_error(phone_number, msg)\n reply_to_sender(phone_number, msg)\n msg = \"\" if Rails.env=='production' # do not show error messages in UI in production\n return msg, true\n end", "def send_sms(message)\n api_response = \"\"\n if !self.mobile.blank?\n txtlocal = Txtlocal.find_by_sms_type(Txtlocal::GROUP_CHAT)\n if !txtlocal.nil?\n txtlocal.message_contents = message\n api_response = txtlocal.send_sms(self.mobile)\n end\n else\n api_response = \"You have not provided any mobile number. Please go to your 'Account' to set up a mobile number\"\n end\n return api_response\n end", "def send_sms_token\n if(self.phone?)\n generate_sms_token! if self.sms_confirmation_token.nil?\n ::Devise.sms_sender.send_sms(self.phone, I18n.t(:\"devise.sms_activations.sms_body\", :sms_confirmation_token => self.sms_confirmation_token, :default => self.sms_confirmation_token))\n else\n self.class.sms_confirmation_keys.each do |key|\n self.errors.add(key, :no_phone_associated)\n end\n false\n end\n end", "def send!(message)\n if(self.msisdn_number.blank?)\n if(info = get_sim_info)\n self.update_attribute(:msisdn_number, response[:msisdn])\n end\n end\n\n JasperSmsGateway.send(self.msisdn_number, message)\n end", "def phone_present\n if phone.blank?\n errors.add(:phone, \"Can't be empty\")\n end\n end", "def send_sms phone, message\n message = URI.escape message\n response = RestClient.get \"#{sender_base_url}/?from=#{@from}&to=#{phone}&text=#{message}&pass=#{@application_pass}\"\n @response = Response.new response\n end", "def send_text_message(body)\n if self.mobile.present?\n begin\n TWILIO_CLIENT.messages.create(from: ENV['TWILIO_PHONE_NUMBER'], to: self.mobile, body: body)\n rescue Twilio::REST::RequestError => e\n puts \"Twilio Error: #{e.message}\"\n end\n end\n end", "def sms number, message\n response = @connection.cmd \"String\" =>\"sms send #{number} #{message}\", \"Match\" => /OK|KO:(.*)/, \"Timeout\" => 5\n if response.chomp == \"OK\"\n true\n else\n raise response.chomp.sub \"KO:\",''\n end\n end", "def send\n if @to.nil? || @from.nil? || @message.nil?\n raise ArgumentError, \"You need to include 'to' and 'from' numbers and a message to send an SMS\"\n end\n to = @to.gsub(\" \",\"\")\n from = @from.gsub(\" \",\"\")\n parameters = {\n \"sms-send-to\" => to,\n \"sms-send-from\" => from,\n \"sms-message\" => @message[0..159]\n }\n request = @browser.post(\"#{VoipfoneClient::API_POST_URL}?smsSend\", parameters)\n response = parse_response(request)\n if response == \"ok\"\n return true\n else\n raise VoipfoneAPIError, response\n end\n end", "def create\n # contact_params[:phone_number] = contact_params[:phone_number].phony_formatted(:normalize => \"KE\", :format => :international).gsub(/\\D/, '')\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: { id: @contact.id.to_i, status: \"success\" } }\n else\n format.html { render :new }\n format.json { render json: { id: @contact.id.to_i, status: \"failure\" } }\n end\n end\n end", "def send_sms(fromNumber)\n begin\n bodyParams = {\n from: { phoneNumber: fromNumber },\n to: [{ phoneNumber: RECIPIENT }],\n # To send group messaging, add more (max 10 recipients) 'phoneNumber' object. E.g.\n #\n #to: [\n # { phoneNumber: RECIPIENT },\n # { phoneNumber: 'Recipient-Phone-Number' }\n # ],\n text: 'Hello World!'\n }\n endpoint = \"/restapi/v1.0/account/~/extension/~/sms\"\n resp = $platform.post(endpoint, payload: bodyParams)\n puts (\"SMS sent. Message id: \" + resp.body['id'].to_s)\n check_message_status(resp.body['id'])\n rescue StandardError => e\n puts (e)\n end\nend", "def format_phone\n if @phone != nil\n @phone = self.phone.scan(/[0-9]/).join\n self.phone = @phone.length == 7 ? ActionController::Base.helpers.number_to_phone(@phone) : \n @phone.length == 10 ? ActionController::Base.helpers.number_to_phone(@phone, area_code: true) :\n @phone\n\n end\n end", "def add_phone_number!(phone_number)\n clean_phone_number = Expect.clean_phone_number(phone_number)\n \n unless self.phone_numbers.where(clean_phone_number: clean_phone_number).any?\n self.phone_numbers.create(phone_number: phone_number)\n end\n end", "def phone_call(message)\n Ruboty::Call::Actions::Call.new(message).call\n end", "def send_code\n return :blank_phone if self.phone.blank?\n self.generate_code\n SMS3.sendto self.phone, \"您的KickTempo手机验证码为:#{self.varified_code}。\"\n end", "def create\n flash[:notice] = 'The phone number was successfully added.' if phone_number.save\n respond_with(phone_number)\n end", "def perform(message, to_number)\n logger.info \"Sending message to #{to_number}\"\n TwilioService.new({\n to: to_number,\n msg: message\n }).send_sms\n end", "def field_register_pharmacy(pharm_number,pharm_contact_name,staff_phone_number)\n pharm_number = standardize_number(pharm_number[0])\n\n #check to make sure this number is not already registered\n phone_number_in_db = Number.where(:id => pharm_number)\n if phone_number_in_db.count > 0\n send_try_again_sms(staff_phone_number,\"This number is already registered to pharmacy #{phone_number_in_db.first.pharmacy_id}\")\n return nil\n end\n\n\n Pharmacy.insert(:preferred_number_id => pharm_number,\n :name => pharm_contact_name)\n pid = Pharmacy.where(:preferred_number_id => pharm_number).first.id\n\n Number.insert(\n :id => pharm_number,\n :pharmacy_id => pid,\n :call_this_number => 1,\n :created_at => Time.now\n )\n\n #settings so we dont call em\n PendingCall.insert(\n :number_id => pharm_number,\n :attempts => $max_ors_attempts,\n :error_message_sent => 1\n )\n\n # Default start and end time for pharmacies\n AvailableTime.insert(\n :pharmacy_id => pid,\n :start_time => \"09:00:00\",\n :end_time => \"21:00:00\"\n )\n\n sms_message_confirmation = \"Registration successful. Pharmacy ID number is #{pid}\"\n $stderr.puts \"sending reg confirmation to to #{staff_phone_number}\"\n\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => staff_phone_number,\n :body => sms_message_confirmation)\n #send message to user\n $stderr.puts \"sending reg confirmation to to #{pharm_number}\"\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => pharm_number,\n :body => \"Welcome to bangpharma. Your pharmacy ID is #{pid}.\")\n\n return nil\nend", "def send_sms!(msg)\n return false unless sms_alerts and phone_number_is_valid? and not mobile_carrier.blank?\n PersonMailer.send_sms(self, msg).deliver\n end", "def phone_number\n\t\t\trecipient.phone_number\n\t\tend", "def fallback_to_twilio\n sms.output = :twilio\n sms.deliver\n end", "def send_message\n unless message_sent\n twilio_client.messages.create(\n from: ENV.fetch(\"TWILIO_PHONE_NUMBER\"),\n to: contact.phone_number,\n body: content,\n )\n update(message_sent: true)\n end\n end", "def phone=(phone)\n if phone.nil?\n fail ArgumentError, 'phone cannot be nil'\n end\n\n if phone.to_s.length > 10\n fail ArgumentError, 'invalid value for \"phone\", the character length must be smaller than or equal to 10.'\n end\n\n pattern = Regexp.new(/^[0-9]+$/)\n if phone !~ pattern\n fail ArgumentError, \"invalid value for \\\"phone\\\", must conform to the pattern #{pattern}.\"\n end\n\n @phone = phone\n end", "def find_or_create_phone_number(phone_text, options={})\n phone = phone_klass.find_and_create_by_number(phone_text)\n phone.assign_carrier(options[:carrier]) if options[:carrier]\n phone\n end", "def huzzah\n # ===========================================================================\n # 6. Send an SMS Message to 415-555-1212\n # uses a HTTP POST, and a new variable t for the information (because it needs \"Body\")\n \n account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)\n \n t = {\n 'From' => CALLER_ID,\n 'To' => phone,\n 'Body' => message\n }\n resp = account.request(\"/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages\",\n \"POST\", t)\n end", "def validate_for_email_or_phone\n unless valid_format_email_or_phone?\n errors.add(:email_or_phone, :invalid)\n end\n end", "def phone_number\n if self[:phone_number] == nil\n return nil\n end\n phone_number = self[:phone_number]\n return PhoneNumberHandler.format_phone_number(phone_number)\n end", "def phone_number\n if self[:phone_number] == nil\n return nil\n end\n phone_number = self[:phone_number]\n return PhoneNumberHandler.format_phone_number(phone_number)\n end", "def format_phone_number\n if self.phone_number.nil?\n return false\n end\n raw_numbers = self.phone_number.gsub(/\\D/, '')\n if raw_numbers.size != 10\n return false\n end\n self.phone_number = \"(#{raw_numbers[0..2]}) #{raw_numbers[3..5]}-#{raw_numbers[6..9]}\"\n end", "def sms_to(phone_number, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end", "def sms_perform(object_instance, options={})\n account = ::SmsExtension::Account.first\n consumer = AP::SmsExtension::Sms::Consumer.new(account)\n options = HashWithIndifferentAccess.new(options)\n options[:phone_number] ||= account.phone_number\n options[:outgoing_message_format] ||= account.outgoing_message_format\n options[:from_phone_number] ||= (!account.from_phone_number.blank? ? account.from_phone_number : ENV['SMS_EXTENSION_TWILIO_FROM_SMS_NUMBER'])\n\n consumer.text(options, object_instance.attributes, object_instance.class.name, options[:outgoing_message_format])\n end", "def phone_number=(phone_number)\n\n if !phone_number.nil? && phone_number.to_s.length > 30\n fail ArgumentError, \"invalid value for 'phone_number', the character length must be smaller than or equal to 30.\"\n end\n\n @phone_number = phone_number\n end", "def phone_number=(phone_number)\n\n if !phone_number.nil? && phone_number.to_s.length > 30\n fail ArgumentError, \"invalid value for 'phone_number', the character length must be smaller than or equal to 30.\"\n end\n\n @phone_number = phone_number\n end", "def deliver_sms(params)\n#puts \"**** Message#deliver_sms; params=#{params}\"\n sms_gateway = params[:sms_gateway]\n phone_number_array = @contact_info.map {|c| c[:phone]}.compact.uniq\n phone_numbers = phone_number_array.join(',')\n assemble_sms()\n#puts \"**** sms_gateway.deliver #{sms_gateway} w #{phone_numbers}: #{sms_only}\"\n #******* CONNECT TO GATEWAY AND DELIVER MESSAGES \n gateway_reply = \n sms_gateway.deliver(phone_numbers, sms_only)\n#puts \"**** gateway_reply=#{gateway_reply}\"\n #******* PROCESS GATEWAY REPLY (INITIAL STATUSES OF SENT MESSAGES) \n gtw_msg_id = nil\n if phone_number_array.size == 1\n # SINGLE PHONE NUMBER \n if gateway_reply =~ /ID: (\\w+)/\n gtw_msg_id = $1\n gtw_msg_id = gateway_reply[4..99] # Temporary workaround as $1 doesn't work on Heroku\n msg_status = MessagesHelper::MsgSentToGateway\n else\n gtw_msg_id = gateway_reply # Will include error message\n msg_status = MessagesHelper::MsgError\n end\n # Mark the message to this member as being sent\n self.sent_messages[0].update_attributes(:gateway_message_id => gtw_msg_id, \n :msg_status => msg_status)\n else\n # MULTIPLE PHONE NUMBERS\n # Get the Clickatell reply and parse into array of hash like {:id=>'asebi9xxke...', :phone => '2345552228372'}\n#puts \"**** gateway_reply=#{gateway_reply}\"\n msg_statuses = gateway_reply.split(\"\\n\").map do |s|\n if s =~ /ID:\\s+(\\w+)\\s+To:\\s+([0-9]+)/\n {:id => $1, :phone => $2} \n else\n {:id => nil, :phone => nil, :error => s}\n end\n end\n # Make array to associate members with their numbers\n @member_phones = self.members.map {|m| {:phone => m.primary_phone, :member => m} }\n # Update the sent_message records to indicate which have been accepted at Gateway \n msg_statuses.each do |s|\n#puts \"**** s[:id]=#{s[:id]}, s[:phone]=#{s[:phone]}\"\n if s[:id] && s[:phone]\n # Find the right member by matching phone numbers\n member = @member_phones.find{|m| m[:phone]==s[:phone]}[:member]\n # Find the right sent_message by matching member & message\n sent_message = SentMessage.where(:member_id=>member.id, :message_id=>self.id).first\n # Update the sent_message\n sent_message.update_attributes(\n :gateway_message_id => s[:id], \n :msg_status=> MessagesHelper::MsgSentToGateway\n )\n end\n end\n # Any sent_messages not now marked with gateway_message_id and msg_status must have errors\n sent_messages.each do |m| \n m.update_attributes(:msg_status=> MessagesHelper::MsgError) if m.msg_status.nil?\n end\n end\n end", "def add_phone_number(phone_number)\n return if self.has_number?(phone_number)\n puts \"adding number: \" + phone_number.number \n self.save\n self.list_memberships.create! :phone_number_id => phone_number.id\n if(self.use_welcome_message?)\n puts \"has welcome message, and creating outgoing message\"\n welcome_message = self.custom_welcome_message\n create_outgoing_message( phone_number, welcome_message )\n end \n end", "def phone=(phone)\n if phone.nil?\n fail ArgumentError, \"phone cannot be nil\"\n end\n\n if phone.to_s.length < 1\n fail ArgumentError, \"invalid value for 'phone', the character length must be great than or equal to .\"\n end\n\n @phone = phone\n end", "def send_sms number, message, opts={}\r\n wait =!(opts[:nowait] || false)\r\n encode = opts[:encode] || :ascii\r\n sender = opts[:sender] || false\r\n datetime = opts[:date] || false\r\n\r\n case encode\r\n when :binary || :base64\r\n encode = 'B'\r\n when :unicode\r\n encode = 'U'\r\n else # :ascii\r\n encode = ''\r\n end\r\n\r\n if sender\r\n sender = \"#{sender} \"\r\n custom = 'F'\r\n else\r\n custom = ''\r\n end\r\n\r\n if datetime\r\n datetime = \"#{datetime} \"\r\n date = 'D'\r\n else\r\n date = ''\r\n end\r\n\r\n cmd_raw \"#{date}#{custom}#{encode}SUBMIT\", \"#{datetime}#{sender}#{number} #{message}\"\r\n\r\n if wait\r\n wait_for last_label\r\n return false if @response_cmd.eql? 'NOOK'\r\n return \"#{@response_args[0]}.#{@response_args[1]}\".to_f\r\n end\r\n end", "def phone(no)\n if no\n number_to_phone(no, :area_code => false)\n else\n no\n end\n end", "def phone=(phone)\n\n if !phone.nil? && phone.to_s.length > 15\n fail ArgumentError, \"invalid value for 'phone', the character length must be smaller than or equal to 15.\"\n end\n\n @phone = phone\n end", "def set_PhoneNumber(value)\n set_input(\"PhoneNumber\", value)\n end", "def phone=(phone)\n if !phone.nil? && phone.to_s.length > 255\n fail ArgumentError, 'invalid value for \"phone\", the character length must be smaller than or equal to 255.'\n end\n\n if !phone.nil? && phone.to_s.length < 0\n fail ArgumentError, 'invalid value for \"phone\", the character length must be great than or equal to 0.'\n end\n\n @phone = phone\n end", "def add_member_phone(phone)\n\n end", "def sms(phone_number)\n mp \"[BP Deprecated] use app.launch(sms: #{phone_number}) over app.sms\"\n launch(sms: phone_number)\n end", "def send_message(phone_number, message)\n command = Command.new('SendSMSBasic', license_key)\n MessageStatus.new(\n Response.parse(\n command.execute({:PhoneNumber => phone_number, :Message => message})\n )[\"SmsReturn\"]\n )\n end", "def create\n # parse phone number and save it in the correct format\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n # render text: \"Thank you! You will receive an SMS shortly with verification instructions.\"\n\n\n # Instantiate a Twilio client\n @client = Twilio::REST::Client.new(TWILIO_CONFIG['sid'], TWILIO_CONFIG['token'])\n \n # Create and send an SMS message\n @client.account.sms.messages.create(\n from: TWILIO_CONFIG['from'],\n to: @user.phone,\n body: \"Thanks for signing up. To verify your account, please reply 'yes' to this message.\"\n # mediaurl: \"http://s3.amazonaws.com/simpleupc/images/full/3bdc2416fbb17d90.jpg\"\n )\n\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 to_s\n valid? ? full : @phone\n end", "def sms\n \t\n \t#flash[:notice] = params\n \t#redirect_to root_path\n\n TwilioTextMessenger.new( params[:phone], params[:message]).call\n \t\n end", "def edit_phone_number\n begin\n if params[:user][:phone_number].present?\n @user = api_user\n if @user && params[:user][:password].present?\n authorized_user = @user.valid_password?(params[:user][:password])\n elsif @user && params[:user][:email].present?\n authorized_user = @user.email == params[:user][:email] ? @user : nil\n else\n authorized_user=@user\n end\n if authorized_user\n if params[:user][:verification_code].present?\n if @user.verification_code == params[:user][:verification_code]\n if @user.update(phone_number: params[:user][:phone_number],verification_code: nil)\n @response = {:code => \"0\",:status => \"Success\",:message => \"Phone number updated successfully\",:user => @user.create_hash}\n else\n @response = {:code => \"1\",:status => \"Error\",:message => \"Error while updating phone number\",:user => @user.errors}\n end\n else\n @response = {:code => \"2\",:status => \"Error\",:message => \"Wrong verification code\"}\n end\n else\n verification_code = rand(1000...9999)\n to_number = \"#{params[:countries]}#{params[:user][:phone_number]}\"\n body = \"Your phone number successfully updated on miniflix and your verification code is #{verification_code}\"\n\n twillo_response = TwilioService.new(to_number, body).call()\n\n if twillo_response[:success]\n @response = {:code => \"0\",:status => \"Success\",:message => \"Successfully sent verification code on your phone number.\"}\n @user.update_attributes(:verification_code => verification_code)\n else\n @response = {:code => \"-1\",:status => \"Error\",:message => twillo_response[:message]}\n end\n end\n else\n @msg = params[:user][:email].present? ? \"Invalid email\" : \"Invalid Current Password\"\n @response = {:code => \"3\",:status => \"Error\",:message => @msg}\n end\n else\n @response = {:code => \"4\",:status => \"Error\",:message => \"Please pass user_id/phone_number/password/email\"}\n end\n rescue Exception => e\n @response = {:code => \"-1\",:status => \"Error\",:message => e.message}\n end\n render :json => @response\n end", "def check_do_not_send!(phone_number)\n if phone_number.do_not_send?\n raise SmsOnRails::SmsError.new(\"Phone number #{phone_number.human_display} do not send is set:#{phone_number.do_not_send}\")\n end\n end", "def phone=(val)\n write_attribute(:phone, PhoneNumber.standardise_phone_number(val))\n end", "def send_sms(content, tonumber)\n tonumber = format(tonumber);\n \tbegin\n @client.messages.create({\n \t :from => @from_number,\n \t :to => tonumber,\n \t :body => content,\n })\n rescue Twilio::REST::RequestError => e\n message = I18n.t(\"errors.sms_not_sent\")\n rescue NoMethodError => e\n message = I18n.t(\"errors.sms_not_sent\")\n else\n message = I18n.t(\"notice.success\")\n end\n\n return message\n\n end", "def set_type_phone_number\n\n if !params[:type].nil? && !params[:phone_number].nil?\n\n @type = params[:type].to_s\n\n @phone_number = params[:phone_number].to_s\n\n end\n\n end", "def send_text(message, site_id)\n s1 = Caboose::Setting.where(:site_id => site_id, :name => \"twilio_account_sid\").first\n account_sid = s1 ? s1.value : nil\n s2 = Caboose::Setting.where(:site_id => site_id, :name => \"twilio_auth_token\").first\n auth_token = s2 ? s2.value : nil\n s3 = Caboose::Setting.where(:site_id => site_id, :name => \"twilio_from_number\").first\n twilio_number = s3 ? s3.value : nil\n send_to = self.cell_phone.blank? ? (self.direct_work_phone.blank? ? self.other_phone : self.direct_work_phone) : self.cell_phone\n send_to = '205-657-0937' if Rails.env.development? # Billy's cell\n if account_sid && auth_token && twilio_number && !send_to.blank? && !message.blank?\n @client = Twilio::REST::Client.new account_sid, auth_token\n begin\n message = @client.messages.create(\n body: message,\n to: \"+1#{send_to.gsub(/[(\\- )]/, '')}\",\n from: \"#{twilio_number}\"\n )\n rescue\n Caboose.log(\"invalid phone number\")\n end\n end\n end", "def send_text_message(text_message)\n number_to_send_to = text_message.receiver\n message = text_message.content\n twilio_sid = \"AC50070372767bdf26a090b08007bba07f\"\n twilio_token = \"8ae1cdbb08d55b99cab34174c3cd8bbb\"\n twilio_phone_number = \"2245209581\"\n @twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token\n @twilio_client.account.sms.messages.create(\n :from => \"+1#{twilio_phone_number}\",\n :to => number_to_send_to,\n :body => message\n )\n \n end", "def register_number(message,sms_number)\n chopped_message = message.gsub(/^\\s*reg\\s/i,'').split(\"\\s\")\n $stderr.puts chopped_message\n # check that it is length 2\n send_try_again_sms(sms_number) if chopped_message.length != 2\n register_number = chopped_message.grep(/\\d+/)\n #TODO - could make this more robust and allow for +88 too\n if register_number[0].length != 11 and register_number.grep(/^\\+1/).length != 1 #length of phone numbers in bangladesh\n send_try_again_sms(sms_number,\n \" The phone number should be 11 digits long\")\n return nil\n end\n\n register_name = chopped_message.grep(/[a-zA-Z]+/)\n\n if register_name.length == 1 and register_number.length == 1\n $stderr.puts \"meets field register reqs\"\n field_register_pharmacy(register_number,register_name,sms_number)\n else\n send_try_again_sms(sms_number)\n end\n return nil\nend", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def phone_number; end", "def phone_number; end", "def create\n twilio_sid = \"AC87d4a655d1b7f6251393db346fd69d46\"\n twilio_token = \"3a1d3e17645ced5700606682a613485d\"\n twilio_phone_number = \"2678677556\"\n \n @twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token\n \n @twilio_client.account.sms.messages.create(\n :from => \"+1#{twilio_phone_number}\",\n :to => '+919042755963',\n :body => \"This is sakthi local app\"\n )\n @employee = Employee.new(employee_params)\n \n p @employee\n p \"---------------------\"\n respond_to do |format|\n if @employee.save\n format.html { redirect_to @employee, notice: 'Employee was successfully created.' }\n format.json { render :show, status: :created, location: @employee }\n else\n format.html { render :new }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end", "def phone_params\n params.require(:phone).permit(:id, :code, :number, :description)\n end", "def set_Phone(value)\n set_input(\"Phone\", value)\n end", "def phone_to(phone_number, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end", "def phone_number\n \"(#{Helpers::FakeIt.area_code}) #{Helpers::FakeIt.exchange_code}-#{Helpers::FakeIt.subscriber_number}\"\n end", "def check_phone_no_format\n is_valid = Spree::Address.is_phone_valid?(@phone)\n render text: is_valid\n end", "def send_text(text, phone)\n account_sid = ENV[\"ACCOUNT_SID\"]\n auth_token = ENV[\"AUTH_TOKEN\"]\n client = Twilio::REST::Client.new account_sid, auth_token\n\n account = client.account\n message = account.sms.messages.create({\n :from => ENV[\"PHONE\"],\n :to => phone,\n :body => text})\n puts message\n end", "def verifyphonenumber\n tc = Twilio::REST::Client.new tsid, tauthtoken\n # Ref: https://www.twilio.com/docs/api/rest/outgoing-caller-ids\n call_delay_in_sec = 45 # Can be 0 to 60 seconds\n caller_id = tc.outgoing_caller_ids.create(:phone_number => params[:PhoneNumber], :call_delay => call_delay_in_sec)\n respond_to do |format|\n format.json { render :json => {:verification_code => caller_id.validation_code},\n :status => :ok }\n end\n end", "def send_confirmation_sms\n SmsApi.send_sms \"+1#{self.phone}\", \"Your confirmation code for StreetEats is #{self.phone_confirmation_code}\"\n end", "def phone_number\n element_with_value('PhoneNumber', opts[:phone_number])\n end" ]
[ "0.6723519", "0.64559287", "0.645273", "0.6400237", "0.6301016", "0.62924147", "0.628437", "0.627692", "0.6229558", "0.6199698", "0.617848", "0.6163542", "0.6155938", "0.61173975", "0.61073047", "0.6102288", "0.61006", "0.6095018", "0.6086288", "0.60789096", "0.6069717", "0.6053017", "0.6049383", "0.6019152", "0.600783", "0.59879094", "0.5978026", "0.596063", "0.59455657", "0.5939159", "0.5919172", "0.5905978", "0.5896282", "0.589272", "0.5887248", "0.58799213", "0.5870295", "0.58648163", "0.586481", "0.5862999", "0.58616626", "0.58489954", "0.58474666", "0.58369154", "0.58289194", "0.5816471", "0.58159167", "0.5814252", "0.5812332", "0.5810219", "0.5804526", "0.5799153", "0.5799019", "0.5793588", "0.5782117", "0.5751897", "0.5750685", "0.5745572", "0.5741452", "0.5738113", "0.573227", "0.573227", "0.57246447", "0.57239443", "0.5723887", "0.57185054", "0.5715683", "0.57104576", "0.57069016", "0.5706286", "0.5702518", "0.5699771", "0.5698014", "0.5685764", "0.5683779", "0.5673453", "0.56672347", "0.5650625", "0.5649861", "0.56488997", "0.5648137", "0.56392735", "0.56239057", "0.56225294", "0.5621358", "0.5621358", "0.5621358", "0.5621358", "0.56153435", "0.56153435", "0.5597441", "0.5595758", "0.5594554", "0.5593009", "0.55883396", "0.5582217", "0.5580971", "0.55773014", "0.5575575", "0.55736315" ]
0.8213789
0
Send an Sms with validation +sms+ is an sms active record object that responds to phone_number and full_message Refer to send_to_phone for more infomation on validation
def send_sms(sms, options={}) send_to_phone(sms.phone_number, sms.actual_message, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_and_validate_sms\n sms_service.validate_params\n end", "def sms\n \t\n \t#flash[:notice] = params\n \t#redirect_to root_path\n\n TwilioTextMessenger.new( params[:phone], params[:message]).call\n \t\n end", "def send_sms_verification_code\n number_to_send_to = phone_number\n verification_code = phone_verification_code\n sms_message_body = I18n.t(\"devise.phone.message_body\", :verification_code => verification_code)\n\n sms = Sms.new\n sms.phone_number = number_to_send_to\n sms.message = sms_message_body\n return false unless sms.send!\n\n true\n end", "def send_sms!(msg)\n return false unless sms_alerts and phone_number_is_valid? and not mobile_carrier.blank?\n PersonMailer.send_sms(self, msg).deliver\n end", "def sms\n @response, @documents = get_solr_response_for_field_values(SolrDocument.unique_key,params[:id])\n if request.post?\n url_gen_params = {:host => request.host_with_port, :protocol => request.protocol}\n tinyPass = request.protocol + request.host_with_port + catalog_path(params['id'])\n tiny = tiny_url(tinyPass)\n if params[:to]\n phone_num = params[:to].gsub(/[^\\d]/, '')\n unless params[:carrier].blank?\n if phone_num.length != 10\n flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', :to => params[:to])\n else\n email = RecordMailer.sms_record(@documents, {:to => phone_num, :carrier => params[:carrier], :callnumber => params[:callnumber], :location => params[:location], :tiny => tiny}, url_gen_params)\n end\n\n else\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')\n end\n else\n flash[:error] = I18n.t('blacklight.sms.errors.to.blank')\n end\n\n unless flash[:error]\n email.deliver\n flash[:success] = \"Text sent\"\n redirect_to catalog_path(params['id']) unless request.xhr?\n end\n end\n unless !request.xhr? && flash[:success]\n respond_to do |format|\n format.js { render :layout => false }\n format.html\n end\n end\n end", "def new; send_sms; end", "def sms(phone_number, **params)\n\n self.post(VERIFY_SMS_RESOURCE,\n phone_number: phone_number,\n **params)\n end", "def create_sms(sms) \n s = SMS.new\n s.subscriber_id = @subscriber_id\n s.subscriber_password = @subscriber_password\n s.remote_host = @remote_host if @remote_host\n s.msg_pin = sms.recipients\n s.setSourceAddr(SMS::ADDR_TYPE_NETWORK, sms.from)\n s.msg_text = sms.body\n raise StandardError.new(\"SMS Body over 140 characters, body = \\n#{sms.body}\") if sms.body.size > 140\n s\n end", "def send_sms(content, tonumber)\n tonumber = format(tonumber);\n \tbegin\n @client.messages.create({\n \t :from => @from_number,\n \t :to => tonumber,\n \t :body => content,\n })\n rescue Twilio::REST::RequestError => e\n message = I18n.t(\"errors.sms_not_sent\")\n rescue NoMethodError => e\n message = I18n.t(\"errors.sms_not_sent\")\n else\n message = I18n.t(\"notice.success\")\n end\n\n return message\n\n end", "def receive_sms\n @view = \"sms\"\n @body = params[\"Body\"]\n @phone_number = params[\"From\"]\n set_user_create_message_parse_and_point\n end", "def send_sms(message)\n api_response = \"\"\n if !self.mobile.blank?\n txtlocal = Txtlocal.find_by_sms_type(Txtlocal::GROUP_CHAT)\n if !txtlocal.nil?\n txtlocal.message_contents = message\n api_response = txtlocal.send_sms(self.mobile)\n end\n else\n api_response = \"You have not provided any mobile number. Please go to your 'Account' to set up a mobile number\"\n end\n return api_response\n end", "def send_sms(to_phone_number, message)\n # message = {to:, from:, body: \"Hello\\n\\nWorld\"}\n # binding.pry\n @@client.messages.create(\n from: @@from,\n to: to_phone_number,\n body: message\n )\n end", "def sms(body, to: nil, from: nil, method: nil, action: nil, status_callback: nil, **keyword_args)\n append(Sms.new(\n body,\n to: to,\n from: from,\n method: method,\n action: action,\n status_callback: status_callback,\n **keyword_args\n ))\n end", "def sms\n account_sid = params[:AccountSid]\n body = params[:Body]\n from = params[:From]\n from_zip = params[:FromZip]\n if from && body && # account_sid == TWILIO_ACCOUNT_SID \n sms = TwilioNet.new()\n sms.send_sms('2146680255', truncate(\"FROM:#{from} BODY:#{body}\", :length => 159) )\n render :layout => 'empty', :template => 'public/sms' \n else\n raise error \n end \n rescue\n render :text => \"Invalid Params #{params.inspect}\"\n end", "def deliver(sms)\n create_sms(sms).submit()\n end", "def send_sms_token\n if(self.phone?)\n generate_sms_token! if self.sms_confirmation_token.nil?\n ::Devise.sms_sender.send_sms(self.phone, I18n.t(:\"devise.sms_activations.sms_body\", :sms_confirmation_token => self.sms_confirmation_token, :default => self.sms_confirmation_token))\n else\n self.class.sms_confirmation_keys.each do |key|\n self.errors.add(key, :no_phone_associated)\n end\n false\n end\n end", "def sends_sms?\n false\n end", "def send_by_sms\n\t\t# ActionMailer deliverya\n\t\trecipeintNumberRaw = params[:mobile_number].gsub!(/[^0-9]/,'')\n\t\trecipeintNumberFormatted = params[:mobile_number]\n\t\t@listing = Listing.find(params[:listing_id])\n\n\t\tsms_message = 'Click to view the listing on ' + @listing.address_1 + ' ' + @listing.address_2 + ' ' + @listing.city + ' ' + @listing.state + ' ' + listing_url(@listing)\n\n\t\tsms_fu = SMSFu::Client.configure(:delivery => :action_mailer)\n\t\tsms_fu.deliver(recipeintNumberRaw, params[:carrier][0] , sms_message, :from => '[email protected]')\n\t\treturn_response = { \"status\" => \"ok\", \"number\" => recipeintNumberFormatted }\n\t\trender :json => return_response.to_json, :callback => params[:callback]\n\n\tend", "def perform (msg, to_phone, from_phone=ENV['ST_MAIN_NO'], type=SMS, next_sequence={})\n if type == MMS\n # send MMS to user\n begin\n mms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed MMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n else # SMS\n begin\n sms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed SMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n end\n end", "def send_sms(*args)\n\t\tbegin\n\t\t\tsend_sms!(*args)\n\t\t\treturn true\n\t\t\n\t\t# something went wrong\n\t\trescue Gsm::Error\n\t\t\treturn false\n\t\tend\n\tend", "def send_sms(number, subject, carrier, message)\n SMSMailer.sms_mailer(number, subject, carrier, message).deliver_now\n end", "def send\n if @to.nil? || @from.nil? || @message.nil?\n raise ArgumentError, \"You need to include 'to' and 'from' numbers and a message to send an SMS\"\n end\n to = @to.gsub(\" \",\"\")\n from = @from.gsub(\" \",\"\")\n parameters = {\n \"sms-send-to\" => to,\n \"sms-send-from\" => from,\n \"sms-message\" => @message[0..159]\n }\n request = @browser.post(\"#{VoipfoneClient::API_POST_URL}?smsSend\", parameters)\n response = parse_response(request)\n if response == \"ok\"\n return true\n else\n raise VoipfoneAPIError, response\n end\n end", "def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n recipient_phone = Phone.find_by_number(@message.number)\n \t recipient_phone ||= User.create!.phones.create!(:number => @message.number)\n @message.send_SMS(@message.raw_message, recipient_phone, \"\", @message.app.id)\n format.html { redirect_to messages_path, notice: 'Message was successfully sent.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def sms(number, message, sec=SMS_SEND_TIMEOUT)\n @logger.log(\"Sending message.\")\n\n msg = ATPhone::SMS::Message.new(message, number)\n \n # Turn on text mode\n send(\"AT+CMGF=1\")\n # Specify number\n raw_send(\"AT+CMGS=\\\"#{msg.number}\\\"\\r\")\n # send message\n raw_send(msg.text + EOM, sec)\n end", "def send_sms phone, message\n message = URI.escape message\n response = RestClient.get \"#{sender_base_url}/?from=#{@from}&to=#{phone}&text=#{message}&pass=#{@application_pass}\"\n @response = Response.new response\n end", "def sms\n account_sid = params[:AccountSid]\n body = params[:Body]\n from = params[:From]\n from_zip = params[:FromZip]\n if from && body && # account_sid == TWILIO_ACCOUNT_SID\n # sms = TwilioNet.new()\n # sms.send_sms('2146680255', truncate(\"FROM:#{from} BODY:#{body}\", :length => 159) )\n # render :layout => 'empty', :template => 'public/sms' \n creator = User.find_or_create_by_sms_number(from)\n creator.create_task(body)\n unless creator.valid?\n Rails.logger.error creator.message\n sms = TwilioNet.new()\n sms.send_sms(from, truncate(creator.message, :length => 159) )\n end\n render :text => \"Task created.\" \n else\n raise error \n end \n rescue\n render :text => \"Invalid Params #{params.inspect}\"\n end", "def sms number, message\n response = @connection.cmd \"String\" =>\"sms send #{number} #{message}\", \"Match\" => /OK|KO:(.*)/, \"Timeout\" => 5\n if response.chomp == \"OK\"\n true\n else\n raise response.chomp.sub \"KO:\",''\n end\n end", "def sms\n reply = TwilioService.new.process_inbound_sms(params)\n render_twiml_message(reply) if reply\n end", "def send_sms (text, receiver, logger) \r\n sms = Skuby::Gateway.send_sms text, receiver\r\n\r\n if sms.success? \r\n response = { status: sms.status, \r\n text: text, \r\n receiver: receiver, \r\n remaining_sms: sms.remaining_sms\r\n }\r\n response.merge! sms_id: sms.sms_id if sms.sms_id?\r\n\r\n logger.debug \"SMS SENT: #{response.to_s}\"\r\n\r\n else\r\n response = { status: sms.status, \r\n error_code: sms.error_code, \r\n error_message: sms.error_message, \r\n text: text, \r\n receiver: receiver\r\n }\r\n response.merge! sms_id: sms.sms_id if sms.sms_id?\r\n\r\n logger.error \"SMS SENT: #{response.to_s}\" \r\n end\r\n\r\n sms.success?\r\nend", "def sms\n # Give Twilio the TwiML payload instructions\n twiml_payload\n end", "def sms\n @sms ||= TermuxRubyApi::SubSystems::Sms.new(self)\n end", "def sms\n send_sms(params)\n respond_to do |format|\n format.json {render :json => {:status => :success }}\n end\n end", "def twilio_send_text_message!(client,phone_num,msg)\n begin\n sms = client.account.sms.messages.create(\n :from => TWILIO_PHONE,\n :to => phone_num,\n :body => msg)\n rescue Exception => e\n puts \"Problems with twilio:\\n#{e}\"\n end\n end", "def set_sms_send\n @sms_send = SmsSend.find(params[:id])\n end", "def set_sms_send\n @sms_send = SmsSend.find(params[:id])\n end", "def create\n @sm = Sm.new(params[:sm])\n\n respond_to do |format|\n if @sm.save\n SmsMailer.send_sms(@sm).deliver\n format.html { redirect_to @sm, notice: \"SMS Sent successfully to #{@sm.number}.\" }\n format.json { render json: @sm, status: :created, location: @sm }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sm.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_sms_message(text, to, from)\n deliver_message_via_carrier(text, to, from)\nend", "def deliver(sms)\n new.deliver!(sms)\n end", "def send_sms(params)\n self.current_params = params\n response = send_request(params)\n smart_response(response.parsed_response)\n end", "def send_to_phone(phone_obj, message, options={})\n\n if options[:skip_validation]\n phone_text = phone_obj.is_a?(ActiveRecord::Base) ? format_phone_number(phone_number) : phone_obj\n return send_message(phone_text, message, options)\n end\n\n phone_number = phone_obj.is_a?(ActiveRecord::Base) ? phone_obj :\n find_or_create_phone_number(phone_obj, options)\n\n assert_message_options!(phone_number, message, options)\n send_message(format_phone_number(phone_number), message, options)\n end", "def sms?\n message_type&.to_sym == :sms\n end", "def sms(phone_number)\n mp \"[BP Deprecated] use app.launch(sms: #{phone_number}) over app.sms\"\n launch(sms: phone_number)\n end", "def send_sms(sms_vo, opts = {})\n data, _status_code, _headers = send_sms_with_http_info(sms_vo, opts)\n data\n end", "def twilio_sms\n sms = {\n :sid => params[:SmsSid], \n :from => params[:From],\n :to => params[:To],\n :body => params[:Body],\n #:status => params[:SmsStatus], # this will be used later for confirmation with Twilio \n }\n @txt = Txt.new(sms) \n \n @status_report = TWILIO_CONFIG[\"base_url\"].to_s + '/home/twilio_status'\n\n #@txt.twilio_reply_sms\n\n respond_to do |format|\n if @txt.save and @txt.match_coupon?(sms)\n flash[:notice] = 'Message was successfully received.' \n format.xml { @txt }\n else\n flash[:notice] = 'Delivery failed.' \n format.xml { @txt }\n end\n end\n\n end", "def sms_perform(object_instance, options={})\n account = ::SmsExtension::Account.first\n consumer = AP::SmsExtension::Sms::Consumer.new(account)\n options = HashWithIndifferentAccess.new(options)\n options[:phone_number] ||= account.phone_number\n options[:outgoing_message_format] ||= account.outgoing_message_format\n options[:from_phone_number] ||= (!account.from_phone_number.blank? ? account.from_phone_number : ENV['SMS_EXTENSION_TWILIO_FROM_SMS_NUMBER'])\n\n consumer.text(options, object_instance.attributes, object_instance.class.name, options[:outgoing_message_format])\n end", "def sms(options = {})\r\n return @_message if @_sms_was_called && options.blank?\r\n\r\n m = @_message\r\n\r\n # Call all the procs (if any)\r\n default_values = {}\r\n self.class.default.each do |k,v|\r\n default_values[k] = v.is_a?(Proc) ? instance_eval(&v) : v\r\n end\r\n\r\n # Handle defaults\r\n options = options.reverse_merge(default_values)\r\n\r\n # Set configure delivery behavior\r\n wrap_delivery_behavior!(options.delete(:delivery_method), options.delete(:delivery_method_options))\r\n\r\n # Assign all options except body, template_name, and template_path\r\n assignable = options.except(:body, :template_name, :template_path)\r\n assignable.each { |k, v| m[k] = v }\r\n\r\n # Render the templates and blocks\r\n m.body = response(options)\r\n @_sms_was_called = true\r\n\r\n m\r\n end", "def create\n @message = Message.new(message_params)\n\n if @message.save\n SharpenAPI.send_sms(@message.message, @message.recipient_numbers)\n redirect_to admin_bat_signal_path, notice: 'Message was successfully sent'\n else\n format.html { render :new }\n format.json do\n render json: @message.errors, status: :unprocessable_entity\n end\n end\n end", "def send(txt, to, options = {})\n options.default = nil\n api_request(\"sendSms.php\", {\n txt: txt,\n to: to,\n idGroup: options[:idGroup],\n source: options[:source],\n flash: options[:flash],\n dateTimeSend: options[:dateTimeSend],\n onlydelivery: options[:onlydelivery],\n use_alfasource: options[:use_alfasource],\n discountID: options[:discountID],\n channel: options[:channel]\n })\n end", "def receive_sms\n uninitialize_sms\n body = params[:Body]\n phone_number = normalize_phone params[:From].strip\n @problem_text = body.split\n action = sms_parsing(body).downcase\n if action == \"join\"\n sms_create_account\n return\n elsif Account.find_by_phone_number(phone_number) == nil\n sms_send(params[:From], \"Please first create an account by texting the word 'join'.\")\n return\n end\n if !@sms_error\n case action\n when /^add$/,/^insert$/\n sms_create\n when /^accept$/\n sms_accept_problem\n when /^get$/\n @offset = false\n sms_get(0)\n when /^edit$/\n sms_edit\n when /^delete$/, /^destroy$/\n sms_delete\n when /^next$/\n offset = session[\"offset\"]\n if offset == nil\n sms_error(\"Sorry, there is no saved session right now. Please first text \\\"GET\\\" with @location !skill %number of texts you want to allow.\")\n else\n @offset = true\n sms_get(offset)\n end\n when /^detail$/, /^details$/, /^describe$/\n sms_detail\n when /^account$/\n forgot_acc\n when /^change$/\n sms_change_password\n when /^password$/\n forgot_password\n# when /^skill$/, /^skills$/\n# sms_skill\n when /^keywords$/, /^key$/, /^keys$/, /^help$/\n sms_keywords\n when /^explain$/\n sms_explain\n else\n if is_num?(action)\n session[:received_confirmation] = action\n sms_confirm_acc\n else\n sms_wrong_keyword\n end\n end\n end\n render :nothing => true\n end", "def send_sms(fromNumber)\n begin\n bodyParams = {\n from: { phoneNumber: fromNumber },\n to: [{ phoneNumber: RECIPIENT }],\n # To send group messaging, add more (max 10 recipients) 'phoneNumber' object. E.g.\n #\n #to: [\n # { phoneNumber: RECIPIENT },\n # { phoneNumber: 'Recipient-Phone-Number' }\n # ],\n text: 'Hello World!'\n }\n endpoint = \"/restapi/v1.0/account/~/extension/~/sms\"\n resp = $platform.post(endpoint, payload: bodyParams)\n puts (\"SMS sent. Message id: \" + resp.body['id'].to_s)\n check_message_status(resp.body['id'])\n rescue StandardError => e\n puts (e)\n end\nend", "def send_sms\n status = self.status\n if status.upcase == 'INTERVENTION'\n self.message\n end\n end", "def sms\n account_sid = <your account sid>\n auth_token = <your auth token>\n client = Twilio::REST::Client.new(account_sid, auth_token)\n\n client.messages.create(\n from: <twilio number>,\n to: <your number>,\n body: @message\n )\nend", "def deliver!(sms = @sms) #:nodoc:\n raise \"no SMS object available for delivery!\" unless sms\n logger.info \"Sending SMS: #{sms} via #{sms.delivery}\" unless logger.nil?\n \n begin\n send(\"perform_delivery_#{sms.delivery}\", sms) if perform_deliveries\n rescue Exception => e \n raise e if raise_delivery_errors\n end\n \n logger.info \"SMS Sent!\" unless logger.nil?\n return sms\n end", "def message_type\n 'sms'\n end", "def with_sms_verification(phone)\n # Try to find SMS verification request\n sms_verification = SmsVerification.where({ cookie: cookie, phone: phone }).first\n\n # No SMS code sent yet.\n unless sms_verification\n generate_sms_verification_code(phone)\n false\n # SMS code was already sent\n else\n # SMS code is correct\n if sms_verification.code == params[:sms_verification_code]\n reset(sms_verification)\n true\n # SMS code is incorrect\n else\n sms_verification.attempts += 1\n sms_verification.save\n\n if sms_verification.attempts >= 3\n reset(sms_verification)\n generate_sms_verification_code(phone)\n end\n\n false\n end\n end\n end", "def sms_send_params\n params.require(:sms_send).permit(:recv_num, :send_content, :state, :sms_type, :user_id)\n end", "def sms_send_params\n params.require(:sms_send).permit(:recv_num, :send_content, :state, :sms_type, :user_id)\n end", "def create\n @sms_send = SmsSend.new(sms_send_params)\n\n respond_to do |format|\n if @sms_send.save\n format.html { redirect_to @sms_send, notice: 'Sms send was successfully created.' }\n format.json { render :show, status: :created, location: @sms_send }\n else\n format.html { render :new }\n format.json { render json: @sms_send.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_twilio_mms\n # Get your Account Sid and Auth Token from twilio.com/user/account\n\n account_sid = 'add your account sid'\n auth_token = 'add your auth token'\n\n # set up a client to talk to the Twilio REST API\n client = Twilio::REST::Client.new account_sid, auth_token\n\n\n mms_message_body = \"name:#{self.contact.name}\"\n mms_message_body += \"\" #quick way to create spacing inbetween txt lines\n mms_message_body += \"phone: #{self.contact.phone_number}\"\n mms_message_body += \"\" #quick way to create spacing inbetween txt lines\n mms_message_body += \"#{self.message}\"\n end", "def create\n @sms = Sms.new(params[:sms])\n\n respond_to do |format|\n if @sms.save\n flash[:notice] = 'Sms was successfully created.'\n format.html { redirect_to(@sms) }\n format.xml { render :xml => @sms, :status => :created, :location => @sms }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sms.errors, :status => :unprocessable_entity }\n end\n end\n end", "def send_sms_confirmation!\n return false if txter_sms_blocked?\n return true if sms_confirmed?\n return false if txter_sms_phone_number.blank?\n\n confirmation_code = Txter.generate_confirmation_code\n\n # Use this class' confirmation_message method if it\n # exists, otherwise use the generic message\n message = (self.class.respond_to?(:confirmation_message) ?\n self.class :\n Txter).confirmation_message(confirmation_code)\n\n if message.to_s.size > 160\n raise ArgumentError, \"SMS Confirmation Message is too long. Limit it to 160 characters of unescaped text.\"\n end\n\n response = Txter.deliver(message, txter_sms_phone_number)\n\n if response.success?\n update_txter_sms_confirmation confirmation_code\n else\n false\n end\n end", "def validate_sms_params\n # raise\n if params[:to].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.to.blank')\n elsif params[:carrier].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')\n elsif params[:to].gsub(/[^\\d]/, '').length != 10\n flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', to: params[:to])\n elsif !sms_mappings.values.include?(params[:carrier])\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.invalid')\n elsif current_user.blank? && !@user_characteristics[:on_campus] && !verify_recaptcha\n flash[:error] = 'reCAPTCHA verify error'\n end\n\n flash[:error].blank?\n end", "def validate_sms_params\n # raise\n if params[:to].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.to.blank')\n elsif params[:carrier].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')\n elsif params[:to].gsub(/[^\\d]/, '').length != 10\n flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', to: params[:to])\n elsif !sms_mappings.values.include?(params[:carrier])\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.invalid')\n elsif current_user.blank? && !@user_characteristics[:on_campus] && !verify_recaptcha\n flash[:error] = 'reCAPTCHA verify error'\n end\n\n flash[:error].blank?\n end", "def send_user_status_sms\n user = User.find_by(:id => self.user_id)\n user.send_status_sms\n end", "def deliver_sms(params)\n#puts \"**** Message#deliver_sms; params=#{params}\"\n sms_gateway = params[:sms_gateway]\n phone_number_array = @contact_info.map {|c| c[:phone]}.compact.uniq\n phone_numbers = phone_number_array.join(',')\n assemble_sms()\n#puts \"**** sms_gateway.deliver #{sms_gateway} w #{phone_numbers}: #{sms_only}\"\n #******* CONNECT TO GATEWAY AND DELIVER MESSAGES \n gateway_reply = \n sms_gateway.deliver(phone_numbers, sms_only)\n#puts \"**** gateway_reply=#{gateway_reply}\"\n #******* PROCESS GATEWAY REPLY (INITIAL STATUSES OF SENT MESSAGES) \n gtw_msg_id = nil\n if phone_number_array.size == 1\n # SINGLE PHONE NUMBER \n if gateway_reply =~ /ID: (\\w+)/\n gtw_msg_id = $1\n gtw_msg_id = gateway_reply[4..99] # Temporary workaround as $1 doesn't work on Heroku\n msg_status = MessagesHelper::MsgSentToGateway\n else\n gtw_msg_id = gateway_reply # Will include error message\n msg_status = MessagesHelper::MsgError\n end\n # Mark the message to this member as being sent\n self.sent_messages[0].update_attributes(:gateway_message_id => gtw_msg_id, \n :msg_status => msg_status)\n else\n # MULTIPLE PHONE NUMBERS\n # Get the Clickatell reply and parse into array of hash like {:id=>'asebi9xxke...', :phone => '2345552228372'}\n#puts \"**** gateway_reply=#{gateway_reply}\"\n msg_statuses = gateway_reply.split(\"\\n\").map do |s|\n if s =~ /ID:\\s+(\\w+)\\s+To:\\s+([0-9]+)/\n {:id => $1, :phone => $2} \n else\n {:id => nil, :phone => nil, :error => s}\n end\n end\n # Make array to associate members with their numbers\n @member_phones = self.members.map {|m| {:phone => m.primary_phone, :member => m} }\n # Update the sent_message records to indicate which have been accepted at Gateway \n msg_statuses.each do |s|\n#puts \"**** s[:id]=#{s[:id]}, s[:phone]=#{s[:phone]}\"\n if s[:id] && s[:phone]\n # Find the right member by matching phone numbers\n member = @member_phones.find{|m| m[:phone]==s[:phone]}[:member]\n # Find the right sent_message by matching member & message\n sent_message = SentMessage.where(:member_id=>member.id, :message_id=>self.id).first\n # Update the sent_message\n sent_message.update_attributes(\n :gateway_message_id => s[:id], \n :msg_status=> MessagesHelper::MsgSentToGateway\n )\n end\n end\n # Any sent_messages not now marked with gateway_message_id and msg_status must have errors\n sent_messages.each do |m| \n m.update_attributes(:msg_status=> MessagesHelper::MsgError) if m.msg_status.nil?\n end\n end\n end", "def sms=(arg)\n raise ArgumentError, \"sms expects a string, not a #{arg.class}\" unless arg.is_a?(String)\n @sms = arg\n end", "def create\n\n begin\n\n text = params[\"Content\"]\n\n if !text.downcase.start_with?(\"test\")\n mobile = params[\"MSISDN\"]\n if !mobile.start_with?(\"+\")\n mobile = \"+#{mobile}\"\n end\n\n service = SmsService.new\n\n @message = SmsService.handle_sms_sending(text, mobile)\n\n render text: 'success', status: 200\n else\n if Rails.env == \"production\"\n msg = text.split(\" \")[1]\n HTTParty.post(ENV['DEVELOPEMENT_SERVER_URL'], :query => { \"Content\" => msg, \"MSISDN\" => params[\"MSISDN\"] })\n end\n render text: 'success', status: 200\n end\n rescue => error\n respond_to do |format|\n format.all { render json: (@message.errors if [email protected]?), status: :unprocessable_entity }\n end\n end\n end", "def sendSMS(to, body = \"No body was send for this message.\", media = nil)\n\naccount_sid = $accountsid\nauth_token = $authtoken\n@client = Twilio::REST::Client.new(account_sid, auth_token)\n\nif media\n message = @client.messages.create(\n body: body,\n from: $phone,\n media_url: [media],\n to: to\n)\nelse\n message = @client.messages.create(\n body: body,\n from: $phone,\n to: to\n)\nend\nreturn message.sid\nend", "def send!(message)\n if(self.msisdn_number.blank?)\n if(info = get_sim_info)\n self.update_attribute(:msisdn_number, response[:msisdn])\n end\n end\n\n JasperSmsGateway.send(self.msisdn_number, message)\n end", "def sms_params\n params.permit(:message)\n end", "def send(user, number, message, phone=nil)\n phone = Behaviour.select_phone(number, user['behaviour']) if phone.nil?\n if phone #se fizer match com os existentes\n `gammu-smsd-inject -c ~/.sms/gammu-smsdrc-#{phone} TEXT #{number} -text \"#{message}\"` # send to daemon\n #LOGIT que foi para a fila\n else \n #LOGIT que alguem tentou mas nao foi para a fila\n end\n end", "def send_now(mnobj = nil, recipient_sms_numbers: nil, generated_text: nil, importance: nil, logger: nil)\n logger ||= Rails.logger\n\n importance ||= self.class.importance\n\n resp = []\n if recipient_sms_numbers\n logger.info 'Sending sms to a defined set of recipients'\n elsif mnobj\n logger.info \"Sending sms for #{mnobj.id}\"\n else\n raise FphsException, 'No message notification or recipient list set for SMS send'\n end\n\n recipient_sms_numbers ||= mnobj.recipient_sms_numbers\n generated_text ||= mnobj.generated_text\n\n raise FphsException, 'No recipients to SMS' unless recipient_sms_numbers&.present?\n\n recipient_sms_numbers.each do |sms_number|\n val = PhoneValidation.validate_sms_number_format sms_number, no_exception: true\n\n if val\n res = send_sms sms_number, generated_text, importance\n resp << { aws_sns_sms_message_id: res.message_id } if res\n else\n resp << { error: BadFormatMsg }\n end\n end\n\n resp.to_json\n end", "def send_sms(destination, message, params = {})\n execute_operation(:send_sms, { destination: destination, message: message, params: params } )\n end", "def send_text_message(text_message)\n number_to_send_to = text_message.receiver\n message = text_message.content\n twilio_sid = \"AC50070372767bdf26a090b08007bba07f\"\n twilio_token = \"8ae1cdbb08d55b99cab34174c3cd8bbb\"\n twilio_phone_number = \"2245209581\"\n @twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token\n @twilio_client.account.sms.messages.create(\n :from => \"+1#{twilio_phone_number}\",\n :to => number_to_send_to,\n :body => message\n )\n \n end", "def send_text(sms, phones)\n phones.each do |phone|\n post_response = Faraday.post do |request|\n request.url \"https://api.twilio.com/2010-04-01/Accounts/#{ACCOUNT_SID}/SMS/Messages.json\"\n request.headers['Authorization'] = \"Basic \" + Base64.strict_encode64(\"#{ACCOUNT_SID}:#{AUTH_TOKEN}\")\n request.body = URI.encode_www_form({'From' => PHONE_NUMBER, 'To' => phone.phone_number, 'Body' => sms.message})\n end\n end\n end", "def huzzah\n # ===========================================================================\n # 6. Send an SMS Message to 415-555-1212\n # uses a HTTP POST, and a new variable t for the information (because it needs \"Body\")\n \n account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)\n \n t = {\n 'From' => CALLER_ID,\n 'To' => phone,\n 'Body' => message\n }\n resp = account.request(\"/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages\",\n \"POST\", t)\n end", "def send_confirmation_sms\n SmsApi.send_sms \"+1#{self.phone}\", \"Your confirmation code for StreetEats is #{self.phone_confirmation_code}\"\n end", "def send_sms_with_http_info(sms_vo, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SMSApi.send_sms ...'\n end\n # verify the required parameter 'sms_vo' is set\n if @api_client.config.client_side_validation && sms_vo.nil?\n fail ArgumentError, \"Missing the required parameter 'sms_vo' when calling SMSApi.send_sms\"\n end\n # resource path\n local_var_path = '/sms'\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(sms_vo)\n auth_names = ['oauth2']\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 => 'SMSResponseVO')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SMSApi#send_sms\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def twilio\n @number = params[:phone_number]\n \n #Text message info\n t = {\n \n 'From' => CALLER_ID,\n 'To' => @number,\n 'Body' => (\"Visit uhpartments.com when you walk through an apartment\")\n }\n\n begin\n account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)\n resp = account.request(\"/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages\",\n 'POST',\n t)\n resp.error! unless resp.kind_of? Net::HTTPSuccess\n rescue StandardError => bang\n #This area will be called if an error happens with the Twilio API\n flash[:alert] = \"Bad number.\"\n redirect_to({ :action => :home })\n \n return\n end\n\n redirect_to({ :action => :home, :alert => \"SMS sent.\" })\n end", "def send_to_phone\n if params[:level_source] && params[:phone] && (level_source = LevelSource.find(params[:level_source]))\n send_sms(level_source, params[:phone])\n render status: :ok, nothing: true\n else\n render status: :not_acceptable, nothing: true\n end\n end", "def send_message\n unless message_sent\n twilio_client.messages.create(\n from: ENV.fetch(\"TWILIO_PHONE_NUMBER\"),\n to: contact.phone_number,\n body: content,\n )\n update(message_sent: true)\n end\n end", "def send_message(phone_number, message)\n command = Command.new('SendSMSBasic', license_key)\n MessageStatus.new(\n Response.parse(\n command.execute({:PhoneNumber => phone_number, :Message => message})\n )[\"SmsReturn\"]\n )\n end", "def create\n @message = Message.new(message_params)\n if @message.save\n @message.action = 'SEND'\n @message.save\n\n # Send SMS text\n boot_twilio\n sms = @client.messages.create(\n body: @message.text,\n from: Rails.application.secrets.twilio_number,\n to: @message.number,\n )\n redirect_to @message, alert: \"SMS Text sent.\"\n else\n render 'new'\n end\n end", "def sms_to(phone_number, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end", "def create \n @message = Message.new({\n incoming: true,\n sid: params['SmsSid'],\n to: params['To'],\n from: params['From'],\n body: params['Body']\n })\n \n respond_to do |format|\n if @message.save\n \n reply = (@message.body.downcase.strip == 'b') ? 'Have a nice day, honey!' : 'Uh oh, we are calling mum...'\n \n response = Twilio::TwiML::Response.new do |r|\n r.Sms reply\n end\n \n Rails.logger.info response.text\n \n user = User.normalise_and_find(params['From'])\n \n if user\n alert = user.alerts.where(:sid => nil).order(\"start asc\").limit(1)\n \n if alert.length == 1\n alert = alert.first\n \n if @message.body.downcase.strip == 'b'\n alert.sid = \"CHECKED\"\n alert.save\n else\n alert.delay.call(alert_url(alert, :format => :xml))\n end\n end\n end\n \n format.xml { render :text => response.text }\n else\n raise \"Can't save!\"\n end\n end\n end", "def create\n to = params[:to]\n\n unless to\n raise IOError, \"Incorrect params for sending text message\" \n end\n\n @client = Twilio::REST::Client.new(\n CONFIG[:twilio_account_sid],\n CONFIG[:twilio_auth_token])\n\n @account = @client.account\n @message = @account.sms.messages.create({\n :from => CONFIG[:twilio_phone_number],\n :to => to,\n :body => \"Happy Mining! #{CONFIG[:ios_app_link]}\"}) \n\n rescue => ex\n handle_exception(ex)\n ensure\n respond_to do |format|\n format.json\n end\n end", "def perform(message, to_number)\n logger.info \"Sending message to #{to_number}\"\n TwilioService.new({\n to: to_number,\n msg: message\n }).send_sms\n end", "def send_message(phone_number, message, options={})\n raise SmsOnRails::SmsError.new(\"Override send_message in subclass #{self.class}\")\n end", "def execute\n if Rails.env == 'production' || Rails.env == 'staging' || dev_mode\n # TODO these should be in env vars, not hard-coded here\n account_sid = 'AC38de11026e8717f75248f84136413f7d'\n auth_token = 'f82546484dc3dfc96989f5930a13e508'\n \n begin\n @client = Twilio::REST::Client.new account_sid, auth_token\n sms = @client.account.messages.create({\n from: sender,\n to: \"+44#{recipient}\",\n body: message_body\n })\n rescue Twilio::REST::RequestError => e\n errors.add(\"Code: #{e.code.to_s}.\", e.to_s)\n rescue SocketError => e\n errors.add(:network, 'is disconnected. Please check your connection.')\n end\n \n return sms\n end\n end", "def send_sms(sender, numbers, text, **params)\n # Create the send XMLmarkup\n estimate_cost = estimate_cost(numbers, text)\n return -1 if estimate_cost == -1\n\n if estimate_cost < get_balance\n identity = \"#{Time.now.to_i}#{rand(1000000000..9999999999)}\"\n batchID = @company + \"+\" + identity\n is_persian_text = is_persian(text)\n msgClass = params[\"flash\"] ? \"0\" : \"1\"\n dcs = is_persian_text ? \"8\" : \"0\"\n binary = is_persian_text ? \"true\" : \"false\"\n text = text.to_h if is_persian_text\n\n builder = Builder::XmlMarkup.new()\n builder.instruct! :xml, version: \"1.0\", encoding: \"UTF-8\"\n builder.declare! :DOCTYPE, :smsBatch, :PUBLIC, \"-//PERVASIVE//DTD CPAS 1.0//EN\", \"http://www.ubicomp.ir/dtd/Cpas.dtd\"\n builder.smsBatch(company: @company, batchID: batchID) do |b|\n b.sms(msgClass: msgClass, binary: binary, dcs: dcs) do |t|\n numbers.each do |number|\n t.destAddr() do |f|\n f.declare! \"[CDATA[%s]]\" % number\n end\n end\n t.origAddr() do |f|\n f.declare! \"[CDATA[%s]]\" % sender\n end\n t.message() do |f|\n f.declare! \"[CDATA[#{text}]]\"\n end\n end\n end\n\n out_xml = builder.target!\n\n result = send_xml(out_xml)\n\n source = XML::Parser.string(result)\n content = source.parse\n\n if content.find_first('ok')\n if content.find_first('ok').content.include? 'CHECK_OK'\n @errors = nil\n batchID\n else\n @errors = \"Something going wrong\"\n nil\n end\n else\n @errors = content.find_first('message').content.strip\n nil\n end\n else\n @errors = 'Not enough balance'\n nil\n end\n end", "def send_sms(sms_number, msg_text, importance)\n # Use a fixed test number for dev and test (non production) environments\n sms_number = self.class.test_sms_number unless Rails.env.production?\n\n raise FphsException, \"Invalid SMS importance: #{importance}\" unless valid_importance?(importance)\n\n aws_sns_client.publish(\n phone_number: sms_number,\n message: msg_text,\n message_attributes: {\n 'AWS.SNS.SMS.SenderID' => {\n data_type: 'String',\n string_value: self.class.sender_id\n },\n 'AWS.SNS.SMS.SMSType' => {\n data_type: 'String',\n string_value: importance\n }\n }\n )\n end", "def confirm_sms!\n unless_sms_confirmed do\n self.sms_confirmation_token = nil\n self.sms_confirmed_at = Time.now\n save(:validate => false)\n end\n end", "def twiml\n sms = { from: params[:From],\n to: params[:To],\n body: params[:Body] }\n\n from_user = User.find_by_phone_number(params[:From])\n sms[:from_user_id] = from_user.id if from_user\n to_user = User.find_by_phone_number(params[:To])\n sms[:to_user_id] = to_user.id if to_user\n\n # save the message into the DB\n @sms = Sms.create(sms)\n from_user = @sms.from_user\n\n # response logic\n # if from_user && from_user.response.nil?\n # if sms[:body].downcase.include?(\"yes\")\n # twilio.respond_to_yes(sms[:from])\n # from_user.response = true\n # from_user.save\n # elsif sms[:body].downcase.include?(\"no\")\n # twilio.send_sms(sms[:from], \"Got it. Have a great day!\")\n # from_user.response = false\n # from_user.save\n # end\n # end\n\n # Empty response to Twilio (Do nothing more)\n render xml: Twilio::TwiML::Response.new.text\n end", "def send_sms\n puts \"Send a message.\"\nend", "def send_sms number, message, opts={}\r\n wait =!(opts[:nowait] || false)\r\n encode = opts[:encode] || :ascii\r\n sender = opts[:sender] || false\r\n datetime = opts[:date] || false\r\n\r\n case encode\r\n when :binary || :base64\r\n encode = 'B'\r\n when :unicode\r\n encode = 'U'\r\n else # :ascii\r\n encode = ''\r\n end\r\n\r\n if sender\r\n sender = \"#{sender} \"\r\n custom = 'F'\r\n else\r\n custom = ''\r\n end\r\n\r\n if datetime\r\n datetime = \"#{datetime} \"\r\n date = 'D'\r\n else\r\n date = ''\r\n end\r\n\r\n cmd_raw \"#{date}#{custom}#{encode}SUBMIT\", \"#{datetime}#{sender}#{number} #{message}\"\r\n\r\n if wait\r\n wait_for last_label\r\n return false if @response_cmd.eql? 'NOOK'\r\n return \"#{@response_args[0]}.#{@response_args[1]}\".to_f\r\n end\r\n end", "def sms_message(number,\r\n message,\r\n country_code = nil)\r\n # Prepare query url.\r\n _path_url = '/sms-message'\r\n _query_builder = Configuration.get_base_uri\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 }\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'output-case' => 'camel',\r\n 'number' => number,\r\n 'message' => message,\r\n 'country-code' => country_code\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: _parameters\r\n )\r\n CustomQueryAuth.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)\r\n SMSMessageResponse.from_hash(decoded)\r\n end", "def set_smsno\n @smsno = Smsno.find(params[:id])\n end", "def create\n # create an incoming sms object\n sms = Sms::Message.create(:from => params[:sms_test][:from], :body => params[:sms_test][:body], :mission => current_mission)\n\n # submit it to the handle method over in the SmsController and get the reply\n reply = SmsController.handle_sms(sms)\n\n # save the reply and let the sent_at default to now\n reply.save if reply\n\n # render the body of the reply\n render :text => reply ? reply.body : \"<em>#{t('sms_console.no_reply')}</em>\".html_safe\n end", "def text(options, params, object_name, format=\"\")\n body = \"\"\n if format.empty?\n outgoing_text_option = @account.outgoing_text_options.where(:name => object_name).first\n # Find the format string from fields that were passed.\n body = outgoing_text_option.build_text(object_name, params)\n else\n body = format\n end\n\n from_phone_number = options[:from_phone_number]\n phone_number = options[:phone_number]\n\n begin\n twilio_account.sms.messages.create(:from => from_phone_number, :to => phone_number, :body => body)\n rescue\n Rails.logger.error \"Unable to send SMS...: #{$!.message}\"\n Rails.logger.error $!.backtrace.join(\"\\n\")\n raise\n end\n ::SmsExtension::Message.create(:from => from_phone_number, :to => phone_number, :body => body)\n end", "def send_sms!(msg, allow_multiple = false)\n if msg.to_s.size > 160 && !allow_multiple\n raise ArgumentError, \"SMS Message is too long. Either specify that you want multiple messages or shorten the string.\"\n end\n return false if msg.to_s.strip.blank? || txter_sms_blocked?\n return false unless sms_confirmed?\n\n # split into pieces that fit as individual messages.\n msg.to_s.scan(/.{1,160}/m).map do |text|\n if Txter.deliver(text, txter_sms_phone_number).success?\n text.size\n else\n false\n end\n end\n end" ]
[ "0.7531832", "0.7422945", "0.7406239", "0.73494947", "0.7317686", "0.72133756", "0.7177639", "0.7120962", "0.7114795", "0.7044778", "0.7029981", "0.7023073", "0.70016986", "0.6957868", "0.69455945", "0.69433737", "0.6924345", "0.6900544", "0.68777055", "0.68578756", "0.6857518", "0.68391764", "0.68286574", "0.67914116", "0.6769672", "0.6765303", "0.6764211", "0.67606914", "0.6749733", "0.67140645", "0.6712823", "0.6685724", "0.6672046", "0.6659401", "0.6659401", "0.66355765", "0.6629768", "0.66236055", "0.66058064", "0.66014373", "0.65943205", "0.6583588", "0.65811056", "0.656358", "0.6548242", "0.6547611", "0.65379304", "0.6537006", "0.6532779", "0.6520738", "0.65134454", "0.6507065", "0.6485735", "0.64795053", "0.64414144", "0.6426111", "0.6426111", "0.6419178", "0.6403997", "0.6401806", "0.6393812", "0.6392697", "0.6392697", "0.63905567", "0.6380611", "0.63791585", "0.63650537", "0.6355888", "0.6344326", "0.6330668", "0.631522", "0.6278663", "0.6277149", "0.62767303", "0.62623996", "0.6257819", "0.62460136", "0.62431145", "0.6232274", "0.6224673", "0.6215979", "0.6215778", "0.6211444", "0.61986053", "0.61957204", "0.6181352", "0.61802477", "0.6179407", "0.6169131", "0.61571294", "0.6150934", "0.61476594", "0.6138334", "0.6130999", "0.61208105", "0.61116934", "0.6108053", "0.60951006", "0.60884976", "0.6086278" ]
0.77748454
0
can override in subclass if different finder should be used
def find_or_create_phone_number(phone_text, options={}) phone = phone_klass.find_and_create_by_number(phone_text) phone.assign_carrier(options[:carrier]) if options[:carrier] phone end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finder_methods; end", "def find(object, parent = @base)\n raise NotImplementedError, \"Subclasses must implement public method find\"\n end", "def method_for_find\n resources_configuration[:self][:finder] || :find\n end", "def method_missing(name, *args)\n if self.finders.has_key?(name)\n return self.finders[name].get\n end\n\n super\n end", "def find_by()\n\n end", "def finder_method\n config[:child_finder]\n end", "def finder(criteria)\n @finder = criteria\n end", "def method_missing(method_id, *arguments)\n if match = /find_(all_by|by)_([_a-zA-Z]\\w*)/.match(method_id.to_s)\n finder = determine_finder(match)\n\n facets = extract_attribute_names_from_match(match)\n super unless all_attributes_exists?(facets)\n\n #Overrride facets to use appropriate attribute name for current locale\n facets.collect! {|attr_name| respond_to?(:globalize_facets) && globalize_facets.include?(attr_name.intern) ? localized_facet(attr_name) : attr_name}\n\n attributes = construct_attributes_from_arguments(facets, arguments)\n\n case extra_options = arguments[facets.size]\n when nil\n options = { :conditions => attributes }\n set_readonly_option!(options)\n ActiveSupport::Deprecation.silence { send(finder, options) }\n\n when Hash\n finder_options = extra_options.merge(:conditions => attributes)\n validate_find_options(finder_options)\n set_readonly_option!(finder_options)\n\n if extra_options[:conditions]\n with_scope(:find => { :conditions => extra_options[:conditions] }) do\n ActiveSupport::Deprecation.silence { send(finder, finder_options) }\n end\n else\n ActiveSupport::Deprecation.silence { send(finder, finder_options) }\n end\n\n else\n raise ArgumentError, \"Unrecognized arguments for #{method_id}: #{extra_options.inspect}\"\n end\n elsif match = /find_or_(initialize|create)_by_([_a-zA-Z]\\w*)/.match(method_id.to_s)\n instantiator = determine_instantiator(match)\n facets = extract_attribute_names_from_match(match)\n super unless all_attributes_exists?(facets)\n\n if arguments[0].is_a?(Hash)\n attributes = arguments[0].with_indifferent_access\n find_attributes = attributes.slice(*facets)\n else\n find_attributes = attributes = construct_attributes_from_arguments(facets, arguments)\n end\n options = { :conditions => find_attributes }\n set_readonly_option!(options)\n\n find_initial(options) || send(instantiator, attributes)\n else\n super\n end\n end", "def find\n super.first\n end", "def find\n fail NotImplementedError\n end", "def find_on_extension(*args)\n if extended?\n define_extended_class\n finder_type, options = args.first, args.extract_options!\n options = prepare_extended_options(options, finder_type)\n sql = construct_finder_sql(options)\n sql = replace_tables_text(sql)\n result = find_by_sql(sql)\n preload_associations(result, options[:include]) if options[:include]\n [:first,:last].include?(finder_type) ? result.first : result\n else\n find(*args)\n end\n end", "def method_missing(method, *args, &block)\n if name?(method.to_sym)\n find(method.to_sym)\n else\n super\n end\n end", "def find\n raise \"Method not implemented\"\n end", "def method_missing(method, *args)\n begin\n if method != :find_by_symbol\n if obj = find_by_symbol(method)\n redefine_method method do\n find_by_symbol(method)\n end\n return obj\n end\n end\n rescue\n # Ignore errors, and call super\n end\n super\n end", "def method_missing(method, *args)\n if method =~ /find/\n finder = method.to_s.split('_by_').first\n attributes = method.to_s.split('_by_').last.split('_and_')\n\n chain = Dynamoid::Criteria::Chain.new(self)\n chain.query = Hash.new.tap {|h| attributes.each_with_index {|attr, index| h[attr.to_sym] = args[index]}}\n \n if finder =~ /all/\n return chain.all\n else\n return chain.first\n end\n else\n super\n end\n end", "def finder(*finders)\r\n finders.each do |finder|\r\n instance_eval <<CODE, __FILE__, __LINE__ + 1\r\n#--\r\n# FIXME: This can probably be refactored as:\r\n#\r\n# scoped(args.extract_options!).\\#{finder} *args, &block\r\n#++\r\ndef #{finder}(*args, &block)\r\n options = args.extract_options!\r\n\r\n validate_limit! options\r\n validate_offset! options\r\n\r\n version = options.delete :version\r\n format = options.delete :format\r\n\r\n unless (input = options.delete(:filter)).blank?\r\n query = filter(version)[input]\r\n end\r\n\r\n validate_order!(for_finding = options.dup)\r\n if for_finding[:include]\r\n for_finding[:include] = translate_include for_finding[:include], version\r\n end\r\n\r\n result = model.scoped(query || {}).#{finder} *(args << for_finding), &block\r\n\r\n case result\r\n when nil\r\n # nil\r\n when ActiveRecord::Base\r\n new result, version, format, options.slice(:limit, :include)\r\n when Array\r\n options.update :filter => input if input\r\n\r\n Restful::Resource::Collection.new result.map { |resource|\r\n new resource, version, format\r\n }, format, model.table_name, options\r\n end\r\nend\r\nCODE\r\n end\r\n end", "def finder_methods=(_arg0); end", "def find\n model_class.filterrific_find(self)\n end", "def finder_for(meth)\n # SEQUEL5: Remove\n unless finder = (frozen? ? @finders[meth] : Sequel.synchronize{@finders[meth]})\n finder_loader = @finder_loaders.fetch(meth)\n finder = finder_loader.call(self)\n Sequel.synchronize{@finders[meth] = finder}\n end\n finder\n end", "def find_all\n finder_or_run(:find_all)\n end", "def find; end", "def method_missing(m,*args)\n #find_by_name(\"John\") returns first YamlContentBase object that matches\n if m.to_s.index(\"find_by\") == 0\n attribute = m.to_s.gsub(\"find_by_\",\"\")\n return self.detect{|x| x.send(attribute) == args[0]}\n #find_all_by_name(\"John\") returns array of YamlContentBase objects that match\n elsif m.to_s.index(\"find_all_by\") == 0\n attribute = m.to_s.gsub(\"find_all_by_\",\"\")\n return self.select{|x| x.send(attribute) == args[0]}\n end\n raise \"'#{m}' is not a method\"\n end", "def find method=:all, options={}\r\n if method.is_a? Hash\r\n options = method\r\n method= :all\r\n end\r\n if @scope\r\n model_class.send(:with_scope, @scope) {model_class.find method, find_options(options)}\r\n else\r\n model_class.find method, find_options(options)\r\n end\r\n end", "def method_missing(method_name, *args)\n\n method = method_name.to_s\n\n if method.end_with? '!'\n method.chop!\n error_on_empty = true\n end\n\n if method.start_with? 'find_all_by_'\n attribs = method.gsub /^find_all_by_/, ''\n elsif method.start_with? 'find_by_'\n attribs = method.gsub /^find_by_/, ''\n limit(1)\n elsif method.start_with? 'find_first_by_'\n limit(1)\n find_first = true\n attribs = method.gsub /^find_first_by_/, ''\n elsif method.start_with? 'find_last_by_'\n limit(1)\n find_last = true\n attribs = method.gsub /^find_last_by_/, ''\n else\n super\n end\n\n attribs = attribs.split '_and_'\n conditions = {}\n attribs.each { |attr| conditions[attr] = args.shift }\n\n where(conditions, *args)\n load\n raise RecordNotFound if error_on_empty && @records.empty?\n return @records.first if limit_value == 1\n @records\n end", "def method_for_find\n :find_by_slug!\n end", "def respond_to_missing?(method, include_private = false) #OK\n (method.to_s.start_with? \"find_by_\") || super\n end", "def find(*args)\n return super if block_given?\n find_with_ids(*args)\n end", "def find(*args)\n Collection.new(super, @mapped_collection)\n end", "def define_find_method(name, builder)\n define_helper \"find_#{name}\", ->(id) { builder.find(id) }\n end", "def def_finder_method(mod, meth, type)\n # SEQUEL5: Remove\n mod.send(:define_method, meth){|*args, &block| finder_for(meth).send(type, *args, &block)}\n end", "def prepared_finder(meth=OPTS, opts=OPTS, &block)\n # SEQUEL5: Remove\n if block\n raise Error, \"cannot pass both a method name argument and a block of Model.finder\" unless meth.is_a?(Hash)\n meth = meth.merge(:prepare=>true)\n else\n opts = opts.merge(:prepare=>true)\n end\n finder(meth, opts, &block)\n end", "def find_by(field, value)\n @base.send('find_by_' + field, value)\n end", "def find item\n\tend", "def finder_method(name, &block)\n singleton_class.send(:define_method, :\"__secure_remote_access_to__#{name}\") do |this, acting_user, *args|\n this = respond_to?(:acting_user) ? this : all\n begin\n old = this.acting_user\n this.acting_user = acting_user\n # returns a PsuedoRelationArray which will respond to the\n # __secure_collection_check method\n ReactiveRecordPsuedoRelationArray.new([*this.instance_exec(*args, &block)])\n ensure\n this.acting_user = old\n end\n end\n singleton_class.send(:define_method, \"_#{name}\") do |*args|\n all.instance_exec(*args, &block)\n end\n singleton_class.send(:define_method, name) do |*args|\n all.instance_exec(*args, &block)\n end\n end", "def find_models\n raise_must_override\n end", "def rest_find_by_name_or_id(parent_id, val)\n # use explicitly defined finders\n # else default to new generic CliCommand find_by methods\n if rest_has_name\n if respond_to?(\"find_#{rest_key}_by_name_or_id\", true)\n send(\"find_#{rest_key}_by_name_or_id\", parent_id, val)\n else\n find_by_name_or_id(rest_key, parent_id, val)\n end\n else\n if respond_to?(\"find_#{rest_key}_by_id\", true)\n send(\"find_#{rest_key}_by_id\", parent_id, val)\n else\n find_by_id(rest_key, parent_id, val)\n end\n end\n end", "def find_record_by(model)\n raise_must_override\n end", "def find(id)\n raise NotImplementedError\n end", "def method_missing(name, *args)\n dyna = DynamicFinder.new(name, *args)\n finder, conditions = dyna.finder, dyna.conditions\n results = find(finder, :conditions => conditions)\n results ? results : dyna.create(self)\n end", "def find_with_ferret(q, options = {}, find_options = {})\n options[:lazy] = true\n super\n end", "def method_missing(method_id, *arguments, &block)\n if match = ActiveRecord::DynamicFinderMatch.match(method_id)\n attribute_names = match.attribute_names\n super unless all_attributes_exist?(attribute_names)\n if !arguments.first.is_a?(Hash) && arguments.size < attribute_names.size\n ActiveSupport::Deprecation.warn(\n \"Calling dynamic finder with less number of arguments than the number of attributes in \" \\\n \"method name is deprecated and will raise an ArguementError in the next version of Rails. \" \\\n \"Please passing `nil' to the argument you want it to be nil.\"\n )\n end\n if match.finder?\n options = arguments.extract_options!\n relation = options.any? ? scoped(options) : scoped\n relation.send :find_by_attributes, match, attribute_names, *arguments\n elsif match.instantiator?\n scoped.send :find_or_instantiator_by_attributes, match, attribute_names, *arguments, &block\n end\n elsif match = ActiveRecord::DynamicScopeMatch.match(method_id)\n attribute_names = match.attribute_names\n super unless all_attributes_exist?(attribute_names)\n if arguments.size < attribute_names.size\n ActiveSupport::Deprecation.warn(\n \"Calling dynamic scope with less number of arguments than the number of attributes in \" \\\n \"method name is deprecated and will raise an ArguementError in the next version of Rails. \" \\\n \"Please passing `nil' to the argument you want it to be nil.\"\n )\n end\n if match.scope?\n self.class_eval <<-METHOD, __FILE__, __LINE__ + 1\n def self.#{method_id}(*args) # def self.scoped_by_user_name_and_password(*args)\n attributes = Hash[[:#{attribute_names.join(',:')}].zip(args)] # attributes = Hash[[:user_name, :password].zip(args)]\n scoped(:conditions => attributes) # scoped(:conditions => attributes)\n end # end\n METHOD\n send(method_id, *arguments)\n end\n else\n super\n end\n end", "def find(_index_value)\n raise \"Implement in subclass\"\n end", "def find(*args)\n records = super\n @after.call(records) if @after\n records\n end", "def find(*args, &block)\n if args.first.is_a?(Hash)\n super(*args, &block)\n else\n super(id: args)\n end\n end", "def where(*args)\n #self.class.new(layout, layout.find(*args), args)\n get_results(:find, args)\n end", "def find(id)\n finder_or_run(:find, id)\n end", "def find(id)\n fetch([name, id]) do\n super\n end\n end", "def find(query); end", "def find(query); end", "def find_records(predicate)\n raise_must_override\n end", "def find_on_create\n write_inheritable_attribute :find_on_create, true\n end", "def find_all\n fail NotImplementedError\n end", "def find_by_author(author)\n raise \"Must be overridden\"\n end", "def method_missing(method_name, *args, &block)\r\n if model\r\n scopes = ActiveRecord::Base.scopes.merge(model.scopes).keys\r\n\r\n if scopes.include? method_name\r\n return Restful::Resource::Scope.new self, method_name, model, args,\r\n block\r\n elsif method_name.to_s =~ /^(?:find(?:_all)?|first|last)_by_/\r\n finder method_name\r\n return send method_name, *args, &block\r\n end\r\n end\r\n\r\n super\r\n end", "def method_missing msg, *args, &block\n model = begin;\n Object.const_get msg\n rescue NameError\n end\n \n if model and model.respond_to?(:descends_from_active_record?) and model.descends_from_active_record?\n model.find args.first\n else\n super\n end\nend", "def find(options = {})\n tmp = nil\n @member_class.with_scope(options) do\n tmp = @owner.send(@find_proc, @find_options)\n end\n return tmp\n end", "def find(*args)\n select(*args)\n\n=begin\n\n options = args.last.is_a?(Hash) ? args.pop : {}\n case args.first\n when :all then find_every options\n when :first then find_initial options\n else find_from_ids args, options\n end\n\n=end\n\n end", "def method_missing(method_id, *arguments, &block)\n if match = DynamicFinderMatch.match(method_id)\n attribute_names = match.attribute_names\n super unless all_attributes_exists?(attribute_names)\n if match.finder?\n finder = match.finder\n bang = match.bang?\n self.class_eval <<-EOS, __FILE__, __LINE__ + 1\n def self.#{method_id}(*args)\n options = args.extract_options!\n attributes = construct_attributes_from_arguments(\n [:#{attribute_names.join(',:')}],\n args\n )\n finder_options = { :conditions => attributes }\n validate_find_options(options)\n\n #{'result = ' if bang}if options[:conditions]\n with_scope(:find => finder_options) do\n find(:#{finder}, options)\n end\n else\n find(:#{finder}, options.merge(finder_options))\n end\n #{'result || raise(RecordNotFound, \"Couldn\\'t find #{name} with #{attributes.to_a.collect {|pair| \"#{pair.first} = #{pair.second}\"}.join(\\', \\')}\")' if bang}\n end\n EOS\n send(method_id, *arguments)\n elsif match.instantiator?\n instantiator = match.instantiator\n self.class_eval <<-EOS, __FILE__, __LINE__ + 1\n def self.#{method_id}(*args)\n attributes = [:#{attribute_names.join(',:')}]\n protected_attributes_for_create, unprotected_attributes_for_create = {}, {}\n args.each_with_index do |arg, i|\n if arg.is_a?(Hash)\n protected_attributes_for_create = args[i].with_indifferent_access\n else\n unprotected_attributes_for_create[attributes[i]] = args[i]\n end\n end\n\n find_attributes = (protected_attributes_for_create.merge(unprotected_attributes_for_create)).slice(*attributes)\n\n options = { :conditions => find_attributes }\n\n record = find(:first, options)\n\n if record.nil?\n record = self.new(unprotected_attributes_for_create)\n #{'record.save' if instantiator == :create}\n record\n else\n record\n end\n end\n EOS\n send(method_id, *arguments, &block)\n end\n else\n super\n end\n end", "def find(id)\n\nend", "def find(*args, **options, &optional_filter_block)\n LOG.info(\"Capybara find #{args.join(' ')}\")\n super\n end", "def find(args, mode); end", "def find_with(*values)\n if values.blank?\n read_inheritable_attribute(:find_with) || find_with(:session, :cookie, :params, :http_auth)\n else\n values.flatten!\n write_inheritable_attribute(:find_with, values)\n end\n end", "def find_all\n \n end", "def find_object(parent_object, id)\n raise NotImplementedError, \"#{self.class} must implement method: #{__callee__}\"\n end", "def find_with_ferret(q, options = {}, find_options = {})\n if respond_to?(:scope) && scope(:find, :conditions)\n if find_options[:conditions]\n find_options[:conditions] = \"(#{find_options[:conditions]}) AND (#{scope(:find, :conditions)})\"\n else\n find_options[:conditions] = scope(:find, :conditions)\n end\n end\n return ActsAsFerret::find q, self, options, find_options\n end", "def find(item, type = nil)\n find_by_id(item) || find_by_generic(item, type)\n end", "def find\n\t\tif defined?(@collection)\n\t\t\treturn @collection.find\n \tend\n\tend", "def resource_finder\n case finder = crudify_options[:finder]\n when Symbol : send(finder)\n when Proc : instance_exec(&finder)\n else self.class.read_inheritable_attribute(:resource_class) || self.class.controller_name.classify.constantize\n end\n end", "def finder_result\n @result ||= self.class.result_for(self.send(self.class.sharded_column))\n end", "def find_by_id(id)\n raise NotImplementedError.new\n end", "def find_by_target_urn(urn)\n raise \"Must be overridden\"\n end", "def find_finder_class_for record #:nodoc: \n class_hierarchy = [record.class]\n\n while class_hierarchy.last != @klass && class_hierarchy.last.superclass\n class_hierarchy.push(class_hierarchy.last.superclass)\n end\n \n class_hierarchy.detect { |klass| !klass.abstract_class? }\n end", "def find_all\n end", "def find(path, type, setting); end", "def search_for(_spec)\n raise NotImplementedError, not_implemented_msg(:search_for)\n end", "def method_missing(method, *args)\n if method =~ /^find_all_by/\n @scope.send(method, *args).map do |element|\n element.restrict(@context, options_with_escape)\n end\n elsif method =~ /^find_by/\n @scope.send(method, *args).restrict(@context, options_with_escape)\n elsif @scope.heimdallr_scopes && @scope.heimdallr_scopes.include?(method)\n Proxy::Collection.new(@context, @scope.send(method, *args), options_with_escape)\n elsif @scope.respond_to? method\n raise InsecureOperationError,\n \"Potentially insecure method #{method} was called\"\n else\n super\n end\n end", "def find_with_proc?\n !metadata.find_with.nil? && metadata.find_with.respond_to?(:call)\n end", "def find_by_name(name)\n end", "def find_by_name\n not_found and return if params[:id].blank?\n\n name = controller_name.singularize\n cond = \"find\" + (params[:id] =~ /\\A\\d+(-.+)?\\Z/ ? \"\" : \"_by_name\")\n not_found and return unless instance_variable_set(\"@#{name}\", resource_base.send(cond, params[:id]))\n end", "def find_with_searchlogic(*args)\n options = args.extract_options!\n options = filter_options_with_searchlogic(options)\n args << options\n find_without_searchlogic(*args)\n end", "def find(options = {})\n if(options.class == Integer)\n model = self.new(quickbook_gateway.get(\"#{entity.downcase}/#{options}\")[entity]) \n model.is_new_record = false\n return model\n end\n \n return self.find_all(options, 1)[0]\n end", "def find options = {}\n init_specification options, CANONICAL_OPTIONS do\n finish_specification_initialization \n end\n return Aquarium::Finders::FinderResult.new if nothing_to_find?\n types_and_objects = input_types + input_objects\n method_names_or_regexps = input_methods\n if method_names_or_regexps.empty?\n not_matched = {}\n types_and_objects.each {|t| not_matched[t] = []}\n return Aquarium::Finders::FinderResult.new(:not_matched => not_matched)\n end\n result = do_find_all_by types_and_objects, method_names_or_regexps\n unless (input_exclude_methods.nil? or input_exclude_methods.empty?)\n result -= do_find_all_by types_and_objects, input_exclude_methods\n end\n result\n end", "def real(options={})\n @real ||= self.type.constantize.find(self.id, options)\n end", "def find opt = nil, opts = { }\n opt ||= :all\n \n opts[:limit] = 1 if opt == :first\n\n # self.sql sets self.model_class.\n this_sql = self.sql(opts)\n result = model_class.find_by_sql(this_sql)\n\n result = result.first if opt == :first\n\n result\n end", "def find(file, report = self)\n current_path = File.join self.path, file\n if File.exist? current_path\n current_path\n else\n if superclass == Object\n raise FileNotFoundError.new file, report\n end\n superclass.find file, report\n end\n end", "def find_by_sql(sql)\n raise \"not implemented\"\n end", "def find(dn = self.dn, options = {})\n # Some misguided attempts to emulate active record.\n case dn\n when :all then search({:limit => false}.merge(options))\n when :first then first(options)\n when Array then dn.map {|d| fetch(d, options)}\n else fetch(dn, options)\n end\n end", "def method_missing(method_id, *arguments)\n if match = method_id_to_matches(method_id.to_s)\n @table_name = match.captures.first\n\n finder = determine_finder(match)\n attribute_names = []\n attribute_names ||= extract_attribute_names_from_match(match)\n\n conditions = construct_conditions_from_arguments(attribute_names, arguments)\n\n case extra_options = arguments[attribute_names.size]\n when nil\n options = {:conditions => conditions}\n send(finder, options)\n when Hash\n send(finder)\n end\n\n return self\n else\n super\n end\n end", "def find(*args)\n #self.class.new(layout, data, (queries.dup << args))\n wrap_data(data, (queries.dup << args))\n end", "def find(name); end", "def search(args)\n raise NotImplementedError, \"Not implemented\"\n end", "def find_by_name(id)\n end", "def find_for_show(find_by_conditions:)\n search.find_by(find_by_conditions)\n end", "def find_by_oauth2_method\n self.class.find_by_oauth2_method\n end", "def text_search_find(ids, options)\n if defined?(ActiveModel)\n # guess that we're on Rails 3\n raise \"text_search_find not implemented for Rails 3 (yet) - patches welcome\"\n elsif defined?(ActiveRecord::Base) and ancestors.include?(ActiveRecord::Base)\n merge_text_search_conditions!(ids, options)\n all(options)\n elsif defined?(Sequel::Model) and ancestors.include?(Sequel::Model)\n self[primary_key.to_sym => ids].filter(options)\n elsif defined?(DataMapper::Resource) and included_modules.include?(DataMapper::Resource) \n get(options.merge(primary_key.to_sym => ids))\n end\n end", "def finder_options(options={})\n clear_default_fields\n\n select = \"#{finder_table_name}.*\"\n order = self.sort_order || \"#{finder_table_name}.created_at ASC\"\n group = \"#{finder_table_name}.#{primary_key}\"\n\n conditions = []\n conditions << if self.state =~ /^read$/\n sanitize_sql(['? = messages.receiver_id AND messages.id IN (SELECT messages.id FROM messages ' +\n 'LEFT OUTER JOIN readings ON messages.id = readings.readable_id AND readings.readable_type = \\'Message\\' ' + \n 'WHERE readings.readable_id = messages.id AND readings.readable_type = \\'Message\\' AND readings.person_id = ?)',\n self.person.id, self.person.id])\n elsif self.state =~ /^unread$/\n sanitize_sql(['? = messages.receiver_id AND messages.id NOT IN (SELECT messages.id FROM messages ' +\n 'LEFT OUTER JOIN readings ON messages.id = readings.readable_id AND readings.readable_type = \\'Message\\' ' + \n 'WHERE readings.readable_id = messages.id AND readings.readable_type = \\'Message\\' AND readings.person_id = ?)',\n self.person.id, self.person.id])\n end\n \n conditions << sanitize_sql([\"messages.status IN (?)\", ['delivered', 'done', 'read']])\n conditions = conditions.compact.reject(&:blank?).join(\" AND \")\n \n result = {:select => select, :order => order, :group => group, :conditions => conditions,\n :include => :readings}.merge_finder_options(options)\n \n reset_default_fields\n result\n end", "def method_missing(method, *args, &block)\n assumed_class = method.to_s.singularize.titleize.constantize\n assumed_class.where(:resource_id => id).where(lang: [I18n.locale.to_s, '*']).first\n rescue Exception => msg\n super\n end", "def register_methods\n types.each do |type|\n self.class.send(:define_method, \"find_#{type}\".to_sym) do |*args|\n find(type, *args)\n end\n end\n end", "def find_child(method, *args); end", "def find(id); end", "def find(id); end" ]
[ "0.72618836", "0.70492786", "0.70340765", "0.7013792", "0.6947906", "0.6900682", "0.67339385", "0.6720188", "0.6693351", "0.6691238", "0.66717136", "0.6663905", "0.6663524", "0.66394144", "0.6585558", "0.65437466", "0.653401", "0.64552194", "0.6424414", "0.6395701", "0.6369246", "0.630723", "0.62275493", "0.6226239", "0.6188735", "0.6163134", "0.6136079", "0.6131955", "0.61236805", "0.6094055", "0.60706776", "0.60431784", "0.6041001", "0.603659", "0.6024412", "0.60125643", "0.6011637", "0.5984233", "0.59723496", "0.5971315", "0.59556854", "0.59233415", "0.5912489", "0.59111565", "0.58831465", "0.58695954", "0.5833836", "0.5819795", "0.5819795", "0.5817576", "0.5814558", "0.5802415", "0.57823604", "0.5759957", "0.5755591", "0.5737747", "0.57366765", "0.57251537", "0.5724918", "0.5718708", "0.57090694", "0.5701807", "0.5698499", "0.5695777", "0.56943005", "0.5690226", "0.5685652", "0.5685452", "0.56792057", "0.5644325", "0.56389993", "0.56313723", "0.56229794", "0.56097263", "0.5607218", "0.5602223", "0.5600805", "0.5578218", "0.5573277", "0.5572481", "0.5570888", "0.5557705", "0.55560577", "0.55539507", "0.55371237", "0.5533361", "0.552352", "0.5514107", "0.5510891", "0.55106467", "0.5510558", "0.5506274", "0.55029297", "0.55026555", "0.5501505", "0.54991984", "0.5493631", "0.5487865", "0.5481661", "0.5477672", "0.5477672" ]
0.0
-1
override this if the expected format differs in subclass
def format_phone_number(phone_number) phone_number.digits end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format\n raise '#format must be implemented in child class'\n end", "def format\n raise NotImplementedError\n end", "def formats; end", "def formats; end", "def _process_format(format); end", "def _process_format(format); end", "def _process_format(format) # :nodoc:\n end", "def internal_format\n selfclass.send(:internal_format)\n end", "def want_format?(derived_name, derived_width, derived_height)\n true\n end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def create_format_method\n end", "def formatter\n raise NotImplementedError\n end", "def force(new_format)\r\n @format = new_format\r\n self\r\n end", "def format?\n # if :custom\n if self.conventional?\n :conventional\n elsif self.relaxed?\n :relax\n elsif self.redacted?\n :redacted\n elsif self.standard?\n :standard\n else\n :invalid\n end\n end", "def format\n @format ||= properties.format.new self\n end", "def validates_format_of(*args)\n validates_with(FormatValidator, _merge_attributes(args))\n end", "def format\n @spec[:format]\n end", "def format\n @format ||= self._format_default\n end", "def format\n @format\n end", "def formatter; end", "def formatter; end", "def formatter; end", "def formatAPA\n \"Not format abstract class\"\n end", "def call(format_type: DEFAULT_NEWS_FORMAT_TYPE)\n self.combined_options = defaults.merge(\n format_type: validate_format_type(format_type)\n )\n super\n end", "def inherited(subclass)\n super\n\n subclass.serialization.replace serialization\n subclass.fields.replace fields\n end", "def to_s\r\n assert_exists\r\n super({\"length\" => \"size\",\"max length\" => \"maxLength\",\"read only\" => \"readOnly\" })\r\n end", "def format\n @_format\n end", "def _wrapper_formats; end", "def formats\n format\n end", "def formatters; end", "def format\n @data.format == :base ? :file : @data.format\n end", "def expected_format\n options[:expected_format] || 'yyyy-mm-dd'\n end", "def is_format?(); @type == GRT_FORMAT; end", "def get_formatter_class\n fail 'get_formatter_class method is not override'\n end", "def format\n @format ||= {}\n end", "def convert\n raise \"The convert method must be implemented by subclass!\"\n end", "def format\n @data_chunk_reader.format\n end", "def format\n @data_chunk_reader.format\n end", "def formats=(values); end", "def configure(conf)\n super\n \n ## Check if \"output_format\" has a valid value\n unless @output_format.to_s == \"structured\" ||\n @output_format.to_s == \"flat\" ||\n @output_format.to_s == \"statsd\"\n \n raise ConfigError, \"output_format value '#{@output_format}' is not valid. Must be : structured, flat or statsd\"\n end\n end", "def get(verse)\n self.class.format(super)\n end", "def verify_config(opts)\n opts = check_params(opts,[:instance_format,:data])\n super(opts)\n end", "def format!; end", "def create_format_method\n case @style\n when :json; Parseable.create_json_format_method(self)\n when :yaml; Parseable.create_yaml_format_method(self)\n else raise ArgumentError, \"unknown format style '#@style'\" end\n end", "def method_missing(method, *args)\n \"#{method.to_s} not a valid formatter!\"\n end", "def configure(conf)\n super\n\n ## Check if \"output_format\" has a valid value\n unless @output_format.to_s == \"structured\" ||\n @output_format.to_s == \"flat\" ||\n @output_format.to_s == \"statsd\"\n\n raise ConfigError, \"output_format value '#{@output_format}' is not valid. Must be : structured, flat or statsd\"\n end\n end", "def validate\n fail 'sub class to implement'\n end", "def initialize()\n super\n @unsupported.delete :newline\n end", "def inherited(subclass)\n super\n opts = {}\n json_serializer_opts.each{|k, v| opts[k] = (v.is_a?(Array) || v.is_a?(Hash)) ? v.dup : v}\n subclass.instance_variable_set(:@json_serializer_opts, opts)\n end", "def valid?\n valid_format? @format\n end", "def parse\n raise NotImplementedError\n end", "def format _label, _value\n raise NotImplementedError, self\n end", "def get_field_deserializers()\n return super.merge({\n \"format\" => lambda {|n| @format = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WorkbookChartDataLabelFormat.create_from_discriminator_value(pn) }) },\n \"position\" => lambda {|n| @position = n.get_string_value() },\n \"separator\" => lambda {|n| @separator = n.get_string_value() },\n \"showBubbleSize\" => lambda {|n| @show_bubble_size = n.get_boolean_value() },\n \"showCategoryName\" => lambda {|n| @show_category_name = n.get_boolean_value() },\n \"showLegendKey\" => lambda {|n| @show_legend_key = n.get_boolean_value() },\n \"showPercentage\" => lambda {|n| @show_percentage = n.get_boolean_value() },\n \"showSeriesName\" => lambda {|n| @show_series_name = n.get_boolean_value() },\n \"showValue\" => lambda {|n| @show_value = n.get_boolean_value() },\n })\n end", "def format\n return @format\n end", "def format\n return @format\n end", "def format\n return @format\n end", "def rendered_format; end", "def rendered_format; end", "def parse\n raise NotImplementedError.new\n end", "def change_format(data, from_format, to_format)\n FormatChanger.send(\"from_#{from_format}_to_#{to_format}\", data)\n end", "def testing_format\n @testing_format ||= TestingFormat.create\n end", "def preformatting\n\n end", "def formats\n @@formats\n end", "def format=(ret_format)\n if ret_format\n raise \"Format unknown\" if ![\"json\", \"hash\"].include?(ret_format.to_s)\n @format = ret_format.to_s\n end\n end", "def shouldConvert()\n\t\tfalse\n\tend", "def record_format\n @record_format ||= make_record_description if record_describer\n end", "def format\n @format ||= Manipulator.new\n end", "def reset_format!\n self.format = @default_format\n end", "def parse\n raise \"absctract method called\"\n end", "def formatters=(formatters); end", "def presentation_format=(v) Axlsx.validate_string v; @presentation_format = v; end", "def require_format_of(attribute)\r\n RequireFormatOf.new(attribute)\r\n end", "def process(src)\n super\n @format = case src.parser.to_s\n when 'RDoc::Parser::PerlPOD'\n 'perl'\n when 'RDoc::Parser::C'\n 'c'\n when 'RDoc::Parser::Simple'\n 'text'\n else\n 'ruby'\n end\n\n @last_modified = src.last_modified\n @absolute_name = src.absolute_name\n @full_name = src.full_name\n end", "def to(new_format)\r\n Impl.new( new_format, tokens )\r\n end", "def format(format)\n @format = format\n end", "def join\n super(self.class.format)\n end", "def format_arguments; end", "def format= new_format\n @grpc.type = :PLAIN_TEXT if new_format.to_s == \"text\"\n @grpc.type = :HTML if new_format.to_s == \"html\"\n @grpc.type\n end", "def result(format)\n raise \"Not implemented\"\n end", "def to_format\n @format ||= lookup.last \n end", "def format=(new_format)\n valid_formats = [:json, :xml]\n raise ArgumentError, \"Invalid format. Supported formats: #{valid_formats.join(', ')}.\" unless valid_formats.include?(new_format.to_sym)\n @format = new_format\n refresh_config_for_api_objects!\n @format\n end", "def validated; end", "def _to_json_struct\n raise NoMethodError, \"subclasses must implement #{__method__}\"\n end", "def test_boundaries\n o = StderrOutputter.new('ak', :formatter => Formatter)\n assert_exception(TypeError) { o.formatter = nil }\n assert_exception(TypeError) { o.formatter = String }\n assert_exception(TypeError) { o.formatter = \"bogus\" }\n assert_exception(TypeError) { o.formatter = -3 }\n # the formatter should be preserved\n assert(o.formatter.type == Formatter) \n end", "def parse \n raise \"This has not been implemented yet. Due to the variability of report format, will need to implement a series of specialized parsers\"\n end", "def validate\n validate_summary\n validate_duration\n validate_kind\n validate_state\n validate_created_at\n\n super\n end", "def test_checkformat_good\n @f.set_address(@success,@from)\n success,msg= @f.check_format\n assert success,\"check did not succeed\"\n\n end", "def validated?; end", "def format_specific_setup\n format = document_partial_name(@document)\n if self.respond_to?(\"#{format}_setup\".to_sym)\n send(\"#{format}_setup\".to_sym)\n else\n logger.debug \"Didn't set up any format-specific info for #{format}. To enable custom before_render callbacks for this format, define a filter method called #{format}_setup\"\n end\n # case format\n # when \"auction\"\n # setup_auction_info\n # else\n # logger.debug \"Didn't set up any format-specific info for #{format}\"\n # end\n end", "def valid?\n raise Error::MethodShouldBeOverridenByExtendingClassError\n end", "def initialize\n @formats = []\n end", "def provided_formats\n @target.class_provided_formats\n end", "def invalid_format?(format)\n return true unless FORMATS.include?(format)\n end", "def validate_format(task_name, reference_key, klass)\n (tasks[task_name][reference_key].nil? || tasks[task_name][reference_key].is_a?(klass))\n end" ]
[ "0.70941126", "0.6746338", "0.6254865", "0.6254865", "0.6243915", "0.6243915", "0.6044545", "0.60167336", "0.59922403", "0.597576", "0.597576", "0.597576", "0.597576", "0.597576", "0.597576", "0.597576", "0.597576", "0.5972988", "0.5932285", "0.58962744", "0.57720035", "0.5719252", "0.57171", "0.56517094", "0.559029", "0.5584826", "0.5584278", "0.5584278", "0.5584278", "0.55759966", "0.5565088", "0.5559364", "0.5547968", "0.55419993", "0.5525236", "0.5515195", "0.55022454", "0.5483546", "0.5480566", "0.546414", "0.546284", "0.54431224", "0.54071265", "0.53894", "0.53894", "0.5381064", "0.536981", "0.5360049", "0.5334959", "0.53126353", "0.5305007", "0.52881867", "0.5285544", "0.52664274", "0.5252123", "0.5242411", "0.5238841", "0.52372056", "0.5227825", "0.5223745", "0.5220747", "0.5220747", "0.5220747", "0.52088624", "0.52088624", "0.51731426", "0.51699734", "0.5163651", "0.51510173", "0.51405203", "0.5138241", "0.5135112", "0.51319504", "0.5127056", "0.5117756", "0.5113831", "0.51098907", "0.5093383", "0.5091397", "0.5078967", "0.50771093", "0.50723517", "0.5066099", "0.5065958", "0.5065327", "0.5064754", "0.5061267", "0.5056627", "0.50525874", "0.5041198", "0.50203466", "0.5015995", "0.50117373", "0.5011703", "0.50012064", "0.4992481", "0.498819", "0.4985055", "0.49782696", "0.4974171", "0.49615306" ]
0.0
-1
Raise an exception if the white list is being used (only sends to people on this list) and this phone number is not on the list
def check_white_list!(phone_number) if self.class.config[:white_list] && !phone_number.white_list? raise SmsOnRails::SmsError.new("Phone number #{phone_number.human_display} is not in white list") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_do_not_send!(phone_number)\n if phone_number.do_not_send?\n raise SmsOnRails::SmsError.new(\"Phone number #{phone_number.human_display} do not send is set:#{phone_number.do_not_send}\")\n end\n end", "def sms_eligibility_check\n redirect_to(root_url) && return unless current_user.can_edit_patient?\n\n phone_number = params.require(:phone_number)\n blocked = BlockedNumber.exists?(phone_number: phone_number)\n render json: { sms_eligible: !blocked }\n end", "def process_blocked_numbers\n # eg. 12504274006\n from = params['From']\n\n # Innocent until proven guilty\n blocked = false\n\n # Collection of digits from Twilio that are invalid.\n #\n # see the following link for exact details on these blocked digits.\n # https://www.twilio.com/help/faq/voice/why-am-i-getting-calls-from-these-strange-numbers\n known_invalids = [\"7378742833\", \"2562533\", \"8656696\", \"266696687\"]\n\n # Special int only form of our From number\n from_int = strip_to_int(from).to_s\n\n if from.present?\n if known_invalids.include? from_int\n log \"Invalid Customer From number: matches known blocked / invalid numbers - #{from} - #{from_int}\"\n blocked = true\n end\n\n elsif from.length < 7\n log \"Invalid Customer From number: strangely short number - #{from}\"\n blocked = true\n\n else\n log \"Invalid Customer From number: not present - #{from || 'nil'}\"\n blocked = true\n end\n\n # If anything got triggered,\n # we will redirect to the blocked response.\n if blocked\n #redirect_to invalid_number_path(device: params[:action])\n device = params[:action].to_sym\n\n xml = Twilio::TwiML::Response.new do |b|\n case device\n when :sms\n b.Say \"Sorry, in order to use our services you must be calling from a non-blocked or public number.\"\n when :voice\n b.Message \"Sorry, in order to use our services you must be texting from a non-blocked or public number.\"\n end\n end.text\n\n render xml: xml\n end\n\n end", "def black_listed?(phone, text)\n number_regex = /\\+1(\\d){10,10}$/\n if number_regex.match(phone).nil? \n true \n end\n end", "def sender_not_supported\n sms.to[0] == \"1\" || # USA\n sms.to[0..2] == \"962\" || # Jordan\n sms.to[0..2] == \"971\" # UAE\n end", "def invalid_number\n xml = Twilio::TwiML::Response.new do |r|\n if params[:device] =~ /sms/\n r.Message \"Sorry, to use our Services your number must not be private.\"\n else\n r.Say \"Sorry, we don't allow Customers with private or blocked numbers.\"\n r.Say \"Please try again from another Number.\"\n end\n end.text\n\n render xml: xml\n end", "def validate_to_input\n if inbound_request? && !account.phone_numbers.where(number: to).exists?\n errors.add(:to, I18n.t('errors.messages.parameter_not_found'))\n end\n end", "def validate_whitelisting_process\n return error_with_data(\n 'uaj_2',\n \"Client Whitelisting information is inactivated. Please contact Ost team.\",\n \"Client Whitelisting information is inactivated. Please contact Ost team.\",\n GlobalConstant::ErrorAction.default,\n {}\n ) if get_client_whitelist_detail_obj.nil?\n\n # Check if client whitelisting is running or not\n unless get_client_whitelist_detail_obj.no_suspension_type?\n error_msg = \"Whitelisting or unWhitelisting is not happening at the moment. \"\n error_msg += \"Whitelister eth balance is low.\" if get_client_whitelist_detail_obj.low_balance_suspension_type?\n\n return error_with_data(\n 'uaj_3',\n \"#{error_msg} Please try after sometime.\",\n \"#{error_msg} Please try after sometime.\",\n GlobalConstant::ErrorAction.default,\n {}\n )\n end\n\n # todo: This validation has also been done before enqueue.\n KycWhitelistLog.where(client_id: @client_id, ethereum_address: @ethereum_address).all.each do |kwl|\n\n if (GlobalConstant::KycWhitelistLog.kyc_whitelist_confirmation_pending_statuses.include?(kwl.status))\n return error_with_data(\n 'uaj_1',\n \"Waiting for KYC Whitelist Confirmation. Please try after sometime!\",\n \"Waiting for KYC Whitelist Confirmation. Please try after sometime!\",\n GlobalConstant::ErrorAction.default,\n {}\n )\n end\n\n end\n\n success\n end", "def reject_invalid_numbers\n @customer_numbers.reject! { |num| !Phonelib.valid?(num) }\n end", "def is_whitelisted?(address)\n !!(self.class.safetynet_options[:whitelist].match(address))\n end", "def validate_from_input\n if outbound_request? && !account.phone_numbers.where(number: from).exists?\n errors.add(:from, I18n.t('errors.messages.parameter_not_found'))\n end\n end", "def log_recipient_data_reason(list_item)\n if list_item&.send_status == Messaging::NotificationSms::BadFormatMsg\n logger.info 'Recipient in list had bad format phone number. Will not attempt to resend'\n elsif list_item&.send_status == 'success'\n logger.info 'Recipient in list was already successfully sent. Will not resend'\n elsif !list_item&.can_retry?\n logger.info 'Recipient previously failed but can not retry'\n elsif list_item&.send_status == 'sent'\n logger.info 'Recipient in list was already sent. Will not resend for some other reason'\n else\n logger.warn \"A recipient list item did not exist (#{!!list_item}) or some other reason for not sending\"\n end\n end", "def check_white_list(context,input,original = nil)\n original = input.dup if original.nil?\n @white_list.each do |p|\n match = p.match(input)\n if match.nil? or not match[0].eql?(input)\n # format user msg\n user = \"#{context}: Invalid input. Conform to #{p.to_s}\"\n user << \" with a max length of #{@max}\" unless @max == 0\n # format log message\n log = \"Invalid input: context=#{context}, type=#{@name}, pattern=#{p.to_s}\"\n log << \", input=#{input}, original=#{original}\"\n # raise an error\n raise Owasp::Esapi::ValidationException.new(user,log,context)\n end\n end\n input\n end", "def does_a_phone_to_this_sip_account_exist\n if !Phone.exists?(:id => self.phone_id)\n errors.add(:phone_id, \"(ID #{self.phone_id}) does not exist.\")\n end \n end", "def turn_number(pharm_number,off_or_on,staff_phone_number)\n $stderr.puts \"trying to turn number #{off_or_on}\"\n # does not allow anyone to turn off a primary number\n is_primary_number = Pharmacy.where(:preferred_number_id => pharm_number).count > 0\n\n if (is_primary_number)\n sms_message = \"Sorry this is the primary number associated with this pharmacy. If this number needs to be turned off, please contact Satter.\"\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => staff_phone_number,\n :body => sms_message)\n\n else\n\n #TO DO : we may have this number lingerieng hte in the pending calls table so probably want to check and remove\n\n Number.where(:id => pharm_number).first.update(:call_this_number => off_or_on == 'on' ? 1 : 0)\n sms_message_confirmation = \"#{pharm_number} has been turned #{off_or_on}. Thank you.\"\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => staff_phone_number,\n :body => sms_message_confirmation)\n end\n nil\nend", "def user_has_number\n unless current_user.phone_verifications.count > 0\n redirect_to root_path\n end\n end", "def field_register_pharmacy(pharm_number,pharm_contact_name,staff_phone_number)\n pharm_number = standardize_number(pharm_number[0])\n\n #check to make sure this number is not already registered\n phone_number_in_db = Number.where(:id => pharm_number)\n if phone_number_in_db.count > 0\n send_try_again_sms(staff_phone_number,\"This number is already registered to pharmacy #{phone_number_in_db.first.pharmacy_id}\")\n return nil\n end\n\n\n Pharmacy.insert(:preferred_number_id => pharm_number,\n :name => pharm_contact_name)\n pid = Pharmacy.where(:preferred_number_id => pharm_number).first.id\n\n Number.insert(\n :id => pharm_number,\n :pharmacy_id => pid,\n :call_this_number => 1,\n :created_at => Time.now\n )\n\n #settings so we dont call em\n PendingCall.insert(\n :number_id => pharm_number,\n :attempts => $max_ors_attempts,\n :error_message_sent => 1\n )\n\n # Default start and end time for pharmacies\n AvailableTime.insert(\n :pharmacy_id => pid,\n :start_time => \"09:00:00\",\n :end_time => \"21:00:00\"\n )\n\n sms_message_confirmation = \"Registration successful. Pharmacy ID number is #{pid}\"\n $stderr.puts \"sending reg confirmation to to #{staff_phone_number}\"\n\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => staff_phone_number,\n :body => sms_message_confirmation)\n #send message to user\n $stderr.puts \"sending reg confirmation to to #{pharm_number}\"\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => pharm_number,\n :body => \"Welcome to bangpharma. Your pharmacy ID is #{pid}.\")\n\n return nil\nend", "def ios_device_blocked_on_missing_partner_data\n return @ios_device_blocked_on_missing_partner_data\n end", "def add_phone_number(phone_number)\n return if self.has_number?(phone_number)\n puts \"adding number: \" + phone_number.number \n self.save\n self.list_memberships.create! :phone_number_id => phone_number.id\n if(self.use_welcome_message?)\n puts \"has welcome message, and creating outgoing message\"\n welcome_message = self.custom_welcome_message\n create_outgoing_message( phone_number, welcome_message )\n end \n end", "def sip_account_must_belong_to_phone\n if self.sip_account.id != self.sip_account_id\n errors.add( :sip_account_id, \"Is not a valid sip account for this phone.\" )\n end\n end", "def check_phone_no_format\n is_valid = Spree::Address.is_phone_valid?(@phone)\n render text: is_valid\n end", "def allow_only_htwberlin_accounts\n unless !!email.match(/@htw-berlin.de\\z/)\n self.errors[:email] << 'Muss eine @htw-berlin.de Adresse sein'\n end\n end", "def verifyphonenumber\n tc = Twilio::REST::Client.new tsid, tauthtoken\n # Ref: https://www.twilio.com/docs/api/rest/outgoing-caller-ids\n call_delay_in_sec = 45 # Can be 0 to 60 seconds\n caller_id = tc.outgoing_caller_ids.create(:phone_number => params[:PhoneNumber], :call_delay => call_delay_in_sec)\n respond_to do |format|\n format.json { render :json => {:verification_code => caller_id.validation_code},\n :status => :ok }\n end\n end", "def is_sender_registered?(phone_number)\n phone_number = phone_number.gsub(/\\+1/, '').gsub(/\\D+/, '')\n get_system_org.users.find_by_phone(phone_number)\n end", "def android_device_blocked_on_missing_partner_data\n return @android_device_blocked_on_missing_partner_data\n end", "def confirm_pur_number_warning_hops()\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n wait_for_landing_page_load\n invalid_number_error_hops.should_exist\n invalid_gc_msg = invalid_number_error_hops.inner_text\n invalid_gc_msg.should match(\"We're sorry but the loyalty card number you provided is not valid\")\n end", "def validate_phone_no\n return if phone_no.nil?\n\n if phone_no.length < 25\n allowed_chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '-', '.', '(', ')', ' ', 'x']\n for character in phone_no.split('')\n next if character.in?(allowed_chars)\n\n errors.add(:phone_no, 'Phone no should have only numbers and x, ., -, (, +, )')\n return\n end\n else\n errors.add(:phone_no, 'Phone no should be of length not more than 25 characters')\n end\n end", "def test_nonregistered_user_accepted_characters\n listings = []\n response = get_consumer_search_resp\n response['SearchResult']['BusinessListings'].each do |listing|\n listings << listing['Int_Xxid']\n end\n\n email_check = \"as.test_email-check+#{Common.random_uuid}@xx.com\"\n\n params = {\n 'request_host' => 'http://www.xx.com',\n 'to' => email_check,\n 'from' => email_check,\n 'from_name' => 'TESTr',\n 'lid' => listings.sample.to_s,\n 'note' => 'Checkout this listing!',\n 'mobile' => false\n }\n\n post '/em/share_listing', params\n assert_response(@response, :success)\n assert_match(@parsed_response['MailingID'], @parsed_response['Location'], @parsed_response)\n end", "def blacklisted?(request)\n false\n end", "def twilio\n @number = params[:phone_number]\n \n #Text message info\n t = {\n \n 'From' => CALLER_ID,\n 'To' => @number,\n 'Body' => (\"Visit uhpartments.com when you walk through an apartment\")\n }\n\n begin\n account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)\n resp = account.request(\"/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages\",\n 'POST',\n t)\n resp.error! unless resp.kind_of? Net::HTTPSuccess\n rescue StandardError => bang\n #This area will be called if an error happens with the Twilio API\n flash[:alert] = \"Bad number.\"\n redirect_to({ :action => :home })\n \n return\n end\n\n redirect_to({ :action => :home, :alert => \"SMS sent.\" })\n end", "def call?\n if rejection_reason\n TinyDialer::Log.info \"Rejected #{phone}: #{rejection_reason}\"\n return\n end\n # Make sure (now, now) overlaps (start, stop)\n now = (Time.now.utc + (3600*(timezone)).to_i).strftime('%H:%M')\n unless TinyDialer.db.fetch(\"select ('#{now}'::text::time, '#{now}'::text::time) OVERLAPS ('#{state.start}'::text::time, '#{state.stop}'::text::time)\").first[:overlaps]\n TinyDialer::Log.info \"Rejected #{phone}: Outside of calling times #{state.start} and #{state.stop}\"\n return false\n end\n true\n rescue => e\n TinyDialer::Log.error e\n return\n end", "def add_phone_number!(phone_number)\n clean_phone_number = Expect.clean_phone_number(phone_number)\n \n unless self.phone_numbers.where(clean_phone_number: clean_phone_number).any?\n self.phone_numbers.create(phone_number: phone_number)\n end\n end", "def send_message\n send unless SuppressionList.include?(receiver)\n end", "def cannot_post(list, email)\n @list = list.name\n mail(\n :to => email.from,\n :subject => \"[#{list.name}] You're not allowed to post to this list\",\n :date => Time.zone.now\n )\n end", "def list_owner_cannot_watch\n if self.list.user == self.user\n errors.add(:base, \"List owner cannot add it to watchlist\")\n end\n end", "def reply_to_sender_with_error(phone_number, msg)\n reply_to_sender(phone_number, msg)\n msg = \"\" if Rails.env=='production' # do not show error messages in UI in production\n return msg, true\n end", "def check_if_stolen\n unless license_number != \"1111111\"\n errors.add(:license_number, \"is stolen\")\n end\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 allow_invalid_person?\n allow_invalid_person\n end", "def windows_device_blocked_on_missing_partner_data\n return @windows_device_blocked_on_missing_partner_data\n end", "def valid_attendee\n #puts \"USER DEVICE TOKENS #{@device_tokens}\"\n return (!@phone_number.nil? && !@phone_number.empty?)\n # && !@first_name.nil? && !@first_name.empty? && !@last_name.nil? && !@last_name.empty?)\n end", "def confirm_pur_number_warning()\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n wait_for_landing_page_load\n gsm_error_message.should_exist\n invalid_gc_msg = gsm_error_message.inner_text\n invalid_gc_msg.should match(\"Please enter a valid loyalty card number\")\n end", "def senders_of(message)\n raise CapabilitiesExceeded\n end", "def denied\n ContactMailer.denied\n end", "def trial_warning(company_phone)\n @company_phone = company_phone\n @company = @company_phone.company\n @pay_url = \"#{@landing_url}/pago?api_key=#{@company.api_key}\"\n mail(\n to: @company_phone.extensions.admin.first.email,\n subject: 'GurúComm | Te queda un día de tu periodo de prueba'\n )\n end", "def confirm_cc_number_warning_hops()\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n wait_for_landing_page_load\n invalid_number_error_hops.should_exist\n invalid_gc_msg = invalid_number_error_hops.inner_text\n invalid_gc_msg.should match(\"Invalid Credit Card Information\")\n end", "def whitelisted?(request)\n false\n end", "def cannot_share_exisiting_team_name\n team_names = Team.all.map do |team|\n team.team_name.downcase\n end\n\n current_team_name = team_name.downcase\n \n errors.add(:team_name) if team_names.include?(current_team_name)\n \n p errors.full_messages\n end", "def not_spam\n errors.add(:base, \"invalid reply\") if check_field.present?\n end", "def read_extension_phone_number_detect_sms_feature()\n begin\n endpoint = \"/restapi/v1.0/account/~/extension/~/phone-number\"\n resp = $platform.get(endpoint)\n for record in resp.body['records'] do\n for feature in record['features'] do\n if feature == \"SmsSender\"\n # If user has multiple phone numbers, check and decide which number\n # to be used for sending SMS message.\n return send_sms(record['phoneNumber'])\n end\n end\n end\n if resp.body['records'].length == 0\n puts (\"This user does not own a phone number!\")\n else\n puts(\"None of this user's phone number(s) has the SMS capability!\")\n end\n rescue StandardError => e\n puts (e)\n end\nend", "def detect_sms_feature()\n begin\n endpoint = \"/restapi/v1.0/account/~/extension/~/phone-number\"\n resp = $platform.get(endpoint)\n for record in resp.body['records'] do\n for feature in record['features'] do\n if feature == \"SmsSender\"\n puts (\"This phone number \" + record['phoneNumber'] + \" has SMS feature\")\n end\n end\n end\n if resp.body['records'].length == 0\n puts (\"This user does not own a phone number!\")\n end\n rescue StandardError => e\n puts (e)\n end\nend", "def ios_device_blocked_on_missing_partner_data=(value)\n @ios_device_blocked_on_missing_partner_data = value\n end", "def power_pin_in_use_validation\n errors.add(:power_pin, 'is already in use.') if pin_in_use? power_pin\n end", "def recipient_has_not_already_been_invited\n # this will catch if a person wanting beta access already invited themselves\n email = email_asking_for_invite.strip.downcase\n errors.add(:email_asking_for_invite, \"^#{email_asking_for_invite} has already been added to the invitation list\") if InvitationLink.where(:email_asking_for_invite => email).exists?\n end", "def invalid_address\n render_error(:unprocessable_entity, {recipient: ['invalid address']})\n end", "def validate_maillist\n listname = params[:maillist]\n\n valid = maillist_is_valid? listname\n is_member = valid && maillist_members(params[:maillist]).include?(@current_user.pseudonym.unique_id.split('@')[0])\n\n if !valid\n payload = { valid_maillist: false, reason: \"#{params[:maillist]} is not a valid SFU Maillist\" }\n elsif !is_member\n payload = { valid_maillist: false, reason: \"You are not a member of #{params[:maillist]}. You must be a member of a list to add it to your Space.\" }\n else\n payload = { valid_maillist: true }\n end\n\n render json: payload, status: :ok\n end", "def valid_phone_number\n\t\tnumber = self.number.scan(/\\d/).join('')\n\t\tnumber[0] = '' if number[0] == \"1\"\n\n\t\tif number.length != 10\n\t\t\terrors.add(:phone, \"must be a valid 10 digit phone number\")\n\t\telse\n\t\t\tself.number = number\n\t\tend\n\tend", "def register_number(message,sms_number)\n chopped_message = message.gsub(/^\\s*reg\\s/i,'').split(\"\\s\")\n $stderr.puts chopped_message\n # check that it is length 2\n send_try_again_sms(sms_number) if chopped_message.length != 2\n register_number = chopped_message.grep(/\\d+/)\n #TODO - could make this more robust and allow for +88 too\n if register_number[0].length != 11 and register_number.grep(/^\\+1/).length != 1 #length of phone numbers in bangladesh\n send_try_again_sms(sms_number,\n \" The phone number should be 11 digits long\")\n return nil\n end\n\n register_name = chopped_message.grep(/[a-zA-Z]+/)\n\n if register_name.length == 1 and register_number.length == 1\n $stderr.puts \"meets field register reqs\"\n field_register_pharmacy(register_number,register_name,sms_number)\n else\n send_try_again_sms(sms_number)\n end\n return nil\nend", "def send_sms_verification_code\n number_to_send_to = phone_number\n verification_code = phone_verification_code\n sms_message_body = I18n.t(\"devise.phone.message_body\", :verification_code => verification_code)\n\n sms = Sms.new\n sms.phone_number = number_to_send_to\n sms.message = sms_message_body\n return false unless sms.send!\n\n true\n end", "def send_verification(phone:)\n raise StandardError, \"Phone can't be blank\" if phone.blank?\n raise StandardError, \"Please enter a valid phone\" unless PhoneValidator.valid?(phone)\n\n # check if a code was already sent to this phone number\n existing_code = redis.get(phone_key(phone))\n if existing_code\n\n # if a code was already sent, we need to check\n # that time has passed before re-sending it\n # we don't want to allow users to send too many SMS\n # because they cost money and could be abused\n too_early = redis.get(resend_key(phone)).present?\n\n raise StandardError, \"Can't resend a code this soon\" if too_early\n\n # verify that the maximum number of attempts was not yet reached\n attempts = redis.get(attempts_key(phone)).to_i\n raise StandardError, \"You reached the maximum number of attempts, please wait\" if attempts > MAX_ATTEMPTS\n\n # if time has passed, we re-send the same code\n code = existing_code\n else\n # generate N digit code\n code = SecureRandom.random_number(10 ** CODE_LENGTH).to_s.rjust(CODE_LENGTH, \"0\")\n\n # save this code in redis under the given phone number\n redis.set(phone_key(phone), code, ex: EXPIRATION, nx: true)\n # set attempts to 0\n redis.set(attempts_key(phone), \"0\", ex: EXPIRATION, nx: true)\n end\n\n # reset a timer for being able to send a code for a given phone number\n redis.set(resend_key(phone), \"true\", ex: TIME_BEFORE_RESEND, nx: true)\n\n content = \"Verification code: #{code}\"\n # actually send the SMS using twilio or some other service\n Messenger.call(phone: phone, message: content)\n end", "def phone_pending_confirmation?\n self.unconfirmed_phone_number.present? && self.errors[:unconfirmed_phone_number].empty?\n end", "def place_call\n client = Twilio::REST::Client.new(Settings.twilio.account_sid, Settings.twilio.auth_token)\n params = {\n from: call.caller_id,\n to: call.member_phone_number,\n url: call_start_url(call),\n status_callback: member_call_event_url(call),\n status_callback_method: 'POST',\n status_callback_event: %w[initiated ringing answered completed]\n }\n client.calls.create params\n rescue Twilio::REST::RestError => e\n # 13223: Dial: Invalid phone number format\n # 13224: Dial: Invalid phone number\n # 13225: Dial: Forbidden phone number\n # 13226: Dial: Invalid country code\n # 21211: Invalid 'To' Phone Number\n # 21214: 'To' phone number cannot be reached\n call.action.destroy!\n call.update!(twilio_error_code: e.code, status: 'failed', action_id: nil)\n if (e.code >= 13_223 && e.code <= 13_226) || [21_211, 21_214].include?(e.code)\n add_error(:member_phone_number, I18n.t('call_tool.errors.phone_number.cant_connect'))\n else\n Rails.logger.error(\"Twilio Error: API responded with code #{e.code} for #{call.attributes.inspect}\")\n add_error(:base, I18n.t('call_tool.errors.unknown'))\n end\n end", "def no_own_reservations\n if guest == listing.host\n errors.add(:guest, \"Please select a listing that is not your own\")\n end\n end", "def with_sms_verification(phone)\n # Try to find SMS verification request\n sms_verification = SmsVerification.where({ cookie: cookie, phone: phone }).first\n\n # No SMS code sent yet.\n unless sms_verification\n generate_sms_verification_code(phone)\n false\n # SMS code was already sent\n else\n # SMS code is correct\n if sms_verification.code == params[:sms_verification_code]\n reset(sms_verification)\n true\n # SMS code is incorrect\n else\n sms_verification.attempts += 1\n sms_verification.save\n\n if sms_verification.attempts >= 3\n reset(sms_verification)\n generate_sms_verification_code(phone)\n end\n\n false\n end\n end\n end", "def is_office_phone_allowed=(value)\n @is_office_phone_allowed = value\n end", "def process_in_list\n if !SYSTEM_DATA[\"processes\"].map { |x| x[\"code\"] }.include?(process)\n errors.add(:process, \"Step: #{step} - #{process} not included in list of valid statuses\")\n end\n end", "def block_if_on_hold\n raise \"Account is currently on hold. Messaging is disabled.\" if current_account.on_hold?\n end", "def verify_phone\n phone_verified = false\n begin\n @client = Twilio::REST::Client.new(@config[\"config\"][\"phone\"][\"account_sid\"], @config[\"config\"][\"phone\"][\"auth_token\"])\n phone_numbers = @client.incoming_phone_numbers.list\n if phone_numbers.empty?\n @config[\"config\"][\"phone\"][\"phone_number\"] = @client.available_phone_numbers(\"US\").local.list.first.phone_number\n @config[\"config\"][\"phone\"][\"phone_sid\"] = @client.incoming_phone_numbers.create(phone_number: @config[\"config\"][\"phone\"][\"phone_number\"]).sid\n box(\"Acquired phone number.\")\n else\n @config[\"config\"][\"phone\"][\"phone_number\"] = phone_numbers.first.phone_number\n @config[\"config\"][\"phone\"][\"phone_sid\"] = phone_numbers.first.sid\n box(\"Already have phone number.\")\n end\n phone_verified = true\n success_prompt(\"Twilio authenticated. Phone Number: #{@config[\"config\"][\"phone\"][\"phone_number\"]} Phone SID: #{@config[\"config\"][\"phone\"][\"phone_sid\"]}\")\n rescue StandardError\n error_box(\"Testing Twilio failed. Please try again. If this persists, please reach out to the developers.\")\n end\n phone_verified\nend", "def number_of_sip_accounts_is_possible\n if !self.phone.nil? and self.phone.sip_accounts.include?(self)\n my_self = 1\n else\n my_self = 0\n end\n if !self.phone.nil? and !((self.phone.sip_accounts.count - my_self) < self.phone.phone_model.max_number_of_sip_accounts) \n errors.add(:phone_id, \"only #{self.phone.phone_model.max_number_of_sip_accounts} SIP Accounts for the Phone with the ID #{self.phone.id} possible\")\n end \n end", "def is_office_phone_allowed\n return @is_office_phone_allowed\n end", "def ensure_account_is_not_pending_recovery\n self.match.is_not_pending_recovery!\n end", "def add_member_phone(phone)\n\n end", "def alpha_invited?\n unless Token.exists?(:value => email)\n errors.add :email, \"is not on our alpha list\" \n end\n end", "def blacklisted?\n self.friendship_status == BLACKLISTED\n end", "def invite_valid?\n if self.given_invite_code.present?\n if self.invite.present?\n errors.add(:invite_code, \"has already been used\") if self.invite.used\n else\n errors.add(:invite_code, \"must be valid\") \n end \n end\n end", "def send_sms_reminder\n return true # Disable sms sender\n if phone_number and sms_opt_in?\n _participation_requests = participation_requests.where(date: Date.tomorrow, state: 'accepted')\n return false if _participation_requests.empty?\n\n if _participation_requests.length > 1\n message = I18n.t('sms.users.day_before_reminder.multiple_course',\n nb_courses: _participation_requests.length,\n start_time: I18n.l(_participation_requests.first.start_time, format: :short))\n else\n message = _participation_requests.first.decorate.sms_reminder_message\n end\n\n self.delay.send_sms(message, phone_number)\n end\n end", "def contact_add_check(user, action_user)\n\t\tunless (current_user.id == user.to_i) && (current_user.contacts.where(id: action_user).count == 0)\n\t\t\traise ActionController::RoutingError, 'Not Found'\n\t\tend\n\tend", "def send_to_phone\n if params[:level_source] && params[:phone] && (level_source = LevelSource.find(params[:level_source]))\n send_sms(level_source, params[:phone])\n render status: :ok, nothing: true\n else\n render status: :not_acceptable, nothing: true\n end\n end", "def phone_present\n if phone.blank?\n errors.add(:phone, \"Can't be empty\")\n end\n end", "def no_organization_or_local_network_access\n unless current_contact.from_ungc?\n flash[:error] = \"You do not have permission to access that resource.\"\n redirect_to dashboard_path\n end\n end", "def check_valid_list_id!\n assoc_class = ModelReference.to_record_class_for_type assoc_name.singularize\n assoc_item = assoc_class.where(list_on_attr => list_id).first\n return if assoc_item\n\n raise FphsGeneralError, \"list id does not represent an associated list: #{list_id} for #{assoc_class}\"\n end", "def assign_phone_number\n if !params[:customer].blank? && !params[:call_id].blank?\n call = Radius::Call.find_by_radacctid(params[:call_id].to_i)\n customer = Customer.find_by_name_and_address(params[:customer])\n if !call\n flash[:error] = 'Call not found'\n elsif !customer\n flash[:error] = 'Customer not found'\n else\n customer.phones.add call.caller\n end\n end\n redirect_to :action => :index\n end", "def send_sms_token\n if(self.phone?)\n generate_sms_token! if self.sms_confirmation_token.nil?\n ::Devise.sms_sender.send_sms(self.phone, I18n.t(:\"devise.sms_activations.sms_body\", :sms_confirmation_token => self.sms_confirmation_token, :default => self.sms_confirmation_token))\n else\n self.class.sms_confirmation_keys.each do |key|\n self.errors.add(key, :no_phone_associated)\n end\n false\n end\n end", "def has_wrong_number?\n status_code == '1'\n end", "def ensure_recipient_does_not_have_account_for_another_community\n @braintree_account = BraintreeAccount.find_by_person_id(@braintree_payment.recipient_id)\n\n if @braintree_account\n # Braintree account exists\n if @braintree_account.community_id.present? && @braintree_account.community_id != @current_community.id\n # ...but is associated to different community\n account_community = Community.find(@braintree_account.community_id)\n flash[:error] = \"Unfortunately, we cannot proceed with the payment. Please contact the administrators.\"\n\n error_msg = \"User #{@current_user.id} tries to pay for user #{@braintree_payment.recipient_id} which has Braintree account for another community #{account_community.name(I18n.locale)}\"\n BTLog.error(error_msg)\n ApplicationHelper.send_error_notification(error_msg, \"BraintreePaymentAccountError\")\n redirect_to person_transaction_path(@current_user, @conversation)\n end\n end\n end", "def allow_mails_from_merchant\n end", "def detect_list_name_error(list_name)\n if !(1..100).cover? list_name.size\n 'List name must be between 1 and 100 characters.'\n elsif @storage.existing_list?(list_name)\n \"There is an existing '#{list_name}' list. Please provide a unique list name.\"\n end\nend", "def add_to_allowed_list(email)\n send_contact_command email, 'ADL', '2'\n end", "def no_red_numbers\n if self.player.club.cash <= 0\n self.errors[:base] = I18n.t('training.errors.red_numbers')\n end\n end", "def trust_registration_number; end", "def sms_accept_problem\n problem_id = @problem_text[1]\n password = @problem_text[2]\n provider = Account.find_by_phone_number(normalize_phone(params[:From]))\n problem = Problem.find_by_id(problem_id)\n if problem.nil?\n sms_error(\"Sorry, there is no problem that matches ID #{problem_id}. Please accept problems in the following format: 'Accept [problem ID]'\")\n elsif problem.archived\n sms_error(\"Sorry, problem ID #{problem_id} has already been accepted by another provider. Please choose another problem.\")\n# elsif !provider.verified_skills.include? problem.skills\n# sms_error(\"Sorry, you do not have the skills that this problem requires.\")\n else\n provider.problems << problem\n if provider.save\n problem.archived = true\n problem.save\n requester = problem.account\n sms_send(\"You have accepted problem ##{problem_id}. Please contact your requester at #{requester.phone_number} as soon as possible.\")\n #send a notification to the requester saying that a provider will be contacting shortly\n requester_msg = \"Your #{problem.summary} problem has been accepted. You can contact your provider at #{provider.phone_number}.\"\n sms_send(requester.phone_number, requester_msg)\n end\n end\n end", "def credit_unlimited?\n #if prepaid?\n # raise \"Prepaid users do not have credit\"\n credit == -1\n end", "def dial_up_numbers_ok? \n (!senior.blank? && !senior.devices.gateways.first.blank?) ? senior.devices.gateways.first.dial_up_numbers_ok? : false\n #\n # Fri Sep 24 04:26:03 IST 2010\n # logic updated to check user.devices by type of device\n #\n # senior.blank? ? false : senior.dial_up_numbers_ok_for_device?( senior.device_by_serial_number( kit_serial_number))\n end", "def over_limit?\n self.plan.limit.to_i > 0 && self.sms_usage >= self.plan.limit\n end", "def validate_sms_params\n # raise\n if params[:to].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.to.blank')\n elsif params[:carrier].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')\n elsif params[:to].gsub(/[^\\d]/, '').length != 10\n flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', to: params[:to])\n elsif !sms_mappings.values.include?(params[:carrier])\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.invalid')\n elsif current_user.blank? && !@user_characteristics[:on_campus] && !verify_recaptcha\n flash[:error] = 'reCAPTCHA verify error'\n end\n\n flash[:error].blank?\n end", "def validate_sms_params\n # raise\n if params[:to].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.to.blank')\n elsif params[:carrier].blank?\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')\n elsif params[:to].gsub(/[^\\d]/, '').length != 10\n flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', to: params[:to])\n elsif !sms_mappings.values.include?(params[:carrier])\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.invalid')\n elsif current_user.blank? && !@user_characteristics[:on_campus] && !verify_recaptcha\n flash[:error] = 'reCAPTCHA verify error'\n end\n\n flash[:error].blank?\n end", "def create\n if !BlackList.if_phone_exist?(params[:ad][:phone])\n if Ad.create(ad_params) \n render nothing: true, status: :created \n else\n render nothing: true, status: :unprocessable_entity \n end\n else\n #logger.debug{ \"===============>\" + params[:ad][:phone] }\n render nothing: true, status: :created\n end\n end", "def user_work_phone\n\tend", "def send_code\n status = :bad_request if missing_mfa? && current_user.setup_complete\n status ||= begin\n number = two_factor_phone_params[:two_factor_phone_number]\n MultifactorAuthenticator.new(current_user).send_code_on_number(number)\n :ok\n rescue\n :bad_request\n end\n head status\n end", "def still_ringing?(from)\n client = Twilio::REST::Client.new ACCOUNT_SID, AUTH_TOKEN\n\n client.account.calls.list({\n status: \"in-progress\",\n from: from,\n to: CALLER_ID,\n direction: \"inbound\"}).present?\n end" ]
[ "0.63761723", "0.6157981", "0.6129648", "0.61189705", "0.6074947", "0.5705701", "0.56808025", "0.5662786", "0.55959517", "0.5570956", "0.5565378", "0.54994494", "0.54616123", "0.5456171", "0.5398248", "0.53038", "0.5284092", "0.52454835", "0.5221184", "0.52178013", "0.52010304", "0.5200503", "0.5174442", "0.51568866", "0.5156698", "0.5138318", "0.51282626", "0.51164436", "0.51124173", "0.5095992", "0.5093129", "0.5081995", "0.50724447", "0.50612724", "0.50610065", "0.5050352", "0.5043257", "0.5039327", "0.5038645", "0.5013746", "0.50030005", "0.50018215", "0.49997962", "0.4997765", "0.49917936", "0.49811026", "0.49750027", "0.49739486", "0.49704117", "0.4960775", "0.4958999", "0.49564615", "0.49546236", "0.49537736", "0.49527416", "0.49522296", "0.49519843", "0.4948704", "0.49400765", "0.49381927", "0.49321505", "0.49319902", "0.49209443", "0.49161747", "0.49097413", "0.49015734", "0.49002185", "0.48962435", "0.48939335", "0.4889467", "0.48880658", "0.48857728", "0.4883479", "0.48810515", "0.48788828", "0.48718455", "0.4870969", "0.48664036", "0.4860884", "0.48608273", "0.48553607", "0.48512536", "0.48490667", "0.48455316", "0.48321578", "0.483104", "0.48261273", "0.48258546", "0.48199344", "0.48142552", "0.48137552", "0.4807732", "0.48051998", "0.48040003", "0.4803565", "0.4803565", "0.47991088", "0.47988474", "0.47923645", "0.47896934" ]
0.79890454
0
Raise an exception if this phone_number is marked as do not send
def check_do_not_send!(phone_number) if phone_number.do_not_send? raise SmsOnRails::SmsError.new("Phone number #{phone_number.human_display} do not send is set:#{phone_number.do_not_send}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invalid_number\n xml = Twilio::TwiML::Response.new do |r|\n if params[:device] =~ /sms/\n r.Message \"Sorry, to use our Services your number must not be private.\"\n else\n r.Say \"Sorry, we don't allow Customers with private or blocked numbers.\"\n r.Say \"Please try again from another Number.\"\n end\n end.text\n\n render xml: xml\n end", "def reply_to_sender_with_error(phone_number, msg)\n reply_to_sender(phone_number, msg)\n msg = \"\" if Rails.env=='production' # do not show error messages in UI in production\n return msg, true\n end", "def check_white_list!(phone_number)\n if self.class.config[:white_list] && !phone_number.white_list?\n raise SmsOnRails::SmsError.new(\"Phone number #{phone_number.human_display} is not in white list\")\n end\n end", "def sender_not_supported\n sms.to[0] == \"1\" || # USA\n sms.to[0..2] == \"962\" || # Jordan\n sms.to[0..2] == \"971\" # UAE\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 confirm_phone_number!\n if self.unconfirmed_phone_number.nil?\n LOG.error message: \"tried to confirm an unconfirmed_phone_number that is nil. This should never happen.\", user_id: self.id\n nil\n else\n self.phone_number = self.unconfirmed_phone_number\n self.unconfirmed_phone_number = nil\n self.phone_number_confirmed_at = Time.now\n self.phone_number_confirmation_token = nil\n self.phone_number_confirmation_sent_at = nil\n\n self.save!\n end\n end", "def send_verification_no\n if self.verification_no?\n self.deliver_verification_sms\n else\n random_number = (89999 * rand + 100000).to_int\n self.verification_no = random_number\n self.deliver_verification_sms\n end\n end", "def do_not_send?\n !self.do_not_send.blank?\n end", "def phone_pending_confirmation?\n self.unconfirmed_phone_number.present? && self.errors[:unconfirmed_phone_number].empty?\n end", "def sms_eligibility_check\n redirect_to(root_url) && return unless current_user.can_edit_patient?\n\n phone_number = params.require(:phone_number)\n blocked = BlockedNumber.exists?(phone_number: phone_number)\n render json: { sms_eligible: !blocked }\n end", "def sends_sms?\n false\n end", "def send_sms_reminder\n return true # Disable sms sender\n if phone_number and sms_opt_in?\n _participation_requests = participation_requests.where(date: Date.tomorrow, state: 'accepted')\n return false if _participation_requests.empty?\n\n if _participation_requests.length > 1\n message = I18n.t('sms.users.day_before_reminder.multiple_course',\n nb_courses: _participation_requests.length,\n start_time: I18n.l(_participation_requests.first.start_time, format: :short))\n else\n message = _participation_requests.first.decorate.sms_reminder_message\n end\n\n self.delay.send_sms(message, phone_number)\n end\n end", "def not_spam\n errors.add(:base, \"invalid reply\") if check_field.present?\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 invalid_order(invalid) \n @misplaced = invalid\n mail :to => \"honzik@localhost\", :subject => 'Invalid order requested'\n end", "def send_free_confirmation(phone_number, iphone)\n service_layer.send_message(phone_number, MessageBuilder::free_confirmation, false)\n iphone.increment!(:sent)\n end", "def send_verification(phone:)\n raise StandardError, \"Phone can't be blank\" if phone.blank?\n raise StandardError, \"Please enter a valid phone\" unless PhoneValidator.valid?(phone)\n\n # check if a code was already sent to this phone number\n existing_code = redis.get(phone_key(phone))\n if existing_code\n\n # if a code was already sent, we need to check\n # that time has passed before re-sending it\n # we don't want to allow users to send too many SMS\n # because they cost money and could be abused\n too_early = redis.get(resend_key(phone)).present?\n\n raise StandardError, \"Can't resend a code this soon\" if too_early\n\n # verify that the maximum number of attempts was not yet reached\n attempts = redis.get(attempts_key(phone)).to_i\n raise StandardError, \"You reached the maximum number of attempts, please wait\" if attempts > MAX_ATTEMPTS\n\n # if time has passed, we re-send the same code\n code = existing_code\n else\n # generate N digit code\n code = SecureRandom.random_number(10 ** CODE_LENGTH).to_s.rjust(CODE_LENGTH, \"0\")\n\n # save this code in redis under the given phone number\n redis.set(phone_key(phone), code, ex: EXPIRATION, nx: true)\n # set attempts to 0\n redis.set(attempts_key(phone), \"0\", ex: EXPIRATION, nx: true)\n end\n\n # reset a timer for being able to send a code for a given phone number\n redis.set(resend_key(phone), \"true\", ex: TIME_BEFORE_RESEND, nx: true)\n\n content = \"Verification code: #{code}\"\n # actually send the SMS using twilio or some other service\n Messenger.call(phone: phone, message: content)\n end", "def user_has_phone_if_notify\n if user_notification != \"Do not notify\" && (user.phone_number == \"\" || user.phone_number == nil)\n errors.add :user_notification, \"requires that you provide a phone number under the \\\"Edit Account\\\" page.\"\n end\n end", "def validate_to_input\n if inbound_request? && !account.phone_numbers.where(number: to).exists?\n errors.add(:to, I18n.t('errors.messages.parameter_not_found'))\n end\n end", "def raise_unprocessable\n message = 'Unable to process submission digitally'\n claim.errors.add(:base, message, message: message)\n raise(Common::Exceptions::ValidationErrors, claim)\n end", "def check_phone_no_format\n is_valid = Spree::Address.is_phone_valid?(@phone)\n render text: is_valid\n end", "def request_declined me \n @amount = me.amount\n @me = me\n @currency = me.account.currency\n subjects = \"Money request declined by recipient!\"\n mail to: me.sender.email, subject: subjects\n end", "def send_sms_token\n if(self.phone?)\n generate_sms_token! if self.sms_confirmation_token.nil?\n ::Devise.sms_sender.send_sms(self.phone, I18n.t(:\"devise.sms_activations.sms_body\", :sms_confirmation_token => self.sms_confirmation_token, :default => self.sms_confirmation_token))\n else\n self.class.sms_confirmation_keys.each do |key|\n self.errors.add(key, :no_phone_associated)\n end\n false\n end\n end", "def has_wrong_number?\n status_code == '1'\n end", "def invalid_address\n render_error(:unprocessable_entity, {recipient: ['invalid address']})\n end", "def ensure_account_is_not_pending_recovery\n self.match.is_not_pending_recovery!\n end", "def send_to_phone(phone_obj, message, options={})\n\n if options[:skip_validation]\n phone_text = phone_obj.is_a?(ActiveRecord::Base) ? format_phone_number(phone_number) : phone_obj\n return send_message(phone_text, message, options)\n end\n\n phone_number = phone_obj.is_a?(ActiveRecord::Base) ? phone_obj :\n find_or_create_phone_number(phone_obj, options)\n\n assert_message_options!(phone_number, message, options)\n send_message(format_phone_number(phone_number), message, options)\n end", "def deliverable?\n recipient.status != \"address_not_exist\"\n end", "def send_sms_verification_code\n number_to_send_to = phone_number\n verification_code = phone_verification_code\n sms_message_body = I18n.t(\"devise.phone.message_body\", :verification_code => verification_code)\n\n sms = Sms.new\n sms.phone_number = number_to_send_to\n sms.message = sms_message_body\n return false unless sms.send!\n\n true\n end", "def turn_number(pharm_number,off_or_on,staff_phone_number)\n $stderr.puts \"trying to turn number #{off_or_on}\"\n # does not allow anyone to turn off a primary number\n is_primary_number = Pharmacy.where(:preferred_number_id => pharm_number).count > 0\n\n if (is_primary_number)\n sms_message = \"Sorry this is the primary number associated with this pharmacy. If this number needs to be turned off, please contact Satter.\"\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => staff_phone_number,\n :body => sms_message)\n\n else\n\n #TO DO : we may have this number lingerieng hte in the pending calls table so probably want to check and remove\n\n Number.where(:id => pharm_number).first.update(:call_this_number => off_or_on == 'on' ? 1 : 0)\n sms_message_confirmation = \"#{pharm_number} has been turned #{off_or_on}. Thank you.\"\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => staff_phone_number,\n :body => sms_message_confirmation)\n end\n nil\nend", "def is_not_pending_recovery!\n self.update_attribute(:verification_key, nil) if self.is_pending_recovery?\n end", "def test_get_verification_status_invalid\n test_recipient = 'number'\n\n verification = @twizo.create_verification(test_recipient)\n\n assert_raise Twizo::TwizoError do\n verification = verification.send\n end\n end", "def reject_invalid_numbers\n @customer_numbers.reject! { |num| !Phonelib.valid?(num) }\n end", "def sms number, message\n response = @connection.cmd \"String\" =>\"sms send #{number} #{message}\", \"Match\" => /OK|KO:(.*)/, \"Timeout\" => 5\n if response.chomp == \"OK\"\n true\n else\n raise response.chomp.sub \"KO:\",''\n end\n end", "def fallback_to_twilio\n sms.output = :twilio\n sms.deliver\n end", "def do_not_email?\n false\n end", "def add_phone_number!(phone_number)\n clean_phone_number = Expect.clean_phone_number(phone_number)\n \n unless self.phone_numbers.where(clean_phone_number: clean_phone_number).any?\n self.phone_numbers.create(phone_number: phone_number)\n end\n end", "def confirm_phone\n pending_any_phone_confirmation do\n if phone_confirmation_period_expired?\n self.errors.add(:phone, :confirmation_period_expired)\n return false\n end\n\n self.phone_confirmed_at = Time.now # .utc\n if pending_phone_reconfirmation?\n skip_phone_reconfirmation! # TODO: phone will be changed\n self.phone = unconfirmed_phone\n self.unconfirmed_phone = nil\n end\n save(validate: true)\n end\n end", "def process_blocked_numbers\n # eg. 12504274006\n from = params['From']\n\n # Innocent until proven guilty\n blocked = false\n\n # Collection of digits from Twilio that are invalid.\n #\n # see the following link for exact details on these blocked digits.\n # https://www.twilio.com/help/faq/voice/why-am-i-getting-calls-from-these-strange-numbers\n known_invalids = [\"7378742833\", \"2562533\", \"8656696\", \"266696687\"]\n\n # Special int only form of our From number\n from_int = strip_to_int(from).to_s\n\n if from.present?\n if known_invalids.include? from_int\n log \"Invalid Customer From number: matches known blocked / invalid numbers - #{from} - #{from_int}\"\n blocked = true\n end\n\n elsif from.length < 7\n log \"Invalid Customer From number: strangely short number - #{from}\"\n blocked = true\n\n else\n log \"Invalid Customer From number: not present - #{from || 'nil'}\"\n blocked = true\n end\n\n # If anything got triggered,\n # we will redirect to the blocked response.\n if blocked\n #redirect_to invalid_number_path(device: params[:action])\n device = params[:action].to_sym\n\n xml = Twilio::TwiML::Response.new do |b|\n case device\n when :sms\n b.Say \"Sorry, in order to use our services you must be calling from a non-blocked or public number.\"\n when :voice\n b.Message \"Sorry, in order to use our services you must be texting from a non-blocked or public number.\"\n end\n end.text\n\n render xml: xml\n end\n\n end", "def valid_phone_number\n\t\tnumber = self.number.scan(/\\d/).join('')\n\t\tnumber[0] = '' if number[0] == \"1\"\n\n\t\tif number.length != 10\n\t\t\terrors.add(:phone, \"must be a valid 10 digit phone number\")\n\t\telse\n\t\t\tself.number = number\n\t\tend\n\tend", "def pending_any_confirmation\n if (!confirmed? || pending_reactivation?)\n yield\n else\n self.errors.add(:phone, :already_confirmed)\n false\n end\n end", "def unless_sms_confirmed\n unless confirmed_sms?\n yield\n else\n self.class.sms_confirmation_keys.each do |key|\n self.errors.add(key, :sms_already_confirmed)\n end\n false\n end\n end", "def needs_sending?\n !sent? && !flagged?\n end", "def send_sms!(msg)\n return false unless sms_alerts and phone_number_is_valid? and not mobile_carrier.blank?\n PersonMailer.send_sms(self, msg).deliver\n end", "def assert_does_not_send(receiver, method, *args)\n SendFailure.assert!(receiver, method, *args)\n end", "def can_send?\n !sent?\n end", "def allow_invalid_person?\n allow_invalid_person\n end", "def sms_confirmation_required?\n !confirmed_sms?\n end", "def missed\n EventMailer.missed\n end", "def send_message\n send unless SuppressionList.include?(receiver)\n end", "def not_sent_to_me=(value)\n @not_sent_to_me = value\n end", "def send!(message)\n if(self.msisdn_number.blank?)\n if(info = get_sim_info)\n self.update_attribute(:msisdn_number, response[:msisdn])\n end\n end\n\n JasperSmsGateway.send(self.msisdn_number, message)\n end", "def invalid?\n action_enum = action rescue nil\n !action_enum || (ack_required? && !has_serial?)\n end", "def iphone_required(udid = params[:udid])\n udid = udid.to_s.strip\n \n raise \"IPhone UDID isn't given\" if udid.blank?\n raise \"IPhone UDID is invalid\" unless /^[0-9a-f]{40}$/i =~ udid\n \n @iphone = Iphone.find_or_create_by_udid(udid)\n\n raise \"IPhone is not allowed to send free messages\" unless @iphone.can_send_free_messages?\n end", "def before_send_notifications\n\t\treturn true unless self.resend_recipient_ids.blank?\n\t\treturn true unless self.force_send_notifications.blank?\n\t\treturn false\n\tend", "def before_send_notifications\n\t\treturn true unless self.resend_recipient_ids.blank?\n\t\treturn true unless self.force_send_notifications.blank?\n\t\treturn false\n\tend", "def skip_sms_confirmation!\n self.sms_confirmed_at = Time.now\n end", "def field_register_pharmacy(pharm_number,pharm_contact_name,staff_phone_number)\n pharm_number = standardize_number(pharm_number[0])\n\n #check to make sure this number is not already registered\n phone_number_in_db = Number.where(:id => pharm_number)\n if phone_number_in_db.count > 0\n send_try_again_sms(staff_phone_number,\"This number is already registered to pharmacy #{phone_number_in_db.first.pharmacy_id}\")\n return nil\n end\n\n\n Pharmacy.insert(:preferred_number_id => pharm_number,\n :name => pharm_contact_name)\n pid = Pharmacy.where(:preferred_number_id => pharm_number).first.id\n\n Number.insert(\n :id => pharm_number,\n :pharmacy_id => pid,\n :call_this_number => 1,\n :created_at => Time.now\n )\n\n #settings so we dont call em\n PendingCall.insert(\n :number_id => pharm_number,\n :attempts => $max_ors_attempts,\n :error_message_sent => 1\n )\n\n # Default start and end time for pharmacies\n AvailableTime.insert(\n :pharmacy_id => pid,\n :start_time => \"09:00:00\",\n :end_time => \"21:00:00\"\n )\n\n sms_message_confirmation = \"Registration successful. Pharmacy ID number is #{pid}\"\n $stderr.puts \"sending reg confirmation to to #{staff_phone_number}\"\n\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => staff_phone_number,\n :body => sms_message_confirmation)\n #send message to user\n $stderr.puts \"sending reg confirmation to to #{pharm_number}\"\n $client.account.sms.messages.create(\n :from => $sms_out_number,\n :to => pharm_number,\n :body => \"Welcome to bangpharma. Your pharmacy ID is #{pid}.\")\n\n return nil\nend", "def error?\n reply_code > 0 && reply_code != 20201\n end", "def does_a_phone_to_this_sip_account_exist\n if !Phone.exists?(:id => self.phone_id)\n errors.add(:phone_id, \"(ID #{self.phone_id}) does not exist.\")\n end \n end", "def validate_to_address\n raise StanzaErrors::FeatureNotImplemented.new(self, 'cancel') unless pubsub\n end", "def needs_address?\n !flagged? && !sent?\n end", "def bad_req_code\n SendgridClient.bad_req_code\n end", "def with_sms_verification(phone)\n # Try to find SMS verification request\n sms_verification = SmsVerification.where({ cookie: cookie, phone: phone }).first\n\n # No SMS code sent yet.\n unless sms_verification\n generate_sms_verification_code(phone)\n false\n # SMS code was already sent\n else\n # SMS code is correct\n if sms_verification.code == params[:sms_verification_code]\n reset(sms_verification)\n true\n # SMS code is incorrect\n else\n sms_verification.attempts += 1\n sms_verification.save\n\n if sms_verification.attempts >= 3\n reset(sms_verification)\n generate_sms_verification_code(phone)\n end\n\n false\n end\n end\n end", "def error_occured(error)\n @error = error\n mail :to => '[email protected]', subject: 'Depot Exception Warning'\n end", "def send phone_number\n account = CLIENT.account \n message = account.sms.messages.create({from: TAKEAWAY_NUMBER , to: phone_number, body: \"Thanks for your order! It shall arrive no later than #{@delivery_time.strftime(\"%H\")}:#{@delivery_time.strftime(\"%M\")}.\"})\n message.body\n end", "def denied\n ContactMailer.denied\n end", "def not_pending\n if user.incoming_friend_requests.pluck(:user_id).include?(friend_id)\n errors.add(:friend, 'already requested friendship')\n end\n end", "def validate_from_input\n if outbound_request? && !account.phone_numbers.where(number: from).exists?\n errors.add(:from, I18n.t('errors.messages.parameter_not_found'))\n end\n end", "def call?\n if rejection_reason\n TinyDialer::Log.info \"Rejected #{phone}: #{rejection_reason}\"\n return\n end\n # Make sure (now, now) overlaps (start, stop)\n now = (Time.now.utc + (3600*(timezone)).to_i).strftime('%H:%M')\n unless TinyDialer.db.fetch(\"select ('#{now}'::text::time, '#{now}'::text::time) OVERLAPS ('#{state.start}'::text::time, '#{state.stop}'::text::time)\").first[:overlaps]\n TinyDialer::Log.info \"Rejected #{phone}: Outside of calling times #{state.start} and #{state.stop}\"\n return false\n end\n true\n rescue => e\n TinyDialer::Log.error e\n return\n end", "def reject?(sender)\r\n false\r\n end", "def raise_if_transaction_running\n raise Agent::Error.new(Agent::Error::TRNS_IPRG) if check_for_running_transaction\n end", "def handle_smtp_error(error)\n case error.message\n when /^512/, /^550/\n update(status: 'hard_bounced')\n recipient.update(status: 'address_not_exist')\n # Recipient's mailbox full\n when /^422/\n update(status: 'not_sent')\n else\n update(status: 'hard_bounced')\n raise error\n end\n end", "def cell_phone_in_e164; end", "def rejected\n RequestMailer.rejected\n end", "def send_message(phone_number, message, options={})\n raise SmsOnRails::SmsError.new(\"Override send_message in subclass #{self.class}\")\n end", "def submit_number\n content_tag(\"strong\", configatron.incoming_sms_number.blank? ? \"[\" + t(\"sms_form.guide.unknown_number\") + \"]\" : configatron.incoming_sms_number)\n end", "def assert_message_options!(phone_number, message, options)\n raise SmsOnRails::SmsError.new(\"Invalid or undefined phone number: #{phone_number.human_display}\") unless phone_number && phone_number.valid?\n raise SmsOnRails::SmsError.new(\"No message specified\") unless message\n raise SmsOnRails::SmsError.new(\"Message is too long. #{message}\") if message.length > self.class.max_characters\n check_white_list!(phone_number)\n check_do_not_send!(phone_number)\n end", "def allow_to_fail(ticket_number)\n if ticket_number\n @result.allow_ticket = ticket_number.to_s\n end\n end", "def send_urgent?; preference == EmailSetting::OPTIONS[:'All Urgent Requests'] || preference.nil?; end", "def can_subscribe?()\n \treturn !(self.phoneNumber.nil?)\n\tend", "def phone_number\n\t\t\trecipient.phone_number\n\t\tend", "def verifyphonenumber\n tc = Twilio::REST::Client.new tsid, tauthtoken\n # Ref: https://www.twilio.com/docs/api/rest/outgoing-caller-ids\n call_delay_in_sec = 45 # Can be 0 to 60 seconds\n caller_id = tc.outgoing_caller_ids.create(:phone_number => params[:PhoneNumber], :call_delay => call_delay_in_sec)\n respond_to do |format|\n format.json { render :json => {:verification_code => caller_id.validation_code},\n :status => :ok }\n end\n end", "def allow_mails_from_merchant\n end", "def notify_or_raise(ex)\n if should_raise?\n fail ex\n else\n notify_or_ignore_with_options(ex)\n end\n end", "def phone_verification_needed?\n if phone_number.blank?\n errors.add(:phone_verification_code, :empty_phone_number_field)\n false\n elsif phone_number_verified\n errors.add(:phone_verification_code, :phone_verification_not_needed)\n false\n else\n true\n end\n end", "def emergency_contact_for?(host)\n self.is_emergency_contact_for? host\n end", "def user_has_number\n unless current_user.phone_verifications.count > 0\n redirect_to root_path\n end\n end", "def ensure_recipient_does_not_have_account_for_another_community\n @braintree_account = BraintreeAccount.find_by_person_id(@braintree_payment.recipient_id)\n\n if @braintree_account\n # Braintree account exists\n if @braintree_account.community_id.present? && @braintree_account.community_id != @current_community.id\n # ...but is associated to different community\n account_community = Community.find(@braintree_account.community_id)\n flash[:error] = \"Unfortunately, we cannot proceed with the payment. Please contact the administrators.\"\n\n error_msg = \"User #{@current_user.id} tries to pay for user #{@braintree_payment.recipient_id} which has Braintree account for another community #{account_community.name(I18n.locale)}\"\n BTLog.error(error_msg)\n ApplicationHelper.send_error_notification(error_msg, \"BraintreePaymentAccountError\")\n redirect_to person_transaction_path(@current_user, @conversation)\n end\n end\n end", "def must_not_be_overdue\n\t\tif self.profile.state == 'Overdue'\n\t\t\terrors.add(:base, \"This person has unpaid charges.\")\n\t\tend\n\tend", "def unsupported_retryable_write?\n # code 20 is IllegalOperation.\n # Note that the document is expected to be a BSON::Document, thus\n # either having string keys or providing indifferent access.\n code == 20 && server_message&.start_with?(\"Transaction numbers\") || false\n end", "def phone_present\n if phone.blank?\n errors.add(:phone, \"Can't be empty\")\n end\n end", "def reject?(sender)\n false\n end", "def reject?(sender)\n false\n end", "def send_free_message(kind, phone_number = params[:phone_number])\n raise \"Phone_number is not given\" if phone_number.blank?\n \n messaging = Messaging.new\n messaging.send(\"send_free_#{kind}\", normalize_phone(phone_number), @iphone)\n \n render :text => \"\"\n end", "def needs_invoice_number\n !draft and number.nil?\n end", "def needs_invoice_number\n !draft and number.nil?\n end", "def validate_pos_invoice\n if self.customer_id && !self.pos_invoice_addresses\n raise_error('Billing address Required!!!!')\n end\nend", "def black_listed?(phone, text)\n number_regex = /\\+1(\\d){10,10}$/\n if number_regex.match(phone).nil? \n true \n end\n end", "def bad_req_code\n assert_equal SendgridClient.bad_req_code, MailgunClient.bad_req_code\n SendgridClient.bad_req_code\n end" ]
[ "0.607112", "0.6060908", "0.6054189", "0.60044056", "0.5925642", "0.5805717", "0.5770679", "0.5762686", "0.57417256", "0.5707474", "0.5676484", "0.5671356", "0.56031024", "0.5597773", "0.55894005", "0.55642843", "0.5537139", "0.552299", "0.5512725", "0.55118793", "0.5495996", "0.54713225", "0.5455601", "0.54512674", "0.54278845", "0.54204684", "0.54056627", "0.5397728", "0.5391648", "0.5386057", "0.5369798", "0.5361086", "0.5355876", "0.53316617", "0.5316478", "0.53164256", "0.529801", "0.5296686", "0.52963084", "0.52894247", "0.52549577", "0.5251557", "0.52493286", "0.5231002", "0.52176094", "0.5196391", "0.51947427", "0.51859903", "0.5183629", "0.51781464", "0.5171563", "0.51622003", "0.5151942", "0.51497775", "0.5143218", "0.5143218", "0.51285964", "0.51175493", "0.51121116", "0.5104288", "0.5091883", "0.509078", "0.50872546", "0.50857425", "0.5074237", "0.5073653", "0.5069906", "0.5067416", "0.5065987", "0.5058929", "0.5052049", "0.5048713", "0.50486374", "0.5048183", "0.50460374", "0.50438446", "0.5020094", "0.501119", "0.50074154", "0.5007362", "0.50037694", "0.5003388", "0.4997449", "0.4996889", "0.49967787", "0.49940023", "0.49904668", "0.49863574", "0.49600065", "0.49566457", "0.4955655", "0.49526978", "0.49512637", "0.49512637", "0.4946004", "0.4939912", "0.4939912", "0.49345484", "0.49339047", "0.49302563" ]
0.8045469
0
Raise exception if invalid data is entered
def assert_message_options!(phone_number, message, options) raise SmsOnRails::SmsError.new("Invalid or undefined phone number: #{phone_number.human_display}") unless phone_number && phone_number.valid? raise SmsOnRails::SmsError.new("No message specified") unless message raise SmsOnRails::SmsError.new("Message is too long. #{message}") if message.length > self.class.max_characters check_white_list!(phone_number) check_do_not_send!(phone_number) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invalid\n puts \"Invalid entry, please try again.\"\n end", "def invalid(*arguments)\n raise Invalid\n end", "def is_valid?\n raise Exception\n end", "def validate_input\n problems = test_input\n raise OperationalError, \"Found the following problems: #{problems}\" unless problems.empty?\n end", "def error\n print \"That is not a valid input. \\n\"\n end", "def unrecognized_input\n puts \"Input not recognized or is invalid.\"\n exit_screen\n end", "def validate_input(data)\r\n @field_names[1..-1].each do |f|\r\n next if data[f].nil?\r\n\r\n raise 'Invalid data %s for column %s' % [data[f], f] unless \\\r\n KBTable.valid_data_type?(@field_types[@field_names.index(f)],\r\n data[f])\r\n end\r\n end", "def displayinvalidinputerror\r\n\t\t\[email protected]('Invalid input.')\r\n\t\tend", "def invalid_input\n puts \"Invalid input, please try again\"\nend", "def invalid; end", "def error\n raise StandardError, 'Error parsing input'\n end", "def error\n\t\tputs \"*********************\"\n\t\tputs \"<ERROR> Invalid input\"\n\t\tputs \"*********************\"\n\tend", "def invalid_inputs\n puts \"Invalid input! Your positions must have x and y coordinates \"\\\n \"between 0 and 7.\"\n end", "def validate_input_1option\n begin\n x = gets.chomp.to_i\n raise \"Incorrect Input\" if x != 1\n return x\n rescue\n puts \"Please Enter 1\"\n validate_input_1option\n end\nend", "def validate\n super\n rescue Sudoku::Constraint::ConstraintError => e\n raise ConstraintError, e.message + \" in a column\"\n end", "def err_code\n puts \"Your date is not valid............!\"\n Kernel.exit\n end", "def check_against_input_for_specials(data)\r\n @field_names[1..-1].each do |f|\r\n raise(ArgumentError,\r\n 'You cannot input a value for this field: %s' % f) if \\\r\n @field_extras[@field_names.index(f)].has_key?('Calculated') \\\r\n or @field_extras[@field_names.index(f)].has_key?('Link_many') \\\r\n and not data[f].nil? \r\n end\r\n end", "def vash_value_exception(val,*args)\n name = vash_value_name(val,*args)\n msg = \"invalid value #{val.inspect}\"\n msg += \" at position #{args[0].inspect}\" unless args[0].nil?\n msg += \" for option #{args[1].to_s}\" unless args.length < 2\n [Puppet::Util::PTomulik::Vash::InvalidValueError, msg]\n end", "def exception_on_syntax_error=(_arg0); end", "def validate_data\n raise Error, \"no user found associated with #{@database}\" unless @user\n raise Error, \"password not defined for #{@user}@#{@database}\" unless @password\n end", "def validate\n (raise ArgumentError, 'Wrong number of arguments, expected 1' if ARGV.length != 1)\n (raise IndexError, 'Input parameter has to be a natural number' unless /\\A\\d+\\z/.match(@price))\n (raise IndexError, 'Minimal price is 8 cents' if @price.to_i < 8)\n end", "def test_valid_input\n assert_equal(nil, RomanMathmaticalOperation.new(\"X\", \"+\",\"V\").send(:valid_input))\n exception = assert_raise(\"RomanMathmaticalOperationError\") {RomanMathmaticalOperation.new(\"X\", \"+\",nil).send(:valid_input)}\n assert_equal(\"This X or is not valid\", exception.message)\n exception = assert_raise(\"RomanMathmaticalOperationError\") {RomanMathmaticalOperation.new(\"X\", \"%\",\"V\").send(:valid_input)}\n assert_equal(\"Operator missmatch\", exception.message)\n end", "def validate_paramters\n raise Scorekeeper::MissingParameterException if @income.nil? || @zipcode.nil? || @age.nil?\n end", "def validate!(data)\n keys.each do |key|\n raise InvalidSchemaError.new(\"missing key #{key}\") unless data.key?(key)\n end\n end", "def invalid_command\n puts \"Please enter a valid command\"\nend", "def invalid_command\n puts \"Please enter a valid command\"\nend", "def invalid_answer?\n raise NotImplementedError\n end", "def invalid_command\n puts \"Please enter a valid command\"\nend", "def valid_input\n if !@operand_one or !@operand_two or !RomanMathmaticalOperation.is_roman(@operand_one) or !RomanMathmaticalOperation.is_roman(@operand_two)\n raise RomanMathmaticalOperationError, \"This #{@operand_one} or #{@operand_two} is not valid\"\n end\n\n unless OPERATORS.include?(@operator)\n raise RomanMathmaticalOperationError, \"Operator missmatch\"\n end\n end", "def invalid_command\n # code invalid_command here\n puts \"Please enter a valid command\"\nend", "def test_get_location_bad_input\n assert_raises 'Improper typing of location input argument in method get_location' do\n locations = LocationRelation.new\n locations.get_location 55\n end\n end", "def test_validate_patient_account_number_by_giving_invalid_data\n eob = InsurancePaymentEob.new\n eob.patient_account_number = \"gh.gh-&&89\"\n eob.save\n assert !eob.valid?, eob.errors.full_messages.to_s\n end", "def exception_on_syntax_error; end", "def _entry_3_invalidcommand(*args)\n\n end", "def _entry_4_invalidcommand(*args)\n\n end", "def assert_valid\n raise ValidationError, \"no name\" unless name\n raise ValidationError, \"no version\" unless version\n raise ValidationError, \"no summary\" unless summary\n #raise ValidationError, \"no maintainer\" unless maintainer\n #raise ValidationError, \"no homepage\" unless homepage\n end", "def input_invalid_username\n fill_in(USERNAME_INPUT_ID, :with => 'Ruben12ddf')\n end", "def raise_invalid(value)\n if value.is_a?(Numeric)\n raise EnumError, \"#{value.inspect} is out of bounds of #{self.class.name}\"\n else\n raise EnumError, \"#{value.inspect} is not valid for #{self.class.name}\"\n end\n end", "def _entry_1_invalidcommand(*args)\n\n end", "def _entry_1_invalidcommand(*args)\n\n end", "def validate\r\n validate! rescue false\r\n end", "def validate_input(data)\n flag=true\n while flag && data==\"\"\n puts \"Invalid Input!!! \"\n puts \"Enter Again : \"\n data=gets.chomp\n end\n return data\nend", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def check_errors\n unless valid? \n bigmessage = self.errors.full_messages.join \"\\n\" \n raise bigmessage unless bigmessage.empty?\n \n raise \"format should not be nil\" if format.nil?\n raise \"invalid format #{format}\" unless format.valid? \n raise \"#{self.errors.to_a}, error encountered while saving #{@datafile_id}, #{@bitstream_id} \" \n end\n end", "def validate\n 2.times { puts }\n puts <<-EOF\nYou have entered the following information\nApocalypse server : #{@address}\nApocalypse server port : #{@port}\nApocalypse username : #{@username}\nApocalypse password : #{'*' *@password.length}\nThis Server' hostname : #{@hostname}\nEOF\n\n print \"Is this correct? [no]: \"\n raise Exception.new(\"Aborted by user.\") unless gets =~ /^y(?:es|)$/\n puts\n end", "def validate_data_format\n unless data.is_a?(Array)\n raise DataFormatError, \"Data set(s) should be given as an array\"\n end\n end", "def validate!(data)\n fail UnexpectedTypeError, 'A Hash was expected' unless data.is_a? Hash\n end", "def invalid_option\n\t\t\t\talert_menu \"Invalid option!\"\n\t\t\tend", "def invalid\n @invalid\n end", "def invalid_args!(message)\n raise InvalidCommandLine, message\n end", "def validate_params\n puts\n puts \"You're about to import data in your '#{Rails.env}' instance.\"\n puts \"You'll use the following source files:\"\n puts \" users: #{options['users'] || '-'} \"\n puts \" projects: #{options['projects'] || '-'}\"\n puts \" issues: #{options['issues'] || '-'}\"\n puts\n puts \"/!\\\\ Make sure to have a backup of your database before continuing.\"\n puts\n print 'Is this ok ? [y/n]: '\n STDOUT.flush\n ok = STDIN.gets.chomp!\n exit 2 if ok != 'y'\n puts\n end", "def error_message\n raise \"calculator is empty\"\n end", "def validate(arg)\n arg.each do |arg|\n if arg[0].to_f > 90 || arg[0].to_f < -90\n msg = \"Latitude '#{arg[0]}' is invalid - must be between -90 and 90\"\n raise Error, msg\n end\n if arg[1].to_f > 180 || arg[1].to_f < -180\n msg = \"Longitude '#{arg[1]}' is invalid - must be between -180 and 180\"\n raise Error, msg\n end\n end\n end", "def test_add_location_bad_input\n assert_raises 'Improper typing of location input in method add_location' do\n locations = LocationRelation.new\n locations.add_location Location.new('test_location_1')\n end\n end", "def exception\n raise \"It's a bad one!\"\n end", "def raise_bad_format\r\n error_message = ErrorMessage.new(\"400\", \"Api:et stödjer inte det begärda formatet.\",\r\n \"Felaktig begäran. Kontakta utvecklaren.\")\r\n render json: error_message, status: :bad_request\r\n end", "def error?; end", "def error?; end", "def error?; end", "def test_that_an_invalid_fmt_argument_raises\n assert_raises(ArgumentError) { Eddy::Models::Element::DT.new(fmt: :not_valid, val: @epoch) }\n end", "def raise_unprocessable\n message = 'Unable to process submission digitally'\n claim.errors.add(:base, message, message: message)\n raise(Common::Exceptions::ValidationErrors, claim)\n end", "def _entry_2_invalidcommand(*args)\n\n end", "def method_missing(name, *args, &block)\n Waw::Validation.send(name, *args, &block)\n rescue Exception => ex\n raise ex.class, ex.message, caller\n end", "def _entry_5_invalidcommand(*args)\n\n end", "def test_raises_error_with_invalid_dates\n assert_raises DataWrangler::Configuration::Error do\n _new_validator(\n {\n \"from\" => @invalid_date_string,\n \"to\" => Date.today.to_s\n }\n )\n end\n end", "def log_data_invalid_error(data, exception)\n open(OPERATION_IMPORT_LOG, 'a') do |file|\n\n file.puts \"==== DATA INVALID ====\"\n file.puts \"Skipping Invoice #{data[:invoice_num]} of company #{data[:company]}\"\n file.puts \"Reason - #{exception.message}\"\n end\n end", "def invalid_user_shot\n \"Please enter a valid coordinate:\\n> \"\n end", "def check_emission_validity # :nodoc:\n \t super\n \trescue EventNotExecutable => e\n\t refine_emit_exception(e)\n \tend", "def check_emission_validity # :nodoc:\n \t super\n \trescue EventNotExecutable => e\n\t refine_emit_exception(e)\n \tend", "def validate_input input\r\n\t\t\t\t\t\t\tif @console\r\n\t\t (input.match(/\\A[[:alpha:][:blank:]]+\\z/) || (check_enter input)) && (input.size < 2)\r\n\t\t else\r\n\t\t input.match(/\\A[[:alpha:][:blank:]]+\\z/) && !(check_enter input)\r\n\t\t end\r\n\t\t end", "def edit_missing\n @punch.arrival and @punch.departure and raise \"Nulla da inserire\"\n end", "def error_check\n raise \"Subject is blank!\" if @message_config[:subject].strip.length == 0\n raise \"Subject is long!\" if @message_config[:subject].length > 120\n raise \"Body is blank!\" if @message_config[:body].strip.length == 0\n end", "def error_handling(cookbook, item_to_make)\n unless cookbook.has_key?(item_to_make)\n raise ArgumentError.new(\"#{item_to_make} is not a valid input\")\n end\nend", "def error_handling(cookbook, item_to_make)\n unless cookbook.has_key?(item_to_make)\n raise ArgumentError.new(\"#{item_to_make} is not a valid input\")\n end\nend", "def check!\n super()\n \n if not [Symbol, String, Integer, NilClass].any?{ |cl| @id.kind_of?(cl) }\n raise Exception::new(\"ID must contain Symbol, String, Number or nil if included.\")\n end\n end", "def invalid_command\n puts \"Please enter a valid command\"\n #invalid_command\n # code invalid_command here\nend", "def validate!\n # Expression must be present.\n if expression.to_s.length == 0\n raise SkyDB::Query::ValidationError.new(\"Invalid expression for selection group: '#{expression.to_s}'\")\n end\n end", "def validate!\n raise ArgumentError, 'Context should be a String' unless @context.is_a? String\n raise ArgumentError, 'Pattern should be a String' unless @pattern.is_a? String\n raise ArgumentError, 'Starting Index should be an Integer' unless @starting_index.is_a?(Integer)\n raise ArgumentError, 'Starting Index should be >= 0' unless @starting_index >= 0\n raise ArgumentError, 'Noise Threshold should be an Integer' unless @noise_threshold.is_a?(Integer)\n raise ArgumentError, 'Noise Threshold should be >= 0' unless @noise_threshold >= 0\n end", "def validate_input\n\t\tif @options[:num].is_a?(Integer) and @options[:num] >= 0 \n\t\t\t@num = @options[:num].to_i.abs \n\n\t\telse\n\t\t\t@num = \"NAN\"\n\n\t\tend\n\tend", "def check_age(age)\n raise ArgumentError, \"Enter Positive Number\" unless age > 0\nend", "def _entry_6_invalidcommand(*args)\n\n end", "def validate_fields\n %w[email author].each do |field|\n value = self.send(field)\n abort \"Hoe #{field} value not set. aborting\" if value.nil? or value.empty?\n end\n end", "def validate()\n # rung base method to check\n # for alphabet\n super\n # check for sequenz\n # an validate sequenz length\n if (sequenz?)\n # hier check sequenz length \n if(@lenth != @string.length)\n raise \"String length is not correct\\nRequired lenght: #{@lenth}\\nCurrent length: #{@string.length}\\nString:#{@string}\" \n end\n end\n end", "def test_missing_argument_invalid_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,'s'])\n\tend", "def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end", "def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end", "def validate!\n valid? || raise(LimitExceeded.new(@string))\n end", "def validate_item( x )\n fail 'not implemented!'\n end", "def valid?\n raise 'Not Implemented'\n end", "def test_receiving_amount_invalid_format\n parser = Parser::new\n transaction = \"Cyrus[10]\"\n assert_raises SystemExit do\n parser.parse_receiving_amount transaction\n end\n end", "def test_create_invalidgrade\n begin\n Grade.new(\"ABD\")\n rescue ArgumentError\n assert(true) # this is a specifc error we throw\n rescue\n assert(false) # uncaught exception\n end\n end", "def validate_file_input\n if params[:input_data].present?\n check_format(params[:input_data])\n else\n\t\t\traise_error NO_FILE_PROVIDED\n\t\tend\n end", "def raise(*rest) end", "def raise(*rest) end", "def raise!(contract)\n raise InvalidContract.new(contract.errors.to_s) if @raise_on_invalid\n end", "def invalid_key(system_key)\n fail InvalidSyntax, \"`#{system_key}` must be a String or a Symbol.\"\n end", "def check_args(hash)\n if !hash.include? :hostname\n raise ArgumentError, \"You must provide a hostname\"\n elsif !hash.include? :service_name\n raise ArgumentError, \"You must provide a service name\"\n elsif !hash.include? :return_code\n raise ArgumentError, \"You must provide a return code\"\n elsif !hash.include? :status\n raise ArgumentError, \"You must provide a status\"\n end\n end" ]
[ "0.7204732", "0.68714714", "0.6782001", "0.67791027", "0.66476434", "0.66430736", "0.6570518", "0.65528625", "0.6529928", "0.6499327", "0.64077157", "0.6353185", "0.622718", "0.6171436", "0.61366737", "0.6089337", "0.6045087", "0.60324174", "0.602325", "0.59874827", "0.59034556", "0.5864331", "0.5811513", "0.58071434", "0.5755359", "0.5755359", "0.57511705", "0.5744613", "0.5732374", "0.57254773", "0.57019234", "0.56989896", "0.56885624", "0.5676582", "0.5675137", "0.5669514", "0.5663841", "0.56626993", "0.5660872", "0.5660872", "0.565853", "0.5657506", "0.56424874", "0.56424874", "0.56424874", "0.56424874", "0.56424874", "0.5641804", "0.5639047", "0.56311613", "0.5629767", "0.56242055", "0.5624167", "0.5620074", "0.5617243", "0.5611294", "0.56037813", "0.55943465", "0.5589852", "0.558534", "0.5567994", "0.5567994", "0.5567994", "0.5564464", "0.5562715", "0.55604506", "0.5558527", "0.55557334", "0.55522805", "0.5539295", "0.55386055", "0.5532685", "0.5532685", "0.5522191", "0.55219823", "0.55188423", "0.5515611", "0.5515611", "0.54976404", "0.54924756", "0.5489707", "0.547742", "0.5467738", "0.54668593", "0.54642314", "0.5462251", "0.5449981", "0.54357463", "0.5428347", "0.5428347", "0.5425452", "0.5415947", "0.5410276", "0.5407577", "0.5396626", "0.5387051", "0.5379652", "0.5379652", "0.53785217", "0.53721356", "0.5368722" ]
0.0
-1
return the appropriate exception class Return a fatal error if the block returns true and a non fatal if the block returns false
def sms_error_class(&block)#:nodoc if yield SmsOnRails::FatalSmsError else SmsOnRails::SmsError end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_exception?; end", "def CATCH(exception_klass, &block)\n yield\n rescue ::Exception\n if $!.instance_of?(exception_klass)\n pass\n else\n failure(\"Faced a exception, that instance of #{exception_klass}.\",\n \"Faced a exception, that instance of #{$!.class}.\", 2)\n end\n else\n failure(\"Faced a exception, that instance of #{exception_klass}.\",\n 'The block was not faced any exceptions.', 2)\n ensure\n _declared!\n end", "def RESCUE(exception_klass, &block)\n fmt_err = ->err_cls { err_cls.ancestors.take_while { |mod| mod != Object }.join(' < ') }\n yield\n rescue exception_klass\n pass\n rescue ::Exception\n failure(\"Faced a exception, that kind of #{exception_klass}(#{fmt_err.call(exception_klass)}).\",\n \"Faced a exception, that instance of #{$!.class}(#{fmt_err.call($!.class)}).\", 2)\n else\n failure(\"Faced a exception, that kind of #{exception_klass}(#{fmt_err.call(exception_klass)}).\",\n 'The block was not faced any exceptions.', 2)\n ensure\n _declared!\n end", "def handle_exception(&block)\r\n yield\r\n\r\n rescue TypeError\r\n return Parsers::Message.invalid_type\r\n rescue Exception\r\n return Parsers::Message.unexpected_error\r\n end", "def exception_class; end", "def rescue_from(exception); end", "def catch_exceptions; end", "def fatal?; end", "def fatal?; end", "def fatal?\n exception.fatal?\n end", "def raise(exception_klass = T.unsafe(nil)); end", "def exception\n exception_class = error_class\n return unless exception_class\n\n exception_class.new(nil, stdout, stderr)\n end", "def error!\n # Unhandled exception\n if @exception\n exception_message\n exit 2\n # Some checksums did not match?\n elsif !(invalid_packages.empty? && invalid_metadata_files.empty?)\n error_message\n exit 2\n # We don't have checksums for some packages?\n elsif unverifiable_package_count != 0\n unverifiable_packages_message\n exit 2\n else\n success_message\n exit 0\n end\n end", "def run_and_convert_exceptions(&block)\n block.call\n rescue *self.class.expected_errors => e\n raise self.class.horza_error_from_orm_error(e.class).new(e.message)\n end", "def get_error\n error = nil\n begin\n yield\n rescue Exception, RuntimeError => e\n error = e\n end\n error\nend", "def raise(exception); end", "def expects_exception?; self.class.expects_exception; end", "def refute_exception\n yield\n rescue StandardError => e\n flunk e.message\n end", "def continued_exception; end", "def exit_exception; end", "def check_retval(rc, e_klass = nil)\n return true unless ::OpenNebula.is_error?(rc)\n fail (e_klass ? e_klass : RuntimeError ), rc.message\n end", "def build_exception\n begin\n klopfer!\n rescue => e\n return e\n end\n end", "def safe_rescue_exception?(exception)\n # Exceptions to be safe rescued\n errors = [\n { :type => PG::UniqueViolation, :messages => [\"ERROR: duplicate key value violates unique constraint\"] }, # Happens when primary key (id) is overwritten with where or create_with value\n { :type => PG::InvalidParameterValue, :messages => [\"ERROR: invalid hexadecimal digit\"] }, # Happens when setting binary_col with invalid values (usually when not going through Active Record, for example with update_columns/update_column)\n { :type => PG::InvalidTextRepresentation, :messages => [\"ERROR: invalid input syntax for type\"] }, # Happens when setting columns with special types (for example booleans or decimals) with invalid values (usually when not going through Active Record, for example with update_columns/update_column)\n { :type => PG::InvalidTextRepresentation, :messages => [\"ERROR: invalid input syntax for integer\"] }, # Happens when setting integer columns with invalid values (usually when not going through Active Record, for example with update_columns/update_column)\n { :type => PG::InvalidDatetimeFormat, :messages => [\"ERROR: invalid input syntax for type\"] }, # Happens when setting datetime columns with invalid values (usually when not going through Active Record, for example with update_columns/update_column)\n { :type => PG::DatetimeFieldOverflow, :messages => [\"ERROR: date/time field value out of range\"] }, # Happens when setting datetime columns with values without range, for example the value 0 (usually when not going through Active Record, for example with update_columns/update_column)\n { :type => PG::SyntaxError, :messages => [\"ERROR: syntax error at or near \\\"DISTINCT\\\"\", \"DISTINCT DISTINCT\"] }, # This is necessary due to a bug in Rails finder options when setting a limit, distinct true and eager_load on has_many or has_and_belongs_to_many\n { :type => PG::AmbiguousColumn, :messages => [\"ERROR: column reference \\\"id\\\" is ambiguous\"] }, # Happens when setting a value for finder option having while also setting a value for finder option eager_load or joins (it is probable expecting a different input format for having then)\n { :type => ActiveRecord::RecordNotFound, :messages => [] }, # Happens when we try to find a non-existing record (for example by using the find method with an unknown id)\n { :type => ActiveRecord::ConfigurationError, :messages => [\"Association named\", \"was not found\"] }, # Happens when trying to set an association method (for example includes) with an invalid association name\n { :type => ArgumentError, :messages => [\"invalid value for Integer()\"] }, # Happens when setting an invalid value for the limit finder option\n { :type => ArgumentError, :messages => [\"argument out of range\"] }, # Happens when setting an very small or very large value (such as 0000-00-00 00:00:00) for a datetime field (and possibly other fields)\n ]\n errors.each do |error|\n if exception.is_a?(error[:type])\n match = true\n error[:messages].each do |message|\n unless exception.message.scan(message).present?\n match = false\n break\n end\n end\n return true if match\n end\n end\n false\n end", "def continued_exception=(_arg0); end", "def fatal; end", "def assert_raise(error_to_raise = Exception)\n begin\n # Dangerous Code\n yield\n rescue => the_error_object\n if the_error_object.class == error_to_raise\n print \".\"\n else\n print \"F\"\n end\n else\n print \"E\"\n end\n\nend", "def error(exception) nil ; end", "def identify_error\n begin\n yield\n rescue => ex\n ex.message.insert(0, \"#{@id} error: \")\n raise\n end\n end", "def check_retval(rc, e_klass)\n return true unless OpenNebula.is_error?(rc)\n case rc.errno\n when OpenNebula::Error::EAUTHENTICATION\n fail Errors::AuthenticationError, rc.message\n when OpenNebula::Error::EAUTHORIZATION\n fail Errors::UserNotAuthorizedError, rc.message\n when OpenNebula::Error::ENO_EXISTS\n fail Errors::ResourceNotFoundError, rc.message\n when OpenNebula::Error::EACTION\n fail Errors::ResourceStateError, rc.message\n else\n fail e_klass, rc.message\n end\n end", "def safely(&block)\r\n begin\r\n yield\r\n rescue Exception => e\r\n if e.message =~ /connection was aborted/\r\n puts \" [yp searcher] Error: #{e} #{e.message}. Continuing.\"\r\n end\r\n end\r\n end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def fatal(error)\n debug(error)\n raise(error)\n end", "def fatal_raise error, *args, &block\n return if @level > FATAL\n message = block_given? ? build_pair(yield) : build_pair(*args)\n add( FATAL, nil, message )\n raise error, message\n end", "def raise_on_error?\n @raise\n end", "def exception(return_code)\n error = OpenNebula.is_error?(return_code)\n\n raise OneProvisionLoopException, return_code.message if error\n end", "def exception(return_code)\n error = OpenNebula.is_error?(return_code)\n\n raise OneProvisionLoopException, return_code.message if error\n end", "def catch_sftp_exception(&block)\n yield block\n rescue Exception => e\n @errors.push(e.message)\n DevOn::print \"SFTP ERRORS\"\n DevOn::print @errors\n raise e.backtrace\n end", "def try(&block)\n begin\n yield\n rescue Errno::ETIMEDOUT, Timeout::Error, Net::HTTPNotFound\n log \"Connection Error\"\n rescue Exception => exc\n log exc.message\n log exc.backtrace\n end\n end", "def exceptions\n\t\tselect {|x| x.class == Exception }\n\tend", "def try &bk\n yield\n rescue Exception => ex\n ex\n end", "def rescue_action(e); raise e; end", "def exceptions; end", "def rescue_standard_error\n yield\n rescue StandardError => e\n if ENV['RESCUE_EXCEPTION']\n nil\n else\n raise e\n end\n end", "def underlying_exception; end", "def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend", "def reraise\n raise $!.class, $!.message, caller[1..-1]\nend", "def rescue_action(e) raise e end", "def rescue_action(e) raise e end", "def rescue_action(e) raise e end", "def rescue_action(e) raise e end", "def fatal?\n level == 3\n end", "def rescue(&block)\n begin\n block.call \n rescue Exception => e\n self.catch(e)\n raise(e)\n end\n end", "def rescue(&block)\n begin\n block.call \n rescue Exception => e\n self.catch(e)\n raise(e)\n end\n end", "def on_error_in node_type, &block\n @exceptions[node_type] = block\n end", "def exception\n raise \"It's a bad one!\"\n end", "def exceptions\n Calls.new(select(&:raised?))\n end", "def ERROR(&block)\n Then(on_eval: \"_gvn_error\", &block)\n end", "def ignore_raise\n yield\nrescue StandardError\n :raised\nend", "def fatal?; @level <= FATAL; end", "def fatal?; @level <= FATAL; end", "def foo\n return raise\n#> xxxxxx\n end", "def fatal message = nil, &block\n if block_given?\n add 4, nil, message, &block\n else\n add 4, message, nil, &block\n end\n end", "def exception\n @exception&.object\n end", "def raise_rescue\n begin\n puts 'I am before the raise.'\n raise 'An error has occured.'\n puts 'I am after the raise.'\n rescue RuntimeError # 指定捕获异常的类型\n puts 'I am rescue!'\n end\n puts 'I am after the rescue.'\nend", "def execute_with_rescue(&block)\n begin\n yield block\n rescue Flickr::Error => ex\n self.error_messages ||= []\n self.error_messages << {:date => Time.now, :msg => ex.message}\n if ex.message.match(/(User not found|Invalid auth token)/)\n self.status = 'inactive'\n end\n self.save\n return\n end\n end", "def catch_ssh_exception(&block)\n yield block\n rescue Exception => e\n @errors.push(e.message)\n DevOn::print \"SSH ERRORS\"\n DevOn::print @errors\n raise e.backtrace\n end", "def recover_from(_error); end", "def return_check\n @@return_check ||= Proc.new { |ptr| Error.check_and_raise( ptr ) }\n end", "def fatal?\n false\n end", "def error\n return unless error?\n err || GenericError.new(error_code, error_msg)\n end", "def error?; end", "def error?; end", "def error?; end", "def raise_exc\n raise\n rescue\n end", "def exception?\n false\n end", "def serialize_error\n case error\n when Common::Exceptions::BaseError\n base_error\n when Common::Client::Errors::ClientError\n client_error\n when EMISRedis::VeteranStatus::NotAuthorized\n emis_error(:not_authorized)\n when EMISRedis::VeteranStatus::RecordNotFound\n emis_error(:not_found)\n when MPI::Errors::RecordNotFound\n mpi_error(404)\n when MPI::Errors::FailedRequestError\n mpi_error(503)\n when MPI::Errors::DuplicateRecords\n mpi_error(404)\n else\n standard_error\n end\n end", "def protect_runtime_errors # &block\n\t\tbegin\n\t\t\tyield\n\t\trescue StandardError => e\n\t\t\t# switch states first, in case extra messages need to be printed to contexualize the actual exception\n\t\t\tself.runtime_error()\n\t\t\t\n\t\t\t\n\t\t\t# keep execption from halting program,\n\t\t\t# but still output the exception's information.\n\t\t\tprint_wrapped_error(e)\n\t\t\t\n\t\t\t\n\t\tend\n\tend", "def abort_on_exception=(*) end", "def standard_exception_handling\n begin\n yield\n rescue SystemExit => ex\n # Exit silently with current status\n raise\n rescue OptionParser::InvalidOption, ArgumentError => ex\n $stderr.puts ex.message\n exit(false)\n rescue Exception => ex\n # Exit with error message\n display_error_message(ex)\n exit(false)\n end\n end", "def standard_exception_handling\n begin\n yield\n rescue SystemExit => ex\n # Exit silently with current status\n raise\n rescue OptionParser::InvalidOption => ex\n $stderr.puts ex.message\n exit(false)\n rescue Exception => ex\n # Exit with error message\n display_error_message(ex)\n exit(false)\n end\n end", "def interrupt_exception\n\t\t\tm = Module.new\n\t\t\t(class << m; self; end).instance_eval do\n\t\t\t\tdefine_method(:===){|e|\n\t\t\t\t\te.message =~ /interrupt/i || e.class == Curl::Err::MultiBadEasyHandle\n\t\t\t\t}\n\t\t\tend\n\t\t\tm\n\t\tend", "def underlying_exception=(_arg0); end", "def raise_exception_info\n begin\n puts 'I am before the raise.'\n raise 'An error has occured.'\n puts 'I am after the raise.'\n rescue RuntimeError => e\n puts e.message\n puts e.backtrace.inspect # 打印具体的错误位置\n end\n puts 'I am after the rescue.'\nend", "def error?; @level <= ERROR; end", "def error?; @level <= ERROR; end", "def error?\n !!@exception\n end", "def raise?(diagnostic)\n (@all_errors_are_fatal &&\n diagnostic.level == :error) ||\n diagnostic.level == :fatal\n end", "def with_exception_handling\r\n yield\r\n rescue Timeout::Error => exc\r\n return { code: Scrapers::StatusCodes::BLOCKED_REQUEST }\r\n rescue Exception => exc\r\n @logger.error(\"\\n#{self.class} error\")\r\n @logger.error(exc)\r\n @logger.error(exc.backtrace.join(\"\\n\"))\r\n @logger.error(body)\r\n\r\n return { code: Scrapers::StatusCodes::INTERNAL_ERROR }\r\n end", "def __force__\n @mutex.synchronize do\n if @result.equal?(NOT_SET) && @error.equal?(NOT_SET)\n begin\n @result = @block.call\n rescue ::Exception => e\n @error = e\n end\n end\n end if @result.equal?(NOT_SET) && @error.equal?(NOT_SET)\n # BasicObject won't send raise to Kernel\n @error.equal?(NOT_SET) ? @result : ::Kernel.raise(@error)\n end", "def original_exception; end", "def parse_error(error)\n case error\n when SocketError\n PuppetDebugger::Exception::ConnectError.new(message: \"Unknown host: #{Puppet[:server]}\")\n when Net::HTTPError\n PuppetDebugger::Exception::AuthError.new(message: error.message)\n when Errno::ECONNREFUSED\n PuppetDebugger::Exception::ConnectError.new(message: error.message)\n when Puppet::Error\n if error.message =~ /could\\ not\\ find\\ class/i\n PuppetDebugger::Exception::NoClassError.new(default_modules_paths: default_modules_paths,\n message: error.message)\n elsif error.message =~ /default\\ node/i\n PuppetDebugger::Exception::NodeDefinitionError.new(default_site_manifest: default_site_manifest,\n message: error.message)\n else\n error\n end\n else\n error\n end\n end", "def raise_exc\n <<-CODE\n t1 = stack_pop();\n cpu_raise_exception(state, c, t1);\n CODE\n end", "def exceptions\n end", "def test\n begin\n raise IOError\n rescue IOError => ex\n puts \"rescue: #{ex.class}\"\n ensure\n puts \"ensure: #{$!.class}\"\n end\nend", "def if_non_200_raise(exception_klass)\n @non_200_exception = exception_klass\n self\n end", "def error?\n !!exception\n end" ]
[ "0.64999", "0.639861", "0.62881917", "0.6216377", "0.6079258", "0.60760385", "0.6013458", "0.5898451", "0.5898451", "0.5891785", "0.5890962", "0.58423346", "0.5833738", "0.5830342", "0.58183247", "0.57865447", "0.57862973", "0.5762253", "0.5762216", "0.57568586", "0.57344645", "0.56797737", "0.56710494", "0.56525046", "0.55995834", "0.5590642", "0.55528045", "0.55462027", "0.5541735", "0.55235994", "0.55211484", "0.55211484", "0.55211484", "0.55211484", "0.55211484", "0.551541", "0.550801", "0.5490371", "0.5470643", "0.5470643", "0.5465877", "0.54553556", "0.54540855", "0.544686", "0.54351383", "0.54302514", "0.54291254", "0.54221237", "0.54084265", "0.5404351", "0.5365108", "0.5365108", "0.5365108", "0.5365108", "0.5364386", "0.53594714", "0.53594714", "0.53577256", "0.53548855", "0.5348853", "0.5348201", "0.53449345", "0.53443485", "0.53443485", "0.5338976", "0.53333545", "0.53333277", "0.5332967", "0.5331584", "0.5330774", "0.53285426", "0.5327347", "0.53064084", "0.53039604", "0.5300491", "0.5300491", "0.5300491", "0.5292315", "0.528135", "0.52700716", "0.5268102", "0.526593", "0.5261247", "0.5243933", "0.52427405", "0.5240528", "0.5233641", "0.523347", "0.523347", "0.5226328", "0.52258027", "0.5224821", "0.52198225", "0.5214862", "0.52103853", "0.5199142", "0.5188978", "0.51875013", "0.5179976", "0.517688" ]
0.567967
22
The class used for phone numbers can be overwritten and specified in environment.rb
def phone_klass config[:phone_klass]||SmsOnRails::PhoneNumber end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def phone_number; end", "def phone_number; end", "def cell_phone; end", "def shape_phone_number\n self.phone_number = twilio_format phone_number\n end", "def initialize(phone)\n @phone = phone\n end", "def phone_number\n \"(#{Helpers::FakeIt.area_code}) #{Helpers::FakeIt.exchange_code}-#{Helpers::FakeIt.subscriber_number}\"\n end", "def phone_number\n get_attribute(Yoti::Attribute::PHONE_NUMBER)\n end", "def phone\n @phone ||= Phone::Gateway.new(client)\n end", "def phone_number\n case rand(0..2)\n when 0 then fixed_line_number\n when 1 then mobile_number\n when 2 then mobile_or_pager_number\n end\n end", "def phone_number\n element_with_value('PhoneNumber', opts[:phone_number])\n end", "def get_instance(payload)\n PhoneNumberInstance.new(@version, payload)\n end", "def get_instance(payload)\n PhoneNumberInstance.new(@version, payload)\n end", "def phone_number\n '+18773289677'\n end", "def phone_number\n element_with_value('PhoneNumber', opts[:phone_number][0..14])\n end", "def phone\n if @data.attribute_names.include?(:cmupreferredtelephone)\n @phone ||= @data[:cmupreferredtelephone].last.gsub(/[^0-9]/,'')\n else\n @phone ||= nil\n end\n end", "def phone_number_with_country_code; end", "def mobile_phone_number\n FFaker.numerify(\"#{mobile_phone_prefix}## ### ###\")\n end", "def initialize(string)\n @phone = NormalizePhone::Base.new(string).normalize\n @extension = NormalizePhone::Extension.new(string).normalize\n end", "def phone_number\n case rand(0..1)\n when 0 then home_work_phone_number\n when 1 then mobile_phone_number\n end\n end", "def standardized_phone_number\n @standardized_phone_number ||= phone_number.gsub(/\\D/, '')\n end", "def phone_number\n '+18009977777'\n end", "def mutate_phone_number(_)\n Faker::PhoneNumber.phone_number\n end", "def cell_phone\n parse('cell_phone.formats')\n end", "def cell_phone_with_country_code; end", "def phone_number(nr)\n country_code = AppConfig['contact_info.default_country_code'].to_s\n Phone.parse(nr, :country_code => country_code).format(:europe)\n rescue\n return nr\n end", "def phone_number_field\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.input.className(create_ats_regex_string(\"ats-phonefield\")), format_method(__method__))\n end", "def phone_number\n value = Faker::PhoneNumber.phone_number\n remove_extension(value)\n end", "def phone_number\n value = Faker::PhoneNumber.phone_number\n remove_extension(value)\n end", "def set_PhoneNumber(value)\n set_input(\"PhoneNumber\", value)\n end", "def phone=(v)\n @phone = alma_string v\n end", "def phone=(val)\n write_attribute(:phone, PhoneNumber.standardise_phone_number(val))\n end", "def user_home_phone\n\tend", "def international_phone_number\n rand(0..1).zero? ? international_mobile_phone_number : international_home_work_phone_number\n end", "def get\n PhoneNumber.get self\n end", "def phone_number\n\t\t\trecipient.phone_number\n\t\tend", "def initialize(prefix = Address.new.phone_prefix, number = nil, extension = nil)\n @prefix = prefix.gsub(/\\A0/,\"\")\n\n if number\n @number = number\n elsif landline?\n @number = ([rand(2..9).to_s] + (rand(3..7).times.collect{rand(0..9).to_s})).join(\"\")\n else\n @number = ([rand(2..9).to_s] + (7.times.collect{rand(0..9).to_s})).join(\"\")\n end\n\n @extension = extension.to_s\n end", "def phone(type = :default)\n raise \"Ruby version #{RUBY_VERSION} not supported!\" unless RUBY_VERSION =~ /^1.8/\n self.downcase.split(//).inject('') do |acc, b| # better syntax in 1.9\n if b =~ /[a-z]/\n unless type == :legacy\n val = ((b[0] % LETTER_A_VALUE / 3) + 2)\n val -= 1 if %w(s v y z).include?(b)\n acc += val.to_s\n else # not real\n acc += ((b[0] % LETTER_A_VALUE / 3) + 1).to_s\n end\n else\n acc += b\n end\n end\n end", "def phone=(new_phone)\n super(Phone::PhoneBuilder.new(phone: new_phone).format)\n end", "def gen_int_phone_num\n \"011-#{rand(100) + 1}-#{rand(100) + 10}-#{rand(1000) + 1000}\"\nend", "def phone_microdata_for(type)\n type == 'fax' ? 'faxNumber' : 'telephone'\n end", "def international_phone\n \"011-#{rand(100) + 1}-#{rand(100)+10}-#{rand(10000)+1000}\"\n end", "def phone_type(string)\n Phonelib.parse(string, \"US\").national(false)\n end", "def short_phone_number\n FFaker.numerify('###-##-##')\n end", "def phone_number_with_ext\n \"(#{Faker::PhoneNumber.area_code}) #{Faker::PhoneNumber.exchange_code}-#{Faker::PhoneNumber.subscriber_number} Ext:1234\"\n end", "def phone_number\n rand(0..1).zero? ? home_work_phone_number : mobile_phone_number\n end", "def demongoize(object)\n RussianPhone::Number.new(object, @options)\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def coerce_phone(value, options = {})\n value ? coerce_string(value).upcase.gsub(/[^+0-9A-Z]/,'') : nil\n end", "def phone_number_field\n $tracer.trace(__method__)\n #unit_test_no_generate: phone_number_field, input.id(\"PhoneNumber\")\n return ToolTag.new(input.id(\"PhoneNumber\"), __method__, self)\n end", "def phone_number\n @phone.number\n end", "def set_Phone(value)\n set_input(\"Phone\", value)\n end", "def mobile_number\n \"#{mobile_phone_prefix}-#{short_phone_number}\"\n end", "def phone_number=(value)\n super(value.blank? ? nil : value.gsub(/[^\\d]/, ''))\n end", "def mobile_number\n FFaker.numerify('8### ####')\n end", "def set_type_phone_number\n\n if !params[:type].nil? && !params[:phone_number].nil?\n\n @type = params[:type].to_s\n\n @phone_number = params[:phone_number].to_s\n\n end\n\n end", "def phone_number_label\n $tracer.trace(format_method(__method__))\n\treturn ToolTag.new(@tag.find.label.className(create_ats_regex_string(\"ats-phonelbl\")), format_method(__method__))\n end", "def phone_number\n if self[:phone_number] == nil\n return nil\n end\n phone_number = self[:phone_number]\n return PhoneNumberHandler.format_phone_number(phone_number)\n end", "def phone_number\n if self[:phone_number] == nil\n return nil\n end\n phone_number = self[:phone_number]\n return PhoneNumberHandler.format_phone_number(phone_number)\n end", "def add_phone_number(type, number)\n phone_number = PhoneNumber.new\n phone_number.type = type\n phone_number.number = number\n #once we have that we need to append it to the internal @phone_numbers array with:\n phone_numbers.push(phone_number)\n end", "def formatted_phone\n phone\n end", "def mobile_phone\n return unless @user.loa3?\n\n dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::MOBILE)\n end", "def coerce_phone(value, options = {})\n value = coerce_string(value, options)\n value ? value.upcase.gsub(/[^+0-9A-Z]/, \"\") : nil\n end", "def home_work_phone_number\n FFaker.numerify(\"(#{home_work_phone_prefix}) #### ####\")\n end", "def gen_phone_num\n \"#{rand(900) + 100}-#{rand(900) + 100}-#{rand(1000) + 1000}\"\nend", "def format_phone\n if @phone != nil\n @phone = self.phone.scan(/[0-9]/).join\n self.phone = @phone.length == 7 ? ActionController::Base.helpers.number_to_phone(@phone) : \n @phone.length == 10 ? ActionController::Base.helpers.number_to_phone(@phone, area_code: true) :\n @phone\n\n end\n end", "def initialize(number)\n @raw_number = number\n @number = CnPhoneNumber.clean(number)\n # assume okay until shown otherwise\n @reason = :ok\n #puts \"number = #{@number}\"\n\n # TODO too short or too long\n\n # let's determine the basic type: landline, mobile, magic, or unknown\n # source: TODO\n if CnPhoneNumber.is_magic_number?(@number)\n @type = :magic\n # a very basic length check: at least 7 digits, assuming no area or provider code\n elsif @number.length >= 7\n if @number[0] == '1'\n # at this point, it's either: Beijing's city code, OR ...\n if @number[1] == '0'\n @type = :landline\n # no known mobile providers have '19...'\n elsif @number[1] != '9'\n @type = :mobile\n else\n @type = :unknown\n end\n else\n @type = :landline\n end\n else\n @type = :unknown\n @reason = :unknown_type\n end\n #puts \"type = #{@type}\"\n\n if @type == :mobile\n # see if we can find a provider, and strip it from @number if found\n @provider = :unknown\n @provider_number = nil\n\n # all mobile numbers must be length 11. there are two cases:\n # a) 3 digit provider code + 8 digit local extension\n # b) 4 digit provider code (134X) + 7 digit local extension\n length_check_passed = @number.length == 11\n\n if length_check_passed\n Providers.all.each_pair do | area_code, provider |\n if @number[0, area_code.length] == area_code\n @provider = provider\n @provider_number = area_code\n @number = @number[area_code.length, @number.length]\n break\n end\n end\n end\n elsif @type == :landline\n # try to find the city, and strip it from @number if found\n @city = :unknown\n @city_number = nil\n Provinces.all.each_pair do | area_code, city |\n #puts area_code, city, @number[0, area_code.length]\n # all landline numbers must be >= length 7 (minus the provider code)\n if @number[0, area_code.length] == area_code && @number.length - area_code.length >= 7\n @city = city\n @city_number = area_code\n @number = @number[area_code.length, @number.length]\n break\n end\n end\n else\n @provider = :unknown\n @provider_number = nil\n @city = :unknown\n @city_number = nil\n end\n\n end", "def mobile_phone=(value)\n @mobile_phone = value\n end", "def user_work_phone\n\tend", "def international_phone\n phone.gsub(/[^\\d]/, \"\").prepend('+1')\n end", "def set_phone_num\n @phone_num = PhoneNum.find(params[:id])\n end", "def mobile_phone=(n)\n pull unless @details\n pn = Quickbooks::Model::TelephoneNumber.new\n pn.free_form_number = n\n @details.mobile_phone = pn\n #update our locally stored number too\n update_mobile_phone_number\n end", "def update_phone_number\n begin\n self.phone_number = self.primary_phone.tr('^0-9', '')\n rescue\n return nil\n end\n end", "def find_or_create_phone_number(phone_text, options={})\n phone = phone_klass.find_and_create_by_number(phone_text)\n phone.assign_carrier(options[:carrier]) if options[:carrier]\n phone\n end", "def context\n unless @instance_context\n @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])\n end\n @instance_context\n end", "def context\n unless @instance_context\n @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])\n end\n @instance_context\n end", "def phone_number(area_code = nil)\n area_code ||= CITIES.rand[1]\n length = 10 - area_code.length\n \"#{area_code} #{numerify('#' * length)}\"\n end", "def phone(no)\n if no\n number_to_phone(no, :area_code => false)\n else\n no\n end\n end", "def phonenumber_with_extension(extension)\n Phonenumber.new(prefix, number, extension)\n end", "def phone=(value)\n write_attribute(:phone, Phone.new(value).value)\n end", "def set_phone_type\n @phone_type = PhoneType.find(params[:id])\n end", "def set_phone_attributes\n # 6 digit zero padded number as a string.\n self.phone_number_confirmation_token = ( SecureRandom.hex(3).to_i(16) % 1_000_000 ).to_s.rjust( 6, \"0\" )\n # removes all white spaces, hyphens, and parenthesis\n self.unconfirmed_phone_number.to_s.gsub!(/[\\s\\-\\(\\)]+/, '')\n self.phone_number_confirmation_sent_at = nil\n end", "def phone_numbers_full\n format_entities('gd$phoneNumber', :format_phone_number)\n end", "def mobile_phone\n return @mobile_phone\n end", "def phone_number_with_country_code\n \"#{country_code} #{phone_number}\"\n end", "def phone_number_hops_field\n $tracer.trace(__method__)\n #unit_test_no_generate: phone_number_hops_field, input.className(create_ats_regex_string(\"ats-phone\"))\n return ToolTag.new(input.className(create_ats_regex_string(\"ats-phone\")), __method__, self)\n end", "def format_phone\n if Phoner::Phone.valid? self.phone\n pn = Phoner::Phone.parse phone, :country_code => '1'\n self.phone = pn.format(\"(%a) %f-%l\")\n end\n end", "def internationalized_phone_number(phone_number)\n \t\"+1#{phone_number}\"\n end", "def phone_numbers\n xml.css('phone_number').map{|c| Allorails::PhoneNumber.new(c)}\n end", "def home_phone\n home_phone = @customers[0][4].to_s.split(\"\")\n i = 0\n @home_phone_type = \"\"\n while i < 4\n @home_phone_type << home_phone[i]\n i += 1\n end\n @home_phone_type\n end", "def phone\n @json['user']['content']['phonenumber'] || ''\n end", "def fix_phone_number\n number = phone_number.to_s.gsub(/\\D/, '')\n number = number[1..-1] if number.starts_with?('1')\n self.phone_number = number\n end", "def add_member_phone(phone)\n\n end", "def phone_number\n return homework_number if rand(0..1).zero?\n\n mobile_number\n end", "def phone_numbers\n self[\"gd$phoneNumber\"] ? self[\"gd$phoneNumber\"].map { |e| e['$t'] } : []\n end", "def cell_phone\n value = Faker::PhoneNumber.cell_phone\n remove_extension(value)\n end", "def cell_phone\n value = Faker::PhoneNumber.cell_phone\n remove_extension(value)\n end", "def cell_phone_in_e164; end" ]
[ "0.7149462", "0.7149462", "0.6723532", "0.66596115", "0.6586894", "0.6545018", "0.64875835", "0.6354251", "0.63465804", "0.63203377", "0.63079596", "0.63079596", "0.63017267", "0.62971115", "0.6267595", "0.6260722", "0.62606966", "0.62460846", "0.6218876", "0.6217696", "0.61975366", "0.6178809", "0.6133845", "0.6129335", "0.612034", "0.6096632", "0.6092276", "0.6092276", "0.6076023", "0.60449976", "0.6038826", "0.6032758", "0.60208815", "0.601824", "0.6015239", "0.59936607", "0.59773624", "0.596257", "0.5959593", "0.5952549", "0.5947341", "0.5946447", "0.5942079", "0.591484", "0.5907317", "0.5907242", "0.5903231", "0.5903231", "0.5903231", "0.5903231", "0.58873993", "0.5887013", "0.5881443", "0.58795255", "0.58692664", "0.58639926", "0.58611387", "0.58534485", "0.58448267", "0.58382493", "0.5837798", "0.5836622", "0.5827267", "0.58254725", "0.58162254", "0.581544", "0.5815257", "0.5797479", "0.5793725", "0.5792991", "0.57871586", "0.5783832", "0.57799685", "0.57749856", "0.57401395", "0.5730219", "0.5721398", "0.57203335", "0.5710024", "0.56942445", "0.56925327", "0.56883764", "0.5688171", "0.56874424", "0.56853384", "0.56809855", "0.5676864", "0.56731564", "0.5671847", "0.5656771", "0.5645565", "0.5644384", "0.5634622", "0.563284", "0.5626743", "0.5609774", "0.560768", "0.56061614", "0.56061614", "0.56032985" ]
0.8048162
0
Name of service provider (downcase no spaces)
def name @name ||= self.to_s.demodulize.underscore end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_name\n self[:name].gsub(/\\.|,/, '_').gsub(/\\s/, '').underscore.to_sym if self[:name]\n end", "def _display_name\n respond_to?(:service_name) ? service_name : name.split(\"::\").last\n end", "def name\n @provider[:name]\n end", "def name(_prefix = false)\n 'Providers'\n end", "def service_name; end", "def provider_name(provider)\n Account.provider_name(provider)\n end", "def provider_name\n object.provider_id.titleize\n end", "def name\n @provider_name\n end", "def provider_name\n return @provider_name\n end", "def service_type_name(account_name, name)\n map_opts = get_acct_catalog_map(account_name)\n case map_opts[:provider]\n when \"hp\"\n service_name = name\n unless map_opts[:catalog].nil?\n service_catalog_key = name.to_s.downcase.gsub(' ','_').to_sym\n service_name = map_opts[:catalog][service_catalog_key] if map_opts[:catalog].has_key?(service_catalog_key)\n end\n return service_name\n else\n return name\n end\n end", "def service_name\n return @service_name\n end", "def service_name\n resource[:name]\n end", "def provider_name=(provider)\n unless provider.nil?\n @provider_name = provider.downcase\n end\n end", "def service_name\n @service_name ||= InchCI::ProjectUID.new(uid).service\n end", "def service(name)\n \"#{SERVICE_NAME} #{name}\"\n end", "def name\n @service.name.to_s\n end", "def service_display_name(arg)\n service = arg.to_sym if arg.respond_to?(:to_sym)\n service = service_name(arg) unless @options.include?(service)\n if service.nil?\n nil\n else\n @options[service].display_name\n end\n end", "def cloud_service_name\n return @cloud_service_name\n end", "def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def provider_name(provider)\n I18n.t(provider, scope: 'account.provider_name')\n end", "def service_key\n (is_a?(Module) ? name : self.class.name).demodulize.underscore.to_sym\n end", "def service_key\n (is_a?(Module) ? name : self.class.name).demodulize.underscore.to_sym\n end", "def name\n return service_name if info.nil?\n info[:name]\n end", "def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name(provider)\n when 'NilClass' then nil\n else\n provider\n end\n end", "def service_type_name\n \"\" \n end", "def carto_provider\n application_name.delete(\" \")\n end", "def service_name\n if settings && settings[\"service_name\"].present?\n settings[\"service_name\"]\n else\n APP_CONFIG.global_service_name || \"Sharetribe\"\n end\n end", "def service_name\n if settings && settings[\"service_name\"].present?\n settings[\"service_name\"]\n else\n APP_CONFIG.global_service_name || \"Sharetribe\"\n end\n end", "def provider_type\n provider.to_s.gsub(\"oauth2\", \"\").try(:titleize)\n end", "def plugin_human_name\n @plugin_human_name ||= \"#{provider_name.titleize} Provider\"\n end", "def provider_name=(value)\n @provider_name = value\n end", "def service_name=(value)\n @service_name = value\n end", "def service_name(default_name)\n ENV[\"DOMAIN\"].to_s.empty? ? default_name : ENV[\"DOMAIN\"].split('.').first\n end", "def service_name_for_user(service_name, user)\n service_name\n end", "def basic_service_name\n return @basic_service_name if @basic_service_name\n basic_service_name = name\n basic_service_name = service_name unless name_equals_title?\n if basic_service_name.start_with? 'p_'\n basic_service_name = basic_service_name.gsub(/^p_/, '')\n end\n debug \"Using '#{basic_service_name}' as the basic service name for the primitive '#{name}'\"\n @basic_service_name = basic_service_name\n end", "def cloud_service_name=(value)\n @cloud_service_name = value\n end", "def service_prov_name(eob = nil,claim = nil )\n @eob = @eob.nil?? eob : @eob\n prov_id, qualifier = service_prov_identification\n ['NM1', '82', (@eob.rendering_provider_last_name.to_s.strip.blank? ? '2': '1'),\n prov_last_name_or_org, @eob.rendering_provider_first_name,\n @eob.rendering_provider_middle_initial, '', @eob.rendering_provider_suffix,\n qualifier, prov_id].trim_segment.join(@element_seperator)\n end", "def service_name=(_arg0); end", "def dot_service( shortname )\n shortname + \".service\"\n end", "def get_service_name\n\t\t\t\traise \"Should return the a service name from config.wsdl keys\"\n\t\t\tend", "def name\n \"#{service} // #{login}\"\n end", "def oauth_provider_humanized\n case provider\n when 'google' then 'Google'\n when 'github' then 'GitHub'\n end\n end", "def service_name\n return @target.service_name\n end", "def service_name\n raise TypeError, 'no type on this reply' unless\n instance_variable_defined? :@type\n\n @type.split('.').first.sub '_', ''\n end", "def cloud_service_instance_name\n return @cloud_service_instance_name\n end", "def find_provider(provider_name, domain_front)\n @options[:format] = :dots_9\n spinner = TTY::Spinner.new(\"[:spinner] Auto-detecting\", @options)\n case provider_name\n when :auto\n domain = Adomain.domain(domain_front)\n [amazon, azure, alibaba].map do |provider|\n if provider[:dfront].include?(domain)\n # spinner.update(title: \"Provider found: #{provider[:name].bold}\")\n # spinner.reset\n spinner.success(\" | Provider found: #{provider[:name].bold}\")\n return provider[:name].downcase.to_sym\n end\n end\n when :amazon || :azure || :alibaba\n provider_name\n else\n spinner.error(\"Failed to auto detect provider: please use '-p' and choose from: 1, 2 or 3\")\n end\n end", "def service_plan_name\n return @service_plan_name\n end", "def sti_name\n name.demodulize.underscore\n end", "def name\n @name ||= options[:name] || service_url\n end", "def name\n @name ||= options[:name] || service_url\n end", "def name\n @name ||= options[:name] || service_url\n end", "def client_name\r\n self.name.strip.upcase\r\n end", "def service_name(name)\n @name = name\n end", "def provider_name\n @json['profile']['providerName'] rescue nil\n end", "def get_ai_service_base_name(options)\n service_base_name = options['service']\n if service_base_name.match(/i386|sparc/)\n service_base_name = service_base_name.gsub(/i386/,\"\")\n service_base_name = service_base_name.gsub(/sparc/,\"\")\n service_base_name = service_base_name.gsub(/_$/,\"\")\n end\n return service_base_name\nend", "def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end", "def label_with_service_provider\n label << \", with #{service_provider.display_name}\"\n end", "def strategy_name\n options[:name] || @provider\n end", "def service_name(source: nil)\n source ||= service\n keys = []\n keys << :\"emma.error.#{source}._name\" if source\n keys << :'emma.error.api._name'\n keys << 'remote service'\n # noinspection RubyMismatchedReturnType\n I18n.t(keys.shift, default: keys)\n end", "def api_name\n to_s.split('::').last.gsub(/[^\\A]([A-Z])/, '_\\\\1').downcase\n end", "def endpoint_name\n self.name.split('::').last.downcase\n end", "def provider\n system.provider\n end", "def scheme_name\n svc = minter\n return nil unless svc.present?\n\n scheme(svc: svc)&.name&.downcase\n end", "def service_name\n @documents.service_name\n end", "def get_cloud_provider\n\t\t\t\tcloud = node[:cloud][:provider].to_s\n\t\t\t\tcloud.strip!\n\t\t\t\treturn cloud\n\t\t\tend", "def name\n camel = self.class.to_s.gsub(/.*::/, '')\n camel.gsub(/(\\S)([A-Z])/, '\\1_\\2').downcase\n end", "def service\n @service ||=\n if (c = self_class)\n name = c.safe_const_get(:SERVICE_NAME)\n name ||= c.module_parent_name.underscore.remove(/_service$/)\n name&.to_sym || super\n end\n end", "def service_klass(constant_string)\n if const_defined?([to_s, constant_string].join(\"::\"))\n [to_s, constant_string].join(\"::\")\n else\n provider = to_s.split(\"::\").last\n Fog::Logger.deprecation(\"Unable to load #{[to_s, constant_string].join('::')}\")\n Fog::Logger.deprecation(\n format(\n Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,\n service: constant_string,\n provider: provider\n )\n )\n [\"Fog\", constant_string, provider].join(\"::\")\n end\n end", "def openstack_provider\n # dream host doesn't support windows so bail early if we're on windows\n return \"openstack\" if RUBY_PLATFORM.match?(/mswin|mingw|windows/)\n\n if Etc::Passwd.entries.map(&:name).include?(\"dhc-user\")\n \"dreamhost\"\n else\n \"openstack\"\n end\n end", "def default_provider\n return nil unless node && node['platform_family']\n Chef::Provider::Dropbox.const_get(node['platform_family'].split('_')\n .map(&:capitalize).join)\n end", "def eob_provider_name\n str = \"\" #initialize in case the fieds are blank\n str += self.provider_last_name.upcase if !self.provider_last_name.blank?\n str += \", \"\n str += self.provider_first_name.upcase if !self.provider_first_name.blank?\n return str\n end", "def format\n self.class.name.split('::').last.downcase.to_sym\n end", "def provider\n get(PROVIDER)\n end", "def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end", "def service_name\n raise NotImplementedError, \"Subclass #{self.class.name} of Configuration must implement service_name\"\n end", "def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def service_name\n @service_name = \"HelloAgent\"\n end", "def service\n if origin_url =~ /github/i\n 'github'\n elsif origin_url =~ /bitbucket/i\n 'bitbucket'\n elsif origin_url =~ /stash/i\n 'stash'\n else\n ''\n end\n end", "def xlate_service()\n return SERVICE_XLATES[@service] if (SERVICE_XLATES.has_key?(@service))\n return(@service.to_s) \n end", "def module_name(version, service)\n version = version.to_sym\n service = service.to_sym\n return \"#{api_name}::#{version.to_s.upcase}::#{service}\"\n end", "def provider\n @provider or raise \"No provider set via space.use_provider\"\n end", "def cloud_service_instance_name=(value)\n @cloud_service_instance_name = value\n end", "def provider_name_from_state\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:state].to_s.split(/\\|/).last\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider name_from_stat rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def platform\n self.class.name.split(\"::\").last.gsub(/(?<=[^A-Z])[A-Z]+/, \"-\\\\0\").downcase\n end", "def alternative_names\n auth_providers.map do |ap|\n { provider: ap.provider, name: \"#{ap.uname} (#{ap.provider})\" }\n end\n end", "def add_service_name(current_string)\n add_if_present(@service_name, current_string, \" #{@service_name}\")\n end", "def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end", "def name\n n = self.class.name\n n.gsub!( /::/, '.' )\n n.gsub( /(\\w)\\w+\\./ ) { |m| $1.downcase + '.' }\n end", "def service(symbol)\n \"#{self.class}::#{symbol.to_s.camelcase}\".constantize\n end", "def name\n return @name if @name\n @name = pick_existing_name service_name_variations(service_title), service_name_variations(service_name)\n if @name\n message = \"Using CIB name '#{@name}' for primitive '#{service_title}'\"\n message += \" with name '#{service_name}'\" unless name_equals_title?\n debug message\n else\n message = \"Primitive '#{service_title}'\"\n message += \" with name '#{service_name}'\" unless name_equals_title?\n message += ' was not found in CIB!'\n fail message\n end\n @name\n end", "def rename_provider\n attributes.fetch(:renameProvider)\n end", "def name\n self.class.name.split(\"::\").last.downcase\n end", "def service_given\n if (md = SERVICE_GIVEN_REGEXP.match(self.text))\n md[1]\n end\n end", "def service_plan_name=(value)\n @service_plan_name = value\n end", "def service_key\n SERVICE_KEY\n end", "def service_name\n raise \"please implement #service_name in your subclass #{self.class}\"\n end", "def provider\n \"AWS\"\n end", "def type\n :puppet_provider\n end", "def param_service_full_name(options = {})\n merge_options_with_defaults(options, {\n :mandatory => true,\n :lookup_method => lambda do |request| \n @op.with_machine(request.get_param_value(\"machine\")) do |machine| \n localhost.list_services().map do |x|\n x[\"full_name\"]\n end\n end\n end \n })\n RHCP::CommandParam.new(\"service\", \"the service to work with\", options)\nend", "def customize_provider(name,options)\n ''\n end" ]
[ "0.80776316", "0.760347", "0.7460511", "0.74558145", "0.74318576", "0.7325714", "0.7313657", "0.73103267", "0.72889596", "0.72464234", "0.7233958", "0.71187687", "0.7117379", "0.7114123", "0.70778394", "0.7077228", "0.70516884", "0.7050071", "0.7030351", "0.7002944", "0.7002151", "0.7002151", "0.699318", "0.69567823", "0.69394135", "0.692907", "0.68961793", "0.68961793", "0.6803961", "0.67960554", "0.6774488", "0.67579764", "0.674392", "0.6736473", "0.67282057", "0.6684082", "0.66727424", "0.6660303", "0.6654199", "0.66358954", "0.66188943", "0.66147953", "0.65335876", "0.6515862", "0.64932984", "0.64876044", "0.6458226", "0.6453432", "0.6440541", "0.6440541", "0.6440541", "0.6415847", "0.64145815", "0.6366042", "0.63658017", "0.63633686", "0.6356907", "0.63376343", "0.63332206", "0.63330764", "0.632614", "0.632237", "0.6315016", "0.6296927", "0.62797695", "0.62712467", "0.6241799", "0.6239022", "0.6234516", "0.62331384", "0.62165844", "0.6214259", "0.6209399", "0.6188735", "0.6184751", "0.617838", "0.61575747", "0.61281455", "0.6115981", "0.6115327", "0.61024666", "0.60903895", "0.60861295", "0.60846645", "0.6081231", "0.6080942", "0.6075713", "0.60718584", "0.6062042", "0.60571754", "0.6046361", "0.6033271", "0.6029675", "0.60235006", "0.6009605", "0.6009523", "0.600926", "0.6006825", "0.59991044", "0.59949404" ]
0.62288576
70
Human name of provider
def human_name @human_name ||= self.to_s.demodulize.titleize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def provider_name\n object.provider_id.titleize\n end", "def name\n @provider[:name]\n end", "def name\n @provider_name\n end", "def plugin_human_name\n @plugin_human_name ||= \"#{provider_name.titleize} Provider\"\n end", "def provider_name\n return @provider_name\n end", "def provider_name(provider)\n I18n.t(provider, scope: 'account.provider_name')\n end", "def provider_name(provider)\n Account.provider_name(provider)\n end", "def oauth_provider_humanized\n case provider\n when 'google' then 'Google'\n when 'github' then 'GitHub'\n end\n end", "def human_from_name; end", "def display\n\t\tLink.pretty_name(provider)\n\tend", "def eob_provider_name\n str = \"\" #initialize in case the fieds are blank\n str += self.provider_last_name.upcase if !self.provider_last_name.blank?\n str += \", \"\n str += self.provider_first_name.upcase if !self.provider_first_name.blank?\n return str\n end", "def human_to_name; end", "def provider_name\n @json['profile']['providerName'] rescue nil\n end", "def display_name\n NAME\n end", "def display_name\n NAME\n end", "def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def display_name\n name\n end", "def display_name\n name\n end", "def display_name\n return @display_name\n end", "def display_name\n self.imap_provider_code\n end", "def display_name\n name\n end", "def display_name\n return @display_name\n end", "def display_name\n @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n return @display_name\n end", "def display_name\n prefered_name\n end", "def display_name\n display_name = @current_profile.display_name\n end", "def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end", "def name\n @gapi[\"displayName\"]\n end", "def to_s\n human_name\n end", "def display_name\n kingdom_name\n end", "def display_name\n # This display name is different from others.\n # We'll display the station id here, not the regional office,\n # since we don't connect to VACOLS.\n \"#{username} (#{station_id})\"\n end", "def provider_name=(provider)\n unless provider.nil?\n @provider_name = provider.downcase\n end\n end", "def display_name\n public_name\n end", "def display_name\n name\n end", "def display_name\n name\n end", "def display_name\n name\n end", "def displayname\n\t\treturn self[:displayName] ||\n\t\t\t[ self.givenName, self.sn ].compact.join( ' ' )\n\tend", "def display_name\n\t\tself.name.titleize\n\tend", "def full_name\n '(unknown)'\n end", "def display_name\n @hash['display_name']\n end", "def provider_name=(value)\n @provider_name = value\n end", "def display_name\n @data['display_name']\n end", "def display_name\n \"#{name}\"\n end", "def display_name\n \"#{name}\"\n end", "def display_name\n \"#{name}\"\n end", "def name\n\t\tif name_source.present?\n\t\t\tproviders = [\"twitter\",\"facebook\",\"google_oauth2\",\"lastfm\",\"vimeo\"]\n\t\t\tp,v = name_source.split(\"::\",2)\n\t\t\treturn name_source unless p.in? providers\n\t\t\tl = self.links.find_by(provider: p)\n\t\t\tif l\n\t\t\t\tnames = l.names\n\t\t\t\treturn names[v.to_sym] if names.is_a? Hash and v and names[v.to_sym]\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn custom_name if custom_name.present?\n\t\treturn email.split('@')[0].titleize if email.present?\n\t\tUser.default_name\n\tend", "def display_name\n @name\n end", "def name\n @display_name || @name\n end", "def display_name\n @name.titlecase\n end", "def human_name\n Helpers.underscore(@name)\n end", "def display_name\n username\n end", "def name\n display_name\n end", "def name_display\n self.name[I18n.locale]\n end", "def display_name\n if self.name.present?\n [self.name, self.producer].join(' - ')\n else\n self.producer\n end\n end", "def display_name\n @json['profile']['displayName'] rescue nil\n end", "def display_name\n full_name.join(\" \")\n end", "def display_name\n \t\"#{name}\"\n end" ]
[ "0.83065915", "0.80116135", "0.7943693", "0.79019463", "0.7733817", "0.75995886", "0.75586027", "0.75013816", "0.7470618", "0.738612", "0.7384954", "0.73716587", "0.7368003", "0.73118037", "0.73118037", "0.7308407", "0.7301407", "0.7301407", "0.7286233", "0.7265958", "0.7262644", "0.7261553", "0.7259112", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.72581446", "0.7257309", "0.72446424", "0.72222394", "0.7220706", "0.7214513", "0.7201006", "0.7189461", "0.71460444", "0.71382946", "0.7114398", "0.7114398", "0.7114398", "0.7091336", "0.7073281", "0.70626044", "0.704457", "0.70349544", "0.7010145", "0.6990077", "0.6990077", "0.6990077", "0.6989971", "0.6980884", "0.697832", "0.69452393", "0.6927557", "0.69256073", "0.691603", "0.6913406", "0.6903029", "0.6894125", "0.6893563", "0.68915606" ]
0.7038715
83
Hash map of provider_id to the provider
def provider_map @provider_map ||= provider_list.inject({}) do |map, klass| map[klass.provider_id] = klass unless klass.nil? map end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def provider_by_id(provider_id)\n provider_map[provider_id.to_i] if provider_id.to_i > 0\n end", "def provider_key\n map_options.try(:[], :provider_key)\n end", "def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config into a string for comparison\n return (provider[1].nil? ? {} : provider[1]) if provider[0].to_s == @provider_name\n end\n\n nil\n end", "def provider_id\n return @provider_id\n end", "def [](key)\n if key == \"provider\"\n return @provider\n end\n @hash[key]\n end", "def provider_id=(value)\n @provider_id = value\n end", "def set_provider_project\n @provider_project = ProviderProject.find(params[:id])\n @h_providers = {}\n Provider.all.map{|p| @h_providers[p.id] = p}\n end", "def provider_key_for(service_id)\n storage.get(storage_key(service_id, 'provider_key'.freeze))\n end", "def providers\n @providers ||= {}\n end", "def lookup_key(uid, provider=nil)\n [provider, uid].compact.join('_').to_sym\n end", "def providers\n @providers.keys\n end", "def hash\n name.hash ^ provider.hash\n end", "def provider_name\n object.provider_id.titleize\n end", "def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end", "def set_provider_provider_type\n @provider_provider_type = Provider::ProviderType.find(params[:id])\n end", "def provider_identity\n [self.source.name, self.uid].compact.join('_')\n end", "def provider_resource_id\n return @provider_resource_id\n end", "def set_provider\n @provider = Provider.friendly.find(params[:id])\n end", "def parameters_hash(provider_class_name=nil)\n parameters_hash = {}\n @resource.parameters_with_value.each do |parameter|\n parameters_hash.store parameter.name, parameter.value\n end\n parameters_hash.store :name, basic_service_name\n parameters_hash.store :provider, provider_class_name if provider_class_name\n parameters_hash\n end", "def provider\n get(PROVIDER)\n end", "def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name(provider)\n when 'NilClass' then nil\n else\n provider\n end\n end", "def hash\n [provider_name, host_name, host_port, host_ssl, host_tls, host_no_cert_check, bind_dn, bind_password, search_timeout, admin_pool_max_active, admin_pool_lookup_on_validate, user_pool_max_active, user_pool_lookup_on_validate, user_base_dn, user_objectclass, user_id_attribute, user_extra_filter, user_make_dn_path, group_base_dn, group_objectclass, group_name_attribute, group_extra_filter, group_make_dn_path, group_member_attribute, use_uid_for_ext_id, customattributes].hash\n end", "def provider_resource_id=(value)\n @provider_resource_id = value\n end", "def provider_name\n return @provider_name\n end", "def set_provider\r\n @provider = Provider.find(params[:id])\r\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def provider_name(provider)\n Account.provider_name(provider)\n end", "def number\n as_hash = customer_number.to_h\n provider = Utils.get_enum_string(P::CustomerNumberProvider, as_hash[:provider], \"CUSTOMER_NUMBER_PROVIDER\")\n as_hash.merge(provider: provider)\n end", "def set_provider\n PROVIDERS.each do |name|\n regex_string = PROVIDERS.first.eql?(name) ? name[0..-3] : name\n self.provider = name if link =~ /#{regex_string}/\n end\n end", "def name\n @provider_name\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def identity_providers=(value)\n @identity_providers = value\n end", "def identity_providers=(value)\n @identity_providers = value\n end", "def providify\n newparam(:provider)\n nil\n end", "def provider\n @provider\n end", "def formats\n providers.keys\n end", "def set_service_and_provider(id)\n service = Service.find(id)\n provider = User.preload(:profile).find(service.user_id)\n [service, provider]\n end", "def set_provider\n @provider = Provider.find(params[:id]) if params[:id].present?\n @providers = Goodstype.find(params[:goodstype_id]).providers if params[:goodstype_id].present?\n end", "def provider_items\n @provider_items ||= ProviderItem.find(provider_items_ids)\n end", "def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end", "def provider=(provider)\n @provider = provider\n end", "def providers\n @providers ||= load_hash 'config/providers.yml'\n end", "def key_map\n hash = {}\n hash['email'] = self.email\n hash['zip'] = self.zip\n hash['user_id'] = self.user_id\n hash\n end", "def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def provider_name\n @json['profile']['providerName'] rescue nil\n end", "def provider_id\n @service.try(:booking_details).try(:[], :provider_id)\n end", "def set_provider\n @provider = Provider.unscoped.where(\"allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER')\").where(deleted_at: nil).where(symbol: params[:id]).first\n fail ActiveRecord::RecordNotFound unless @provider.present?\n end", "def provider_name=(value)\n @provider_name = value\n end", "def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end", "def get_providers\n @weights.map{|k,v|v.keys}.flatten.uniq\n end", "def cleanup_provider(provider)\n lookups = {}\n Souffle::Provider.constants.each { |k| lookups[k.to_s.downcase] = k.to_s }\n lookups.fetch([provider.downcase], provider)\n end", "def get_provider_overrides(name)\n (@__provider_overrides[name] || []).map do |p|\n [\"2\", p]\n end\n end", "def social_profile(provider)\n social_profiles.select{ |sp| sp.provider == provider.to_s }.first\n end", "def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def provider\n providers.first\n end", "def populate_providers_hash\n # GET A LIST OF ALL PROVIDERS\n Rails.logger.info(\"Retrieving providers list from #{@ingest_providers_list_endpoint}\")\n response = RestClient::Request.execute :method => :get, :url => \"#{@ingest_providers_list_endpoint}\", :verify_ssl => OpenSSL::SSL::VERIFY_NONE\n if (response.code != 200)\n Rails.logger.info(\"ERROR #{response.code} retrieving providers list\")\n # terminate task if we cannot validate the providers names\n exit(status=256)\n else\n list_of_providers_hashes = JSON.parse!(response.body)\n list_of_providers_hashes.each do |hash|\n provider_id = hash['provider-id']\n @all_providers[provider_id] = 'Y'\n end\n Rails.logger.info(\"RETRIEVED A LIST OF ALL PROVIDERS, SIZE: #{list_of_providers_hashes.size}, LOOKUP SIZE: #{@all_providers.size}\")\n end\n end", "def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end", "def mappings_provider(provider_name, is_legacy = false)\n return nil if provider_name.nil?\n provider = nil\n module_name = is_legacy ? 'Highlander': 'Cfhighlander'\n begin\n providers = Object.const_get(module_name).const_get('MapProviders')\n providers.const_get(provider_name)\n rescue NameError => e\n if e.to_s.include? \"uninitialized constant\"\n return mappings_provider(provider_name, true) unless is_legacy\n return nil\n end\n STDERR.puts(e.to_s)\n raise e\n end\nend", "def id_hash(id, organization)\n {\n id: id,\n provider: organization.oauth_provider,\n realm: organization.oauth_uid\n }\n end", "def set_agency_provider\n data = CareerAdvisorWebServices.new(\"admin\",\"nagashri1\").get_code_for_title(params[:id])\n @key = data.present? ? data[0][\"onetsoc_code\"] : '00.000.00'\n\n end", "def providers\n ([self] + parent_groups).reverse.inject({}) do |memo, group|\n begin\n memo.merge(group.poise_spec_helpers[:providers] || {})\n rescue NoMethodError\n memo\n end\n end\n end", "def providers\n url = url_with_api_version(@base_url, 'providers')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end", "def moniker_provider\n attributes.fetch(:monikerProvider)\n end", "def key_map\r\n hash = {}\r\n hash['name'] = name\r\n hash['address'] = address\r\n hash['city'] = city\r\n hash['region'] = region\r\n hash['postal_code'] = postal_code\r\n hash['unit_type'] = unit_type\r\n hash['unit_number'] = unit_number\r\n hash['country'] = country\r\n hash\r\n end", "def providers\n @providers.dup\n end", "def format_resource(provider, _)\n str_h1 = '%-80s'\n id = provider['ID']\n body = provider.body\n\n CLIHelper.print_header(str_h1 % \"PROVIDER #{id} INFORMATION\")\n puts format('ID : %<s>s', :s => id)\n puts format('NAME : %<s>s', :s => provider['NAME'])\n\n return if body['provider'] == 'onprem'\n\n # Get max size to adjust all the values\n size = body['connection'].keys.map {|k| k.size }.max\n data = {}\n\n # Generate data value with the new key adjusted format\n body['connection'].map {|k, v| data[k.ljust(size)] = v }\n\n puts\n CLIHelper.print_header(str_h1 % 'CONNECTION INFORMATION')\n data.each do |key, value|\n CLIHelper.scr_bold\n print \"#{key} : \"\n CLIHelper.scr_restore\n puts value\n end\n end", "def references_provider\n attributes.fetch(:referencesProvider)\n end", "def provider_name(provider)\n I18n.t(provider, scope: 'account.provider_name')\n end", "def alternative_names\n auth_providers.map do |ap|\n { provider: ap.provider, name: \"#{ap.uname} (#{ap.provider})\" }\n end\n end", "def provider\n use_provider('null') unless defined? @provider\n @provider\n end", "def encrypted_uid(provider)\n\t\tlinks.each do |link|\n\t\t\treturn link.encrypted_uid if link.provider == provider\n\t\tend\n\t\treturn nil\n\tend", "def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end", "def get_auth_data(provider, token)\n\t\t\tcase provider\n\t\t\t\twhen 'Facebook'\n\t\t\t\t\treturn {\n\t\t\t\t\t\t:uid \t=> token['uid'],\n\t\t\t\t\t\t:token \t=> token['extra']['raw_info']['token'],\n\t\t\t\t\t\t:email \t=> token['extra']['raw_info']['email'],\n\t\t\t\t\t\t:name \t=> token['extra']['raw_info']['name'],\n\t\t\t\t\t\t:link \t=> token['extra']['raw_info']['link'],\n\t\t\t\t\t\t:image_url\t=> token['image']\n\t\t\t\t\t}\n\n\t\t\t\twhen 'Google'\n\t\t\t\t\treturn {\n\t\t\t\t\t\t:uid => token['uid'],\n\t\t\t\t\t\t:token => token['credentials']['token'],\n\t\t\t\t\t\t:email => token['info']['email'],\n\t\t\t\t\t\t:name => token['info']['name']\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\traise \"Provider #{provider} not handled\"\n\t\t\tend\n\t\tend", "def provider_class\n self.class\n end", "def provider_class\n self.class\n end", "def oauth_provider_humanized\n case provider\n when 'google' then 'Google'\n when 'github' then 'GitHub'\n end\n end", "def to_json\n return {\n name: name,\n provider: provider\n }.to_json\n end", "def rename_provider\n attributes.fetch(:renameProvider)\n end", "def provider\n\tend", "def link_account(provider, uid)\n self[provider.column.to_sym] = uid\n self.save\n end", "def provider\n return nil unless user_id\n user_id.split('/').last\n end", "def provider\n return nil unless user_id\n user_id.split('/').last\n end", "def key_map\r\n hash = {}\r\n hash['id'] = id\r\n hash['name'] = name\r\n hash['description'] = description\r\n hash['contacts'] = contacts.map(&:key_map)\r\n hash['status'] = status\r\n hash['building'] = building.key_map\r\n hash['unit'] = unit.key_map\r\n hash['access'] = access\r\n hash['agency'] = agency\r\n hash['manager'] = manager\r\n hash\r\n end", "def get_selected_providers\n params.keys.select do |k|\n k.include? \"provider\"\n end.map do |checkbox|\n checkbox.split(\":\").last\n end\n end", "def course_providers_list\n # TODO: Make sure course_providers are not huge. Very unlikely though\n course_providers.active.map do |cp|\n [\"#{ cp.locality } - #{ cp.city } - #{ cp.state }\", cp.id]\n end\n end", "def set_provider_service\n @provider_service = ProviderService.find(params[:id])\n end", "def resolve_provider\n attributes.fetch(:resolveProvider)\n end", "def edit\n @connected_providers = current_user.identities.collect{ |identitiy| identitiy.provider }\n super\n end", "def provider_icon(provider)\n icon_name =\n if provider.to_s =~ /developer/\n 'user' # Generic user icon\n else\n provider_class(provider)\n end\n fa(icon_name)\n end", "def initialize(provider_attributes, options = {})\n @provider_attributes = provider_attributes.with_indifferent_access\n @provider_name = provider_attributes['provider']\n @options = {\n :user_attributes => {},\n :identity_attributes => {},\n :skip_raw_info => false,\n :skip_nils => true\n }.merge(options)\n\n @provider_identity = ModelMapper.new(self,\n :model => @options[:identity_model],\n :relation => @options[:identity_relation],\n :attributes => @options[:identity_attributes],\n :attribute_names => @options[:identity_attribute_names],\n :unique_identifiers => @options[:identity_identifiers] || [:provider, :uid],\n :required_criteria => @options[:identity_required_criteria]\n )\n @provider_user = ModelMapper.new(self,\n :model => @options[:user_model],\n :relation => @options[:user_relation],\n :attributes => @options[:user_attributes],\n :attribute_names => @options[:user_attribute_names],\n :unique_identifiers => @options[:user_identifiers] || [:email],\n :required_criteria => @options[:user_required_criteria]\n )\n end", "def provider_box\n strings = []\n strings << @document.provider_name\n strings << @labels[:provider]\n @document.provider_lines.split(\"\\n\").each do |line|\n strings << line\n end\n strings << \"#{@labels[:tax_id]}: #{@document.provider_tax_id}\" \\\n unless @document.provider_tax_id.empty?\n strings << \"#{@labels[:tax_id2]}: #{@document.provider_tax_id2}\" \\\n unless @document.provider_tax_id2.empty?\n strings\n end", "def register_provider( name, provider )\n @providers ||= Hash.new\n name = name.to_s\n\n unless provider.respond_to?(:logger)\n raise Polylog::InvalidProvider, \"`logger` method not found for provider #{name.inspect}\"\n end\n\n arity = provider.method(:logger).arity\n unless 1 == arity\n raise Polylog::InvalidProvider, \"`logger` method arity must be 1; arity is #{arity} for provider #{name.inspect}\"\n end\n\n @providers[name] = provider\n end", "def name\n @provider[:name]\n end", "def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end" ]
[ "0.77841043", "0.7281434", "0.6751144", "0.67248017", "0.66945326", "0.66607016", "0.64579046", "0.6436252", "0.6308327", "0.63036674", "0.62080294", "0.61596274", "0.60550034", "0.6043217", "0.6032127", "0.59899306", "0.5988631", "0.5912014", "0.58991325", "0.5866773", "0.5864048", "0.5860017", "0.5856235", "0.577448", "0.5754712", "0.5747258", "0.5747258", "0.5747258", "0.5747258", "0.5747258", "0.5747258", "0.5747258", "0.57317704", "0.57236886", "0.57177836", "0.5698913", "0.56938493", "0.5680583", "0.5680583", "0.56508523", "0.5632013", "0.5629215", "0.56017834", "0.55987966", "0.5598694", "0.5595402", "0.55935335", "0.5578346", "0.55753726", "0.5565449", "0.5543076", "0.55157673", "0.5502217", "0.5501901", "0.55009264", "0.5500569", "0.54685736", "0.5467218", "0.54267037", "0.5426564", "0.54159284", "0.5413588", "0.5408218", "0.54014915", "0.53836244", "0.53719026", "0.53665465", "0.5349897", "0.53417003", "0.5339439", "0.5331865", "0.53299934", "0.5305981", "0.53051084", "0.5292939", "0.5287662", "0.528116", "0.52802914", "0.52610034", "0.5252981", "0.5252981", "0.52445173", "0.52440774", "0.5240458", "0.5240285", "0.52375066", "0.52306515", "0.52306515", "0.52290916", "0.5224983", "0.52205634", "0.5219817", "0.5204442", "0.5204181", "0.5201892", "0.5199547", "0.5197349", "0.51962084", "0.5187621", "0.51841336" ]
0.8484686
0
List of all providers available
def provider_list @provider_list ||= subclasses.inject([]) do |list, klass_name| klass = klass_name.constantize begin list << klass.instance rescue LoadError => exc logger.error "#{klass} load error: #{exc}" end list end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def providers\n @providers.keys\n end", "def providers\n @providers ||= {}\n end", "def providers\n url = url_with_api_version(@base_url, 'providers')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end", "def providers\n driver(current_driver).providers\n end", "def providers\n @providers_manager\n end", "def providers\n providers = YARD::Registry.all(\"puppet_providers_#{name}\".to_sym)\n return providers if providers.empty?\n\n providers.first.children\n end", "def providers(params = {})\n response = default_scope.get('providers/') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end", "def suitable_providers\n return @suitable_providers if @suitable_providers\n @suitable_providers = []\n [\n @resource.class.defaultprovider,\n @resource.class.suitableprovider,\n ].flatten.uniq.each do |provider_class|\n if service_provider_enabled? provider_class\n @suitable_providers << provider_class.name\n end\n end\n @suitable_providers\n end", "def available_service_providers\n @providers = ServiceProvider.order(rating: :desc).order(rating_count: :desc)\n end", "def load_used_providers\n Vmpooler::Providers.load_by_name(used_providers)\n end", "def providers\n @providers ||= load_hash 'config/providers.yml'\n end", "def providers\n @providers.dup\n end", "def providers(parameters = {}, invocation_options = {})\n exec(RubyTerraform::Commands::Providers,\n parameters, invocation_options)\n end", "def providers\n authentication_strategies.pluck :provider\n end", "def providers_get(opts = {})\n data, _status_code, _headers = providers_get_with_http_info(opts)\n data\n end", "def configured_providers\n Rails.configuration.providers.select do |provider|\n Rails.configuration.send(\"omniauth_#{provider}\")\n end\n end", "def configured_providers\n Rails.configuration.providers.select do |provider|\n Rails.configuration.send(\"omniauth_#{provider}\")\n end\n end", "def formats\n providers.keys\n end", "def lcr_providers\n\n @page_title = _('Providers_for_LCR') # + \": \" + @lcr.name\n @page_icon = \"provider.png\"\n\n @providers = @lcr.sms_providers(\"asc\")\n @all_providers = SmsProvider.find(:all)\n @other_providers = []\n for prov in @all_providers\n @other_providers << prov if [email protected]?(prov)\n end\n flash[:notice] = _('No_providers_available') if @all_providers.empty?\n end", "def get_providers(opts = {})\n data, _status_code, _headers = get_providers_with_http_info(opts)\n data\n end", "def course_providers_list\n # TODO: Make sure course_providers are not huge. Very unlikely though\n course_providers.active.map do |cp|\n [\"#{ cp.locality } - #{ cp.city } - #{ cp.state }\", cp.id]\n end\n end", "def omniauth_providers\n @omniauth_providers ||= Account.omniauth_providers.map(&:to_s)\n end", "def provides\n @provides ||= user_data_as_array('provide')\n @provides\n end", "def list(selection=nil)\n env.load!\n\n env.config.providers.each do |name,provider|\n env.logger.debug(\"Asking provider #{name} to list ip #{selection}\")\n provider.ip_list(selection,options)\n end\n end", "def index\n @providers = Provider.all\n end", "def smb_enumprintproviders\n resp = smb_enumprinters(8, nil, 1, 0)\n return nil if not resp\n rptr, tmp, blen = resp.unpack(\"V*\")\n\n resp = smb_enumprinters(8, nil, 1, blen)\n return nil if not resp\n\n bcnt,pcnt,stat = resp[-12, 12].unpack(\"VVV\")\n return nil if stat != 0\n return nil if pcnt == 0\n return nil if bcnt > blen\n return nil if pcnt < 3\n\n #\n # The correct way, which leads to invalid offsets :-(\n #\n #providers = []\n #\n #0.upto(pcnt-1) do |i|\n # flags,desc_o,name_o,comm_o = resp[8 + (i*16), 16].unpack(\"VVVV\")\n #\n # #desc = read_unicode(resp,8+desc_o).gsub(\"\\x00\", '')\n # #name = read_unicode(resp,8+name_o).gsub(\"\\x00\", '')\n # #comm = read_unicode(resp,8+comm_o).gsub(\"\\x00\", '')\n # #providers << [flags,desc,name,comm]\n #end\n #\n #providers\n\n return resp\n\n end", "def smb_enumprintproviders\n\t\tresp = smb_enumprinters(8, nil, 1, 0)\n\t\treturn nil if not resp\n\t\trptr, tmp, blen = resp.unpack(\"V*\")\n\n\t\tresp = smb_enumprinters(8, nil, 1, blen)\n\t\treturn nil if not resp\n\n\t\tbcnt,pcnt,stat = resp[-12, 12].unpack(\"VVV\")\n\t\treturn nil if stat != 0\n\t\treturn nil if pcnt == 0\n\t\treturn nil if bcnt > blen\n\t\treturn nil if pcnt < 3\n\n\t\t#\n\t\t# The correct way, which leads to invalid offsets :-(\n\t\t#\n\t\t#providers = []\n\t\t#\n\t\t#0.upto(pcnt-1) do |i|\n\t\t#\tflags,desc_o,name_o,comm_o = resp[8 + (i*16), 16].unpack(\"VVVV\")\n\t\t#\n\t\t#\t#desc = read_unicode(resp,8+desc_o).gsub(\"\\x00\", '')\n\t\t#\t#name = read_unicode(resp,8+name_o).gsub(\"\\x00\", '')\n\t\t#\t#comm = read_unicode(resp,8+comm_o).gsub(\"\\x00\", '')\n\t\t#\t#providers << [flags,desc,name,comm]\n\t\t#end\n\t\t#\n\t\t#providers\n\n\t\treturn resp\n\n\tend", "def providers\n ([self] + parent_groups).reverse.inject({}) do |memo, group|\n begin\n memo.merge(group.poise_spec_helpers[:providers] || {})\n rescue NoMethodError\n memo\n end\n end\n end", "def providers\n @title = 'Puppet Provider Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_provider)\n erb(:objects)\nend", "def provided_pools\n list = []\n @config[:pools].each do |pool|\n list << pool['name'] if pool['provider'] == name\n end\n list\n end", "def alternative_names\n auth_providers.map do |ap|\n { provider: ap.provider, name: \"#{ap.uname} (#{ap.provider})\" }\n end\n end", "def load_providers()\n @cookbook_loader.each do |cookbook|\n cookbook.load_providers\n end\n true\n end", "def index\n @supplier_providers = Supplier::Provider.all\n end", "def index\n @service_providers = ServiceProvider.all\n end", "def whitelist_providers\n [:new_school_ldap, :twitter, :nyu_shibboleth, :aleph]\n end", "def get_selected_providers\n params.keys.select do |k|\n k.include? \"provider\"\n end.map do |checkbox|\n checkbox.split(\":\").last\n end\n end", "def get_auto_start_providers\n\t\ts = get_admin_section \"system.applicationHost/serviceAutoStartProviders\"\n\t\tIisObjectCollection.new s.Collection, :add, AutoStartProvider\n\tend", "def list(opts = {})\n search_provider.list(opts)\n end", "def providers_get_providers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProvidersApi.providers_get_providers ...\"\n end\n # resource path\n local_var_path = \"/api/Providers\"\n\n # query parameters\n query_params = {}\n query_params[:'$filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'$orderby'] = opts[:'orderby'] if !opts[:'orderby'].nil?\n query_params[:'$top'] = opts[:'top'] if !opts[:'top'].nil?\n query_params[:'$skip'] = opts[:'skip'] if !opts[:'skip'].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', 'text/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 => 'ProviderListItemPage')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProvidersApi#providers_get_providers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def list(selection=nil)\n\n env.config.providers.each do |name,provider|\n env.ui.info(\"Asking provider #{name} to list keystore #{selection}\")\n provider.keystore_list(selection,options)\n end\n end", "def provides(name)\n @providers << name unless @providers.include?(name)\n end", "def index\n @providerservices = Providerservice.all\n end", "def populate_providers_hash\n # GET A LIST OF ALL PROVIDERS\n Rails.logger.info(\"Retrieving providers list from #{@ingest_providers_list_endpoint}\")\n response = RestClient::Request.execute :method => :get, :url => \"#{@ingest_providers_list_endpoint}\", :verify_ssl => OpenSSL::SSL::VERIFY_NONE\n if (response.code != 200)\n Rails.logger.info(\"ERROR #{response.code} retrieving providers list\")\n # terminate task if we cannot validate the providers names\n exit(status=256)\n else\n list_of_providers_hashes = JSON.parse!(response.body)\n list_of_providers_hashes.each do |hash|\n provider_id = hash['provider-id']\n @all_providers[provider_id] = 'Y'\n end\n Rails.logger.info(\"RETRIEVED A LIST OF ALL PROVIDERS, SIZE: #{list_of_providers_hashes.size}, LOOKUP SIZE: #{@all_providers.size}\")\n end\n end", "def available_plugins\n PluginList.availables(@client)\n end", "def get_drivers\n return return_all_drivers\n end", "def index\n @utility_providers = UtilityProvider.all\n end", "def get_providers\n @weights.map{|k,v|v.keys}.flatten.uniq\n end", "def expiring_providers(expiring_favorites)\n providers = []\n expiring_shows = expiring_favorites.map {|favorite| favorite.show}\n shows_by_provider.each do |provider, show_array|\n shows_in_common = show_array.select do |show|\n expiring_shows.include?(show)\n end\n if !shows_in_common.empty?\n providers << provider \n end \n end \n providers\n end", "def provides\n sort!\n sources.map {|s| s.provides }.flatten\n end", "def provider_items\n @provider_items ||= ProviderItem.find(provider_items_ids)\n end", "def service_resource_providers\n service_resource_providers = []\n\n if ::File.exist?(\"/usr/sbin/update-rc.d\")\n service_resource_providers << :debian\n end\n\n if ::File.exist?(\"/usr/sbin/invoke-rc.d\")\n service_resource_providers << :invokercd\n end\n\n if ::File.exist?(\"/sbin/insserv\")\n service_resource_providers << :insserv\n end\n\n # debian >= 6.0 has /etc/init but does not have upstart\n if ::File.exist?(\"/etc/init\") && ::File.exist?(\"/sbin/start\")\n service_resource_providers << :upstart\n end\n\n if ::File.exist?(\"/sbin/chkconfig\")\n service_resource_providers << :redhat\n end\n\n if ::File.exist?(\"/bin/systemctl\")\n # FIXME: look for systemd as init provider\n service_resource_providers << :systemd\n end\n\n service_resource_providers\n end", "def generate_providers(cookbooks_paths)\n providers = []\n cookbooks_paths = [cookbooks_paths] unless cookbooks_paths.is_a?(Array)\n cookbooks_paths.each do |cookbooks_path|\n return [] unless File.directory?(cookbooks_path)\n Dir[File.normalize_path(File.join(cookbooks_path, '*/'))].each do |cookbook_path|\n cookbook_name = File.basename(cookbook_path)\n Dir[File.normalize_path(File.join(cookbook_path, POWERSHELL_PROVIDERS_DIR_NAME, '*/'))].each do |provider_file_path|\n provider_name = filename_to_qualified_string(cookbook_name, provider_file_path)\n provider_class_name = convert_to_class_name(provider_name)\n next if @providers_names.include?(provider_class_name)\n generate_single_provider(provider_class_name, provider_file_path)\n providers << provider_name\n end\n end\n end\n @providers_names += providers\n true\n end", "def available_service_providers\n ServiceProvider.includes(:provision_services).\n where(:provision_services => {:product_category_id => self.service_request.product_category_id,\n :product_brand_id => self.service_request.product_brand_id }\n ) if self.service_request\n end", "def available_plugins\n @plugins.keys\n end", "def providers\n [AssetPipelineProvider, FilesystemProvider]\n end", "def search(connector, options={})\n if options.respond_to? :to_str\n return search(connector, :q=>options.to_str)\n end\n json = connector.prepare_and_invoke_api_call(\n 'profiles/v1/search/providers', :method=>:get,\n :auth=>false, :sign=>false, :params=>options)\n\n providers = []\n if json['providers']['provider']\n [json['providers']['provider']].flatten.each do |provider|\n providers << self.new(provider)\n end\n end\n return providers\n end", "def list(selection=nil)\n\n env.config.keypairs.each do |name,provider|\n env.ui.info(\"Keypair name:#{name}\")\n end\n end", "def get_drivers\n drivers\n end", "def provider\n system.provider\n end", "def provider_map\n @provider_map ||= provider_list.inject({}) do |map, klass|\n map[klass.provider_id] = klass unless klass.nil?\n map\n end\n end", "def index\n @providers = Provider.order('lName').all\n end", "def identity_providers\n return @identity_providers\n end", "def identity_providers\n return @identity_providers\n end", "def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end", "def providers( url )\n\n\t\t\[email protected] do | name, options |\n\t\t\t\tif ( url =~ options[ :pattern ])\n\t\t\t\t\tyield self._provider( name, options )\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def identity_providers=(value)\n @identity_providers = value\n end", "def identity_providers=(value)\n @identity_providers = value\n end", "def [] format\n providers[format]\n end", "def index\n @v1_provider_operations = V1::ProviderOperation.all\n end", "def providers_get_providers(opts = {})\n data, _status_code, _headers = providers_get_providers_with_http_info(opts)\n return data\n end", "def providers\n before = ObjectSpace.each_object(Class).to_a\n filter_dir_contents(read_dir_contents).each { |f| require f }\n after = ObjectSpace.each_object(Class).to_a\n classes = (after - before).select { |c| c <= ProviderStrategy }\n @strategies.concat(classes.map(&:new))\n end", "def get_providers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PricesApi.get_providers ...'\n end\n # resource path\n local_var_path = '/v1/providers'\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\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 => 'Providers')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PricesApi#get_providers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def instances\n packages = []\n\n begin\n execpipe(listcmd) do |process|\n fields = [:name, :ensure]\n\n # yaourt -Q returns a list of packages in the format of\n # repo/package version (group)\n regex = /^\\w+\\/(\\S+)\\s+(\\S+)/\n\n process.each_line do |line|\n hash = {}\n\n if match = line.match(regex)\n fields.zip(match.captures) do |field, value|\n hash[field] = value\n end\n\n hash[:provider] = self.name\n packages << new(hash)\n else\n warning('Failed to match line %s' % line)\n end\n end\n end\n rescue Puppet::ExecutionFailure\n return nil\n end\n\n return packages\n end", "def index\n config = api.get_config_vars(app).body\n matches = config.keys & REDIS_PROVIDERS\n current = config['REDIS_URL']\n\n selected = REDIS_PROVIDERS.select do |key|\n config[key] == current && !current.nil?\n end\n\n if selected.empty?\n display \"No REDIS instance currently set to REDIS_URL\"\n else\n display \"Currently using #{selected.first}\\n\"\n end\n\n display\n display 'Available REDIS providers'\n matches.each do |match|\n display \" #{match}\"\n end\n end", "def find_providers_for(attributes)\n plugins = []\n attributes.each do |attribute|\n attrs = select_subtree(@map, attribute)\n raise Ohai::Exceptions::AttributeNotFound, \"No such attribute: \\'#{attribute}\\'\" unless attrs\n raise Ohai::Exceptions::ProviderNotFound, \"Cannot find plugin providing attribute: \\'#{attribute}\\'\" unless attrs[:_plugins]\n\n plugins += attrs[:_plugins]\n end\n plugins.uniq\n end", "def provider\n get(PROVIDER)\n end", "def available\n service_auth_map.keys.sort\n end", "def provides?(provider)\n @cursors.find do |cursor|\n cursor.providers.include?(provider)\n end\n end", "def omniauth_provider_groups(&block)\n # Find the most even number of groups\n groups = [5, 4].find { |g| omniauth_providers.count % g == 0 }\n groups ||= 3 # Fall back to 3 per line (yuck)\n\n # Return providers in groups\n omniauth_providers.in_groups_of groups, false, &block\n end", "def [](name)\n @providers[name]\n end", "def services\n warn \"DEPRECATED: this is no longer supported by LDAP. This method will always return an empty Array\"\n []\n end", "def provider\n @provider\n end", "def name(_prefix = false)\n 'Providers'\n end", "def fc_interfaces\n provider.fc_interfaces\n end", "def render_provider_cards\n return unless providers_params.present?\n providers_params.map { |prov| render \"catalog/providers/#{prov}\" }.join.html_safe\n end", "def all\n scan_supported_keys\n end", "def provider\n providers.first\n end", "def data_providers_get(opts = {})\n data, _status_code, _headers = data_providers_get_with_http_info(opts)\n data\n end", "def list_known_servers\n connect.servers.all\n end", "def index\n @payment_providers = PaymentProvider.all\n end", "def provider_box\n strings = []\n strings << @document.provider_name\n strings << @labels[:provider]\n @document.provider_lines.split(\"\\n\").each do |line|\n strings << line\n end\n strings << \"#{@labels[:tax_id]}: #{@document.provider_tax_id}\" \\\n unless @document.provider_tax_id.empty?\n strings << \"#{@labels[:tax_id2]}: #{@document.provider_tax_id2}\" \\\n unless @document.provider_tax_id2.empty?\n strings\n end", "def authentication_providers authenticator, account: Conjur.configuration.account\n JSON.parse(url_for(:authentication_providers, account, authenticator, credentials).get)\n end", "def provider\n use_provider('null') unless defined? @provider\n @provider\n end", "def index\n @providers = User.where(provider: true).where.not(slug: [nil,''], provider_name: [nil,'']).page(params[:page]).per( 12 ).order(:provider_name)\n end", "def set_provider\n PROVIDERS.each do |name|\n regex_string = PROVIDERS.first.eql?(name) ? name[0..-3] : name\n self.provider = name if link =~ /#{regex_string}/\n end\n end", "def list_families\n http_get(:uri=>\"/plugins/families\", :fields=>x_cookie)\n end", "def available_services_regions\n unless @regions\n @regions = []\n service_catalog.each do |service|\n next if service[\"type\"]==\"identity\"\n (service[\"endpoints\"] || []).each do |endpint|\n @regions << endpint['region']\n end\n end\n @regions.uniq!\n end\n @regions\n end", "def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config into a string for comparison\n return (provider[1].nil? ? {} : provider[1]) if provider[0].to_s == @provider_name\n end\n\n nil\n end", "def algorithms\n get_info :algorithms\n end" ]
[ "0.8306263", "0.7844875", "0.78092164", "0.7733508", "0.7679863", "0.7518636", "0.7396428", "0.7349031", "0.7271211", "0.725279", "0.72131926", "0.7002545", "0.69713765", "0.6923558", "0.6800231", "0.67870593", "0.67870593", "0.67741054", "0.67666966", "0.67639494", "0.6738653", "0.66201437", "0.64863527", "0.6438945", "0.6404954", "0.63910145", "0.63787353", "0.6348828", "0.6344367", "0.6314092", "0.6313086", "0.6307819", "0.624965", "0.6249184", "0.6234086", "0.6212027", "0.61979264", "0.619737", "0.61845094", "0.6180167", "0.6135153", "0.6132805", "0.61210644", "0.61184907", "0.61075634", "0.6105636", "0.610439", "0.60526043", "0.6052014", "0.60471183", "0.60352737", "0.6026316", "0.6018823", "0.60019004", "0.5991372", "0.5985697", "0.59845257", "0.5979273", "0.59770614", "0.59724987", "0.59604293", "0.5948371", "0.5948371", "0.5924975", "0.59193206", "0.58771056", "0.5834173", "0.5834173", "0.5830967", "0.58209854", "0.5820985", "0.5807712", "0.57957673", "0.57867527", "0.57615215", "0.5758556", "0.57423913", "0.5704281", "0.56997955", "0.56643844", "0.5661061", "0.56542754", "0.5648334", "0.56400174", "0.5629385", "0.56284815", "0.55981296", "0.5593882", "0.55924106", "0.55774987", "0.5564239", "0.5562269", "0.553558", "0.55317295", "0.5526482", "0.55193776", "0.5511446", "0.55091673", "0.5496131", "0.54823166" ]
0.7353798
7
Locate the service provider by provider id Example: SmsOnRails::ServiceProviders::Base.provider_by_id 1
def provider_by_id(provider_id) provider_map[provider_id.to_i] if provider_id.to_i > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name(provider)\n when 'NilClass' then nil\n else\n provider\n end\n end", "def set_provider_service\n @provider_service = ProviderService.find(params[:id])\n end", "def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end", "def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end", "def find_service\n if params[:service_id].present?\n @service = @provider.services.find_by_id(params[:service_id])\n end\n end", "def set_provider\n @provider = Provider.friendly.find(params[:id])\n end", "def set_providerservice\n @providerservice = Providerservice.find(params[:id])\n end", "def provider_key_for(service_id)\n storage.get(storage_key(service_id, 'provider_key'.freeze))\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def factory(id = nil)\n if id\n OneProvision::Provider.new_with_id(id, @client)\n else\n OneProvision::Provider.new(OneProvision::Provider.build_xml,\n @client)\n end\n end", "def set_provider_provider_type\n @provider_provider_type = Provider::ProviderType.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def get_provider(id, opts = {})\n # get all matching providers\n matching_provider_args = providers.find_all{|args| args.first == id}\n # sort providers on priority, form high to low\n matching_provider_args.sort! do |args_a, args_b|\n # we want to sort from high priority to low, but providers with the same priority level\n # should stay in the same order because among those, the last one added has the highest priority\n # (last added means first in the array, since they are pushed into the beginning of the array)\n (Provider.new(*args_b).priority || self.default_priority) <=> (Provider.new(*args_a).priority || self.default_priority)\n end\n # if no skip option is given, opts[:skip].to_i will result in zero, so it'll grab thefirst from the array\n # if the array is empty, args will always turn out nil\n args = matching_provider_args[opts[:skip].to_i]\n\n return args.nil? ? nil : Provider.new(*args)\n end", "def set_provider\r\n @provider = Provider.find(params[:id])\r\n end", "def provider\n providers.first\n end", "def set_supplier_provider\n @supplier_provider = Supplier::Provider.find(params[:id])\n end", "def provider\n get(PROVIDER)\n end", "def set_service_and_provider(id)\n service = Service.find(id)\n provider = User.preload(:profile).find(service.user_id)\n [service, provider]\n end", "def set_provider\n @provider = Provider.unscoped.where(\"allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER')\").where(deleted_at: nil).where(symbol: params[:id]).first\n fail ActiveRecord::RecordNotFound unless @provider.present?\n end", "def find_service(id)\n self.class.get(\"/services/#{id}.json?apikey=#{apikey}\")\n end", "def provider\n use_provider('null') unless defined? @provider\n @provider\n end", "def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def provider_for_profile(id)\n\t\tid.present? && Profile.find(id.to_i).payable_provider || \n\t\t\traise(Payment::ChargeAuthorizationError, I18n.t('payment.provider_not_allowed_charge_authorizations'))\n\tend", "def find_region_by_service(id)\n self.class.get(\"/services/#{id}/regions.json?apikey=#{apikey}\") \n end", "def provider_id\n return @provider_id\n end", "def provider_id=(value)\n @provider_id = value\n end", "def get_service_provider_icon(agency_id, mode)\n # search name first, then search external_id\n # this is because leg.agency_id is pre-processed in itinerary_parser\n # in which agency_id was not original agency_id from GTFS\n # but instead it's identified service name...\n s = Service.where(name: agency_id).first ||\n Service.where(external_id: agency_id).first\n\n if s\n if s.logo_url\n return get_service_provider_icon_url(s.logo_url)\n elsif s.provider and s.provider.logo_url\n return get_service_provider_icon_url(s.provider.logo_url)\n end\n end\n\n return get_mode_icon(mode)\n end", "def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end", "def provider\n return nil unless user_id\n user_id.split('/').last\n end", "def provider\n return nil unless user_id\n user_id.split('/').last\n end", "def set_provider\n @provider = Provider.find(params[:id]) if params[:id].present?\n @providers = Goodstype.find(params[:goodstype_id]).providers if params[:goodstype_id].present?\n end", "def provider_name\n object.provider_id.titleize\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def my_provider\n self.class.my_provider\n end", "def get id\n @services[id]\n end", "def provider\n @provider\n end", "def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def set_panel_provider\n @panel_provider = PanelProvider.find(params[:id])\n end", "def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end", "def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end", "def set_v1_provider_operation\n @v1_provider_operation = V1::ProviderOperation.find(params[:id])\n end", "def eval_service_provider_id\n service_provider_id = \"-\"\n if eob && eob.provider_npi.present?\n service_provider_id = eob.provider_npi\n elsif eob && eob.provider_tin.present?\n service_provider_id = eob.provider_tin\n elsif (!eob.blank? && !eob.claim_information.blank? && eob.claim_information.provider_npi.present?)\n service_provider_id = eob.claim_information.provider_npi\n elsif (!eob.blank? && !eob.claim_information.blank? && eob.claim_information.provider_ein.present?)\n service_provider_id = eob.claim_information.provider_ein\n elsif facility.facilities_npi_and_tins.present?\n service_provider_id = get_facility_npi_and_tin\n end\n service_provider_id\n end", "def find_provider(provider_name, domain_front)\n @options[:format] = :dots_9\n spinner = TTY::Spinner.new(\"[:spinner] Auto-detecting\", @options)\n case provider_name\n when :auto\n domain = Adomain.domain(domain_front)\n [amazon, azure, alibaba].map do |provider|\n if provider[:dfront].include?(domain)\n # spinner.update(title: \"Provider found: #{provider[:name].bold}\")\n # spinner.reset\n spinner.success(\" | Provider found: #{provider[:name].bold}\")\n return provider[:name].downcase.to_sym\n end\n end\n when :amazon || :azure || :alibaba\n provider_name\n else\n spinner.error(\"Failed to auto detect provider: please use '-p' and choose from: 1, 2 or 3\")\n end\n end", "def find_resource(id)\n query_service.find_by(id: Valkyrie::ID.new(id.to_s))\n end", "def set_payment_provider\n @payment_provider = PaymentProvider.find(params[:id])\n end", "def set_register_financeiro_provider\n @register_financeiro_provider = Register::Financeiro::Provider.find(params[:id])\n end", "def provider_id\n @service.try(:booking_details).try(:[], :provider_id)\n end", "def data_providers_id_get(id, opts = {})\n data, _status_code, _headers = data_providers_id_get_with_http_info(id, opts)\n data\n end", "def find_by(id:)\n storage_adapters.values.find do |storage_adapter|\n storage_adapter.handles?(id: id)\n end.find_by(id: id)\n end", "def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end", "def provider\n system.provider\n end", "def get_service_by_id(id)\n if params[:id]\n Service.find(params[:id])\n else\n nil #todo error handling.\n end\n end", "def find_srid(srname_or_srid)\n Factory::SridProvider.build.find(srname_or_srid)\n end", "def getContractBy_payment_provider_id( payment_provider, payment_provider_id)\n params = Hash.new\n params['payment_provider'] = payment_provider\n params['payment_provider_id'] = payment_provider_id\n return doCurl(\"get\",\"/contract/by_payment_provider_id\",params)\n end", "def service(id)\n ss = services\n ss.keep_if {|s| s.id == id}.first unless ss.nil?\n end", "def provide(oid = :all, &block)\n provider = Provider.new(oid)\n provider.instance_eval(&block)\n\n # Providers are pushed onto the end of the provider queue.\n # When dispatching, this is searched in order for a match.\n # So, like exception handlers, you such specify providers\n # in order of most -> least specific oid. ('1.3.1' comes before '1.3')\n providers << provider\n end", "def set_providers_payment_type\n @providers_payment_type = Providers::PaymentType.find(params[:id])\n end", "def provider\n @provider ||= find_constant( remoter_base, ::PoolParty::Remote )\n end", "def load_provider_model\n @provider_info_model ||= provider_infos.first\n end", "def first_provider(provider)\n @first_provider ||= authentications.each { |a| return a if a.provider == provider }\n end", "def provider_name(provider)\n Account.provider_name(provider)\n end", "def [](name)\n @providers[name]\n end", "def provider\n @provider or raise \"No provider set via space.use_provider\"\n end", "def provider_class\n self.class\n end", "def provider_class\n self.class\n end", "def authenticate_service_id(service_id, provider_key)\n provider_key == provider_key_for(service_id)\n end", "def provider_resource_id\n return @provider_resource_id\n end", "def [](key)\n if key == \"provider\"\n return @provider\n end\n @hash[key]\n end", "def authentication provider=:identity\n Authentication.where(user_id: id, provider: provider).all.first\n end", "def set_service_prov_type\n @service_prov_type = ServiceProvType.find(params[:id])\n end", "def retrieve\n provider.send(self.class.name)\n end", "def set_provider_payment\n @provider_payment = ProviderPayment.find(params[:id])\n end", "def provider_cli\n @provider_cli ||= begin\n return nil unless name = settings.exists?(\"provider.name\")\n require \"cyoi/cli/providers/provider_cli_#{settings.provider.name}\"\n klass = self.class.provider_cli(settings.provider.name)\n klass.new(settings.provider, hl)\n end\n end", "def find_service(service)\n @configs[service]\n end", "def name\n @provider[:name]\n end", "def get_credentials_provider\n @providers.each { |p|\n begin\n # if token is assigned, that's the provider we want.\n # providers must throw NoValueError so that we can fall to the next provider if necessary\n CerberusUtils::get_credentials_from_provider(p)\n return p\n\n rescue Cerberus::Exception::NoValueError\n next\n end\n }\n\n # we should have found and returned a valid provider above, else there's a problem\n CerberusUtils::Log.instance.error(\"Could not find a valid provider\")\n raise Cerberus::Exception::NoValidProviders.new\n end", "def provider_name\n return @provider_name\n end", "def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def provider_key\n map_options.try(:[], :provider_key)\n end", "def find_resource(resource_id)\n query_service.find_by(id: Valkyrie::ID.new(resource_id))\n end", "def set_content_provider\n @content_provider = ContentProvider.friendly.find(params[:id])\n end", "def name\n @provider_name\n end", "def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end", "def find_driver(id)\n return find_by_id(@drivers, id)\n end", "def find_by_id(id)\n configs.each do |config|\n if config.config_name.eql?(id)\n return config.new\n end\n end\n nil\n end", "def find(id)\n result = nil\n @vendors.each do |vendor|\n result = vendor if vendor.id == id\n end\n result\n end", "def set_oauth_service\n @oauth_service = @application.oauth_services.find(params[:id])\n end", "def service(id)\n request :get, \"/services/#{id}\"\n end", "def is_provider?\n self.provider?\n end", "def set_utility_provider\n @utility_provider = UtilityProvider.find(params[:id])\n end", "def provider_path\n provider_directory + \"#{@provider}.rb\"\n end", "def find_by_id(client, id, params = {})\n params = default_params.merge(params)\n\n client.get(\"#{resource_name}/#{id}\", params).data[resource_name_singular]\n end", "def provider(val=nil)\n if val && !val.is_a?(Class)\n resource_names = [resource_name]\n # If subclass_providers! might be in play, check for those names too.\n resource_names.concat(self.class.subclass_resource_equivalents) if self.class.respond_to?(:subclass_resource_equivalents)\n # Silly ruby tricks to find the first provider that exists and no more.\n provider_class = resource_names.lazy.map {|name| Poise::Helpers::Inversion.provider_for(name, node, val) }.select {|x| x }.first\n Poise.debug(\"[#{self}] Checking for an inversion provider for #{val}: #{provider_class && provider_class.name}\")\n val = provider_class if provider_class\n end\n super\n end" ]
[ "0.7458697", "0.72878104", "0.7274961", "0.7274961", "0.69589186", "0.6915681", "0.684967", "0.67321646", "0.66674227", "0.66674227", "0.66674227", "0.66674227", "0.66674227", "0.66674227", "0.66674227", "0.6658751", "0.66550994", "0.6650489", "0.6648719", "0.66163296", "0.6588922", "0.6524334", "0.64783925", "0.6467272", "0.6449501", "0.64295346", "0.63314563", "0.63243896", "0.62461585", "0.62213427", "0.6165452", "0.6135268", "0.6077138", "0.6036914", "0.60091287", "0.60091287", "0.5994473", "0.59859955", "0.5978939", "0.59705067", "0.59667975", "0.595045", "0.59483945", "0.5910168", "0.5890988", "0.5885364", "0.5884423", "0.5865868", "0.5835637", "0.58105755", "0.580827", "0.58032835", "0.57999605", "0.5782719", "0.57820076", "0.5767056", "0.57622105", "0.5740605", "0.5736845", "0.57148767", "0.5693278", "0.56906134", "0.56849277", "0.5668079", "0.56652653", "0.563675", "0.563295", "0.560513", "0.56044424", "0.5587856", "0.558521", "0.558521", "0.5575302", "0.5551153", "0.55351186", "0.55286694", "0.55100113", "0.55012363", "0.54973745", "0.54969317", "0.5495823", "0.5492248", "0.549113", "0.5490301", "0.5489179", "0.5487721", "0.54667336", "0.54654574", "0.5464166", "0.5458921", "0.54537016", "0.5447801", "0.5447467", "0.54376334", "0.5417532", "0.5377829", "0.53775746", "0.53635406", "0.5357963", "0.5346771" ]
0.7632758
0
Locate the service provider by name or symbol Example: SmsOnRails::ServiceProviders::Base.provider_by_name :dummy
def provider_by_name(provider_name) key = provider_name.to_s.downcase provider_list.detect{|p| key == p.name || provider_name == p.human_name} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name(provider)\n when 'NilClass' then nil\n else\n provider\n end\n end", "def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end", "def [](name)\n @providers[name]\n end", "def locate(service_name)\n klass = @services[service_name]\n raise \"Unknown service: #{service_name}\" unless klass\n klass.new\n end", "def provider\n use_provider('null') unless defined? @provider\n @provider\n end", "def find_provider(provider_name, domain_front)\n @options[:format] = :dots_9\n spinner = TTY::Spinner.new(\"[:spinner] Auto-detecting\", @options)\n case provider_name\n when :auto\n domain = Adomain.domain(domain_front)\n [amazon, azure, alibaba].map do |provider|\n if provider[:dfront].include?(domain)\n # spinner.update(title: \"Provider found: #{provider[:name].bold}\")\n # spinner.reset\n spinner.success(\" | Provider found: #{provider[:name].bold}\")\n return provider[:name].downcase.to_sym\n end\n end\n when :amazon || :azure || :alibaba\n provider_name\n else\n spinner.error(\"Failed to auto detect provider: please use '-p' and choose from: 1, 2 or 3\")\n end\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def named(name)\n service = all.find{|service| service.name == name}\n if service.nil?\n raise UnknownService, \"Service named #{name} isn't available\"\n else\n service\n end\n end", "def provider\n system.provider\n end", "def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def provider\n providers.first\n end", "def for_bosh_provider_name(system_config)\n case system_config.bosh_provider.to_sym\n when :aws\n Bosh::CloudFoundry::Providers::AWS.new(system_config.microbosh.fog_compute)\n when :openstack\n Bosh::CloudFoundry::Providers::OpenStack.new(system_config.microbosh.fog_compute)\n else\n raise \"please support #{system_config.bosh_provider} provider\"\n end\n end", "def service(symbol)\n \"#{self.class}::#{symbol.to_s.camelcase}\".constantize\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def _provider( name, options )\n\n\t\t\t@_provider ||= { }\n\t\t\t@_provider[ name ] ||= (\n\n\t\t\t\tObject::const_get( name ).new( options )\n\t\t\t)\n\t\tend", "def name\n @provider[:name]\n end", "def provider\n get(PROVIDER)\n end", "def mappings_provider(provider_name, is_legacy = false)\n return nil if provider_name.nil?\n provider = nil\n module_name = is_legacy ? 'Highlander': 'Cfhighlander'\n begin\n providers = Object.const_get(module_name).const_get('MapProviders')\n providers.const_get(provider_name)\n rescue NameError => e\n if e.to_s.include? \"uninitialized constant\"\n return mappings_provider(provider_name, true) unless is_legacy\n return nil\n end\n STDERR.puts(e.to_s)\n raise e\n end\nend", "def my_provider\n self.class.my_provider\n end", "def service_provider\n base_class = if defined?(Chef::Provider::RunitService)\n Chef::Provider::RunitService\n elsif defined?(Chef::Provider::Service::Runit)\n Chef::Provider::Service::Runit\n else\n raise PoiseService::Error.new('Unable to find runit_service provider class.')\n end\n Class.new(base_class) do\n # Lie about the name.\n def self.name\n superclass.name\n end\n\n def inside_docker?\n # We account for docker already so just lock it to false.\n false\n end\n end\n end", "def find_service(service)\n @configs[service]\n end", "def find(name)\n result = nil\n connect do |conn|\n begin\n conn.search2(dn(name), 0, \"objectclass=*\") do |result|\n # Convert to puppet-appropriate attributes\n return entry2provider(result)\n end\n rescue => detail\n return nil\n end\n end\n end", "def provider_feature(name)\n return nil unless defined?(@features)\n\n @features[name]\n end", "def find_by_service_name(name)\n service = locator.find_by_name(name)\n service['credentials'] if service\n end", "def service_type_name(account_name, name)\n map_opts = get_acct_catalog_map(account_name)\n case map_opts[:provider]\n when \"hp\"\n service_name = name\n unless map_opts[:catalog].nil?\n service_catalog_key = name.to_s.downcase.gsub(' ','_').to_sym\n service_name = map_opts[:catalog][service_catalog_key] if map_opts[:catalog].has_key?(service_catalog_key)\n end\n return service_name\n else\n return name\n end\n end", "def service_key\n (is_a?(Module) ? name : self.class.name).demodulize.underscore.to_sym\n end", "def service_key\n (is_a?(Module) ? name : self.class.name).demodulize.underscore.to_sym\n end", "def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end", "def find_service\n if params[:service_id].present?\n @service = @provider.services.find_by_id(params[:service_id])\n end\n end", "def name(_prefix = false)\n 'Providers'\n end", "def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end", "def register_provider(name, klass)\n @providers[name] = klass\n end", "def method_missing(m, *args, &block)\n return @services[m.to_sym] if @services.include? m.to_sym\n raise NoMethodError.new(\"undefined method `#{m}' for #{self}\")\n end", "def default_provider\n return nil unless node && node['platform_family']\n Chef::Provider::Dropbox.const_get(node['platform_family'].split('_')\n .map(&:capitalize).join)\n end", "def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end", "def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end", "def provider\n @provider or raise \"No provider set via space.use_provider\"\n end", "def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end", "def find(service_name)\n return @services if service_name == :all\n \n service = @services[service_name]\n return service unless service.nil? \n \n ContainerLogger.warn \"Unexisting service called: #{@name}::#{service_name}\", 1\n nil\n end", "def find_strategy(type)\n \"Simple::OAuth2::Strategies::#{type.to_s.camelize}\".constantize\n end", "def maybe_chef_platform_lookup(resource)\n Chef::Platform.find_provider_for_node(node, resource)\n end", "def retrieve\n provider.send(self.class.name)\n end", "def name\n @provider_name\n end", "def resolve_provider\n attributes.fetch(:resolveProvider)\n end", "def provides(name)\n @providers << name unless @providers.include?(name)\n end", "def provider\n @provider ||= find_constant( remoter_base, ::PoolParty::Remote )\n end", "def provider(name, &block)\n name = name.to_sym\n @__providers[name] ||= []\n @__provider_overrides[name] ||= []\n\n # Add the provider to the ordering list\n @__provider_order << name\n\n if block_given?\n @__providers[name] << block if block_given?\n\n # If this block takes two arguments, then we curry it and store\n # the configuration override for use later.\n if block.arity == 2\n @__provider_overrides[name] << block.curry[Vagrant::Config::V2::DummyConfig.new]\n end\n end\n end", "def provider\n begin\n @provider ||= eval(\"MusicProviders::#{source}\").new\n rescue\n @provider = MusicProviders::DefaultProvider.new\n end\n end", "def provider_by_id(provider_id)\n provider_map[provider_id.to_i] if provider_id.to_i > 0\n end", "def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def method_missing(sym, *args)\n lookup(sym.to_sym)\n end", "def find_class_or_module name\n @store.find_class_or_module name\n end", "def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end", "def find_by_name(name)\n end", "def method_missing( sym, *args, &block )\n if args.empty? && block.nil? && @registry[:services].has_key?( sym )\n return @registry[:services][ sym ]\n else\n super\n end\n end", "def provider\n EmailAddress::Config.providers.each do |name, defn|\n return name if EmailAddress::DomainMatcher.matches?(@host_name, defn[:domains])\n end\n nil\n end", "def set_provider_service\n @provider_service = ProviderService.find(params[:id])\n end", "def provider_name(provider)\n Account.provider_name(provider)\n end", "def find_by_name(name)\n Discovery.find_by_name(name)\n end", "def openstack_provider\n # dream host doesn't support windows so bail early if we're on windows\n return \"openstack\" if RUBY_PLATFORM.match?(/mswin|mingw|windows/)\n\n if Etc::Passwd.entries.map(&:name).include?(\"dhc-user\")\n \"dreamhost\"\n else\n \"openstack\"\n end\n end", "def set_provider\n @provider = Provider.unscoped.where(\"allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER')\").where(deleted_at: nil).where(symbol: params[:id]).first\n fail ActiveRecord::RecordNotFound unless @provider.present?\n end", "def maybe_explicit_provider(resource)\n return nil unless resource.provider\n resource.provider\n end", "def provider_key_for(service_id)\n storage.get(storage_key(service_id, 'provider_key'.freeze))\n end", "def provider_name\n return @provider_name\n end", "def strategy_name\n options[:name] || @provider\n end", "def provider_name\n object.provider_id.titleize\n end", "def service(name)\n name = name.to_sym\n\n service_info = SERVICES[name]\n if service_info.nil?\n raise ArgumentError, sprintf('No service found with name %s', name)\n end\n\n require_path = sprintf(SERVICE_PATH, @path_version,\n service_info.first)\n require require_path\n\n class_path = sprintf(SERVICE_CLASS_PATH, @version, service_info.last)\n return class_for_path(class_path)\n end", "def find_srid(srname_or_srid)\n Factory::SridProvider.build.find(srname_or_srid)\n end", "def type\n :puppet_provider\n end", "def provider\n @provider\n end", "def method_missing(name, *args, &blk)\n provider.send(name, *args)\n end", "def suitable_providers\n return @suitable_providers if @suitable_providers\n @suitable_providers = []\n [\n @resource.class.defaultprovider,\n @resource.class.suitableprovider,\n ].flatten.uniq.each do |provider_class|\n if service_provider_enabled? provider_class\n @suitable_providers << provider_class.name\n end\n end\n @suitable_providers\n end", "def autodetect_selected_provider\n if EcwidPizzeria::Application.config.app.ecwid.order_api_enabled\n params[:provider]\n\n url = \"https://app.ecwid.com/api/v1/#{EcwidPizzeria::Application.config.app.ecwid.shop_id}/orders\"\n api_params = {secure_auth_key: EcwidPizzeria::Application.config.app.ecwid.order_api_key, order: params[:ord]}\n\n response = RestClient.get(url, params: api_params)\n order = JSON.parse(response)['orders'].first\n\n val = order['paymentMethod'].to_s.downcase.strip\n # Try to get customer country code from order\n params[:country_code] ||= order.fetch('billingPerson', {}).fetch('countryCode', nil) || order['customerCountryCodeByIP']\n\n params[:provider] = case val\n when *(EcwidPizzeria::Application.config.banks.enabled + ['estcard', 'paypal'])\n val\n when %r(\\A(makecommerce|maksekeskus)(.*)\\z)\n payment_method = $2.gsub(':', '').strip.parameterize.gsub('-', '_')\n \"makecommerce_#{payment_method}\"\n when %r(\\A(#{EcwidPizzeria::Application.config.banks.enabled.join('|')}*?)\\s(pank|bank)\\z)\n $1\n when 'danskebank', 'dnb', 'danske', 'danske bank', 'danske pank'\n 'sampo'\n end\n end\n rescue\n nil\n end", "def find_engine\n result = nil\n # We already know the name of the gem from user input\n if Gem.loaded_specs.has_key? gem_name\n # Let's get the gem's full path in the filesystem\n gpath = Gem.loaded_specs[gem_name].full_gem_path\n # Then match the path we've got to the path of an engine - \n # which should have its Module Name (aka paydirt)\n Rails::Application::Railties.engines.each do |engine| \n if engine.class.root.to_s == gpath\n # Get the class name from the engine hash\n result = engine.class\n break\n end\n end\n end\n result\n end", "def discovered_method(rpc_name, api, version=nil)\n if !rpc_name.kind_of?(String) && !rpc_name.kind_of?(Symbol)\n raise TypeError,\n \"Expected String or Symbol, got #{rpc_name.class}.\"\n end\n rpc_name = rpc_name.to_s\n api = api.to_s\n version = version || 'v1'\n service = self.discovered_api(api, version)\n if service.to_h[rpc_name]\n return service.to_h[rpc_name]\n else\n return nil\n end\n end", "def provider(force_reload=false)\n return @provider unless @provider.nil? || force_reload\n @provider = ServiceProvider.get(@provider_permalink)\n end", "def lookup(type_name, resource_name)\n self.class.catalog_lookup(resource.catalog, type_name, resource_name)\n end", "def provider_type\n provider.to_s.gsub(\"oauth2\", \"\").try(:titleize)\n end", "def class_get class_name\n\t\t\t\[email protected] do\n\t\t\t\t\tproviders.each do |p|\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\treturn p.class_get(class_name) \n\t\t\t\t\t\trescue NotExist;\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\traise \"Class '#{class_name}' doesn't exist!\"\n\t\t\t\tend\n\t\t\tend", "def service_name\n self[:name].gsub(/\\.|,/, '_').gsub(/\\s/, '').underscore.to_sym if self[:name]\n end", "def provider_class\n self.class\n end", "def provider_class\n self.class\n end", "def service(name)\n \"#{SERVICE_NAME} #{name}\"\n end", "def method_missing(method_sym, *arguments, &block)\n # ignore classes\n return true if method_sym == :klass\n \n # load service from cache if available\n service = instance_variable_get(\"@#{method_sym.to_s}\")\n \n # service is not cached yet -> first request\n unless service \n # construct the class name of requested service.\n # For example Openstack::IdentityService.\n # Services must be located in app/services/openstack\n service_class_name = \"Openstack::#{method_sym.to_s.classify}Service\"\n \n # load service class\n klazz = begin\n eval(service_class_name)\n rescue\n raise \"service #{service_class_name} not found!\"\n end\n\n # service must extend OpenstackServiceProvider::BaseProvider, see below.\n unless klazz < OpenstackServiceProvider::BaseProvider\n raise \"service #{service_class_name} is not a subclass of OpenstackServiceProvider::BaseProvider\" \n end\n\n service = klazz.new(@endpoint,@region,@current_user)\n # new service is instantiated -> cache it for further use in the same controller request.\n instance_variable_set(\"@#{method_sym.to_s}\", service)\n end\n \n return service\n end", "def test_name_or_provider\n provider = @type.provide(:testing) do\n end\n\n # first make sure we can pass the name in\n resource = nil\n assert_nothing_raised(\"Could not create provider instance by name\") do\n resource = @type.new :name => \"yay\", :provider => :testing\n end\n\n assert_instance_of(provider, resource.provider, \"Did not create provider instance\")\n\n # Now make sure we can pass in an instance\n provinst = provider.new(:name => \"foo\")\n assert_nothing_raised(\"Could not pass in provider instance\") do\n resource = @type.new :name => \"foo\", :provider => provinst\n end\n\n assert_equal(provinst, resource.provider, \"Did not retain provider instance\")\n assert_equal(provider.name, resource[:provider], \"Provider value was set to the provider instead of its name\")\n\n # Now make sure unsuitable provider instances still throw errors\n provider = @type.provide(:badprov) do\n confine :exists => \"/no/such/file\"\n end\n\n # And make sure the provider must be a valid provider type for this resource\n pkgprov = Puppet::Type.type(:package).new(:name => \"yayness\").provider\n assert(provider, \"did not get package provider\")\n\n assert_raise(Puppet::Error, \"Did not fail on invalid provider instance\") do\n resource = @type.new :name => \"bar\", :provider => pkgprov\n end\n\n end", "def provider\n conf['provider'] || 'defaults'\n end", "def first_provider(provider)\n @first_provider ||= authentications.each { |a| return a if a.provider == provider }\n end", "def set_providerservice\n @providerservice = Providerservice.find(params[:id])\n end", "def service_klass(constant_string)\n if const_defined?([to_s, constant_string].join(\"::\"))\n [to_s, constant_string].join(\"::\")\n else\n provider = to_s.split(\"::\").last\n Fog::Logger.deprecation(\"Unable to load #{[to_s, constant_string].join('::')}\")\n Fog::Logger.deprecation(\n format(\n Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,\n service: constant_string,\n provider: provider\n )\n )\n [\"Fog\", constant_string, provider].join(\"::\")\n end\n end", "def spawn_lookup(name)\n name = name.to_s\n require \"earth_tools/lookup/#{name}\"\n klass = name.split(\"_\").map{ |i| i[0...1].upcase + i[1..-1] }.join\n EarthTools::Lookup.const_get(klass).new\n end", "def reg_resolve!(key)\n return key unless Utils.ident?(key)\n spec = reg_resolve(key)\n\n if spec\n spec\n else\n raise \"Unable to resolve spec: #{key}\"\n end\n end", "def service\n @service ||=\n if (c = self_class)\n name = c.safe_const_get(:SERVICE_NAME)\n name ||= c.module_parent_name.underscore.remove(/_service$/)\n name&.to_sym || super\n end\n end", "def set_provider\n @provider = Provider.friendly.find(params[:id])\n end", "def find_by_name(name)\n binding.pry\n self.name\n end", "def provides?(provider)\n @cursors.find do |cursor|\n cursor.providers.include?(provider)\n end\n end", "def set_selected_provider\n autodetect_selected_provider if params[:provider] == 'auto' && params[:ord].present?\n\n @selected_provider = case params[:provider]\n when 'estcard'\n if EcwidPizzeria::Application.config.estcard.enabled\n prepare_estcard\n params[:provider]\n end\n when 'paypal'\n if EcwidPizzeria::Application.config.paypal.enabled\n prepare_paypal\n params[:provider]\n end\n when %r(\\Amakecommerce_(.*)\\z)\n payment_method = $1\n @payment_method = payment_method\n\n @payment_method = if EcwidPizzeria::Application.config.make_commerce.enabled && makecommerce_service.enabled_payment_methods.include?(payment_method)\n params[:provider] = 'makecommerce'\n payment_method\n else\n nil\n end\n params[:provider]\n when *EcwidPizzeria::Application.config.banks.enabled\n prepare_ipizza\n params[:provider]\n end\n end", "def create_provider_object(config, logger, metrics, redis_connection_pool, provider_class, provider_name, options)\n provider_klass = Vmpooler::PoolManager::Provider\n provider_klass.constants.each do |classname|\n next unless classname.to_s.casecmp(provider_class) == 0\n\n return provider_klass.const_get(classname).new(config, logger, metrics, redis_connection_pool, provider_name, options)\n end\n raise(\"Provider '#{provider_class}' is unknown for pool with provider name '#{provider_name}'\") if provider_klass.nil?\n end", "def cleanup_provider(provider)\n lookups = {}\n Souffle::Provider.constants.each { |k| lookups[k.to_s.downcase] = k.to_s }\n lookups.fetch([provider.downcase], provider)\n end", "def get_credentials_provider\n @providers.each { |p|\n begin\n # if token is assigned, that's the provider we want.\n # providers must throw NoValueError so that we can fall to the next provider if necessary\n CerberusUtils::get_credentials_from_provider(p)\n return p\n\n rescue Cerberus::Exception::NoValueError\n next\n end\n }\n\n # we should have found and returned a valid provider above, else there's a problem\n CerberusUtils::Log.instance.error(\"Could not find a valid provider\")\n raise Cerberus::Exception::NoValidProviders.new\n end", "def service_display_name(arg)\n service = arg.to_sym if arg.respond_to?(:to_sym)\n service = service_name(arg) unless @options.include?(service)\n if service.nil?\n nil\n else\n @options[service].display_name\n end\n end" ]
[ "0.75238806", "0.6708917", "0.63696367", "0.6368261", "0.6309314", "0.6273535", "0.62581193", "0.6247125", "0.6228032", "0.6226512", "0.62250024", "0.6215729", "0.6200408", "0.61664134", "0.6146286", "0.6123955", "0.60825837", "0.60461485", "0.6016185", "0.59677553", "0.59562415", "0.59547794", "0.5953447", "0.59274536", "0.5910528", "0.5904444", "0.5904444", "0.59004617", "0.5873874", "0.58561194", "0.58469236", "0.58433783", "0.5828551", "0.58108485", "0.58106", "0.58106", "0.5807964", "0.5796152", "0.57936406", "0.57705426", "0.5756749", "0.5739371", "0.5734062", "0.5718224", "0.5714845", "0.570859", "0.5700712", "0.5697744", "0.5674564", "0.5664415", "0.56493086", "0.56425285", "0.56412303", "0.5620678", "0.56148314", "0.5592145", "0.55798525", "0.557774", "0.5573074", "0.5569927", "0.55627733", "0.55586535", "0.55466884", "0.5545587", "0.55357933", "0.5532579", "0.5528827", "0.55280834", "0.5514579", "0.5513947", "0.55106544", "0.55087197", "0.55066824", "0.5502643", "0.5497489", "0.54921436", "0.5491036", "0.5490629", "0.54724264", "0.54630256", "0.5431441", "0.5431441", "0.5430579", "0.5410857", "0.5402762", "0.53922296", "0.5385286", "0.53791255", "0.53762436", "0.5351329", "0.5350603", "0.5350301", "0.53481716", "0.53371316", "0.5330975", "0.53211224", "0.5317177", "0.5316383", "0.5314159", "0.5312488" ]
0.6485821
2
Locate the service provider object by provider_id, string, symbol, or ServiceProvider object Defaults to the default service provider SmsOnRails::ServiceProviders::Base.get_service_provider :dummy SmsOnRails::ServiceProviders::Base.get_service_provider 1 SmsOnRails::ServiceProviders::Base.get_service_provider SmsOnRails::ServiceProviders::Dummy
def get_service_provider(provider) case provider.class.to_s when 'Fixnum' then provider_by_id(provider) when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider)) when 'Symbol' then provider_by_name(provider) when 'NilClass' then nil else provider end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end", "def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end", "def set_provider_service\n @provider_service = ProviderService.find(params[:id])\n end", "def find_service\n if params[:service_id].present?\n @service = @provider.services.find_by_id(params[:service_id])\n end\n end", "def provider\n use_provider('null') unless defined? @provider\n @provider\n end", "def set_providerservice\n @providerservice = Providerservice.find(params[:id])\n end", "def provider_by_id(provider_id)\n provider_map[provider_id.to_i] if provider_id.to_i > 0\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def provider\n get(PROVIDER)\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def set_provider_provider_type\n @provider_provider_type = Provider::ProviderType.find(params[:id])\n end", "def provider_key_for(service_id)\n storage.get(storage_key(service_id, 'provider_key'.freeze))\n end", "def provider\n providers.first\n end", "def eval_service_provider_id\n service_provider_id = \"-\"\n if eob && eob.provider_npi.present?\n service_provider_id = eob.provider_npi\n elsif eob && eob.provider_tin.present?\n service_provider_id = eob.provider_tin\n elsif (!eob.blank? && !eob.claim_information.blank? && eob.claim_information.provider_npi.present?)\n service_provider_id = eob.claim_information.provider_npi\n elsif (!eob.blank? && !eob.claim_information.blank? && eob.claim_information.provider_ein.present?)\n service_provider_id = eob.claim_information.provider_ein\n elsif facility.facilities_npi_and_tins.present?\n service_provider_id = get_facility_npi_and_tin\n end\n service_provider_id\n end", "def get_provider(id, opts = {})\n # get all matching providers\n matching_provider_args = providers.find_all{|args| args.first == id}\n # sort providers on priority, form high to low\n matching_provider_args.sort! do |args_a, args_b|\n # we want to sort from high priority to low, but providers with the same priority level\n # should stay in the same order because among those, the last one added has the highest priority\n # (last added means first in the array, since they are pushed into the beginning of the array)\n (Provider.new(*args_b).priority || self.default_priority) <=> (Provider.new(*args_a).priority || self.default_priority)\n end\n # if no skip option is given, opts[:skip].to_i will result in zero, so it'll grab thefirst from the array\n # if the array is empty, args will always turn out nil\n args = matching_provider_args[opts[:skip].to_i]\n\n return args.nil? ? nil : Provider.new(*args)\n end", "def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end", "def choose_service_provider\n #validate permissions\n return unless permitted_for_user_type?(Client)\n # Retrieve service request\n return unless get_service_request?\n render_not_found \"service with id #{service.id} not found\" and return unless (service = @service_request.service)\n # validate ownership on this service\n render_forbidden \"you are not the client of this service request\" and return unless service.client_id == @current_user.id\n # Validate service request is approved\n render_forbidden \"service request with id #{@service_request.id} was not approved by service provider with id #{@service_request.service_provider.id}\" and return unless (@service_request.approved?)\n\n # Set service provider\n service.service_provider = @service_request.service_provider\n # Confirm service\n service.confirmed!\n #handle save\n render_unprocessable_entity \"couldn't save\" and return false unless service.save\n # Delete all other related requests\n ServiceRequest.delete_all(service: service)\n # Render success\n render_success\n\n # notify service provider\n NotificationsService.send_notification(@current_user, service_provider, NOTIFICATION_TYPE[:confirmed_you_as_provider], service.id)\n end", "def factory(id = nil)\n if id\n OneProvision::Provider.new_with_id(id, @client)\n else\n OneProvision::Provider.new(OneProvision::Provider.build_xml,\n @client)\n end\n end", "def my_provider\n self.class.my_provider\n end", "def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end", "def find_provider(provider_name, domain_front)\n @options[:format] = :dots_9\n spinner = TTY::Spinner.new(\"[:spinner] Auto-detecting\", @options)\n case provider_name\n when :auto\n domain = Adomain.domain(domain_front)\n [amazon, azure, alibaba].map do |provider|\n if provider[:dfront].include?(domain)\n # spinner.update(title: \"Provider found: #{provider[:name].bold}\")\n # spinner.reset\n spinner.success(\" | Provider found: #{provider[:name].bold}\")\n return provider[:name].downcase.to_sym\n end\n end\n when :amazon || :azure || :alibaba\n provider_name\n else\n spinner.error(\"Failed to auto detect provider: please use '-p' and choose from: 1, 2 or 3\")\n end\n end", "def set_selected_provider\n autodetect_selected_provider if params[:provider] == 'auto' && params[:ord].present?\n\n @selected_provider = case params[:provider]\n when 'estcard'\n if EcwidPizzeria::Application.config.estcard.enabled\n prepare_estcard\n params[:provider]\n end\n when 'paypal'\n if EcwidPizzeria::Application.config.paypal.enabled\n prepare_paypal\n params[:provider]\n end\n when %r(\\Amakecommerce_(.*)\\z)\n payment_method = $1\n @payment_method = payment_method\n\n @payment_method = if EcwidPizzeria::Application.config.make_commerce.enabled && makecommerce_service.enabled_payment_methods.include?(payment_method)\n params[:provider] = 'makecommerce'\n payment_method\n else\n nil\n end\n params[:provider]\n when *EcwidPizzeria::Application.config.banks.enabled\n prepare_ipizza\n params[:provider]\n end\n end", "def set_provider\n @provider = Provider.friendly.find(params[:id])\n end", "def set_service_and_provider(id)\n service = Service.find(id)\n provider = User.preload(:profile).find(service.user_id)\n [service, provider]\n end", "def provider_id\n @service.try(:booking_details).try(:[], :provider_id)\n end", "def find_service(service)\n @configs[service]\n end", "def suitable_providers\n return @suitable_providers if @suitable_providers\n @suitable_providers = []\n [\n @resource.class.defaultprovider,\n @resource.class.suitableprovider,\n ].flatten.uniq.each do |provider_class|\n if service_provider_enabled? provider_class\n @suitable_providers << provider_class.name\n end\n end\n @suitable_providers\n end", "def get_credentials_provider\n @providers.each { |p|\n begin\n # if token is assigned, that's the provider we want.\n # providers must throw NoValueError so that we can fall to the next provider if necessary\n CerberusUtils::get_credentials_from_provider(p)\n return p\n\n rescue Cerberus::Exception::NoValueError\n next\n end\n }\n\n # we should have found and returned a valid provider above, else there's a problem\n CerberusUtils::Log.instance.error(\"Could not find a valid provider\")\n raise Cerberus::Exception::NoValidProviders.new\n end", "def service_provider\n base_class = if defined?(Chef::Provider::RunitService)\n Chef::Provider::RunitService\n elsif defined?(Chef::Provider::Service::Runit)\n Chef::Provider::Service::Runit\n else\n raise PoiseService::Error.new('Unable to find runit_service provider class.')\n end\n Class.new(base_class) do\n # Lie about the name.\n def self.name\n superclass.name\n end\n\n def inside_docker?\n # We account for docker already so just lock it to false.\n false\n end\n end\n end", "def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config into a string for comparison\n return (provider[1].nil? ? {} : provider[1]) if provider[0].to_s == @provider_name\n end\n\n nil\n end", "def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end", "def _provider( name, options )\n\n\t\t\t@_provider ||= { }\n\t\t\t@_provider[ name ] ||= (\n\n\t\t\t\tObject::const_get( name ).new( options )\n\t\t\t)\n\t\tend", "def set_provider\n @provider = Provider.unscoped.where(\"allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER')\").where(deleted_at: nil).where(symbol: params[:id]).first\n fail ActiveRecord::RecordNotFound unless @provider.present?\n end", "def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end", "def default_provider\n return nil unless node && node['platform_family']\n Chef::Provider::Dropbox.const_get(node['platform_family'].split('_')\n .map(&:capitalize).join)\n end", "def provider\n @provider or raise \"No provider set via space.use_provider\"\n end", "def provider\n @provider\n end", "def provider\n conf['provider'] || 'defaults'\n end", "def available_service_providers\n ServiceProvider.includes(:provision_services).\n where(:provision_services => {:product_category_id => self.service_request.product_category_id,\n :product_brand_id => self.service_request.product_brand_id }\n ) if self.service_request\n end", "def provider(force_reload=false)\n return @provider unless @provider.nil? || force_reload\n @provider = ServiceProvider.get(@provider_permalink)\n end", "def first_provider(provider)\n @first_provider ||= authentications.each { |a| return a if a.provider == provider }\n end", "def provider\n @provider ||= Bosh::Providers.for_bosh_provider_name(settings.bosh_provider, fog_compute)\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id]) if params[:id].present?\n @providers = Goodstype.find(params[:goodstype_id]).providers if params[:goodstype_id].present?\n end", "def set_supplier_provider\n @supplier_provider = Supplier::Provider.find(params[:id])\n end", "def load_provider_model\n @provider_info_model ||= provider_infos.first\n end", "def provider_key\n map_options.try(:[], :provider_key)\n end", "def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end", "def set_provider\r\n @provider = Provider.find(params[:id])\r\n end", "def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end", "def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end", "def resolve_provider\n attributes.fetch(:resolveProvider)\n end", "def find_service(id)\n self.class.get(\"/services/#{id}.json?apikey=#{apikey}\")\n end", "def autodetect_selected_provider\n if EcwidPizzeria::Application.config.app.ecwid.order_api_enabled\n params[:provider]\n\n url = \"https://app.ecwid.com/api/v1/#{EcwidPizzeria::Application.config.app.ecwid.shop_id}/orders\"\n api_params = {secure_auth_key: EcwidPizzeria::Application.config.app.ecwid.order_api_key, order: params[:ord]}\n\n response = RestClient.get(url, params: api_params)\n order = JSON.parse(response)['orders'].first\n\n val = order['paymentMethod'].to_s.downcase.strip\n # Try to get customer country code from order\n params[:country_code] ||= order.fetch('billingPerson', {}).fetch('countryCode', nil) || order['customerCountryCodeByIP']\n\n params[:provider] = case val\n when *(EcwidPizzeria::Application.config.banks.enabled + ['estcard', 'paypal'])\n val\n when %r(\\A(makecommerce|maksekeskus)(.*)\\z)\n payment_method = $2.gsub(':', '').strip.parameterize.gsub('-', '_')\n \"makecommerce_#{payment_method}\"\n when %r(\\A(#{EcwidPizzeria::Application.config.banks.enabled.join('|')}*?)\\s(pank|bank)\\z)\n $1\n when 'danskebank', 'dnb', 'danske', 'danske bank', 'danske pank'\n 'sampo'\n end\n end\n rescue\n nil\n end", "def for_bosh_provider_name(system_config)\n case system_config.bosh_provider.to_sym\n when :aws\n Bosh::CloudFoundry::Providers::AWS.new(system_config.microbosh.fog_compute)\n when :openstack\n Bosh::CloudFoundry::Providers::OpenStack.new(system_config.microbosh.fog_compute)\n else\n raise \"please support #{system_config.bosh_provider} provider\"\n end\n end", "def provider_type\n provider.to_s.gsub(\"oauth2\", \"\").try(:titleize)\n end", "def create_provider_object(config, logger, metrics, redis_connection_pool, provider_class, provider_name, options)\n provider_klass = Vmpooler::PoolManager::Provider\n provider_klass.constants.each do |classname|\n next unless classname.to_s.casecmp(provider_class) == 0\n\n return provider_klass.const_get(classname).new(config, logger, metrics, redis_connection_pool, provider_name, options)\n end\n raise(\"Provider '#{provider_class}' is unknown for pool with provider name '#{provider_name}'\") if provider_klass.nil?\n end", "def provider_cli\n @provider_cli ||= begin\n return nil unless name = settings.exists?(\"provider.name\")\n require \"cyoi/cli/providers/provider_cli_#{settings.provider.name}\"\n klass = self.class.provider_cli(settings.provider.name)\n klass.new(settings.provider, hl)\n end\n end", "def locate(service_name)\n klass = @services[service_name]\n raise \"Unknown service: #{service_name}\" unless klass\n klass.new\n end", "def provider\n @provider ||= find_constant( remoter_base, ::PoolParty::Remote )\n end", "def get_service_provider_icon(agency_id, mode)\n # search name first, then search external_id\n # this is because leg.agency_id is pre-processed in itinerary_parser\n # in which agency_id was not original agency_id from GTFS\n # but instead it's identified service name...\n s = Service.where(name: agency_id).first ||\n Service.where(external_id: agency_id).first\n\n if s\n if s.logo_url\n return get_service_provider_icon_url(s.logo_url)\n elsif s.provider and s.provider.logo_url\n return get_service_provider_icon_url(s.provider.logo_url)\n end\n end\n\n return get_mode_icon(mode)\n end", "def provider_name\n object.provider_id.titleize\n end", "def maybe_explicit_provider(resource)\n return nil unless resource.provider\n resource.provider\n end", "def provider\n system.provider\n end", "def provider_name\n return @provider_name\n end", "def initialize_provider(provider=nil)\n prv = cleanup_provider(Souffle::Config[:provider])\n Souffle::Provider.const_get(prv).new\n rescue Souffle::Exceptions::InvalidAwsKeys => e\n Souffle::Log.error \"#{e.message}:\\n#{e.backtrace.join(\"\\n\")}\"\n rescue Exception\n raise Souffle::Exceptions::InvalidProvider,\n \"The provider Souffle::Provider::#{prv} does not exist.\"\n end", "def cloud_provider\n (cloud.nil? ? nil : cloud.cloud_provider)\n end", "def set_service_prov_type\n @service_prov_type = ServiceProvType.find(params[:id])\n end", "def provider_class\n self.class\n end", "def provider_class\n self.class\n end", "def method_missing(m, *args, &block)\n return @services[m.to_sym] if @services.include? m.to_sym\n raise NoMethodError.new(\"undefined method `#{m}' for #{self}\")\n end", "def name\n @provider_name\n end", "def service\n @service ||= fetcher.get(Service, service_id)\n end", "def mappings_provider(provider_name, is_legacy = false)\n return nil if provider_name.nil?\n provider = nil\n module_name = is_legacy ? 'Highlander': 'Cfhighlander'\n begin\n providers = Object.const_get(module_name).const_get('MapProviders')\n providers.const_get(provider_name)\n rescue NameError => e\n if e.to_s.include? \"uninitialized constant\"\n return mappings_provider(provider_name, true) unless is_legacy\n return nil\n end\n STDERR.puts(e.to_s)\n raise e\n end\nend", "def scm_provider_klass\n @scm_provider_klass ||= eval(danger.scm_provider.to_s)\n end", "def provider_id\n return @provider_id\n end", "def set_providers_payment_type\n @providers_payment_type = Providers::PaymentType.find(params[:id])\n end", "def retrieve\n provider.send(self.class.name)\n end", "def provider_class\n @__klass ||= Yeller::Provider.class_of(provider)\n end", "def create_simple_provider_source\n create_source(PROVIDER_TEMPLATE, provider_path)\n end", "def service_klass(constant_string)\n if const_defined?([to_s, constant_string].join(\"::\"))\n [to_s, constant_string].join(\"::\")\n else\n provider = to_s.split(\"::\").last\n Fog::Logger.deprecation(\"Unable to load #{[to_s, constant_string].join('::')}\")\n Fog::Logger.deprecation(\n format(\n Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,\n service: constant_string,\n provider: provider\n )\n )\n [\"Fog\", constant_string, provider].join(\"::\")\n end\n end", "def customize_provider(name,options)\n ''\n end", "def [](key)\n if key == \"provider\"\n return @provider\n end\n @hash[key]\n end", "def set_v1_provider_operation\n @v1_provider_operation = V1::ProviderOperation.find(params[:id])\n end", "def set_oauth_service\n @oauth_service = @application.oauth_services.find(params[:id])\n end", "def lookup_service_host\n # Allow manual overrides\n return config[:lookup_service_host] unless config[:lookup_service_host].nil?\n\n # Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service.\n vim = RbVmomi::VIM.connect @connection_options\n vim_settings = vim.serviceContent.setting.setting\n sso_url = vim_settings.select { |o| o.key == \"config.vpxd.sso.sts.uri\" }&.first&.value\n\n # Configuration fallback, if no SSO URL found for some reason\n ls_host = sso_url.nil? ? config[:vcenter_host] : URI.parse(sso_url).host\n debug(\"Using Lookup Service at: \" + ls_host)\n\n ls_host\n end", "def crypto_provider\n acts_as_authentic_config[:crypto_provider].tap { |provider|\n raise NilCryptoProvider if provider.nil?\n }\n end", "def choose_provider\n settings.provider[\"name\"] = hl.choose do |menu|\n menu.prompt = \"Choose your infrastructure: \"\n menu.choice(\"AWS\") { \"aws\" }\n menu.choice(\"OpenStack\") { \"openstack\" }\n menu.choice(\"vSphere\") { \"vsphere\" }\n end\n save_settings!\n end", "def providers\n @providers ||= {}\n end", "def set_register_financeiro_provider\n @register_financeiro_provider = Register::Financeiro::Provider.find(params[:id])\n end", "def initialize name, providers = {}, default = nil\n @name = name\n @configured_providers = providers\n @configured_default = default || providers.values.first\n\n reset\n end" ]
[ "0.7120375", "0.7120375", "0.7066134", "0.6926658", "0.6756454", "0.664944", "0.64757156", "0.6442512", "0.6427198", "0.6407234", "0.639914", "0.62184274", "0.62003773", "0.6198943", "0.61861867", "0.6149234", "0.6080506", "0.60593235", "0.6016637", "0.60074884", "0.59833676", "0.59832674", "0.5954518", "0.5949568", "0.593706", "0.5936615", "0.59348685", "0.5923416", "0.5920728", "0.5905677", "0.5834089", "0.58259887", "0.58209944", "0.579812", "0.5794112", "0.5791235", "0.57872474", "0.5783343", "0.5766522", "0.57491755", "0.57486236", "0.57476646", "0.5734316", "0.5717181", "0.5717181", "0.5717181", "0.5717181", "0.5717181", "0.5717181", "0.5717181", "0.57074004", "0.5686848", "0.5682211", "0.56571436", "0.56534916", "0.56529826", "0.5652214", "0.5640041", "0.5629722", "0.5629433", "0.5625918", "0.5624644", "0.5615882", "0.5593182", "0.55817866", "0.5573971", "0.557024", "0.55618536", "0.55473006", "0.55461717", "0.553765", "0.55321896", "0.5527443", "0.55126995", "0.5504861", "0.54933983", "0.5486602", "0.54677904", "0.54677904", "0.5462847", "0.545517", "0.54446584", "0.5411803", "0.54042226", "0.5389835", "0.53710926", "0.53512144", "0.53358513", "0.5327798", "0.5327645", "0.53201914", "0.5312704", "0.5311339", "0.5297916", "0.529384", "0.5291276", "0.52897525", "0.5283889", "0.5282194", "0.5280621" ]
0.8196303
0
=== Validations === Instance Methods
def to_s login end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validation; end", "def validation; end", "def validate; end", "def validate; end", "def validate; end", "def validate; end", "def validator; end", "def validate\n fail 'sub class to implement'\n end", "def validate\n end", "def is_valid; end", "def validate!; end", "def validate!; end", "def validate!; end", "def validate\n \n \n end", "def validate\n end", "def validate\n end", "def validate\n end", "def valid; end", "def validate\r\n\r\n end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def validate!\n # pass\n end", "def validate\n # add errors if not validate\n end", "def validate\n\n end", "def validate\n raise NoMethodError, \"must define method 'validate'\"\n end", "def validate\n valid?\n end", "def validate\n validator_class.new(self).validate\n end", "def validate\n errors.clear\n self.class.validator.invoke self\n end", "def validate\n end", "def validate\n end", "def validate\n end", "def validate!\n super()\n self\n end", "def validated?; end", "def is_valid?\n end", "def validate\r\n @invalid=false\r\n end", "def valid?\n raise \"You must override `valid?' in your class\"\n end", "def validate\n super \n end", "def validations\n {}\n end", "def valid?(_) true end", "def valid?(_) true end", "def subclass_validations ; true ; end", "def validate\r\n validate! rescue false\r\n end", "def is_valid\n\tend", "def is_valid\n\tend", "def validate(options); end", "def validate\n @invalid=false\n end", "def validated; end", "def valid?\n end", "def valid?\n end", "def valid?\n end", "def valid?\n end", "def validate!\n validate_redis\n validate_workers\n validate_options\n end", "def validate!\n true\n end", "def validate\n super\n end", "def validate\n validations = self.class.meta_eval { @validations }\n\n validations.each do |v|\n raise \"#{self.class}.#{v[:name]} #{v[:options][:message]}\" unless\n v[:proc].call(send(v[:name]))\n end\n\n self\n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def initialize *args\n super\n \n raise ArgumentError, errors.full_messages.join(\"\\n\") unless self.valid?\n self\n end", "def validate\n validate_root\n validate_associated\n valid?\n end", "def check_validity!\n # nothing\n end", "def validate\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def is_valid\n return true\n end", "def run_validations\n true\n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def valid?\n true\n end", "def validate!\n self.class.validators.each do |validator|\n validator.validate!(self)\n end\n nil\n end", "def valid?\n true && super\n end", "def validate!\n\t\t\t\treturn true\n\t\t\tend", "def validate\n validate_params\n validate_colour\n validate_coordinates\n validate_dimension\n end", "def initialize(params = {})\n super\n self.is_valid = true\n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def validate( _x )\n #TODO: cover common type-based validations?\n #TODO: Offer validation objects?\n raise InternalError.new( \"#{self.class}.validate() not implemented!\" )\n end", "def validate\n raise ValidationError, \"ID is required\" if id.nil?\n raise ValidationError, \"Version is required\" if version.nil?\n raise ValidationError, \"Issue instant is required\" if issue_instant.nil?\n raise ValidationError, \"Issue instant must be UTC\" unless issue_instant.utc?\n end", "def valid\n @valid\n end", "def validate\n errors.clear\n instance_exec(&validate_block) if validate_block && get\n end", "def validate!\n raise ActiveRecord::RecordInvalid.new(self) unless valid?\n end", "def validate\n validate_params\n validate_coordinates\n validate_colour\n validate_dimension\n end", "def valid?\n validate\n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def validations\n []\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end" ]
[ "0.8152792", "0.8152792", "0.81295663", "0.81295663", "0.81295663", "0.81295663", "0.8064927", "0.8014242", "0.7988546", "0.7982067", "0.79448813", "0.79448813", "0.79448813", "0.7857196", "0.78026223", "0.78026223", "0.78026223", "0.7795886", "0.7775166", "0.77417326", "0.77417326", "0.77417326", "0.77417326", "0.77417326", "0.7715051", "0.7674814", "0.76711255", "0.76680833", "0.7644113", "0.7635585", "0.76101106", "0.76021725", "0.76021725", "0.76021725", "0.75414747", "0.75364304", "0.75346434", "0.75198567", "0.74994403", "0.7493246", "0.7491887", "0.74883497", "0.74883497", "0.74630934", "0.7457386", "0.7452927", "0.7452927", "0.74478394", "0.7422041", "0.7413448", "0.73707414", "0.73707414", "0.73707414", "0.73707414", "0.73210007", "0.7316828", "0.731019", "0.7291243", "0.7276923", "0.7273334", "0.7218654", "0.72091895", "0.71909666", "0.71832097", "0.71832097", "0.7180643", "0.71792644", "0.7175096", "0.71419334", "0.71305114", "0.7125949", "0.7109698", "0.71062076", "0.7100549", "0.709577", "0.70804954", "0.7072673", "0.70700336", "0.7067201", "0.7062575", "0.7053589", "0.70442533", "0.7039078", "0.70318556", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327", "0.70180327" ]
0.0
-1
Creates and initializes a new instance of the Rollouts class.
def initialize(client) @client = client end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize()\n @rolls = []\n end", "def initialize \n\t\t @rolls = []\n\t end", "def initialize\n @lister = Lister.new\n end", "def initialize\n \n end", "def initialize\n\t\t\t@numbershowing\n\t\t\t@@rolls = 0\n\t\tend", "def initialize\n configure_trello\n end", "def initialize()\n end", "def initialize(templates, twitter_config)\n @templates = templates\n @twitter_config = twitter_config\n end", "def initialize\n @rolls = []\n @frames = []\n end", "def new \n @intervention = Intervention.new\n logger.info(\"INTERVENTIONS CONTROLLER \") \n end", "def initialize\n end", "def initialize(poller = CZTop::Poller.new)\n @readables = []\n @writables = []\n @poller = poller\n end", "def initialize\n super\n Souffle::Config.merge!(config)\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize(journey_class = nil)\n @journey_class = journey_class\n @journeys = []\n end", "def initialize\n initialize!\n end", "def initialize\n initialize!\n end", "def initialize\n @router = Router.new(ROUTES)\n end", "def initialize(*)\n @l = SingLogger.instance\n end", "def initialize\n \n end", "def initialize\n \n end", "def initialize(therms, location)\n @github = Github::Service.new(therms, location)\n @stackoverflow = Stackoverflow::Service.new(therms, location)\n @acuk = AcUk::Service.new('')\n end", "def initialize\r\n\r\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize(path_parameters, request_adapter)\n super(path_parameters, request_adapter, \"{+baseurl}/policies/featureRolloutPolicies/{featureRolloutPolicy%2Did}/appliesTo/{directoryObject%2Did}\")\n end", "def initialize(namespace)\n self.namespace = namespace\n end", "def trainings\n Namespace::Trainings.new(credentials: credentials)\n end", "def initialize(source)\n super('Routage')\n set_color(YELLOW)\n @source = source\n build_top\n @layout.add_widget(HLine.new)\n build_bottom\n @layout.insertSpacing(8, 15)\n @layout.addStretch\n enable_choices(false)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize(config)\n super(config, SERVICE_INFO)\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n init\n end", "def initialize(config)\n\t\tend", "def initialize(config)\n end", "def initialize(config)\n end", "def initialize()\r\n\r\n end", "def initialize(klass, resource_path)\n url = \"#{ApiClient.config.path}#{resource_path}\"\n @collection = ApiClient::Parser.response(ApiClient::Dispatcher.get(url), url)\n @collection.map! do |attributes|\n klass.new(attributes)\n end\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize(*args)\n super\n self[:notify] = [\n \"Service[splunk]\",\n \"Service[splunkd]\",\n ].select { |ref| catalog.resource(ref) } unless catalog.nil?\n\n end", "def initialize(*args)\n super\n self[:notify] = [\n \"Service[splunk]\",\n \"Service[splunkd]\",\n ].select { |ref| catalog.resource(ref) }\n end", "def initialize() end", "def initialize(config = {})\n super\n original_initialize(config)\n end", "def initialize(source, dest)\n self.source = source\n self.dest = dest\n self.layouts = {}\n self.posts = []\n self.collated = {}\n end", "def initialize\n @rolls = []\n @total_score = 0\n @current_roll = 0\n end", "def initialize path\n # make menu instance accessible by the class\n @@menu = self\n @rolls = {}\n @sources = []\n\n # load a yaml file\n load_from_file path\n\n # create objects from the menu\n set_sources\n set_roll_models\n set_rolls\n end", "def initialize(sandbox, pod_targets, aggregate_targets)\n @sandbox = sandbox\n @pod_targets = pod_targets\n @aggregate_targets = aggregate_targets\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end", "def initialize()\n end" ]
[ "0.60734344", "0.57835203", "0.54926264", "0.5415586", "0.5393725", "0.5369428", "0.53643847", "0.5338317", "0.531938", "0.5290521", "0.52732533", "0.52668226", "0.5263349", "0.5256004", "0.5256004", "0.5256004", "0.5256004", "0.5256004", "0.5256004", "0.5256004", "0.5254884", "0.5251198", "0.5251198", "0.5248718", "0.52387816", "0.521421", "0.521421", "0.52126986", "0.52094096", "0.5196273", "0.5196273", "0.5196273", "0.5196273", "0.5196273", "0.5196273", "0.51730627", "0.51695794", "0.5165538", "0.51630956", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.5158287", "0.51513064", "0.51513064", "0.51513064", "0.51513064", "0.51513064", "0.51513064", "0.51513064", "0.51513064", "0.51513064", "0.51492345", "0.51434624", "0.5140078", "0.5140078", "0.5139158", "0.51299715", "0.5129715", "0.5129715", "0.5129715", "0.51186293", "0.5117768", "0.5109797", "0.5108223", "0.5092411", "0.5091332", "0.5087759", "0.5078897", "0.5076194", "0.5076194", "0.5076194", "0.5076194", "0.5076194", "0.5076194", "0.5076194" ]
0.0
-1
Aaaand here's where I quit writing readable code. Good luck. Here be dragonnes. Abandon all hope, ye who enter here. Don't say I didn't warn you.
def index_of_coincidence(matrix) matrix.inject([]) do |indices, row_letters| frequencies = letter_frequencies(row_letters) indices << ("A".."Z").inject(0) { |a,v| x = frequencies[v] a += x*(x-1) a } / (row_letters.size * (row_letters.size - 1)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sharp; accidental; end", "def anchored; end", "def code_like_crazy\r\n puts \"I'm crushing some code!\"\r\n end", "def as_you_like_it_quote; end", "def silly_adjective; end", "def jack_handey; end", "def beautify; end", "def beautify; end", "def autofinish; end", "def big_bad; end", "def buzzword; end", "def buzzword; end", "def charm_failure\n slowly do\n\"\"\"\nDuncan barks, wags his tail, rolls over, does all his awesome tricks...\n\nBut the troll just looks on in disdain. \n\n'Go home, little dog, before I sqquish you.' \n\"\"\"\n end\n what_next\n end", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def faint; end", "def faint; end", "def herald; end", "def weird_stuff\n puts \"Mussolini apparently liked to eat raw garlic, although he suffered\n from severe stomach ulcers. He also had many Jewish friends, and didn't like\n Hitler very much. Yeah right!\"\n #sleep(20)\n puts \"Idi Amin gave himself the title His Excellency, President for Life Field\n Marshall Al Hadj Doctor Idi Amin Dada, VC, DSO, MC, Lord of all the Beasts\n of the Earth and Fishes of the Sea and Conqueror of the British Empire in\n Africa in General and Uganda in particular.\"\n #sleep(20)\n puts \"Adolf Hitler thought of himself as a pacifist. He was a vegetarian.\n It is said that he injured his groin during World War I, and his left\n testicle was removed. Hitler enjoyed watching Charley Chaplin, who made fun\n of Hitler.\"\n #sleep(20)\n puts \"Stalin was also the man behind the most wicked practical joke ever\n played. Being a very private man he gave the order that no person should\n enter his bed chambers on pain of death. Later, while in his chambers he\n decided to test whether his guards had listened to this instruction.\n Pretending to scream in pain, he called for the guards stationed outside\n the door. Fearing that their leader was in trouble the guards burst into\n the room. Stalin had them executed for failing to follow his standing orders.\n This little prank soon backfired, however, when Stalin suffered a seizure\n while alone in his bedroom. The guards were too afraid to enter, finding\n him hours later laid in a puddle of stale urine. He died three days later.\"\n #sleep(30)\n puts \"Niyazov loved to rename things. For example, he renamed the month of\n January Turkmenbashi, which means Father of the Turkmen, a name he gave\n himself. He also 'legislated' the renaming of the days of the week to ones\n that translate to 'Young Day', 'Spirituality Day', etc. He even renamed the\n word 'bread', Gurbansoltan, after his own mother. Niyazov outlawed beards on\n men and cosmetics on TV anchors, and prohibited both chewing tobacco and lip-\n syncing on Turkmenistan soil. In a society of smokers, Niyazov recommended\n that people chew on bones, which he argued would strengthen their teeth. He\n authored a book, the Book of the Soul, and ordered students in schools and\n mosques to read and study it, and in the case of mosques, to give it equal\n respect to the Quran (and if not, the mosque would be demolished). To get a\n driver's license, people had to memorize the contents of the book. Finally,\n Niyazov told everyone that he had made a pact with G-d that anyone who read\n his book three times would go to heaven. In 2005, he ordered a copy of his\n book to be sent to outer space.\"\n #sleep(60)\n puts \"Mussolini apparently liked to eat raw garlic, although he suffered\n from severe stomach ulcers. He also had many Jewish friends, and didn't like\n Hitler very much. Yeah right!\"\n #sleep(10)\n puts \"He gave himself the title His Excellency, President for Life Field\n Marshall Al Hadj Doctor Idi Amin Dada, VC, DSO, MC, Lord of all the Beasts\n of the Earth and Fishes of the Sea and Conqueror of the British Empire in\n Africa in General and Uganda in particular.\"\n end", "def probers; end", "def ignores; end", "def throw_away_meaningless_line\n puts \"I have no idea what you are talking about\"\n end", "def code_point=(_); end", "def throw_away_meaningless_line\n\t\tputs \"I have no idea what you are talking about\"\n\tend", "def replace_this_with_appropriate_code(x) end", "def code_point; end", "def lines_of_code; end", "def lines_of_code; end", "def king_richard_iii; end", "def who_we_are\r\n end", "def simple_blind_ror\n \n end", "def leading; end", "def do_something this, that, other\n puts \"We, I mean I, am doing, er, something!\"\nend", "def slop!; end", "def slop!; end", "def ibu; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def suivre; end", "def romeo_and_juliet_quote; end", "def beauty_hidden(honest_beauty, trust_beauty)\n puts honest_beauty\n puts trust_beauty\nend", "def hey_hey; end", "def does\n puts \"ALL THE THINGESSSS!!!eleventy\"\nend", "def strain; end", "def bad_smell_by_nfunctions\n end", "def most_interesting_man_in_the_world; end", "def ignore; end", "def terpene; end", "def p15\n\t\nend", "def pass; end", "def pass; end", "def normalize(code); end", "def keep_it_in\n raise \"rawr\"\nrescue\n # ahem\nend", "def schubert; end", "def boring_parrot(statement)\n statement\nend", "def boring_parrot(thing)\n \"#{thing} is so boring!\"\nend", "def leading=(_); end", "def hiss; end", "def irrelevant_line(source_line); end", "def never_lines; end", "def never_lines; end", "def throw_fierce_lqqks\n 'Here I am, giving you Soviet-Satellite realness'\n end", "def woo; puts \"woooooo\"; end", "def bang!\n \"b a n g\"\n end", "def mercedes\n woo(\"It turns out to be a self-driving car and drops you off at home.\")\nend", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def introduce_myself \n # Best practice 2 spaces within method body \n puts \"I am handsome\"\n end", "def romeo_and_juliet; end", "def bellini; end", "def my955; end", "def _here_\n 'here'\nend", "def introduce_myself\n #method body\n puts \"'I am handsome'\"\n puts \"i am talented\"\n puts \"i am briliant\"\n puts \"i am amazing\"\n puts 'is talented'\n puts \"is charming\"\n\n #method body\n end", "def hermes_catchphrase; end", "def spice; end", "def gounod; end", "def some_method\n # incorrect\n begin\n n / d\n rescue ZeroDivisionError\n puts 'Cannot divide by 0!'\n end\n\n # Do not rescue class Exception. Must rescue a specific class\n\n # incorrect\n begin\n # Exception caught\n rescue\n # Process exception\n end\n\n # incorrect\n begin\n # Exception caught\n rescue Exception\n # Process exception\n end\n\n # Use %w( ) to create array of strings\n\n # incorrect\n # STATES = ['draft', 'open', 'closed']\n\n # When write key of hash, use symbol instead of characters if possible\n\n # incorrect\n hash = {'one' => 1, 'two' => 2, 'three' => 3}\n\n # Strings\n\n # When combine variables into a string, follow below rules\n\n # incorrect\n email_with_name = user.name + ' <' + user.email + '>'\n\n # * When need to add more into string, do not use ``` String#+ ``` method, use ``` String#<< ``` method\n\n # correct\n html = ''\n html + '<h1>Page title</h1>'\n\n paragraphs.each do |paragraph|\n html + \"<p>#{paragraph}</p>\"\n end\n\n /(regexp)/ =~ string\n process $1\n\n string = \"some injection\\nusername\"\n string[/^username$/] # matches\n string[/\\Ausername\\Z/] # don't match\n\n #Use x when writing a complex regular expression. However, all empty characters will be ignored.\n\n regexp = %r{\n start # some text\n \\s # white space char\n (group) # first group\n (?:alt1|alt2) # some alternation\n end\n }\n\n # % syntax\n\n # Use %() when need to display \n\n message = %(please differenate between ' and \" )\n\n # Use %r() when need to write / in regular expression\n\n %r(\\s+)\n\n %r(^/(.*)$)\n\n # Comparison\n\n # When need to compare between a variable and a value like a number or a constant, write variable on the right side\n\n greeting = 'Hello!'\n\n # bad\n if greeting == 'Hola!'\n end\n end", "def king_richard_iii_quote; end", "def fix_common_typos!\n # well, I don't know what kind of typos people do!\n @pattern.squish!\n end", "def skipped!; end", "def wookiee_sentence; end", "def too_complex; end", "def statement; end", "def source_line=(_); end", "def problem_14\nend", "def marvin_quote; end", "def plain; end", "def caveats; nil end", "def caveats; nil end", "def single_line?; end", "def stylish_chef\n best_hairstyle = \"Guy Fieri\"\n return \"Martha Stewart\"\n \"Guy Fieri\"\nend", "def err_for_todo(name)\n# def err_for_todo(todos, name) # alt syntax\n # if todos.any? { |todo| todo[:name] == name }\n # 'The todo must be unique'\n # elsif !(1..50).cover?(name.size)\n # 'The todo must have between 1 and 50 characters'\n # end\n unless (1..50).cover?(name.size)\n 'The todo must have between 1 and 50 characters'\n end\nend", "def process_code_listing(lines)\n # extract caption\n caption = nil\n # no caption for listings in appendix\n if !lines.first.index(\",\").nil?\n raise \"error [#{lines.first.index(\",\")}] [#{lines.first}]\" if lines.first.split(\",\").size != 2\n raise \"error\" if lines.first.split(\",\").first.split(\"=\").size != 2\n caption = lines.first.split(\",\").first.split(\"=\")[1] \n end\n # remove start and end\n lines = lines[1..-1]\n # pretty print \n return final_pretty_code_listing(lines, caption)\nend", "def heroine; end", "def how_it_works\r\n end", "def bug\n end" ]
[ "0.64761376", "0.6459945", "0.6401181", "0.63383317", "0.6323038", "0.629742", "0.6257737", "0.6257737", "0.6247281", "0.623469", "0.6233748", "0.6233748", "0.61176527", "0.6105489", "0.6105489", "0.6105489", "0.60356885", "0.60356885", "0.60326856", "0.60019815", "0.5983476", "0.59571135", "0.59537643", "0.59527", "0.5920217", "0.5913082", "0.59108806", "0.5890911", "0.5890911", "0.5860371", "0.5827779", "0.5813095", "0.58063674", "0.579943", "0.5784669", "0.5784669", "0.5781894", "0.57790554", "0.57790554", "0.57790554", "0.57790554", "0.57790554", "0.57790554", "0.57790554", "0.57764137", "0.5767246", "0.5766885", "0.5711866", "0.56939286", "0.56883615", "0.5687212", "0.5666345", "0.56544507", "0.5653031", "0.5624909", "0.56203514", "0.56203514", "0.5595031", "0.55945194", "0.5594361", "0.5586226", "0.5567678", "0.5566542", "0.55633277", "0.5561079", "0.5556131", "0.5556131", "0.55560535", "0.5551365", "0.5548056", "0.554736", "0.5542376", "0.55319417", "0.5525075", "0.55203384", "0.55136317", "0.55134314", "0.55077666", "0.55022174", "0.5498197", "0.54974294", "0.5483967", "0.5467431", "0.54609466", "0.5459974", "0.54530126", "0.54476666", "0.54466844", "0.5441193", "0.5434521", "0.54329216", "0.542676", "0.5422501", "0.5422501", "0.54212403", "0.54196113", "0.5419591", "0.54178804", "0.5417352", "0.5414322", "0.5413888" ]
0.0
-1
this logic would probably have made more sense in a `CommentsController`, since it would simplify the `PostsController` and keep it more focused.
def add_new_comment # Get the object that you want to comment commentable = Post.find(params[:id]) # Create a comment with the user submitted content comment = Comment.new(comment_params) # Add the comment commentable.comments << comment @comments = commentable.comments respond_to do |format| format.html { redirect_to root_path } format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n\n redirect_to controller: 'pages', action: 'dashboard', post_id: @post.id and return\n\n if params[:comment_order] == 'newest'\n @comments = @post.comments.order(created_at: :desc)\n elsif params[:comment_order] == 'upvote'\n @comments = @post.comments.sort_by{|x| count_opinion(x.opinions)}\n elsif params[:comment_order] == 'happiness'\n # SHOULD store sentiment as a field upon save\n # @comments = @post.comments.sort_by{|x| JSON.parse(Sentimentalizer.analyze(x.content).to_json). }\n elsif params[:comment_order] == 'distress'\n else\n @comments = @post.comments\n end\n end", "def for_post\n @post = Post.find(params[:post_id])\n @comments = @post.comments\n @comment = @post.comments.new(user_id: current_user.id)\n end", "def show\n @post = Post.find(params[:id])\n @commentable = @post\n @comments = @commentable.comments\n @comment = Comment.new\n \n end", "def show\n @post = Post.find(params[:id])\n @commentable = @post\n @comments = @commentable.comments\n @comment = Comment.new\n \n end", "def index\n # @post = Post.find(params[:post_id])\n @comments = @post.comments\n end", "def comments\n \n post = Post.find(params[:post_id]) \n comment = Comment.new(comment_params)\n comment.post = post\n comment.user = current_user \n comment.save\n\n redirect_to post_read_path(post)\n end", "def show\n# 아직 이럴 필요까진 없는 듯...\n# @comments = if params[:comment]\n# @post.comments.where(id: params[:comment])\n# else\n# @post.comments.where(parent_id: nil)\n# end\n# @comments = @comments.page(params[:page].per(5)\n end", "def show\n @post = Post.find(params[:id])\n @post_comments = @post.comments.order('created_at DESC')\n if user_signed_in? \n @comment = @post.comments.new(user_id: current_user.id)\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def index\n # `includes` tells Rails what associations we're going to be using in\n # our view. This is important, since normally when you call `.comments`\n # on a post, Rails will make a call to the database. If you have a large\n # number of posts, this can cause a huge number of DB requests.\n if params[:user_id]\n @posts = Post.where(user_id: params[:user_id])\n else\n @posts = Post\n end\n @posts = @posts.includes(:comments)\n end", "def comments\n @user = User.find(params[:user_id])\n\n if params[:type].eql?(\"short_term_objective\")\n @short_term_objective = ShortTermObjective.find(params[:data])\n @number_of_comments = @short_term_objective.comments.count\n if params[:more_type] == \"true\"\n @comments = @short_term_objective.comments.order(\"id\")\n else\n @comments = @short_term_objective.comments.limit(5).order(\"id\")\n end\n elsif params[:type].eql?(\"evidence\")\n @evidence = Evidence.find(params[:data])\n @number_of_comments = @evidence.comments.count\n if params[:more_type] == \"true\"\n @comments = @evidence.comments.order(\"id\")\n else\n @comments = @evidence.comments.limit(5).order(\"id\") \n end \n end\n render :layout => false\n end", "def show\n @comment = Comment.new\n @comments = if params[:comment]\n @post.comments.where(id: params[:comment])\n else\n @post.comments.where(parent_id: nil)\n end\n\n @comments = @comments.order('created_at asc').paginate(page: params[:page], per_page: 2)\n\n end", "def show\n @articleFirst = @article.comments.desc.first\n #@comments = @article.comments.order(\"created_at DESC\")\n if signed_in? and current_user.admin?\n @comments = @article.comments.order(\"created_at DESC\").paginate(page:\n params[:page], per_page: 1)\n else\n @comments = @article.comments.approved_comments.paginate(page:\n params[:page], per_page: 1)\n end\n @comment = @article.comments.build\n @valid_comments = 0\n end", "def show\n if current_user.admin?\n @comments = Comment.where(post_id: params[:id]).paginate(:page => params[:page], :per_page => 3)\n else\n @comments = Comment.where(post_id: params[:id]).where(is_active: 1).paginate(:page => params[:page], :per_page => 3)\n end\n end", "def index\n @comments = Comment.all\n @post = Post.find(params[:post_id])\n end", "def create \n @post = Post.find_by(slug: params[:post_id])\n @comment = Comment.new(params.require(:comment).permit(:body))\n @comment.post = @post #associate comment with the particular post\n @comment.creator = current_user #returns user object of logged in user\n \n if @comment.save\n flash[:notice] = \"Your comment was added\"\n redirect_to post_path(@post) #redirect must be a url\n else\n #comment was submitted from 'posts/show', so this is where\n #you go back to display errors. This template needs \n #@post and @comment to be set up in order to work.\n render 'posts/show' # render must be a template file\n end\n end", "def show\n \t@post = Post.find(params[:post_id])\n \t@comment = @post.comments.find(params[:id])\n end", "def show\n # pre-sorting the comments means that when we tree them, they'll be encountered in the sorted order.\n comments = @post.comments.sort { |x,y| x.c_at <=> y.c_at }\n @comment_list = PostsHelper.tree_comments comments\n @posts = Post.where category: @post[:category]\n @category = @post[:category]\n end", "def show\n @comments = Comment.where(post_id: params[:id])\n @post = Post.find_by(id: params[:id])\n end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments\n @comment = Comment.new\n end", "def show\n require \"digest\"\n @post = Post.find(params[:id])\n if(@post.visible != true && (!session[:author] || session[:author].id != @post.author_id))\n flash[:error] = \"El post solicitado es invisible\"\n redirect_to \"/posts\"\n end\n @comments = @post.comments.paginate(:page => params[:page])\n @comment = Comment.new\n end", "def show\n @post = Post.where(:id => params[:id]).first\n @comment = @post.comments.new\n @comments = @post.comments.created_at_order\n end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments\n @comment = Comment.new if signed_in?\n end", "def show\n @post = Post.find(params[:id])\n @topic = Topic.find(params[:topic_id])\n @comment = Comment.new\n @comments = @post.comments\n authorize @post\n end", "def show\n @post = Post.find(params[:id])\n @comments = Post.where(:originatingPost_id => params[:id])\n end", "def show\n @comment = Comment.new\n @comments = @post.comments\n end", "def show\n @comments = @post.comments\n @comment = Comment.new\n end", "def show\n @user = User.find(params[:id])\n @posts = Post.where(user: @user)\n @post = current_user.posts.new if @user == current_user\n @comment = Comment.new\n end", "def show\n @post = Post.find(params[:id])\n @comments = Comment.where(:post_id => params[:id])\n end", "def show\n @post = Post.find_by_id(params[:id]) || Post.find_by_url(params[:id])\n if logged_in?\n @comments = @post.comments.all(:order => \"created_at DESC\")\n else\n @comments = @post.comments.approved(:order => \"created_at DESC\")\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end", "def show\n\t\t@category = Category.friendly.find(params[:id])\t\n\t\t@posts = (@category.posts + @category.groups + @category.meeting_rooms + @category.contests + @category.forum_polls + @category.communities).compact.flatten.sort_by{|p| p.updated_at}.reverse\n\t\t@comment = Comment.new\n\tend", "def show\n @post = Post.find_by_short_id!(params[:id])\n\n @short_url = @post.short_id_url\n\n @comments = Comment.ordered_for_post_or_thread_for_user(@post.id, nil,\n current_user)\n\n respond_to do |format|\n format.html {\n @comment = Comment.new\n\n render :action => \"show\"\n }\n format.json {\n render :json => @post.as_json(:with_comments => @comments)\n }\n end\n\n end", "def index\n @comment = Comment.new\n @latest_comment = if @post.present?\n #FIXME: do not use sql in controllers\n @post.comments.order('comments.created_at DESC').first\n end\n respond_to do |format|\n format.js\n format.html { redirect_to view_context.post_review_path_helper(@post) }\n end\n end", "def show\n# @discussion.replies.paginate(page: params[:page], per_page: 10)\n \n @discussions = @forum.discussions.paginate(page: params[:page], per_page: 10)\n @discussion = Discussion.new\n end", "def show\n\n @post = Post.find(params[:id])\n @responses = @post.post_replies.live.limit(10)\n @title = @post.display_title\n @comment = Comment.new\n @comments = @post.comments.created_recent.paginate(:page => params[:page], :per_page => 5)\n if @comments.count > 15\n @top_comments = @post.comments.top(2)\n else\n @top_comments = []\n end\n\n if @post.text? && @post.draft?\n redirect_to edit_post_path(@post)\n return\n end\n\n if current_user\n @post.add_postview_for_user(@current_user.id)\n else\n @post.add_postview_for_user(0)\n end\n\n\n @body_class = 'off-canvas'\n\n respond_to do |format|\n format.html # show.html.erb\n format.js\n end\n end", "def index\n @comment = current_user.comments.new\n if params[:idea_id] != 0\n @idea = Idea.find(params[:idea_id])\n @comments = @idea.comments\n elsif params[:project_id] != 0\n @project = Project.find(params[:project_id])\n @comments = @project.comments\n end\n @comments = @comments.limit(10)\n end", "def index\n @comments = @post.comments.all\n \n end", "def index\n @post = Post.find params[:post_id]\n @comments = @post.comments.all\n end", "def show\n # @comment = Post.find(params[:id]).comments.build\n end", "def comments\n posts.all :conditions => { :object_type => :comment }\n end", "def show\n @post = Post.includes(:user).find_by(id: params[:id])\n @comments = @post.comments.includes(:user).all\n @comment = @post.comments.build(user_id: current_user.id) if current_user\n end", "def index\n\t\tredirect_to pretty_post_url(@post) + '#comments'\n end", "def show\n authorize! :read_drafts, @post unless @post.published\n if can? :read, Comment, @post\n @commentable = @post\n @comments = @commentable.comments.recent.page(params[:page]).per(15)\n @comment = Comment.new\n end\n end", "def index\n if params[:blog_id]\n @blog = Blog.find(params[:blog_id])\n if params[:user_id]\n @user = User.find(params[:user_id])\n @comments = @blog.comments.by_user(@user)\n elsif params[:post_id]\n @post = @blog.posts.find(params[:post_id])\n @comments = @post.comments\n elsif @blog\n @comments = @blog.comments\n end\n elsif params[:user_id]\n @user = User.find(params[:user_id])\n @comments = @user.comments\n end\n\n respond_to do |format|\n format.html {\n @comments = @comments.paginate(:page => params[:page], :per_page => 10,\n :include => { :post => :blog })\n }\n format.xml { render :xml => @comments.recent }\n end\n end", "def create\n @user = User.find_by_slug(params[:user_id])\n @post = @user.posts.find(params[:post_id])\n @comment = @post.comments.create(params[:comment])\n\n @comment.commenter = current_user.profile.name#test and move to model?\n\n if @comment.save(params[:comment])\n current_user.comments << @comment #test and move to model?\n current_user.profile.increment_comments_count#test and move to model?\n flash[:notice] = \"Comment created successfully!\"\n end\n# respond_with(@user, :location => user_following_path(@user))\n respond_with(@post, @comment, :layout => !request.xhr?)\n end", "def show\r\n @blog_post = BlogPost.find(params[:id])\r\n @blog_post_comment = BlogPostComment.new\r\n @blog_post_comments = BlogPostComment.paginate(page: params[:page], per_page: 10, conditions: [\"blog_post_id = ?\", params[:id]], order: \"created_at DESC, id DESC\")\r\n end", "def show\n @comments = Comment.where(\"submission_id=\" + (params[:id])).order(\"created_at DESC\")\n end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments.all\n @comment = @post.comments.new\n @user = current_user\n @title = @post.title\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def show\n @post = Post.find(params[:id])\n \n # Post wasn't completely uploaded (probably exited during crop)\n if @post.image_file_name.nil?\n render_404\n return \n end\n \n @comments = @post.comments\n \n # Add description to comments if it exists\n @description_comment = Comment.new({ :user_id => @post.user.id, :blurb => @post.description })\n @description_comment.created_at = @post.created_at\n @comments = [@description_comment] + @comments if @post.description != ''\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def show\n redirect_to pretty_post_url(@post) + \"#comment_#{params[:id]}\"\n end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments.all\n end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments.all\n end", "def can_create_comment?(post); true; end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments\n @comments = @post.approved if cannot? :manage, Comment\n respond_with(@post)\n end", "def show\n @article = Article.find(params[:id]) # find article in database by id = ..\n\n # this section to handle comments\n @comment = Comment.new # create new COMMENT so rails can figure out which fields COMMENT has\n @comment.article_id = @article.id\n\n end", "def show\n @post = Post.find(params[:id])\n @comments = Comment.where(:post_id => params[:id]).order(\"id desc\")\n @comments = @comments.page(params[:page]).per(20)\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def show\n views = @fishing_area.views + 1\n @fishing_area.update(views: views)\n\n @comments = @fishing_area.comments.paginate(page: params[:page], per_page: 5)\n end", "def index\n @post_comments = PostComment.all\n end", "def show\n @post = Post.find_by_slug(params[:id])\n @comment = Comment.new\n logger.debug \"No. of comments for post #{@post.title} is #{@post.comments.size}\"\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end", "def class_comments\n if controller.controller_name == 'comments'\n \"current\"\n end\n end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments.includes(:user).all\n @comment = @post.comments.build(user_id: current_user.id) if current_user\n end", "def show\n @post = Post.find(params[:id])\n @comments = @post.comments.order('created_at DESC')\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def show\n @post = Post.find(params[:id])\n @comments = Comment.find_all_by_posts_id (@post.id)\n @comment = Comment.new\n @tags = Tag.all\n @categories = Category.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n format.json { render json: @comments }\n format.json { render json: @comment }\n end\n end", "def show\n kiss_record \"View blog post\"\n if admin_signed_in?\n @post = Post.find_by_title_for_url(params[:id])\n else\n @post = Post.where(:draft => false).find_by_title_for_url(params[:id])\n end\n if session[:comment].nil?\n @comment = @post.comments.new\n else\n @comment = session[:comment]\n end\n\t\t@comments = @post.comments.all.reverse\n end", "def index\n if params[:_post_id]\n post_comments = PostComment.where(post_id: params[:_post_id])\n render json: post_comments.as_json(\n include: { user: { only: [:name, :id] } },\n except: [:post_id, :user_id]),\n status: :ok\n else\n render json: @current_user.post_comments.as_json(\n include: { post: { only: [:title, :id, :excerpt] } },\n except: [:user_id, :post_id]),\n status: :ok\n end\n end", "def show\n #@post = Post.find(params[:id])\n @comment = Comment.new\n @comment_container_id_prefix = COMMENT_CONTAINER_ID_PREFIX\n respond_to do |format|\n format.html\n format.json { render json: @post, except: :updated_at, :include => {:user => {:only => [:name]}}}\n end\n end", "def show\n @post = Post.find(params[:id])\n @comment = Comment.new\n end", "def show\n @comments = Comment.where(post_id: params[:id])\n end", "def show\n\t\t@post = Post.find(params[:id])\n\t\[email protected]_count += 1\n\t\[email protected]\n\t\t@comment = Comment.new # 이거 안적으니까 지난 시간 구하는거에서 에러나\n\t\trespond_to do |format|\n\t\t\tformat.html { render :action => \"show\" }\n\t\t\tformat.js { render :file => \"posts/show.js.erb\" }\n\t\tend\n\tend", "def index\n\n @comments = params.has_key?('latest') ? @article.comments.latest : @article.comments.viewable\n\n end", "def index\n @posts = Post.paginate(:all, :page => params[:page], :per_page => 20, :order => \"posts.created_on desc, comments.created_on\", :include => [ :comments, :user ])\n @title = \"rawdod\"\n# @hotness = Post.find(:all, :order => \"commented_on desc\", :limit => 8, :conditions => [\"commented_on is NOT NULL\"])\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @posts.to_xml }\n end\n end", "def show\n @comments = @post.comments\n end", "def create\n if params[:post_id]\n @post = Post.find(params[:post_id])\n @comment = @post.comments.build(params[:comment].merge({:user_id => current_user.id}))\n else\n @story = Story.find(params[:story_id])\n @comment = @story.comments.build(params[:comment].merge({:user_id => current_user.id})) \n end\n respond_to do |format|\n if @comment.save \n format.html {\n flash[:notice] = 'Comment was successfully created.'\n if params[:post_id]\n redirect_to(@comment)\n else\n redirect_to edit_story_path(@story)\n end \n }\n format.js {\n render :update do |page|\n if params[:post_id]\n page << \"$('#new_comment').resetForm();\" \n page.redirect_to post_path(@post) \n else\n page['#Story-Comment-List'].html(render(:partial => \"stories/comment_list\", :locals => {:story => @story}))\n page << \"$('#comment_item_#{@comment.id}').effect('highlight', {}, 10000);\"\n page << \"$('#Comment-Creation-From').resetForm();\" \n end\n page << \"Message.notice('Comment was successfully posted.');\" \n end\n }\n format.xml { render :xml => @comment, :status => :created, :location => @comment }\n else\n format.html { render :action => \"new\" }\n format.js {\n render :update do |page|\n page['#dialog-form'].dialog('open');\n page['#new_comment_errors'].show();\n page['#new_comment_errors'].html(\"#{@comment.errors.full_messages}\");\n end \n }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @post = Post.find params[:id]\n @like = @post.like_for(current_user)\n @comment = Comment.new\n end", "def create\n #initialize a new post object with the parameters submitted, validated by post_params\n @post = Post.new(post_params)\n \n isComment = false\n #check whether this is actually a comment, meaning it should have kind=2 and will need an originating post id\n if params[:kind].present?\n @post.kind = params[:kind].to_i\n @post.originatingPost_id = params[:originatingPost_id].to_i\n isComment = true\n \n #otherwise, it is a post, which optionally has tags\n else\n @post.kind = 0\n @tagsToAdd = params[:tagsToAdd].split(\" \")\n @tagsToAdd.each do |t|\n @post.tags << createTag(t)\n end\n end\n \n #either way, the currently logged in user should be logged as the creator of this post/comment\n @post.user = User.find(session[:user_id])\n \n if @post.save!\n if isComment\n redirect_to action: \"show\", :id => params[:originatingPost_id] #stay on the post's show page\n else\n redirect_to action: \"show\", :id => @post.id #go to this new post's show page\n end\n else\n redirect_to action: 'new' #upon failure, try again\n end\n end", "def create\n @post = Post.find(params[:post_id]) #загружаем нужный пост для этого и нужен вложенный ресурс\n @comment = Comment.new(comment_params)\n @comment.post = @post #связываем пост и комментарий\n @comment.user = current_user\n #current_user вернет nil если не требовать аунтификации пользвателя\n if @comment.save\n redirect_to @post, notice: t(:comment_created)\n else\n render :new \n end\n end", "def show\n @posts = @profile.user.posts.paginate(page: params[:page], per_page: 5)\n @comment = Comment.new\n end", "def show\n @comments = @posting.forest\n end", "def show\n @comments = @news_post.comment_threads.order('created_at desc')\n @new_comment = Comment.build_from(@news_post, current_user.id, \"\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_post }\n end\n end", "def show\n #@last_comments = @post.comments.last(5)\n @last_comments = @post.comments.all\n @comment = @post.comments.build\n end", "def show\n if @comments.count === 0 || @comments.count >= 5\n @jakiKom = 'komentarzy'\n elsif @comments.count === 1\n @jakiKom = 'komentarz'\n else\n @jakiKom = 'komentarze'\n end\n respond_to do |format|\n format.html\n format.js\n end\n if current_user\n u = User.find(current_user.id)\n if u.has_role? :admin\n @crud = true\n elsif @post.user === u\n @crud = true\n else\n @crud = false\n end\n else\n @crud = false\n end\n case\n when params[:sortDate]\n case params[:sortDate]\n when \"desc\"\n @comments = @comments.order('created_at DESC')\n @sd = true;\n when \"asc\"\n @comments = @comments.order('created_at ASC')\n @sd = false;\n end\n end\n end", "def show\n #@profile = Profile.find(params[:profile_id])\n @user = current_user\n @request = Request.find(params[:id])\n #enable comments\n @commentable = @request\n @comments = @commentable.comments\n @comment = Comment.new\n end", "def posts; end", "def show\n @post = Post.find(params[:id], include: :comments, order: 'comments.id')\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def show\n @page = params[:page] || \"1\"\n @comments = Comment.includes(:user).where(post_id: @post.id).paginate(page: @page, per_page: @comment_per_page)\n end", "def index\n @post = @post\n @comments = Comment.post_comments(@post)\n @origin_url = params[:origin_url] == nil ? @post : params[:origin_url]\n end", "def can_have_comments?\n self.post?\n end", "def index\n @comments = Post.all\n end", "def show\n logger.debug(\"***comment show*** #{params}\")\n @blog = Blog.find(params[:blog_id])\n @entry = Entry.find(params[:entry_id])\n @comment = @entry.comments.find(params[:id])\n end", "def show\n @post.display_count += 1\n @post.save\n @comments = Comment.where(post_id: @post.id).paginate(:page => params[:page])\n\n # calculate reply number\n page = params[:page].to_i\n page = (page <= 0) ? 0 : (page - 1)\n @floor = page * Comment.per_page\n\n respond_to do |format|\n unless params[:show_as_article].nil?\n format.html { render :show_as_article }\n else\n format.html { render :show }\n end\n format.js\n end\n end", "def show\n @issue = Issue.find(params[:id])\n @comment = Comment.new\n \n if current_tester != nil\n @tester = Tester.find(current_tester)\n #@comment.tester_id = @tester.id\n elsif current_user\n @user = User.find(current_user)\n #@comment.user_id = @user.id\n end\n \n #@comment.issue_id = @issue.id\n \n @commentofissue = @issue.comments.order(\"created_at DESC\")\n ##@commentofissue = @commentofissue.order(\"created_at DESC\")\n\n end", "def show\n # Later, access votes table to display by highest votes.\n # @comments is @all_comments\n @comments = @character.comment_threads.order('created_at DESC')\n @new_comment = Comment.build_from(@character, current_user.id, \"\") if user_signed_in?\n\n end", "def create\n if(params[:comment][:tipus] == 'comment')\n\t\t\t@post = Post.find(params[:post_id])\n \t\t@comment = @post.comments.create(params[:comment].permit(:text, :tipus))\n \telse\n \t\t@parent = Comment.find(params[:comment][:parent_id])\n \t\t#@comment = @parent.replies.create(params[:comment].permit(:text, :tipus, :parent_id))\n \t\t@comment = Comment.new(comment_params)\n \t\[email protected] << @comment\n \t\[email protected] = 'reply'\n \t\[email protected]_id = @parent.post.id\n\t\t\t@post = Post.find(@comment.post_id)\n \tend\n\t\[email protected]_attribute(:nComments, @post.nComments + 1)\n \[email protected]_id = current_user.id\n\n \[email protected]\n\n \tif @comment.save\n \t\tif @comment.tipus == 'comment'\n \t\t\tredirect_to post_path(@post)\n \t\telse\n \t\t\tredirect_to post_path(@parent.post)\n \t\tend\n \telse\n \t\trender 'new'\n \tend\n end", "def show\n @post = Post.find_by_id(params[:id])\n @comment = Comment.new\n end", "def show\n @issue = Issue.find(params[:id])\n @feedback = Feedback.find(params[:feedback_id])\n @comment = Comment.new\n\n if current_tester != nil\n @tester = Tester.find(current_tester)\n #@comment.tester_id = @tester.id\n elsif current_user\n @user = User.find(current_user)\n #@comment.user_id = @user.id\n end\n\n #@comment.issue_id = @issue.id\n\n @numissue = @issue.comments.all\n @commentofissue = @issue.comments.order(\"created_at DESC\")\n ##@commentofissue = @commentofissue.order(\"created_at DESC\")\n\n end", "def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create(params[:comment].permit(:comment))\n @comment.user_id = current_user.id if current_user\n\n if @comment.save\n redirect_to post_path(@post)\n else\n render 'new'\n end\n end", "def show\n @comment = Comment.new\n @comment.post_id = @post.id\n end", "def set_comment_and_post\n @comment = Comment.find(params[:id])\n @post = @comment.post\n end", "def show\n @comment = Comment.new\n @comment.post_id = @post.id\n end", "def update_comments\n post = Post.find_by_id(params[:id])\n if !post.nil?\n @comments = post.comments.order(\"rank DESC\")\n else\n @comments = []\n end\n render :layout => \"update_comments\"\n end", "def show\n @user_creator = User.find(@issue.userCreator)\n @user = User.find(current_user.id);\n @comments = Comment.all\n \n @comments = @comments.select{|comment| comment.issue_id == @issue.id}\n @comment = Comment.new\n @comment.issue_id = @issue.id\n @comment.user_id = @user.id\n \n end", "def create\n\t\tComment.transaction do\t\t\n\t\t\t@post = Post.find(comment_params[:post_id])\n\t\t\t@author = @post.user\n\t\t\t\n\t\t\tif @post.reblogged\t\t\n\t\t\t\tnew_params = comment_params\n\t\t\t\tnew_params[:post_id] = @post.source_id\n\t\t\t\t@comment = current_user.comments.build(new_params)\n\t\t\telse\n\t\t\t\t@comment = current_user.comments.build(comment_params)\n\t\t\tend\t\t\t\n\t\t\t\n\t\tend\n\t\t\n\t\tif @comment.save && create_with_notification(@author, @comment)\n\t\t\trender partial: 'comment', locals: { comment: @comment }\n\t\telse\n\t\t\trender json: @comment.errors.full_messages, status: 422\n\t\tend\n end" ]
[ "0.675864", "0.657712", "0.64732933", "0.64732933", "0.64477986", "0.6359159", "0.6296727", "0.62833905", "0.6242645", "0.61736727", "0.6171855", "0.6138182", "0.6129519", "0.6106882", "0.6072991", "0.60716456", "0.60702604", "0.6067918", "0.6061656", "0.6059156", "0.60554224", "0.60458124", "0.6044373", "0.6036085", "0.6032261", "0.60139805", "0.6009773", "0.6009163", "0.6008513", "0.5985299", "0.59740126", "0.59692734", "0.5962253", "0.5959895", "0.5958666", "0.59516144", "0.5928797", "0.5919325", "0.5896655", "0.58929837", "0.5892733", "0.5873896", "0.58678603", "0.58642614", "0.5859155", "0.5857588", "0.5855125", "0.5853258", "0.58478737", "0.5829593", "0.5829593", "0.58283", "0.58274364", "0.58267117", "0.5823928", "0.58226293", "0.58186144", "0.58159053", "0.5808501", "0.5800747", "0.5794505", "0.57935244", "0.579326", "0.5788787", "0.57870084", "0.57780385", "0.5765881", "0.5763929", "0.57631135", "0.57613206", "0.57598466", "0.5759322", "0.57584697", "0.57560444", "0.57540333", "0.57468736", "0.57457197", "0.5743458", "0.5739998", "0.5729054", "0.57272214", "0.57259977", "0.57250434", "0.5723242", "0.5721725", "0.57191485", "0.57117593", "0.57007635", "0.5699603", "0.5688306", "0.5681446", "0.5677299", "0.5675229", "0.56733155", "0.56723243", "0.5664961", "0.5663729", "0.56616384", "0.56544137", "0.5649595", "0.5649553" ]
0.0
-1
GET /tasks/1 GET /tasks/1.xml
def show respond_with(@task = Task.find(params[:id])) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @task }\n end\n end", "def index\n get_tasks\n get_priorities\n get_users\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def index\n @tasks = @project.tasks\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def index\n @tasks = Task.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def index\n @tasks = Task.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def task(name)\n get \"#{base_url}/tasks/#{name}\"\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def index\n @tasks = Task.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def index\n # GET /tasks\n @tasks = Task.all\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n format.xml { render xml: @task }\n end\n end", "def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end", "def index\n @tasks = Task.find(:all, :order => \"name asc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def show\n @task = Task.find_by_name(unescape_url(params[:id]))\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def list_tasks(api_object)\n puts \"Current Tasks:\"\n doc = Nokogiri::XML.parse api_object.read\n puts doc\n descriptions = doc.xpath('tasks/task/description').collect {|e| e.text }\n puts descriptions.join(\", \")\n puts \"\"\nend", "def show\n @task = Task.find(params[:id])\n @subtasks = @task.children\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def index\r\n @tasks = get_sorted_list_of_tasks\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @tasks }\r\n end\r\n end", "def show\n @page_title = \"Task List\"\n @task_list = TaskList.find(params[:id])\n @tasks = Task.find(:all,\n :conditions => [\"task_list_id = ?\",@task_list.id]\n ) \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task_list }\n end\n end", "def url\n\n \"/tasks/#{self.id}\"\n\n end", "def show\n @project_task = ProjectTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @project_task }\n end\n end", "def show\n @task = current_user.tasks.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @task }\n end\n end", "def show\n @user_task = UserTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_task }\n end\n end", "def task\n @task = MailTasks::Task.find( params[:id] )\n end", "def show\r\n @task = @current_user.tasks.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @task }\r\n end\r\n end", "def show\n @time_task = TimeTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @time_task }\n end\n end", "def index\n @tasks = current_user.tasks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def show\n @subtask = Subtask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @subtask }\n end\n end", "def show\n @agile_task = AgileTask.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @agile_task }\n end\n end", "def get(action, task, params={})\n @action = action\n @task = task\n request(:get, params)\n end", "def show\n @long_running_task = LongRunningTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @long_running_task }\n end\n end", "def show\n @job = Job.find(params[:id])\n @tasks = @job.tasks\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @job }\n end\n end", "def show\n respond_with Task.find(params[:id])\n end", "def show\n @rg_task = RgTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rg_task }\n end\n end", "def show\n @workflow_task = WorkflowTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @workflow_task }\n end\n end", "def show\n @project = Project.find(params[:id])\n @members = @project.members.all\n @tasks = @project.tasks.all(:order => \"status, priority, deadline\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => [@project, @members, @tasks] }\n end\n end", "def get_task(taskid)\n params = {\n 'method' => :get,\n 'command' => \"/task/#{taskid}\"\n }\n\n response, headers = send_request(params)\n\n task = response.css('Task').first\n status = task['status']\n start_time = task['startTime']\n end_time = task['endTime']\n\n { :status => status, :start_time => start_time, :end_time => end_time, :response => response }\n end", "def show\n @task = Task.find(params[:id])\n end", "def show\n @task = Task.find(params[:id])\n end", "def show\n @task = Task.find(params[:id])\n end", "def show\n \n @task = @project.tasks.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def task(task_id, tasklist_id = '@default')\n get gtasks_task_url(task_id, tasklist_id)\n end", "def show\n @reminder_task_list = ReminderTaskList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @reminder_task_list }\n end\n end", "def index\n @project = Project.find(params[:project_id])\n @tasks = @project.tasks\n end", "def get_task_list(id)\n response = request(\n :expects => 200,\n :idempotent => true,\n :method => 'GET',\n :parser => Fog::ToHashDocument.new,\n :path => \"tasksList/#{id}\"\n )\n ensure_list! response.body, :Task\n response\n end", "def index\n @api_tasks = Api::Task.all\n end", "def get_task(taskid)\n params = {\n 'method' => :get,\n 'command' => \"/task/#{taskid}\"\n }\n\n response, headers = send_request(params)\n\n task = response.css('Task').first\n status = task['status']\n start_time = task['startTime']\n end_time = task['endTime']\n\n { :status => status, :start_time => start_time, :end_time => end_time, :response => response }\n end", "def get_task(taskid)\n params = {\n 'method' => :get,\n 'command' => \"/task/#{taskid}\"\n }\n\n response, headers = send_request(params)\n\n task = response.css('Task').first\n status = task['status']\n start_time = task['startTime']\n end_time = task['endTime']\n\n { :status => status, :start_time => start_time, :end_time => end_time, :response => response }\n end", "def show\n\t\t@project = Project.find(params[:id])\n\t\t@tasks = @project.tasks \n\n\tend", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @task }\n end\n end", "def show\n @task = Task[params[:id]]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def index\n @tasks = Task.all \n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find params[:id]\n end", "def show\n @task = Task.find(params[:id])\n @subtasks = @task.statuses.order(:created_at).reverse\n @subtask = Status.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task }\n end\n end", "def show\n @task = Task.find params[:id]\n\n end", "def show\n @project = Project.find(params[:id])\n @tasks = Task.find_all_by_id(params[:id])\n end", "def show\n render :json => Project.find(params[:project_id]).tasks.find(params[:id])\n end", "def tasks(project_id)\n account = Config.details \n c = FreshBooks::Client.new(account[\"account\"], account[\"token\"])\n c.task.list :project_id => project_id\n end", "def show\n @task = @project.tasks.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { redner json: @task }\n end\n\n end" ]
[ "0.739653", "0.71483886", "0.706631", "0.7033858", "0.7030175", "0.70199716", "0.70163554", "0.6996634", "0.69620013", "0.69607425", "0.69607425", "0.69607425", "0.69607425", "0.69607425", "0.69188", "0.6918308", "0.6916772", "0.6878961", "0.68282247", "0.6817829", "0.678755", "0.6734971", "0.6729513", "0.66938645", "0.6673785", "0.6666564", "0.6638321", "0.66278267", "0.66001856", "0.6583001", "0.6524877", "0.6519867", "0.6496166", "0.64894414", "0.6442428", "0.64358336", "0.6383366", "0.6344458", "0.6341667", "0.63372666", "0.6330123", "0.6319343", "0.6317534", "0.6317534", "0.6317534", "0.63055015", "0.62903315", "0.6269559", "0.6243622", "0.6238867", "0.62331694", "0.62293845", "0.62293845", "0.6221492", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.6218447", "0.621744", "0.62119997", "0.62102365", "0.6208453", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.620739", "0.61838627", "0.61636156", "0.6162894", "0.615882", "0.6154231", "0.6143326", "0.6142458" ]
0.0
-1
GET /tasks/new GET /tasks/new.xml
def new respond_with(@task = Task.new) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n format.xml { render xml: @tasks }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = context.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.xml { render :xml => @task }\n end\n end", "def new\r\n @task = @current_user.tasks.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @task }\r\n end\r\n end", "def new\n @project_task = ProjectTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project_task }\n end\n end", "def new\n @page_title = \"Task List New\"\n @task_list = TaskList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_list }\n end\n end", "def new\n @task = Task.new(:task_list => TaskList.find(params[:task_list_id]))\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n\n\n\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n # raise params.inspect\n @task = Task.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new(:expires => true, :time => -1, :start_date => Time.now.at_beginning_of_day, :end_date => Time.now.at_beginning_of_day)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @time_task = TimeTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @time_task }\n end\n end", "def new\n @task = current_user.tasks.new\n @tags = current_user.tags.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @user_task = UserTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_task }\n end\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @task }\n end\n end", "def new\n options = {} \n options[:status_id] = Status.find_by_title(params[:page]).id if params[:page]\n @task = Task.new(options)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n format.js { render :layout => false }\n end\n end", "def new\n @workflow_task = WorkflowTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workflow_task }\n end\n end", "def new\n @rg_task = RgTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rg_task }\n end\n end", "def new\n @task = Task.new\n @sprint = Sprint.find(params[:id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new\n \n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def new\n @subtask = Subtask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @subtask }\n end\n end", "def new\n @task = Task.new\n respond_with(@task)\n end", "def new\n @task = Task.new(:project_id => params[:id])\n\t\t@projects = Project.sorted\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @template_task = TemplateTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @template_task }\n end\n end", "def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task_list }\n end\n end", "def new\n @task_priority = TaskPriority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @task_priority }\n end\n end", "def create\n @task = Task.new(params[:task])\n\n respond_to do |format|\n if @task.save\n flash[:notice] = 'Task was successfully created.'\n format.html { redirect(@task) }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\r\n @status_task = StatusTask.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @status_task }\r\n end\r\n end", "def new\n \n if params[:id].nil?\n @projects = Project.all\n else\n @project = Project.find(params[:id])\n end\n\n @priorities = Priority.all\n @stopovers = Stopover.all\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @project = Project.find(params[:project_id])\n @task = @project.tasks.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @task_changes = TaskChange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task_changes }\n end\n end", "def new\n @todo_task = TodoTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo_task }\n end\n end", "def new\n @task_row = TaskRow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_row }\n end\n end", "def new\n @task = Task.new(params[:task])\n end", "def new\n\t@task = Task.new\nend", "def new\n @task = Task.new\n \n if params[:task_id].nil?\n @parent = Task.new\n else\n @parent = Task.find(params[:task_id])\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todo }\n end\n end", "def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todo }\n end\n end", "def new\n @annotation_task = AnnotationTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @annotation_task }\n end\n end", "def new\n @task_state = TaskState.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_state }\n end\n end", "def new\n @group_of_task = GroupOfTask.new\n @projects = Project.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_of_task }\n end\n end", "def new\n @reminder_task_list = ReminderTaskList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reminder_task_list }\n end\n end", "def new\n @task = Task.new(:due_at => Time.now)\n \n respond_with @task\n end", "def new\n @task = Task.new\n\n respond_to do |format|\n format.js\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @workflow_task_type = WorkflowTaskType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workflow_task_type }\n end\n end", "def new\n @task = Task.new(sdate:Time.now.getlocal.strftime(\"%F\"),edate:Time.now.getlocal.strftime(\"%F\"))\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @tasks_translation = TasksTranslation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tasks_translation }\n end\n end", "def new\n @task = Task.new\n # tasks_counts\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n\t\t@task= Task.new\n\tend", "def new\n @project = Project.find(params[:project_id])\n @sprint = Sprint.find(params[:sprint_id])\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @script = Script.new\n @task = Task.get(params[:task_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @script }\n end\n end", "def create\n task = Task.new(params[:task])\n unless task.save\n flash[:error] = \"Unable to add task\"\n end\n @tasks = Task.open_tasks\n render :partial => \"task_list\", :layout => false\n end", "def new\n @long_running_task = LongRunningTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @long_running_task }\n end\n end", "def new\n if can_manage?\n @task = Task.new\n end\n\n respond_to do |format|\n format.html {\n unless can_manage?\n redirect_to('/')\n end\n }\n format.xml { render :xml => @task }\n end\n end", "def new\n @task = Task.new\n @parent = current_user.projects.first\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n @tasktype = Tasktype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tasktype }\n end\n end", "def new\n @todos = Todos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todos }\n end\n end", "def new\n @tasks_person = TasksPerson.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tasks_person }\n end\n end", "def new\n @task_assignment = TaskAssignment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_assignment }\n end\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def new\n @task = Task.new\n end", "def create\n @task = current_user.tasks.new(params[:task])\n\n respond_to do |format|\n if @task.save\n flash[:notice] = 'Task was successfully created.'\n format.html { redirect_to(@task) }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n format.js { render :action => \"show\", :layout => false}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n format.js { render :text => \"ERROR\" + @task.errors.to_s }\n end\n end\n end", "def new\n @task_definition = TaskDefinition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task_definition }\n end\n end", "def new\n @todo_list = TodoList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todo_list }\n end\n end", "def create\n @task = current_user.tasks.new(params[:task])\n @task.switch_now if params[:commit] == 'Switch Now'\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to(@task, :notice => 'Task was successfully created.') }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n @tags = current_user.tags.all\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @task_stat = TaskStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task_stat }\n end\n end", "def create\n #byebug\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @new_project = Project.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @new_project }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @task_share = TaskShare.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_share }\n end\n end", "def create\n @task = params[:task]\n redirect_to new_task_url if @task.blank?\n @response = `#{@task}`\n end", "def new\n @list = List.new\n 1.times { @list.tasks.build }\n respond_with(@list)\n end", "def new\n @project_path = ProjectPath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project_path }\n end\n end", "def new\n @indexer_task = IndexerTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indexer_task }\n end\n end" ]
[ "0.79913056", "0.783725", "0.7735345", "0.7735345", "0.7735345", "0.7735345", "0.7605314", "0.7521009", "0.7475729", "0.74077904", "0.7396494", "0.72603416", "0.7239029", "0.7223643", "0.7221421", "0.7204809", "0.71812963", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7151181", "0.7138869", "0.7137261", "0.71098095", "0.70731354", "0.7070201", "0.7024432", "0.7014773", "0.69434774", "0.68827385", "0.6870374", "0.68670636", "0.6855922", "0.6848468", "0.6828395", "0.6803601", "0.67775506", "0.6777406", "0.67673695", "0.67527586", "0.6714076", "0.67139834", "0.67137104", "0.6701274", "0.6691979", "0.6691979", "0.66704714", "0.66686726", "0.6664307", "0.66555256", "0.6650648", "0.66435194", "0.6622528", "0.66135025", "0.6611166", "0.6593932", "0.659143", "0.65908474", "0.65899676", "0.6557232", "0.6552975", "0.6549533", "0.6535408", "0.6524962", "0.65115935", "0.64827585", "0.64708114", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6454869", "0.6435932", "0.6429989", "0.64267075", "0.6417856", "0.6411448", "0.64030814", "0.63852644", "0.63788617", "0.63755196", "0.63721347", "0.6368152", "0.6365325", "0.6352088" ]
0.0
-1
POST /tasks POST /tasks.xml
def create @task = params[:task] ? Task.create(params[:task]) : Task.create(:description=>params[:description], :isDone=>params[:isDone], :order=>params[:order] ) respond_with(@task) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end", "def create_task(options = {})\n request(:post, \"tasks\", options)\n end", "def post(action, task=nil, params={})\n @action = action\n @task = task\n request(:post, params)\n end", "def add_task(task_name)\n unless File.exist? \"app/scheduled_jobs/#{task_name}.rb\"\n raise \"Task #{task_name} does not exist!\"\n end\n url = \"http://localhost:#{server_port}/tasks/#{task_name}\"\n command \"/usr/bin/curl #{url} -X POST\"\nend", "def create\n @task = Task.new(task_params)\n @task.start\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to tasks_url, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n if @task.save\n render json: @task, status: :created\n else\n render json: @task.errors, status: :unprocessable_entity\n end\n end", "def create\n #byebug\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@task = Task.new(task_params)\n task = @task_list.tasks.create!(task_params)\n render json: task\n end", "def create\n # raise params.inspect\n @task = Task.new(task_params)\n if @task.save\n redirect_to tasks_url\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n\n end\n end", "def save_task(task)\n update_object_xml('Task', task.id, task.to_xml)\n end", "def create\n @task = Task.new(params[:task])\n\n respond_to do |format|\n if @task.save\n flash[:notice] = 'Task was successfully created.'\n format.html { redirect(@task) }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to tasks_path, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: tasks_path }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n @task.save\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to tasks_url, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to tasks_url, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(task)\n validate_type!(task)\n\n attributes = sanitize(task)\n _, _, root = @client.post(\"/tasks\", attributes)\n\n Task.new(root[:data])\n end", "def create\n @task = Task.new(task_params)\n respond_to do |format|\n if @task.save\n @users = User.all\n @users.each do |user|\n user.tasks << @task\n end\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_task = Api::Task.new(api_task_params)\n\n respond_to do |format|\n if @api_task.save\n format.html { redirect_to @api_task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @api_task }\n else\n format.html { render :new }\n format.json { render json: @api_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.create!(task_params)\n end", "def create\n projusers = ProjectsUser.find(params[:task][:project_users_id])\n @task = projuser.tasks.build(task_params)\n\n if @task.save\n render json: @task , status: :created, location: @task\n else\n render json: @task.errors, status: :unprocessable_entity\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: \"Task was successfully created.\" }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: \"Task was successfully created.\" }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: \"Task was successfully created.\" }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def add task_details\n\n #prepare payload\n now = Time.now.to_i \n defaults = {\n \"method\" => \"task.save\",\n \"id\" => UUID.generate,\n \"type\" => 0,\n \"_type\" => now,\n \"state\" => 0,\n \"_state\" => now,\n }\n\n task = defaults.merge(task_details)\n self.post [task].to_json\n end", "def create\n @task = Task.new(task_params)\n @task.save\n redirect_to task_path(@task)\n end", "def create\n @task = current_user.tasks.new(task_params)\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'タスクを登録しました!' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = @project.tasks.new(task_params)\n @task.user = current_user if current_user.developer?\n @statuses = Task.statuses.keys\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to edit_project_task_path(@project, @task.id), notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n puts @task.errors.as_json\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n @task.save\n render json: full_task(@task)\n end", "def create\n @user_task = UserTask.new(params[:user_task])\n\n respond_to do |format|\n if @user_task.save\n flash[:notice] = 'UserTask was successfully created.'\n format.html { redirect_to(@user_task) }\n format.xml { render :xml => @user_task, :status => :created, :location => @user_task }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n if @task.save\n render :show, status: :created, location: @task\n else\n render json: @task.errors, status: :unprocessable_entity\n end\n end", "def create\n @task = Task.create(task_params)\n redirect_to tasks_path\n end", "def create\n @event_task = @event.event_tasks.new(event_task_params)\n\n respond_to do |format|\n if @event_task.save\n format.html { redirect_to @event_task, notice: 'Event task was successfully created.' }\n format.json { render :show, status: :created, location: @event_task }\n else\n format.html { render :new }\n format.json { render json: @event_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(params[:task])\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(params[:task])\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(params[:task])\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(params[:task])\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = @project.tasks.create!(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to project_url(@project), notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def task_params\n params.require(:task).permit(:name, :description, :start_date, :end_date, :status, :priority, :tenant_id, :project_id)\n end", "def create\n @project = Project.find(params[:project_id])\n @task = @project.tasks.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @project, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(params[:task])\n @sprint = Sprint.find(@task.sprint_id)\n\n respond_to do |format|\n if @task.save\n flash[:notice] = 'Task was successfully created.'\n format.html { redirect_to(@task) }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(params[:task])\n if @task.save\n flash[:notice] = 'Task was successfully created.' \n end\n respond_with(@task)\n end", "def create\n @task = @project.tasks.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to [@project, @task], notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = current_user.tasks.build(task_params)\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: \"Task was successfully created.\" }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = @project.tasks.build(params[:task])\n #alias field is non mandatory\n \n respond_to do |format|\n if @task.save\n flash[:notice] = 'Task was successfully created.'\n format.html { redirect_to [@project, :tasks] }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n flash[:notice] = 'Failed to create task.'\n flash[:errors] = @task.errors.full_messages.join('<br />')\n format.html { redirect_to :back }\n end\n end\n end", "def create\n \n @user= User.find_by_id(session[:user_id])\n @task = @user.tasks.create(params[:task])\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = current_user.tasks.build(task_params)\n respond_to do |format|\n if @task.save \n format.html { redirect_to @task, notice: \"Task was successfully created.\" }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = @project.tasks.build(task_params)\n @task.open!\n respond_to do |format|\n if @task.save\n format.html { redirect_to ([@project, @task]), notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: ([@project, @task]) }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n task = Task.new(task_params)\n if task.save\n render json: task, status: :created\n else\n render_errors(task)\n end\n end", "def create\n\t\t@task = Task.new(task_params)\n\t\[email protected] = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @task.save\n\t\t\t\tformat.html { render json: @task }\n\t\t\t\tformat.json { render json: @task }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @task.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n flash[:notice] = \"Task was successfully created.\" if task.save\n respond_with(task)\n end", "def task_params\n params.require(:task).permit(:name, :priority, :duedate, :completed, :description, :status)\n end", "def create\n @task = Task.new(task_params)\n\n if @task.save\n render json: @task, serializer: TaskSerializer\n else\n render json: { error: t('task_create_error') }, status: :unprocessable_entity\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render action: 'show', status: :created, location: @task }\n else\n format.html { render action: 'new' }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render action: 'show', status: :created, location: @task }\n else\n format.html { render action: 'new' }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render action: 'show', status: :created, location: @task }\n else\n format.html { render action: 'new' }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@task = Task.new(task_params)\n\n\t\trespond_to do |format|\n\t\t\tif @task.save\n\t\t\t\tformat.html { redirect_to [:admin, @task], notice: 'Task was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: [:admin, @task] }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: [:admin, @task].errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @task = Task.create!(params[:task])\n @task.complete = 0\n if @task.save\n \t#logger.debug \"New task: #{@task.attributes.inspect}\"\n \trespond_to do |format|\n \t\tformat.html {redirect_to tasks_url, notice: 'Task was successfully created.' }\n \t\tformat.js\n \tend\n end\n end", "def task_params\n params.require(:task).permit(:title, :notes, :end_date, :task_status_id)\n end", "def create\n @taks = Task.new()\n @task.save\n redirect_to task_path(@task)\n end", "def create\n @task = Task.new(\n name: params[:task][:name],\n description: params[:task][:description],\n completed_at: params[:task][:completed_at]\n )\n if @task.save\n redirect_to task_path(@task.id)\n else\n render :new\n end\n end", "def task_params\n params.require(:task).permit(:title, :content, :expired_at, :status, :priority, tag_ids: [])\n end", "def create\n @task = Task.new(params[:task])\n if @task.save\n redirect_to wip_path\n else\n redirect_to wip_path\n end\n end", "def create\n if get_case\n @task = @case.tasks.create(task_params)\n path_tasks = case_tasks_path\n else\n @task = Task.new(task_params)\n path_tasks = tasks_path\n end\n\n @task.user = @user\n @task.firm = @firm\n\n respond_to do |format|\n if @task.save\n track_activity @task\n if @task.add_event && @task.due_date.present?\n @task.create_event\n end\n format.html { redirect_to path_tasks, notice: 'Task successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = current_user.tasks.new(params[:task])\n @task.switch_now if params[:commit] == 'Switch Now'\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to(@task, :notice => 'Task was successfully created.') }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n @tags = current_user.tags.all\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_task(list_id, text)\n path = \"lists/#{list_id}/tasks\"\n params = {task: {text: text}}\n request(path, params, :post)\n\n # output full list again\n show_list(list_id)\n end", "def create\n @task = current_user.tasks.new task_params\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n task = Task.new(task_params)\n task.save ? respond_with(task) : false\n end", "def create\n @task = params[:task]\n redirect_to new_task_url if @task.blank?\n @response = `#{@task}`\n end", "def create\n @task = Task.find(params[:user_task][:tasks_id])\n\tcurrent_user.craete_task!(@task)\n respond_to do |format|\n if @user_task.save\n format.html { redirect_to @user_task, notice: 'User Task was successfully created.' }\n format.json { render json: @user_task, status: :created, location: @user_task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def task_params\n params.require(:task).permit(:name, :done)\n end", "def create\n @task = @list.tasks.build(task_params)\n\n if @task.save\n return render_success_task_created\n else\n return render_error_save @task\n end\n end", "def create\n # 'params_task' returns the value that is authorized by this function\n # rails in default blocks any modifications so we have to give this access\n @task = Task.new(task_params)\n @task.save\n # we don't want to go to a kind of 'create's page' so we are redirecting to\n # out root page\n redirect_to tasks_path(@task)\n end", "def create_tasks_with_http_info(task_payload, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DevicesManagementApi.create_tasks ...\"\n end\n # verify the required parameter 'task_payload' is set\n fail ArgumentError, \"Missing the required parameter 'task_payload' when calling DevicesManagementApi.create_tasks\" if task_payload.nil?\n # resource path\n local_var_path = \"/devicemgmt/tasks\".sub('{format}','json')\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(task_payload)\n auth_names = ['artikcloud_oauth']\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 => 'TaskEnvelope')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DevicesManagementApi#create_tasks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def task_params\n params.require(:task).permit(:task)\n end", "def create\n @task = current_user.tasks.build(params[:task])\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to :action => :index, notice: 'Task was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = current_user.tasks.new(params[:task])\n\n respond_to do |format|\n if @task.save\n flash[:notice] = 'Task was successfully created.'\n format.html { redirect_to(@task) }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n format.js { render :action => \"show\", :layout => false}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n format.js { render :text => \"ERROR\" + @task.errors.to_s }\n end\n end\n end", "def tasks_post(cbrain_task, opts = {})\n data, _status_code, _headers = tasks_post_with_http_info(cbrain_task, opts)\n data\n end", "def create\n @task = Task.new(params[:task])\n\n respond_to do |format|\n if @task.save\n @feature.tasks << @task\n @iteration.tasks << @task\n @feature.save\n @iteration.save\n get_tasks\n format.js\n format.html { redirect_to(@task, :notice => 'Task was successfully created.') }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n format.js\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n @task.send_slack\n format.html { redirect_to @task, notice: t('task.successfully-created') }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = current_user.tasks.build(task_params)\n command = Tasks::Create.call(@task)\n\n respond_to do |format|\n if command.success?\n # TODO: Move messages to en.yml and use I18n\n format.html { redirect_to @task, notice: \"Task was successfully created.\" }\n else\n format.html { render :new, status: :unprocessable_entity }\n end\n end\n end", "def task_params\n params.require(:task).permit(:name, :description, :status, :project_users_id)\n end", "def create\n @task = @project.tasks.build(params[:task])\n if @task.save\n @task.insert_at # The top of the list.\n respond_to do |format|\n format.html do\n flash[:notice] = 'Task was created.'\n flash[:highlight_dom_id] = dom_id(@task)\n redirect_to project_tasks_path(@project)\n end\n end\n else\n respond_to do |format|\n format.html { render :action => 'new' }\n end\n end\n end", "def add_user_task\n task = Task.create(task_params)\n puts \"New task: #{task}\"\n if task\n render json: {task: task}\n else\n render json: task.error.full_messages, status: 402\n end\n end", "def task_params\n params.require(:task).permit(:name, :description, :priority, :complete, :due_date)\n end", "def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n if params[:create_and_continue]\n format.html { redirect_to new_task_url, notice: 'Task was successfully created.' }\n else\n format.html { redirect_to tasks_url, notice: 'Task was successfully created.' }\n end\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(task_params)\n\t\t\n\t\t# Assume none are taken at creation...\n\t\[email protected] = 0\n\n respond_to do |format|\n if @task.save\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render :show, status: :created, location: @task }\n else\n format.html { render :new }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.new(params[:task])\n\[email protected]_id = current_user.id\n\t\n\tlogger.info \"Completed: #{params[:task][:completed]}\"\n @task.completed_at = Time.now if params[:task][:completed]\n logger.info \"Completed At: #{@task.completed_at}\"\n logger.info \"Completed?: #{@task.completed?}\"\n \n respond_to do |format|\n if @task.save\n \tcalculate_totals\n #flash[:notice] = 'Task was successfully created.'\n format.js # run the create.js.erb template\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\r\n @status_task = StatusTask.new(params[:status_task])\r\n\r\n respond_to do |format|\r\n if @status_task.save\r\n format.html { redirect_to @status_task, notice: 'Status task was successfully created.' }\r\n format.json { render json: @status_task, status: :created, location: @status_task }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @status_task.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def task_params\n params.require(:task).permit(:name, :status, :due_date)\n end", "def create\n @default_task = DefaultTask.new(params[:default_task])\n\n if @default_task.save\n render json: @default_task, status: :created, location: @default_task\n else\n render json: @default_task.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.6856477", "0.6845752", "0.65675074", "0.64086604", "0.6378109", "0.6377058", "0.6344394", "0.6312993", "0.63005185", "0.62720716", "0.6271131", "0.6255944", "0.62371874", "0.62227607", "0.6221714", "0.62177366", "0.61810756", "0.6178637", "0.61708736", "0.6165702", "0.616234", "0.6159927", "0.6159927", "0.6159927", "0.6159927", "0.6159927", "0.6159927", "0.6159927", "0.6159927", "0.6159927", "0.61571205", "0.61571205", "0.61571205", "0.6150246", "0.61489284", "0.61411184", "0.61308", "0.61284614", "0.6118521", "0.6109446", "0.6102098", "0.6092964", "0.6081866", "0.6081866", "0.6081866", "0.6081866", "0.60812575", "0.6078208", "0.60761434", "0.6074746", "0.6074324", "0.6070822", "0.6069412", "0.6066326", "0.6059945", "0.605921", "0.60559976", "0.60508066", "0.60501266", "0.6039256", "0.6034554", "0.6034189", "0.60320544", "0.60312796", "0.60312796", "0.6029812", "0.602939", "0.602732", "0.6018343", "0.601239", "0.6007315", "0.6004455", "0.5994044", "0.5990967", "0.5990343", "0.59882045", "0.5986597", "0.59782463", "0.5970819", "0.596528", "0.5963301", "0.59571725", "0.5956713", "0.59565246", "0.59538174", "0.59531164", "0.5952245", "0.59479004", "0.5943883", "0.5941036", "0.59406257", "0.59404117", "0.5936322", "0.5921561", "0.59165096", "0.5914642", "0.59126264", "0.5908383", "0.5907433", "0.5904191" ]
0.62306863
13
PUT /tasks/1 PUT /tasks/1.xml
def update @task = Task.find(params[:id]) params[:task] ? @task.update_attributes(params[:task]) : @task.update_attributes(:description=>params[:description], :isDone=>params[:isDone], :order=>params[:order] ) #@task.save respond_with(@task) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n format.html { redirect_to(@task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n task = @task_list.tasks.find(params[:id])\n task.update_attributes(task_params)\n render nothing: true\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @task.update(task_params)\n end", "def update\n @task = context.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(redirect, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { redirect_to(redirect, :notice => 'Please try again') }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n @tasks = Task.find(params[:id])\r\n if @tasks.update(task_params)\r\n render json: @tasks\r\n else\r\n render json: @tasks.errors, status: :unprocessable_entity\r\n end\r\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n format.html { redirect(@task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def save_task(task)\n update_object_xml('Task', task.id, task.to_xml)\n end", "def update\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Successfully updated task.'\n format.html { redirect_to :back }\n format.xml { }\n else\n format.html render :action => \"edit\"\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n format.xml { render xml: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(task_list_path(params[:task_list_id]), :notice => 'task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find_by(id: params[:id])\n if @task.update(task_params)\n render json: { message: I18n.t('task.update.success') }, status: 200\n else\n render json: @task.errors, status: :unprocessable_entity\n end\n end", "def update\n @task = Task.find(params[:id])\n @task.update(task_params)\n\n redirect_to tasks_path(@task)\n end", "def update\n set_task\n respond_to do |format|\n if @task.update!(task_params)\n format.html\n format.json { respond_with_bip(@task) }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, :notice => 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n @task.update(task_params)\n #@task.save\n redirect_to tasks_path(@task)\n end", "def update_task(id, title, description)\n task = Task.find(id)\n task.title = title\n task.description = description\n task.save\nend", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to action: \"index\" }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_task\n @api_v1_task = Task.find(params[:id])\n end", "def update\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n end\n respond_with(@task)\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n command = Tasks::Update.call(@task, params: task_params)\n respond_to do |format|\n if command.success?\n format.html { redirect_to @task, notice: \"Task was successfully updated.\" }\n else\n format.html { render :edit, status: :unprocessable_entity }\n end\n end\n end", "def update\n task = Task.find(params[:id])\n if task.update(task_params)\n render json: task\n else\n render_errors(task)\n end\n end", "def update\n @task = Task.find(params[:id])\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to_index('Task was successfully updated.', 1)}\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.json { render :show, status: :ok, location: @task }\n else\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = current_user.tasks.find(params[:id])\n # Tasks may not change job, so no assigment like the Create action\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n format.html { redirect_to job_url(@task.job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors.to_xml }\n end\n end\n end", "def update\n flash[:notice] = \"Task was successfully updated.\" if task.save\n respond_with(task)\n end", "def update\n @task = Task.find(params[:id])\n @sprint = Sprint.find(@task.sprint_id)\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n format.html { redirect_to(@task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update \n\t logger.debug \"Params --------------------------------------- #{params}\"\n\n\t logger.debug \"task params --------------------------------------#{task_params}\"\n\t format_task_attributes(task_params)\n\t \n\t logger.debug \"-------------------------------------------------------------\"\n\t logger.debug \"Updated Params #{@updated_params}\"\n\t @updated_params[:id]=params[:id]\n\t @task = Task.find(@updated_params[:id])\n\t logger.debug \"#########################\"\n\t logger.debug \"Task found \"\n\t \n\t @task.assign_attributes(@updated_params)\n\t authorize! :update, @task\n\t @task.is_completed=false\n\t save_task\n\tend", "def update\n @task = current_user.tasks.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to :action => :index, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @task = @current_user.tasks.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @task.update_attributes(params[:task])\r\n format.html { redirect_to(@task) }\r\n format.xml { head :ok }\r\n format.js {\r\n #flash[:notice] = 'Task updated'\r\n render :text => 'Task successfully updated'\r\n }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @task.update(task_params)\n redirect_to task_path(@task)\n end", "def update\n @task = Task.find(params[:id])\n respond_to do |format|\n if @task.update_attributes(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = @project.tasks.find(params[:id])\n #@task = @project.tasks.update!(task_params)\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to project_url(@task), notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_task = UserTask.find(params[:id])\n\n respond_to do |format|\n if @user_task.update_attributes(params[:user_task])\n flash[:notice] = 'UserTask was successfully updated.'\n format.html { redirect_to(@user_task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n \t@task = @project.tasks.find(params[:id])\n if @task.update_attributes(params[:task])\n redirect_to(project_tasks_path(@project))\n flash[:notice] = 'Task was successfully updated.'\n else\n render('edit')\n end\n end", "def update\n respond_to do |format|\n if @api_task.update(api_task_params)\n format.html { redirect_to @api_task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_task }\n else\n format.html { render :edit }\n format.json { render json: @api_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n format.html { redirect_to(@task) }\n format.xml { head :ok }\n format.js { render :action => \"show\", :layout => false }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n format.js { render :text => \"ERROR\" + @task.errors.to_s }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task.project, :notice => 'Task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @task.update(task_params)\n redirect_to tasks_path\n end", "def edit_user_task\n task = Task.find(params[:id])\n \n if task.update(task_params)\n render json: {task: task, status: 201} \n else\n render json: {errors: task.errors.full_message , status: 422}\n end\n end", "def edit_user_task\n task = Task.find(params[:id])\n \n if task.update(task_params)\n render json: {task: task, status: 201} \n else\n render json: {errors: task.errors.full_message , status: 422}\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n $redis.publish('tasks.update', TaskSerializer.new(Task.last).to_json)\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subtask = Subtask.find(params[:id])\n\n respond_to do |format|\n if @subtask.update_attributes(params[:subtask])\n flash[:notice] = 'Subtask was successfully updated.'\n format.html { redirect_to(@subtask) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subtask.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n Task.associate_task(params:params, task: @task)\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n get_tasks\n format.js\n format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.js\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(options = {})\n self.merge!(Vermonster::Client.connection.put(\"tasks/#{self[\"id\"]}\", \"{\\\"task\\\": #{options.to_json}}\").body)\n end", "def update\n if @task.update(task_params)\n render :show, status: :ok, location: @task\n else\n render json: @task.errors, status: :unprocessable_entity\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tbegin\n\t\t\t\tif @task.update(task_params)\n\t\t\t\t\tformat.html { redirect_to @task, notice: 'Task was successfully updated.' }\n\t\t\t\t\tformat.json { render json: @task, status: :ok }\n\t\t\t\telse\n\t\t\t\t\tformat.html { render :edit }\n\t\t\t\t\tformat.json { render json: @task.errors, status: :unprocessable_entity }\n\t\t\t\tend\n\t\t\trescue ActiveRecord::RecordInvalid => error\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: { \"error\": error.message }, status: :ok }\n\t\t\tend\n\t\tend\n\tend", "def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Úkol byl úspěšně upraven.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task = Task.find(params[:id])\n\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n redirect_to(@task)\n else\n render :action => \"edit\"\n end\n end", "def update\n @task = current_user.tasks.find(params[:id])\n if params[:commit] == 'Switch Now'\n @task.switch_now\n params[:task] ||= {}\n params[:task][:stop] = @task.stop\n end\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n @tags = current_user.tags.all\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @task.update(task_params)\n render :show, status: :ok\n else\n render json: @task.errors, status: :unprocessable_entity\n end\n end", "def update\n @task = current_user.tasks.find(params[:id])\n\n respond_with @task do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(tasks_path, :notice => t('messages.updated')) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n @task = Task.find_by(id: params[:id])\n if @task.nil?\n redirect_to tasks_path\n elsif @task.update(\n name: params[:task][:name],\n description: params[:task][:description],\n completed_at: params[:task][:completed_at]\n )\n redirect_to task_path(@task.id)\n else\n render :edit\n end\n end", "def update\n\n if get_case\n @task = @case.tasks.create(task_params)\n path_tasks = case_tasks_path\n else\n path_tasks = tasks_path\n end\n respond_to do |format|\n if @task.update(task_params)\n track_activity @task\n format.html { redirect_to path_tasks, notice: 'Task successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to tasks_path, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: tasks_path }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to tasks_path, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: tasks_path }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: \"Task was successfully updated.\" }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: \"Task was successfully updated.\" }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: \"Task was successfully updated.\" }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: \"Task was successfully updated.\" }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: \"Task was successfully updated.\" }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to @task, notice: t('task.successfully-updated') }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workflow_task = WorkflowTask.find(params[:id])\n\n respond_to do |format|\n if @workflow_task.update_attributes(params[:workflow_task])\n flash[:notice] = 'WorkflowTask was successfully updated.'\n format.html { redirect_to(@workflow_task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @workflow_task.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.66543084", "0.6609352", "0.6608818", "0.65850276", "0.65850276", "0.6576394", "0.65693724", "0.656838", "0.6545663", "0.64219695", "0.6406723", "0.639931", "0.6389918", "0.6383213", "0.6354153", "0.6315247", "0.63002414", "0.62886757", "0.62886757", "0.62886757", "0.62780565", "0.62695336", "0.6262394", "0.6248562", "0.62430763", "0.6240486", "0.6240486", "0.6240486", "0.6240486", "0.6240486", "0.6240486", "0.6240486", "0.6240486", "0.62344265", "0.61936074", "0.6186984", "0.6186352", "0.6185369", "0.6171186", "0.6168244", "0.6157632", "0.61346304", "0.61343443", "0.61253566", "0.6124533", "0.61242497", "0.61160433", "0.61147535", "0.6105362", "0.6082082", "0.6076802", "0.6069394", "0.6068425", "0.6068425", "0.6066735", "0.60631514", "0.60539615", "0.60445184", "0.6039641", "0.6039316", "0.60390544", "0.6030699", "0.60295427", "0.6025788", "0.6024813", "0.6022856", "0.6018749", "0.59854925", "0.5984659", "0.5984054", "0.59836966", "0.59836966", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.5975542", "0.59748626", "0.59748626", "0.59748626", "0.59748626", "0.59748626", "0.59723336", "0.59709966" ]
0.60626566
56
GET /offenses GET /offenses.json
def index @offenses = Offense.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @expenses = find_expenses.all\n render json: @expenses\n end", "def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def index\n @petty_cash_expenses = PettyCashExpense.all\n render json: @petty_cash_expenses\n end", "def index\n @expenses = Expense.all\n respond_with @expenses\n end", "def index\n @api_v1_expenses = Api::V1::Expense.all\n end", "def index\n @expenses = current_user.expenses.date_between(params[:from],params[:to]).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def index\n @office_expenses = OfficeExpense.all\n end", "def show\n @expense = current_user.organization.expenses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @defenses = Defense.all\n end", "def expenses\n @expenses ||= Harvest::API::Expenses.new(credentials)\n end", "def deserialize_offenses(offenses); end", "def index\n @expenses = Expense.all\n end", "def index\n @expenses = Expense.search(params[:search])\n end", "def index\n @expenses = get_class.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def show\n render json: @petty_cash_expense\n end", "def offenses; end", "def offenses; end", "def offenses; end", "def index\n @fixed_expenses = FixedExpense.for_user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fixed_expenses }\n end\n end", "def index\n @livingexpenses = Livingexpense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @livingexpenses }\n end\n end", "def index\n @expenses = current_user.user_account.expenses\n #DZF get totals\n\t\tunless @expenses.blank?\n\t\t\t@expense_total_price = current_user.user_account.get_expenses_total_price\n\t\t\t@expense_total_payed_price = current_user.user_account.get_expenses_total_total_payed_price\n\t\t\t@expense_total_payed_percentage = @expense_total_payed_price / @expense_total_price * 100\n\t\t\t@expense_total_remaining_price = current_user.user_account.get_expenses_total_remaining_price\n\t\t\t#DZF get payers percentage\n\t\t\t@payer_types_totals = {}\n\t\t\tPayerType.all.each do |pt|\n\t\t\t\t@payer_types_totals.merge!({pt.name => (current_user.user_account.get_payer_total_price_by_id(pt.id) * 100 / @expense_total_price) } )\n\t\t\tend\n\t\tend\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def show\n @expenses = @expenses_file.expenses.select(\"strftime('%m', date) as month, strftime('%Y', date) as year, SUM(tax_amount) + SUM(pre_tax_amount) AS total\").\n group('month, year').order('year, month').as_json\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @expenses_props = Expense.all\n end", "def index\n @expenses = Expense.limit(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n end\n end", "def index\n\n # authenticate request\n if auth_user\n\n # check user has data to show\n if Expense.user(@user).count ==0\n render json: { message: \"You have no data - please submit date via a POST request\" }, status: 401\n else\n\n # retrieve paramaters\n # set start and end date to data min/max if not provided \n start_date = params[:start_date].respond_to?(:to_date) ? params[:start_date].to_date : Expense.user(@user).min_by(&:date).date\n end_date = params[:end_date].respond_to?(:to_date) ? params[:end_date].to_date : Expense.user(@user).max_by(&:date).date\n category = params[:category]\n\n # request category if provided (uses scopes defined in Expense model)\n if category == nil\n @expenses = Expense.user(@user).after_date(start_date).before_date(end_date)\n else\n @expenses = Expense.user(@user).after_date(start_date).before_date(end_date).category(category)\n end\n end\n\n else\n # request not authenticated\n return render json: { message: \"Invalid Token\", status: 400}, status: 400\n end\n end", "def index\n @lincenses = Lincense.all\n end", "def index\n @marketing_expenses = MarketingExpense.all\n end", "def index\n @offices = Office.all\n json_response(@offices)\n end", "def index\n @expenses = Expense.all\n # @assets = Asset.all\n @assets = current_user.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n end\n end", "def index\n @expenses = Expense.get_expenses(\n current_user[:id],\n session[:budget]['dateStart'],\n session[:budget]['dateEnd'],\n sort\n )\n\n get_tag_forms\n\n @expenses_sum = calculate_expenses_sum @expenses\n\n get_charts_and_tags @expenses\n end", "def set_offense\n @offense = Offense.find(params[:id])\n end", "def index\n redirect_to home_entries_path\n\n @entries = current_user.entries.expenses\n end", "def index\n @shared_expenses = SharedExpense.all\n end", "def index\n @expenses = Expense.includes(:place, :account, sub_category: :category).order('paid_at DESC').page(params[:page])\n end", "def index\n @rec_expenses = RecExpense.all\n end", "def index\n @offices = Office.where(\"user_id = ?\", current_user).order('created_at DESC').page(params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offices }\n end\n end", "def index\n @record_expenses = RecordExpense.all\n end", "def show\n @expense = current_user.expenses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expense }\n end\n end", "def index\n @offices = Office.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offices }\n end\n end", "def index\n @person_expense_records = PersonExpenseRecord.all\n\n render json: @person_expense_records\n end", "def index\n @offers = Offer.all\n\n render json: @offers\n end", "def show\n @expense = TblReceipt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @expense }\n format.js\n end\n end", "def expense_list\n\n end", "def index\n @expenses = Expense.for_user(current_user).all\n @sum = Expense.for_user(current_user).sum(:price)\n \n respond_to do |format|\n format.html # index.html.erb\n format.iphone {render :layout => false}\n format.xml { render :xml => @expenses }\n end\n end", "def index\n @dispenses = Dispense.all\n end", "def index\n\n if (params[:dossier])\n if params[:dossier] && params[:clear].present? && params[:clear] == 'true'\n @expenses = []\n elsif params[:dossier] && params[:activite_id].present? && params[:activite_id]!='undefined' \n @expenses = Expense.where(:dossier_id => params[:dossier], :activite_id => params[:activite_id])\n else\n @expenses = Expense.where(:dossier_id => params[:dossier])\n end\n else\n @expenses = []\n end\n \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n format.json {render :json => {\"success\"=>true,\"data\"=>@expenses.map {|p| p.attributes.merge(:total_ht => p.total, :total_ttc => p.total_ttc, :activite_name => p.activite.try(:description))}, :totalSize =>@expenses.count}}\n \n end\n end", "def update\n respond_to do |format|\n if @offense.update(offense_params)\n format.html { redirect_to @offense, notice: 'Offense was successfully updated.' }\n format.json { render :show, status: :ok, location: @offense }\n else\n format.html { render :edit }\n format.json { render json: @offense.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n respond_with @expense\n end", "def show\n @expense = Expense.find(params[:id])\n index\n end", "def index\n @bid_expenses = BidExpense.all\n end", "def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def index\n @offices = current_user.offices\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @offices }\n end\n end", "def index\n @expense_owners = ExpenseOwner.all\n end", "def index\n @utility_expenses = UtilityExpense.all\n end", "def index\n @extended_warranties = ExtendedWarranty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @extended_warranties }\n end\n end", "def agency_chart\n if(params[ :year ].nil?)\n params[ :year ] = '2015'\n else\n # Nothing to do.\n end\n expenses_of_public_agency = HelperController.expenses_year( \n params[ :id ].to_i, params[ :year ] )\n expenses_list = change_type_list_expenses( \n expenses_of_public_agency, params[ :year ] )\n\n respond_to do |format|\n format.json { render json: expenses_list }\n end\n end", "def index\n @defense_responses = DefenseResponse.all\n end", "def show\n @admin_expense_type = Admin::ExpenseType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_expense_type }\n end\n end", "def index\n @offers = Offer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end", "def show\n render json: @person_expense_record\n end", "def index\n @expenses_files = ExpensesFile.all\n end", "def show\n @operating_expense = OperatingExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operating_expense }\n end\n end", "def index\n client = find_client(request.headers[\"X-CLIENT-TOKEN\"], request.headers[\"X-CLIENT-EMAIL\"])\n @appointments = client.appointments.includes(:stylist).includes(:offerings).order(\"created_at DESC\")\n respond_to do |f|\n f.json {\n render :json => @appointments\n }\n end\n end", "def index\n @ef_mentals = EfMental.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ef_mentals }\n end\n end", "def index\n @monthly_expenses = MonthlyExpense.all\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def show\n @expense = Expense.for_user(current_user).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expense }\n end\n end", "def index\n if params[:for_applicant]\n @offers = current_user.applicant.offers\n elsif params[:for_positions]\n @offers = []\n current_user.positions.each { |offer| @offers << offer }\n else\n @offers = Offer.all\n end\n\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n end\n end", "def index\n @employees = current_owner.employees.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employees }\n end\n end", "def index\n @holidays = Holiday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @holidays }\n end\n end", "def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def travel_expenses\n expenses.select {|expense| expense.category == \"travel\"}\n end", "def index\n @investigations = Investigation.where(:visible => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @investigations }\n end\n end", "def index\n @opportunities = Opportunity.all\n\n render json: @opportunities\n end", "def show\n json_response(@office)\n end", "def index\n @sells = Sell.all\n\n render json: @sells\n end", "def index\n @recent = Highfive.recent.approved\n @leaders = User.leaders\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @highfives }\n end\n end", "def show\n @expense_state = ExpenseState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense_state }\n end\n end", "def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end", "def index\n @expedientes = Expediente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expedientes }\n end\n end", "def index\n @expenses = Expense.order(sort_column + ' ' + sort_direction).paginate(page: params[:page])\n end", "def index\n if @expense.nil?\n today = Date.today\n year = params[:year].to_i if params[:year]\n month = params[:month].to_i if params[:month]\n \n @date = today\n \n if year && month\n day = today.day\n if year != today.year || month != today.month\n day = 1\n end\n @date = Date.civil(year, month, day)\n end\n else\n @date = @expense.date\n end\n \n @expenses = Expense.by_month(@date)\n \n respond_to do |format|\n format.html { render :action => 'index' }\n format.xml { render :xml => @expenses }\n end\n end", "def show\n p 'show?'\n @acceptances = []\n if(current_user)\n if(params[:id])\n @acceptance = Acceptance.find(params[:id])\n else\n @acceptances = Acceptance.where(\"user_id=? and (status=? or status = ?) and end_time> ?\", current_user.id, \"successfully paid\", \"payment pending\", Time.now())\n end\n end\n p \"acceptances are \"\n \n presenter = Api::V3::AcceptancesPresenter.new\n acceptances_json = @acceptances.map{|x| presenter.as_json(x)}\n p acceptances_json\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: acceptances_json }\n end\n end", "def index\n if params[:event_id].blank?\n @offerings = Offering.all\n else\n @offerings = Offering.find_all_by_event_id params[:event_id]\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offerings }\n end\n end", "def show\n @fixed_expense = FixedExpense.for_user(current_user).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fixed_expense }\n end\n end", "def index\n @granted_scopes = GrantedScope.paginate(:page => params[:page], :per_page => 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @granted_scopes }\n end\n end", "def index\n @ocats = Ocat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ocats }\n end\n end", "def new\n @expense = Expense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @committee_offices = CommitteeOffice.all\n end", "def index\n @depenses = Depense.all\n @total = 0\n @depenses.each do |dep|\n @total += dep.value\n end\n @solde = User.find(1).solde\n end", "def index\n d = Date.today\n @expenses = @household.expenses.monthly_statement(d.month, d.year).order(spent_at: :desc)\n end", "def index\n @investments = Investment.all\n\n render json: {investments: @investments}, root: false\n end" ]
[ "0.75776654", "0.71068573", "0.6749626", "0.6726666", "0.6719622", "0.668571", "0.6649442", "0.6632258", "0.6614437", "0.66078746", "0.66050977", "0.6593806", "0.65027565", "0.64805466", "0.6334884", "0.63270557", "0.63270557", "0.63270557", "0.6317255", "0.63116145", "0.62832344", "0.62582797", "0.6235158", "0.6235158", "0.6235158", "0.6235158", "0.6235158", "0.6225626", "0.61969334", "0.61860996", "0.61722136", "0.61479145", "0.6141123", "0.61131054", "0.6088068", "0.60195404", "0.6006845", "0.5993274", "0.5976476", "0.5971173", "0.59489113", "0.593299", "0.5926091", "0.5918214", "0.5908353", "0.58746994", "0.58595663", "0.5831828", "0.58040786", "0.58025646", "0.57946914", "0.57890123", "0.5788132", "0.577548", "0.57556844", "0.5739518", "0.57392424", "0.5715842", "0.5707357", "0.56949294", "0.56877947", "0.56688553", "0.56673783", "0.56582123", "0.56355816", "0.5620983", "0.55924577", "0.55830765", "0.5573672", "0.5572821", "0.55666125", "0.5559444", "0.5552651", "0.5551358", "0.5539444", "0.5520004", "0.55080074", "0.5491659", "0.5490027", "0.5476345", "0.5475085", "0.547161", "0.54697675", "0.5465303", "0.54590225", "0.5457903", "0.5448364", "0.5447427", "0.5445529", "0.5444962", "0.5440162", "0.5436985", "0.5435984", "0.5435165", "0.543481", "0.54342335", "0.54242915", "0.54230905", "0.5421679", "0.54208976" ]
0.7563574
1
GET /offenses/1 GET /offenses/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @offenses = Offense.all\n end", "def index\n @expenses = find_expenses.all\n render json: @expenses\n end", "def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def index\n @api_v1_expenses = Api::V1::Expense.all\n end", "def show\n @expense = current_user.organization.expenses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @expenses = Expense.all\n respond_with @expenses\n end", "def index\n @petty_cash_expenses = PettyCashExpense.all\n render json: @petty_cash_expenses\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @expenses = Expense.all\n end", "def index\n @defenses = Defense.all\n end", "def index\n @office_expenses = OfficeExpense.all\n end", "def show\n render json: @petty_cash_expense\n end", "def index\n @expenses = get_class.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @expenses = current_user.expenses.date_between(params[:from],params[:to]).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def set_api_v1_expense\n @api_v1_expense = Api::V1::Expense.find(params[:id])\n end", "def set_offense\n @offense = Offense.find(params[:id])\n end", "def expenses\n @expenses ||= Harvest::API::Expenses.new(credentials)\n end", "def deserialize_offenses(offenses); end", "def index\n @expenses = Expense.limit(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n end\n end", "def index\n @expenses = Expense.search(params[:search])\n end", "def offenses; end", "def offenses; end", "def offenses; end", "def index\n @fixed_expenses = FixedExpense.for_user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fixed_expenses }\n end\n end", "def index\n @livingexpenses = Livingexpense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @livingexpenses }\n end\n end", "def show\n @expense = current_user.expenses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n index\n end", "def show\n @expense = TblReceipt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @expenses_props = Expense.all\n end", "def index\n @lincenses = Lincense.all\n end", "def index\n @offices = Office.all\n json_response(@offices)\n end", "def index\n @expenses = current_user.user_account.expenses\n #DZF get totals\n\t\tunless @expenses.blank?\n\t\t\t@expense_total_price = current_user.user_account.get_expenses_total_price\n\t\t\t@expense_total_payed_price = current_user.user_account.get_expenses_total_total_payed_price\n\t\t\t@expense_total_payed_percentage = @expense_total_payed_price / @expense_total_price * 100\n\t\t\t@expense_total_remaining_price = current_user.user_account.get_expenses_total_remaining_price\n\t\t\t#DZF get payers percentage\n\t\t\t@payer_types_totals = {}\n\t\t\tPayerType.all.each do |pt|\n\t\t\t\t@payer_types_totals.merge!({pt.name => (current_user.user_account.get_payer_total_price_by_id(pt.id) * 100 / @expense_total_price) } )\n\t\t\tend\n\t\tend\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def show\n @expenses = @expenses_file.expenses.select(\"strftime('%m', date) as month, strftime('%Y', date) as year, SUM(tax_amount) + SUM(pre_tax_amount) AS total\").\n group('month, year').order('year, month').as_json\n end", "def index\n @expenses = Expense.all\n # @assets = Asset.all\n @assets = current_user.assets\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n end\n end", "def show\n @admin_expense_type = Admin::ExpenseType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_expense_type }\n end\n end", "def index\n @offices = Office.where(\"user_id = ?\", current_user).order('created_at DESC').page(params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offices }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @expense }\n format.js\n end\n end", "def index\n @offices = Office.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offices }\n end\n end", "def index\n @shared_expenses = SharedExpense.all\n end", "def show\n @operating_expense = OperatingExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operating_expense }\n end\n end", "def show\n respond_with @expense\n end", "def index\n @marketing_expenses = MarketingExpense.all\n end", "def index\n\n # authenticate request\n if auth_user\n\n # check user has data to show\n if Expense.user(@user).count ==0\n render json: { message: \"You have no data - please submit date via a POST request\" }, status: 401\n else\n\n # retrieve paramaters\n # set start and end date to data min/max if not provided \n start_date = params[:start_date].respond_to?(:to_date) ? params[:start_date].to_date : Expense.user(@user).min_by(&:date).date\n end_date = params[:end_date].respond_to?(:to_date) ? params[:end_date].to_date : Expense.user(@user).max_by(&:date).date\n category = params[:category]\n\n # request category if provided (uses scopes defined in Expense model)\n if category == nil\n @expenses = Expense.user(@user).after_date(start_date).before_date(end_date)\n else\n @expenses = Expense.user(@user).after_date(start_date).before_date(end_date).category(category)\n end\n end\n\n else\n # request not authenticated\n return render json: { message: \"Invalid Token\", status: 400}, status: 400\n end\n end", "def index\n redirect_to home_entries_path\n\n @entries = current_user.entries.expenses\n end", "def index\n @rec_expenses = RecExpense.all\n end", "def index\n @expenses = Expense.includes(:place, :account, sub_category: :category).order('paid_at DESC').page(params[:page])\n end", "def index\n @person_expense_records = PersonExpenseRecord.all\n\n render json: @person_expense_records\n end", "def index\n @record_expenses = RecordExpense.all\n end", "def index\n @dispenses = Dispense.all\n end", "def update\n respond_to do |format|\n if @offense.update(offense_params)\n format.html { redirect_to @offense, notice: 'Offense was successfully updated.' }\n format.json { render :show, status: :ok, location: @offense }\n else\n format.html { render :edit }\n format.json { render json: @offense.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @offers = Offer.all\n\n render json: @offers\n end", "def show\n @expense = Expense.for_user(current_user).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expense }\n end\n end", "def index\n\n if (params[:dossier])\n if params[:dossier] && params[:clear].present? && params[:clear] == 'true'\n @expenses = []\n elsif params[:dossier] && params[:activite_id].present? && params[:activite_id]!='undefined' \n @expenses = Expense.where(:dossier_id => params[:dossier], :activite_id => params[:activite_id])\n else\n @expenses = Expense.where(:dossier_id => params[:dossier])\n end\n else\n @expenses = []\n end\n \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n format.json {render :json => {\"success\"=>true,\"data\"=>@expenses.map {|p| p.attributes.merge(:total_ht => p.total, :total_ttc => p.total_ttc, :activite_name => p.activite.try(:description))}, :totalSize =>@expenses.count}}\n \n end\n end", "def show\n @expense_state = ExpenseState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense_state }\n end\n end", "def show\n render json: @person_expense_record\n end", "def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def index\n @offices = current_user.offices\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @offices }\n end\n end", "def show\n @housing_expense = HousingExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @housing_expense.to_xml }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expense }\n end\n end", "def show\n @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @opinion }\n end\n end", "def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end", "def index\n @expense_owners = ExpenseOwner.all\n end", "def show\n @officer = Officer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @officer }\n end\n end", "def index\n @bid_expenses = BidExpense.all\n end", "def show\n @fixed_expense = FixedExpense.for_user(current_user).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fixed_expense }\n end\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def index\n @expenses = Expense.for_user(current_user).all\n @sum = Expense.for_user(current_user).sum(:price)\n \n respond_to do |format|\n format.html # index.html.erb\n format.iphone {render :layout => false}\n format.xml { render :xml => @expenses }\n end\n end", "def show\n @officer = Officer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @officer }\n end\n end", "def show\n @livingexpense = Livingexpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @livingexpense }\n end\n end", "def show\n p 'show?'\n @acceptances = []\n if(current_user)\n if(params[:id])\n @acceptance = Acceptance.find(params[:id])\n else\n @acceptances = Acceptance.where(\"user_id=? and (status=? or status = ?) and end_time> ?\", current_user.id, \"successfully paid\", \"payment pending\", Time.now())\n end\n end\n p \"acceptances are \"\n \n presenter = Api::V3::AcceptancesPresenter.new\n acceptances_json = @acceptances.map{|x| presenter.as_json(x)}\n p acceptances_json\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: acceptances_json }\n end\n end", "def index\n @offers = Offer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end", "def index\n @utility_expenses = UtilityExpense.all\n end", "def show\n @competency = Competency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competency }\n end\n end", "def new\n @expense = Expense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expense }\n end\n end", "def update\n respond_to do |format|\n if @api_v1_expense.update(api_v1_expense_params)\n format.html { redirect_to @api_v1_expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_expense }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @audit = current_user.audits.find(params[:id])\n @findings= @audit.findings.paginate(:page => params[:page], :per_page => 7).order('id DESC')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @audit }\n \n end\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 index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end", "def index\n client = find_client(request.headers[\"X-CLIENT-TOKEN\"], request.headers[\"X-CLIENT-EMAIL\"])\n @appointments = client.appointments.includes(:stylist).includes(:offerings).order(\"created_at DESC\")\n respond_to do |f|\n f.json {\n render :json => @appointments\n }\n end\n end", "def index\n @extended_warranties = ExtendedWarranty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @extended_warranties }\n end\n end", "def index\n @expenses_files = ExpensesFile.all\n end", "def show\n #@appointment = Appointment.find(params[:id])\n @conversation = Conversation.find(@appointment.conversation_id)\n @conversation.mark_as_read(current_user)\n @subtotal = @appointment.fee * (@appointment.length.to_f/60)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @appointment }\n end\n end", "def index\n @applicants = Applicant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @applicants }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @expense.to_xml }\n end\n end", "def index\n @expenses = Expense.get_expenses(\n current_user[:id],\n session[:budget]['dateStart'],\n session[:budget]['dateEnd'],\n sort\n )\n\n get_tag_forms\n\n @expenses_sum = calculate_expenses_sum @expenses\n\n get_charts_and_tags @expenses\n end", "def show\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exprience }\n end\n end", "def show\n json_response(@office)\n end", "def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end", "def index\n @ocats = Ocat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ocats }\n end\n end", "def show\n @accounting_office = AccountingOffice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @accounting_office }\n end\n end", "def index\n @defense_responses = DefenseResponse.all\n end", "def show\n @withdrawal = Withdrawal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @withdrawal }\n end\n end", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def expense_list\n\n end" ]
[ "0.7490258", "0.7310726", "0.70116097", "0.6912074", "0.6810443", "0.6602823", "0.65834475", "0.65461856", "0.65461856", "0.65461856", "0.65461856", "0.65461856", "0.6539045", "0.6491504", "0.6447113", "0.63997185", "0.63898754", "0.63524115", "0.63280684", "0.6317086", "0.63149774", "0.6259868", "0.6256885", "0.62456316", "0.6216364", "0.6198006", "0.6198006", "0.6198006", "0.6175333", "0.6171086", "0.61669135", "0.61537474", "0.6125195", "0.61083364", "0.6098411", "0.6097913", "0.60789627", "0.60470915", "0.6026036", "0.60120904", "0.60095954", "0.6003532", "0.5981681", "0.5969775", "0.5942565", "0.5935411", "0.59305644", "0.5921241", "0.5917096", "0.59145224", "0.5909543", "0.58960253", "0.58596164", "0.58557045", "0.58396715", "0.58353037", "0.5830235", "0.5825158", "0.5816822", "0.5814669", "0.57922596", "0.5772117", "0.57560354", "0.57515776", "0.57515776", "0.57515776", "0.57432085", "0.57328707", "0.5710712", "0.57095045", "0.57031876", "0.56981695", "0.5697497", "0.5693481", "0.56820357", "0.56820023", "0.56791824", "0.567472", "0.56645507", "0.5661358", "0.5653237", "0.56453514", "0.5639333", "0.56376934", "0.563562", "0.56312877", "0.56073666", "0.55939484", "0.5590667", "0.5589634", "0.55894893", "0.55840695", "0.5583417", "0.557818", "0.55754215", "0.5570627", "0.557032", "0.5565488", "0.5564649", "0.5563883", "0.5563544" ]
0.0
-1
POST /offenses POST /offenses.json
def create host_name = begin Resolv.getname(request.ip) rescue Resolv::ResolvError end || 'n/a' params[:offense].merge!({:ip_address => request.ip, :host_name => host_name}) @offense = Offense.new(offense_params) respond_to do |format| if @offense.save if @offense.email? self.email end if @offense.phone? self.sms end format.html { redirect_to @offense, notice: 'Offense was successfully created.' } format.json { render :show, status: :created, location: @offense } else format.html { render :new } format.json { render json: @offense.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @expense = Expense.new(expense_params)\n\n if @expense.save\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end", "def create\n # Get the variables passed in from params on create\n @expense = Expense.new(expense_params)\n\n if @expense.save\n render json: @expense, status: :created, location: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end", "def deserialize_offenses(offenses); end", "def create\n\t\tuser = User.find_by(id: expense_params['user_id'])\n\t\tdebt = Debt.find_by(id: expense_params['debt_id'])\n\t\texpense = user.expenses.build(expense_params)\n\t\tif expense.save \n\t\t\tif debt\n\t\t\t\tdebt.expenses << expense\n\t\t\tend\n\t\t\trender json: user\n\t\telse\n\t\t\trender json: expense.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def create\n data = params[:expense]\n\n @expense = current_user.expenses.build(params[:expense])\n if @expense.save\n flash[:success] = \"Expense created!\"\n redirect_to root_url\n else\n format.html { render action: \"new\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n #@expense = Expense.new(params[:expense])\n #\n #respond_to do |format|\n # if @expense.save\n # format.html { redirect_to @expense, notice: 'Expense was successfully created.' }\n # format.json { render json: @expense, status: :created, location: @expense }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @expense.errors, status: :unprocessable_entity }\n # end\n #end\n end", "def create\n @solideo_depense = SolideoDepense.new(solideo_depense_params)\n\n respond_to do |format|\n if @solideo_depense.save\n format.html { redirect_to solideo_depenses_path, notice: 'Solideo depense was successfully created.' }\n format.json { render :show, status: :created, location: @solideo_depense }\n else\n format.html { render :new }\n format.json { render json: @solideo_depense.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @offenses = Offense.all\n end", "def create\n\n @expense = Expense.new(expense_params)\n\n b_id = Building.search(@expense.buildinginfo)\n Building.find_by(id: b_id).expenses << @expense\n \n respond_to do |format|\n if @expense.save\n format.html { redirect_to @expense, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense_owner = ExpenseOwner.new(expense_owner_params)\n\n respond_to do |format|\n if @expense_owner.save\n format.html { redirect_to @expense_owner, notice: 'Expense owner was successfully created.' }\n format.json { render :show, status: :created, location: @expense_owner }\n else\n format.html { render :new }\n format.json { render json: @expense_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_v1_expense = Api::V1::Expense.new(api_v1_expense_params)\n\n respond_to do |format|\n if @api_v1_expense.save\n format.html { redirect_to @api_v1_expense, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_expense }\n else\n format.html { render :new }\n format.json { render json: @api_v1_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(expense_params)\n\n respond_to do |format|\n if @expense.save\n format.html { redirect_to @expense, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.create(expense_params)\n @expense.user_id = current_user.id\n @expense.save!\n respond_with @expense, status: 201\n end", "def index\n @expenses = find_expenses.all\n render json: @expenses\n end", "def set_offense\n @offense = Offense.find(params[:id])\n end", "def create\n @operating_expense = OperatingExpense.new(params[:operating_expense])\n\n respond_to do |format|\n if @operating_expense.save\n format.html { redirect_to(@operating_expense, :notice => 'Operating expense was successfully created.') }\n format.xml { render :xml => @operating_expense, :status => :created, :location => @operating_expense }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @operating_expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @petty_cash_expense = PettyCashExpense.new(petty_cash_expense_params)\n\n respond_to do |format|\n if @petty_cash_expense.save\n format.json { render :show, status: :created, location: @petty_cash_expense }\n else\n format.json { render json: @petty_cash_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(expense_params)\n authorize @expense\n @expense.created_by = current_user\n @expense.expense_by = current_user unless policy(@expense).can_assign?\n respond_to do |format|\n if @expense.save\n format.html { redirect_back_or_default expenses_url, t('Record has been saved') }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(expense_params)\n @expense.user_id = current_user.id\n \n respond_to do |format|\n if @expense.save\n format.html { redirect_to @expense, notice: 'Expense was successfully created.' }\n format.json { render action: 'show', status: :created, location: @expense }\n else\n format.html { render action: 'new' }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @expense = Expense.new(params[:expense])\n @expense.user = current_user\n\n respond_to do |format|\n if @expense.save\n format.json { render json: @expense, status: :created, location: @expense }\n format.js\n else\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @marketing_expense = MarketingExpense.new(marketing_expense_params)\n\n respond_to do |format|\n if @marketing_expense.save\n format.html { redirect_to @marketing_expense, notice: 'Marketing expense was successfully created.' }\n format.json { render :show, status: :created, location: @marketing_expense }\n else\n format.html { render :new }\n format.json { render json: @marketing_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def office_expense_params\n params.require(:office_expense).permit(:expense_type, :description, :amount, :user_id)\n end", "def create\n @expense = Expense.new(expense_params)\n\n respond_to do |format|\n puts \"********* creating an expense\"\n if @expense.save\n puts \"** expense saved\"\n puts @expense.id.to_s\n format.html { redirect_to @expense, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n puts \"** expense not saved\"\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @offense.update(offense_params)\n format.html { redirect_to @offense, notice: 'Offense was successfully updated.' }\n format.json { render :show, status: :ok, location: @offense }\n else\n format.html { render :edit }\n format.json { render json: @offense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @defense = Defense.new(defense_params)\n\n respond_to do |format|\n if @defense.save\n format.html { redirect_to @defense, notice: 'Defense was successfully created.' }\n format.json { render :show, status: :created, location: @defense }\n else\n format.html { render :new }\n format.json { render json: @defense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @shared_expense = SharedExpense.new(shared_expense_params)\n\n respond_to do |format|\n if @shared_expense.save\n format.html { redirect_to root_url, notice: 'Shared expense was successfully created.' }\n format.json { render :show, status: :created, location: @shared_expense }\n else\n format.html { render :new }\n format.json { render json: @shared_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(params[:expense])\n\t\[email protected]_account_id = current_user.user_account.id\n\t\t\n respond_to do |format|\n if @expense.save\n\t\t\t\tif @expense.wants_points\n\t\t\t\t\tNoticeMailer.matriclick_points_email(current_user, @expense).deliver\n\t\t\t\t\tformat.html {redirect_to points_url, notice: \"Ya tenemos el gasto que acabas de ingresar. Te enviaremos un email luego de validar tus puntos.\"}\n\t\t\t\telse\n format.html { redirect_to expenses_url, notice: 'Expense was successfully created.' }\n\t\t\t\tend\n else\n format.html { render action: \"new\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rec_expense = RecExpense.new(rec_expense_params)\n\n respond_to do |format|\n if @rec_expense.save\n format.html { redirect_to @rec_expense, notice: 'Rec expense was successfully created.' }\n format.json { render :show, status: :created, location: @rec_expense }\n else\n format.html { render :new }\n format.json { render json: @rec_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(expense_params)\n @expense.source = :webapp\n respond_to do |format|\n if @expense.save\n format.html { redirect_to :back, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(params[:expense])\n\n respond_to do |format|\n if @expense.save\n format.html { redirect_to(@expense, :notice => 'Expense was successfully created.') }\n format.xml { render :xml => @expense, :status => :created, :location => @expense }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(expense_params)\n\n respond_to do |format|\n if @expense.save\n if !params[:expense_category].blank?\n category = ExpenseCategory.find_by name: params[:expense_category]\n if !category.nil?\n @expense.update(expense_category: category)\n if params[:expense_category] == \"Diesel\"\n company = DieselCompany.find(params[:diesel_company])\n DieselExpense.create! expense: @expense, diesel_company: company, litres: @expense.quantity\n end\n end\n # cash = Cash.today.first\n # cash.update(amount_out: (cash.amount_out + @expense.amount), balance: (cash.balance - @expense.amount))\n end\n format.html { redirect_to expenses_path, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def offenses; end", "def offenses; end", "def offenses; end", "def create\n\n # authenticate request\n if auth_user\n\n #check we have everything we need!\n if params[:date] && params[:amount] && params[:category] && valid_date? && valid_amount?\n @new_expense = Expense.create(category: params[:category], date: params[:date], amount: params[:amount], user_id: @user.id)\n render json: { message: \"Good going! You made an expense for $#{params[:amount]}\", object: @new_expense }, status: 200\n else\n # tell user what they haven't provided correctly\n whats_not_supplied(params) \n end\n\n else\n # request not authenticated\n return render json: { message: \"Invalid Token\", status: 400}, status: 400\n end\n\n end", "def create\n @dog_expense = DogExpense.new(dog_expense_params)\n\n respond_to do |format|\n if @dog_expense.save\n format.html { redirect_to @dog_expense, notice: 'Dog expense was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dog_expense }\n else\n format.html { render action: 'new' }\n format.json { render json: @dog_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(params[:expense])\n\n respond_to do |format|\n if @expense.save\n flash[:notice] = 'Expense was successfully created.'\n format.html { redirect_to expense_url(@expense) }\n format.xml { head :created, :location => expense_url(@expense) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @expense.errors.to_xml }\n end\n end\n end", "def create\n @record_expense = RecordExpense.new(record_expense_params)\n\n respond_to do |format|\n if @record_expense.save\n format.html { redirect_to @record_expense, notice: 'New expense successfully created.' }\n format.json { render :show, status: :created, location: @record_expense }\n else\n format.html { render :new }\n format.json { render json: @record_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:code, :gasto_id, :documento, :descrip, :importe, :fecha, :document_id,:turno)\n end", "def create\n recurring = params[:expense].delete(:recurring)\n statement = Statement.find(params[:statement_id])\n @expense = Expense.new(params[:expense])\n @expense.statement = statement\n @expense.recurring = recurring\n\n respond_to do |format|\n if @expense.save\n format.html { redirect_to @expense.statement, notice: 'Statement expense was successfully created.' }\n format.json { render json: @expense, status: :created, location: @expense }\n else\n format.html { render action: \"new\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:user_id, :date, :reseller, :item_or_service, :payment_form, :charged_to, :cost, :amount_from_budget, :notes, :document)\n end", "def create\n @fixed_expense = FixedExpense.new(params[:fixed_expense])\n @fixed_expense.user_id = current_user.id\n\n respond_to do |format|\n if @fixed_expense.save\n flash[:notice] = 'FixedExpense was successfully created.'\n format.html { redirect_to(fixed_expenses_path) }\n format.xml { render :xml => @fixed_expense, :status => :created, :location => @fixed_expense }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fixed_expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:description, :comment, :amount, :datetime)\n end", "def create\n @offices = Office.create!(office_params)\n json_response(@offices, :created)\n end", "def create\n @bid_expense = BidExpense.new(bid_expense_params)\n\n respond_to do |format|\n if @bid_expense.save\n format.html { redirect_to bid_expenses_path, notice: 'Bid expense was successfully created.' }\n format.json { render :show, status: :created, location: @bid_expense }\n else\n format.html { render :new }\n format.json { render json: @bid_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:date, :description, :amount, :category_id)\n end", "def create\n @expense = Expense.new(expense_params)\n if @expense.date == nil\n @expense.date = Time.now\n end\n\n @user = User.all.first\n if @expense.gains\n @user.current_balance = @user.current_balance + @expense.amount\n else\n @user.current_balance = @user.current_balance - @expense.amount\n end\n @user.save\n\n respond_to do |format|\n if @expense.save\n format.html { redirect_to '/expenses', notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:amount, :to, :note, :category_id, :subcategory_id, :date, :tag_list)\n end", "def new_offense(message)\n offense = Offense.new\n offense.message = message\n @linter.offenses << offense\n @linter.offense_count += 1\n offense\n end", "def create\n @name_expense = NameExpense.new(name_expense_params)\n\n respond_to do |format|\n if @name_expense.save\n format.html { redirect_to @name_expense, notice: 'Name expense was successfully created.' }\n format.json { render :show, status: :created, location: @name_expense }\n else\n format.html { render :new }\n format.json { render json: @name_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(expense_params)\n if @expense.save\n\t flash[:success] = \"Expense record created\"\n redirect_to @expense\n else\n render 'new'\n end\n end", "def create\n @person_expense_record = PersonExpenseRecord.new(person_expense_record_params)\n\n if @person_expense_record.save\n render json: @person_expense_record, status: :created, location: @person_expense_record\n else\n render json: @person_expense_record.errors, status: :unprocessable_entity\n end\n end", "def create\n @admin_expense_type = Admin::ExpenseType.new(params[:admin_expense_type])\n\n respond_to do |format|\n if @admin_expense_type.save\n format.html { redirect_to admin_expense_types_url }\n format.json { render json: @admin_expense_type, status: :created, location: @admin_expense_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_expense_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:amount, :description, :spent_at)\n end", "def create\n @monthly_expense = MonthlyExpense.new(monthly_expense_params)\n\n respond_to do |format|\n if @monthly_expense.save\n format.html { redirect_to @monthly_expense, notice: \"Monthly expense was successfully created.\" }\n format.json { render :show, status: :created, location: @monthly_expense }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @monthly_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @housing_expense = HousingExpense.new(params[:housing_expense])\n\n respond_to do |format|\n if @housing_expense.save\n flash[:notice] = 'HousingExpense was successfully created.'\n format.html { redirect_to housing_expense_url(@housing_expense) }\n format.xml { head :created, :location => housing_expense_url(@housing_expense) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @housing_expense.errors.to_xml }\n end\n end\n end", "def create\n @etat_depense = EtatDepense.new(etat_depense_params)\n @etat_depense.date = @etat_depense.date.change(month: 1, day: 1)\n respond_to do |format|\n if @etat_depense.save\n format.html { redirect_to etat_depenses_path, notice: 'Etat depense was successfully created.' }\n format.json { render :show, status: :created, location: @etat_depense }\n else\n format.html { render :new }\n format.json { render json: @etat_depense.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:description, :amount, :user_sub, :category_id, :title, :date)\n end", "def expense_params\n params.require(:expense).permit :name, :amount, :date, :account_id, :category_id\n end", "def create\n @expense_type = ExpenseType.new(expense_type_params)\n\n respond_to do |format|\n if @expense_type.save\n format.html { redirect_to @expense_type, notice: 'Expense type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @expense_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @expense_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @petty_cash_expenses = PettyCashExpense.all\n render json: @petty_cash_expenses\n end", "def new\n @expense = Expense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expense }\n end\n end", "def create\n @expense = Expense.new(expense_params)\n @gastos = Gasto.all \n @documents = Document.all\n \n respond_to do |format|\n if @expense.save\n @expense.correlativo\n \n format.html { redirect_to @expense, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense = Expense.new(params[:expense])\n if params[:expense][:item_id].present?\n @expense.categorie_id = Item.find(params[:expense][:item_id]).categorie_id\n end\n @expense.dossier_id = params[:dossier]\n \n if params[:activite_id].present?\n @expense.activite_id = params[:activite_id]\n end\n \n @expense.save\n respond_to do |format|\n format.json { render :json => { :success => true, :message => \"Created Expense #{@expense.id}\", :data => @expense.attributes.merge(:total_ht => @expense.total, :total_ttc => @expense.total_ttc, :activite_name => @expense.activite.try(:description))}}\n end\n \n end", "def update\n @expense = Expense.find params.fetch(:id)\n\n if @expense.update(expense_params)\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end", "def new\n @expense = Expense.new\n @assigned_categories = \"\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expense }\n end\n end", "def create\n @office_expense = OfficeExpense.new(office_expense_params)\n\n respond_to do |format|\n if @office_expense.save\n User.all.each do |user|\n ExpenseMailer.expense_added_mail(@office_expense, user).deliver\n end\n format.html { redirect_to @office_expense, notice: 'Office expense was successfully created.' }\n format.json { render :show, status: :created, location: @office_expense }\n else\n format.html { render :new }\n format.json { render json: @office_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @utility_expense = UtilityExpense.new(utility_expense_params)\n\n respond_to do |format|\n if @utility_expense.save\n format.html { redirect_to @utility_expense, notice: 'Utility expense was successfully created.' }\n format.json { render :show, status: :created, location: @utility_expense }\n else\n format.html { render :new }\n format.json { render json: @utility_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def offense_params\n params.require(:offense).permit(:ip_address, :host_name, :email, :phone)\n end", "def expense_params\n params.require(:expense).permit(:user_id, :amount, :created_at, :description, category_ids: [])\n end", "def expense_params\n params.require(:expense).permit(:incurred_date, :reimbursed_date, \n :user_id, :account_id, :supplier, :description, :without_vat, \n :vat, :with_vat, :is_mileage, :miles, :mileage_rate, :expense,\n :cost_centre_id, :is_checked)\n end", "def expense_params\n params.require(:expense).permit(:name, :amount)\n end", "def set_office_expense\n @office_expense = OfficeExpense.find(params[:id])\n end", "def create\n @expense = Expense.new(params[:expense])\n @workflow = Workflow.find(params[:wid])\n\n respond_to do |format|\n if @expense.save\n @workflow.expense=@expense\n @workflow.update_attributes(:status => \"finished\")\n @workflow.repairmen.each do |re|\n re.user.update_attributes(:status => 'idle')\n end\n format.html { redirect_to workflow_flow_workflows_path, notice: 'Expense was successfully created.' }\n format.json { render :json => @expense, :status => :created }\n else\n #format.html { render action: \"new\" }\n format.json { render :json => @expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n expense_details = expense_params\n\n expense_details[:amount] = correct_value(expense_details[:amount])\n\n @expense = Expense.new(expense_details)\n\n if @expense.save\n\n association = {\n :expense_id => @expense[:id],\n :tag_id => tag_params[:id],\n }\n\n expense_tag_association = ExpensesTagsAssociation.new(association)\n expense_tag_association.save\n\n redirect_to expenses_path, notice: (I18n.t 'Expense was successfully created.')\n else\n render action: \"new\"\n end\n end", "def index\n @office_expenses = OfficeExpense.all\n end", "def expenses\n @expenses ||= Harvest::API::Expenses.new(credentials)\n end", "def create\n @expense = @current_user.expenses.create(params[:expense])\n params[:expense][:categories].each do |category_id|\n category_id = category_id.to_i\n if category_id > 0\n @expense.categories << Category.find(category_id)\n end\n end\n respond_to do |format|\n if @expense.save\n flash[:notice] = 'Expense was successfully created.'\n format.html { redirect_to(@expense) }\n format.xml { render :xml => @expense, :status => :created, :location => @expense }\n format.iphone { redirect_to(@expense) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n format.iphone { render :action => \"new\" }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:exp_date, :amt, :profile_id, :item_id)\n end", "def create\n userID = session[:user_id]\n editionID = params[:edition_id]\n price = params[:price]\n\n uri = URI(\"http://107.170.7.58:4567/api/create/sell\")\n parameters = {\"ext\" => \"json\", \"user_id\" => userID, \"edition_id\" => editionID, \"price\" => price, \"start_date\" => Time.now, \"end_date\" => 90.days.from_now}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end", "def expense_params\n params.require(:expense).permit(:expenses_date, :item_wise, :expenses_type, :expenses_code, :amount, :gst_number, :vendor_invoice_number, :remarks, :expenses_number, :expense_category_id, :gst_treatment_id, :place_of_supply_id, :tax_id, :customer_company_id, :document_id, expense_items_attributes: [:id, :expense_type, :expense_code, :particular, :description, :amount, :tax_id, :expense_id, :expense_category_id ])\n end", "def create\n @expense_tracker = ExpenseTracker.new(expense_tracker_params)\n\n respond_to do |format|\n if @expense_tracker.save\n format.html { redirect_to @expense_tracker, notice: 'Expense tracker was successfully created.' }\n format.json { render :show, status: :created, location: @expense_tracker }\n else\n format.html { render :new }\n format.json { render json: @expense_tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def solideo_depense_params\n params.require(:solideo_depense).permit(:date, :ouvrages, :reserve, :fonctionnement, :innovation)\n end", "def create\n @offering = current_user.offerings.new(offering_params)\n @offering.status = 1\n respond_to do |format|\n if @offering.save\n format.html { redirect_to @offering, notice: 'La oferta de servicio ha sido creada correctamente.' }\n format.json { render :show, status: :created, location: @offering }\n else\n format.html { render :new }\n format.json { render json: @offering.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:expenseDate, :Description, :category_id, :user_id, :splitWith => {})\n end", "def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end", "def index\n @defenses = Defense.all\n end", "def expense_params\n params.require(:expense).permit(:expense, :cost, :category_id, :amount, :gains, :date, :descripton)\n end", "def index\n @api_v1_expenses = Api::V1::Expense.all\n end", "def depense_params\n params.require(:depense).permit(:title, :value, :date, :checked)\n end", "def create\n @expense = Expense.new(params[:expense])\n @expense.user_id = current_user.id\n\n respond_to do |format|\n if @expense.save\n flash[:notice] = 'Expense was successfully created.'\n format.html { redirect_to(expenses_path) }\n format.iphone { redirect_to(expenses_path) }\n format.xml { render :xml => @expense, :status => :created, :location => @expense }\n else\n format.html { render :action => \"new\" }\n format.iphone { render :action => \"new\", :layout => false }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @depense = Depense.new(depense_params)\n\n respond_to do |format|\n if @depense.save\n format.html { redirect_to @depense, notice: 'Depense was successfully created.' }\n format.json { render :show, status: :created, location: @depense }\n me = User.find(1)\n me.solde = me.solde - @depense.value\n me.save\n else\n format.html { render :new }\n format.json { render json: @depense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @proof_sale = ProofSale.new(proof_sale_params)\n\n respond_to do |format|\n if @proof_sale.save\n format.html { redirect_to @proof_sale, notice: 'Proof sale was successfully created.' }\n format.json { render :show, status: :created, location: @proof_sale }\n else\n format.html { render :new }\n format.json { render json: @proof_sale.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @defense_response = DefenseResponse.new(defense_response_params)\n\n respond_to do |format|\n if @defense_response.save\n format.html { redirect_to @defense_response, notice: 'Defense response was successfully created.' }\n format.json { render :show, status: :created, location: @defense_response }\n else\n format.html { render :new }\n format.json { render json: @defense_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @accident_assignee_expense = AccidentAssigneeExpense.new(params[:accident_assignee_expense])\n\n respond_to do |format|\n if @accident_assignee_expense.save\n format.html { redirect_to(@accident_assignee_expense, :notice => 'Accident assignee expense was successfully created.') }\n format.xml { render :xml => @accident_assignee_expense, :status => :created, :location => @accident_assignee_expense }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @accident_assignee_expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n params[:refill_type] = params[:refill_type].to_i\n params[:status] = params[:status].to_i\n params[:cost_basis] = params[:cost_basis].to_i\n params[:other_coverage_code] = params[:other_coverage_code].to_i\n params[:reason_for_delay] = params[:reason_for_delay].to_i\n params[:partial_fill_status] = params[:partial_fill_status].to_i\n params[:reported_to_pmp] = params[:reported_to_pmp].to_i\n\n @dispense = Dispense.new(dispense_params)\n\n respond_to do |format|\n if @dispense.save\n format.html { redirect_to @dispense, notice: 'Dispense was successfully created.' }\n format.json { render :show, status: :created, location: @dispense }\n else\n format.html { render :new }\n format.json { render json: @dispense.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(\n :direction,\n :title,\n :amount,\n :company,\n :facility,\n :expense_category_id,\n :expense_by_id,\n :expense_to_id,\n :expense_date,\n :created_by_id,\n :updated_by_id\n )\n end", "def index\n @expenses = Expense.all\n end", "def create\n @offering = Offering.new(params[:offering])\n @offering.event_id = params[:event_id]\n @offering.user_id = current_user.id\n\n respond_to do |format|\n if @offering.save\n format.html { redirect_to @offering, notice: 'Oferta criada com sucesso.' }\n format.json { render json: @offering, status: :created, location: @offering }\n else\n format.html { render action: \"new\" }\n format.json { render json: @offering.errors, status: :unprocessable_entity }\n end\n end\n end", "def expense_params\n params.require(:expense).permit(:description, :category_id)\n end", "def create\n @food_expenditure = FoodExpenditure.new(food_expenditure_params)\n\n respond_to do |format|\n if @food_expenditure.save\n current_user.food_expenditures << @food_expenditure\n @food_expenditure.update_user_accounts(current_user)\n format.html { redirect_to @food_expenditure, notice: 'FoodExpenditure was successfully created.' }\n format.json { render :show, status: :created, location: @food_expenditure }\n else\n format.html { render :new }\n format.json { render json: @food_expenditure.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.64397866", "0.6335863", "0.62904537", "0.62583876", "0.6209672", "0.6144524", "0.61436576", "0.6135067", "0.61191994", "0.60927397", "0.6092162", "0.5972164", "0.5953867", "0.5947", "0.59128845", "0.58974355", "0.58756137", "0.5847546", "0.58367676", "0.58366776", "0.57520366", "0.5749165", "0.57325864", "0.56927395", "0.5690803", "0.5658961", "0.5655777", "0.5645901", "0.56458235", "0.5620994", "0.5600953", "0.5600685", "0.5600685", "0.5600685", "0.5593122", "0.55914843", "0.55794615", "0.55784035", "0.5575347", "0.5572432", "0.5562014", "0.5556807", "0.5539054", "0.5537857", "0.5534759", "0.55270594", "0.5523634", "0.55205274", "0.5514184", "0.551207", "0.5509755", "0.5501933", "0.549733", "0.548376", "0.5472505", "0.54718244", "0.5460027", "0.5458966", "0.5449547", "0.54486364", "0.54429114", "0.5438716", "0.5432165", "0.5429212", "0.5413017", "0.54050374", "0.5386646", "0.53785235", "0.5367143", "0.5365789", "0.53603286", "0.5358763", "0.53518325", "0.534683", "0.5344699", "0.533537", "0.53273976", "0.5324145", "0.53223705", "0.53084767", "0.53079736", "0.5303959", "0.53017193", "0.5297366", "0.5288585", "0.5282917", "0.5277577", "0.527442", "0.5274369", "0.5274182", "0.52690953", "0.52631474", "0.52621275", "0.52614367", "0.52609545", "0.5257562", "0.5246951", "0.52276427", "0.5227406", "0.52270633", "0.52263904" ]
0.0
-1
PATCH/PUT /offenses/1 PATCH/PUT /offenses/1.json
def update respond_to do |format| if @offense.update(offense_params) format.html { redirect_to @offense, notice: 'Offense was successfully updated.' } format.json { render :show, status: :ok, location: @offense } else format.html { render :edit } format.json { render json: @offense.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end", "def update\n respond_to do |format|\n if @api_v1_expense.update(api_v1_expense_params)\n format.html { redirect_to @api_v1_expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_expense }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find params.fetch(:id)\n\n if @expense.update(expense_params)\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to expenses_url, notice: 'Expense was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n #format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :ok }\n else\n #format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to expenses_path, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense_owner.update(expense_owner_params)\n format.html { redirect_to @expense_owner, notice: 'Expense owner was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense_owner }\n else\n format.html { render :edit }\n format.json { render json: @expense_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to :json\n\n if @expense_claim.update(expense_claim_params)\n head :ok\n else\n render partial: 'expense_claim_key_data', layout: false, status: :ok, locals: { expense_claim: @expense_claim }\n end\n end", "def update\n @operating_expense = OperatingExpense.find(params[:id])\n\n respond_to do |format|\n if @operating_expense.update_attributes(params[:operating_expense])\n format.html { redirect_to(@operating_expense, :notice => 'Operating expense was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @operating_expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to '/expenses', notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solideo_depense.update(solideo_depense_params)\n format.html { redirect_to solideo_depenses_path, notice: 'Solideo depense was successfully updated.' }\n format.json { render :show, status: :ok, location: @solideo_depense }\n else\n format.html { render :edit }\n format.json { render json: @solideo_depense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to edit_expense_path(@expense), notice: 'Expense was successfully updated.' }\n format.json { render :edit, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expenses_file.update(expenses_file_params)\n format.html { redirect_to @expenses_file, notice: 'Expenses file was successfully updated.' }\n format.json { render :show, status: :ok, location: @expenses_file }\n else\n format.html { render :edit }\n format.json { render json: @expenses_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @petty_cash_expense.update(petty_cash_expense_params)\n format.json { render :show, status: :ok, location: @petty_cash_expense }\n else\n format.json { render json: @petty_cash_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @expense\n @expense.updated_by = current_user\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_back_or_default expenses_url, t('Record has been saved') }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @docs_ponto.update(docs_ponto_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @docs_ponto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.json { head :ok }\n format.js\n else\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to(@expense, :notice => 'Expense was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to(@expense, :notice => 'Expense was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to :back, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { redirect :back}\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @expense_report\n\n\n @expense_report.actual_expenses.each do |exp|\n exp.requests.each do |req|\n req.amount_from_total = req.percentrequested * exp.total\n req.destination = @expense_report.trip.destination\n req.expense_type = 'actual'\n end\n end\n\n\n respond_to do |format|\n if @expense_report.update(expense_report_params)\n format.html { redirect_to @expense_report, notice: 'Expense report was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense_report }\n else\n format.html { render :edit }\n format.json { render json: @expense_report.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @appraisal_fee.update(appraisal_fee_params)\n format.html { redirect_to appraisal_fees_path, notice: 'Appraisal fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @appraisal_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @overall.update(overall_params)\n format.html { redirect_to @overall, notice: 'Overall was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @overall.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n @expense.reset\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n\n flash[:notice] = 'Expense was successfully updated.'\n format.html { redirect_to expense_url(@expense) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expense.errors.to_xml }\n end\n end\n end", "def update\n @admin_expense_type = Admin::ExpenseType.find(params[:id])\n\n respond_to do |format|\n if @admin_expense_type.update_attributes(params[:admin_expense_type])\n format.html { redirect_to admin_expense_types_url }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_expense_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_offense\n @offense = Offense.find(params[:id])\n end", "def update\n @housing_expense = HousingExpense.find(params[:id])\n\n respond_to do |format|\n if @housing_expense.update_attributes(params[:housing_expense])\n flash[:notice] = 'HousingExpense was successfully updated.'\n format.html { redirect_to housing_expense_url(@housing_expense) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @housing_expense.errors.to_xml }\n end\n end\n end", "def update\n @expense = Expense.for_user(current_user).find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n flash[:notice] = 'Expense was successfully updated.'\n format.html { redirect_to(expenses_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @officer = Officer.find(params[:id])\n\n respond_to do |format|\n if @officer.update_attributes(params[:officer])\n format.html { redirect_to @officer, :notice => 'Officer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @officer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @depense.update(depense_params)\n format.html { redirect_to @depense, notice: 'Depense was successfully updated.' }\n format.json { render :show, status: :ok, location: @depense }\n else\n format.html { render :edit }\n format.json { render json: @depense.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @office = Office.find(params[:id])\n\n respond_to do |format|\n if @office.update_attributes(params[:office])\n format.html { redirect_to offices_path, notice: 'Office was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @office.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @officer = Officer.find(params[:id])\n\n respond_to do |format|\n if @officer.update_attributes(params[:officer])\n format.html { redirect_to @officer, notice: 'Officer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @officer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative_update.update(api_v1_initiative_update_params)\n format.html { redirect_to @api_v1_initiative_update, notice: 'Initiative update was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative_update }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to foods_path(), notice: 'Food was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @etat_depense.update(etat_depense_params)\n format.html { redirect_to etat_depenses_path, notice: 'Etat depense was successfully updated.' }\n format.json { render :show, status: :ok, location: @etat_depense }\n else\n format.html { render :edit }\n format.json { render json: @etat_depense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @callout.update(callout_params)\n format.html { redirect_to @callout, notice: 'Callout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @callout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @opportunity = Opportunity.find(params[:id])\n\n if @opportunity.update(opportunity_params)\n head :no_content\n else\n render json: @opportunity.errors, status: :unprocessable_entity\n end\n end", "def update\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n if @kickoff.update_attributes(params[:kickoff])\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense_type.update(expense_type_params)\n format.html { redirect_to @expense_type, notice: 'Expense type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @expense_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @officer.update(officer_params)\n format.html { redirect_to @officer, notice: 'Officer was successfully updated.' }\n format.json { render :show, status: :ok, location: @officer }\n else\n format.html { render :edit }\n format.json { render json: @officer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @officer.update(officer_params)\n format.html { redirect_to @officer, notice: 'Officer was successfully updated.' }\n format.json { render :show, status: :ok, location: @officer }\n else\n format.html { render :edit }\n format.json { render json: @officer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @offering = Offering.find(params[:id])\n\n respond_to do |format|\n if @offering.update_attributes(params[:offering])\n format.html { redirect_to @offering, notice: 'Oferta atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offering.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @one_offspring.update(one_offspring_params)\n format.html { redirect_to @one_offspring, notice: 'One offspring was successfully updated.' }\n format.json { render :show, status: :ok, location: @one_offspring }\n else\n format.html { render :edit }\n format.json { render json: @one_offspring.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @opinion.update(opinion_params)\n format.html { redirect_to @opinion, notice: 'Opinion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @offer = Offer.find(params[:id])\n checkaccountobject(\"offers\",@offer)\n respond_to do |format|\n if @offer.update_attributes(params[:offer])\n format.html { redirect_to @offer, notice: 'Offer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @getoff_info = GetoffInfo.find(params[:id])\n\n respond_to do |format|\n if @getoff_info.update_attributes(params[:getoff_info])\n format.html { redirect_to @getoff_info, :notice => 'Getoff info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @getoff_info.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update_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 resource.update(deposit_contract_params)\n respond_with client, resource\n end", "def update\n @request_for_change.set_manager(force: true)\n @request_for_change.set_security_officer(force: true)\n\n respond_to do |format|\n if @request_for_change.update(request_for_change_params)\n format.html { redirect_to edit_request_for_change_path(@request_for_change), notice: 'Request for change was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_for_change.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @food_expenditure.update(food_expenditure_params)\n @food_expenditure.update_attributes(:edit_able=>false)\n format.html { redirect_to @food_expenditure, notice: 'FoodExpenditure was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_expenditure }\n else\n format.html { render :edit }\n format.json { render json: @food_expenditure.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fixed_expense = FixedExpense.for_user(current_user).find(params[:id])\n\n respond_to do |format|\n if @fixed_expense.update_attributes(params[:fixed_expense])\n flash[:notice] = 'FixedExpense was successfully updated.'\n format.html { redirect_to(fixed_expenses_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fixed_expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @rec_expense.update(rec_expense_params)\n format.html { redirect_to @rec_expense, notice: 'Rec expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @rec_expense }\n else\n format.html { render :edit }\n format.json { render json: @rec_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @office.update(office_params)\n head :no_content\n end", "def update\n respond_to do |format|\n if @expense.update_attributes(params[get_type])\n update_paps\n format.html { redirect_to @expense, notice: 'Udalosť bola úspešne zmenená.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_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 respond_to do |format|\n if @shared_expense.update(shared_expense_params)\n format.html { redirect_to @shared_expense, notice: 'Shared expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @shared_expense }\n else\n format.html { render :edit }\n format.json { render json: @shared_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @food_item_add_on.update(food_item_add_on_params)\n format.html { redirect_to @food_item_add_on, notice: 'Food item add on was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_item_add_on }\n else\n format.html { render :edit }\n format.json { render json: @food_item_add_on.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @observance.update(observance_params)\n format.html { redirect_to @observance, notice: 'Observance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @observance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @offer.update(offers_params)\n format.jsonapi { render :show, status: :ok, location: @offer }\n else\n format.jsonapi { render jsonapi: @offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @loan_officer.update(loan_officer_params)\n format.html { redirect_to @loan_officer, notice: 'Loan officer was successfully updated.' }\n format.json { render :show, status: :ok, location: @loan_officer }\n else\n format.html { render :edit }\n format.json { render json: @loan_officer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @auto_offer.update(auto_offer_params)\n format.html { redirect_to @auto_offer, notice: 'Auto offer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @auto_offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_expense\n @api_v1_expense = Api::V1::Expense.find(params[:id])\n end", "def update\n @person_expense_record = PersonExpenseRecord.find(params[:id])\n\n if @person_expense_record.update(person_expense_record_params)\n head :no_content\n else\n render json: @person_expense_record.errors, status: :unprocessable_entity\n end\n end", "def update\n authorize @trip\n\n\n @trip.estimated_expenses.each do |exp|\n exp.requests.each do |req|\n req.amount_from_total = req.percentrequested * exp.total\n req.destination = @trip.destination\n req.expense_type = 'estimated'\n end\n end\n\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @appoint_responsible.update(appoint_responsible_params)\n format.html { redirect_to @appoint_responsible, notice: 'Appoint responsible was successfully updated.' }\n format.json { render :show, status: :ok, location: @appoint_responsible }\n else\n format.html { render :edit }\n format.json { render json: @appoint_responsible.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @offering.update(offering_params)\n format.html { redirect_to @offering, notice: 'La oferta de servicio ha sido actualizada correctamente.' }\n format.json { render :show, status: :ok, location: @offering }\n else\n format.html { render :edit }\n format.json { render json: @offering.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n @expense = Expense.find(params[:id])\n \n if params[:expense][:item_id].present?\n @expense.categorie_id = Item.find(params[:expense][:item_id]).categorie_id\n end\n if params[:activite_id].present?\n @expense.activite_id = params[:activite_id]\n end\n \n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to(@expense, :notice => 'Expense was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => { :success => true, :message => \"Updated Expense #{@expense.id}\", :data => @expense.attributes.merge(:total_ht => @expense.total, :total_ttc => @expense.total_ttc, :activite_name => @expense.activite.try(:description))}} \n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @opinion.update(opinion_params)\n format.html { redirect_to opinions_path, notice: 'Opinion was successfully updated.' }\n format.json { render :show, status: :ok, location: @opinion }\n else\n format.html { render :edit }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to @food, notice: \"Piatto aggiornato correttamente.\" }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fee = Fee.find(params[:id])\n\n respond_to do |format|\n if @fee.update_attributes(params[:fee])\n format.html { redirect_to fees_path, notice: 'Fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @optinpartner = Optinpartner.find(params[:id])\n\n respond_to do |format|\n if @optinpartner.update_attributes(params[:optinpartner])\n format.html { redirect_to @optinpartner, notice: 'Optinpartner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @optinpartner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to [@expense.statement.account, @expense.statement], notice: 'Statement expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n if @dayoff.update_attributes(params[:dayoff])\n format.html { redirect_to @dayoff, notice: 'Dayoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dayoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fulcliente = Fulcliente.find(params[:id])\n\n respond_to do |format|\n if @fulcliente.update_attributes(params[:fulcliente])\n format.html { redirect_to @fulcliente, notice: 'Fulcliente was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fulcliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n if @opinion.update_attributes(params[:opinion])\n format.html { redirect_to @opinion, notice: 'Opinion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @marketing_expense.update(marketing_expense_params)\n\n @project.create_activity :edited_marketing_expense, owner: current_user,\n parameters: { text: 'Edited ', object_id: @marketing_expense.id, form_data: params[:marketing_expense].to_s }\n\n ProjectMailer.marketing_expense(@project, @marketing_expense, current_user)\n\n format.html { redirect_to @marketing_expense, notice: 'Marketing expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @marketing_expense }\n else\n format.html { render :edit }\n format.json { render json: @marketing_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @apprendice.update(apprendice_params)\n format.html { redirect_to @apprendice, notice: 'Apprendice was successfully updated.' }\n format.json { render :show, status: :ok, location: @apprendice }\n else\n format.html { render :edit }\n format.json { render json: @apprendice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @flat_happening = FlatHappening.find(params[:id])\n\n if @flat_happening.update_attributes(params[:flat_happening])\n head :no_content\n else\n render json: @flat_happening.errors, status: :unprocessable_entity\n end\n end", "def edit\n @appointment_request = current_user.requests.find_by(\n id: params[:request_id]\n )\n\n if @appointment_request.present?\n render json: { appointment_request: @appointment_request, status: 200 }\n else\n render json: { status: 404, layout: false }, status: 404\n end\n end", "def update\n respond_to do |format|\n if @dog_expense.update(dog_expense_params)\n format.html { redirect_to @dog_expense, notice: 'Dog expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @dog_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fee.update(fee_params)\n format.html { redirect_to @fee, notice: 'Fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @fee }\n else\n format.html { render :edit }\n format.json { render json: @fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @adopted_pet.update(adopted_pet_params)\n format.html { redirect_to @adopted_pet, notice: 'Adopted pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @adopted_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @adopted_pet.update(adopted_pet_params)\n format.html { redirect_to @adopted_pet, notice: 'Adopted pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @adopted_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @factoid = Factoid.find(params[:id])\n\n respond_to do |format|\n if @factoid.update_attributes(params[:factoid])\n format.html { redirect_to @factoid, notice: 'Factoid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @factoid.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @proof_sale.update(proof_sale_params)\n format.html { redirect_to @proof_sale, notice: 'Proof sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @proof_sale }\n else\n format.html { render :edit }\n format.json { render json: @proof_sale.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.67526627", "0.6729683", "0.65609837", "0.64252037", "0.63811225", "0.637187", "0.6313367", "0.6313367", "0.6271081", "0.6257897", "0.6251552", "0.623205", "0.6222745", "0.6215098", "0.6186781", "0.6168107", "0.6158371", "0.6158371", "0.6158371", "0.6131059", "0.6126703", "0.6124767", "0.61229306", "0.6077942", "0.604926", "0.604926", "0.6040064", "0.6030189", "0.60033935", "0.59988093", "0.5995016", "0.59674615", "0.5950899", "0.5948333", "0.5947357", "0.5947127", "0.59470695", "0.5946983", "0.5934487", "0.5931944", "0.5926766", "0.5922387", "0.5915994", "0.5915058", "0.59108984", "0.5909589", "0.590948", "0.59061277", "0.5892457", "0.5892457", "0.58902013", "0.5890089", "0.58817947", "0.5879795", "0.58747053", "0.5870054", "0.58687055", "0.5863167", "0.58537424", "0.58478945", "0.5847443", "0.5843887", "0.58429587", "0.5834172", "0.5827636", "0.5822412", "0.5821785", "0.58105236", "0.58009726", "0.5799198", "0.57982266", "0.579381", "0.5786723", "0.5782735", "0.5782108", "0.57678896", "0.5767367", "0.5765918", "0.5756367", "0.5751152", "0.574906", "0.5745094", "0.57417053", "0.57332623", "0.5731971", "0.57277805", "0.5726506", "0.5721403", "0.57165074", "0.57126415", "0.57091933", "0.5708575", "0.57039803", "0.5701524", "0.5701524", "0.5698378", "0.5698378", "0.5695251", "0.5686273", "0.5684706" ]
0.6924017
0
DELETE /offenses/1 DELETE /offenses/1.json
def destroy @offense.destroy respond_to do |format| format.html { redirect_to offenses_url, notice: 'Offense was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @api_v1_expense.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = current_user.organization.expenses.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.find params.fetch(:id)\n @expense.destroy\n head :no_content\n end", "def destroy\n @operating_expense = OperatingExpense.find(params[:id])\n @operating_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(operating_expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\n @expense.destroy\n \n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n respond_with @expense.destroy, status: 204\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dog_expense.destroy\n respond_to do |format|\n format.html { redirect_to dog_expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @solideo_depense.destroy\n respond_to do |format|\n format.html { redirect_to solideo_depenses_url, notice: 'Solideo depense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @livingexpense = Livingexpense.find(params[:id])\n @livingexpense.destroy\n\n respond_to do |format|\n format.html { redirect_to livingexpenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @housing_expense = HousingExpense.find(params[:id])\n @housing_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to housing_expenses_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html {redirect_to expenses_url, notice: 'Expense was successfully destroyed.'}\n format.json {head :no_content}\n end\n end", "def destroy\n @admin_expense_type = Admin::ExpenseType.find(params[:id])\n @admin_expense_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_expense_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense_owner.destroy\n respond_to do |format|\n format.html { redirect_to expense_owners_url, notice: 'Expense owner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense_type.destroy\n respond_to do |format|\n format.html { redirect_to expense_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @name_expense.destroy\n respond_to do |format|\n format.html { redirect_to name_expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n format.js\n format.iphone { redirect_to(@bucket) }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html\n format.json { render head :ok }\n format.js { render :nothing => true }\n end\n end", "def destroy\n @expense = current_user.expenses.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n flash[:success] = t('activerecord.flash.deleted')\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense_claim.destroy\n respond_to do |format|\n format.html { redirect_to expense_claims_url, notice: 'Expense claim was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @depense.destroy\n respond_to do |format|\n format.html { redirect_to depenses_url, notice: 'Depense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expensesbasis.destroy\n respond_to do |format|\n format.html { redirect_to [@post, @expensesbasis], notice: 'Expensesbase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rec_expense.destroy\n respond_to do |format|\n format.html { redirect_to rec_expenses_url, notice: 'Rec expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n expense = Expense.destroy(params[\"id\"])\n\n if expense\n render json: {\n status: \"SUCCESS\",\n message: \"Expense deleted\",\n }, status: :ok\n else\n render json: {\n status: \"ERROR\",\n message: \"Invalid id\",\n }, status: 400\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense_id = @expense.id\n @expense.destroy\n\n respond_to do |format|\n format.json { head :ok }\n format.js\n end\n end", "def destroy\n @etat_depense.destroy\n respond_to do |format|\n format.html { redirect_to etat_depenses_url, notice: 'Etat depense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @overall.destroy\n respond_to do |format|\n format.html { redirect_to overalls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expenses_file.destroy\n respond_to do |format|\n format.html { redirect_to expenses_files_url, notice: 'Expenses file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.for_user(current_user).find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to('/') }\n format.iphone { redirect_to('/') }\n format.xml { head :ok }\n end\n end", "def destroy\n @accident_vehicle_expense = AccidentVehicleExpense.find(params[:id])\n @accident_vehicle_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(accident_vehicle_expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to account_statement_url(params[:account_id],params[:statement_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @shared_expense.destroy\n respond_to do |format|\n format.html { redirect_to shared_expenses_url, notice: 'Shared expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @marketing_expense.destroy\n respond_to do |format|\n format.html { redirect_to marketing_expenses_url, notice: 'Marketing expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @point_of_sale.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @petty_cash_expense.destroy\n head :no_content \n end", "def destroy\n @advocacy = Advocacy.find(params[:id])\n @advocacy.destroy\n\n respond_to do |format|\n format.html { redirect_to advocacies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @fixed_expense = FixedExpense.for_user(current_user).find(params[:id])\n @fixed_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(fixed_expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @round_expense = RoundExpense.find(params[:id])\n @round_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(round_expenses_url) }\n format.xml { head :ok }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @ocat = Ocat.find(params[:id])\n @ocat.destroy\n\n respond_to do |format|\n format.html { redirect_to ocats_url }\n format.json { head :no_content }\n end\n 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 destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n redirect_to expenses_url, notice: (I18n.t 'Expense was successfully deleted.')\n end", "def destroy\n @investigated.destroy\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @defense.destroy\n respond_to do |format|\n format.html { redirect_to defenses_url, notice: 'Defense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person_expense_record.destroy\n\n head :no_content\n end", "def destroy\n @appraisal_fee.destroy\n respond_to do |format|\n format.html { redirect_to appraisal_fees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opinion.destroy\n respond_to do |format|\n format.html { redirect_to opinions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ovode = Ovode.find_by_url(params[:id])\n @ovode.destroy\n\n respond_to do |format|\n format.html { redirect_to ovodes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @competency.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n if authorized?(:destroy, @expense)\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n format.js { render :action => \"destroy\" }\n end\n end\n end", "def destroy\n @lincense.destroy\n respond_to do |format|\n format.html { redirect_to lincenses_url, notice: 'Licensia fue exitosamente destruida.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense_state = ExpenseState.find(params[:id])\n @expense_state.destroy\n\n respond_to do |format|\n format.html { redirect_to expense_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fullassessment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @office = Office.find(params[:id])\n @office.destroy\n\n respond_to do |format|\n format.html { redirect_to offices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @office = Office.find(params[:id])\n\n authorize! :destroy, @office\n \n @office.destroy\n\n track_event(\"Deleted Listing\");\n\n respond_to do |format|\n format.html { redirect_to offices_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 authorize @expense\n set_return_to\n @expense.destroy\n respond_to do |format|\n format.html { redirect_back_or_default expenses_url, t('Record has been deleted') }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n @opinion = Opinion.find(params[:id])\n @opinion.destroy\n\n respond_to do |format|\n format.html { redirect_to opinions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opinion = Opinion.find(params[:id])\n @opinion.destroy\n\n respond_to do |format|\n format.html { redirect_to opinions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @food_expenditure.destroy\n respond_to do |format|\n format.html { redirect_to food_expenditures_url, notice: 'FoodExpenditure was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @economia4 = Economia4.find(params[:id])\n @economia4.destroy\n\n respond_to do |format|\n format.html { redirect_to economia4s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @food_item_add_on.destroy\n respond_to do |format|\n format.html { redirect_to food_item_add_ons_url, notice: 'Food item add on was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @theader.destroy\n respond_to do |format|\n format.html { redirect_to offices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expediente = Expediente.find(params[:id])\n @expediente.destroy\n\n respond_to do |format|\n format.html { redirect_to expedientes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @withdrawal = Withdrawal.find(params[:id])\n @withdrawal.destroy\n\n respond_to do |format|\n format.html { redirect_to withdrawals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @offer = Offer.find(params[:id])\n checkaccountobject(\"offers\",@offer)\n @offer.destroy\n\n respond_to do |format|\n format.html { redirect_to offers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @farmexpense = Farmexpense.find(params[:id])\n @farmexpense.destroy\n\n respond_to do |format|\n format.html { redirect_to(farmexpenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @record_expense.destroy\n respond_to do |format|\n format.html { redirect_to record_expenses_url, notice: 'Record expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @apprentice = Apprentice.find(params[:id])\n @apprentice.destroy\n\n respond_to do |format|\n format.html { redirect_to apprentices_url }\n format.json { head :no_content }\n end\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @deposit.destroy\n respond_to do |format|\n format.html { redirect_to deposits_url, notice: \"Deposit was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @deposit.destroy\n respond_to do |format|\n format.html { redirect_to deposits_url, notice: 'Deposit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @historial_odt = HistorialOdt.find(params[:id])\n @historial_odt.destroy\n\n respond_to do |format|\n format.html { redirect_to historial_odts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dispense.destroy\n respond_to do |format|\n format.html { redirect_to dispenses_url, notice: 'Dispense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fulcliente = Fulcliente.find(params[:id])\n @fulcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to fulclientes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @observance.destroy\n respond_to do |format|\n format.html { redirect_to observances_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bid_expense.destroy\n respond_to do |format|\n format.html { redirect_to bid_expenses_url, notice: 'Bid expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @economic = Economic.find(params[:id])\n @economic.destroy\n\n respond_to do |format|\n format.html { redirect_to(economics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exprience = Exprience.find(params[:id])\n @exprience.destroy\n\n respond_to do |format|\n format.html { redirect_to expriences_url }\n format.json { head :no_content }\n end\n end", "def DeleteView id\n \n APICall(path: \"views/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @expenditure = Expenditure.find(params[:id])\n @expenditure.destroy\n\n respond_to do |format|\n format.html { redirect_to expenditures_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7225612", "0.7159345", "0.71342397", "0.71342397", "0.7132981", "0.7132981", "0.7128484", "0.7126406", "0.6981811", "0.69228697", "0.6864533", "0.6864533", "0.6849043", "0.6821547", "0.6811175", "0.6811175", "0.6811175", "0.6811175", "0.6811175", "0.6811175", "0.67957675", "0.67668724", "0.6764354", "0.6763368", "0.675679", "0.6739534", "0.67364943", "0.6730441", "0.6720338", "0.66893375", "0.6683101", "0.66533005", "0.661595", "0.6610577", "0.66054505", "0.6591428", "0.6583852", "0.658374", "0.65768015", "0.65643805", "0.6539595", "0.65368766", "0.6536352", "0.65334207", "0.6531335", "0.6523897", "0.65189284", "0.6507382", "0.65000015", "0.64990896", "0.6498405", "0.6498405", "0.64862627", "0.64853716", "0.6481943", "0.64678633", "0.64572513", "0.6447225", "0.6442776", "0.64409214", "0.6434947", "0.6431282", "0.6422655", "0.64095944", "0.6395574", "0.6393936", "0.63931006", "0.63922393", "0.6391849", "0.6388183", "0.63874215", "0.6380326", "0.63795394", "0.6379501", "0.6379421", "0.63710624", "0.63710624", "0.63664687", "0.6365799", "0.6363438", "0.63623095", "0.6358864", "0.63580555", "0.6354952", "0.6345144", "0.63427377", "0.6340037", "0.6338188", "0.6333222", "0.6329904", "0.6329813", "0.63251287", "0.6323701", "0.6321581", "0.631945", "0.63173664", "0.6313945", "0.63078487", "0.6306337", "0.62974644" ]
0.7256284
0
Use callbacks to share common setup or constraints between actions.
def set_offense @offense = Offense.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 offense_params params[:offense] end Whitelisting IP Address
def offense_params params.require(:offense).permit(:ip_address, :host_name, :email, :phone) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def client_face_ip_params\n params.fetch(:face_ip, {}).permit!\n end", "def card_ip_params\n params.fetch(:card_ip, {}).permit!\n end", "def face_ip_params\n params.fetch(:face_ip, {}).permit!\n end", "def create\n host_name = begin\n Resolv.getname(request.ip)\n rescue Resolv::ResolvError\n end || 'n/a'\n\n params[:offense].merge!({:ip_address => request.ip, :host_name => host_name})\n\n @offense = Offense.new(offense_params)\n respond_to do |format|\n if @offense.save\n if @offense.email?\n self.email\n end\n if @offense.phone?\n self.sms\n end\n format.html { redirect_to @offense, notice: 'Offense was successfully created.' }\n format.json { render :show, status: :created, location: @offense }\n else\n format.html { render :new }\n format.json { render json: @offense.errors, status: :unprocessable_entity }\n end\n end\n end", "def aws_elastic_ip_params\n params.require(:aws_elastic_ip).permit(:aws_account_id, :aws_region_id, :instance_id, :public_ip, :allocation_id, :association_id, :domain, :network_interface_id, :network_interface_owner_id, :private_ip_address)\n end", "def onsen_params\n params.require(:onsen).permit(:name, :prefecture_id, :url, :review, :list_id, :user_id)\n end", "def ip_adress_params\n params[:ip_adress]\n end", "def address_params\n #funky strong params block taken from https://github.com/rails/rails/issues/9454#issuecomment-14167664\n params.require(:address).permit(:id, :name, :address, :telephone, :agent).tap do |whitelisted|\n whitelisted[:address] = params[:address][:address]\n end\n end", "def ipaddress_params\n params.require(:ipaddress).permit(:ip_address,:ip,:interface,:virtualmachine_id)\n end", "def isp_params\n params.require(:isp).permit(:name, :attackID)\n end", "def reserved_address_params\n params[:reserved_address].permit(:vlan_id, :ip, :description)\n end", "def address_params\n params.require(:address).permit(:vlan_id,\n :user_id,\n :ip,\n :mac_address,\n :usage,\n :start_date,\n :end_date,\n :application_form,\n :assigner,\n :recyclable)\n end", "def replace_administrative_ip(opts)\n opts = check_params(opts,[:old_ips,:new_ips,:netmasks])\n super(opts)\n end", "def config_to_allow_offenses=(_arg0); end", "def process_ip_address_params\n params.fetch(:process_ip_address)\n end", "def omise_params\n params.require(:omise).permit(:name, :tel, :address, :homepage)\n end", "def bypass_site_allowed_ips\n @attributes[:bypass_site_allowed_ips]\n end", "def access_list_to_ea_point_params\n params.require(:access_list_to_ea_point).permit(:ea_pproof, :remove_ea_pproof, :al_file_name, :al_eap_id)\n end", "def ip_list_params\n params.require(:ip_list).permit(:address, :type, :instance_id)\n end", "def adpartner_params\n params.require(:adpartner).permit(\n :name, :name_addon, :lastname, :firstname, :street, :zip, :city,\n :country, :email, :website, :commission_absolute, :commission_relative\n )\n end", "def violation_params\n if (!params[:image_url].nil? )\n params[:image_url].gsub!(/{:value=>\\\"(.*)\\\"}/,\"\\\\1\")\n end\n params.permit(:title, :description, :city_id, :district_id, :neighborhood_id, :type_id, :address, :image_url, :tag_list, :closed)\n end", "def attack_params\n params.require(:attack).permit(:status, :caseID, :attackID, :target, :functionality, :url, :registrationDate,:expireryDate, :notes, :image, :whois_text)\n end", "def vip_privilege_params\n params[:vip_privilege].permit!\n end", "def whitelist(ip)\n send_req({a: :wl, key: ip})\n end", "def incident_params\n params.require(:incident).permit(:address_1, :address_2, :city, :state, :zip, \n :country, :description, :incident_type, :occured_at, :neighborhood, :latitude, :longitude)\n end", "def rule_params\n params.permit(:api_services, :icon, :method, :what, :discount, :user_id)\n end", "def iprange_params\n params.require(:iprange).permit(:ip_block_start, :ip_block_end, :ip_range, :kladr_city_code, :city_id, :ip)\n end", "def sea_params\n params.require(:sea).permit(:label,\n :advertiser,\n :keywords => [],\n :fqdn_advertisings => [])\n end", "def incidence_params\n params.require(:incidence).permit(:ticket, :type_id, :picture, :motive_id, :description,:ubigeo_id, :reference, :date, :latitud, :longitud)\n end", "def sunshine_center_other_expense_params\n params.require(:sunshine_center_other_expense).permit(:hosting, :blogging, :facebook, :liability_insurance, :heath_insurance, :detox, :workers_compensation, :fica, :office_supplies, :cort, :kipu, :miscellaneous, :start_date, :end_date, :company_id)\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def appoint_responsible_params\n params.require(:appoint_responsible).permit(:email, :user_id, :inheritor_email, :inheritor_id, :accepted, :file)\n end", "def expense_params\n expense = params.require(:expense) \\\n .permit(:place_id, :amount, :comment, :paid_at, :fixed,\n :sub_category_id, :account_id, :place_name, :place_id)\n\n if expense[:place_name].present? && expense[:place_id].present?\n expense.delete :place_name\n expense.delete 'place_name'\n end\n\n expense\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 life_params\n params.require(:life_and_disability).permit(:id, :name, :webaddress, :street_address_1, :city, :state, :zip, :phone, :fax, :contact_id,\n share_with_ids: [])\n end", "def emergency_params(action = :update)\n permitted = [:fire_severity, :police_severity, :medical_severity]\n permitted << :resolved_at if action == :update\n permitted << :code if action == :create\n params.require(:emergency).permit(permitted)\n end", "def ip_restrict\n allow_ips = Settings.ip_addresses.monstarlab.to_h.values.flatten\n allow_ips << \"::1\" if Rails.env.development?\n remote_ip = request.remote_ip\n\n return render_404 unless allow_ips.include? remote_ip\n end", "def offre_params\n params.require(:offre).permit(:user_id, :url, :language, :contrat, :salaire, :localisation)\n end", "def reach_params\n if params[:reach][:websitepurpose] != nil\n params[:reach][:websitepurpose] = params[:reach][:websitepurpose].join(',')\n end\n if params[:reach][:objectiveachieve] != nil\n params[:reach][:objectiveachieve] = params[:reach][:objectiveachieve].join(',')\n end\n params.require(:reach).permit(:whatyouwant, :howlongrun, :triedonline, :everspentmoney, :runningwebsite, :websitepurpose, :objectiveachieve, :investatleast, :name, :phonenumber, :whatsappnumber, :email)\n end", "def happiness_params\n params.permit(:device_id, :feeling_like, :lat, :lng, :city, :country, :neighborhood, :string)\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def serv_offer_params\n params.require(:serv_offer).permit(:serv_title, :serv_detail, :serv_images, :serv_catagory, :catalog, :goods_catalog_id, :user_id, :district, :city, :province, :country, :latitude, :longitude, :via, :status, :range, :price, :unit, :change_price)\n end", "def lou_inspection_params\n params.require(:lou_inspection).permit(:business_id, :score, :date, :visit)\n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def aid_offer_params\n params.require(:aid_offer).permit(:name, :phone, :nric, :content, :location_id)\n end", "def teleport_incense_params\n params[:teleport_incense]\n end", "def office_expense_params\n params.require(:office_expense).permit(:expense_type, :description, :amount, :user_id)\n end", "def eligibility_params\n params.require(:eligibility).permit(ELIGIBILITY_PARAMS)\n end", "def early_access_request_params\n params.require(:early_access_request).permit(:email)\n end", "def vote_params\n params.require(:vote).permit(:candidate_id, :ip_address)\n end", "def http_request_params\n params.require(:http_request).permit(:ip, :address)\n end", "def expense_owner_params\n params.require(:expense_owner).permit(:name, :allocation)\n end", "def power_of_attorney_params\n params.require(:power_of_attorney).permit(:name, :phone, :email, :address, :state, :city, :zip_code)\n end", "def expense_params\n params.require(:expense).permit(:incurred_date, :reimbursed_date, \n :user_id, :account_id, :supplier, :description, :without_vat, \n :vat, :with_vat, :is_mileage, :miles, :mileage_rate, :expense,\n :cost_centre_id, :is_checked)\n end", "def negociated_price_params\n params.require(:negociated_price).permit(:article_id, :client_id, :washing_price, :handwash_price, :tab_price, :deposit_price)\n end", "def set_offense\n @offense = Offense.find(params[:id])\n end", "def inden_usage_params\n params.require(:inden_usage).permit(:inden_card_id, :petrol_ltr, :petrol_price, :diesel_ltr, :diesel_price, :issue_date, :petronas_p_ltr, :petronal_p_price, :petronas_d_ltr, :petronas_d_price, :unit_fuel_id)\n end", "def permit_request_params\n params.permit(:address)\n end", "def access_internet_params\n params.require(:access_internet).permit(:total_traffic, :hfc_cgn, :hfc_public, :hfc_ipv6, :hfc, :mobile_cgn, :mobile_corporate, :mobile_ipv6, :mobile, :mobile_olo, :corporate, :cache_in)\n end", "def address_params\n params.require(:address).permit(Address.attribute_list) unless params[:address].nil?\n end", "def enemy_params\n params.require(:enemy).permit(:ap_no, :enemy_id, :suffix_id)\n end", "def remove_ip(opts)\n opts = check_params(opts,[:ips])\n super(opts)\n end", "def residence_params\n\t\tparams.require(:residence).permit(:nombre, :provincia, :partido, :ciudad, :direccion, :img_link, :desc)\n\tend", "def ad_params\n params.require(:ad).permit(:pb_area_id, :pb_industry_id, :start_at, :end_at, :display_price_unit, :display_price, :days, :payment_type, :max_budget, :banner_1, :banner_2, :banner_3, :banner_4, :type_name, :product_name, :pb_product_id, :name, :description, :description_2, :ad_position_id, :url, :image, :image_2, :image_3, :image_4, :user_id, :status)\n end", "def accesspoint_params\n params.require(:accesspoint).permit(:streetaddress, :city, :zipcode, :publicbuilding, :wirelessavailable, :publicworkstations, :downloadspeed, :uploadspeed, :passwordrequired)\n end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def victim_params\n params.require(:victim).permit(:date, :last_name, :first_name, :age, :victim_of, :country, :city, :zip_code, :address)\n end", "def offer_params\n params.require(:offer).permit(:offer_id, :user_id, :company_id, :position, :employment_type, :responsiveness, :experience, :response_time, :address, :latitude, :longitude, :street_number, :locality, :route, :offer, :administrative_area_level_1, :country, :postal_code)\n end", "def address_search_params\n params.require(:address_search).permit(:sentiment, :search_string)\n end", "def damage_vulnerability_params\n params.fetch(:damage_vulnerability).permit(:name)\n end", "def off_day_params\n params.require(:off_day).permit(:off_day_title, :off_day_date, :is_annual, :notes)\n end", "def security_and_privacy_vulnerability_params\n params.require(:security_and_privacy_vulnerability).permit(:product_id, :cve_id, :severity, :description, :advisories)\n end", "def attorney_params\n params.require(:attorney).permit(:name, :telephone, :email, :preferred)\n end", "def view_params\n params.require(:view).permit(:ip_address, :post_id)\n end", "def awareness_params\n params.require(:awareness).permit(:title, :url, :meaning, :source, :insert_time, :update_time, :users_id)\n end", "def partner_profile_params\n params.require(:partner_profile).permit(:user_id, :admin_service_city_id, :driving_licence_number, :driving_license_state, :pan_number, :adhaar_number, :passport_number, :passport_issue_city, :admin_service_id, :approval_code, :approved_by, :approved_timestamp, :address_line1, :address_line2, :address_line3, :city, :state, :pin_code)\n end", "def advertiser_params\n params[:advertiser].permit(:company, :first_name, :last_name, :email, :address, :city, :postcode, :country_code, :user_id)\n end", "def ripple_address_params\n params.require(:ripple_address).permit(:managed, :address, :type, :tag, :uid, :data)\n end", "def node_params\n params.require(:node).permit(:ip_address)\n end", "def aide_params\n params.require(:aide).permit(:result_no, :generate_no, :e_no, :aide_no, :name, :enemy_id, :cost_sp, :bonds, :mhp, :msp, :mep, :range, :fuka_texts, :skill_texts)\n end", "def overage_params\n params.require(:overage).permit(:name, :phone_number, :overage_date, :reason, :added_data)\n end", "def offer_params\n params.require(:offer).permit(:available_from, :available_to, :available_limit, :discount_id, :coupon_id)\n end", "def advert_params\n params.require(:advert).permit(:price, :adress, :agent_id, :toilet_count, :salon_count)\n end", "def inspection_params\n params.require(:inspection).permit(:code, :houhou, :houhou_eng, :basho, :basho_eng, :cost)\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 voip_params\n params.require(:voip).permit(:client_id, :uid, :gatewayip, :prefix, :number, :line, :restrictions, :gateway, :protocol, :comments)\n end", "def employer_liability_insurance_params\n params.require(:employer_liability_insurance).permit(:title, :synopsis, :price, :aasm_state, :type, :company_id, :image, :target, :feature, :benefit)\n end", "def is_adisease_params\n params.require(:is_adisease).permit(:id, :name, :neighbors)\n end", "def defense_params\n params.require(:defense).permit(:description)\n end", "def area_of_expertise_params\n params.require(:area_of_expertise).permit(:Title, :Filed, :Domain)\n end", "def incident_params\n params.require(:incident).permit(\n :id,\n :prisoner_id,\n :date_of_arrest,\n :prison_id,\n :date_of_release,\n *Incident.globalize_attribute_names,\n article_ids: [],\n tag_ids: []\n )\n end", "def expense_params\n params.require(:expense).permit(:image_url, :name, :description, :amount, :money_source_id)\n end", "def add_ip(opts)\n opts = check_params(opts,[:ips])\n super(opts)\n end", "def whitelisted_ip?(ip)\n config.allowed_ips.include?(ip)\n end", "def attack_params\n params.require(:attack).permit(:name, :comment, :result)\n end", "def eye_params\r\n\t\t\tparams.require(:eye).permit(:phr_id,\r\n\t\t\t\t\t\t\t\t\t\t:date,\r\n\t\t\t\t\t\t\t\t\t\t:doctor,\r\n\t\t\t\t\t\t\t\t\t\t:glass_od_sph,\r\n\t\t\t\t\t\t\t\t\t\t:glass_od_cyl,\r\n\t\t\t\t\t\t\t\t\t\t:glass_od_axis,\r\n\t\t\t\t\t\t\t\t\t\t:glass_od_prism,\r\n\t\t\t\t\t\t\t\t\t\t:glass_od_base,\r\n\t\t\t\t\t\t\t\t\t\t:glass_od_add,\r\n\t\t\t\t\t\t\t\t\t\t:glass_os_sph,\r\n\t\t\t\t\t\t\t\t\t\t:glass_os_cyl,\r\n\t\t\t\t\t\t\t\t\t\t:glass_os_axis,\r\n\t\t\t\t\t\t\t\t\t\t:glass_os_prism,\r\n\t\t\t\t\t\t\t\t\t\t:glass_os_base,\r\n\t\t\t\t\t\t\t\t\t\t:glass_os_add,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_pwr,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_bc,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_dia,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_cyl,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_axis,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_add,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_colour,\r\n\t\t\t\t\t\t\t\t\t\t:cont_od_brand,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_pwr,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_bc,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_dia,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_cyl,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_axis,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_add,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_colour,\r\n\t\t\t\t\t\t\t\t\t\t:cont_os_brand,\r\n\t\t\t\t\t\t\t\t\t\t:comment,\r\n\t\t\t\t\t\t\t\t\t\t:comment2)\r\n\t\tend", "def admin_advertisement_params\n params.require(:advertisement).permit! \n end", "def estateban_params\n params.require(:estateban).permit(:EstateID, :bannedUUID, :bannedIp, :bannedIpHostMask, :bannedNameMask)\n end", "def hacknu_preference_params\n params.require(:hacknu_preference).permit(:min_age, :max_age, :distance)\n end" ]
[ "0.6451915", "0.63072747", "0.62550074", "0.6174547", "0.61519116", "0.60925585", "0.606579", "0.6013168", "0.5996419", "0.5991109", "0.593127", "0.58840626", "0.5820846", "0.5767206", "0.5748995", "0.5748386", "0.5742781", "0.569169", "0.56866574", "0.5674833", "0.5662369", "0.5642537", "0.5619571", "0.5617941", "0.5602408", "0.5600235", "0.559749", "0.5592695", "0.5567546", "0.5562373", "0.5555373", "0.5533533", "0.5531072", "0.55292743", "0.5524733", "0.55094045", "0.5505519", "0.55038804", "0.55024403", "0.5466725", "0.5462484", "0.5459954", "0.5456988", "0.54457325", "0.5441245", "0.5434312", "0.5431562", "0.54307705", "0.5430349", "0.5419178", "0.54028493", "0.5399025", "0.5394642", "0.5394256", "0.53928745", "0.5391624", "0.5383482", "0.538303", "0.5371453", "0.5370758", "0.5368422", "0.5366539", "0.5355001", "0.53455675", "0.5336389", "0.533429", "0.53339094", "0.5331637", "0.5331627", "0.5325385", "0.53243536", "0.53227377", "0.53099823", "0.5308081", "0.5305915", "0.53020376", "0.53013295", "0.5299312", "0.52954125", "0.5295302", "0.5295286", "0.5291233", "0.52904224", "0.528404", "0.5281853", "0.52818465", "0.5281055", "0.52806085", "0.5278067", "0.52757514", "0.5274729", "0.5262325", "0.52623045", "0.5261383", "0.5259283", "0.52532494", "0.52526575", "0.52511954", "0.5250128", "0.5248878" ]
0.8244986
0
Paypal payment request was cancelled, remove the associated transaction
def request_cancelled(source, token) Transaction.where(community_id: token[:community_id], id: token[:transaction_id]).destroy_all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel\n begin\n payment = Payment.find_by_token!(params[:token])\n payment.cancel!\n flash[:notice] = \"Sie haben die Bezahlung per Paypal abgebrochen.\"\n\n redirect_to edit_order_url(payment.order)\n rescue Exception => e\n redirect_to store_url, flash: { error: e.message }\n end\n end", "def cancel(_response_code)\n active_merchant_response(true, 'PayUIn will automatically capture the amount after creating a shipment.')\n end", "def destroy\n appointment_request = current_user.pending_requests\n .find(params[:request_id])\n if appointment_request.cancel!\n redirect_to root_path\n else\n render status: 500\n end\n end", "def cancel(unique_id)\n request('payment/cancel', :cancel => {:unique_id => unique_id} )\n end", "def cancel_saferpay_payment\n return unless transaction_id = saferpay_payment.transaction_id\n\n gateway.void(transaction_id)\n end", "def cancel\n payment = Spree::Payment.find_by(id: params[:payment_id])\n redirect_to redirect_path(payment.try(:order))\n end", "def cancel\n find_order\n @order.cancel! unless @order.canceled?\n settle_payments_if_desired\n render text: @settlement_results.to_json\n end", "def cancel\n\t\tclient = GocardlessPro.new(self.customer.client.organisation)\n\t\tclient.cancel_payment(self.gc_id)\n\tend", "def cancel!\n if AccountTransaction.transfer(self.num * self.price, self.startup.account, self.startup.account, :escrow, :balance).new_record?\n self.errors.add(:num, 'could not be refunded to your startup\\'s balance') \n return false\n end\n if self.responses.count > 0\n self.num = 0\n self.save\n else\n self.destroy\n end\n end", "def cancel_payment\n\n\t\t\t\t\t# Delete payment id\n\t\t\t\t\tself.payment_id = nil\n\t\t\t\t\t\n\t\t\t\t\t# Save\n\t\t\t\t\tself.override_accept_terms\n\t\t\t\t\tif !self.save\n\t\t\t\t\t\treturn false\n\t\t\t\t\tend\n\n\t\t\t\t\treturn true\n\t\t\t\tend", "def cancel_transaction\n @dps_pxpay_id = params[:id]\n zencartdps_pxpay_record = ActiveRecord::Base.connection.update(\n \"UPDATE zencartdps_pxpay SET success = 0, response_text = '' WHERE dps_pxpay_id = #{@dps_pxpay_id}\"\n )\n if zencartdps_pxpay_record > 0\n flash[:notice] = 'The transaction was cancelled'\n else\n flash[:error] = 'An error happened. The transaction was not cancelled'\n end\n\n redirect_to :action => :new_order, :id => @dps_pxpay_id\n end", "def paypal_cancel\r\n user_id = params[:user_id]\r\n @user = User.find(user_id)\r\n session[:user_id] = @user[:id]\r\n session[:user_email] = @user[:email]\r\n \r\n cancel_purchase(params[:id])\r\n flash[:notice] = I18n.t 'event.purchase.pur_can'\r\n redirect_to(:controller => 'home', :action=>'index') \r\n end", "def cancel!\n if hpp_payment? || adyen_cc_payment?\n if source.respond_to?(:requires_manual_refund?) && source.requires_manual_refund?\n log_manual_refund\n else\n process { payment_method.cancel response_code }\n end\n else\n super\n end\n end", "def cancel!\n if hpp_payment? || adyen_cc_payment?\n if source.respond_to?(:requires_manual_refund?) && source.requires_manual_refund?\n log_manual_refund\n else\n process { payment_method.cancel response_code }\n end\n else\n super\n end\n end", "def test_purchase_cancel\n response = @gateway.setup_purchase(200, @options)\n\n assert_success response\n # now try to authorize the payment, issuer simulator has cancelled the payment\n response = @gateway.capture(response.transaction['transactionID'])\n\n assert_failure response\n assert_equal 'Cancelled', response.transaction['status'], 'Transaction should cancel'\n end", "def cancel!\n if transfer.present? && transfer.complete?\n return!\n update cancelled_at: Time.current\n else\n transfer.destroy! if transfer.present?\n destroy!\n end\n order.update_shipped!\n end", "def postTransactionCancelled( transaction_id)\n params = Hash.new\n params['transaction_id'] = transaction_id\n return doCurl(\"post\",\"/transaction/cancelled\",params)\n end", "def cancel(original_reference:, reference:, merchantAccount: @merchant_account)\n postJSON(\"/Payment/v12/cancel\",\n reference: reference,\n merchantAccount: merchant_account,\n originalReference: original_reference\n )\n end", "def cancel_preauth(tx, reason)\n payment = {}\n Result::Success.new(payment)\n rescue => e\n Result::Error.new(e.message)\n end", "def release(account, merchant, transaction_id)\n delete \"/#{CGI::escape(account)}/transactions/#{transaction_id}\" + \"?merchant=#{merchant}\"\n expect_status! 'CANCELLED'\n end", "def cancel\n @error = :cancelled\n end", "def release\n request = Remit::Cancel::Request.new(transaction_id: transaction_id)\n response = remit.cancel request\n response.errors.empty?\n end", "def cancel_reason\n @subscription_purchase.cancel_reason\n end", "def cancel_old_solidus_payments\n solidus_payments_to_cancel.each(&:cancel!)\n end", "def cancel\n cookies.delete :payment_in_process\n redirect_to fines_path, flash: { error: (t 'mylibrary.fine_payment.cancel_html') }\n end", "def cancel!\n update(request_cancelled: true)\n end", "def cancel_rebilling_cycle(rebill_id)\n @PARAM_HASH[\"TRANS_TYPE\"] = \"SET\"\n @PARAM_HASH[\"STATUS\"] = \"stopped\"\n @PARAM_HASH[\"REBILL_ID\"] = rebill_id\n end", "def cancel\n \n unless status == :cancelled\n transaction do \n if total_paid > 0\n update(:status => :cancelled, :payment_status => :refunded, :total_paid => 0, :total_pending => total_cost)\n else \n update(:status => :cancelled)\n end\n # Create newsfeed\n ::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',\n action: 'cancel_booking',\n identifier: self.id.to_s,\n description: BookingDataSystem.r18n.t.canceled_booking)\n charges.each do |charge|\n charge.refund\n end\n end\n end\n\n self\n end", "def cancel_double_paypal_payments\n return unless order\n\n if service_provider == paypal_ipn\n unaccept_self_if_existing_paypal\n elsif /PayPal/.match?(service_provider)\n unaccept_previous_ipn\n end\n end", "def unpay\n self.status = 'unpaid'\n self.pay_date = nil\n if self.payment_id\n Payment.destroy(self.payment_id)\n self.payment_id = nil\n remove_from_balance\n end\n self.save\n end", "def cancelled!\n @cancelled = true\n end", "def cancel_request\n if params.key?(:tutor_id) && params.key?(:student_id) && params.key?(:tutor_subject_id)\n pending_request = PendingTutorRequest.where('tutor_id = ? AND student_id = ? AND tutor_subject_id = ?',\n params[:tutor_id],\n params[:student_id],\n params[:tutor_subject_id]).first\n course = Course.find(TutorSubject.find(params[:tutor_subject_id]).course_id)\n else\n pending_request = PendingTutorRequest.find(params[:request_id])\n # Look into see if there is another way to do this.\n course = Course.find(TutorSubject.find(pending_request.tutor_subject_id).course_id)\n end\n\n pending_request.destroy\n course_code = course.course_prefix + course.course_code\n notifcation_params = { 'user_id' => params[:tutor_id],\n 'title' => 'Request Cencelled',\n 'body' => 'A request for ' + course_code + ' has been cancelled.',\n 'icon' => 'request_cancelled',\n 'color' => 'lightgrey',\n 'type' => 'cancel' }\n Notifications.send_notification(notifcation_params)\n\n head :ok\n end", "def destroy\n @transaction = Transaction.find(params[:id])\n @transaction.status = 'rejected'\n @transaction.save\n end", "def cancel(response_code)\n transaction = protected_request do\n braintree.transaction.find(response_code)\n end\n if VOIDABLE_STATUSES.include?(transaction.status)\n void(response_code, nil, {})\n else\n credit(cents(transaction.amount), nil, response_code, {})\n end\n end", "def destroy\n @transaction_request.destroy\n end", "def delete_pending(purchase)\r\n self.pending_purchases.delete(purchase)\r\n end", "def cancel status=:canceled\n result = true\n\n # Refund all transactions associated with order\n self.select_order_transactions.payments.each do |t|\n result = self.braintree_refund_transaction t\n end\n\n # Mark the order as canceled if all braintree refunds succeeded\n if result\n self.edit_mode = false\n self.status = status\n self.save\n end\n\n # Return result\n result\n end", "def cancel!\n state_guard { modify_call 'Status' => 'cancelled' }\n end", "def cancel!(transaction_uuid)\n post(nil, \"#{collection_path}/transaction-uuid-#{transaction_uuid}/cancel\")\n end", "def delete_cancel_mile_payment(body)\r\n # Prepare query url.\r\n _path_url = '/v2/ecommerce/payments'\r\n _query_builder = Configuration.get_base_uri\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.delete(\r\n _query_url,\r\n headers: _headers,\r\n parameters: body.to_json\r\n )\r\n OAuth2.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)\r\n Response.from_hash(decoded)\r\n end", "def external_unconfirm\n if not self.transaction_source_id.nil? \n self.errors.add(:generic_errors, \"Can't modify the automated generated transaction\")\n return self \n end\n \n self.is_confirmed = false \n if self.save\n self.update_affected_accounts_due_to_un_confirmation\n end\n end", "def destroy\n @payment_request.destroy\n respond_to do |format|\n format.html { redirect_to payment_requests_url, notice: \"Payment request was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def payment_intent_cancelled?\n status == 'Payment Intent Cancelled'\n end", "def cancel!\n if charged && !canceled\n refund!\n recharge!\n end\n end", "def destroy\n @trip = Trip.find(params[:trip_id])\n return json_response({ \n status: \"error\",\n error: \"Trip is already cancelled\"\n }, 400) unless @trip.status == \"active\"\n @trip.status = \"cancelled\"\n @trip.save\n response = { \n status: Message.success,\n message: 'Trip cancelled successfully'\n }\n json_response(response, 200)\n end", "def process_cancellation!\n if payment.settled?\n # If we have the money, refund it.\n if payment.refund!\n return_stock\n IslayShop::OrderMailer.cancelled(self).deliver\n next!(\"Credited #{formatted_total}\")\n else\n fail!(\"Could not refund payment due to a problem with the payment provider\")\n end\n else\n # If the payment provider supports voiding, void\n if payment.can_void?\n if payment.void!\n return_stock\n IslayShop::OrderMailer.cancelled(self).deliver\n next!(\"Payment has been voided\")\n else\n fail!(\"Could not void payment due to a problem with the payment provider\")\n end\n else\n # Let the authorization expire:\n return_stock\n IslayShop::OrderMailer.cancelled(self).deliver\n next!(\"Payment can't be voided: the authorization will expire, usually within 7 days.\")\n end\n end\n end", "def cancel_order\n if self.status.downcase == \"pending\"\n self.status = \"Canceled\"\n self.save\n self\n else \n \"Error in Order Model\"\n end\n end", "def cancel(*)\n super.tap do\n __debug_sim('USER has decided to withdraw the submission.')\n end\n end", "def destroy\n @payment_txn.destroy\n respond_to do |format|\n format.html { redirect_to payment_txns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @payment_request.destroy\n respond_to do |format|\n format.html { redirect_to payment_requests_url, notice: \"#{@payment_request.name} was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def invalidate_old_payments\n unless store_credit?\n Spree::Adyen::RedirectResponse.where(payment: order.payments).destroy_all\n end\n super\n end", "def cancel_order(options)\n request :account, :delete, 'order', options\n end", "def cancel_all_financial_transactions_payin\n self.financial_transactions.payin.finished.each do |ft|\n LOG.debug message: \"found payin financial_transaction_id: #{ft.id} to refund (purpose: #{ft.purpose}\", booking_id: self.id\n create_financial_transaction_refund_payin ft\n end\n end", "def payment_method\n # If redirected here with token, means user selected cancel option at PayPal.\n if params.key? :token\n flash[:notice] = 'PayPal payment cancelled'\n end\n\n @payment = @application.unpaid_payment\n end", "def destroy\n \n respond_to do |format|\n if @req.destroy\n flash[:notice] = \"Responsibility request with id : '#{@req.id}' has been cancelled\"\n format.html { redirect_to responsibility_requests_url }\n format.xml { head :ok }\n else\n flash[:error] = \"Failed to cancel responsibility request '#{@req.id}'\"\n format.html { redirect_to service_url(@service) }\n end\n end\n end", "def cancel_payment(payment_id, amount=nil)\n request = Braspag::Request::UpdateSaleRequest.new(\"void\", merchant, environment)\n\n request.amount = amount\n\n request.execute(payment_id)\n end", "def after_cancel\n restock_items!\n\n #TODO: make_shipments_pending\n Spree::OrderMailer.cancel_email(self).deliver\n Spree::OrderMailer.cancel_email_retailer(self).deliver\n unless %w(partial shipped delivered).include?(shipment_state)\n self.payment_state = 'credit_owed'\n end\n end", "def cancel\n @order.cancel!\n return redirect_to order_path(@order), :notice => t(:update_success)\n end", "def destroy\n @appointment_payment = AppointmentPayment.find(params[:id])\n @appointment_payment.destroy\n\t#appointment_payments_url\n respond_to do |format|\n format.html { redirect_to(\"/appointment_payments/appt_cancel/1\") }\n format.xml { head :ok }\n end\n end", "def uncancel\r\n @plan = check_security(params[:id])\r\n @plan.uncancel(current_user)\r\n\r\n #MES- Every user is notified of an uncancel- it's like an\r\n # invitation.\r\n @plan.planners.each do | plnr |\r\n user = plnr.owner\r\n if user != current_user &&\r\n UserAttribute::FALSE_USER_ATT_VALUE != user.get_att_value(UserAttribute::ATT_REMIND_BY_EMAIL).to_i &&\r\n UserAttribute::INVITE_NOTIFICATION_ALWAYS == user.get_att_value(UserAttribute::ATT_INVITE_NOTIFICATION_OPTION).to_i\r\n UserNotify.deliver_uncancel_plan(current_user, plnr.owner, @plan)\r\n end\r\n end\r\n flash[:notice] = \"This plan is reinstated.<br/>All attendees have been re-invited.\"\r\n redirect_back\r\n end", "def cancel_trip_request\n\t\t# Get the trip referenced\n\t\t@trip = Trip.find_by(_id: trip_params[:trip_id])\n\t\t# Check that the user has actually requested this trip\n\t\tif @trip.user_requests.include?(current_user._id) && current_user.trips_requested.include?(trip_params[:trip_id])\n\t\t\t# Delete the request\n\t\t\[email protected]_requests.delete(current_user._id)\n\t\t\tcurrent_user.trips_requested.delete(trip_params[:trip_id])\n\t\t\[email protected]!\n\t\t\tcurrent_user.save!\n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\tmessage: 'Successfully cancelled the request'\n\t\t\t}, status: 200\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'This user has not requested this trip and thus cannot cancel the request'\n\t\t\t}, status: 404\n\t\tend\n\tend", "def cancel\n @calculator.retrieve_pending_amount\n end", "def process_cancel_preauth!\n if self.transaction_type.to_sym == :preauth\n do_preauth_cancel\n else\n LOG.error message: \"Cannot cancel this type of transaction\", financial_transaction_id: self.id, transaction_type: self.transaction_type\n raise \"Cannot cancel this type of transaction on this status\"\n end\n end", "def cancelled_requests; end", "def destroy\n @payment.destroy\n end", "def destroy\n @payment.destroy\n end", "def cancel_rebilling_cycle(rebill_id)\r\n @PARAM_HASH[\"TRANS_TYPE\"] = \"SET\"\r\n @PARAM_HASH[\"STATUS\"] = \"stopped\"\r\n @PARAM_HASH[\"REBILL_ID\"] = rebill_id\r\n @api = \"bp20rebadmin\"\r\n end", "def cancel_rebilling_cycle(rebill_id)\r\n @PARAM_HASH[\"TRANS_TYPE\"] = \"SET\"\r\n @PARAM_HASH[\"STATUS\"] = \"stopped\"\r\n @PARAM_HASH[\"REBILL_ID\"] = rebill_id\r\n @api = \"bp20rebadmin\"\r\n end", "def cancel\n self.solved(:abort)\n end", "def destroy\n session.delete(:return_to)\n session[:return_to] ||= request.referer\n @partner_payment.destroy\n respond_to do |format|\n format.html { redirect_to session.delete(:return_to), notice: 'Partner payment was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def cancel(billing_key)\n raise MethodNotImplemented\n end", "def destroy\n @recurring_transaction.destroy\n respond_with @recurring_transaction\n end", "def cancel_agreement(futurepay_id)\n run_command({:futurePayId => futurepay_id, \"op-cancelFP\" => \"\" })\n end", "def cancel\n investment = Investment.new(session[:investment_attributes])\n investment.skip_validation = true\n investment.status = 1\n if investment.save\n redirect_to investments_path, notice: \"Your Investments successfuly saved!\"\n else\n redirect_to start_wizard_investment_path, alert: \"Something went wrong, your investments hasn't been saved\"\n end\n end", "def remove\n if status == \"pending\"\n reject\n else\n destroy\n end\n end", "def destroy\n\n # Save the capital project\n capital_project = @funding_request.activity_line_item.capital_project\n @funding_request.destroy\n notify_user(:notice, \"The Funding Request was successfully removed from ALI #{@activity_line_item.name}.\")\n\n # Check to see if the capital project status needs to change after removing\n # the funding request\n if capital_project.funding_difference != 0\n capital_project.save\n end\n\n respond_to do |format|\n format.html { redirect_to capital_project_activity_line_item_url(@project, @activity_line_item) }\n format.json { head :no_content }\n end\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 cancel\n @order.cancel\n render_update @order\n end", "def destroy\n @account_transactions = Transaction.all\n @account_transactions.each do |transaction|\n if transaction.account.acc_number == @account.acc_number\n transaction.destroy\n elsif transaction.transtype == 'Borrow' && transaction.status == 'Pending' && transaction.receiver == @account.acc_number\n #a borrow trans, still pending, and has reciever as the acct being deleted, decline acct and set effective date\n transaction.status= 'Declined'\n transaction.effective_date = Time.now\n transaction.save\n end\n end\n @account.destroy\n respond_to do |format|\n format.html { redirect_to accounts_url, notice: 'Account was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def cancels_proposal\n context.proposal.destroy!\n end", "def yunbi_cancel_order (id:0, base:nil)\n if 0 == id\n return nil\n end\n\n begin\n client = new_yunbi_client\n response = client.post '/api/v2/order/delete', {\"id\":id}\n $LOG.debug (method(__method__).name) { {\"return\"=>response} }\n return response\n rescue Exception => e\n puts e\n $LOG.debug (method(__method__).name) { {\"error\"=>e} }\n return nil\n end\nend", "def cancel\n\t\tself.status = 'Canceled'\n\t\tself.save(validate: false)\n\tend", "def internal_delete_object\n if self.transaction_activity.is_confirmed?\n self.errors.add(:generic_errors, \"Transaction sudah di konfirmasi\")\n return self \n end\n \n self.destroy \n end", "def orderCanceled\n order = Order.last\n user = User.find(Contract.find(order.contract_id).buyer_id)\n MagicMailer.orderCanceled(order, user)\n end", "def mark_as_cancelled\n update({\n stripe_status: 'canceled',\n ends_at: Time.current,\n })\n end", "def test_bp_cancel_billing_imm\n bp = create_entitlement_base(@account.account_id, 'Sports', 'MONTHLY', 'DEFAULT', @user, @options)\n check_entitlement(bp, 'Sports', 'BASE', 'MONTHLY', 'DEFAULT', DEFAULT_KB_INIT_DATE, nil)\n\n # Move clock a few days ahead\n kb_clock_add_days(10, nil, @options)\n\n # We specify a requested_date which is in between the start_date and the current date to verify\n # this is has been honored\n requested_date = '2013-08-05'\n entitlement_policy = nil\n billing_policy = 'IMMEDIATE'\n use_requested_date_for_billing = nil\n\n bp.cancel(@user, nil, nil, requested_date, entitlement_policy, billing_policy, use_requested_date_for_billing, @options)\n\n canceled_bp = get_subscription(bp.subscription_id, @options)\n check_subscription(canceled_bp, 'Sports', 'BASE', 'MONTHLY', 'DEFAULT', DEFAULT_KB_INIT_DATE, requested_date, DEFAULT_KB_INIT_DATE, '2013-08-11')\n end", "def destroy\n cancel_contract!\n render json: { success: true }, status: :ok\n end", "def send_email_request_cancelled\n send_email_request_approved\n end", "def cancel_signature_request(opts)\n post(\"/signature_request/cancel/#{opts[:signature_request_id]}\", body: opts)\n end", "def destroy\n @current_account.cancel\n\n AccountMailer.canceled(@current_account).deliver_later\n\n redirect_to account_canceled_path, notice: 'Account was successfully canceled.'\n end", "def cancel_request\n\t\tuser = current_user\n\n\t\tassignment = Assignment.find_by(request_id: params[:request_id])\n\t\tuser.accepteds.delete(assignment)\n\t\tpending_status = RequestStatus.find_by(description: \"pending accept\")\n\t\tpending_status.assignments << assignment\n\n\t\tredirect_back fallback_location: '/home'\n\tend", "def handle_cancel_response(response)\n cancel_response = response\n status = cancel_response[\"status\"]\n data = cancel_response[\"data\"]\n\n if status == \"success\"\n response = {\"error\": false, \"data\": data}\n return JSON.parse(response.to_json)\n else\n response = {\"error\": true, \"data\": data}\n raise CancelPaymentPlanError, JSON.parse(response.to_json)\n end\n end", "def cancel(error)\n @cancelled = true\n @__context__.remove(self)\n end", "def cancelled?\n status_code == 'ABORT'\n end", "def cancel_request_for(requested_item)\n url = @server.vxws_uri(\"CancelService\")\n request = Net::HTTP::Post.new(url.path)\n request.body = cancel_request_post_data(requested_item)\n response = Net::HTTP.new(url.host, url.port).start {|http| http.request(request) }\n response.body\n end", "def cancel(transaction_id)\n response = provider.void(transaction_id, nil)\n provider.refund(nil, nil, transaction_id, {refund_all: true}) unless response.success?\n end", "def remove_payment\n @payment = Payment.find(params[:id])\n @payment.update!(state: 2)\n end", "def destroy\n ## Get the id of subunit in order to redirect once payment is deleted\n subunit = @rent_payment.subunit\n\n ## As payment is being deleted, change status of rent charge to false\n subunit_rent = @rent_payment.subunit_rent\n subunit_rent.payed = false\n subunit_rent.save!\n\n ## Destroy the payment\n @rent_payment.destroy\n\n respond_to do |format|\n format.html { redirect_to subunit_path(subunit), notice: 'Rent payment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def cancel_scheduled_payment_transaction_by_external_key_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PaymentsApi.cancel_scheduled_payment_transaction_by_external_key ...\"\n end\n # resource path\n local_var_path = \"/1.0/kb/payments/cancelScheduledPaymentTransaction\"\n\n # query parameters\n query_params = {}\n query_params[:'transactionExternalKey'] = opts[:'transaction_external_key'] if !opts[:'transaction_external_key'].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 header_params[:'X-Killbill-CreatedBy'] = opts[:'x_killbill_created_by'] if !opts[:'x_killbill_created_by'].nil?\n header_params[:'X-Killbill-Reason'] = opts[:'x_killbill_reason'] if !opts[:'x_killbill_reason'].nil?\n header_params[:'X-Killbill-Comment'] = opts[:'x_killbill_comment'] if !opts[:'x_killbill_comment'].nil?\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(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PaymentsApi#cancel_scheduled_payment_transaction_by_external_key\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def cancel(id); end" ]
[ "0.69355446", "0.6841983", "0.6754656", "0.6667826", "0.6615182", "0.65919185", "0.6570695", "0.65464526", "0.64938396", "0.6401845", "0.6380504", "0.6350311", "0.63450956", "0.63450956", "0.6334871", "0.6310997", "0.6289712", "0.62858653", "0.62611973", "0.62432975", "0.6238143", "0.62172264", "0.6202574", "0.61977696", "0.61907214", "0.61570114", "0.61520433", "0.6144408", "0.6126169", "0.6109427", "0.6108636", "0.6095367", "0.6085607", "0.60614944", "0.6052401", "0.60510856", "0.6050576", "0.604587", "0.6043221", "0.60427016", "0.60062134", "0.5989128", "0.5986641", "0.5985711", "0.5967759", "0.59614074", "0.5957513", "0.595662", "0.5956206", "0.59547514", "0.5954075", "0.59418327", "0.5940241", "0.5927975", "0.5924021", "0.591411", "0.5911121", "0.58932394", "0.5889044", "0.5885564", "0.588309", "0.587364", "0.5871164", "0.5868352", "0.5861903", "0.5861903", "0.5855272", "0.5855272", "0.58524853", "0.5848853", "0.58472246", "0.5835061", "0.5831993", "0.5822251", "0.58145833", "0.58141136", "0.5814099", "0.5813295", "0.58132654", "0.58069724", "0.580515", "0.58025175", "0.57988507", "0.5798436", "0.5793066", "0.5779083", "0.5775689", "0.5768016", "0.57626945", "0.57611156", "0.57550687", "0.575283", "0.5750051", "0.5738284", "0.57363886", "0.57301545", "0.5727925", "0.57254994", "0.57248914", "0.57157713" ]
0.72221696
0
Privates TODO source not yet passed here, add when needed
def transition_type(tx, payment) payment_status = payment[:payment_status] pending_reason = payment[:pending_reason] tx_state = tx[:status] case [tx_state, payment_status, pending_reason] when ["initiated", :pending, :authorization] :initiated_to_preauthorized when ["initiated", :voided, :none] :initiated_to_voided when ["preauthorized", :voided, :none] else :unknown_transition end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def internal; end", "def usage; end", "def usage; end", "def extra; end", "def private_method\n end", "def private_notes\n \n end", "def example_pending; end", "def main_description; end", "def pending?; end", "def implementation; end", "def implementation; end", "def todo\n flunk \"test not written\"\n end", "def who_we_are\r\n end", "def private_notes\n end", "def internal?; end", "def probers; end", "def used?; end", "def hints; end", "def processed_source=(_); end", "def processed_source=(_); end", "def entry; end", "def entry; end", "def entry; end", "def entry; end", "def helpers; end", "def helpers; end", "def helpers; end", "def modified?; end", "def todo_tag(text); end", "def refutal()\n end", "def extra_pubish_tasks(p)\n \n end", "def custom; end", "def custom; end", "def extra_state; end", "def unused\n end", "def doc_task; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def source_line=(_); end", "def source() end", "def missed?; end", "def how_it_works\r\n end", "def doc_task=(_arg0); end", "def factories_to_lint; end", "def base_docstring; end", "def need_help \n end", "def before_lint; end", "def desc=(_); end", "def pre_generation_hook(task)\n end", "def incomplete\r\n\r\n end", "def enter_pending; end", "def docstring; end", "def docstring; end", "def base_description(_); end", "def purpose\n end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def process_fix\n super\n end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def adapt_source(source); end", "def notes; end", "def notes; end", "def notes; end", "def missing; end", "def desc; end", "def source(override); end", "def anatomy; end", "def operations; end" ]
[ "0.68431306", "0.6068417", "0.6043124", "0.6043124", "0.59161043", "0.58871865", "0.5838618", "0.5833893", "0.57494", "0.56986094", "0.5692667", "0.5692667", "0.5692447", "0.5670363", "0.56643975", "0.5653755", "0.5649849", "0.564068", "0.5617287", "0.56069773", "0.56069773", "0.5599461", "0.5599461", "0.5599461", "0.5599461", "0.55883956", "0.55883956", "0.55883956", "0.5558934", "0.55243194", "0.55207133", "0.55046123", "0.5495993", "0.5495993", "0.5468814", "0.5462664", "0.546006", "0.544886", "0.544886", "0.544886", "0.544886", "0.544886", "0.544886", "0.544886", "0.544886", "0.544886", "0.544886", "0.544886", "0.5443325", "0.5440304", "0.5429925", "0.5426365", "0.54127777", "0.5406461", "0.5402364", "0.53962654", "0.5392491", "0.53915226", "0.5380872", "0.5373101", "0.5369104", "0.53680146", "0.53680146", "0.5365162", "0.535595", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.53535354", "0.5351371", "0.5351371", "0.5351371", "0.5351371", "0.53379816", "0.53347826", "0.53347826", "0.53347826", "0.53347826", "0.53347826", "0.53257996", "0.5311476", "0.5311476", "0.5311476", "0.5305678", "0.53046316", "0.52863735", "0.52853733", "0.5282063" ]
0.0
-1
The _render_ method is used within a layout to inject the results of the template render. Ruhl::Engine.new(html, :layout => path_to_layout).render(self)
def _render_ document.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_rhtml(name)\n logmsg \"base_controller::render_rthml rendering #{name}\"\n content = get_rhtml(name)\n #logmsg \"base_controller::render_rhtml_internal() file not found #{name}\" if !content && @@debug\n return nil if !content\n if @body\n temp = body\n @body = \"\"\n erb = ERB.new(content,nil,nil,\"@body\")\n erb.result(binding)\n @body = temp + @body\n else\n erb = ERB.new(content,nil,nil,\"@body\")\n erb.result(binding)\n end\n # something in erb handling is changing the session! xxx\n # @session = Session.find_by_hashid cookies.anselm_sid\n return \"\"\n end", "def render\n @template.to_haml(0, @options)\n end", "def render\n layout = File.read \"#{site.root}/_layouts/#{@layout}.html\"\n @output = Liquid::Template.parse(layout).render('post'=>self) \n end", "def render\r\n erb = ERB.new(File.read(html_dir + \"/index.html.erb\"))\r\n erb.result data.get_binding\r\n end", "def do_render\n Mustache.render(template, self)\n end", "def render r\n end", "def render_result\n layout = @render_args[:layout]\n view = @render_args[:view]\n if layout.kind_of? Symbol # this handles the layout(:none)\n view.result(binding)\n else\n @view[:timestamp] = \"<!-- rendered: #{Time.now()} / env: #{rack_env} -->\"\n @view[:body] = view.result(binding)\n # layout = @layout if layout.nil? # this handles the layout(:some_other_layout) case for formats\n layout.result(binding)\n end\n end", "def render_result\n layout = @render_args[:layout]\n view = @render_args[:view]\n if layout.kind_of? Symbol # this handles the layout(:none)\n view.result(binding)\n else\n @view[:timestamp] = \"<!-- server: #{@port} / rendered: #{Time.now()} / env: #{rack_env} -->\"\n @view[:body] = view.result(binding)\n # layout = @layout if layout.nil? # this handles the layout(:some_other_layout) case for formats\n layout.result(binding)\n end\n end", "def render_template(view, template, layout_name, locals); end", "def render(template_name)\n if already_built_response? \n raise \"DoubleRenderError\"\n else \n controller_name = self.class.to_s.underscore \n dir = File.join(\"views\",controller_name, \"#{template_name}.html.erb\")\n # debugger\n content = File.read(dir).split(\"\\n\")\n content.map! do | statement | \n start_point = /<%/ =~ statement\n # debugger\n if start_point.nil? \n statement\n else \n front_part = statement[0...start_point]\n # returning = \n # start_point += statement[start_point+2] == \"=\" ? 2 : 1\n end_point = /%>/ =~ statement \n end_point += 1\n rear_part = statement[end_point+2..-1]\n front_part.to_s + ERB.new(statement[start_point..end_point]).result(binding) + rear_part.to_s\n end \n end \n render_content(content)\n end \n end", "def _render_template(options); end", "def _render_template(options); end", "def render(options = {})\n options.merge! :vendor_lua => @vendor_lua if @vendor_lua\n #debugger\n #puts \">> LAMINATE RENDER START. Disabling gc.\"\n #GC.disable\n # Compile template if needed\n name = @name.dup\n prepare_template(name)\n lua = @loader.load_compiled(name).dup\n\n @errors = []\n error_proc = Proc.new {|err| handle_error(err, lua, options)}\n\n State.new(options).run(error_proc) do |state|\n state.logger = logger\n state.eval(lua)\n # Included template functions. The trick is that we don't return to Ruby and eval the included template, because the\n # Lua binding doesn't like re-entering eval. So instead we bind a function '_load_template' which returns the template\n # code, and then we eval it inside Lua itself using 'loadstring'. Thus the template 'include' function is actually\n # a native Lua function.\n state.function '_load_template' do |template_name|\n prepare_template(template_name)\n load_template_innerds(template_name)\n end\n\n state.eval(\"return #{@compiler.lua_template_function(name)}()\")\n end\n end", "def render(options)\n case\n when options.has_key?(:text)\n response.body = options[:text]\n when options.has_key?(:template)\n template_filename = options[:template]\n template_string = IO.read(template_filename)\n view = View.new(self)\n template_engine = engine_for(template_string, :filename => template_filename)\n view.content = template_engine.render(view)\n if has_layout?\n layout_string = IO.read(layout)\n layout_engine = engine_for(layout_string, :filename => layout)\n response.body = layout_engine.render(view) do |*args|\n view.get_content_for(*args)\n end\n else\n response.body = view.content\n end\n else\n raise 'invalid options passed to render'\n end\n @_rendered = true\n response.body\n end", "def render(template_name)\n contents = File.read(\"views/#{self.class.to_s.underscore}/#{template_name}.html.erb\")\n template = ERB.new(contents)\n # ivars = self.instance_variables\n new_content = template.result(binding)\n render_content(new_content, \"text/html\")\n end", "def render(options)\n if options[:haml]\n template_content = File.read(options[:haml])\n @page_contents << Haml::Engine.new(template_content).render(self) \n elsif options[:partial]\n template_content = File.read(options[:haml])\n return Haml::Engine.new(template_content).render(self) \n elsif options[:text]\n @page_contents << options[:text]\n else\n raise \"No render type found. Must be haml, partial or text\"\n end\n end", "def render_output(html_title, html_body, erb_template)\n # assign i_vars referenced in template file\n @title = html_title\n @body = html_body\n\n erb = ERB.new(erb_template)\n erb.result(binding)\n end", "def render(options = nil, extra_options = {}, &block) #:doc:\n @flash=flash\nputs \"RENGINE RENDER #1\"\n options=interpret_rengine_options(options)\nputs \"RENGINE RENDER #2\"\n #no layout\n super(options,extra_options,&block)\nputs \"RENGINE RENDER #3\"\n unless self.no_wrap\nputs \"RENGINE RENDER #4a\"\n \n \n txx=render_weblab(setUserJavascript+ self.response_body.join(\"\\n\"))\n puts \"RENGINE RENDER #4b\"\n\n # puts \"===========================\\n\"+txx.join(\"\\n\")+\"\\n!================================!\"\n\n if $render_translation_link\n txx << \"\\n<div style=\\\"background-color:#aaa;color:#0ff;\\\">\\n\"\n txx << translation_tool(@displayed_blurb_names)\n txx << \"\\n</div>\\n\"\n end\nputs \"RENGINE RENDER #5\"\n\n self.response_body=txx\n \n end\n end", "def render(template_name, view_handler, locals, &content)\n self.kramdown_source.render(template_name)\n end", "def render\n template_body = Tilt.new(@template).render(self)\n if @layout\n layout = Dir[File.join(File.dirname(@template), @layout) + '*'].first\n raise \"#{Guinness::EMOJI} Guinness : Unable to locate layout at: '#{@layout}'\" unless layout\n @body = Tilt.new(layout).render(self) { template_body }\n end\n @body || template_body\n end", "def render\n raise NotImplementedError.new \"Please override 'render' in your \"+\n \"concrete implementation\"\n end", "def render(template_name)\n controller_name = self.class.to_s.gsub(/Controller$/, '').underscore\n base_template = ERB.new File.read(\"app/views/layouts/application.html.erb\")\n page_template = ERB.new File.read(\"app/views/#{controller_name}/#{template_name}.html.erb\")\n page = page_template.result(call_binding)\n content = base_template.result(call_binding { page })\n render_content(content, \"text/html\")\n end", "def render(html, options={})\n require \"haml\" unless defined? Haml\n Haml::Engine.new(html, options).render\nend", "def render(template_path)\n template = File.read(\"#{app.views}/#{template_path.sub(/^\\//, '')}\")\n engine = Haml::Engine.new(template)\n @response = engine.render(self, assigns_for_template)\nend", "def _render_one(entry)\n @entry = entry\n @filename = @entry.filename\n\n # avoid double render of layout path\n return if @entry.source_path == @layout_path\n\n # render. Result goes into @content_for_resources\n input = File.read(@entry.source_path)\n \n # render using either erb or haml\n case File.extname(@entry.source_path)\n when /\\.rhtml$/, /\\.html.erb$/\n @content_for_resources += eval(Erubis::Eruby.new.convert(input))\n when /\\.haml$/, /\\.html.haml$/\n require 'haml'\n @content_for_resources += Haml::Engine.new(input).to_html(self)\n end\n\n @filename =nil\n @entry = nil\n end", "def render_view(template, params={})\n params[:controller] = self\n template = \"#{template}.rhtml\" if template.is_a? Symbol\n content = @@erb_template.new(template, params, plugin_name()).string\n @response[:html] << content\n @response[:script] << params[:script] if params[:script]\n end", "def render opts = {}\n renderer.render opts\n end", "def render(template_name)\n controller_name = self.class.to_s.underscore\n filepath = \"views/#{controller_name}/#{template_name}.html.erb\"\n file = File.read(filepath)\n\n to_render = ERB.new(file).result(binding)\n\n self.render_content(to_render, \"text/html\")\n end", "def render\n end", "def render(template_name)\n path = File.join('views', self.class.name.underscore, \"#{template_name}.html.erb\")\n file = File.read(path)\n @flash = flash.now unless flash.now.empty?\n render_content(ERB.new(file).result(binding), 'text/html')\n end", "def render_html_body\n # FIXME actually render the text\n renderer.new(body).to_html\n end", "def render_template(context, options); end", "def render(name, options = {})\n options = options.merge(:request => request, :params => params)\n content = render_template(name, options)\n layout = options.delete(:layout)\n \n if name[0, 1] == '_'\n return content\n \n elsif layout == false\n response.body = content\n else\n options.merge!(:content => content)\n response.body = render_template(layout || \"layout.rhtml\", options)\n end\n\n response['Content-Length'] = response.body.size.to_s\n end", "def build_html\n ApplicationController.render(partial: partial, locals: locals)\n end", "def render(template)\n template = File.read(\"./views/#{template}\")\n engine = Haml::Engine.new(template)\n @response = engine.render\nend", "def render(template_name)\n template = ERB.new(File.read(\"views/#{self.class.to_s.underscore}/#{template_name}.html.erb\"))\n bindings = binding()\n render_content(template.result(bindings), \"text/html\")\n end", "def to_html\n layout = ENV['RONN_LAYOUT']\n layout_path = nil\n if layout\n layout_path = File.expand_path(layout)\n unless File.exist?(layout_path)\n warn \"warn: can't find #{layout}, using default layout.\"\n layout_path = nil\n end\n end\n\n template = Ronn::Template.new(self)\n template.context.push html: to_html_fragment(nil)\n template.render(layout_path || 'default')\n end", "def render(*args) \n return '' if @root.nil? \n \n context = case args.first\n when Liquor::Context\n args.first\n when Hash\n Context.new([args.first, assigns], instance_assigns, registers, @rethrow_errors)\n when nil\n Context.new(assigns, instance_assigns, registers, @rethrow_errors)\n else\n raise ArgumentError, \"Expect Hash or Liquor::Context as parameter\"\n end\n \n options = nil\n case args.last\n when Hash\n options = args.last\n \n if options[:registers].is_a?(Hash)\n self.registers.merge!(options[:registers]) \n end\n\n if options[:filters]\n context.add_filters(options[:filters])\n end\n \n if options[:layout]\n raise ArgumentError, \"Expected Liquor::Template as layout argument\" unless options[:layout].is_a? Liquor::Template\n end \n \n when Module\n context.add_filters(args.last) \n when Array\n context.add_filters(args.last) \n end\n \n begin \n # render the nodelist.\n # for performance reasons we get a array back here. join will make a string out of it\n res = @root.render(context).join\n \n if options && options[:layout]\n content_for_assigns = (context.has_key?(\"content_for\") ? context[\"content_for\"] : {})\n content_for_assigns = content_for_assigns.merge({ \"_rendered_template_\" => res })\n \n case args.first\n when Liquor::Context\n args.first[\"content_for\"] = content_for_assigns\n when Hash\n args.first.merge!({ \"content_for\" => content_for_assigns })\n end \n \n layout_template = args.last.delete(:layout)\n \n # Here we execute render method of the Liquor::Template object (we execute _this_ method)\n # It is not the @root.render method. It is a result of the @root.render(context).join\n # so we don't need to call join here.\n res = layout_template.render(*args)\n end\n \n res\n ensure\n @errors = context.errors\n end\n end", "def render(context, options); end", "def render(*args, &block); end", "def render\n ERB.new(load_resource(template)).result(bound.get_binding)\n end", "def render(template_name)\n controller_name = self.class.to_s.underscore\n\n string = File.read(\"./views/#{controller_name}/#{template_name}.html.erb\")\n #\"./\" for project root dir\n\n template = ERB.new(string)\n capture = template.result(binding) #evaluate and bind\n\n render_content(capture, \"text/html\")\n end", "def render(webroot = Pathname.new('/'))\n @webroot = webroot\n Haml::Engine.new(@template).render(self)\n end", "def render\n # To be implemented.\n end", "def render(options = {})\n template.render options\n end", "def render(props)\n # HTML.\n end", "def render(template = nil)\n template = self.get_default_tpl if template.nil?\n @template = self.normalize_tpl(template)\n @layout = self.get_layout(@template)\n __tpl__ = @layout.nil? ? @template : @layout\n @tpl_stack.push(__tpl__.gsub(/\\W/, '_'))\n result = ::ERB.new(File.read(self.get_tpl_file(__tpl__)), nil, nil, 's2cgi_' + @tpl_stack.join('_')).result(binding)\n @tpl_stack.pop\n self.render_result(result)\n end", "def render(template_path)\n template = File.read(\"./#{template_path.sub(/^\\//, '')}\")\n engine = Haml::Engine.new(template)\n @response = engine.render(self, assigns_for_template)\nend", "def render(template_path)\n template = File.read(\"./#{template_path.sub(/^\\//, '')}\")\n engine = Haml::Engine.new(template)\n @response = engine.render(self, assigns_for_template)\nend", "def erb(template) render template end", "def render\n case File.extname(@template_file)\n when '.erb'\n render_erb\n else\n render_plain\n end\n end", "def render(text)\n return Mustache.render(text, self)\n end", "def render(request)\n case format\n when :html\n @data\n when :erb\n scope = Scope.new(request, @view_registry)\n view_html = Tilt[\"erb\"].new { @data }.render(scope)\n\n if @layout_data\n layout_template = Tilt[\"erb\"].new { @layout_data }\n layout_template.render(scope) { view_html }\n else\n view_html\n end\n end\n end", "def render\n template = ERB.new File.new(@template_path).read, nil, \"%\"\n template.result(binding)\n end", "def render(html, context = {})\n @context = context = (@context || {}).merge(context)\n html = render_sections(html)\n @context = context\n render_tags(html)\n end", "def render(view, locals, buffer=nil, &block)\n @template.instance_variable_set(:'@source', wrapped_source)\n\n super(view, locals, buffer, &block)\n end", "def render_plain\n template_content\n end", "def render\n raise NotImplementedError, \"Subclasses must implement a render method\"\n end", "def render_layout(output, layout, info); end", "def render\n raise NotImplementedError\n end", "def render(template_name)\n # \"views/#{controller_name}/#{template_name}.html.erb\"\n\n # format view path\n controller_name = self.class.to_s.underscore\n view_path = \"views/#{controller_name}/#{template_name}.html.erb\"\n\n # read in contents of view file and interpret embedded ruby\n view_content = File.read(view_path)\n template_content = ERB.new(view_content).result(binding) # binding gives erb access to ivars\n\n # html/text downloads output???\n render_content(template_content, \"text/html\")\n end", "def render(_, _)\n self.class.run(@filename, @source)\n end", "def to_html(*options)\n view = View.new(self)\n # todo: this is not clean...\n options = (options.shift || {}).merge!(@options || {})\n # todo: if rails is loaded set the default engine: dynamicreports::report.default_engine\n engine = options.delete(:engine) || @@default_engine\n options[:template] = self.class.template\n view.__send__(\"#{engine}\", options)\n end", "def render(*args); end", "def render(*args); end", "def render\n erb_page = ERB.new(content).result(binding)\n Kramdown::Document.new(erb_page).to_html.html_safe\n end", "def render_layout(layout, **kwargs, &block)\n render html: capture(&block), layout: \"layouts/#{layout}\", **kwargs\n end", "def render()\n # WARNING! NO NEED TO UNDERSTAND THIS\n self.action = calling_method = caller[0].split(\"`\").pop.gsub(\"'\", \"\")\n template = File.read(view_filename)\n eruby = Erubis::Eruby.new(template)\n eruby.result(binding())\n end", "def render(template_name)\n controller_name = self.class.name.underscore\n dir_path = File.dirname(__FILE__)\n\n file_path = File.join(dir_path, \"..\", 'views', controller_name, \"#{template_name}.html.erb\")\n file_content = File.read(file_path)\n\n template = ERB.new(file_content)\n render_content(template.result(binding), 'text/html')\n end", "def render(template, local_assigns={})\n @view.instance_eval do\n evaluate_assigns\n end\n\n options = @@options.dup\n locals = options[:locals] || {}\n locals.merge! local_assigns\n options[:locals] = locals\n\n if @view.haml_inline\n engine = Haml::Engine.new(template, options)\n else\n options[:filename] ||= template\n engine = Haml::Engine.new(File.read(template), options)\n end\n\n yield_proc = @view.instance_eval do\n proc { |*name| instance_variable_get(\"@content_for_#{name.first || 'layout'}\") }\n end\n\n engine.to_html(@view) { |*args| yield_proc.call(*args) }\n\n end", "def render(*args, &block)\n\t options = _normalize_render(*args, &block)\n\t self.response_body = render_to_body(options)\n\t _process_format(rendered_format, options) if rendered_format\n\t self.response_body\n\t end", "def uncached_render\n before_process\n\n content = engine.transform(self)\n\n if path and tlayout = layout\n [instance, tlayout.instance].each do |i|\n i.instance_variable_set(\"@content\", content)\n end\n\n content = tlayout.render\n end\n\n content\n\n ensure\n after_process unless $!\n end", "def render!\n render :file => template_path\n end", "def render(path, hash={})\n @template.class.new(path, localized_look_in).render(@hash.merge(hash)).strip\n end", "def render\n end", "def render\n end", "def render\n end", "def render\n raise NotImplementedError, 'this should be overridden by concrete sub-class'\n end", "def _render_layout_for( res )\n return unless res.layout\n lyt = Resources.layouts.find :filename => res.layout\n return if lyt.nil?\n\n _track_rendering(lyt.path) {\n @content = Filters.process(\n self, lyt, ::Webby::Resources::File.read(lyt.path))\n _render_layout_for(lyt)\n }\n end", "def render\n raise NotImplementedError\n end", "def render(template)\n @renderer.render(template, @request.accept.types, self)\n end", "def render_with_engine_additions(opts)\n template_path_for_method = Dir[\"#{template_path}/#{opts[:file]}*\"].first\n body = opts.delete(:body)\n i = initialize_template_class(body)\n i.base_path = File.dirname(template_path_for_method)\n i.render(opts)\n end", "def render(erb)\n erb.result(binding)\n end", "def render!\n write_out('HTML', 'index.html', @html_template.render)\n write_out('feed', 'feed.xml', @feed_template.render)\n end", "def render(view, locals, buffer = nil, add_to_stack: true, &block)\n instrument_render_template do\n compile!(view)\n if buffer\n view._run(method_name, self, locals, buffer, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)\n nil\n else\n view._run(method_name, self, locals, OutputBuffer.new, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)&.to_s\n end\n end\n rescue => e\n handle_render_error(view, e)\n end", "def render(context = Erubis::Context.new)\n # Read template data\n template_filename = \"#{@template}.rhtml\"\n begin\n template = File.read(template_filename)\n rescue Errno::ENOENT\n raise ScriptError.new(\"Template #{template_filename} does not exist!\")\n end\n\n # Prepare template and variables\n eruby = Erubis::Eruby.new template\n \n # Perform templating\n begin\n result = eruby.evaluate context\n rescue\n raise TemplateError.new(\"Encountered error processing template #{template_filename}.\", $!)\n end\n\n # Output result\n output result \n end", "def render_template(options={})\n # puts \"ActionController#render_template(start), options = #{options}\"\n #`var d = new Date(); console.log(\"time= \" + d.getSeconds() + \":\" + d.getMilliseconds());`\n #Timer.time_stamp(\"render_template (begin)\")\n content_fors = options.delete(:content_for) || {}\n partial = options[:partial]\n\n # renderer = ActionView::Renderer.new(self, path: render_path)\n # puts \"renderer = #{@renderer.inspect}\"\n if partial\n # puts \"ActionController#render_template (partial)\"\n top_view_html = @renderer.render(options)\n else\n # puts \"ActionController#render_template (file)\"\n top_view_html = @renderer.render(file: render_path, options: {locals: @__locals})\n end\n\n content_for_htmls = {}\n content_fors.each do |key, selector|\n content_for_html = @renderer.content_fors[key]\n #puts \"content for #{key} = #{content_for_html}\"\n content_for_htmls[selector] = content_for_html\n end\n #`var d = new Date(); console.log(\"time= \" + d.getSeconds() + \":\" + d.getMilliseconds());`\n [top_view_html, content_for_htmls]\n end", "def render\n raise \"Trying to call abstract method for #{self}\"\n end", "def rendered; end", "def render; end", "def render; end", "def render; end", "def render; end", "def render; end", "def render(template_name)\n #Open template, put content into string-content\n cntrl_name = self.class.to_s.underscore\n\n erb_temp = File.read(\"views/#{cntrl_name}/#{template_name}.html.erb\")\n content = ERB.new(erb_temp).result(binding)\n\n render_content(content , 'text/html')\n end", "def render\n Node.new.instance_eval(template)\n end", "def render(template_name, context=Context.new, layout=true)\n #context = Context.new(context) if context.is_a?(Hash)\n context = hook_context(context)\n while true\n template = get_template(template_name, context) # context is passed only for preprocessor\n _buf = context._buf\n output = template.render(context)\n context._buf = _buf\n unless context._layout.nil?\n layout = context._layout\n context._layout = nil\n end\n layout = @layout if layout == true or layout.nil?\n break unless layout\n template_name = layout\n layout = false\n context.instance_variable_set('@_content', output)\n end\n return output\n end", "def render(data = {}, &block)\n output = content(data, &block)\n output = layout.render(get_data(data)) { output } unless layout.nil?\n output\n end", "def render(locals = {})\n liquify(wrap_in_layout(string), (options[:locals] || {}).merge(locals))\n end", "def html\n @html ||= Template.new(\"#{@input_file}:body\", @body).\n render_with(template_ivar => self).to_html\n end", "def render (workitem)\n\n eval_template workitem\n end" ]
[ "0.7152846", "0.69996667", "0.6934577", "0.6898046", "0.6896382", "0.6864809", "0.686088", "0.677647", "0.67536", "0.67215997", "0.67098606", "0.67098606", "0.67020935", "0.6696569", "0.66872424", "0.6673592", "0.6666515", "0.6646769", "0.6625404", "0.6603426", "0.6600309", "0.65967757", "0.65894586", "0.65892714", "0.65889734", "0.6581335", "0.65686774", "0.6534258", "0.6534111", "0.6529743", "0.6523593", "0.6482497", "0.64807856", "0.6478948", "0.646661", "0.64653367", "0.6464453", "0.64582676", "0.6449882", "0.644937", "0.64201474", "0.6417705", "0.6417448", "0.64136803", "0.6407305", "0.6405609", "0.63992715", "0.63880813", "0.63880813", "0.63829887", "0.63689935", "0.6364383", "0.63609546", "0.6354455", "0.63542813", "0.63522494", "0.6344017", "0.63389945", "0.6331765", "0.63277096", "0.63259435", "0.632171", "0.6314541", "0.6312597", "0.6312597", "0.6294285", "0.62935567", "0.62864625", "0.62851614", "0.6283352", "0.6279119", "0.627705", "0.62733877", "0.62722355", "0.62712705", "0.62712705", "0.62712705", "0.6270655", "0.6263568", "0.6259063", "0.6257539", "0.6250125", "0.62473476", "0.62453103", "0.62452275", "0.6244354", "0.62282497", "0.62229615", "0.62201864", "0.62183744", "0.62183744", "0.62183744", "0.62183744", "0.62183744", "0.6215384", "0.6214276", "0.62113106", "0.6207929", "0.6203142", "0.619838", "0.6194688" ]
0.0
-1
Here I want to check that the basket matches price.
def create_receipt total_cost = 0 @basket.each {|item, quantity| total_cost += price(item,quantity) } total_cost end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_price\n end", "def check_basket(basket)\n increase_support if in_basket?(basket)\n end", "def test_PPPPQRUVPQRUVPQRUVSU\n basket = Checkout.new.checkout('PPPPQRUVPQRUVPQRUVSU')\n # PPPPPP QQQ RRR S UUUU VVV\n # 250 + [80 + 150(Free Q?)] + 30 + 120 + 130\n # Q=30\n # R5 pricing: S=20, was 30\n assert_equal 730, basket, '4F, pay for 3F because third free'\n end", "def price_is_right(bids, actual_retail_price)\n \nend", "def purchasing?\n auction.buy_it_now_price == amount\n end", "def order_price_check order_number, order_sum\n order = Order.where(uid: order_number).first\n return :order_not_found unless order\n\n order_price = money_round(order.total_price).to_f\n equal_prices = ('%.2f' % order_sum.to_f) == ('%.2f' % order_price)\n\n return :incorrect_price unless equal_prices\n\n :correct_price\n end", "def can_buy_drug?(price, qty)\n wallet > (price * qty) \n end", "def price_is_right(bids, actual_retail_price)\n winning_bid = 0\n bids.each {|current_bids| winning_bid = current_bids if current_bids < actual_retail_price && current_bids > winning_bid}\n winning_bid\nend", "def under_five(cart)\n\tcart.all? do |item|\n\t\titem.all? do |name, data|\n\t\t\tdata[:price] <= 5\n\t\tend\n\tend\nend", "def price_is_right(bids, actual_retail_price)\n #\n # your code goes here\n #\nend", "def paid_enough(hash, price)\n temp_paid = cash_converters(hash)\n if temp_paid >= price then true else false end\n end", "def test_should_show_different_display_price_if_have_variations\n # Test a product without variations.\n a_grenade = items(:holy_grenade)\n assert_equal a_grenade.variations.count, 0\n assert_equal a_grenade.display_price, a_grenade.price\n # Test a product with variations.\n a_lightsaber = items(:lightsaber)\n assert_equal a_lightsaber.variations.count, 3\n assert_equal a_lightsaber.quantity, a_lightsaber.variations.sum(:quantity)\n a_lightsaber_0 = a_lightsaber.variations[0]\n a_lightsaber_1 = a_lightsaber.variations[1]\n a_lightsaber_2 = a_lightsaber.variations[2]\n # Test with different prices.\n assert_not_equal a_lightsaber_0.price, a_lightsaber_1.price\n assert_not_equal a_lightsaber_0.price, a_lightsaber_2.price\n assert_not_equal a_lightsaber_1.price, a_lightsaber_2.price\n assert_equal a_lightsaber.display_price[0], a_lightsaber.variations.min {|a,b| a.price <=> b.price }.price\n assert_equal a_lightsaber.display_price[1], a_lightsaber.variations.max {|a,b| a.price <=> b.price }.price\n # Test with equal prices.\n a_lightsaber_0.price = 10.00\n assert a_lightsaber_0.save\n a_lightsaber_1.price = 10.00\n assert a_lightsaber_1.save\n a_lightsaber_2.price = 10.00\n assert a_lightsaber_2.save\n assert_equal a_lightsaber.display_price, a_lightsaber.variations.min {|a,b| a.price <=> b.price }.price\n end", "def bought?\n # paym\n end", "def test_return_total_price\n # Create a cart and add some products.\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), 4)\n assert_equal a_cart.items.length, 2\n\n total = 0.0\n for item in a_cart.items\n total += (item.quantity * item.unit_price)\n end\n\n assert_equal total, a_cart.total\n end", "def expensive?\n base_price = an_order.base_price\n base_price > 1000\nend", "def validate(order)\n raise \"Total price is incorrect!\" if calculate_price != expected_price\n end", "def discounted?\n price < 10\n end", "def check_for_eligible_of_free_shipping(order)\n order.each do |key, price|\n if price > 100\n return true\n else\n return false\n end \n end\nend", "def fixed_price?\n !auction?\n end", "def check_price\n self.price = self.price.to_f\n end", "def shipping_free?(price)\n return price >= 50\nend", "def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )\n BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount.to_s ) == order_discount\n end", "def show\n @basket.set_price\n if params[:st]\n if @basket.address || @basket.type_of_delivery == '2'\n\n if params[:st]==1\n p=0\n @basket.cart_items.each do |c|\n if c.amount.to_i > c.dvd.amount\n p=1\n end\n end\n if p==0\n @basket.cart_items.each do |c|\n c.dvd.amount= c.dvd.amount- c.amount.to_i\n c.dvd.amount.save\n end\n else\n redirect_to @basket, notice: 'Нет в наличии'\n end\n else\n @basket.status=params[:st]\n @basket.save\n end\n else\n redirect_to @basket, notice: 'Не указан адрес'\n end\n end\n\n end", "def test_food_has_price\n assert_equal(1.50, @food1.price())\nend", "def checkout(cart, coupons)\n #call the consolidate to get the count item first\n new_cart = consolidate_cart(cart)\n #apply coupon to the new cart\n apply_coupons(new_cart, coupons)\n #apply clearance after discount from coupon\n apply_clearance(new_cart)\n\ntotal = 0\n new_cart.each do |name, hash|\n total += (hash[:price] * hash[:count])\n #binding.pry\n end\n\nif total >= 100\n total *= 0.9\n end\n\n total\nend", "def quantity_check_availabilty(shop_id)\n a = sub_products.map do |p|\n p.quantity if p.shop_id == shop_id\n end.reject(&:blank?)\n rv = a[0]\n end", "def in_stock?(product, quantity = 1)\n @inventory[product] && @inventory[product][\"quantity\"] >= quantity\nend", "def test_discount_on_less_quantity_of_item\n # Add 2 strawberries to line items\n line_items = [ @strawberry_in_cart_1, @strawberry_in_cart_2]\n @bulk_discount.apply(line_items)\n\n # Test if the discount is applied\n assert_equal @strawberry_in_cart_1.price, @strawberry.price, \"Discount not applied\"\n assert_equal @strawberry_in_cart_2.price, @strawberry.price, \"Discount not applied\"\n end", "def enough_order_size?(quantity, price)\n quantity * price > MIN_AMOUNT\n end", "def buy\n if @product.price <= @user.coin_credit # Checks whether the user has enough coin_credit or not\n purchase\n else\n @user.errors.add(:coin_credit, :not_enough_credit)\n false\n end\n end", "def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end", "def check_for_product(product)\n if @products.map(&:name).include?(product.capitalize)\n price = @products.select { |p| p.name == product.capitalize }.map(&:price)[0]\n puts \"Please pay #{price} pennies for the #{product.upcase}\"\n 1\n else\n puts 'Product is unavailable'\n 0\n end\n end", "def amount_ok?( order_amount )\n BigDecimal.new( amount ) == order_amount \n end", "def discounted?\n if price.to_f < 1000\n # return true\n # else\n # return false\n # end\n end\n end", "def cart_check\n puts \"cart checking\"\n \n sleep(2)\n mini_cart_text.click\n wait_for_spinner\n sleep(2)\n puts @prod2 = cartpage_productname.text.downcase\n if(@prod1 == @prod2)\n puts \"product is added to the cart: PASS\"\n else\n puts \"product is not added to the cart: FAIL\" # cart is invalid ie when items in the cart are sold out \n end\n end", "def customer_can_afford_pet?(customer_hash, wanted_pet)\n if customer_hash[:cash] >= wanted_pet[:price]\n true\n else\n false\n end\nend", "def check_new_price\n begin\n new_price = Float(params[:item][:new_price])\n add_price_error if new_price < 0\n rescue\n add_price_error\n end\n end", "def in_basket?(basket)\n @item_ids.all? do |item_id|\n basket.include?(item_id)\n end\n end", "def bids_above(price)\n\t\torders.where(\"order_type = 'buy' AND price > #{price}\").order(:price)\n\tend", "def customer_can_afford_pet(customer, new_pet)\n if customer[:cash] >= new_pet[:price]\n return true\n end\n return false\nend", "def is_discounted?\n price < 10\n end", "def is_discounted?\n price < 10\n end", "def check_cart item\n \tcheck = false\n \t#Doc tat ca san pham trong cart session\n \tsession[\"cart\"].each do |x|\n \t\t#So sanh ID product voi ID product trong gio hang\n \t\tif x['id'] == item[:id]\n \t\t\tx['quantity'] = x['quantity'] + 1\n \t\t\tx['total'] = x['price'] * x['quantity']\n \t\t\treturn\n \t\tend\n \tend\n \tsession[\"cart\"].push(item)\n end", "def with_sku?(sku, quantity)\n return false\n return false if order.order_items.size == 0 && quantity == 1\n (sku.price_with_taxes.in_euro.to_yuan.amount * quantity + order_price) > Setting.instance.max_total_per_day\n end", "def test(points, r1, r2)\n points = points.map do |pair, response|\n [response[:asks][0][\"price\"], response[:bids][0][\"price\"]]\n end.flatten\n\n puts \"UEBU correct\" if r1 == 1000 / points[0] * points[3] * points[5]\n puts \"UBEU correct\" if r2 == 1000 / points[4] / points[2] * points[1]\n end", "def custom_price?\n (total_price_with_taxes != original_price) && (original_price > 0.0)\n end", "def test_check_inventory\n # Create a cart and add some products.\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), 4)\n assert_equal a_cart.items.length, 2\n \n an_out_of_stock_product = items(:red_lightsaber)\n assert an_out_of_stock_product.update_attributes(:quantity => 1)\n \n # Assert that the product that was out of stock was removed.\n removed_products = a_cart.check_inventory\n assert_equal removed_products, [an_out_of_stock_product.name]\n\n # Should last the right quantity of the rest.\n assert_equal a_cart.items.length, 1\n end", "def customer_can_afford_pet(customer, new_pet)\n if customer[:cash] >= new_pet[:price]\n return true\n end\n return false\nend", "def customer_can_afford_pet(customer, new_pet)\n if customer[:cash] >= new_pet[:price]\n return true\n end\n return false\nend", "def checkout\n\t\tcheckout_price = 0\n\t\[email protected] do |shake|\n\t\t\tcheckout_price += shake.price_of_milkshake\n\t\tend\n\t\tcheckout_price\n\tend", "def test_calculate_subtotal_price\n assert_equal(23.52, Stub.new.calculate_subtotal_price(24.0,0.48))\n end", "def validate_product_quantity_in_stock\n init_order_and_order_item\n session[:cart].values.each do |item|\n product = Product.find_by id: item[\"product_id\"].to_i\n next if conditional_checking(product, item)\n @order.errors.add(:unit_in_stock, add_flash_danger(product))\n end\n return if @order.errors.blank?\n render :new\n end", "def sell(item, count)\n wanted = Hash.new\n wanted[item] = count\n if total_inventory[item] >= wanted[item]\n return true\n elsif total_inventory[item] < wanted[item]\n then false\n else\n \"Error\"\n end\n end", "def can_buy_depot_train?(entity)\n entity.cash >= @depot.upcoming.first.price\n end", "def customer_can_afford_pet(customer, new_pet_hash)\n if customer[:cash] > new_pet_hash[:price]\n return true\n else\n return false\n end\nend", "def customer_can_afford_pet(customer, new_pet)\n if customer[:cash] >= new_pet[:price]\n true\n else\n false\n end\nend", "def customer_can_afford_pet?(customer, new_pet)\n if customer[:cash] >= new_pet[:price]\n return true\n else\n return false\n end\nend", "def check_price\n return unless self.price.nil?\n if product && product.master_price\n self.price = product.master_price\n else\n errors.add_to_base(\"Must supply price for variant or master_price for product.\")\n return false\n end\n end", "def checkout(cart, coupons)\n cart = consolidate_cart(cart)\n check_out_two = apply_coupons(cart, coupons)\n check_out_final = apply_clearance(check_out_two)\n\n\n cost = 0\n check_out_final.each do |item, prices|\n cost += prices[:price] * prices[:count]\n end\n\n if cost >= 100\n new_price = (cost * 0.9).round(2)\n return new_price\n else\n return cost\n end\nend", "def check_order\n order.each { |e| e[0].capitalize.constantize.price }\n end", "def customer_can_afford_pet(customers, new_pet)\n if customers[:cash] >= new_pet[:price]\n return true\n else\n return false\n end\nend", "def check_price\n return unless self.price.nil?\n if product && product.master_price\n self.price = product.master_price\n else\n errors.add_to_base(\"Must supply price for variant or master_price for product.\")\n return false\n end\n end", "def check_price\n if self.price.nil?\n raise 'Must supply price for variant or master.price for product.' if self == product.master\n self.price = product.master.price\n end\n end", "def wholesale?\n line_items.any? do |line_item|\n product = line_item.product\n # a product could have multiple wholesale prices\n [\n product.wholesale_price,\n product.wholesale_subscription_price\n ].include? line_item.price\n end\n end", "def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )\n parsed_discount = discount.nil? ? 0.to_d : discount.to_d\n BigDecimal.new( original_gross ) == order_amount && parsed_discount == order_discount\n end", "def check_price\n if price.nil?\n raise 'Must supply price for variant or master.price for product.' if self == product.master\n self.price = product.price\n end\n end", "def customer_can_afford_pet(customer, new_pet)\n if customer[:cash]<= new_pet[:price]\n return false\n else\n return true\n end\nend", "def customer_can_afford_pet(customer, new_pet)\n if customer[:cash]<= new_pet[:price]\n return false\n else\n return true\n end\nend", "def variant_full_price(variant)\nproduct = variant.product\nunless product.variants.active(current_currency).all? { |v| v.price == product.price }\nSpree::Money.new(variant.price, { currency: current_currency }).to_html\nend\nend", "def check_for_equal_item(name, price, description, item_not_to_compare = nil)\r\n index = items.index {|x| x.name.eql?(name) and x.price.eql?(price) and x.description.eql?(description) and x != item_not_to_compare}\r\n return items[index] unless index == nil\r\n end", "def valid_for?(cart)\n minimum_order_value.nil? || minimum_order_value < cart.item_sum\n end", "def check_price\n if self.price.blank?\n raise \"Must supply price for variant or master.price for product.\" if self.is_master\n self.price = calculate_price\n end\n end", "def has_enough_money(item)\r\n if(self.credits>= item.get_price)\r\n return true\r\n else\r\n puts('get money')\r\n return false\r\n end\r\n end", "def customer_can_afford_pet(customer_hash, pet)\n if customer_hash[:cash] >= pet[:price]\n return true\n else\n return false\n end\nend", "def fire_for(basket)\n num = num_matching_products(basket)\n Event.new(created_by: self,\n product: @product,\n num_matches: num / 2,\n new_price: Price.zero) if num > 1\n end", "def is_discounted?\n price.to_f <= 2\n end", "def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend", "def customer_can_afford_pet(customer,new_pet)\n customer_cash=customer[:cash]\n @pet_shop[:pets].push(new_pet)\n for pet in @pet_shop[:pets] do\n if customer_cash >= pet[:price] \n return true\n else\n return false\n end\n end\n end", "def customer_can_afford_pet(customer, pet)\n if customer[:cash] == pet[:price]\n end\n return true\nend", "def is_enough\r\n \tProduct.find(@cart_item.product_id).count - @cart_item.count >= 0\r\n end", "def price_is_right(bids, actual_retail_price)\n\n best_bid = nil\n smallest_diff = nil\n\n bids.each do |bid|\n diff = actual_retail_price - bid\n\n if diff > 0\n if best_bid == nil or smallest_diff > diff\n smallest_diff = diff\n best_bid = bid\n end\n end\n end\n best_bid\nend", "def test_total_netto_price\n #quantity x netto price\n prod = InvoicesApp::InvoiceItems.new('safsdfsdfsdf', 3, 4.5)\n assert_equal prod.total_netto_price, 13.5\n end", "def customer_can_afford_pet(customer, new_pet)\n if customer[:cash] < new_pet[:price]\n return false\n else\n return true\n end\nend", "def fire_for(basket)\n num = num_matching_products(basket)\n Event.new(created_by: self,\n product: @product,\n num_matches: num,\n new_price: @price_per_unit) if num >= @min_num\n end", "def customer_can_afford_pet(customer, new_pet)\n if (customer[:cash] >= new_pet[:price])\n return true\n else\n return false\n end\nend", "def enable?(item)\n return (item.price > 0)\n end", "def has_different_point_values?\n offer_value = Inventory.evaluate_items(@offer[:items])\n for_value = Inventory.evaluate_items(@for[:items])\n if offer_value != for_value\n add_error(:for, :items,\n \"Invalid Offer, the items offered and received do not worth the same\")\n true\n else false; end\n end", "def check_price\n @num_cookbooks = (params[:num_cookbooks] && params[:num_cookbooks].to_i > 3) ? params[:num_cookbooks].to_i : 4\n ccc = CookbookCostCalculator.new(\n num_bw_pages: current_cookbook.num_bw_pages, \n num_color_pages: current_cookbook.num_color_pages, \n num_books: @num_cookbooks, \n binding: current_cookbook.book_binding.to_sym\n )\n @cookbook = current_cookbook\n @printing_cost = ccc.printing_cost || \"Unknown\"\n @cost_per_book = (@printing_cost != \"Unknown\") ? (@printing_cost.to_f / @num_cookbooks).round(2) : \"Unknown\"\n end", "def products_in_stock?(products)\n in_stock = false\n products.each_value {|p| in_stock = true if product_in_stock?(p) }\n return in_stock\n end", "def calculate_price\n total_price = 0\n # Add price of the burger\n choose_burger_price\n total_price += @burger_price\n # Add prices of all the non-burger items - would like to include burgers but they have multiple price attributes\n order_items = fillings + sides + dips + drinks\n order_items.each do |item|\n total_price += item.price\n end\n # Update the total price of the order\n update_attribute(:order_price, total_price)\n end", "def customer_can_afford_pet(supplied_customer, new_pet)\n supplied_customer[:cash] < new_pet[:price] ? false : true\nend", "def asks_below(price)\n\t\torders.where(\"order_type = 'sell' AND price < '#{price}'\").order(:price)\n\tend", "def check_line_items_quantities?\n self.line_items.each do |line_item|\n line_item_addresses_quantity = line_item.line_item_addresses.pluck(:quantity).sum\n if line_item.quantity == line_item_addresses_quantity\n line_item.line_item_addresses.each do |line_item_address|\n if line_item_address.quantity < 1\n unless self.user.quadvision_user.quadvision_delivery_addresses.pluck(:id).include?(line_item_address.address.id)\n return false\n end\n end\n end\n else\n return false\n end\n end\n return true\n end", "def check_stock\n receiving_details.each{|p|\n #errors.add(:quantity, \" in size #{p.product_size.size_detail.size_number} can't be more than PO quantity\") if p.product_size.size_detail.present? && p.quantity.to_i > ProductDetail.find_by_warehouse_id_and_product_size_id(origin_warehouse_id, p.product_size_id).available_qty.to_i\n }\n end", "def payment_possible_for?(listing)\n listing.price && listing.price > 0 && stripe_in_use?\n end", "def sell(item, quantity)\n if total_inventory.has_key?(item) && quantity < total_inventory[item]\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] >= quantity\n vendor.inventory[item] -= quantity\n else\n vendor.inventory[item] -= quantity\n diff = vendor.inventory[item].abs\n vendor.inventory[item] = 0\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] != 0\n require \"pry\"\n binding.pry\n vendor.inventory[item] - diff\n end\n end\n end\n end\n end\n end\n return true\n else\n return false\n end\n end", "def sell_all_bot(profit_rate = 0.2)\n markets_url = get_url({ :api_type => \"public\", :action => \"markets\" })\n markets = call_api(markets_url)\n expected_worth = 0.0\n markets.each do |market|\n currency = market[\"MarketCurrency\"]\n base_currency = market[\"BaseCurrency\"]\n market_name = market[\"MarketName\"]\n if market[\"IsActive\"] and base_currency == \"BTC\"\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n if balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0 #purchased coins\n orders_history_url = get_url({ :api_type => \"account\", :action => \"market_orders_history\", :market => market_name })\n orders_history = call_secret_api(orders_history_url)\n net_value = 0.0\n orders_history.each do |order|\n net_value += order[\"Price\"] if order[\"OrderType\"] == \"LIMIT_BUY\"\n net_value -= order[\"Price\"] if order[\"OrderType\"] == \"LIMIT_SELL\"\n end\n if net_value > 0 # buys are more, we need to get more than this net value by selling available coins\n sell_price = (net_value + net_value*profit_rate)/balance_details[\"Available\"]\n sell_price = \"%.8f\" % sell_price\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price })\n order_placed = call_secret_api(sell_limit_url)\n p [order_placed, \"for #{market_name} at #{sell_price}\"]\n end\n expected_worth += (net_value + net_value*profit_rate)\n end\n end\n end\n p [\"Expected Worth=\", expected_worth]\nend", "def can_update_basket?\n !(\n needs_shipping_quote? || quote? || payment_on_account? || pay_by_phone? ||\n payment_received?\n )\n end", "def ticket_price\n\t\t#There is no base cost\n\t\tticket_price = @price\n\t\[email protected] do |item|\n\t\tif @items.count > 5\n\t\t\tticket_price += item.price * 0.9\n\t\telse\n\t\t\tticket_price += item.price\n\t\tend\n\t\tend\n\t\tticket_price.round(2)\n\tend", "def sold?(product)\n product.status == 'Sold'\n end" ]
[ "0.7105521", "0.6877894", "0.68416524", "0.6708596", "0.6669452", "0.66378236", "0.66360927", "0.64825416", "0.64629155", "0.63959813", "0.6391854", "0.6332381", "0.6299121", "0.62837476", "0.62683326", "0.6254401", "0.62386584", "0.6222037", "0.6188844", "0.61536664", "0.61373323", "0.61195564", "0.61117136", "0.6109283", "0.60985947", "0.6091592", "0.60478354", "0.60445124", "0.6043474", "0.60358775", "0.60312676", "0.60189", "0.60111415", "0.60075754", "0.5990747", "0.5990159", "0.5969654", "0.59675646", "0.5950613", "0.5930887", "0.59178466", "0.59178466", "0.5906478", "0.590271", "0.5895351", "0.58951855", "0.58928645", "0.58914745", "0.58914745", "0.5887436", "0.5882208", "0.5879671", "0.58754754", "0.58748245", "0.5873459", "0.58701867", "0.5870107", "0.58672595", "0.58615595", "0.58497506", "0.58469015", "0.5842205", "0.58311284", "0.58085376", "0.58076906", "0.5807505", "0.58052576", "0.58052576", "0.58050406", "0.5791481", "0.5789266", "0.5788344", "0.5782948", "0.5782287", "0.5776745", "0.5772122", "0.5770552", "0.57472515", "0.5743275", "0.57428646", "0.57392514", "0.5738284", "0.5737812", "0.5737504", "0.57343155", "0.57335323", "0.57298607", "0.57286286", "0.572852", "0.5723847", "0.57187337", "0.5717485", "0.57168114", "0.5715427", "0.5713215", "0.5713099", "0.5709742", "0.5709083", "0.5706198", "0.5702502" ]
0.59118223
42
Creates and mantains the regular expression
def create_regex_for_preffix(preffix) @preffix_regexp = /#{preffix}-\d+/ end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pattern2regex(pattern); end", "def create pat, args = Hash.new\n negated = args[:negated]\n ignorecase = args[:ignorecase]\n wholewords = args[:wholewords]\n wholelines = args[:wholelines]\n extended = args[:extended]\n multiline = args[:multiline]\n\n flags = pattern_to_flags pat\n arg = flags_to_arg flags\n\n pat = pat.sub @pattern_re, '\\1'\n\n if wholewords\n pat = '\\b' + pat + '\\b'\n elsif wholelines\n pat = '^' + pat + '$'\n end\n\n cls = negated ? NegatedRegexp : Regexp\n return cls.new pat, arg\n end", "def make_regexp\n @intent = self.intent\n regexp = self.pattern.dup.downcase\n words = regexp.split(\" \")\n words.each do |word|\n if word.include? '/'\n regexp = regexp.gsub(word,\"(#{word})\")\n\n end\n\n end\n regexp = regexp.gsub('/',\"|\")\n regexp = regexp.gsub('^ ','.{0,60}').gsub(' ^','.{0,60}').gsub(' *','.{1,60}').gsub('* ','.{1,60}').gsub('^','.{1,60}').gsub(' [','.{0,60}[')\n regexp = regexp.gsub(' .{0,60}','.{0,60}')\n regexp = regexp.gsub(' .{1,60}','.{1,60}')\n regexp = '.{0,60}' + regexp + '.{0,60}'\n self.regexp = regexp\n chunks = self.pattern.split(' ')\n chunks.each do |ch|\n result= Regexp.new(/\\[.{0,12}\\]/) =~ ch\n if(result==0)\n set = WordSet.find_by_keyword(ch[1..-2])\n str = '(' + set.words.join('|') + ')'\n regexp = self.regexp.gsub(ch,str)\n self.regexp = regexp\n end\n end\n self.save\n end", "def regexp\n @regexp ||= Regexp.compile(source.to_s, Regexp::IGNORECASE)\n end", "def create_regex(p) #:nodoc:\n output = StringIO.open('','w')\n $stderr = output\n begin\n r = /#{p}/ui\n ensure\n output.close\n $stderr = STDERR\n end\n end", "def regexp=(_arg0); end", "def regexp; end", "def regexp; end", "def build_regex_from_pattern( pattern )\n regex_str = pattern.gsub('/','\\\\/').gsub('+','[^\"\\/\"]+').gsub('\\/#','.*').gsub('#','.*')\n Regexp.new regex_str\n end", "def regex\n Regexp.new(@str)\n end", "def to_regex\n\t\treturn Regexp.new(\"\") if blank?\n\n\t\t# Building the regex takes O(word_length) time, so I always cache the result \n\t\t# of this method in a variable when using it.\n\t\tx_start, y_start = @start_pos\n\t\tx_end, y_end = @end_pos\n\t\tregex_str = \"\"\n\n\t\tx_start.upto(x_end) do |x_i|\n\t\t\ty_start.upto(y_end) do |y_i|\n\t\t\t\tletter = @letter_positions[[x_i, y_i]]\n\t\t\t\tif letter\n\t\t\t\t\tregex_str += \"[#{letter}]\"\n\t\t\t\telse\n\t\t\t\t\tregex_str += \"[A-Z]\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tRegexp.new(regex_str)\n\tend", "def initialize(regex, options = {})\n @@parse_options = options\n @@parse_options[:reg_options] ||= Regextest::RegexOption.new\n @verification = (options && options[:verification] == false)?false:true\n @reg_string = nil\n @reg_exp = nil\n \n # Set seed for randomizing\n @seed = set_seed_for_randomizing(@@parse_options[:seed])\n\n # Covert to source string if necessary\n set_regex(regex)\n\n # Parse string\n @front_end = Regextest::Front.new(@reg_string, @@parse_options)\n \n # Prepare back-end process. (use generate method for generating string)\n @back_end = Regextest::Back.new(@front_end)\n \n @result = nil\n @reason = nil\n end", "def create_reg_exp(sport)\n sport_regexp = \"\"\n sport_chars = sport.split \"\"\n sport_chars.each_index do |i|\n # regular expression contains substrings of various lengths\n sport_regexp += \"|\" + \"#{sport_chars[i]}#{sport_chars[i + 1]}#{sport_chars[i + 2]}#{sport_chars[i+3]}\" if i < sport.length - 3\n sport_regexp += \"|\" + \"#{sport_chars[i]}#{sport_chars[i + 1]}#{sport_chars[i + 2]}\" if i < sport.length - 2\n sport_regexp += \"|\" + \"#{sport_chars[i]}#{sport_chars[i + 1]}\" if i < sport.length - 1\n sport_regexp += \"|\" + \"#{sport_chars[i]}\" if i < sport.length\n end\n Regexp.new sport_regexp[1, sport_regexp.length]\nend", "def regex(pattern)\n Regexp.new pattern.regex\n end", "def regexps; end", "def init_regex(regex)\n optimized_regex=/\\A#{regex}/ # anchor the search\n self.parser=lambda do |parent_node|\n offset = parent_node.next\n if parent_node.src[offset..-1].index(optimized_regex)==0\n range = $~.offset(0)\n range = (range.min+offset)..(range.max+offset)\n TerminalNode.new(parent_node,range,regex)\n end\n end\n self.terminal=true\n end", "def regexp\n s = Regexp.escape self\n s.gsub! /\\\\\\?/, '[^/]'\n s.gsub! /\\\\\\*/, '[^/]*'\n s.gsub! /\\\\\\[!/, '[^'\n s.gsub! /\\\\\\]/, ']'\n s.gsub! /\\\\\\{/, '('\n s.gsub! /,/, '|'\n s.gsub! /\\\\\\}/, ')'\n Regexp.new s\n end", "def regexp\n return @regexp if @regexp\n placeholder = '___PLACEHOLDER___'\n @regexp = @base_theme.dup\n # Install placeholders for the variable data\n @regexp.gsub!(VARIABLE_MATCHER) { placeholder }\n # Strip the header comments\n @regexp.gsub! /.*^\\*\\/\\s*/m, ''\n # Collapse all whitespace\n @regexp.gsub! /\\s+/, ' '\n # Escape the literal strings\n @regexp = Regexp.escape(@regexp)\n # Whitespace means nothing\n @regexp.gsub! /\\\\\\ /, '\\s+'\n # Fast variable finder\n @regexp.gsub! placeholder, '([^;]*|\\S*)'\n # Get 'er done\n @regexp = Regexp.new(@regexp)\n end", "def get_regex(pattern, encoding='ASCII', options=0)\n Regexp.new(pattern.encode(encoding),options)\nend", "def regex\n @regex ||= (\n if template\n Templates.const_get(template.upcase)\n else\n case pattern\n when Regexp\n pattern\n when String\n flags = 0\n flags + Regexp::MULTILINE if multiline\n flags + Regexp::IGNORECASE if insensitive\n if escape\n Regexp.new(Regexp.escape(pattern), flags)\n else\n pat = substitute_templates(pattern)\n Regexp.new(pat, flags)\n end\n end\n end\n )\n end", "def to_re(esc=false)\n Regexp.new((esc ? Regexp.escape(self) : self))\n end", "def build_regex(string, params = nil)\n result = build_regex_str(string, params)\n Regexp.new \"^#{result}$\"\n end", "def re; end", "def build_regexp(level)\n regexp_string = \"^.*?\"\n i = 1\n while i < level\n regexp_string += \"\\/.*?\" \n i +=1\n end\n regexp_string += \"(?=\\/)\"\n Regexp.new(regexp_string)\n end", "def as_regex\n Regexp.new('/' + split.map do |element|\n replace element\n end.join('/'))\n end", "def build_regexp(term, opts = {})\n opts[:sensitive] ||= false\n if opts[:sensitive]\n Regexp.new(term, Regexp::EXTENDED)\n else\n Regexp.new(term, Regexp::EXTENDED | Regexp::IGNORECASE)\n end\n end", "def to_regex_str\n pattern\n end", "def validate_regex_validation()\n if self.regex_validation != nil\n begin\n re = Regexp.new( self.regex_validation )\n rescue RegexpError\n errors.add( :regex_validation, \"is invalid.\" )\n end\n end\n end", "def to_regexp\n\t\t\treturn @regexp\n\t\tend", "def regex(_obj)\n raise NotImplementedError\n end", "def prepare_for_regexp(output_str)\n split_lines(output_str).map do |str|\n Regexp.new(Regexp.escape(str), Regexp::EXTENDED)\n end\n end", "def to_reb\n escaped_string = self.inspect[1,self.inspect.length-2]\n return rebexToRegex(escaped_string)\n end", "def start_re; end", "def initialize_regexp(pattern)\n ret = {}\n\n # for URI::split\n ret[:ABS_URI] = Regexp.new('\\A\\s*' + pattern[:X_ABS_URI] + '\\s*\\z', Regexp::EXTENDED)\n ret[:REL_URI] = Regexp.new('\\A\\s*' + pattern[:X_REL_URI] + '\\s*\\z', Regexp::EXTENDED)\n\n # for URI::extract\n ret[:URI_REF] = Regexp.new(pattern[:URI_REF])\n ret[:ABS_URI_REF] = Regexp.new(pattern[:X_ABS_URI], Regexp::EXTENDED)\n ret[:REL_URI_REF] = Regexp.new(pattern[:X_REL_URI], Regexp::EXTENDED)\n\n # for URI::escape/unescape\n ret[:ESCAPED] = Regexp.new(pattern[:ESCAPED])\n ret[:UNSAFE] = Regexp.new(\"[^#{pattern[:UNRESERVED]}#{pattern[:RESERVED]}]\")\n\n # for Generic#initialize\n ret[:SCHEME] = Regexp.new(\"\\\\A#{pattern[:SCHEME]}\\\\z\")\n ret[:USERINFO] = Regexp.new(\"\\\\A#{pattern[:USERINFO]}\\\\z\")\n ret[:HOST] = Regexp.new(\"\\\\A#{pattern[:HOST]}\\\\z\")\n ret[:PORT] = Regexp.new(\"\\\\A#{pattern[:PORT]}\\\\z\")\n ret[:OPAQUE] = Regexp.new(\"\\\\A#{pattern[:OPAQUE_PART]}\\\\z\")\n ret[:REGISTRY] = Regexp.new(\"\\\\A#{pattern[:REG_NAME]}\\\\z\")\n ret[:ABS_PATH] = Regexp.new(\"\\\\A#{pattern[:ABS_PATH]}\\\\z\")\n ret[:REL_PATH] = Regexp.new(\"\\\\A#{pattern[:REL_PATH]}\\\\z\")\n ret[:QUERY] = Regexp.new(\"\\\\A#{pattern[:QUERY]}\\\\z\")\n ret[:FRAGMENT] = Regexp.new(\"\\\\A#{pattern[:FRAGMENT]}\\\\z\")\n\n ret\n end", "def initialize_regexp(pattern)\n ret = {}\n\n # for URI::split\n ret[:ABS_URI] = Regexp.new('\\A\\s*' + pattern[:X_ABS_URI] + '\\s*\\z', Regexp::EXTENDED)\n ret[:REL_URI] = Regexp.new('\\A\\s*' + pattern[:X_REL_URI] + '\\s*\\z', Regexp::EXTENDED)\n\n # for URI::extract\n ret[:URI_REF] = Regexp.new(pattern[:URI_REF])\n ret[:ABS_URI_REF] = Regexp.new(pattern[:X_ABS_URI], Regexp::EXTENDED)\n ret[:REL_URI_REF] = Regexp.new(pattern[:X_REL_URI], Regexp::EXTENDED)\n\n # for URI::escape/unescape\n ret[:ESCAPED] = Regexp.new(pattern[:ESCAPED])\n ret[:UNSAFE] = Regexp.new(\"[^#{pattern[:UNRESERVED]}#{pattern[:RESERVED]}]\")\n\n # for Generic#initialize\n ret[:SCHEME] = Regexp.new(\"\\\\A#{pattern[:SCHEME]}\\\\z\")\n ret[:USERINFO] = Regexp.new(\"\\\\A#{pattern[:USERINFO]}\\\\z\")\n ret[:HOST] = Regexp.new(\"\\\\A#{pattern[:HOST]}\\\\z\")\n ret[:PORT] = Regexp.new(\"\\\\A#{pattern[:PORT]}\\\\z\")\n ret[:OPAQUE] = Regexp.new(\"\\\\A#{pattern[:OPAQUE_PART]}\\\\z\")\n ret[:REGISTRY] = Regexp.new(\"\\\\A#{pattern[:REG_NAME]}\\\\z\")\n ret[:ABS_PATH] = Regexp.new(\"\\\\A#{pattern[:ABS_PATH]}\\\\z\")\n ret[:REL_PATH] = Regexp.new(\"\\\\A#{pattern[:REL_PATH]}\\\\z\")\n ret[:QUERY] = Regexp.new(\"\\\\A#{pattern[:QUERY]}\\\\z\")\n ret[:FRAGMENT] = Regexp.new(\"\\\\A#{pattern[:FRAGMENT]}\\\\z\")\n\n ret\n end", "def initialize(regexp)\n regexp = Regexp.compile(regexp) unless regexp.is_a?(Regexp)\n source, options = regexp.source, regexp.options\n super(source, options)\n end", "def create_regex(arr)\n return nil if arr.empty?\n\n regex_str = arr.join('|')\n Regexp.new(regex_str)\nend", "def make_regexp(word)\n\t\texps = word.scan(/./).map do |c|\n\t\t\tif c =~ /[aeiou]/i\n\t\t\t\t\"[aeiou]+\"\n\t\t\telse\n\t\t\t\t\"#{c}+\"\n\t\t\tend\n\t\tend\n\t\t# make it a regular expression and ignore the case, also match the whole expression\n\t\tRegexp.new(\"^#{exps.join}$\", Regexp::IGNORECASE)\n\tend", "def initialize(attribute_name, regexp, options = {})\n super(attribute_name, options)\n @regexp = regexp\n end", "def add_regexp_handling pattern, name, exclusive = false\n bitmap = @attributes.bitmap_for(name)\n @regexp_handlings << [pattern, bitmap]\n @exclusive_bitmap |= bitmap if exclusive\n end", "def initialize(name, regexp)\n @name = name\n @regexp = regexp\n validate_input\n end", "def pregex2regex(regex, br_flg = false)\n this_regex = regex.dup\n br_ex = br_flg ? '' : '?:'\n %w(girl_name human_name precure_name cast_name color).each do |attr|\n expression = '\\[:' + attr + ':\\]'\n precures_ex = cure_list(attr.to_sym).join('|')\n replaced = \"(#{br_ex}#{precures_ex})\"\n this_regex.gsub!(/#{expression}/, replaced)\n end\n this_regex\n end", "def regexp_literal\n # RegularExpressionLiteral::\n # \t/ RegularExpressionBody / RegularExpressionFlags\n pos0 = @pos\n return nil unless @codes[@pos] == 0x2f\n\n body = regexp_body\n flags = regexp_flags\n return ECMA262::ECMA262RegExp.new(body, flags)\n end", "def convert_to_regexp(name, regexp)\n return regexp if Regexp == regexp\n begin\n return Regexp.new(regexp)\n rescue\n @errors << \"Invalid pattern: #{name} regexp: #{regexp} error: #{$!}\"\n end\n end", "def pattern_create(length, sets = nil)\n Rex::Text.pattern_create(length, sets)\n end", "def to_regexp(text, exact: false, all_whitespace: false, options: nil)\n return text if text.is_a?(Regexp)\n\n escaped = Regexp.escape(text)\n escaped = escaped.gsub('\\\\ ', '[[:blank:]]') if all_whitespace\n escaped = \"\\\\A#{escaped}\\\\z\" if exact\n Regexp.new(escaped, options)\n end", "def rx(s)\n Regexp.new(Regexp.escape(s))\n end", "def build_regexp_from_string(str)\n fail RegexpError, \"Isn't a Regexp: #{str}\" if str[0] != '/'\n\n options = extract_regexp_options(str)\n Regexp.new(str[1...str.rindex('/')], options)\n end", "def monocle(inputString)\n\toptic = Regexp.new(inputString)\n\treturn optic\nend", "def initialize(regexp, opts)\n regexp = Regexp.compile(regexp) unless regexp.is_a?(Regexp)\n source, options = regexp.source, regexp.options\n super(source, options)\n end", "def initialize()\n @regexps = Hash.new {|hash,key| hash[key] = Regexp.new(key)}\n @memoization = nil\n @terminal_parse_failures = nil\n end", "def to_regexp(text)\n text.is_a?(Regexp) ? text : Regexp.new(Regexp.escape(normalize_whitespace(text)))\n end", "def to_regexp\n Regexp.new(@value)\n end", "def pattern2regex(pattern)\n pattern = \"^\" + pattern.to_s.gsub(/\\./, \"\\\\.\").\n gsub(/\\?/, '.').\n gsub(/([+\\/])/, '\\\\\\\\\\\\0').\n gsub(/\\*/, '.*') + \"$\"\n Regexp.new(pattern, true)\n end", "def make_regexp(schemes = nil)\n unless schemes\n @regexp[:ABS_URI_REF]\n else\n /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x\n end\n end", "def make_regexp(schemes = nil)\n unless schemes\n @regexp[:ABS_URI_REF]\n else\n /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x\n end\n end", "def setup_regex\n @to_from_match = /(\\d+:\\d+:\\d+,\\d+) --> (\\d+:\\d+:\\d+,\\d+)/\n @whitespace_only = /^\\s*$/\n end", "def regex_search\n if use_regex?\n ::Arel::Nodes::Regexp.new((custom_field? ? field : table[field]), ::Arel::Nodes.build_quoted(formated_value))\n else\n non_regex_search\n end\n end", "def initialize find, replace\n @regexp = Regexp.new(\"^#{find}$\")\n @replace = replace\n end", "def build_regex_pattern index, pattern_element\n \"^\" + @phone_number[index..(index + pattern_element - 1)].map { |c| \"(#{NUMBER_LETTERS[c].join('|')})\" }.join + \"$\"\n end", "def test_regexp\n# (find-node \"(emacs-ja)Regexps\")\n \n conv = lambda{|from,to| assert_equal(to, el4r_conv_regexp(from)) }\n conv[ //, '' ]\n conv[ /a/, 'a' ]\n conv[ /a./, 'a.' ]\n conv[ /a*/, 'a*' ]\n conv[ /a+/, 'a+' ]\n conv[ /a?/, 'a?' ]\n conv[ /[ab]/, '[ab]' ]\n conv[ /[^ab]/, '[^ab]' ]\n conv[ /^ab/, '^ab' ]\n conv[ /ab$/, 'ab$' ]\n conv[ /a|b/, 'a\\|b' ]\n conv[ /(ab)/, '\\(ab\\)' ]\n conv[ /\\As/, '\\`s' ]\n conv[ /s\\Z/, %q[s\\'] ]\n # \\=\n conv[ /\\bball\\B/, '\\bball\\B']\n # \\<\n # \\>\n conv[ /\\w/, '[0-9A-Za-z_]']\n conv[ /\\W/, '[^0-9A-Za-z_]']\n # \\sC\n # \\SC\n # \\D (number)\n end", "def to_rx(esc=true)\n Regexp.new((esc ? Regexp.escape(self) : self))\n end", "def format_regex\n callback.options[:live_validator] || callback.options[:with]\n end", "def set_regex(param)\n case param\n when String\n if md = param.match(/^\\/(.*)\\/([imx]*)$/)\n @reg_exp = eval(param)\n @reg_string = @reg_exp.source\n else\n new_param = check_builtin(param)\n @reg_string = new_param\n @reg_exp = /#{@reg_string}/\n end\n when Regexp\n @reg_exp = param\n @@parse_options[:reg_options].set(@reg_exp.options) # inner regex options have priorty\n @reg_string = @@parse_options[:reg_options].prefix_reg + @reg_exp.source\n else\n raise \"Error: string or regular expression required\"\n end\n @@parse_options[:reg_source] = @reg_string\n end", "def match(regexp); end", "def to_regex_str\n if pattern == \"**\"\n \".*\"\n else\n \"[^/]+\"\n end\n end", "def add_regexp(regexp)\n starting_chars = regexp.starting_chars\n if starting_chars.kind_of? Symbol \n scanning_table.default = regexp\n else\n common_chars = starting_chars.select { |c| scanning_table.has_key? c } \n starting_chars = starting_chars - common_chars\n starting_chars.each { |c| scanning_table[c] = regexp }\n colliding_states = common_chars.map { |c| scanning_table[c] }\n colliding_states.uniq!\n colliding_states.zip(common_chars).each { |r,c| scanning_table[c] = RegexpSpecification.mix(regexp,r) }\n end\t\n \n if @built\n build\n end\n \n self\n end", "def match_string_to_regexp(str)\n #str = str.split(/(\\(\\(.*?\\)\\))(?!\\))/).map{ |x|\n # x =~ /\\A\\(\\((.*)\\)\\)\\Z/ ? $1 : Regexp.escape(x)\n #}.join\n #str = str.gsub(/\\\\\\s+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n\n #str = str.split(/([#$]\\(.*?\\))/).map{ |x|\n # x =~ /\\A[#$]\\((.*)\\)\\Z/ ? ($1.start_with?('#') ? \"(#{$1})\" : $1 ) : Regexp.escape(x)\n #}.join\n #str = str.gsub(/\\\\\\s+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n\n$stderr.puts \"HERE!!!!!!\"\n\n str = str.split(PATTERN).map{ |x|\n case x\n when /\\A\\(\\((.*)\\)\\)\\Z/\n $1\n when /\\A[#$]\\((.*)\\)\\Z/\n $1.start_with?('#') ? \"(#{$1})\" : $1\n else\n Regexp.escape(x)\n end\n }.join\n\n str = str.gsub(/\\\\\\s+/, '\\s+')\n\n Regexp.new(str, Regexp::IGNORECASE)\n\n #rexps = []\n #str = str.gsub(/\\(\\((.*?)\\)\\)/) do |m|\n # rexps << '(' + $1 + ')'\n # \"\\0\"\n #end\n #str = Regexp.escape(str)\n #rexps.each do |r|\n # str = str.sub(\"\\0\", r)\n #end\n #str = str.gsub(/(\\\\\\ )+/, '\\s+')\n #Regexp.new(str, Regexp::IGNORECASE)\n end", "def protect_regex(reg)\n Regexp.new('(^|(?!(!.*)))' + reg.source + '($|(?!(.*!)))')\n end", "def pattern2regex(pattern)\n tail = pattern\n prefix = String.new\n while !tail.empty? do\n head, sep, tail = tail.partition(/[\\*\\?]/)\n prefix = prefix + Regexp.quote(head)\n case sep\n when '*'\n prefix += '.*'\n when '?'\n prefix += '.'\n when ''\n else\n fail \"Unpexpcted sep:#{sep}\"\n end\n end\n Regexp.new(\"^\" + prefix + \"$\", true)\n end", "def sanitize_regexp(value)\n original = value.dup\n\n SANITIZE_REGEXP.each do |pattern, replacement|\n value.gsub!(pattern, replacement)\n end\n\n value2 = ''\n group_index = 0\n value.scan(/((?:[^\\\\(]+|\\\\[^\\d])+)|(\\\\\\d+)|(\\(\\??)/m) do |content, backref, capture|\n value2 << if capture == '('\n \"(?<_#{group_index += 1}>\"\n elsif backref\n \"\\\\k<_#{backref[/\\d+/]}>\"\n else\n (content || capture)\n end\n end\n\n Regexp.new(value2)\n rescue RegexpError => ex\n if ex.message =~ /^invalid multibyte escape:/\n begin\n /#{value2.force_encoding(Encoding::BINARY)}/n\n rescue RegexpError => ex\n error(ex, original, value2)\n end\n else\n error(ex, original, value2)\n end\n end", "def add_regexp_handling(pattern, name)\n @attribute_manager.add_regexp_handling(pattern, name)\n end", "def to_regexp\n case expr.first\n when :hex\n Regexp.new(translate_codepoints(expr[1]))\n when :istr\n /#{expr.last}/ui\n when :range\n Regexp.new(\"[#{translate_codepoints(expr[1])}]\")\n else\n raise \"Can't turn #{expr.inspect} into a regexp\"\n end\n end", "def get_regular_expression_of_symbols\n regular_expression = nil\n @symbols.each do |symbol|\n formated_symbol = Regexp.escape(symbol[:symbol])\n regular_expression = if regular_expression.nil?\n \"(#{formated_symbol})\"\n else\n \"#{regular_expression}|(#{formated_symbol})\"\n end\n end\n Regexp.new(regular_expression)\n end", "def make_recognizer token_regexps={}\n return RECOGNIZER_REGEXPS[pattern] if RECOGNIZER_REGEXPS[pattern]\n tokens = []\n recognizer = recognizer_pattern.gsub(/:(\\\\\\{\\w+\\\\\\}|\\w+)/) do\n tok = $1.gsub(/\\W/,'')\n tokens << tok.to_sym\n '('+recognize_replace(tok, token_regexps)+')'\n end\n RECOGNIZER_REGEXPS[pattern] = [Regexp.new(recognizer), tokens]\n end", "def make_pattern pattern\n state = :close\n rule = ''\n last_ch = ''\n pattern.split('').each do |ch|\n case ch\n when '('\n state = :open\n rule << '('\n when ')'\n state = :close\n rule << ')'\n else\n case state\n when :open\n case last_ch\n when '('\n else\n rule << '|'\n end\n rule << ch\n when :close\n rule << \"[#{ch}]\"\n end\n end\n last_ch = ch\n end\n Regexp.new rule\nend", "def lex_en_regexp_modifiers=(_arg0); end", "def lex_en_regexp_modifiers=(_arg0); end", "def lex_en_regexp_modifiers=(_arg0); end", "def to_regexp(text)\n text.is_a?(Regexp) ? text : Regexp.escape(normalize_whitespace(text))\n end", "def regex(regex, validator_name = nil, error_message = nil)\n error_message ||= \"must match #{regex.inspect}\"\n validator_name ||= \"string.regex\"\n @regexes << { error_message: error_message, validator_name: validator_name, regex: regex }\n self\n end", "def setup_regex(word)\n @exact_rgx = /href='(.*)'>#{word}<\\//\n @partial_rgx = /href='(.*)'>#{word}/\n end", "def build_regex(fields)\n fields_or = fields.map { |field| \"#{field}(\\\\[\\\\])?\" }.join('|')\n\n Regexp.new(\"^#{fields_or}$\")\n end", "def regex_for(pattern)\n return pattern if Regexp === pattern\n pattern = pattern.split('.') if String === pattern\n\n source = ''\n pattern.each_with_index do |part, index|\n if part == '*'\n source << '\\\\.' unless index == 0\n source << '[^\\.]+'\n elsif part == '#'\n source << '.*?' # .*? ?\n else\n source << '\\\\.' unless index == 0\n source << part\n end\n end\n\n Regexp.new(\"\\\\A#{source}\\\\Z\")\n end", "def start_re=(_); end", "def convert_regexp_handling target\n convert_string super\n end", "def compile_validator(s)\n Regexp.new(s.gsub(/\\w+/) do\n '(' + TRANSFORMER.select {|k,v| v.first.to_s == $& }.map {|v| \":#{v.first}\" }.join('|') + ')'\n end.gsub(/\\s+/, '').sub(/\\A/, '\\A').sub(/\\Z/, '\\Z'))\n end", "def to_sp\n regexp_s = self.to_s\n return StringPattern.cache[regexp_s] unless StringPattern.cache[regexp_s].nil?\n regexp = Regexp.new regexp_s\n require \"regexp_parser\"\n default_infinite = StringPattern.default_infinite\n pata = []\n pats = \"\"\n patg = [] # for (aa|bb|cc) group\n set = false\n set_negate = false\n options = []\n capture = false\n\n range = \"\"\n fixed_text = false\n options = regexp.to_s.scan(/\\A\\(\\?([mix]*)\\-[mix]*:/).join.split('')\n last_char = (regexp.to_s.gsub(/\\A\\(\\?[mix]*\\-[mix]*:/, \"\").length) - 2\n Regexp::Scanner.scan regexp do |type, token, text, ts, te|\n if type == :escape\n if token == :dot\n token = :literal\n text = \".\"\n elsif token == :literal and text.size == 2\n text = text[1]\n else\n puts \"Report token not controlled: type: #{type}, token: #{token}, text: '#{text}' [#{ts}..#{te}]\"\n end\n end\n\n unless set || (token == :interval) || (token == :zero_or_one) ||\n (token == :zero_or_more) || (token == :one_or_more) || (pats == \"\")\n if (pats[0] == \"[\") && (pats[-1] == \"]\")\n pats[0] = \"\"\n if (token == :alternation) || !patg.empty?\n if fixed_text\n if patg.size == 0\n patg << (pata.pop + pats.chop)\n else\n patg[-1] += pats.chop\n end\n else\n patg << pats.chop\n end\n else\n if fixed_text\n pata[-1] += pats.chop\n else\n if pats.size == 2\n pata << pats.chop\n else\n pata << \"1:[#{pats}\"\n end\n if last_char == te and type == :literal and token == :literal\n pata << text\n pats = \"\"\n next\n end\n end\n end\n else\n if (token == :alternation) || !patg.empty?\n patg << \"1:#{pats}\"\n else\n pata << \"1:#{pats}\"\n end\n end\n pats = \"\"\n end\n fixed_text = false\n case token\n when :open\n set = true\n pats += \"[\"\n when :close\n if type == :set\n set = false\n if pats[-1] == \"[\"\n pats.chop!\n else\n if set_negate\n pats+=\"%]*\"\n set_negate = false\n else\n pats += \"]\"\n end \n\n end\n elsif type == :group\n capture = false\n unless patg.empty?\n patg << pats if pats.to_s != \"\"\n pata << patg\n patg = []\n pats = \"\"\n end\n end\n when :negate\n if set and pats[-1] == '['\n pats+=\"%\"\n set_negate = true\n end\n when :capture\n capture = true if type == :group\n when :alternation\n if type == :meta\n if pats != \"\"\n patg << pats\n pats = \"\"\n elsif patg.empty?\n # for the case the first element was not added to patg and was on pata fex: (a+|b|c)\n patg << pata.pop\n end\n end\n when :range\n pats.chop! if options.include?('i')\n range = pats[-1]\n pats.chop!\n when :digit\n pats += \"n\"\n when :nondigit\n pats += \"*[%0123456789%]\"\n when :space\n pats += \"_\"\n when :nonspace\n pats += \"*[% %]\"\n when :word\n pats += \"Ln_\"\n when :nonword\n pats += \"$\"\n when :word_boundary\n pats += \"$\"\n when :dot\n pats += \"*\"\n when :literal\n if range == \"\"\n if text.size > 1\n fixed_text = true\n if !patg.empty?\n patg << text.chop\n else\n pata << text.chop\n end\n pats = text[-1]\n else\n pats += text\n pats += text.upcase if options.include?('i')\n end\n else\n range = range + \"-\" + text\n if range == \"a-z\"\n if options.include?('i')\n pats = \"L\" + pats\n else\n pats = \"x\" + pats\n end\n elsif range == \"A-Z\"\n if options.include?('i')\n pats = \"L\" + pats\n else\n pats = \"X\" + pats\n end\n elsif range == \"0-9\"\n pats = \"n\" + pats\n else\n if set\n pats += (range[0]..range[2]).to_a.join\n if options.include?('i')\n pats += (range[0]..range[2]).to_a.join.upcase\n end\n else\n trange = (range[0]..range[2]).to_a.join\n if options.include?('i')\n trange += trange.upcase\n end\n pats += \"[\" + trange + \"]\"\n end\n end\n range = \"\"\n end\n pats = \"[\" + pats + \"]\" unless set\n when :interval\n size = text.sub(\",\", \"-\").sub(\"{\", \"\").sub(\"}\", \"\")\n size+=(default_infinite+size.chop.to_i).to_s if size[-1] == \"-\"\n pats = size + \":\" + pats\n if !patg.empty?\n patg << pats\n else\n pata << pats\n end\n pats = \"\"\n when :zero_or_one\n pats = \"0-1:\" + pats\n if !patg.empty?\n patg << pats\n else\n pata << pats\n end\n pats = \"\"\n when :zero_or_more\n pats = \"0-#{default_infinite}:\" + pats\n if !patg.empty?\n patg << pats\n else\n pata << pats\n end\n pats = \"\"\n when :one_or_more\n pats = \"1-#{default_infinite}:\" + pats\n if !patg.empty?\n patg << pats\n else\n pata << pats\n end\n pats = \"\"\n end\n end\n if pats != \"\"\n if pata.empty?\n if pats[0] == \"[\" and pats[-1] == \"]\" #fex: /[12ab]/\n pata = [\"1:#{pats}\"]\n end\n else\n pata[-1] += pats[1] #fex: /allo/\n end\n end\n if pata.size == 1 and pata[0].kind_of?(String)\n res = pata[0]\n else\n res = pata\n end\n StringPattern.cache[regexp_s] = res\n return res\n end", "def init_string(string)\n init_regex Regexp.escape(string)\n end", "def path_regex\n Regexp.new path_pattern, 'i'\n end", "def lex_en_regexp_modifiers; end", "def lex_en_regexp_modifiers; end", "def lex_en_regexp_modifiers; end", "def signature\r\n [@regexp, @replace]\r\n end", "def signature\r\n [@regexp, @replace]\r\n end", "def pdf_regex\n @attributes[:pdf_regex]\n end", "def regexp\n pattern = '(?:' + Regexp.union([@name] + @aliases).source + ')'\n\n @arguments.each_value do |format|\n arg_regexp = case format\n when Array then Regexp.union(format)\n when Regexp then format\n when Symbol then ARG_FORMATS.fetch(format)\n else Regexp.escape(format.to_s)\n end\n\n pattern << ' (' << arg_regexp.source << ')'\n end\n\n # match the full message\n pattern << '$'\n\n return Regexp.new(pattern)\n end", "def initialize(regexp)\n regexp = Regexp.compile(regexp) unless regexp.is_a?(Regexp)\n source, options = regexp.source, regexp.options\n @names, scanner = [], StringScanner.new(source)\n\n while scanner.skip_until(/\\(/)\n if scanner.scan(/\\?:<([^>]+)>/)\n @names << scanner[1]\n elsif scanner.scan(/\\?:/)\n # ignore noncapture\n else\n @names << nil\n end\n end\n source.gsub!(/\\?:<([^>]+)>/, '')\n\n @names = [] unless @names.any?\n @names.freeze\n\n super(source, options)\n end", "def compile(source)\n regexp = Regexp.compile(source)\n expression = parse(regexp)\n Regexp.compile(expression.to_s(true), expression.flags)\n end", "def autoregex(anything)\n deb \"Autoregex() supercool! With a #{blue anything.class}\"\n case anything.class.to_s\n when 'String' \n if anything.match(/^\\/.*\\/$/) # '/asd/' is probably an error! The regex builder trails with '/' automatically\n fatal 23,\"Attention, the regex is a string with trailing '/', are you really SURE this is what you want?!?\"\n end\n return Regexp.new(anything)\n when 'Regexp'\n return anything # already ok\n when 'Array'\n return Regexp.new(anything.join('|'))\n else\n msg = \"Unknown class for autoregexing: #{red anything.class}\"\n $stderr.puts( msg )\n raise( msg )\n end\n return nil\nend", "def method_regex\n Regexp.new method_pattern, 'i'\n end" ]
[ "0.7329675", "0.72689664", "0.7261707", "0.71062505", "0.70473987", "0.704684", "0.6994994", "0.6994994", "0.69867474", "0.6928799", "0.6920296", "0.68591547", "0.6825901", "0.6807855", "0.67674977", "0.67615503", "0.6721402", "0.67136043", "0.6703084", "0.6640034", "0.6630384", "0.65970474", "0.6551828", "0.65272814", "0.6519877", "0.64823616", "0.6468883", "0.6446003", "0.64431375", "0.64026445", "0.6392846", "0.6372706", "0.63543797", "0.63501513", "0.63501513", "0.63417345", "0.63397133", "0.6330621", "0.63075596", "0.63067615", "0.62960094", "0.6285627", "0.6217463", "0.62065923", "0.6181061", "0.6178502", "0.61743164", "0.61740935", "0.61700535", "0.61606336", "0.61396724", "0.6135495", "0.61146474", "0.61075425", "0.61048275", "0.61048275", "0.6080542", "0.60660225", "0.6062877", "0.6036361", "0.60338914", "0.6029699", "0.6014369", "0.59978795", "0.59967536", "0.5994178", "0.5992321", "0.5956316", "0.5939054", "0.59309816", "0.5914707", "0.5912782", "0.5909691", "0.5909414", "0.5872106", "0.5872006", "0.5867857", "0.5867857", "0.5867857", "0.5847489", "0.58330494", "0.5829808", "0.58260274", "0.5821978", "0.5796017", "0.57925487", "0.5789925", "0.57844096", "0.5777369", "0.57659733", "0.5765592", "0.5765592", "0.5765592", "0.5765546", "0.5765546", "0.57495064", "0.5740364", "0.57326335", "0.57297575", "0.5729213", "0.57274956" ]
0.0
-1
Initialize the basic configuration to start the commit validation
def init $LOG = Logger.new($STDOUT,:pattern => config.log_pattern) # repository = ARGV.shift # transaction = ARGV.shift # raise 'Bad Arguments' if !transaction or !repository @projects = create_projects # parse the projects configuration # @commit = Commit.new(repository,transaction) @closed_status=config.closed_status end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @configuring = false\n @validating = false\n end", "def initialize(configuration)\n super\n require_configuration([:email, :password, :source])\n setup!\n end", "def init_compile_config\n end", "def initialize\n @config = DebMaker::Config.new\n yield @config\n @config.validate\n end", "def initialize(config)\n @config = config\n @config.symbolize_keys!\n @check_all = true\n end", "def initialize(config = {})\n\t\tsuper # check syntax\n\tend", "def initialize(config = {})\n\t\tsuper # check syntax\n\tend", "def initialize\n set_config\n end", "def init_compile_config\n # TODO\n end", "def init_compile_config\n # TODO\n end", "def setup_initial_config!\n application.config do\n attribute :praxis do\n attribute :validate_responses, Attributor::Boolean, default: false\n attribute :validate_response_bodies, Attributor::Boolean, default: false\n\n attribute :show_exceptions, Attributor::Boolean, default: false\n attribute :x_cascade, Attributor::Boolean, default: true\n end\n end\n end", "def initialize(commit)\n @commit = commit\n end", "def initialize(config)\n\t\tend", "def _init_configuration\n\t\t# Set defaults\n\t\t@setup = { \"create\" => false, \"environment\" => false, \"test\" => true, \"destroy\" => false }\n\t\t@config = false\n\tend", "def prepare(commit_message, force_commit)\n # If there's just one, it's the current version. Don't run if the current config is present.\n restore_woa_settings if Dir.glob(\"#{@app_directory.chomp(\"/wielder_of_anor-#{VERSION}\")}/wielder_of_anor*\").length > 1 &&\n !(File.exists?(\"#{@app_directory}/lib/config.yaml\"))\n first_run unless File.exists?(\"#{@app_directory}/lib/config.yaml\")\n\n config = YAML.load_file(\"#{@app_directory}/lib/config.yaml\")\n @commit_message = commit_message\n @force_commit = force_commit\n @current_directory = Dir.pwd\n @files_changed_file_location = config['files_changed_file_location']\n @commit_for_user = config['commit_for_user']\n @check_branch = config['check_branch']\n @branches_to_check = config['branches_to_check']\n @current_branch_file_location = \"#{@app_directory}/lib/current_branch\"\n\n # Don't want to use a previous version.\n File.delete(@files_changed_file_location) if File.exists?(@files_changed_file_location)\n\n git_diff\n\n @files_changed_file = File.open(@files_changed_file_location, \"r\")\n @forbidden_words = config['forbidden_words']\n end", "def define\n task :validate\n\n namespace :scm do\n task :push => :validate do\n status \"Pushing commits ...\"\n\n unless push!\n error \"Could not push commits\"\n end\n end\n end\n end", "def initialize\n super\n \n run_hook :before_configuration\n \n # Search the root of the project for required files\n $LOAD_PATH.unshift(root)\n \n # Check for and evaluate local configuration\n local_config = File.join(root, \"config.rb\")\n if File.exists? local_config\n puts \"== Reading: Local config\" if logging?\n instance_eval File.read(local_config)\n end\n \n run_hook :build_config if build?\n run_hook :development_config if development?\n \n run_hook :after_configuration\n \n # Add in defaults\n default_extensions.each do |ext|\n activate ext\n end\n \n if logging?\n self.class.extensions.each do |ext|\n puts \"== Extension: #{ext}\"\n end\n end\n end", "def initialize(commit)\n @commit = commit\n end", "def initialize config_path = nil\n @config = Configuration.new(config_path)\n @errors = {}\n\n generate_jshintrc_file\n end", "def init\n # hook method (called when checker is being initialized)\n end", "def initialize(&block)\n @ruby = GitHooksHelper::Ruby.new\n @debug = false\n\n @result = GitHooksHelper::Result.new(false)\n @changed_files = GitHooksHelper::Git.in_index\n debug(\"changed files\")\n debug @changed_files\n instance_eval(&block) if block\n\n if @result.errors?\n status = 1\n puts \"ERRORS:\".red\n puts @result.errors.join(\"\\n\")\n puts \"--------\\n\".red\n end\n\n if @result.warnings?\n if @result.stop_on_warnings\n puts \"WARNINGS:\".yellow\n else\n puts \"Warnings:\".yellow\n end\n puts @result.warnings.join(\"\\n\")\n puts \"--------\\n\".yellow\n end\n\n if @result.perfect_commit?\n puts \"Perfect commit!\".green\n end\n\n if @result.continue?\n # all good\n puts(\"COMMIT OK:\".green)\n exit 0\n else\n puts(\"COMMIT FAILED\".red)\n exit 1\n end\n end", "def init!\n # check if configuration file is already created\n unless File.exist?(CONFIG_FILE)\n puts \"=> [PagSeguro] The configuration could not be found at #{CONFIG_FILE.inspect}\"\n return\n end\n \n # The developer mode is enabled? So install it!\n developer_mode_install! if developer?\n end", "def initialize(grit_commit)\n @grit_commit = grit_commit\n end", "def startup_config_check\n\t\tfw_connect\n\t\t# they are ALL stale right now...\n\t\tcheck_config_freshness\n\t\tpending = get_pending_commits\n\t\tdo_pending_commits(pending) if pending != 0\n\t\tfw_exit\n\tend", "def init(config=@config)\n # make the directory if it's not there\n super\n FileUtils.makedirs @hg\n \n requirements = [\"revlogv1\"]\n \n # add some requirements\n if config[\"format\"][\"usestore\", Boolean] || true\n FileUtils.mkdir \"#{@hg}/store\"\n requirements << \"store\"\n requirements << \"fncache\" if config[\"format\"][\"usefncache\", Boolean, true]\n \n # add the changelog\n make_changelog\n end\n \n # write the requires file\n write_requires requirements\n end", "def configure; end", "def initialize()\n begin\n puts \"Eis::Runner::init called\" if $DEBUG\n @loaded_modules = []\n generate_module_list()\n handle = InputHandler.new()\n set_environment()\n rescue ArgumentError =>e\n puts \"\\e[31mERROR\\e[0m: No config file given...\" + e\n puts \"--------------------------------------------\"\n raise\n end\n end", "def initialize(config = nil)\n @config = config\n setup\n end", "def validate_config\n verify_config_provided(options)\n setup_logger(options)\n extend_load_path(options[:load_path])\n\n exit Longleaf::ValidateConfigCommand.new(options[:config]).execute\n end", "def initialize(grit_commit)\n @grit_commit = grit_commit\n end", "def initialize(config = {})\n init_config(config)\n end", "def initialize(config = {})\n init_config(config)\n end", "def initialize(config = {})\n init_config(config)\n end", "def initialize\n @formatter = Yolo::Formatters::ProgressFormatter.new\n @error = Yolo::Formatters::ErrorFormatter.new\n check_config\n update_config\n end", "def initialize(...)\n super()\n configure(...)\n end", "def initialize\n @email = \"[email protected]\"\n @group = \"anonymous\"\n @documents = []\n @changes = []\n @config = {}\n end", "def initialize(config)\n @config = config\n setup\n end", "def configure\n load_configuration\n verify_configuration\n end", "def configure\n end", "def configure!(config = {})\n @token = config[:token]\n @node = config[:node]\n @version = config[:version]\n @revision = config[:revision]\n self\n end", "def initialize(config)\n end", "def initialize(config)\n end", "def validate_pre_run!\n check_if_yml_present!\n check_if_yml_has_correct_content!\n check_if_rubocop_command_exists!\n end", "def initialize\n message.info \"Loading configuration...\"\n @config ||= validate(config_file)\n aws_config\n end", "def initialize()\r\n buildProperties = parse([BUILD_PROPERTIES, LOCAL_PROPERTIES]);\r\n testProperties = parse([TEST_PROPERTIES, LOCAL_PROPERTIES]);\r\n @app_host = testProperties[\"config_appHost\"]\r\n @module_html = buildProperties[\"config_appStartupUrl\"]\r\n @base_url = self.app_host + \"/\" + self.module_html\r\n @admin_user = testProperties[\"config_credentialsAdmin\"]\r\n @normal_user = testProperties[\"config_credentialsUser\"]\r\n @browser = testProperties[\"config_capybaraSeleniumBrowser\"]\r\n @browserPath = testProperties[\"config_capybaraSeleniumBrowserPath\"]\r\n @defaultAjaxWaitTime = testProperties[\"config_defaultAjaxWaitTime\"]\r\n end", "def init!\n # check if configuration file is already created\n puts \"=> [MoIP] Sandbox mode enabled\" if sandbox?\n unless File.exist?(CONFIG_FILE)\n puts \"=> [Moip] The configuration could not be found at #{CONFIG_FILE.inspect}\"\n return\n end\n end", "def initialize(*args)\n initialize_config unless instance_variable_defined?(:@config)\n super\n end", "def configure\n\n # config file default options\n configuration = {\n :options => {\n :verbose => false,\n :coloring => 'AUTO'\n },\n :mount => {\n :source => {\n :name => nil\n },\n :mountpoint => {\n :name => nil\n },\n :passphrasefile => {\n :name => 'passphrase'\n },\n :keyfile => {\n :name => 'encfs6.xml'\n },\n :cmd => nil,\n :executable => nil\n },\n :unmount => {\n :mountpoint => {\n :name => nil\n },\n :cmd => nil,\n :executable => nil\n },\n :copy => {\n :source => {\n :name => nil\n },\n :destination => {\n :name => nil\n },\n :cmd => nil,\n :executable => nil\n }\n }\n\n # set default config if not given on command line\n config = @options[:config]\n unless config\n config = [\n File.join(@working_dir, \"revenc.conf\"),\n File.join(@working_dir, \".revenc.conf\"),\n File.join(@working_dir, \"config\", \"revenc.conf\"),\n File.expand_path(File.join(\"~\", \".revenc.conf\"))\n ].detect { |filename| File.exists?(filename) }\n end\n\n if config && File.exists?(config)\n # rewrite options full path for config for later use\n @options[:config] = config\n\n # load options from the config file, overwriting hard-coded defaults\n config_contents = YAML::load(File.open(config))\n configuration.merge!(config_contents.symbolize_keys!) if config_contents && config_contents.is_a?(Hash)\n else\n # user specified a config file?, no error if user did not specify config file\n raise \"config file not found\" if @options[:config]\n end\n\n # the command line options override options read from the config file\n @options = configuration[:options].merge!(@options)\n @options.symbolize_keys!\n\n # mount, unmount and copy configuration hashes\n @options[:mount] = configuration[:mount].recursively_symbolize_keys! if configuration[:mount]\n @options[:unmount] = configuration[:unmount].recursively_symbolize_keys! if configuration[:unmount]\n @options[:copy] = configuration[:copy].recursively_symbolize_keys! if configuration[:copy]\n end", "def initialize(config={})\n @config = config\n end", "def setup\n @commit_data = {\n :id => \"a-real-deal-id-#{get_iterator}\",\n :commit_message => 'Creating Git Resource',\n :author_name => 'Collin',\n :author_email => '[email protected]',\n :attributes => \"{ \\\"title\\\" : \\\"test #{get_iterator}\\\" }\",\n :rendered => \"<h1>Test #{get_iterator}</h1>\"\n }\n @commit_sha = Regulate::Git::Interface.save(@commit_data)\n end", "def initialize(conf = {})\n super(conf) ;\n setup() ;\n end", "def initialize(options = {})\n @options = options\n merge_configs\n merge_message\n validate_options\n end", "def new_config\n puts '####################################################################'\n puts '## Welcome to Fast Gitlab Issues configuration ##'\n puts \"####################################################################\\n\\n\"\n\n # -------------------------- #\n # CHECKERS #\n # -------------------------- #\n\n git_directory?\n already_configured?\n\n # -------------------------- #\n # INITIALIZERS #\n # -------------------------- #\n\n # The hash that will contain the project's fgi configuration to save as yml\n # It will contain :\n # :url\n # :routes\n # :project_id\n # :project_slug\n # :default_branch\n config = {}\n\n config[:git_service_class] = define_git_service\n config[:url] = save_git_url\n\n # Instanciation of the Git service class\n # TODO - HARD REFECTO NEEDED HERE...\n git_service = config[:git_service_class].new(config: config)\n config[:git_service] = git_service.to_sym\n user_token = save_user_token(config: config, git_service: git_service)\n project_name_and_id = define_project_name_and_id(git_service, user_token)\n config = config.merge(project_name_and_id)\n git_service = config[:git_service_class].new(config: config)\n config[:default_branch] = define_default_branch(git_service, user_token)\n\n # -------------------------- #\n # CREATORS #\n # -------------------------- #\n\n Fgi::Tokens.create_user_tokens_file(config: config, git_service: git_service, token: user_token)\n create_fgi_config_file(config)\n end", "def initialize(commit, repository)\n @commit = commit\n @repository = repository\n @comments = nil\n end", "def initialize\n configure_via_yaml\n configure_via_env\n end", "def initialize\n @argv_option = {}\n @config = {}\n end", "def initialize(config)\n @config = config\n @matchers = []\n end", "def setup!\n if @options.has_key?(:home)\n @home = Pathname.new(@options[:home])\n elsif not ENV['COMMITSU_HOME'].nil?\n @home = Pathname.new(ENV['COMMITSU_HOME'])\n else\n @home = Environment.default_home\n end\n load_config!\n @gui = @options.has_key?('gui')\n if @options.has_key?('issuetracker')\n begin\n @tracker = Commitsu::Trackers.get(@options['issuetracker'],self)\n rescue LoadError => le\n puts \"Unable to load tracker. Gem not found: #{le}\"\n @tracker = Commitsu::Trackers.none\n end\n else\n @tracker = Commitsu::Trackers.none\n end\n end", "def git_config\n unless options[:skip_git]\n puts \"Initializing git to project\"\n end\n end", "def initialize(params={})\n if params.has_key?(:name)\n @botname = params.delete(:name)\n end\n\n @config = load_config(params)\n @run_count = 0\n\n #\n # check for command line options\n # handle resets, etc\n #\n\n at_exit do\n if [email protected]? && @run_count <= 0 && skip_run? != true\n run!\n end\n \n raise $! if $!\n end\n @handlers = {}\n end", "def initialize(config = {})\n @config = config\n end", "def initialize(params={})\n if params.has_key?(:name)\n @botname = params.delete(:name)\n end\n\n @config = load_config(params)\n @run_count = 0\n\n #\n # check for command line options\n # handle resets, etc\n #\n\n at_exit do\n if [email protected]? && @run_count <= 0 && skip_run? != true\n run_or_stream\n end\n \n raise $! if $!\n end\n @handlers = {}\n end", "def initialize(config={})\n @configuration = config\n end", "def initialize(options = {})\n @build_command = options.delete(:build_command)\n @spec_command = options.delete(:spec_command) \n @verbose = options.has_key?(:verbose) ? options.delete(:verbose) : false\n @update = options.has_key?(:update) ? options.delete(:update) : false\n @spec = options.has_key?(:spec) ? options.delete(:spec) : true\n @app_root = options.delete(:app_root)\n super\n end", "def initialize(config)\n @config = config\n end", "def initialize(config)\n @config = config\n end", "def finalize_setup\n Bolt::Logger.configure(config.log, config.color, config.disable_warnings)\n Bolt::Logger.stream = config.stream\n Bolt::Logger.analytics = analytics\n Bolt::Logger.flush_queue\n\n # Logger must be configured before checking path case and project file, otherwise logs will not display\n config.check_path_case('modulepath', config.modulepath)\n config.project.check_deprecated_file\n\n if options[:clear_cache] && File.exist?(config.project.plugin_cache_file)\n FileUtils.rm(config.project.plugin_cache_file)\n end\n\n warn_inventory_overrides_cli(options)\n validate_ps_version\n\n options\n rescue Bolt::Error => e\n outputter.fatal_error(e)\n raise e\n end", "def initialize\n @configuration = Configuration.new\n end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def initialize(config)\n raise 'Configuration is empty, abort!' \\\n if config.nil? || config.empty?\n raise \"Configuration does not specify 'config' section!\" \\\n unless config.key?('config')\n\n config['checks'] = [] unless config.key?('checks')\n config['custom'] = [] unless config.key?('custom')\n\n @config = config\n @events = []\n @status = 0\n @output = ''\n @source_nodename_map = nil\n\n @prometheus = Sensu::Plugins::Prometheus::Client.new\n @metrics = Sensu::Plugins::Prometheus::Metrics.new(@prometheus)\n @tmpl = Sensu::Plugins::Prometheus::Checks::Output.new\n @dispatcher = Sensu::Plugins::Events::Dispatcher.new\n end", "def init(path = Dir.pwd, options = {})\n exit_status = FalkorLib::Git.init(path, options)\n unless command?('git-flow')\n # Check (mainly for Linux) if the command is not available under `/usr/lib/git-core`\n git_lib = '/usr/lib/git-core/'\n error \"you shall install git-flow: see https://github.com/nvie/gitflow/wiki/Installation\" unless File.exist?(File.join(git_lib, 'git-flow'))\n end\n remotes = FalkorLib::Git.remotes(path)\n git_root_dir = FalkorLib::Git.rootdir( path )\n Dir.chdir( git_root_dir ) do\n unless FalkorLib::Git.commits?( git_root_dir)\n warn \"Not yet any commit detected in this repository.\"\n readme = 'README.md'\n unless File.exist?( readme )\n answer = ask(cyan(\"=> initialize a commit with an [empty] #{readme} file (Y|n)?\"), 'Yes')\n exit 0 if answer =~ /n.*/i\n FileUtils.touch(readme)\n end\n FalkorLib::Git.add(readme, \"Initiate the repository with a '#{readme}' file\")\n end\n branches = FalkorLib::Git.list_branch(path)\n gitflow_branches = FalkorLib.config.gitflow[:branches].clone\n # correct eventually the considered branch from the options\n gitflow_branches.each do |t, _b|\n gitflow_branches[t] = options[t.to_sym] if options[t.to_sym]\n confs = FalkorLib::Git.config('gitflow*', path, :hash => true)\n gitflow_branches[t] = confs[\"gitflow.branch.#{t}\"] unless confs.empty?\n end\n if options[:interactive]\n gitflow_branches[:master] = ask(\"=> branch name for production releases\", gitflow_branches[:master])\n gitflow_branches[:develop] = ask(\"=> branch name for development commits\", gitflow_branches[:develop])\n end\n ap gitflow_branches if options[:debug]\n if remotes.include?( 'origin' )\n info \"=> configure remote (tracked) branches\"\n exit_status = FalkorLib::Git.fetch(path)\n gitflow_branches.each do |_type, branch|\n if branches.include? \"remotes/origin/#{branch}\"\n exit_status = FalkorLib::Git.grab(branch, path)\n else\n unless branches.include? branch\n info \"=> creating the branch '#{branch}'\"\n FalkorLib::Git.create_branch( branch, path )\n end\n exit_status = FalkorLib::Git.publish(branch, path )\n end\n end\n else\n gitflow_branches.each do |_type, branch|\n unless branches.include? branch\n info \" => creating the branch '#{branch}'\"\n exit_status = FalkorLib::Git.create_branch( branch, path )\n end\n end\n end\n #info \"initialize git flow configs\"\n gitflow_branches.each do |t, branch|\n exit_status = execute \"git config gitflow.branch.#{t} #{branch}\"\n end\n FalkorLib.config.gitflow[:prefix].each do |t, prefix|\n exit_status = execute \"git config gitflow.prefix.#{t} #{prefix}\"\n end\n devel_branch = gitflow_branches[:develop]\n #info \"checkout to the main development branch '#{devel_branch}'\"\n exit_status = run %(\n git checkout #{devel_branch}\n )\n # git config branch.$(git rev-parse --abbrev-ref HEAD).mergeoptions --no-edit for the develop branch\n exit_status = execute \"git config branch.#{devel_branch}.mergeoptions --no-edit\"\n if branches.include?('master') && !gitflow_branches.values.include?( 'master' )\n warn \"Your git-flow confuguration does not hold the 'master' branch any more\"\n warn \"You probably want to get rid of it asap by running 'git branch -d master'\"\n end\n if devel_branch != 'master' &&\n remotes.include?( 'origin' ) &&\n branches.include?( 'remotes/origin/master')\n warn \"You might want to change the remote default branch to point to '#{devel_branch}\"\n puts \"=> On github: Settings > Default Branch > #{devel_branch}\"\n puts \"=> On the remote bare Git repository: 'git symbolic-ref HEAD refs/head/#{devel_branch}'\"\n end\n end\n exit_status\n end", "def configuration; end", "def configuration; end", "def configuration; end", "def configuration; end", "def configuration; end", "def initialize(config_path = nil)\n @config = Configuration.new(config_path)\n @errors = {}\n end", "def git_initialize\n g = Git.init\n g.add('.')\n g.commit('project created')\n end", "def initialize(config=nil)\n unless config.kind_of?(GitHandler::Configuration)\n raise SessionError, 'Configuration required!'\n end\n\n if config.raise_errors == true\n unless File.exists?(config.home_path)\n raise ConfigurationError, \"Home path does not exist!\"\n end\n\n unless File.exists?(config.repos_path)\n raise ConfigurationError, \"Repositories path does not exist!\"\n end\n end\n\n @config = config\n @log = Logger.new(@config.log_path)\n end", "def initialize\n envConfigFile = \"#{$ROOT}/../config/envConfig.yml\"\n @envConfig = loadYAMLFile(envConfigFile)\n stepsFile = \"#{$ROOT}/../config/steps.csv\"\n @steps = loadCSVFile(stepsFile)\n pageObjectsFile = \"#{$ROOT}/../config/pageObjects.csv\"\n @pageObjects = loadCSVFile(pageObjectsFile)\n @reportFolder = generatedReportFolder\n @isProcess = true\n @skipCurrentStep = false\n @report = []\n end", "def initialize\n @config = config_from_file || empty_config\n end", "def initialize\n @configuration = RepositoryConfiguration.new\n end", "def initialize(config)\n @config = config\n end" ]
[ "0.67084014", "0.6101736", "0.60603243", "0.6054827", "0.60223264", "0.5968312", "0.5968312", "0.59331715", "0.59236073", "0.59236073", "0.5909103", "0.5860426", "0.58576787", "0.5824547", "0.5819913", "0.58069026", "0.58011544", "0.579041", "0.5743511", "0.57093674", "0.57048714", "0.57029355", "0.5642017", "0.5627783", "0.5622642", "0.5616375", "0.5608267", "0.560739", "0.55929095", "0.5588093", "0.55847615", "0.55847615", "0.55847615", "0.5584381", "0.5564544", "0.55476856", "0.5546725", "0.55354834", "0.55296874", "0.5529266", "0.55243284", "0.55243284", "0.55226797", "0.5510026", "0.5507027", "0.5502231", "0.54958296", "0.54945815", "0.5484461", "0.5480665", "0.54671603", "0.54646695", "0.54371583", "0.5411196", "0.540188", "0.5397376", "0.5396491", "0.53909856", "0.5386355", "0.5384054", "0.53839725", "0.53823876", "0.537733", "0.53741336", "0.53733045", "0.53733045", "0.53625935", "0.5362408", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.5359682", "0.53580177", "0.5353474", "0.53511006", "0.53511006", "0.53511006", "0.53511006", "0.53511006", "0.5347435", "0.53470063", "0.5341208", "0.5339523", "0.533715", "0.53367317", "0.533555" ]
0.5911225
10
Reached Summary 4 a simple method
def tame_it( number_of_shrews ) puts "Literally " + number_of_shrews.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def p15\n\t\nend", "def schubert; end", "def stest_method_1(test); end", "def zuruecksetzen()\n end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def r; end", "def r; end", "def koan_4\nend", "def demoMethod\n\t\traise \"Ceci est une methode abstraite. This is an abstact method.\";\n\tend", "def verdi; end", "def probers; end", "def schumann; end", "def how_it_works\r\n end", "def call() end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def who_we_are\r\n end", "def terpene; end", "def villian; end", "def returns; end", "def herald; end", "def king_richard_iii; end", "def summary; end", "def summary; end", "def summary; end", "def summary; end", "def demo3\n end", "def koan_3\nend", "def methods() end", "def method\r\n\t1\r\nend", "def usage; end", "def usage; end", "def private; end", "def pass; end", "def pass; end", "def spouse; end", "def bizet; end", "def s1\n end", "def method_one; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def m2\n puts \"metodo 2\"\n end", "def operation; end", "def primer\n end", "def calls; end", "def calls; end", "def silly_adjective; end", "def jack_handey; end", "def operations; end", "def operations; end", "def bellini; end", "def op; end", "def method_731(base); end", "def formation; end", "def sn\n end", "def implementation; end", "def implementation; end", "def example_passed(_)\n end", "def gounod; end", "def weber; end", "def method_one\n end", "def method_one\n end", "def berlioz; end", "def method(p0) end", "def simple_interest\n\nend", "def call(*) end", "def call(*) end", "def troop; end", "def mambo_no_5; end", "def g; end", "def g; end", "def mascot; end", "def spice; end" ]
[ "0.7104674", "0.69082373", "0.67580247", "0.6692698", "0.66250205", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6539291", "0.6513527", "0.6513527", "0.6513527", "0.6513527", "0.6513527", "0.6513527", "0.6513527", "0.6513527", "0.6510228", "0.6510228", "0.650475", "0.6503454", "0.64867806", "0.64667183", "0.6447575", "0.6416007", "0.64076144", "0.63901234", "0.63901234", "0.63901234", "0.63901234", "0.63426447", "0.6309373", "0.627579", "0.6270852", "0.6263629", "0.6249734", "0.624896", "0.624896", "0.624896", "0.624896", "0.62453717", "0.62444025", "0.6240276", "0.62245005", "0.62229306", "0.62229306", "0.62038314", "0.6192297", "0.6192297", "0.61795807", "0.61734706", "0.6145517", "0.61438626", "0.6142684", "0.6142684", "0.6142684", "0.6142684", "0.6142684", "0.6142684", "0.6142684", "0.6142684", "0.61410224", "0.61151594", "0.6109551", "0.61061305", "0.61061305", "0.60988915", "0.6092981", "0.60895485", "0.60895485", "0.606777", "0.60673857", "0.6057488", "0.60561246", "0.60525435", "0.60511905", "0.60511905", "0.60496104", "0.6039927", "0.6039029", "0.60361713", "0.60361713", "0.60323983", "0.6031339", "0.60253656", "0.602484", "0.602484", "0.6016532", "0.6016097", "0.6009106", "0.6009106", "0.6007254", "0.600556" ]
0.0
-1
Finished Summary 5 Complete works of William Shakespeare
def get_shakey {"William Shakespeare"=>{"1"=>{"title"=>"The Two Gentlemen of Verona", "finished"=>1591}, "2"=>{"title"=>"The Taming of the Shrew", "finished"=>1591}, "3"=>{"title"=>"Henry VI, Part 2", "finished"=>1591}, "4"=>{"title"=>"Henry VI, Part 3", "finished"=>1591}, "5"=>{"title"=>"Henry VI, Part 1", "finished"=>1592}, "6"=>{"title"=>"Titus Andronicus", "finished"=>1592}, "7"=>{"title"=>"Richard III", "finished"=>1593}, "8"=>{"title"=>"Edward III", "finished"=>1593}, "9"=>{"title"=>"The Comedy of Errors", "finished"=>1594}, "10"=>{"title"=>"Love's Labour's Lost", "finished"=>1595}, "11"=>{"title"=>"Love's Labour's Won", "finished"=>1596}, "12"=>{"title"=>"Richard II", "finished"=>1595}, "13"=>{"title"=>"Romeo and Juliet", "finished"=>1595}, "14"=>{"title"=>"A Midsummer Night's Dream", "finished"=>1595}, "15"=>{"title"=>"King John", "finished"=>1596}, "16"=>{"title"=>"The Merchant of Venice", "finished"=>1597}, "17"=>{"title"=>"Henry IV, Part 1", "finished"=>1597}, "18"=>{"title"=>"The Merry Wives of Windsor", "finished"=>1597}, "19"=>{"title"=>"Henry IV, Part 2", "finished"=>1598}, "20"=>{"title"=>"Much Ado About Nothing", "finished"=>1599}, "21"=>{"title"=>"Henry V", "finished"=>1599}, "22"=>{"title"=>"Julius Caesar", "finished"=>1599}, "23"=>{"title"=>"As You Like It", "finished"=>1600}, "24"=>{"title"=>"Hamlet", "finished"=>1601}, "25"=>{"title"=>"Twelfth Night", "finished"=>1601}, "26"=>{"title"=>"Troilus and Cressida", "finished"=>1602}, "27"=>{"title"=>"Sir Thomas More", "finished"=>1604}, "28"=>{"title"=>"Measure for Measure", "finished"=>1604}, "29"=>{"title"=>"Othello", "finished"=>1604}, "30"=>{"title"=>"All's Well That Ends Well", "finished"=>1605}, "31"=>{"title"=>"King Lear", "finished"=>1606}, "32"=>{"title"=>"Timon of Athens", "finished"=>1606}, "33"=>{"title"=>"Macbeth", "finished"=>1606}, "34"=>{"title"=>"Antony and Cleopatra", "finished"=>1606}, "35"=>{"title"=>"Pericles, Prince of Tyre", "finished"=>1608}, "36"=>{"title"=>"Coriolanus", "finished"=>1608}, "37"=>{"title"=>"The Winter's Tale", "finished"=>1611}, "38"=>{"title"=>"Cymbeline", "finished"=>1610}, "39"=>{"title"=>"The Tempest", "finished"=>1611}, "40"=>{"title"=>"Cardenio", "finished"=>1613}, "41"=>{"title"=>"Henry VIII", "finished"=>1613}, "42"=>{"title"=>"The Two Noble Kinsmen", "finished"=>1614}}} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def summary; end", "def summary; end", "def summary; end", "def summary; end", "def run\n\t\t\tsummary\n\t\tend", "def finished\n day_noun = (@rubyist.days > 1 ? 'days' : 'day')\n real_noun = (@rubyist.real_ruby_count.zero? || @rubyist.real_ruby_count > 1 ? 'rubies' : 'ruby')\n fake_noun = (@rubyist.fake_ruby_count.zero? || @rubyist.fake_ruby_count > 1 ? 'fake rubies' : 'fake ruby')\n puts \"After #{@rubyist.days} #{day_noun}, Rubyist #{@rubyist.id} found:\"\n puts \"\\t#{@rubyist.real_ruby_count} #{real_noun}\\n\\t#{@rubyist.fake_ruby_count} #{fake_noun}\"\n\n return_msg = ''\n return_msg = 'Going home empty-handed.' if @rubyist.real_ruby_count.zero?\n return_msg = 'Going home sad.' if @rubyist.real_ruby_count <= 9 && [email protected]_ruby_count.zero?\n return_msg = 'Going home victorious!' if @rubyist.real_ruby_count > 9\n return_msg\n end", "def summary\n \n end", "def runs; end", "def final_summary\n puts\n puts <<-eos\n --------------------------------------------------------------------------\n Complete Summary:\n Execution time: #{as_time_elapsed(Time.now - @start)}\n\n Up To Date: #{@uptodate}\n\n Failures: #{@failed}\n\n Added: #{@added}\n Updated: #{@updated}\n Bytes copied: #{as_byte_size(@copied_bytes)}\n\n Removed: #{@removed}\n Bytes freed: #{as_byte_size(@freed_bytes)}\n --------------------------------------------------------------------------\n eos\n puts\n STDOUT.flush\n end", "def tally\n\t\t\treturn if completed?\n\t\t\tcomplete if consensus?\n\t\tend", "def summary\n end", "def summary\n end", "def completed_text_extraction\n end", "def summary\n # TODO\n end", "def schumann; end", "def phase_one\n\t#Intro\n\n\t\[email protected] do |tribe|\n\t\tputs \"Welcome #{tribe}\".green\n\t\tend\n\nprint_header(\"For Phase 1, you will now compete in 8 challenges for immunity. Good luck!\")\n\n\t8.times do\n\t\timmunity_challenge_losing_tribe = @borneo.immunity_challenge\n\t\tputs \"#{immunity_challenge_losing_tribe}\".green + \" has lost the immunity challenge and must now vote out 1 member.\"\n\t\tmember_voted_off = immunity_challenge_losing_tribe.tribal_council\n\tend\t\nend", "def complete\n # # step 0: 对Solutions的结果做voting,并将最终结果存入Problem的result中\n # PhotoRecognitionJob.perform_later(self.id.to_s)\n # step 1: 修改Problem的状态为solved,未完成的Solutions的状态为failed\n self.set(status: :solved)\n self.solutions.each { |solution|\n if solution.status.waiting?\n solution.set(status: :failed)\n end\n }\n # # step 2: 修改Seeker与Solvers的credit\n # self.creator.crowdsourcing_profile.decrease_credit(self.credit_expend)\n # self.creator.crowdsourcing_profile.decrease_prepared_credit(self.credit_prepared)\n # self.creator.crowdsourcing_profile.touch(:updated_at)\n # self.creator.crowdsourcing_profile.save\n # self.solutions.each { |solution|\n # if solution.status.solved?\n # solution.creator.crowdsourcing_profile.increase_credit(solution.problem.credit)\n # solution.creator.crowdsourcing_profile.touch(:updated_at)\n # solution.creator.crowdsourcing_profile.save\n # end\n # }\n # step 3: 修改Seeker_Profile中的 finished + 1 以及积分变化\n # 修改Solver_Profile:如果完成,finished + 1,积分变化;如果失败,failed + 1,积分不变\n self.creator.seeker_profile.increase_finished\n # self.creator.seeker_profile.increase_credit(self.credit_expend)\n self.creator.seeker_profile.touch(:updated_at)\n self.creator.seeker_profile.save\n self.solutions.each { |solution|\n if solution.status.solved?\n solution.creator.solver_profile.increase_finished\n # solution.creator.solver_profile.increase_credit(solution.problem.credit)\n solution.creator.solver_profile.touch(:updated_at)\n solution.creator.solver_profile.save\n else\n solution.creator.solver_profile.increase_failed\n solution.creator.solver_profile.touch(:updated_at)\n solution.creator.solver_profile.save\n end\n }\n end", "def phase_one\n introduction\n title \"Phase One\"\n losers = 0\n immune_members = []\n 8.times do\n losing_tribe = @borneo.tribes.shuffle.first\n puts \"The losing tribe is #{losing_tribe}\".red\n loser = losing_tribe.tribal_council()#no immune members\n puts \" The loser member is #{loser}\"\n losers += 1\n counting = 0\n @borneo.tribes.each{|tribe| counting += tribe.members.length}\n puts \" #{losers} gone!\"\n puts \" #{counting} remaining players\"\n end\nend", "def completed\n end", "def print_final_count finished_driver\r\n\t\tif finished_driver.num_books == 1\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_books} book!\"\r\n\t\telse\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_books} books!\"\r\n\t\tend\r\n\t\t\r\n\t\tif finished_driver.num_toys == 1\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_toys} dinosaur toy!\"\r\n\t\telse\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_toys} dinosaur toys!\"\r\n\t\tend\r\n\t\t\r\n\t\tif finished_driver.num_classes == 1\r\n\t\t\tputs \"#{finished_driver.name} attended #{finished_driver.num_classes} class!\"\r\n\t\telse\r\n\t\t\tputs \"#{finished_driver.name} attended #{finished_driver.num_classes} classes!\"\r\n\t\tend\r\n\t\t\r\n\tend", "def masterwork_prob_bonus; 0; end", "def createJobSummary\n comment = \"PR cannot be merged due to following issues:\\n\"\n if MAINTAINERS_FAILED_VALIDATION.length() != 0\n comment += \"- Maintainers\\n\"\n for issueObject in MAINTAINERS_FAILED_VALIDATION do\n comment += \"\\t- `#{issueObject[:title]}`\\n\"\n for issue in issueObject[:issues] do\n comment += \"\\t\\t- #{issue}\\n\"\n end\n end\n end\n if OSSPROJECTS_FAILED_VALIDATION.length() != 0\n comment += \"- OSS Projects\\n\"\n for issueObject in OSSPROJECTS_FAILED_VALIDATION do\n comment += \"\\t- `#{issueObject[:title]}`\\n\"\n for issue in issueObject[:issues] do\n comment += \"\\t\\t- #{issue}\\n\"\n end\n end\n end\n if SOCIALGOOD_FAILED_VALIDATION.length() != 0\n comment += \"- Social Good Projects\\n\"\n for issueObject in SOCIALGOOD_FAILED_VALIDATION do\n comment += \"\\t- `#{issueObject[:title]}`\\n\"\n for issue in issueObject[:issues] do\n comment += \"\\t\\t- #{issue}\\n\"\n end\n end\n end\n @logger.info(\"Summary: #{comment}\")\n File.write(ENV[\"GITHUB_STEP_SUMMARY\"], comment)\nend", "def phase_one\n puts \"Get ready to start Part 1.\".light_grey\n puts \"Each Tribe will participate in an immunity challenge.\".light_grey\n puts \"The losing Tribe will then vote someone off the island.\".light_grey\n 8.times do \n\t#Sets variable for tribe loser of immunity challege\n\tlosing_tribe = @borneo.immunity_challenge \n\tputs \"#{losing_tribe} \".red + \"has lost the challenge and will vote someone off the island.\"\n\t#Losing tribe holds tribal council and votes off member\n\tmember_voted_off = losing_tribe.tribal_council\n\tputs \"Sadly, \" + \"#{member_voted_off} \".green + \"has been voted off the island.\"\n end\nend", "def finished; end", "def results; end", "def results; end", "def results; end", "def completed()\n end", "def job_summary\n summary = \"#{self.title} - \"\n\n if self.avg_bid\n summary += \"#{self.avg_bid}\"\n elsif self.budget\n summary += \"#{self.budget}\"\n elsif self.budget_range\n summary += \"#{self.budget_range.join(\" - \")}\"\n end\n summary\n end", "def run_completed\n end", "def complete_investigation; end", "def master_done!\n @done = true\n specification! true\n summarize_performance!\n \t\tsummarize_results! @results\n \t\tcleanup!\n \t\t#Notify.completed @experiment\n\n \t\t#sleep 1\n #DRb.stop_service\n end", "def phase_one\n puts \"Phase 1 Starting\".yellow\n counter = 8\n eliminated = []\n while counter > 0\n indexer = 8 - counter\n puts \"Phase one, round #{(indexer+1).to_s}:\".green\n tribe_selected = @borneo.immunity_challenge\n puts \"Tribe selected: #{tribe_selected.to_s}\".green\n puts \"Contestant #{tribe_selected.tribal_council} was eliminated without mercy!\".red\n counter -= 1\n end\n 8 # this is here to pass the test, but not sure it's ver useful beyond that\nend", "def find_work\n\n end", "def desc() summary; end", "def job_fair\n event_display(\"Flatiron holds a JOB FAIR. Everyone busts out their business cards.\")\n group_event_hash_creator({soft_skills: 3})\n end", "def phase_one\n puts \"Phase 1 has been started\"\n\n 8.times do\n selected_tribe = @borneo.immunity_challenge\n\t\tputs \"#{selected_tribe} was the tribe selected to vote\".yellow\n\t\tvoted_off = selected_tribe.tribal_council\n\t\tputs \"#{voted_off} was voted OUT!\".red\n end\nend", "def data\n @github.jobs[0..3] + @stackoverflow.jobs[0..3] + @acuk.jobs[0..3]\n end", "def stderrs; end", "def done\n get_stories_by_iteration(\"done\")\n end", "def summarize_suite(suite, tests); end", "def summarize_suite(suite, tests); end", "def results\r\n print_books\r\n print_toys\r\n print_classes\r\n end", "def extract_works(doc)\n works = []\n doc.search(\"by/citation/title\").each_with_index do |t, i|\n works << t.inner_text\n break if @num_of_works == i + 1\n end\n return nil if works.blank?\n \"most widely held #{works.length == 1 ? \"work\" : \"works\"}: \" + works.join(\"; \")\n end", "def schubert; end", "def home_run(ppl_on_base)\n points = ppl_on_base + 1\n puts \"There were #{ppl_on_base} people on base so we scored #{points} points\"\n end", "def get_test_run_summary_report(test_report, test_summary)\n file_data = test_report\n file_lines = file_data.split(\"\\n\")\n\n=begin\n #Remove the duplicate headings\n title = 0\n i = 0\n file_lines.each do |line|\n i += 1\n if line.match(/<h1 align='center'><u>(\\w|\\s)+<\\/u><\\/h1><br\\/>/)\n title += 1\n if title > 1\n file_lines.delete_at(i-1)\n end\n end\n end\n=end\n\n test_run_summary = <<-EOS\n <h1 align='center'><u>#{test_summary[:title]}<\\/u><\\/h1><br\\/>\n EOS\n\n #Get the test run details from the report\n file_data.match(/<td>Kadu server:(.+)<\\/td>/)\n kadu_server = $1\n test_suites = file_data.scan(/<th align=\"center\">(.+)<\\/th>/)\n test_suite_status = file_data.scan(/Test suite status: <font id=(statuspass|statusfail)>(.*)<\\/font>/)\n\n i = 0\n test_status = {}\n test_suites.each do |test_suite|\n test_status[test_suite] = test_suite_status[i]\n i +=1\n end\n\n test_status = test_status.sort_by{|name,status| status}\n\n test_run_time_in_secs = Time.parse(test_summary[:test_run_end_time].to_s) - Time.parse(test_summary[:test_run_start_time].to_s)\n\n # Get the test case numbers\n passed_tcs = 0\n failed_tcs = 0\n blocked_tcs = 0\n\n file_lines.each do |line|\n passed_tcs +=1 if line.match(\"Test result status: <font id=statuspass>PASS</font>\")\n failed_tcs +=1 if line.match(\"Test result status: <font id=statusfail>FAIL</font>\")\n blocked_tcs +=1 if line.match(\"Test result status: <font id=statusfail>BLOCK</font>\")\n end\n total_tcs_count = passed_tcs + failed_tcs + blocked_tcs\n\n #Create the test run summary section\n test_run_summary += <<-EOS\n <a name=summary></a>\n <table id=\"specifications\" width=\"500px\">\n <tr><td><strong>Kadu Server:</strong></td><td>#{kadu_server}</td></tr>\n <tr><td><strong>Country:</strong></td><td>#{test_summary[:country]}</td></tr>\n <tr><td><strong>Test Run Started On:</strong></td><td>#{test_summary[:test_run_start_time]}</td></tr>\n <tr><td><strong>Duration:</strong></td><td>#{test_run_time_in_secs} secs</td></tr>\n <tr><td><strong>Number of test cases executed:</strong></td><td>#{total_tcs_count}</td></tr>\n <tr><td><strong>Number of test cases passed:</strong></td><td>#{passed_tcs}</td></tr>\n <tr><td><strong>Number of test cases failed:</strong></td><td>#{failed_tcs}</td></tr>\n <tr><td><strong>Number of test cases blocked:</strong></td><td>#{blocked_tcs}</td></tr>\n </table>\n <br>\n EOS\n if !test_summary[:known_issues].nil?\n test_run_summary += <<-EOS\n #{get_fail_test_details(test_summary[:known_issues])}\n <br>\n EOS\n end\n\n test_run_summary += <<-EOS\n <table id=\"specifications\" width=\"900px\">\n <tr>\n <th >Test Suite</th>\n <th >Test Suite Status</th>\n </tr>\n EOS\n i = 0\n test_status.each do |suite_name,suite_status|\n test_run_summary += <<-EOS\n <tr>\n <td><a href=\"##{replace_space_by_dash(suite_name.to_s.gsub(/\"|\\[|\\]/,''))}\">#{suite_name.to_s.gsub(/\"|\\[|\\]/,'')}</a></td>\n <td><font id=#{suite_status[0]}>#{suite_status[1]}</font></td>\n </tr>\n EOS\n i +=1\n end\n test_run_summary += <<-EOS\n </table>\n <br>\n <hr size=2 color=\"#000080\">\n <br/>\n EOS\n\n # Convert the section into array and add it to the file at the start.\n test_run_summary = test_run_summary.split(\"\\n\")\n i = 0\n file_lines.each do |line|\n i += 1\n if line.match(/<center>/)\n j = i\n test_run_summary.each do |row|\n file_lines.insert(j,row)\n j +=1\n end\n break\n end\n end\n\n report = \"\"\n file_lines.each do |line|\n report += <<-EOS\n #{line}\n EOS\n end\n report\n end", "def print_summary\n update_now_date_time\n calc_difference\n puts \"#{DueText.minutes} #{till_or_since}: \\t #{calc_mins_till.round(2)} #{DueText.minutes_suffix} \\n\n #{DueText.hours} #{till_or_since}: \\t #{calc_hours_till.round(2)} #{DueText.hours_suffix} \\n\n #{DueText.days} #{till_or_since}: \\t #{calc_days_till.round(2)} #{DueText.days_suffix} \\n\n #{DueText.weeks} #{till_or_since}: \\t #{calc_weeks_till.round(2)} #{DueText.weeks_suffix} \\n\n #{DueText.months} #{till_or_since}: \\t #{calc_months_till.round(2)} #{DueText.months_suffix} \\n\n #{DueText.years} #{till_or_since}: \\t #{calc_years_till.round(2)} #{DueText.years_suffix}\"\n end", "def phase_three\n puts \"Phase 3 has been started\"\n\n 7.times do\n immune = @borneo.individual_immunity_challenge\n puts \"#{immune} wins the immunity\".blue\n\t\tvoted_off_contestant = @merge_tribe.tribal_council(immune: immune)\n\t\[email protected]_member voted_off_contestant\n\t\tputs \"#{voted_off_contestant}! is OUT!\".red\n end\nend", "def done; end", "def total\n count = 0\n self.total_time_exercise_workouts.each do |ex|\n count += ex.duration\n end\n count\n end", "def computeCompletionTimes(schedule)\n completionTime = 0\n completionTimesSum = 0\n schedule.each do |job|\n completionTime = completionTime + job[\"length\"]\n completionTimesSum = completionTimesSum + job[\"weight\"] * completionTime\n end\n\n puts completionTimesSum\nend", "def calculate_results\n Repository::Config.new(@repo, @log, @process, @type).status(5) {\n files = files_to_analyze\n puts '-----Files to analyze done (Step 1)'\n files = prepare_files_to_rate files\n puts '-----Prepare files to rate done (Step 2)'\n files = count_total_lines files\n puts '-----Count total lines done (Step 3)'\n files = count_errors files\n puts '-----Count errors done (Step 4)'\n files = grade_categories files\n puts '-----Grade categories done (Step 5)'\n files = grade_files files\n puts '-----Grade files done (Step 6)' + files.to_s\n gpa = grade_repo files\n puts '-----Grade repos done (Step 7)' + gpa.to_s\n gpa_percent = get_overall_grades files\n puts '-----Grade overall percentage done (Step 8)' + gpa_percent.to_s\n cat_issues = get_category_issues files\n puts '-----Get categories issues done (Step 9)' + cat_issues.to_s\n store_cat_issues cat_issues\n puts '-----Store category issues done (Step 10)'\n store_grades gpa, gpa_percent\n puts '-----Store grades done (Step 11)'\n }\n end", "def summary(failures, errors, flaky_jobs, duration)\n failed_examples_section = \"\\nFailed examples:\\n\\n\"\n\n failures.each do |_job, msg|\n parts = msg.split(\"\\n\")\n failed_examples_section << \" #{parts[-1]}\\n\"\n end\n\n summary = \"\"\n if @queue.build_failed_fast?\n summary << \"\\n\\n\"\n summary << \"The limit of #{@queue.fail_fast} failures has been reached\\n\"\n summary << \"Aborting...\"\n summary << \"\\n\"\n end\n\n summary << failed_examples_section if !failures.empty?\n\n errors.each { |_job, msg| summary << msg }\n\n summary << \"\\n\"\n summary << \"Total results:\\n\"\n summary << \" #{@queue.example_count} examples \" \\\n \"(#{@queue.processed_jobs_count} jobs), \" \\\n \"#{failures.count} failures, \" \\\n \"#{errors.count} errors\"\n summary << \"\\n\\n\"\n summary << \"Spec execution time: #{duration}\"\n\n if !flaky_jobs.empty?\n summary << \"\\n\\n\"\n summary << \"Flaky jobs detected (count=#{flaky_jobs.count}):\\n\"\n flaky_jobs.each { |j| summary << \" #{j}\\n\" }\n end\n\n summary\n end", "def proof_of_stake\n title(\"Proof of Stake\")\n\n eco_scale = \"https://en.wikipedia.org/wiki/Economies_of_scale\"\n pros1 = \"Energy efficient\"\n pros2 = \"More expensive to attack for attackers\"\n pros3 = \"Not susceptible to ecnomies of scale \\n\\t (for more details about this topic click on this link:\\n\\t #{eco_scale}).\"\n\n pros = [pros1, pros2, pros3]\n\n nothing_at_stake = \"https://medium.com/coinmonks/understanding-proof-of-stake-the-nothing-at-stake-theory-1f0d71bc027\"\n cons = \"nothing-at-stake problem \\n(for more details click on this link:\\n#{nothing_at_stake})\"\n\n\n ppc = {name: \"Peercoin\", website: \"https://peercoin.net/\"}\n pivx = {name: \"Pivx\", website: \"https://pivx.org/\"}\n rdd = {name: \"Reddcoin\", website: \"https://reddcoin.com/\"}\n\n used_by = [ppc, pivx, rdd]\n\n consensus_type = \"Competitive consensus\"\n\n\n explanation = \"\"\"\n The proof of stake was created as an alternative to the proof of work (PoW),\n to tackle inherent issues in the latter. Here instead of using mining, you\n have to have some stake(coins) in the system. So, if you own 10% of the\n stake(coins), then your probability of mining next block will be 10%.\n \"\"\"\n\n further_reading = \"https://en.wikipedia.org/wiki/Proof_of_stake\"\n\n p_o_s = {\n \"pros\" => pros,\n \"cons\" => cons,\n \"used_by\" => used_by,\n \"consensus_type\" => consensus_type,\n \"explanation\" => explanation,\n \"further_reading\" => further_reading\n }\n\n choice = \"0\"\n\n while !choice.include?(\"Q\") && !choice.include?(\"q\")\n choice = consensus_features\n if choice.include?(\"1\")\n puts \"Pros:\"\n p_o_s[\"pros\"].each_with_index { |val, index| puts \"\\t#{index+1}) #{val}\" }\n\n cons = p_o_s[\"cons\"]\n puts \"Cons: #{cons}\"\n elsif choice.include?(\"2\")\n puts \"Used by:\"\n p_o_s[\"used_by\"].each_with_index do\n |valeur, index|\n puts \"#{index+1})\"\n valeur.each do\n |key, value| puts \" #{key}: #{value}\"\n end\n end\n puts \"And others.\"\n elsif choice.include?(\"3\")\n consensus_type = p_o_s[\"consensus_type\"]\n puts \"Type: #{consensus_type}\"\n elsif choice.include?(\"4\")\n explanation = p_o_s[\"explanation\"]\n puts \"Explanation: #{explanation}\"\n elsif choice.include?(\"5\")\n further_reading = p_o_s[\"further_reading\"]\n puts \"Further Reading: #{further_reading}\"\n elsif choice.include?(\"Q\") || choice.include?(\"q\")\n break\n else\n puts \"Error\"\n end\n end\n\nend", "def exams_statistics\n end", "def phase_two\n puts \"Phase 2 has been started\"\n\n 3.times do\n immune = @borneo.individual_immunity_challenge\n puts \"#{immune} win the immunity\".blue\n voted_off_contestant = @merge_tribe.tribal_council({immune: immune})\n puts \"#{voted_off_contestant} is OUT!\".red\n end\nend", "def complete_homework\n self.homeworks.where(\"status = ?\", \"incomplete\").each {|hw| hw.update(status: \"completed\")}\n end", "def dump_summary(duration, example_count, failure_count, pending_count)\n end", "def dump_summary(duration, example_count, failure_count, pending_count)\n end", "def cp_summary(*filter)\n @the_nurse.completed_procs_summary(*filter).map {|name, n| \"#{name} #{n}\"}\n end", "def week_3\n wait(0)\n say \"Start your first short run.\"\n count_down(90, 'running')\n say \"Stop running now. You have 1 long run and two short ones left.\"\n count_down(90, 'walking')\n\n say \"Start the first long run now.\"\n count_down(3*60, 'running')\n say \"Stop running now. You have a short run and a long run left.\"\n count_down(3*60, 'walking')\n\n say \"Start your second short run.\"\n count_down(90, 'running')\n say \"Stop running. You have 1 more long run left.\"\n count_down(90, 'walking')\n\n say \"Start your last run now.\"\n count_down(3*60, 'running')\n say \"Stop running. After this walk, you will have finished.\"\n count_down(3*60, 'walking')\n\n say \"Great! You've finished for today.\"\nend", "def print_summary(num_employees, employeeNames, totalHoursWorked, grossPay)\n i = 0\n while i < num_employees\n puts \"#{employeeNames[i]} worked #{totalHoursWorked[i]} hours this week and earned $#{grossPay[i]} this week.\"\n i += 1\n end\nend", "def estimate\n if self.submitted? && (Time.now - self.updated_at) > 5 * 60\n # re-initialize the estimates\n self.estimated_cost = nil\n self.estimated_duration = nil\n # only estimate projects with a budget of $200K! because why bother!\n budget = self.budget_allocated\n if budget > 200_000\n # give them a 50/50\n if rand > 0.5\n # estimate the number of college grads needed during the time frame + 30%\n # to consume the budget * 2\n days = ((self.end_date - self.start_date) * 1.3).ceil\n budget_per_day = budget * 2 / days\n student_per_day = 200 * 8 # $200/hour * 8 hours\n students = (budget_per_day / student_per_day).ceil\n self.estimated_cost = students * student_per_day * days\n self.estimate_breakdown = number_with_delimiter(students) + ' resources needed at $200/hour for ' +\n number_with_delimiter(days) + ' days.'\n self.estimated_duration = (self.start_date + days * 7 / 5).strftime(\"%B %-m %Y\")\n else\n self.estimate_breakdown = 'Jay has reviewed your request, and does not believe the requirements are ' +\n 'feasible within the budget and time frames. Please try submitting another request.'\n end\n else\n self.estimate_breakdown = 'Jay has reviewed your request, and the allocated budget is not sufficient to meet ' +\n 'the requirements. Please try submitting another request.'\n end\n self.status = :complete\n self.save\n end\n end", "def print_summary\n puts \"\\n\\nScore : # Instances\\n\" << (\"=\" * 19)\n @summary_totals.each_with_index { |value, index| puts \" %5d:%8d\\n\" % [index, value] unless value.nil? }\n puts \"\\n** End of Report\"\n end", "def all_works\n result = []\n for exp in (happening_expressions+presented_expressions).flatten.uniq\n # result << exp.work\n logger.debug \"CLASS:#{exp.work.class}\"\n result = result + [exp.work]\n end\n \n \n result.flatten.uniq.sort_by{|w|[w.work_title.downcase]}\n\n end", "def phase_one\n\tputs \"Phase One: Pre-Merge\".yellow\n\t8.times do\n\t\tlost_tribe = @borneo.immunity_challenge\n\t\tputs \"Tribe #{lost_tribe.to_s.red} has lost this round. They are voting off a member.\"\n\t\teliminated_contestant = lost_tribe.tribal_council\n\t\tputs \"#{eliminated_contestant.to_s.capitalize.red} was voted off.\"\n\tend\n\t#puts \"Phase one ends. 8 contestants were voted off in this phase, and 12 contestants remain in the game.\"\nend", "def finish\n noth\n end", "def build_results\n CircleCi::Project.recent_builds_branch('salsify', 'dandelion', 'develop')\n end", "def run_best_case\n user = User.find(1)\n timetable = user.timetables[2]\n timetable.subjects = user.subjects.ids.sample(5)\n\n p \">>>>>>> Running Best Case for Population Size\"\n run_for_population_size(timetable)\n # p \">>>>>>> Running Best Case for Generations\"\n # run_for_generations(timetable)\n\n # tp all_runs\n #tp all_runs.map { |x| x[:chromosomes] }\n #p all_runs.map(&:fitness).inject(0, :+) / all_runs.size\n #tp all_runs[0].data.collect {|x| x.subject }\n end", "def index\n @goals = current_user.goals\n \n @goals.each do |g|\n completed_milestone=0\n @milestones=g.milestones \n if(@milestones.count>0)\n @milestones.each do |m|\n if(m.completed)\n completed_milestone=completed_milestone+1\n end\n \n\n end\n g.percentage=(completed_milestone/@milestones.count)*100\n else\n g.percentage=0\n end\n \n end\n\n end", "def running_test_case; end", "def summary\n \"Results: #{results[:critical].size} critical, \" \\\n \"#{results[:warning].size} warning, \" \\\n \"#{results[:unknown].size} unknown, #{results[:ok].size} ok\"\n end", "def summary\n {}\n end", "def build_new_works\n\n return if self.status==:new_only_effort #estimation only, no schedule\n\n work_actual_array=self.task.work_actuals\n\n d1 = Date.last_monday(self.task.start)\n d2 = task.stop\n\n logger.info \" build_works_for_baseline from #{d1} to #{d2}\"\n\n d1.step(d2, 7) do |date|\n self.works.build do |w|\n w.start_date =date\n w.duration =WORK_TIME_FRAME\n w.workhours =Baseline.corresponding_work(work_actual_array, date).nil_or.workhours\n w.description=Baseline.corresponding_work(work_actual_array, date).nil_or.description\n end\n end\n end", "def totalRunsConceded\n if (self.bowlingStats.sum(\"runs\")[self.name.to_s] != nil) then\n self.bowlingStats.sum(\"runs\")[self.name.to_s]\n else\n \"\"\n end\n end", "def get_orcid_works____\n \n\n end", "def print_day date\n @list ||= Array.read TODO\n @done ||= Array.read DONE\n @deleted ||= Array.read DELETED\n\n=begin\n YAML.load_file(RECURRENT).each do |taskstr,dates|\n if dates.include? date.wday #and [email protected]{|t| t[:scheduled] == date and t[:description] == taskstr}.empty?\n task = Task.new(taskstr.split(\" \"))\n task[:scheduled] = date.to_datetime\n @list << task if (@done+@list).select{|t| t.scheduled_at?(date) and t[:description] == task[:description]}.empty?\n end\n end\n @list.save TODO\n=end\n\n not_scheduled = (@list+@done).select{|t| t.day_dur(date) > 0.0 and !t.scheduled_at? date}\n all_stat = Stat.new not_scheduled, date, date#[@list,@done]\n done_stat = Stat.new @done, date, date\n todo_stat = Stat.new @list, date, date\n\n puts yellow(\"#{(date).strftime('%a %d %b %Y')} w#{todo_stat[:work][:planned].to_f.to_datetime}/f#{todo_stat[:not_work][:planned].to_f.to_datetime}/t#{todo_stat[:total][:planned].to_f.to_datetime}\")\n @list.each{|t| @list.print t if t[:scheduled] and t[:scheduled].to_date == date}\n\n if date == Date.today\n puts blue(\" Done: w#{done_stat[:work][:measured].to_f.to_datetime}/f#{done_stat[:not_work][:measured].to_f.to_datetime}/t#{done_stat[:total][:measured].to_f.to_datetime}\")\n @done.each do |t|\n if t[:finished] == date\n print \" \"\n @done.print t\n end\n end\n #puts cyan(\" Not scheduled: w#{all_stat[:work][:measured].to_f.to_datetime}/f#{all_stat[:not_work][:measured].to_f.to_datetime}/t#{all_stat[:total][:measured].to_f.to_datetime}\")\n @list.each do |t|\n unless t.day_dur(date) == 0.0 or t.scheduled_at? date\n print \" \"\n @list.print t\n end\n end\n @done.each do |t|\n unless t.day_dur(date) == 0.0 or t.scheduled_at? date\n print \" \"\n @done.print t\n end\n end\n end\nend", "def resultsB7(eventName, band, worksheet)\n \n puts \"===============================================================================================\"\n puts \"Results of first B7 (#{eventName}):\"\n puts \"-----------------------------------\"\n puts \"totalMemberCount: #{band.totalMemberCount}\"\n puts \"coachesCount: #{band.coachesCount}\"\n puts \"nruCount: #{band.nruCount}\"\n puts \"-----------------------------------\"\n puts \"===============================================================================================\"\nend", "def contest_complete\n contest = pet_contests.where(workflow_state: 'in_arena').last\n apply_experience!(contest)\n end", "def index\n @lessons = current_user.lessons.where(topic_id: params[:topic_id])\n @topics = current_user.topics.where(course_id: params[:course_id])\n @courses = current_user.courses\n\n @completed = {}\n # @last_archive_id = current_user.lesson_responses.last.archive_id\n current_user.lessons.each do |lesson|\n @completed[lesson] = 0\n lesson.lesson_responses.each do |lr|\n if lr.marked_as_complete == true && lr.user_id == current_user.id\n @completed[lesson] += 1\n end\n end\n end\n\n end", "def tasks_progress\n total_done = 0\n total_tasks = 0\n self.stories.each do |story|\n story.issues.each do |issue|\n total_tasks += 1\n total_done += issue.done\n end\n end\n total_tasks > 0 ? total_done / total_tasks : 100\n end", "def summary\n calculate_summary! if summary_calculation_needed?\n suffix =\n if examples.length == 1\n # Single test - be nice and just print the exception message if the test\n # failed. No need to say \"1 failed\".\n examples[0][:message].to_s\n else\n [\n !fails.empty? ? \"#{fails.uniq.length} failed\" : nil,\n !skips.empty? ? \"#{skips.uniq.length} skipped\" : nil,\n ].compact.join(' ')\n end\n\n suffix == '' ? title : title + ' (' + suffix + ')'\n end", "def student_task_completion_stats()\n data = _student_task_completion_data_base()\n\n result = {}\n result[:unit] = _calculate_task_completion_stats(data)\n result[:tutorial] = {}\n result[:grade] = {}\n\n tutorials.each do |t|\n result[:tutorial][t.id] = _calculate_task_completion_stats(data.select{|r| r[:tutorial_id] == t.id})\n end\n\n for i in 0..3 do\n result[:grade][i] = _calculate_task_completion_stats(data.select{|r| r[:grade] == i})\n end\n\n result\n end", "def summarize_results(fn)\n body = \"\"\n results = get_test_results(fn)\n total = results[:error].length + results[:fail].length + results[:pass].length\n total_failed = results[:fail].length + results[:error].length\n\n body << \"Tests Executed: \" + total.to_s + \"\\n\"\n body << \"Passed: \" + results[:pass].length.to_s + \"\\n\"\n body << \"Failed: \" + results[:fail].length.to_s + \"\\n\"\n body << \"Error: \" + results[:error].length.to_s + \"\\n\"\n body << ((results[:pass].length.to_f/total).round(4) * 100).to_s + \"% Passed\" + \"\\n\"\n\n if results[:error].length != 0 || results[:fail].length != 0\n body << \"\\n\"\n body << \"Failed/Errored Tests:\\n\"\n (results[:error].concat(results[:fail])).each do |test|\n body << \" #{test}\\n\"\n end\n end\n \n puts \"-\" * 50\n puts body\n puts \"-\" * 50\n \n summary = {}\n summary[:body] = body\n \n bottom_line = \"#{total_failed}/#{total} failed\"\n summary[:bottom_line] = bottom_line\n \n return summary\n end", "def exercise_119 (number)\n end", "def get_duties_summary(page)\n page.css(WebScraper::JOB_DETAILS_SELECTOR)[WebScraper::JOB_DUTIES_SUM_POS].content.strip\n end", "def initialize(fullname)\n\n @firstrun_score = firstrun(fullname)\n total = @firstrun_score\n \n while total > 9\n if total == 11 or total == 22\n local_sum = total\n break\n else\n local_sum = 0\n total.to_s.split('').each do |digit|\n local_sum += digit.to_i\n end\n end\n total = local_sum\n end\n @final_score = total\n end", "def results(time_taken)\n raise \"Implement this in a sub-class\"\n end", "def hiring\n @number.times do # uses number from roll in firing method\n @people_currently_working << @waiting_list.shift\n end\n puts \"Here is our new list of workers for the next three months.\"\n return @people_currently_working\n end", "def mambo_no_5; end", "def run_list; 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 successful_runs\n return @successful_runs\n end", "def profile_example_summaries()\n \"\"\nend", "def print_student_job_listings jobs\n puts \"Available student jobs: #{jobs.count}\"\n jobs.each_with_index do |info, i|\n puts \"Job listing #{i + 1}\"\n puts 'Title: ' + info[:title]\n puts 'Employer: ' + info[:employer]\n puts 'Pay: ' + info[:pay]\n puts 'Job Duration: ' + info[:duration]\n puts 'Hours: ' + info[:hours]\n puts 'Description: ' + info[:desc]\n puts 'Additional information: ' + info[:link] + \"\\n\\n\"\n end\nend", "def summary_at_exit\n reporter = Speciny::Reporter.new(@description)\n @tests.each do |example, result|\n reporter.print_test_result(example, result)\n end\n end", "def portfolio\n funding_rounds.map{|fr| fr.startup}.uniq\n #binding.pry\n end", "def list_fit_wit_workout(e)\n \"#{e.name} on #{e.date_accomplished}\"\n end", "def statistics; end", "def notify_the_user_that_the_program_has_finished_by_calling_this_long_method_name\n done = rand(13)\n puts \"\\nBoo-yah!\" if done == 0\n puts \"\\nOh-yeah!\" if done == 1\n puts \"\\nYah-hoo!\" if done == 2\n puts \"\\nYeah-yuh!\" if done == 3\n puts \"\\nRock on!\" if done == 4\n puts \"\\n^_^\" if done == 5\n puts \"\\nRadical!\" if done == 6\n puts \"\\nAwesome!\" if done == 7\n puts \"\\nTubular!\" if done == 8\n puts \"\\nYay!\" if done == 9\n puts \"\\nGnarly!\" if done == 10\n puts \"\\nSweet!\" if done == 11\n puts \"\\nGroovy!\" if done == 12\n puts \"--------------------------------\\n\"\n end" ]
[ "0.6162224", "0.6162224", "0.6162224", "0.6162224", "0.6040716", "0.59971285", "0.59166753", "0.58814496", "0.58805496", "0.5797787", "0.56916064", "0.56916064", "0.5656195", "0.56453377", "0.56308144", "0.5592461", "0.5589151", "0.5585511", "0.5538737", "0.5536752", "0.55327314", "0.55216104", "0.5490627", "0.5473618", "0.5473276", "0.5473276", "0.5473276", "0.54706895", "0.54588264", "0.5443151", "0.5433872", "0.5417183", "0.54021543", "0.53983366", "0.5391658", "0.5359871", "0.5352793", "0.5337364", "0.5331235", "0.53133047", "0.53003734", "0.53003734", "0.52938044", "0.52884513", "0.52871567", "0.52851856", "0.5276506", "0.52676344", "0.5262818", "0.5261602", "0.52578473", "0.5252951", "0.52494484", "0.5243397", "0.5242372", "0.52370286", "0.5234945", "0.52296406", "0.52286226", "0.52286226", "0.522729", "0.52229476", "0.5212341", "0.5210236", "0.5207204", "0.52063864", "0.519628", "0.51951", "0.5190155", "0.51851296", "0.5183685", "0.5183189", "0.518131", "0.51782876", "0.5173412", "0.5173205", "0.51676774", "0.5165491", "0.5156789", "0.51562834", "0.51430625", "0.51385874", "0.5137609", "0.51274294", "0.5119925", "0.5118738", "0.51168334", "0.5108331", "0.51043636", "0.5101834", "0.5101595", "0.51008713", "0.51005876", "0.50930417", "0.5091199", "0.50908935", "0.5090063", "0.50893545", "0.5088025", "0.5086275", "0.50861156" ]
0.0
-1
Lots of chaining of methods
def count_plays(year) s = get_shakey["William Shakespeare"] .select { |k, v| v["finished"] == year }.each { |key, val| puts val["title"] }.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chained_call(*methods)\n raise \"Not implemented yet.\"\n end", "def chain\n [self]\n end", "def calls; end", "def calls; end", "def chain_methods(methods)\n methods.inject(nil) do |memo, acc|\n target = memo ? memo : self\n target.respond_to?(acc) ? target.send(acc) : memo\n end\n end", "def methods() end", "def operations; end", "def operations; end", "def wrapper; end", "def wrappers(*args, &block); end", "def method_missing method, *args, &block\n case method.to_s\n when /^of_(.*)$/\n return self.of($1, *args, &block)\n when /^and_(.*)$/\n return self.and($1, *args, &block)\n end\n\n return to_proc.send method, *args, &block if Proc.instance_methods.include? method\n\n super\n end", "def call() end", "def chain(method_name, *args, &block)\r\n @chain = true\r\n send(method_name, *args, &block)\r\n end", "def chain_state\n super\n end", "def two_method(x,y,z)\n\t\tx + y + z\nend", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def method_missing(method_name, *args, &block)\n respond_to?(method_name) ? chain_with(method_name) : super\n end", "def nesting() end", "def call(*) end", "def call(*) end", "def method_one; end", "def returns; end", "def first_part_of_call_chain(node); end", "def first_part_of_call_chain(node); end", "def probers; end", "def alternatives; end", "def anchored; end", "def do_twice(what)\n what.call\n what.call\nend", "def extended(*) end", "def combine_ins(obj); end", "def method_and_value; end", "def and method, *args, &block\n @current = natural method, *args, &block\n @callings.push @current\n return self\n end", "def next() end", "def next() end", "def cops; end", "def cops; end", "def cops; end", "def chain *messages, &guard\n return self if messages.empty? or not(\n (block_given? ? (yield_or_eval(&guard)) : self))\n\n (send_as_function messages.shift).chain(*messages, &guard)\n end", "def first_object(arg1, arg2, arg3)\n \nend", "def of method, *args, &block\n @current = natural method, *args, &block\n @callings.unshift @current\n self\n end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def methods=(_arg0); end", "def chain_methods(object, chain_method, options = {})\n separator = options[:separator] || '.'\n force_method_calls = options[:force_method_calls] || false\n Acs::Ldap.logger.debug \"Acs::Ldap::Mapper chain_method on object '#{object}' with chain '#{chain_method}' separator '#{separator}' force_method_calls '#{force_method_calls}'\"\n methods = chain_method.to_s.split(separator)\n if methods.length > 1\n method = methods.shift.to_sym\n if object.respond_to?(method) || force_method_calls\n child_object = object.send(method)\n return chain_methods(child_object, methods.join(separator), options)\n else\n Acs::Ldap.logger.debug \"Acs::Ldap::Mapper chain_method returns 'nil'\"\n return nil\n end\n else\n if object.respond_to?(methods[0].to_sym) || force_method_calls\n value = object.send(methods[0].to_sym)\n Acs::Ldap.logger.debug \"Acs::Ldap::Mapper chain_method returns '#{value}'\"\n return value\n else\n Acs::Ldap.logger.debug \"Acs::Ldap::Mapper chain_method ended without result, returning 'nil'\"\n return nil\n end\n end\n end", "def meth_three\n\treturn 1, 2, 3\nend", "def chain(params = {}, &block); validation_chain.chain(params, &block); end", "def mathtex(*)\n super\n end", "def helpers; end", "def helpers; end", "def helpers; end", "def compose\n raise NotImplementedError.new\n end", "def operation; end", "def spice; end", "def private; end", "def next!() end", "def transformations; end", "def get_chain call\n if node_type? call, :call, :attrasgn, :safe_call, :safe_attrasgn\n get_chain(call.target) + [call.method]\n elsif call.nil?\n []\n else\n [get_target(call)]\n end\n end", "def first_object(arg1, arg2, arg3)\n arg1 || arg2 || arg3 || nil\nend", "def call1\n call2\n call3\nend", "def my_method(*args)\n # yield()\n # yield(self)\n # yield(\"booyaka\")\n # yield(\"booyaka\", \"come and get it\")\n yield(args)\nend", "def chain(&block)\n commands = Commands.new(mode: :chain)\n commands.instance_eval(&block)\n self.!(commands)\n end", "def pipelined\n yield\n end", "def initialize(*)\n super\n reduce(public, any)\n end", "def method_731(base); end", "def chain(other)\n other.each { |handler| use(handler) }\n self\n end", "def for(operation); end", "def original_result; end", "def helper_method(*methods); end", "def andand(*)\n self\n end", "def method\n expect :call, :attrasgn, :safe_call, :safe_attrasgn, :super, :zsuper, :result\n\n case self.node_type\n when :call, :attrasgn, :safe_call, :safe_attrasgn\n self[2]\n when :super, :zsuper\n :super\n when :result\n self.last\n end\n end", "def method2() end", "def romeo_and_juliet; end", "def subtrair(*args)\n end", "def delegating_method; end", "def chain(str, *commands)\n str = require_string! str\n\n commands.reduce(str) { |memo, command| send(command, memo) }\n end", "def multiple?; end", "def merged_result; end", "def group(*) end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def helper(*args, &block); end", "def calls_by_method_name; end", "def chain *enums\n return enum_for(:chain, *enums) unless block_given?\n [self, *enums].each do |enum|\n enum.each {|*args| yield(*args) }\n end\n nil\n end", "def chain(next_link)\n if next_link.is_a? Maybe\n flatten_result(apply(next_link))\n else\n flatten_result(map(next_link))\n end\n end", "def or a, b\n a.prove { yield }\n b.prove { yield }\n end", "def simplify; self; end", "def results=(_arg0); end", "def results=(_arg0); end", "def result; end" ]
[ "0.6815666", "0.620446", "0.5979253", "0.5979253", "0.5871489", "0.5756164", "0.56570244", "0.56570244", "0.5585134", "0.55830115", "0.5459933", "0.54297495", "0.5356684", "0.53369784", "0.5329626", "0.5321702", "0.5321702", "0.5321702", "0.5321702", "0.5321702", "0.5321702", "0.5321702", "0.5321702", "0.53108263", "0.5305781", "0.5284492", "0.5284492", "0.525757", "0.5246746", "0.5240807", "0.5240807", "0.5233865", "0.5218964", "0.5207552", "0.52029276", "0.52026254", "0.519842", "0.51908696", "0.5188409", "0.51288754", "0.51288754", "0.5112145", "0.5112145", "0.5112145", "0.5105328", "0.5103191", "0.5085103", "0.50693834", "0.50693834", "0.50693834", "0.50693834", "0.5063153", "0.5053969", "0.5053811", "0.5031016", "0.5022424", "0.5021191", "0.5021191", "0.5021191", "0.5020432", "0.5018936", "0.5018072", "0.50135535", "0.5006512", "0.5004639", "0.49956596", "0.4993947", "0.49924672", "0.4979661", "0.49718514", "0.49673423", "0.49560475", "0.49523655", "0.49513814", "0.49474728", "0.49429703", "0.49379587", "0.4937858", "0.49292156", "0.49266055", "0.49244854", "0.49213192", "0.49196646", "0.49102727", "0.49058497", "0.49039817", "0.49000683", "0.4899706", "0.4899706", "0.4899706", "0.4899706", "0.4899706", "0.48973027", "0.48964933", "0.48875245", "0.48874733", "0.48835164", "0.48752487", "0.4873793", "0.4873793", "0.4869505" ]
0.0
-1
Adding variables inside of a string, pretty printing
def print_plays(year_from, year_to) get_shakey["William Shakespeare"] .select { |k, v| year_from <= v["finished"] && year_to >= v["finished"] }.each { |k, v| puts "#{v["title"].ljust(30)} #{v["finished"]}" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formatted_string\n format.dup.tap do |str|\n variables.each {|v| str.gsub!(\"%#{v}\", \"%{#{v}}\") }\n end\n end", "def info\n str = <<INFO\nScenario: #{ name }\nSummary: #{ summary }\nDescription: #{ description_without_summary }\nINFO\n variables.each do |key, value|\n str << \"#{ key }: #{ value.inspect }\\n\"\n end\n str\n end", "def pretty_print\n puts `ruby -r pp -e 'pp(#{@template.inspect})'`\n end", "def pretty_print(pp)\n pp.object_address_group(self) do\n ivs = sorted_instance_variables.map(&:to_s)\n pp.seplist(ivs, proc { pp.text ',' }) do |iv|\n pp.breakable ' '\n pp.group(1) do\n pp.text iv\n pp.text ':'\n pp.breakable\n pp.pp instance_variable_get(iv)\n end\n end\n end\n end", "def report\n <<-STRINGSTRINGSTRING\nName: #{@name}\nAge: #{@age}\nAlive: #{@alive}\nSTRINGSTRINGSTRING\n end", "def showvars(x,y)\n \"x = #{x}\\ny = #{y}\"\nend", "def pretty_print pp\n pp.pp eval(self.asPPString)\n end", "def pretty_print pp\n pp.pp eval(self.asPPString)\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n \n pp nds\n puts nds \nend", "def pretty_print_me\n sio = PP.pp(self, \"\")\n\n # aber bitte ohne die ids und ohne @\n sio.gsub(/0x[^\\s]*/,'').gsub(/@/,'')\n end", "def format\n # first of all, handle extended tags\n strs = reduce_nested_tag do |str, snip|\n start = str.index(snip)\n sub = str[start, snip.size]\n str[start, snip.size] = sub.gsub(extended_regex) do |variable|\n variable = variable[1, variable.size] # remove $\n dispatch(variable)\n end\n str\n end\n \n strs.gsub(variable_regex) do |variable|\n variable = variable[1, variable.size] # remove $\n dispatch(variable)\n end.gsub(shell_regex) do |variable|\n dispatch(variable)\n end\n end", "def generate_string(options = nil)\n if comment\n suffix = \" ##{comment}\\n\"\n else\n suffix = \"\\n\"\n end\n\n [address, name, *aliases].join(' ') << suffix\n end", "def build_var *args\n line = \"#{args[0]}\"\n # bracket [] any additional arguments\n line << \" [#{args[1...args.length].join('] [')}]\" if args.length > 1\n line\n end", "def inspect\n s = ''\n @props.each do |key,val|\n s << sprintf(\"%-20.20s : %-40.40s\\n\", key.to_s, val.inspect)\n end\n s\n end", "def printer(var, str)\n print \"#{str}\" * (2 * var - 1)\n end", "def prettify(str); end", "def cheese_and_crackers(cheese_count, boxes_of_crackers)\n# prints the string below with the variable cheese_count interpolated into it\n puts \"You have #{cheese_count} cheeses!\"\n# prints the string below with the variable boxes_of_crackers interpolated into\n# it\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n# prints the string below\n puts \"Man that's enough for a party!\"\n# prints the string below with a new line at the end\n puts \"Get a blanket.\\n\"\n# ends the method\nend", "def to_s\n \"Variable: #{@name}(t) = '#{@value}'\"\n end", "def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n vars.delete(:@page)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end", "def pretty_to_s\n left_str = child_to_s(:left)\n right_str = child_to_s(:right)\n \"| \" * self.level + \"#{@feature} = #{@value}:\" + left_str + right_str\n end", "def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end", "def pl(*args)\n str0 = \"=== \" + caller.first + \"\\n\"\n\n str_out = args.inject(str0){|strs, obj| strs + obj.pretty_inspect.to_s}\n\n puts str_out\n str_out\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n #binding.pry\n pp nds\nend", "def output_variables\n string = \"\"\n @variables.each { |name, value| string += \"#{name} = #{value}\\n\" }\n string\n end", "def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n data << \"\\n\"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\",\\n#{Thread.current[:formatador].indentation}\")\n end\n end\n data << \"\\n#{Thread.current[:formatador].indentation}>\"\n data\n end", "def yay(name)\n # Interpolate string - performs .to_s on variable name and adds it in\n # the appropriate place in the string\n puts \"#{name} is great!\" \n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\npp 'nds'\nend", "def pretty_print_nds(nds)\n pp nds \n # Change the code below to pretty print the nds with pp\nend", "def pretty\n s = \"\"\n self.fields.each do |f|\n unless (f.name == \"payload\")\n s += \"#{f.name}=#{self.send(f.name)} \"\n end\n end\n s.gsub(/ $/, '')\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\t # Change the code below to pretty print the nds with pp\n\n pp nds\nend", "def to_pretty\r\n\t\t\ta = dup\r\n\t\t\ts = \"\"\r\n\t\t\ta.each_with_index {|i, ind|\r\n\t\t\t\ta[ind].each_with_index {|ii, iind|\r\n\t\t\t\t\ta[ind][iind].each_with_index {|iii, iiind|\r\n\t\t\t\t\t\ts << iii\r\n\t\t\t\t\t\ts << \" &\\n\" unless (iiind == (a[ind][iind].size - 1))\r\n\t\t\t\t\t}\r\n\t\t\t\t\ts << \"\\n| \" unless iind == (a[ind].size - 1)\r\n\t\t\t\t}\r\n\t\t\t\ts << \" ;\\n\\n\" unless ind == (a.size - 1)\r\n\t\t\t}\r\n\t\t\treturn s\r\n\t\tend", "def summary\n summary = \"\n - Name: #{@name}\n - Color: #{@color}\n - Mass (in kg): #{@mass_kg}\n - Distance From Sun (in km): #{@distance_from_sun_km}\n - Fun Fact: #{@fun_facts}\"\n\n #returns summary as string\n return summary\n end", "def pretty_print(pp)\n pp.text \"Frames: #{available_frames.to_a.sort.join(\", \")}\"\n\n pp.breakable\n pp.text \"Needed Transformations:\"\n transforms = each_transformation.map { |tr| [tr.from, tr.to] }.sort\n if !transforms.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(transforms) do |tr|\n pp.text \"%s => %s\" % tr\n end\n end\n end\n\n pp.breakable\n pp.text \"Frame/Port Associations:\"\n associations = each_annotated_port.map { |port, frame| [port.name, frame] }.sort\n if !associations.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(associations) do |portdef|\n pp.text \"data of %s is in frame %s\" % portdef\n end\n end\n end\n\n pp.breakable\n pp.text \"Transform Inputs and Outputs:\"\n ports = each_transform_port.map { |port, transform| [port.name, transform.from, transform.to] }.sort\n if !ports.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(ports) do |portdef|\n pp.text \"%s: %s => %s\" % portdef\n end\n end\n end\n end", "def to_s\n text = \"#{keyword} #{base}\"\n text << \"\\n\" + block.to_s.split(\"\\n\").collect { |line| \" #{line}\" }.join(\"\\n\") if block\n\n text\n end", "def pretty_print_nds(nds)\n pp(nds)\nend", "def pretty_print_nds(nds)\n pp(nds)\nend", "def bp (name, value)\n if name != \"\" \n return \"\\n$bp-#{name} : #{value};\"\n else\n return \"\"\n end\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n nil\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp\nend", "def dump_round_vars(before_str=nil, after_str=nil)\n puts before_str\n puts \"This is prev_round: #{ @@prev_round.to_s }\"\n puts \"This is curr_round: #{ @@curr_round.to_s }\"\n puts \"This is next_round: #{ @@next_round.to_s }\"\n\n FIRST_ROOM_NUM.upto(FIRST_ROOM_NUM + NUM_ROOMS - 1) { |room| \n puts \"Room[#{room}]: #{@@clientList[room]}\"\n }\n puts after_str\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def debug_str(inspect_method = :inspect)\n \"Current Date: #{self.input_date.readable}\\nCurrent Time: #{self.input_time.readable}\\n\\nQuery: #{self.query}\\nStandardized Query: #{self.nlp_query}\\nQuery changed in: #{self.nlp_query.changed_in.inspect}\\n\\nConstructs Found: #{s = \"\\n\"; self.construct_finder.constructs.each{|x| s << x.send(inspect_method) + \"\\n\"}; s}\\n\\n@construct_interpreter: #{self.construct_interpreter.send(inspect_method)}\"\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def write(objects = [])\n return '' if objects.empty?\n str = ''\n vars = objects[0].instance_variables.select! { |v| v != :@i_expect_that_nobody_will_use_this_name }.map { |v| v }\n str << vars.map { |i| i[1..-1] }.join(',')\n str << \"\\n\"\n objects.each_with_index do |obj, obj_indx|\n vars.each_with_index do |var, var_indx|\n val = obj.instance_variable_get(var)\n str << val\n str << ',' if var_indx != vars.size - 1\n end\n str << \"\\n\" if obj_indx != objects.size - 1\n end\n\n str\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def string_conc(dog, cat)\n p \"#{dog} #{cat} around the house.\"\nend", "def to_s; \"<Macro #{@procs.length} #{@variables.to_s}>\"; end", "def pretty_format\n pretty = \"\"\n sorted = @hash.sort_by { |name, arrays| name }\n\n sorted.each { |name, array|\n pretty.concat(name)\n pretty.concat(\": \")\n pretty.concat(\"#{@hash[name].join(\",\")}\\n\")\n\n }\n pretty\n\n ### FILL IN YOUR CODE HERE\n end", "def debug_string\n str = \"\"\n klass.fields.each do |f|\n if f.is_padding?\n str << \"#{f.name}: \\n\"\n else\n str << \"#{f.name}: #{send(f.name.to_sym)}\\n\"\n end\n end\n\n str\n end", "def to_s(options = {})\n options[:quotes] ||= %w({ })\n [\"@#{type}{#{key},\", content(options).gsub(/^/,' '), \"}\\n\"].join(\"\\n\")\n end", "def pretty_print_nds(nds)\n pp nds\nend", "def pretty_print_nds(nds)\n pp nds\nend", "def inspect_pretty(other_people=nil)\n\t\tself.instance_variables.inject(\"\") { | all_vars, var_name |\n\t\t\tval = self.instance_variable_get(var_name)\n\n\t\t\tif !value_empty?(val)\n\t\t\t\t# add supplemental info based on instance variable\n\t\t\t\tsupp_info = ''\n\t\t\t\tif other_people\n\t\t\t\t\tcase var_name.to_s\n\t\t\t\t\twhen '@father_id'\n\t\t\t\t\t\tsupp_info = \"(#{other_people[val].alt_id})\"\n\t\t\t\t\twhen '@mother_id'\n\t\t\t\t\t\tsupp_info = \"(#{other_people[val].alt_id})\"\n\t\t\t\t\twhen '@children_ids'\n\t\t\t\t\t\tchildren_alt_ids = \n\t\t\t\t\t\t\tval.inject([]) { |all, child| \n\t\t\t\t\t\t\t\tall << \"#{other_people[child].alt_id}\" }\n\t\t\t\t\t\tsupp_info = \"(#{children_alt_ids.join(', ')})\"\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tall_vars << \"#{var_name}: #{val} #{supp_info}\\n\"\n\t\t\tend\n\t\t\tall_vars \n\t\t}\n\tend", "def pretty_print_nds(nds)\n pp nds \n # Change the code below to pretty print the nds with pp\n nil\nend", "def pretty_print_nds(nds)\n pp nds\n # Change the code below to pretty print the nds with pp\nend", "def pretty\n \" Size: #{size} Blocks: #{blocks} IO Block: #{blksize} Type: #{rdev}\\n\"\\\n \"Device: #{dev} Inode: #{ino} Links: #{nlink}\\n\"\\\n \" Mode: #{prettymode}\\n\"\\\n \" Uid: #{uid} Gid: #{gid}\\n\"\\\n \"Access: #{atime}\\n\"\\\n \"Modify: #{mtime}\\n\"\\\n \"Change: #{ctime}\\n\"\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n \n nil\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n \n nil\nend", "def prettyPrint\n\t\tputs \"'#{@name}' : #{@ingredient.length} ingredients\"\n\n\t\tfor i in [email protected]\n\t\t\tputs \" #{@ingredient[i].amount} #{@ingredient[i].units} #{@ingredient[i].name}\"\n\t\tend\n\n\t\tif @garnish\n\t\t\tputs \" Garnish with #{@garnish}\"\n\t\tend\n\tend", "def to_ps\n ret = \"#{self.class.name}:\\n\"\n c = 0\n @fields.each_pair do |p|\n field = p[1]\n next if field.nil?\n if field.is_a?(NumField) || field.is_a?(ApduList)|| field.is_a?(VarNumField)\n if field.optfield.nil? || field.optfield.value == 1\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, field.hexstr)\n else\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \"--\")\n end\n c = 0\n else #only for bitfield\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \" \" * c + field.bitstr)\n c += field.length\n end\n end\n return ret\n end", "def pp(indent = \"\")\n \"#{indent}#{@number}\"\n end", "def pretty(object)\n PP.pp(object, out)\n end", "def cheese_and_crackers(cheese_count, boxes_of_crackers)\n# print string and parameter\n puts \"You have #{cheese_count} cheeses!\"\n# print string and parameter\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n# print string\n puts \"Man that's enough for a party!\"\n# print string and start a newline\n puts \"Get a blanket.\\n\"\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n nil\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n nil\nend", "def pretty_print_nds(nds)\npp nds\nend", "def pretty_print_nds(nds)\npp nds\nend", "def pretty_print_nds(nds)\npp nds\nend", "def format\n output = @sum.to_s\n\n if @verbose\n @raw.each do |h|\n @display << \"#{h.keys[0]}:#{h.values[0]} \"\n end\n\n output << \" -- #{@display.strip}\"\n end\n\n output\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with \n return pp\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp(nds)\nend", "def add_pretty_printing!\n normalize!\n real_add_pretty_printing!\n normalize!\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n return nds\nend", "def print_basic_info\n \"Name:#{name}, Occupation:#{occupation}, Sex:#{sex}\"\n end", "def concatenation (blow_dryer_setting, male_first_name)\n puts \"but my friends call me #{blow_dryer_setting} #{male_first_name}\"\nend", "def get_debug_string\n string = \"Object(#{@obj_filename})\\nfaces(#{@face_count}) texture:\\n \\\"#{@texture_file}\\\"\"\n return string\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp' \n pp nds\n nil\nend", "def strings(team1, team2)\n p \"I think the #{team1} are better than the #{team2}.\"\nend", "def assemble\n out = \"\"\n\n if @locals.size > 0\n out << \"var \" + @locals.join(', ') + \";\\n\"\n end\n\n out + @code.join\n end", "def print()\n str = start_date.to_s + \" \" + end_date.to_s + \" \" + comment.to_s\n end", "def pretty_text_pokemon(pokemon_ins)\n puts \"#{pokemon_ins.name.capitalize}\\n\"\n print \"Type: #{pokemon_ins.types_array[0].name.capitalize}\" \n print \"/#{pokemon_ins.types_array[1].name.capitalize}\" if pokemon_ins.types_array[1] \n puts \"\"\n puts \"\\n#{pokemon_ins.pokedex_entry}\"\n puts \"\\nHeight: #{(pokemon_ins.height * 3.937).round(2)} in / #{(pokemon_ins.height * 0.1).round(2)} m\"\n puts \"Weight: #{(pokemon_ins.weight / 4.536).round(1)} lb / #{(pokemon_ins.weight * 0.1).round(2)} kg\"\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\n nil\nend", "def as_one_line_string(r)\n print \"#{r.members} Members\".ljust(15)\n print \" ::: \"\n print \"#{r.name}\"[0..29].ljust(30)\n print \" ::: \"\n print \"#{r.city}, #{r.state}, #{r.country}\"[0..19].ljust(20)\n puts\nend", "def string_resource(resource)\n mystring=\"\\t\" + resource[:type].downcase + '{\"' + resource[:title] + '\":'+\"\\n\"\n resource[:parameters].each_pair do |k,v|\n if v.is_a?(Array)\n indent = \" \" * k.to_s.size\n\n mystring+=\"\\t #{k} => [\\n\"\n v.each do |val|\n mystring+=\"\\t #{indent} #{val},\\n\"\n end\n mystring+=\"\\t #{indent} ]\\n\"\n else\n mystring+=\"\\t #{k} => #{v}\\n\"\n end\n end\n mystring+=\"\\t}\\n\"\nend", "def dump\r\n \"#{@name}\\t##{@first_index}.##{@second_index};\\t// #{to_s}\"\r\n end" ]
[ "0.6988502", "0.6172881", "0.6124512", "0.6100341", "0.6099927", "0.60922194", "0.608978", "0.608978", "0.60632825", "0.6061175", "0.60416603", "0.6027202", "0.6021073", "0.59818727", "0.5979205", "0.59609663", "0.59600043", "0.59533596", "0.59449375", "0.5937485", "0.5916443", "0.590804", "0.58878094", "0.5880553", "0.5876556", "0.58442754", "0.57904696", "0.578567", "0.577608", "0.57558006", "0.5753956", "0.5751898", "0.57383764", "0.57313657", "0.5724277", "0.5724277", "0.57184815", "0.57173043", "0.57160133", "0.5715437", "0.57128066", "0.57128066", "0.5710856", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710813", "0.5710807", "0.57105684", "0.5706603", "0.5701144", "0.5700969", "0.5688356", "0.56794626", "0.56794155", "0.56794155", "0.5673963", "0.567291", "0.5671595", "0.5666691", "0.56478524", "0.56478524", "0.56436884", "0.56417435", "0.5634582", "0.5629408", "0.56248033", "0.5621227", "0.5621227", "0.5619224", "0.5619224", "0.5617649", "0.5617649", "0.5617649", "0.5616837", "0.5616284", "0.5615791", "0.561367", "0.5609727", "0.5608404", "0.5599795", "0.5599661", "0.55988747", "0.55976695", "0.5588579", "0.558671", "0.5586457", "0.5584045", "0.55752623", "0.556912", "0.55662096" ]
0.0
-1
Adding variables inside of a string, pretty printing, and changing the way it prints
def print_plays(year_from, year_to) get_shakey["William Shakespeare"] .select { |k, v| year_from <= v["finished"] && year_to >= v["finished"] }.each { |k, v| puts "#{v["finished"]} -> #{v["title"]}" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formatted_string\n format.dup.tap do |str|\n variables.each {|v| str.gsub!(\"%#{v}\", \"%{#{v}}\") }\n end\n end", "def pretty_print pp\n pp.pp eval(self.asPPString)\n end", "def pretty_print pp\n pp.pp eval(self.asPPString)\n end", "def pretty_print\n puts `ruby -r pp -e 'pp(#{@template.inspect})'`\n end", "def pretty_print(pp)\n pp.object_address_group(self) do\n ivs = sorted_instance_variables.map(&:to_s)\n pp.seplist(ivs, proc { pp.text ',' }) do |iv|\n pp.breakable ' '\n pp.group(1) do\n pp.text iv\n pp.text ':'\n pp.breakable\n pp.pp instance_variable_get(iv)\n end\n end\n end\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n \n pp nds\n puts nds \nend", "def pretty_print_me\n sio = PP.pp(self, \"\")\n\n # aber bitte ohne die ids und ohne @\n sio.gsub(/0x[^\\s]*/,'').gsub(/@/,'')\n end", "def printer(var, str)\n print \"#{str}\" * (2 * var - 1)\n end", "def pl(*args)\n str0 = \"=== \" + caller.first + \"\\n\"\n\n str_out = args.inject(str0){|strs, obj| strs + obj.pretty_inspect.to_s}\n\n puts str_out\n str_out\nend", "def info\n str = <<INFO\nScenario: #{ name }\nSummary: #{ summary }\nDescription: #{ description_without_summary }\nINFO\n variables.each do |key, value|\n str << \"#{ key }: #{ value.inspect }\\n\"\n end\n str\n end", "def prettify(str); end", "def cheese_and_crackers(cheese_count, boxes_of_crackers)\n# prints the string below with the variable cheese_count interpolated into it\n puts \"You have #{cheese_count} cheeses!\"\n# prints the string below with the variable boxes_of_crackers interpolated into\n# it\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n# prints the string below\n puts \"Man that's enough for a party!\"\n# prints the string below with a new line at the end\n puts \"Get a blanket.\\n\"\n# ends the method\nend", "def format\n # first of all, handle extended tags\n strs = reduce_nested_tag do |str, snip|\n start = str.index(snip)\n sub = str[start, snip.size]\n str[start, snip.size] = sub.gsub(extended_regex) do |variable|\n variable = variable[1, variable.size] # remove $\n dispatch(variable)\n end\n str\n end\n \n strs.gsub(variable_regex) do |variable|\n variable = variable[1, variable.size] # remove $\n dispatch(variable)\n end.gsub(shell_regex) do |variable|\n dispatch(variable)\n end\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n #binding.pry\n pp nds\nend", "def pretty_print(pp)\n pp.text \"Frames: #{available_frames.to_a.sort.join(\", \")}\"\n\n pp.breakable\n pp.text \"Needed Transformations:\"\n transforms = each_transformation.map { |tr| [tr.from, tr.to] }.sort\n if !transforms.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(transforms) do |tr|\n pp.text \"%s => %s\" % tr\n end\n end\n end\n\n pp.breakable\n pp.text \"Frame/Port Associations:\"\n associations = each_annotated_port.map { |port, frame| [port.name, frame] }.sort\n if !associations.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(associations) do |portdef|\n pp.text \"data of %s is in frame %s\" % portdef\n end\n end\n end\n\n pp.breakable\n pp.text \"Transform Inputs and Outputs:\"\n ports = each_transform_port.map { |port, transform| [port.name, transform.from, transform.to] }.sort\n if !ports.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(ports) do |portdef|\n pp.text \"%s: %s => %s\" % portdef\n end\n end\n end\n end", "def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n vars.delete(:@page)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end", "def inspect\n s = ''\n @props.each do |key,val|\n s << sprintf(\"%-20.20s : %-40.40s\\n\", key.to_s, val.inspect)\n end\n s\n end", "def pretty_to_s\n left_str = child_to_s(:left)\n right_str = child_to_s(:right)\n \"| \" * self.level + \"#{@feature} = #{@value}:\" + left_str + right_str\n end", "def showvars(x,y)\n \"x = #{x}\\ny = #{y}\"\nend", "def report\n <<-STRINGSTRINGSTRING\nName: #{@name}\nAge: #{@age}\nAlive: #{@alive}\nSTRINGSTRINGSTRING\n end", "def debug_str(inspect_method = :inspect)\n \"Current Date: #{self.input_date.readable}\\nCurrent Time: #{self.input_time.readable}\\n\\nQuery: #{self.query}\\nStandardized Query: #{self.nlp_query}\\nQuery changed in: #{self.nlp_query.changed_in.inspect}\\n\\nConstructs Found: #{s = \"\\n\"; self.construct_finder.constructs.each{|x| s << x.send(inspect_method) + \"\\n\"}; s}\\n\\n@construct_interpreter: #{self.construct_interpreter.send(inspect_method)}\"\n end", "def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end", "def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n data << \"\\n\"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\",\\n#{Thread.current[:formatador].indentation}\")\n end\n end\n data << \"\\n#{Thread.current[:formatador].indentation}>\"\n data\n end", "def yay(name)\n # Interpolate string - performs .to_s on variable name and adds it in\n # the appropriate place in the string\n puts \"#{name} is great!\" \n end", "def generate_string(options = nil)\n if comment\n suffix = \" ##{comment}\\n\"\n else\n suffix = \"\\n\"\n end\n\n [address, name, *aliases].join(' ') << suffix\n end", "def dump_round_vars(before_str=nil, after_str=nil)\n puts before_str\n puts \"This is prev_round: #{ @@prev_round.to_s }\"\n puts \"This is curr_round: #{ @@curr_round.to_s }\"\n puts \"This is next_round: #{ @@next_round.to_s }\"\n\n FIRST_ROOM_NUM.upto(FIRST_ROOM_NUM + NUM_ROOMS - 1) { |room| \n puts \"Room[#{room}]: #{@@clientList[room]}\"\n }\n puts after_str\n end", "def add_pretty_printing!\n normalize!\n real_add_pretty_printing!\n normalize!\n end", "def output_variables\n string = \"\"\n @variables.each { |name, value| string += \"#{name} = #{value}\\n\" }\n string\n end", "def pretty_print_nds(nds)\n pp nds \n # Change the code below to pretty print the nds with pp\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\npp 'nds'\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\t # Change the code below to pretty print the nds with pp\n\n pp nds\nend", "def to_s\n \"Variable: #{@name}(t) = '#{@value}'\"\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n nil\nend", "def to_pretty\r\n\t\t\ta = dup\r\n\t\t\ts = \"\"\r\n\t\t\ta.each_with_index {|i, ind|\r\n\t\t\t\ta[ind].each_with_index {|ii, iind|\r\n\t\t\t\t\ta[ind][iind].each_with_index {|iii, iiind|\r\n\t\t\t\t\t\ts << iii\r\n\t\t\t\t\t\ts << \" &\\n\" unless (iiind == (a[ind][iind].size - 1))\r\n\t\t\t\t\t}\r\n\t\t\t\t\ts << \"\\n| \" unless iind == (a[ind].size - 1)\r\n\t\t\t\t}\r\n\t\t\t\ts << \" ;\\n\\n\" unless ind == (a.size - 1)\r\n\t\t\t}\r\n\t\t\treturn s\r\n\t\tend", "def pretty_text_pokemon(pokemon_ins)\n puts \"#{pokemon_ins.name.capitalize}\\n\"\n print \"Type: #{pokemon_ins.types_array[0].name.capitalize}\" \n print \"/#{pokemon_ins.types_array[1].name.capitalize}\" if pokemon_ins.types_array[1] \n puts \"\"\n puts \"\\n#{pokemon_ins.pokedex_entry}\"\n puts \"\\nHeight: #{(pokemon_ins.height * 3.937).round(2)} in / #{(pokemon_ins.height * 0.1).round(2)} m\"\n puts \"Weight: #{(pokemon_ins.weight / 4.536).round(1)} lb / #{(pokemon_ins.weight * 0.1).round(2)} kg\"\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp\nend", "def pretty_format\n pretty = \"\"\n sorted = @hash.sort_by { |name, arrays| name }\n\n sorted.each { |name, array|\n pretty.concat(name)\n pretty.concat(\": \")\n pretty.concat(\"#{@hash[name].join(\",\")}\\n\")\n\n }\n pretty\n\n ### FILL IN YOUR CODE HERE\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend", "def pretty\n s = \"\"\n self.fields.each do |f|\n unless (f.name == \"payload\")\n s += \"#{f.name}=#{self.send(f.name)} \"\n end\n end\n s.gsub(/ $/, '')\n end", "def debug_string\n str = \"\"\n klass.fields.each do |f|\n if f.is_padding?\n str << \"#{f.name}: \\n\"\n else\n str << \"#{f.name}: #{send(f.name.to_sym)}\\n\"\n end\n end\n\n str\n end", "def inspect_pretty(other_people=nil)\n\t\tself.instance_variables.inject(\"\") { | all_vars, var_name |\n\t\t\tval = self.instance_variable_get(var_name)\n\n\t\t\tif !value_empty?(val)\n\t\t\t\t# add supplemental info based on instance variable\n\t\t\t\tsupp_info = ''\n\t\t\t\tif other_people\n\t\t\t\t\tcase var_name.to_s\n\t\t\t\t\twhen '@father_id'\n\t\t\t\t\t\tsupp_info = \"(#{other_people[val].alt_id})\"\n\t\t\t\t\twhen '@mother_id'\n\t\t\t\t\t\tsupp_info = \"(#{other_people[val].alt_id})\"\n\t\t\t\t\twhen '@children_ids'\n\t\t\t\t\t\tchildren_alt_ids = \n\t\t\t\t\t\t\tval.inject([]) { |all, child| \n\t\t\t\t\t\t\t\tall << \"#{other_people[child].alt_id}\" }\n\t\t\t\t\t\tsupp_info = \"(#{children_alt_ids.join(', ')})\"\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tall_vars << \"#{var_name}: #{val} #{supp_info}\\n\"\n\t\t\tend\n\t\t\tall_vars \n\t\t}\n\tend", "def pretty_print_nds(nds)\n pp(nds)\nend", "def pretty_print_nds(nds)\n pp(nds)\nend", "def print()\n printf \"\\nAuthor ID: %d affiliation: %s affiliation short: %s country: %s\\n\", self.article_author_id, self.name, self.short_name, self.country\n printf \"\\nAddress: %s, %s, %s, %s, %s\\n\", self.add_01, self.add_02, self.add_03,self.add_04, self.add_05\n end", "def pretty_print_nds(nds)\n pp nds \n # Change the code below to pretty print the nds with pp\n nil\nend", "def cheese_and_crackers(cheese_count, boxes_of_crackers)\n# print string and parameter\n puts \"You have #{cheese_count} cheeses!\"\n# print string and parameter\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n# print string\n puts \"Man that's enough for a party!\"\n# print string and start a newline\n puts \"Get a blanket.\\n\"\nend", "def pretty_print_nds(nds)\n pp nds\n # Change the code below to pretty print the nds with pp\nend", "def print(params)\n raise \"No :service or :services argument given\" unless params.has_key?(:service) || params.has_key?(:services)\n services = arrayify(params[:services]) | arrayify(params[:service])\n\n result = \"\"\n services.each do |service|\n result += sprintf(\"%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\\n\",\n format_field(service.host),\n format_field(service.config_path),\n format_field(service.status),\n format_field(service.build),\n format_field(service.core_type),\n format_field(service.machine),\n format_field(service.ip),\n format_field(service.agent_status))\n end\n result\n end", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n \n nil\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n \n nil\nend", "def string_conc(dog, cat)\n p \"#{dog} #{cat} around the house.\"\nend", "def write(objects = [])\n return '' if objects.empty?\n str = ''\n vars = objects[0].instance_variables.select! { |v| v != :@i_expect_that_nobody_will_use_this_name }.map { |v| v }\n str << vars.map { |i| i[1..-1] }.join(',')\n str << \"\\n\"\n objects.each_with_index do |obj, obj_indx|\n vars.each_with_index do |var, var_indx|\n val = obj.instance_variable_get(var)\n str << val\n str << ',' if var_indx != vars.size - 1\n end\n str << \"\\n\" if obj_indx != objects.size - 1\n end\n\n str\n end", "def pretty_print\n @word_display.each do |letter|\n print \"#{letter} \"\n end\n puts \"\"\n end", "def build_var *args\n line = \"#{args[0]}\"\n # bracket [] any additional arguments\n line << \" [#{args[1...args.length].join('] [')}]\" if args.length > 1\n line\n end", "def pretty(object)\n PP.pp(object, out)\n end", "def prettyPrint\n\t\tputs \"'#{@name}' : #{@ingredient.length} ingredients\"\n\n\t\tfor i in [email protected]\n\t\t\tputs \" #{@ingredient[i].amount} #{@ingredient[i].units} #{@ingredient[i].name}\"\n\t\tend\n\n\t\tif @garnish\n\t\t\tputs \" Garnish with #{@garnish}\"\n\t\tend\n\tend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n nil\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n nil\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n return nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp(nds)\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\nend", "def pretty_print_nds(nds)\n pp nds\nend", "def pretty_print_nds(nds)\n pp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with \n return pp\nend", "def to_ps\n ret = \"#{self.class.name}:\\n\"\n c = 0\n @fields.each_pair do |p|\n field = p[1]\n next if field.nil?\n if field.is_a?(NumField) || field.is_a?(ApduList)|| field.is_a?(VarNumField)\n if field.optfield.nil? || field.optfield.value == 1\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, field.hexstr)\n else\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \"--\")\n end\n c = 0\n else #only for bitfield\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \" \" * c + field.bitstr)\n c += field.length\n end\n end\n return ret\n end", "def print_out(distance, prior, decided)\n puts \"Next Round: \"\n puts sprintf \"\\t %-10s %s\", \"Dist:\", \" #{distance}\"\n puts sprintf \"\\t %-10s %s\", \"Prior:\", \" #{prior}\"\n puts sprintf \"\\t %-10s %s\", \"Decided:\", \" #{decided}\"\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp' \n pp nds\n nil\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\n nil\nend", "def print()\n str = start_date.to_s + \" \" + end_date.to_s + \" \" + comment.to_s\n end", "def prettyPrint\n\t\tputs \"'#{@name}' : #{@ingredient.length} ingredients\"\n\n\t\t\t# The 0..X operator generates a list that contains\n\t\t\t# integers starting at 0 and going up to and including\n\t\t\t# \"X\", so\n\t\t\t# 0..4\n\t\t\t# produces the list\n\t\t\t# [ 0, 1, 2, 3, 4 ]\n\t\t\t#\n\t\t\t# The \"for loop\" here therefore will run as many times\n\t\t\t# as the \"@ingredient\" list has items, and \"i\" will\n\t\t\t# take on the values 0, 1, 2... in turn\n\t\t\t#\n\t\tfor i in [email protected]\n\t\t\tputs \" #{@ingredient[i].amount} #{@ingredient[i].units} #{@ingredient[i].name}\"\n\t\tend\n\n\t\t\t# if we have a garnish, then print it\n\t\tif @garnish\n\t\t\tputs \" Garnish with #{@garnish}\"\n\t\tend\n\tend", "def format\n output = @sum.to_s\n\n if @verbose\n @raw.each do |h|\n @display << \"#{h.keys[0]}:#{h.values[0]} \"\n end\n\n output << \" -- #{@display.strip}\"\n end\n\n output\n end", "def print_basic_info\n \"Name:#{name}, Occupation:#{occupation}, Sex:#{sex}\"\n end", "def pp(indent = \"\")\n \"#{indent}#{@number}\"\n end", "def cheese_and_crackers(cheese_count, boxes_of_crackers)\n # print a string that interpolates the cheese_count parameter\n puts \"You have #{cheese_count} cheeses!\"\n # print a string that interpolates the boxes_of_crackers parameter\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n # print a string\n puts \"Man that's enough for a party!\"\n # print a string\n puts \"Get a balnket.\\n\"\nend", "def pretty_print_nds(nds)\npp nds\nend", "def pretty_print_nds(nds)\npp nds\nend", "def pretty_print_nds(nds)\npp nds\nend", "def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n nil\n pp nds\nend", "def pretty\n \" Size: #{size} Blocks: #{blocks} IO Block: #{blksize} Type: #{rdev}\\n\"\\\n \"Device: #{dev} Inode: #{ino} Links: #{nlink}\\n\"\\\n \" Mode: #{prettymode}\\n\"\\\n \" Uid: #{uid} Gid: #{gid}\\n\"\\\n \"Access: #{atime}\\n\"\\\n \"Modify: #{mtime}\\n\"\\\n \"Change: #{ctime}\\n\"\n end", "def to_s\r\n pretty_output\r\n end", "def printProps(id , name = \"foo\", age = 10, wage = 100.0, active = true)\n puts \"<<printProps>>\"\n puts <<EOF\nid = #{id}\nname = #{name}\nage = #{age}\nwage = #{wage}\nactive = #{active}\n\nEOF\nend", "def to_s()\n prettify()\n end", "def dump\r\n \"#{@name}\\t##{@first_index}.##{@second_index};\\t// #{to_s}\"\r\n end", "def to_s; \"<Macro #{@procs.length} #{@variables.to_s}>\"; end" ]
[ "0.69246227", "0.6361746", "0.6361746", "0.6273618", "0.6260569", "0.6200668", "0.61361897", "0.6125556", "0.61111057", "0.6083935", "0.6042953", "0.60264343", "0.601633", "0.60158217", "0.5995767", "0.598452", "0.59639335", "0.5956553", "0.595441", "0.5952054", "0.5952018", "0.5924774", "0.591113", "0.59045064", "0.5900081", "0.58950734", "0.58915746", "0.58880794", "0.5879678", "0.58708787", "0.58691025", "0.58410186", "0.5831679", "0.58279574", "0.58243537", "0.5811409", "0.58100766", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.5806638", "0.580633", "0.5803638", "0.5803638", "0.57992387", "0.57990843", "0.5792084", "0.5791114", "0.5791114", "0.57875854", "0.57747436", "0.5774733", "0.5769464", "0.5768239", "0.5761482", "0.5761482", "0.57587165", "0.5755664", "0.57493037", "0.5746563", "0.57459897", "0.57378876", "0.57316285", "0.57316285", "0.57315147", "0.5726605", "0.5726601", "0.5726601", "0.5725646", "0.5725646", "0.5721306", "0.57130283", "0.5711919", "0.57116383", "0.5700316", "0.56735975", "0.56667113", "0.5665022", "0.56584656", "0.5657754", "0.5655504", "0.5647352", "0.5647352", "0.5647352", "0.56395316", "0.5632894", "0.56290054", "0.5614243", "0.56070673", "0.5606069", "0.55982673" ]
0.0
-1
some good control expression docs
def hungry?(time_of_day_in_hours) if time_of_day_in_hours < 12 puts "Me not hungry." false else puts "Me hungry." true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expression; end", "def expressions; end", "def allow_in_control=(_arg0); end", "def triple_expression?; false; end", "def conditions; end", "def conditions; end", "def expression\n super\n end", "def control?(exp)\n exp[0] == :slim && exp[1] == :control\n end", "def modifier; end", "def literal_validation; end", "def literal_validation; end", "def non_complex_expression?(condition); end", "def rule; end", "def rule; end", "def rule; end", "def lex_en_expr_cmdarg; end", "def lex_en_expr_cmdarg; end", "def lex_en_expr_cmdarg; end", "def expression_operator()\n\n\n\n # \n if (TOKENS[look_ahead(1)] >= 25 && TOKENS[look_ahead(1)] <= 26) || look_ahead(1) == :ECOMMERCIAL || look_ahead(1) == :EQUAL || (TOKENS[look_ahead(1)] >= 35 && TOKENS[look_ahead(1)] <= 46)\n match()\n else\n raise \"Expected set\"\n end\n\n\n\n end", "def expr()\n #This is a stub, used for indexing\n end", "def qe_modifiers\n end", "def cond; end", "def cond; end", "def cond; end", "def operations; end", "def operations; end", "def parameter_rule?; end", "def compile_vexpression\n out = expect :number, :identifier,\n :istring, :lparen,\n :sstring, :operator,\n :keyword,\n :regex,\n :newline,\n :istring_begin,\n :iheredoc_begin,\n :plus, :minus,\n :lbrace => :object,\n :lbrack => :array,\n :arrow => :function,\n [\n :preunop, :unop\n ] => :unop,\n [\n :heredoc_ref, :iheredoc_ref\n ] => :href,\n [\n :heredoc, :iheredoc\n ] => :heredoc\n\n value_expect(out)\n end", "def subsequent_rules(*args); end", "def subsequent_rules(*args); end", "def op; end", "def operator; end", "def _lex_actions; end", "def condition; end", "def actual_flow_control\n super\n end", "def conditions()\n {:+ => :plus, :- => :minus, :/ => :divide, :* => :times}\n end", "def parse_condition(exp); end", "def operation; end", "def ctrlChecked _args\n \"ctrlChecked _args;\" \n end", "def control\n @control\n end", "def handle_control(name, val, src, current_pos)\n\n case name\n when :deflang\n puts \"Found default language #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n when :outlinelevel\n puts \"Found #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n @parser_context[:outlinelevel] = val\n when :par\n #puts \"Found new para #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n when :pard\n #puts \"Found default para #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n @parser_context[:paragraph_style] = 0\n @parser_context[:character_style] = -1\n when :s\n #puts \"Found new para style #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n @parser_context[:paragraph_style] = val\n when :cs\n #puts \"Found new char style #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n @parser_context[:character_style] = val\n when *[:ds,:ts,:tsrowd] then\n #puts \"Found #{name.inspect} with #{val} at #{current_pos}\" if @@DEBUG_OUTPUT\n when :listtext\n #puts \"Found list text #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n #@parser_context[:listtext] = true\n when :ilvl\n #puts \"Found list level #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n #@parser_context[:listlevel] = val\n when :intbl\n #puts \"Found table #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n #@parser_context[:table] = true\n when :footnote\n puts \"Found #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n current_pos = parse_footnote(src, current_pos)\n @parser_context[:footnote] = true\n when :hex\n #puts \"Found hex #{name.inspect} with #{val} at #{current_pos}.\" if @@DEBUG_OUTPUT\n end\n current_pos = super(name, val, src, current_pos)\n return current_pos\n end", "def compile_expression\n write_tag '<expression>'\n compile_term\n compile_term while match('+', '-', '<', '/', '=', '>', '&', '|', '*')\n write_tag '</expression>'\n end", "def lex_en_expr_cmdarg=(_arg0); end", "def lex_en_expr_cmdarg=(_arg0); end", "def lex_en_expr_cmdarg=(_arg0); end", "def pre_match() end", "def lex_en_expr_value; end", "def lex_en_expr_value; end", "def lex_en_expr_value; end", "def template() false end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def complete_expression?(str); end", "def start_re=(_); end", "def expression=(_arg0); end", "def maybe_directives?; end", "def lex_en_expr_beg; end", "def lex_en_expr_beg; end", "def lex_en_expr_beg; end", "def expression?\n !@no_expression\n end", "def restriction \n end", "def terms_conditions\r\n\t@title = \"Terms & Conditions\"\r\n end", "def ctrlText _args\n \"ctrlText _args;\" \n end", "def yyerrok; end", "def yyerrok; end", "def allow_matcher; end", "def or_e\n end", "def controlNull \n \"controlNull\" \n end", "def valid?(_) true end", "def valid?(_) true end", "def validator_description\n\t\t\treturn \"a value matching the pattern %p\" % [ self.pattern ]\n\t\tend", "def expr\n or_expr\n end", "def lex_en_expr_variable; end", "def lex_en_expr_variable; end", "def lex_en_expr_variable; end", "def matcher; end", "def matcher; end", "def valid; end", "def expression\n if is_addop @look\n emit_ln 'CLR D0'\n else\n term\n end\n while is_addop @look\n emit_ln 'MOVE D0, -(SP)' \n case @look\n when '+': add\n when '-': subtract\n else expected('Addop')\n end\n end\nend", "def validate\n check_syntax\n end", "def validation; end", "def validation; end", "def oper\n return @oper\n end", "def rule(expression, &block); end", "def rule(expression, &block); end", "def control\n self.genome =~ /.*phi[xX].*/ ? \"Y\" : \"N\"\n end", "def control!\n @control = true\n end", "def test_condition(i)\n case self.rc_query\n when (:contains || :is)\n #i =~ #self.rc_regex\n when :does_not_contain\n #i =~ #self.rc_regex\n when :is_greater_than\n i > self.rc_integer_value\n when :is_less_than\n i < self.rc_integer_value \n when :equals\n i == self.rc_integer_value\n else\n false \n end\n end", "def valid_before=(_arg0); end", "def expect_pattern(state)\n case state\n when :outer then %r{(?:^\\s*|<)%[~=!_#%]?|<l10n>}\n when /\\Acode_line/ then %r{\\n|\\Z}\n when /\\Acode_(?:span|print|template|visitor|comment)/ then %r{[-%]?%>}\n when :l10n then %r{<\\/l10n>}\n end\n end", "def allowed?; true end", "def doc!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 97 )\n\n type = DOC\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 887:5: '`' (~ ( '`' | '\\\\\\\\' | '#' ) | '\\\\\\\\' . | {...}? => INTERPOLATION | '#' )* '`'\n match( 0x60 )\n # at line 888:5: (~ ( '`' | '\\\\\\\\' | '#' ) | '\\\\\\\\' . | {...}? => INTERPOLATION | '#' )*\n while true # decision 13\n alt_13 = 5\n alt_13 = @dfa13.predict( @input )\n case alt_13\n when 1\n # at line 888:7: ~ ( '`' | '\\\\\\\\' | '#' )\n if @input.peek( 1 ).between?( 0x0, 0x22 ) || @input.peek( 1 ).between?( 0x24, 0x5b ) || @input.peek( 1 ).between?( 0x5d, 0x5f ) || @input.peek( 1 ).between?( 0x61, 0xff )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n when 2\n # at line 889:7: '\\\\\\\\' .\n match( 0x5c )\n match_any\n\n when 3\n # at line 890:7: {...}? => INTERPOLATION\n raise FailedPredicate( \"DOC\", \" at_interpolation? \" ) unless ( ( at_interpolation? ) )\n interpolation!\n # --> action\n type = DDOC \n # <-- action\n\n when 4\n # at line 891:7: '#'\n match( 0x23 )\n\n else\n break # out of loop for decision 13\n end\n end # loop for decision 13\n match( 0x60 )\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__, 97 )\n\n end", "def parse_expression\r\n parse_term\r\n while(@cur_token.kind == :OR)\r\n accept_it\r\n parse_term\r\n end\r\n end", "def verify_markup_options; end", "def lex_en_expr_labelarg; end", "def lex_en_expr_labelarg; end" ]
[ "0.6579489", "0.6452731", "0.6260368", "0.60075295", "0.59925455", "0.59925455", "0.59374917", "0.5932704", "0.579051", "0.57368916", "0.57368916", "0.5693686", "0.5630768", "0.5630768", "0.5630768", "0.5600261", "0.5600261", "0.5600261", "0.5563613", "0.5550398", "0.55316633", "0.55077296", "0.55077296", "0.55077296", "0.5507712", "0.5507712", "0.54406184", "0.54210305", "0.5405683", "0.5405683", "0.5400153", "0.5384054", "0.53800166", "0.53600615", "0.5351416", "0.53370047", "0.5328254", "0.53236973", "0.53188974", "0.5287133", "0.52838564", "0.5273338", "0.5267852", "0.5267852", "0.5267852", "0.52638805", "0.5257609", "0.5257609", "0.5257609", "0.52566063", "0.52557456", "0.52557456", "0.52557456", "0.52557456", "0.52557456", "0.52557456", "0.52557456", "0.5253359", "0.5245849", "0.52423865", "0.5224743", "0.5205566", "0.5205566", "0.5205566", "0.51923144", "0.5189724", "0.5184797", "0.51802194", "0.51778764", "0.51778764", "0.5166464", "0.516336", "0.51532906", "0.5151589", "0.5151589", "0.51505303", "0.51501626", "0.5131549", "0.5131549", "0.5131549", "0.51294655", "0.51294655", "0.51252025", "0.5123956", "0.511731", "0.50974786", "0.50974786", "0.5097327", "0.50909543", "0.50909543", "0.5090807", "0.50888985", "0.50821984", "0.5080682", "0.50804836", "0.50802785", "0.50783736", "0.5076806", "0.5073823", "0.5067115", "0.5067115" ]
0.0
-1
Returns true if the authentication was successful and returns false otherwise. cs.authok? => true
def authok? @connection.authok end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authok?\n @authok\n end", "def authok?\n @authok\n end", "def authok?\n @authok\n end", "def authok?\n @authok\n end", "def authok?\n @connection.authok\n end", "def authentication_successful?\n current_user.present?\n end", "def authentication_successful?\n @user.present?\n end", "def successfully_authenticated\n unless self.ok == true\n self.errors.add(:ok, \"Response must include ok true!\")\n end\n end", "def auth_ok?(username, password)\n username_present?(username) && password_ok?(username, password)\n end", "def api_auth_success?\n token, token_options = get_token\n\n resource = nil\n resource = User.find_by_authentication_token(token) unless token.blank?\n\n comparison = valid_token_login?(resource, token)\n\n # token, resource, and comparison must all be valid\n !token.blank? && !resource.blank? && comparison\n end", "def test_login\n if @auth!='' then\n result = do_request(json_obj('user.checkauth',\n {'sessionid'=>@auth}))\n if !result['result'] then\n @auth=''\n return false #auth hash bad\n end\n return true #auth hash good\n else\n return false\n end\n end", "def authentication_response_status\n authenticate_user.success? ? :ok : :unauthorized\n end", "def auth?\n true\n end", "def authenticated?\n !!(session['cas'] && session['cas']['user'])\n end", "def authenticated?\n false if @password.nil?\n @client.authenticated?(@username, @password)\n end", "def authentication_ok?(token_verify_path)\n return false unless token\n return false unless token['access_token']\n return false unless token_verify_path\n\n final_path = token_verify_path.gsub(/\\:access\\_token/, token['access_token'])\n debug { \"Requesting user info from #{final_path}\" }\n request(path: final_path)\n true\n rescue => ex\n error { \"Authentication verification exception\" }\n error { ex }\n false\n end", "def success?\n self.secure? && self.status == \"1\"\n end", "def auth?\n false\n end", "def verify_credentials\n if auth_supplied?\n response = get \"account/verify_credentials\"\n response.ok? ? response : false\n else\n false\n end\n end", "def authenticate?( user, salt, auth )\n return auth == calculate_auth_string( salt, user )\n end", "def authenticated?\n true\n end", "def authenticate\n self.get && true\n end", "def test_authentication\n status = false\n\n Net::HTTP.start(\"#{@subdomain}.#{@options[:host]}\", 80) do |http|\n req = Net::HTTP::Get.new(@options[:pathname])\n\n if authentication_set?\n req.ntlm_auth(@username, @options[:domain], @password)\n end\n\n response = http.request(req)\n\n if response.code.to_i.between?(200,399)\n status = true\n else\n status = false\n end\n end\n\n return status\n end", "def authentication_succeed(oidresp)\n end", "def authenticated?\n session['cas'] && session['cas']['user']\n end", "def authenticated?\n\t\treturn @authenticated ? true : false\n\tend", "def authenticate\n begin \n # TODO No data required to authenticate, send a nil string? hacky\n # TODO should retry if a http connection failed\n return @authenticated if @authenticated\n authenticated = call_remote(:authenticate, \"\")\n @authenticated = authenticated =~ /true/\n rescue \n @authenticated = false\n ensure\n return @authenticated\n end\n end", "def authenticated?\n authentication.authenticated?\n end", "def valid_http_auth?\n controller.authenticate_with_http_basic do |login, password|\n if !login.blank? && !password.blank?\n send(\"#{login_field}=\", login)\n send(\"#{password_field}=\", password)\n return valid?\n end\n end\n \n false\n end", "def authenticated?\n false\n end", "def authenticated?\n @auth_token =~ /^.*$/\n end", "def status_pass?()\n return true if (@status == TAC_PLUS_AUTHEN_STATUS_PASS)\n return false\n end", "def authenticate_user?\n authenticate_customer == \"200 OK\"\n end", "def check_authn\n response = self.class.head @endpoint\n\n return true if response.success?\n\n if response.code == 401 && response.headers[\"www-authenticate\"]\n if response.headers[\"www-authenticate\"].start_with? \"Keystone\"\n keystone_uri = /^Keystone uri='(.+)'$/.match(response.headers[\"www-authenticate\"])[1]\n\n if keystone_uri\n if @auth_options[:type] == \"x509\"\n body = { \"auth\" => { \"voms\" => true } }\n else\n body = {\n \"auth\" => {\n \"passwordCredentials\" => {\n \"username\" => @auth_options[:username],\n \"password\" => @auth_options[:password]\n }\n }\n }\n end\n\n headers = self.class.headers.clone\n headers['Content-Type'] = \"application/json\"\n headers['Accept'] = headers['Content-Type']\n\n response = self.class.post(keystone_uri + \"/v2.0/tokens\", :body => body.to_json, :headers => headers)\n\n if response.success?\n self.class.headers['X-Auth-Token'] = response['access']['token']['id']\n return true\n end\n end\n end\n end\n\n false\n end", "def authenticate\n unless session[:loggedin]\n redirect_to :action => 'login'\n return false\n end\n return true\n end", "def authenticate\n response = request('authenticate', nil)\n # A failure to authenticate returns a nil response.\n if response.nil? || response.empty?\n return false\n else\n @session = response\n return true\n end\n end", "def authenticated?\n !!@authenticated\n end", "def authenticated?\n @authenticated\n end", "def authenticated?\n @authenticated\n end", "def authenticated?\n @authenticated || false\n end", "def authorized?\n !auth.nil?\n end", "def authenticate\n @socket.write(0.chr)\n next_authenticator\n @state = :Starting\n while @state != :Authenticated\n r = next_state\n return r if not r\n end\n true\n end", "def authenticated?\n @session != nil && !@session['session_expires'].nil? && @session['session_expires'] > Time.now && @session['auth'] == true && @session['ip'] == @cgi.remote_addr\n end", "def authenticated?\n valid? && !get_authenticated_user.nil?\n end", "def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n return @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [@@username, @@password]\n end", "def authenticate(passwd)\n\t\t\tres = sendrecv(%Q<AUTHENTICATE #{quote(passwd)}>)\n\n\t\t\tcase res.status_code\n\t\t\t\twhen 250 then true # success\n\t\t\t\twhen 515 then false # failure\n\t\t\t\telse raise(ControllerError, res)\n\t\t\tend\n\t\tend", "def authorized?\n\t\t\t@authenticated\n\t\tend", "def check_auth\n\t\tputs \"CHECKING AUTH STATUS\"\n\n\t\tapi_key = ApiKey.find_by_access_token(params[:access_token])\n\t\tusr = User.find(api_key.user_id)\n\t\t#puts \"CHECKING AUTH FOR USER: #{usr}\"\n\t\trole = usr.role\n\t\tputs \"ROLE: #{role}\"\n\t\tmsg = \"SUCCESS\"\n\n\t\trespond_to do |format|\n \t\tformat.json { render :json => { :msg => msg, :role => role } } \t\t\n \t\tend\n\tend", "def valid_for_authentication?; end", "def valid_for_authentication?; end", "def logged_in?\n return false unless @auth_header\n true\n end", "def authenticates?\n !!@authenticates\n end", "def authenticate?\n @authentication_required\n end", "def auth_works?(server)\n return false unless (server && server.token && server.token.access_token)\n vspinner \"Testing if authentication works using current access token\" do\n Kontena::Client.new(server.url, server.token).authentication_ok?(master_account.userinfo_endpoint)\n end\n end", "def auth_succeeded( request, credentials )\n\t\tself.log.info \"Authentication for %p succeeded.\" % [ credentials ]\n\t\t# No-op by default\n\tend", "def authenticate!\n error!(\"401 Unauthorized\", 401) unless check_auth_token \n end", "def authenticate\n RestClient.post @apiurl + \"authenticate\", \n :username => @username, \n :password => @password\n rescue RestClient::RequestFailed\n handle_error($!)\n return false\n end", "def authenticated?(pass)\n\t\tencrypted_password == User.encrypt(pass,salt)\n\tend", "def authorize\n if session[\"allcool\"] == 1\n return true\n end\n login,password = get_auth_data\n @test = User.find_by_login(login)\n if @test && @test.authenticated?(password) # && @test.is_admin\n session[\"allcool\"] = 1\n return true\n end\n session[\"allcool\"] = 0\n headers[\"Status\"] = \"Unauthorized\" \n headers[\"WWW-Authenticate\"] = 'Basic realm=\"Realm\"'\n self.status = 401\n render \"Authentication Required\"\n return false\n end", "def user_authenticated?\n basic_authenticated? || token_authenticated?\n end", "def authenticate\n user = User.active.where(\"email_id = ?\", self.email_id).first\n if user.present?\n return user.hashed_password == Digest::SHA1.hexdigest(user.password_salt.to_s + self.password)\n end\n return false\n end", "def authenticate\n\t\t\tlogged_in? ? true : access_denied\n\t\tend", "def loggedin?\n !(@auth=='' or @auth.nil?)\n end", "def authorized?\n auth_config = settings.config['authentication']\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? and @auth.basic? and @auth.credentials and @auth.credentials == [auth_config['username'], auth_config['password']]\n end", "def authenticated?\n response = institutions\n case response.code\n when 401\n false\n else\n true\n end\n end", "def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n user = ENV[\"HTTP_USER\"]\n pass = ENV[\"HTTP_PASS\"]\n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [user, pass]\n end", "def authenticate(attempted_password)\n if self.password == attempted_password\n true\n else\n false\n end\n end", "def authenticate(attempted_password)\n if self.password == attempted_password\n true\n else\n false\n end\n end", "def authenticated?\n doorkeeper_token.present? ? doorkeeper_authorize!.nil? : false\n end", "def login?\n if session_code && session_token\n # check code exist at db.\n code_rec = get_code_rec(session_code, subject)\n return false unless code_rec\n # compare token\n code_rec.token == session_token\n else\n return false\n end\n end", "def service_login?()\n return true if (@service == TAC_PLUS_AUTHEN_SVC_LOGIN)\n return false\n end", "def authenticated?\n # If logged on to website, we're good\n @user = current_user\n authenticated = [email protected]?\n\n # If not logged on, or submitting via JSON post (likely), check params\n unless authenticated\n @user = User.find_by(email: params[:email])\n authenticated = @user && @user.authenticate(params[:password])\n end\n\n authenticated\n end", "def authorized?\n if Vermonster::Client.connection.get(\"me\").status == 200\n true\n else\n false\n end\n end", "def authenticate\n action = \"#{@url}index.cgi\"\n page = @agent.get(@url)\n form = page.form_with(:action => action)\n if form != nil\n @log.debug \"Authenticating with #{@url}\"\n form['Bugzilla_login']=@username\n form['Bugzilla_password']=@password\n page = @agent.submit form\n if page.search(\".//td[@id='error_msg']\").empty?\n @log.debug \"Authenticated successfully\"\n return true\n else\n @log.error page.search(\".//td[@id='error_msg']\")[0].content.strip\n end\n else\n @log.error \"Unable to find #{action} form\"\n end\n return false\n end", "def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n \n # read credentials from file\n credentials = open(\"credentials.txt\").read.split(\"\\n\").map{|c| c !~ /^#/ ? c : nil}.compact\n \n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == credentials\n end", "def authenticated?(&block)\n if block\n observeAuthEventWithBlock(block)\n else\n !!authData\n end\n end", "def authenticating?\n username || password\n end", "def authenticate()\n token = session[:token]\n redirect_to login_prompt_path if token.nil?\n return !token.nil?\n end", "def authenticate()\n token = session[:token]\n redirect_to login_prompt_path if token.nil?\n return !token.nil?\n end", "def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? &&\n @auth.basic? &&\n @auth.credentials &&\n check(@auth.credentials)\n end", "def authenticate\n \t\tlogged_in? || access_denied\n \tend", "def authenticate(username, password)\n true\n end", "def authenticate\n\tlogged_in? ? true : access_denied \n end", "def status_error?()\n return true if (@status == TAC_PLUS_AUTHEN_STATUS_ERROR)\n return false\n end", "def authenticated?(config)\n config.has_key?(:username) && config.has_key?(:password)\n end", "def successful?\n @code == 0\n end", "def authenticate(username,password,authen_start)\n acl = nil\n enable = authen_start.body.service_enable?\n ret_val = {:pass => false, :msg => \"Username or password incorrect.\"}\n ret_val[:msg] = \"Password incorrect.\" if (enable)\n fail_log_msg = \"Authentication failed.\"\n user = @tacacs_daemon.users(username) if (username)\n\n # check for active account, and valid pw\n if (!user) # fail if user unknown\n fail_log_msg += \" Unknown user.\"\n\n elsif (enable) # check enable password\n if (user.enable_password)\n if ( user.verify_enable_password(password) )\n if (!user.disabled?)\n ret_val[:pass] = true\n # if login, check if enable is expired\n if (authen_start.body.action_login? && user.enable_password_expired?)\n ret_val[:pass] = false\n ret_val[:msg] = @tacacs_daemon.password_expired_prompt\n fail_log_msg += \" Enable password expired.\"\n end\n else\n ret_val[:msg] = @tacacs_daemon.disabled_prompt\n fail_log_msg += \" Account disabled.\"\n end\n\n end\n\n # get acl for enable access. always prefer one set on user over one set on group\n if (user.enable_acl)\n acl = user.enable_acl\n elsif (user.user_group)\n acl = user.user_group.enable_acl\n end\n\n end\n\n elsif(user.login_password) # check login password\n if ( user.verify_login_password(password) )\n if (!user.disabled?)\n ret_val[:pass] = true\n # if login, check if password is expired\n if (authen_start.body.action_login? && user.login_password_expired?)\n ret_val[:pass] = false\n ret_val[:msg] = @tacacs_daemon.password_expired_prompt\n fail_log_msg += \" Login password expired.\"\n end\n else\n ret_val[:msg] = @tacacs_daemon.disabled_prompt\n fail_log_msg += \" Account disabled.\"\n end\n\n end\n\n # get acl for login access. always prefer one set on user over one set on group\n if (user.login_acl)\n acl = user.login_acl\n elsif (user.user_group)\n acl = user.user_group.login_acl\n end\n end\n\n # if active account and password correct, then check acl. else log failure\n if (ret_val[:pass])\n if (acl)\n match_results = acl.match(@peeraddr)\n\n if ( match_results[:permit] )\n pass_log_msg = \"Authentication successful. User permitted by ACL '#{acl.name}' #{match_results[:by]}.\"\n else\n ret_val[:pass] = false\n ret_val[:msg] = \"Authentication denied due to ACL restrictions on user.\"\n fail_log_msg += \" User denied by ACL '#{acl.name}' #{match_results[:by]}.\"\n end\n else\n pass_log_msg = \"Authentication successful.\"\n end\n end\n\n # log pass/fail\n if (ret_val[:pass])\n if (enable)\n @tacacs_daemon.log(:info,['msg_type=Authentication', \"message=#{pass_log_msg}\",\"status=Pass\"],authen_start,@peeraddr, username)\n else\n @tacacs_daemon.log(:warn,['msg_type=Authentication', \"message=#{pass_log_msg}\",\"status=Pass\"],authen_start,@peeraddr, username)\n end\n else\n @tacacs_daemon.log(:warn,['msg_type=Authentication', \"message=#{fail_log_msg}\",\"status=Fail\"],authen_start,@peeraddr, username)\n end\n\n\n return(ret_val)\n end", "def redmine_check_auth(m)\n \tbegin\n\t\tif ! @registry[\"#{m.sourcenick}_auth\"]\n\t\t\tm.reply \"#{@redmine_l_hello} #{m.sourcenick}, #{@redmine_l_pleaseconnect}.\"\n\t\t\treturn false\n\t\telse\n\t\t\tauthstored = @registry[\"#{m.sourcenick}_auth\"]\n\t\t\tcertificate = {:username => authstored[0].username, :password => authstored[0].password}\n\t\t\treturn certificate\n\t\tend\n rescue Exception => e\n m.reply e.message\n m.reply e.backtrace.inspect\n end\t\n end", "def authenticated?\n !account.nil?\n end", "def authenticated?(pass)\n encrypted_password == User.encrypt(pass, salt)\n end", "def authentication?\n !!@authentication\n end", "def authenticate!\n last_ticket = session[:cas_last_valid_ticket]\n ticket = read_ticket(params)\n\n if ticket\n if resource = mapping.to.authenticate_with_cas_ticket(ticket)\n session[:cas_devise_resouce_name] = mapping.class_name\n session[:cas_last_valid_ticket] = ticket\n success!(resource)\n else\n fail(:invalid)\n end\n elsif returning_from_cas?\n fail(:invalid)\n else\n redirect!(login_url)\n end\n end", "def authenticate\n\t logged_in? ? true : access_denied\n\tend", "def authenticate(auth_password)\n if(password_digest)\n password_digest == checksum(auth_password)\n else\n false\n end\n end", "def authenticate password\n if self.password == password\n true\n else\n false\n end\n end", "def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n\n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [\n ENV[\"HTTP_USER\"],\n ENV[\"HTTP_PASS\"]\n ]\n end", "def valid_for_http_auth?; end", "def success?\n response.message == 'OK'\n end" ]
[ "0.8491629", "0.8491629", "0.8491629", "0.8491629", "0.8405789", "0.7557303", "0.7496545", "0.7422437", "0.72008777", "0.7148655", "0.71213865", "0.7095634", "0.7065356", "0.69968003", "0.69859827", "0.6938615", "0.69154394", "0.68724346", "0.68598443", "0.68461335", "0.68433666", "0.6814646", "0.68057114", "0.6800845", "0.6781913", "0.6777486", "0.67774624", "0.6762619", "0.6760478", "0.67594343", "0.6756147", "0.67539126", "0.67184806", "0.67146456", "0.670143", "0.6691446", "0.6678499", "0.66591513", "0.66591513", "0.66343737", "0.66312706", "0.6622788", "0.6621698", "0.6612592", "0.6599424", "0.6593643", "0.65862864", "0.6580049", "0.6575943", "0.6575943", "0.656143", "0.65540683", "0.65521234", "0.6544486", "0.6538843", "0.65313846", "0.65307087", "0.64960647", "0.6493833", "0.6489173", "0.64811313", "0.64741445", "0.64519167", "0.6450244", "0.6449243", "0.6442611", "0.6441362", "0.6441362", "0.643445", "0.64336705", "0.64328337", "0.64270246", "0.64193183", "0.64061666", "0.64040434", "0.63986063", "0.6389342", "0.63889503", "0.63889503", "0.63676965", "0.6364464", "0.6364298", "0.63556707", "0.63484913", "0.6346208", "0.634245", "0.63349515", "0.6327646", "0.63244104", "0.6323147", "0.63229054", "0.6321953", "0.63217294", "0.6319486", "0.63007295", "0.6300452", "0.62992203", "0.6298626" ]
0.8420339
6
no options documented in API at Nov 2012 (e.g. like limit/marker as used in Nova for servers)
def list_volumes response = @connection.req("GET", "/#{@volume_path}") volumes_hash = JSON.parse(response.body)["volumes"] volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(current); res} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def limit; @opts['limit']; end", "def default_limit\n 10\n end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def limit\n @options[:limit]\n end", "def limit; end", "def limit; end", "def limit; end", "def resource_limits; end", "def resource_limits; end", "def options() end", "def get_limits\n # code\n end", "def limit=(x); @opts['limit'] = x; end", "def limit\n super\n end", "def options; [] end", "def get_options; end", "def limit\n self[:limit]\n end", "def query_options; end", "def rest\n @options[:limit] - @count if @options[:limit] > 0\n end", "def item_limit\n 100\n end", "def limit(limit = nil)\n set_option(:limit, limit)\n end", "def maximum_requests\n super\n end", "def limit\n @request.params[:limit] || 10\n end", "def server_result_limit\n self.parameters[:result_limit]\n end", "def user_options; end", "def http_options; end", "def maximum_limit\n 100\n end", "def miter_limit(limit)\n end", "def set_limit(opts)\n opts = check_params(opts,[:limits])\n super(opts)\n end", "def limits\n return @opts['api_limits']\n end", "def limit\n meta.fetch('limit', nil)\n end", "def rekey_limit; end", "def request_count; end", "def limit(limit); end", "def rate_limit\n options[:rate_limit]\n end", "def default_options; end", "def default_options; end", "def default_options; end", "def quota_info\n end", "def api_mode; end", "def hints; end", "def limit=(_arg0); end" ]
[ "0.6679065", "0.63825583", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6315788", "0.6312041", "0.6292607", "0.6292607", "0.6292607", "0.6221773", "0.6221773", "0.6178981", "0.6150686", "0.6139393", "0.59519786", "0.5939061", "0.5904393", "0.5893639", "0.5887341", "0.58672744", "0.5850784", "0.5836846", "0.58305573", "0.5786109", "0.5772918", "0.5768716", "0.57547027", "0.57149404", "0.56832933", "0.56547266", "0.5609495", "0.56065905", "0.5597138", "0.5593884", "0.5593838", "0.55838436", "0.5571086", "0.5571086", "0.5571086", "0.55552673", "0.5554205", "0.55346775", "0.55306613" ]
0.0
-1
Lists all backend storage pools that are known to the scheduler service
def get_pools(details = true) path = details ? "/scheduler-stats/get_pools?detail=true" : "/scheduler-stats/get_pools" response = @connection.req('GET', path) OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/) JSON.parse(response.body)['pools'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list(mixins = nil)\n # TODO: impl filtering with mixins\n storage = ::Occi::Core::Resources.new\n backend_storage_pool = ::OpenNebula::ImagePool.new(@client)\n rc = backend_storage_pool.info_all\n check_retval(rc, Backends::Errors::ResourceRetrievalError)\n\n backend_storage_pool.each do |backend_storage|\n storage << parse_backend_obj(backend_storage)\n end\n\n storage\n end", "def list_pools\n handle_action_exceptions(__method__) do\n cmd_line = ['listpools']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def list_storage_pools request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_storage_pools_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::NetApp::V1::ListStoragePoolsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def all\n inactive + active\n rescue Exception::LibvirtError\n # If inactive isn't supported, then we just return the active\n # storage pools.\n active\n end", "def get_block_vpool_storage_pools(block_vpool_id,auth=nil, cert=nil)\n\t\trest_get(\"#{@base_url}/block/vpools/#{block_vpool_id}/storage-pools\", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert)\n\tend", "def active\n read_array(:virConnectListStoragePools, :virConnectNumOfStoragePools, :string).collect do |name|\n find_by_name(name)\n end\n end", "def get_pool_names\n JSON.parse(get(\"http://#{@host}/loadbalancers/tenant/#{@tenant}/pools\"))['tenantpools']['pools']\n end", "def names_list\n backend.queue_names\n end", "def all_storages\n hosts = all_hosts\n MiqPreloader.preload(hosts, :storages)\n hosts.collect(&:storages).flatten.compact.uniq\n end", "def pools\n @pools ||= {}\n end", "def pools\n @pools ||= {}\n end", "def storages\n IbmCloudRest.get \"#{@uri}/storage\"\n end", "def storage_list(mixins = nil)\n storages = Occi::Core::Resources.new\n\n Backends::Ec2::Helpers::AwsConnectHelper.rescue_aws_service(@logger) do\n volumes = @ec2_client.describe_volumes.volumes\n volumes.each do |volume|\n next unless volume\n storages << storage_parse_backend_obj(volume)\n end if volumes\n end\n\n storages\n end", "def list_pools(params = {})\n path = \"/pools?\"\n path << \"consumer=#{params[:consumer]}&\" if params[:consumer]\n path << \"owner=#{params[:owner]}&\" if params[:owner]\n path << \"product=#{params[:product]}&\" if params[:product]\n path << \"listall=#{params[:listall]}&\" if params[:listall]\n path << \"activeon=#{params[:activeon]}&\" if params[:activeon]\n results = get(path)\n\n return results\n end", "def get_application_pools\n\t\ts = get_admin_section \"system.applicationHost/applicationPools\"\n\t\tIisObjectCollection.new s.Collection, :add, ApplicationPool\n end", "def list_storage_accounts\n request_path = \"/services/storageservices\"\n request = ManagementHttpRequest.new(:get, request_path, nil)\n response = request.call\n Serialization.storage_services_from_xml(response)\n end", "def backend_instances(refresh=false)\n if @backend_instances.nil? or refresh\n @backend_instances = {}\n backend_data = @socket.execute( \"show stat -1 4 -1\" )[1..-1].collect{|item| item.split(\",\")[0..1]}\n backend_servers = backend_data.inject({}){|hash, items|\n (hash[items[0]] ||=[]) << items[1]; hash\n }\n backend_servers.each do |backend, servers|\n @backend_instances[backend] = HAProxyManager::Backend.new(backend, @socket)\n end\n end\n @backend_instances\n end", "def storage_servers\n self.client.get('gh.storage.servers').split(',')\n end", "def servers(backend = nil)\n my_servers = []\n if backend.nil?\n # return all servers\n backend_instances.each_value do | backend|\n my_servers << backend.server_names\n end\n else\n begin\n my_servers = backend_instances[backend].server_names\n rescue KeyError => e\n \"The backend #{backend} is not a valid argument\"\n end\n end\n # return a list of serv\n my_servers.flatten.uniq\n end", "def backends\n # Lets cache the values and return the cache\n if @backends.nil?\n @backends = {}\n backend_instances.each do | name, backend|\n @backends[name] = backend.servers\n end\n end\n @backends\n end", "def all\n storage.map(&:repository)\n end", "def index\n @storages = Storage.all\n end", "def index\n @storages = Storage.all\n end", "def storage_names\n @storage_names\n end", "def index\n @backends = Backend.all\n end", "def get_pool_names\n (JSON.parse(get(url: \"https://#{@host}/mgmt/tm/ltm/pool\"))['items'] || []).map {|item| item['name']}\n end", "def get_pool_names\n (JSON.parse(get(url: \"https://#{@host}/mgmt/tm/ltm/pool\"))['items'] || []).map {|item| item['name']}\n end", "def compute_list(mixins = nil)\n # TODO: impl filtering with mixins\n compute = Occi::Core::Resources.new\n backend_compute_pool = ::OpenNebula::VirtualMachinePool.new(@client)\n rc = backend_compute_pool.info_all\n check_retval(rc, Backends::Errors::ResourceRetrievalError)\n\n backend_compute_pool.each do |backend_compute|\n compute << compute_parse_backend_obj(backend_compute)\n end\n\n compute\n end", "def provided_pools\n list = []\n @config[:pools].each do |pool|\n list << pool['name'] if pool['provider'] == name\n end\n list\n end", "def merged_backends\n return []\n end", "def inactive\n read_array(:virConnectListDefinedStoragePools, :virConnectNumOfDefinedStoragePools, :string).collect do |name|\n find_by_name(name)\n end\n end", "def list(mixins = nil)\n # TODO: impl filtering with mixins\n network = ::Occi::Core::Resources.new\n backend_network_pool = ::OpenNebula::VirtualNetworkPool.new(@client)\n rc = backend_network_pool.info_all\n check_retval(rc, Backends::Errors::ResourceRetrievalError)\n\n backend_network_pool.each do |backend_network|\n network << parse_backend_obj(backend_network)\n end\n\n network\n end", "def index\n @storage_units = StorageUnit.all\n end", "def get_storage_types\n JSON.parse(RestClient.get(\"https://#{region.sub(/-\\d$/, '')}.power-iaas.cloud.ibm.com/broker/v1/storage-types\", headers))[region]\n end", "def index\n @taskstorages = current_user.taskstorages.all\n end", "def backends(service)\n out = Array.new\n # iterate the servers removing aggregates for FRONT/BACKEND\n @stats[service].each do |k, v|\n if not (k == 'FRONTEND' or k == 'BACKEND')\n out = out << k\n end\n end\n out\n end", "def get_storage_names\n @schemas = self.get_schema\n @schemas.map { |schema| schema['id'] }\n end", "def get_system_pool\n get(\"cloud-instances/#{guid}/system-pools\")\n end", "def load_pools_to_redis\n @redis.with_metrics do |redis|\n previously_configured_pools = redis.smembers('vmpooler__pools')\n currently_configured_pools = []\n config[:pools].each do |pool|\n currently_configured_pools << pool['name']\n redis.sadd('vmpooler__pools', pool['name'].to_s)\n pool_keys = pool.keys\n pool_keys.delete('alias')\n to_set = {}\n pool_keys.each do |k|\n to_set[k] = pool[k]\n end\n to_set['alias'] = pool['alias'].join(',') if to_set.key?('alias')\n to_set['domain'] = Vmpooler::Dns.get_domain_for_pool(config, pool['name'])\n\n redis.hmset(\"vmpooler__pool__#{pool['name']}\", *to_set.to_a.flatten) unless to_set.empty?\n end\n previously_configured_pools.each do |pool|\n unless currently_configured_pools.include? pool\n redis.srem('vmpooler__pools', pool.to_s)\n redis.del(\"vmpooler__pool__#{pool}\")\n end\n end\n end\n nil\n end", "def index\n @storage_types = StorageType.all\n end", "def list_worker_pools request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_worker_pools_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::Build::V1::ListWorkerPoolsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def list_queues(options = {})\n query = {}\n query[\"prefix\"] = options[:prefix] if options[:prefix]\n query[\"marker\"] = options[:marker] if options[:marker]\n query[\"maxresults\"] = options[:max_results].to_s if options[:max_results]\n query[\"include\"] = \"metadata\" if options[:metadata] == true\n query[\"timeout\"] = options[:timeout].to_s if options[:timeout]\n\n options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY\n uri = collection_uri(query, options)\n response = call(:get, uri, nil, {}, options)\n\n Serialization.queue_enumeration_results_from_xml(response.body)\n end", "def get_extensions\n collection = Occi::Collection.new\n BACKEND_TYPES.each { |backend_type| collection.merge! backend_instances[backend_type].get_extensions }\n collection\n end", "def all\n storage\n end", "def get_queues\n @gem_queue = get_queue 'gem'\n @md5_queue = get_queue 'md5'\n @sha512_queue = get_queue 'sha512'\n end", "def get_varray_storage_pools(varray_id,auth=nil, cert=nil)\n\t\trest_get(\"#{@base_url}/vdc/varrays/#{varray_id}/storage-pools\", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert)\n\tend", "def provided_pools\n @config[:pools].select { |pool| pool['dns_config'] == name }.map { |pool| pool['name'] }\n end", "def get_buckets\n buckets = call(CMD_GET_BUCKETS)[:buckets]\n buckets.map {|bucket| Bucket.new(bucket) }\n end", "def list\n ::Taxi::S3.instance.list_buckets\n end", "def all_dbs\n @conn.query({url_path: \"_all_dbs\", method: :get})\n end", "def all\n @pool\n end", "def find_all(options = {})\n proxy_owner.send(:list_bucket, options)\n end", "def do_servers_storages_database_resources\n depl_resource_types = {}\n (@deployment.servers.all(:include => :patterns) + @deployment.storages.all(:include => :patterns) +\n @deployment.database_resources.all(:include => :patterns)).each do |resource|\n cloud = @clouds[resource.cloud_id]\n depl_resource_type_id = case resource.class.to_s\n when 'Server'\n resource.server_type_id\n when 'Storage'\n resource.storage_type_id\n when 'DatabaseResource'\n resource.database_type_id\n end\n depl_resource_types[depl_resource_type_id] ||= {}\n depl_resource_types[depl_resource_type_id][cloud.id] ||= {}\n\n ['instance_hour', 'transaction', 'storage_size', 'read_request', 'write_request'].each do |ccs_name|\n # Skip this ccs_name if the resource doesn't have it\n next unless resource.respond_to?(\"#{ccs_name}_monthly_baseline\")\n\n values = get_monthly_values(resource, ccs_name)\n quantity_values = get_monthly_values(resource, 'quantity')\n\n depl_resource_types[depl_resource_type_id][cloud.id][ccs_name] ||= {}\n depl_resource_types[depl_resource_type_id][cloud.id][ccs_name][:values] ||= Array.new(@costs.length){0}\n depl_resource_types[depl_resource_type_id][cloud.id][ccs_name][:quantity_values] ||= Array.new(@costs.length){0}\n @costs.each_with_index do |month, i|\n # A month has max number of hours, enforce this in case user patterns accidentally make it go over this value\n if ccs_name == 'instance_hour'\n hours_in_month = 24 * Time.days_in_month(month[:timestamp].month, month[:timestamp].year)\n values[i] = hours_in_month if values[i] > hours_in_month\n end\n # Protect users from creating stupid patterns that set values to less than 0\n values[i] = 0 if values[i] < 0\n quantity_values[i] = 0 if quantity_values[i] < 0\n\n depl_resource_types[depl_resource_type_id][cloud.id][ccs_name][:values][i] += (values[i] * quantity_values[i])\n depl_resource_types[depl_resource_type_id][cloud.id][ccs_name][:quantity_values][i] += quantity_values[i]\n end\n end\n end\n\n depl_resource_types.each do |depl_resource_type_id, cloud_ids|\n cloud_ids.each do |cloud_id, ccs_names|\n cloud = @clouds[cloud_id]\n ccs_names.each do |ccs_name, values_hash|\n price_details = get_price_details(cloud_id, depl_resource_type_id, ccs_name)\n\n unless price_details.empty?\n if price_details[:custom_algorithm]\n self.send(\"do_#{price_details[:custom_algorithm]}\")\n else\n @costs.each_with_index do |month, i|\n # No need to multiply the quantity again as values[i] already has the total usage\n usage = values_hash[:values][i]\n cost = get_tiered_cost(usage, price_details[:units], price_details[:tiers])\n recurring_cost = price_details[:recurring_cost_values][i] * values_hash[:quantity_values][i]\n total_cost = cost + recurring_cost\n month[ccs_name.to_sym] += total_cost.to_money(cloud.billing_currency).exchange_to(@user_currency).to_f\n end\n end\n end\n end\n end\n end\n end", "def volumes\n service.list_pool_volumes uuid\n end", "def retrieve_volumes\n dbg { \"retrieving #{pool_info}, #{hv_info}\" }\n\n volumes = pool.list_all_volumes\n dbg { \"list_all_volumes #{pool_info}, #{hv_info}\" }\n\n storage_volumes = volumes.map.with_index do |vol, index|\n id = \"#{uuid}--#{index}\"\n StorageVolume.new(vol, pool: self, id: id)\n end\n\n dbg { \"retrieved size=#{storage_volumes.size}, #{pool_info}, #{hv_info}\" }\n storage_volumes\n end", "def get_pool_names\n pool_names = []\n Dir.entries(@confdir).each do |entry|\n pool_names.push $1 if entry =~ @pool_fname_regex\n end\n pool_names\n end", "def list\n storage.transaction {return storage.roots}\n end", "def storage_pool_id(sys_id, name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/storage-pools\")\n status(response, 200, 'Failed to get pool id')\n storage_pools = JSON.parse(response.body)\n storage_pools.each do |pool|\n return pool['id'] if pool['label'] == name\n end\n nil\n end", "def storage_pool_id(sys_id, name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/storage-pools\")\n status(response, 200, 'Failed to get pool id')\n storage_pools = JSON.parse(response.body)\n storage_pools.each do |pool|\n return pool['id'] if pool['label'] == name\n end\n nil\n end", "def list_buckets(queries: nil, search: nil)\n path = '/storage/buckets'\n\n params = {\n queries: queries,\n search: search,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::BucketList\n )\n end", "def list_server_pools(opts = {})\n data, _status_code, _headers = list_server_pools_with_http_info(opts)\n data\n end", "def loadAll()\n # Load the configuration from global.rb\n SHAREDPOOLS.each_key do |k|\n p = Pool.new(k, SHAREDPOOLS[k][:zone],\n SHAREDPOOLS[k][:allocateable_cpus],\n SHAREDPOOLS[k][:allocateable_mem],\n SHAREDPOOLS[k][:service_class])\n\n @poolList.push(p)\n end\n SERVICES.each_key do |k|\n s = Service.new(k, SERVICES[k][:authinfo],\n SERVICES[k][:maxcpus],\n SERVICES[k][:maxmemory],\n SERVICES[k][:priority])\n @svcList.push(s)\n end\n # Load the requests from redis\n @reqList = $eventProcessor.loadRequests()\n # Compute the free/used stats from state of requests\n @reqList.each { |req|\n if req.status == \"ALLOCATED\"\n pmatches = @poolList.select {|p| p.name == req.pool}\n if pmatches == nil || pmatches[0] == nil\n $Logger.error \"Unable to find pool #{req.pool} for ALLOCATED request #{req.reqid}\"\n next\n end\n smatches = @svcList.select {|s| s.name == req.service}\n if smatches == nil || smatches[0] == nil\n $Logger.error \"Unable to find service #{req.service} for ALLOCATED request #{req.reqid}\"\n next\n end\n pool = pmatches[0]\n pool.availvcpus = pool.availvcpus.to_i - req.vcpus.to_i\n pool.availmem = pool.availmem.to_i - req.mem.to_i\n service = smatches[0]\n service.vcpusallocated = service.vcpusallocated.to_i + req.vcpus.to_i\n service.memallocated = service.memallocated.to_i + req.mem.to_i\n end\n }\n end", "def index\n @pools = Pool.all\n end", "def index\n @storages = Mercadolibre::Storage.all.paginate(page: params[:page], per_page: 7)\n end", "def list_agent_pools request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_agent_pools_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::StorageTransfer::V1::ListAgentPoolsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def compute_list_ids(mixins = nil)\n # TODO: impl filtering with mixins\n backend_compute_pool = ::OpenNebula::VirtualMachinePool.new(@client)\n rc = backend_compute_pool.info_all\n check_retval(rc, Backends::Errors::ResourceRetrievalError)\n\n compute = []\n backend_compute_pool.each do |backend_compute|\n compute << backend_compute['ID']\n end\n\n compute\n end", "def list_bundles\n BrickFTP::API::Bundle.all\n end", "def list_bundles\n BrickFTP::API::Bundle.all\n end", "def all\n Array(@@job_scheduler_instance)\n end", "def index\n @spending_pools = SpendingPool.all\n end", "def all\n containers = service.list_containers\n data = []\n containers.each do |container|\n c = parse_storage_object(container)\n c[:acl] = 'unknown'\n data << c\n end\n load(data)\n end", "def index\n @job_schedulers = JobScheduler.all\n end", "def storages(type: nil)\n response = get(type && \"storage/#{type}\" || \"storage\")\n data = JSON.parse response.body\n data[\"storages\"][\"storage\"]\n end", "def listq(basedir)\n queues = Dir.glob(basedir + \"/queue/??*\")\n queues\nend", "def driver\n storage_hash = get_api_node(['storage-pools', resource[:name]])\n driver = storage_hash['driver']\n return driver\n end", "def databases\n get '_all_dbs'\n end", "def get_storage_names\n # This gets all the non view tables, but has to strip column 0 out of the two column response.\n select(\"SHOW FULL TABLES FROM #{options[:path][1..-1]} WHERE Table_type = 'BASE TABLE'\").map { |item| item.first }\n end", "def list_buckets\n puts '> AWS Buckets'.yellow\n response = s3_client.list_buckets\n buckets = response.buckets.map do |bucket|\n \"#{bucket.name.yellow} - created: #{bucket.creation_date.to_s.greenish}\"\n end\n buckets.each do |bucket|\n puts bucket\n end\n end", "def list_databases\n response = @connection.dbreq(\"GET\", @lbmgmthost, \"#{@lbmgmtpath}/instances/#{CloudDB.escape(@id.to_s)}/databases\",@lbmgmtport,@lbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n CloudDB.symbolize_keys(JSON.parse(response.body)[\"databases\"])\n end", "def index\n @fundamental_resource_pools = Fundamental::ResourcePool.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamental_resource_pools }\n end\n end", "def list_queues(options ={})\r\n content = execute(:get, nil, { :comp => 'list' }.merge!(options), { :x_ms_version => \"2009-09-19\" })\r\n doc = REXML::Document.new(content)\r\n queues = []\r\n \r\n REXML::XPath.each(doc, '//Queue/') do |item|\r\n metadata = {}\r\n \r\n item.elements['Metadata'].elements.each do |element|\r\n metadata.merge!(element.name.gsub(/-/, '_').downcase.to_sym => element.text)\r\n end unless item.elements['Metadata'].nil?\r\n \r\n queues << { :name => REXML::XPath.first(item, \"Name\").text,\r\n :url => REXML::XPath.first(item, \"Url\").text,\r\n :metadata => metadata}\r\n end\r\n return queues\r\n end", "def pool_types\n @pool_types.each\n end", "def compute_list(mixins = nil)\n mixins = deep_clone(mixins) if mixins\n @backend_instance.compute_list(mixins) || Occi::Core::Resources.new\n end", "def index\n @bucket_blocs = BucketBloc.all\n end", "def dbs\n @dbs_hash.keys\n end", "def buckets prefix: nil, token: nil, max: nil\n options = { prefix: prefix, token: token, max: max }\n resp = connection.list_buckets options\n if resp.success?\n Bucket::List.from_response resp, connection\n else\n fail ApiError.from_response(resp)\n end\n end", "def get_storages(request)\n # --- Get User's Images ---\n image_pool = ImagePoolOCCI.new(\n @client,\n POOL_FILTER)\n\n # --- Prepare XML Response ---\n rc = image_pool.info\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n return to_occi_xml(image_pool, :code=>200, :verbose=>request.params['verbose'])\n end", "def connections\n @connection_pool\n end", "def queues(reload = false)\n if reload or @queues.nil?\n @queues = list_queues\n else\n @queues\n end\n end", "def empty_connection_pools!; end", "def blob_tables\n execute('select table_name from information_schema.tables where table_schema = ?', ['blob']).map(&:first)\n end", "def workers\n @queues.keys\n end", "def all_servers\n Infrataster::Server.defined_servers.map { |i| server(i.name) }\nend", "def get_queues\n @gem_name_queue = get_queue 'gem_name'\n @gem_queue = get_queue 'gem'\n end", "def index\n @pools = current_user.pools.all\n end", "def storage_items\n @storage_items[@storage_name].keys.sort.collect {|id| $data_items[id] }\n end", "def storages\n reflective_auto_load_adapter_extension\n storages # call the overrided method\n end", "def get_all_datasets_and_resources(base_url)\n return handle_request(URI.encode(base_url + '/current_package_list_with_ressources'))\n end", "def get_storage_pool request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_storage_pool_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::NetApp::V1::StoragePool.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def buckets\n resp = connection.list_buckets\n if resp.success?\n resp.data[\"items\"].map do |gapi_object|\n Bucket.from_gapi gapi_object, connection\n end\n else\n fail ApiError.from_response(resp)\n end\n end" ]
[ "0.67979616", "0.66166264", "0.6587234", "0.6476892", "0.64444256", "0.63369656", "0.6303545", "0.62649304", "0.6256877", "0.6221136", "0.6221136", "0.612971", "0.6088823", "0.60607886", "0.6053144", "0.5999974", "0.5978249", "0.5918881", "0.5895538", "0.5871423", "0.5857652", "0.5830978", "0.5830978", "0.5809744", "0.579382", "0.57873863", "0.57873863", "0.5782051", "0.57772654", "0.57771593", "0.57720405", "0.57710874", "0.5725203", "0.57083017", "0.56945825", "0.5686388", "0.5682693", "0.5663609", "0.5662868", "0.5655726", "0.563841", "0.56309956", "0.5613309", "0.5596493", "0.55579287", "0.5546959", "0.55467504", "0.5528145", "0.5527133", "0.5499093", "0.5471119", "0.5455757", "0.54057115", "0.5402861", "0.5398443", "0.5392222", "0.5377868", "0.53719026", "0.53719026", "0.53675616", "0.5362578", "0.5353838", "0.53362703", "0.5332848", "0.5327183", "0.5323363", "0.5321591", "0.5321591", "0.5317836", "0.5304399", "0.5300813", "0.5279988", "0.52770585", "0.5267706", "0.5264955", "0.52531147", "0.52404463", "0.52226853", "0.52195644", "0.5207552", "0.52060443", "0.5188808", "0.5188706", "0.51866376", "0.5182186", "0.5178932", "0.5176478", "0.51751256", "0.5173386", "0.51703393", "0.51643884", "0.51617646", "0.51528144", "0.51492596", "0.5146196", "0.51444066", "0.5143242", "0.5141776", "0.51141584", "0.5105823" ]
0.68537563
0
fudge... not clear if volumes support is available as 'native' volume API or as the osvolumes extension. Need to probe to find out (for now) see
def check_if_native(entity) #volumes or snapshots native = extension = false #check if 'native' volume API present: begin response = @connection.req("GET", "/#{entity}") native = true if response.code.match(/^20.$/) return true, entity rescue OpenStack::Exception::ItemNotFound => not_found native = false end #check if available as extension: begin response = @connection.req("GET", "/os-#{entity}") extension = true if response.code.match(/^20.$/) return false, "os-#{entity}" rescue OpenStack::Exception::ItemNotFound => not_found extension = false end raise OpenStack::Exception::NotImplemented.new("No Volumes support for this provider", 501, "No #{entity} Support") unless (native || extension) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_logical_volume_management\n super\n end", "def volume_ls\n help = [\n '',\n \"Use: #{me} volume ls\",\n '',\n 'Lists the names of all cyber-dojo volumes',\n '',\n minitab + '--quiet Only display volume names'\n ]\n\n if ['help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n\n # There is currently no [--filter label=LABEL] option on [docker volume ls]\n # https://github.com/docker/docker/pull/21567\n # So I have to inspect all volumes. Could be slow if lots of volumes.\n\n names = run(\"docker volume ls --quiet\").split\n names = names.select{ |name| cyber_dojo_volume?(name) }\n\n if ARGV[2] == '--quiet'\n names.each { |name| puts name }\n else\n types = names.map { |name| cyber_dojo_type(name) }\n urls = names.map { |name| cyber_dojo_label(name) }\n\n headings = { :name => 'NAME', :type => 'TYPE', :url => 'SRC' }\n\n gap = 3\n max_name = ([headings[:name]] + names).max_by(&:length).length + gap\n max_type = ([headings[:type]] + types).max_by(&:length).length + gap\n max_url = ([headings[:url ]] + urls ).max_by(&:length).length + gap\n\n spaced = lambda { |max,s| s + (space * (max - s.length)) }\n\n name = spaced.call(max_name, headings[:name])\n type = spaced.call(max_type, headings[:type])\n url = spaced.call(max_url , headings[:url ])\n puts name + type + url\n names.length.times do |n|\n name = spaced.call(max_name, names[n])\n type = spaced.call(max_type, types[n])\n url = spaced.call(max_url , urls[n])\n puts name + type + url\n end\n end\nend", "def related_storage_volumes\n related_volumes.find_all do |volume|\n volume.provider_name == \"compellent\" || volume.provider_name == \"vnx\"\n end\n end", "def volume_names\n pool.list_volumes\n end", "def list_volumes\n response = @connection.req(\"GET\", \"/#{@volume_path}\")\n volumes_hash = JSON.parse(response.body)[\"volumes\"]\n volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(current); res}\n end", "def volumes\n @volumes.to_a.freeze\n end", "def volumes\n service.list_pool_volumes uuid\n end", "def getmountedvolumes\n # only support Linux for now\n return {} unless Facter['kernel'] && Facter['kernel'].value == 'Linux'\n\n dir = \"/etc\"\n mounted = {}\n\n # AUTOFS - gather only files named auto[._]*\n Dir.glob(File.join(dir, \"*\")).each do |file|\n next if file !~ /^auto[._].*/\n\n # AUTOFS - match only lines that look like nfs syntax such as host:/path\n IO.foreach(file) do |line|\n if line =~ /\\w:\\S/ && line !~ /^\\s*#/\n # Parse it, Example : \" nventory_backup -noatime,intr irvnetappbk:/vol/nventory_backup \"\n if line =~ /^(\\w[\\w\\S]+)\\s+\\S+\\s+(\\w[\\w\\S]+):(\\S+)/\n mnt = $1\n host = $2\n vol = $3\n mounted[\"volumes[mounted][/mnt/#{mnt}][config]\"] = file\n mounted[\"volumes[mounted][/mnt/#{mnt}][volume_server]\"] = host\n mounted[\"volumes[mounted][/mnt/#{mnt}][volume]\"] = vol\n mounted[\"volumes[mounted][/mnt/#{mnt}][type]\"] = 'nfs'\n end\n end\n end # IO.foreach\n end # Dir.glob\n\n # FSTAB - has diff syntax than AUTOFS. Example: \"server:/usr/local/pub /pub nfs rsize=8192,wsize=8192,timeo=14,intr\"\n IO.foreach(\"/etc/fstab\") do |line|\n if line =~ /^(\\w[\\w\\S]+):(\\S+)\\s+(\\S+)\\s+nfs/\n host = $1\n vol = $2\n mnt = $3\n mounted[\"volumes[mounted][#{mnt}][config]\"] = \"/etc/fstab\"\n mounted[\"volumes[mounted][#{mnt}][volume_server]\"] = host\n mounted[\"volumes[mounted][#{mnt}][volume]\"] = vol\n mounted[\"volumes[mounted][#{mnt}][type]\"] = 'nfs'\n end\n end # IO.foreach\n return mounted\n end", "def is_volume_wrapper?\n volumes = Bplmodels::Finder.getVolumeObjects(pid)\n volumes.present? ? true : false\n end", "def init_ebs_volumes\n @@client.describe_volumes.volumes\n end", "def list_all_volumes\n Docker::Volume.all({}, client)\n rescue\n []\n end", "def mount_kvm_volume(name)\n dev = available_dev\n enable_netblockdev(name, dev)\n vol_grp = lvm_volume_group(\n lvm_partition(dev)\n )\n root = lvm_root(vol_grp)\n lvm_enable(vol_grp) unless lvm_enabled?(root)\n mount(name, root)\n dev\nend", "def volumes\n Collection::StorageVolumeCollection.new(self)\n end", "def volume\n help = [\n '',\n \"Use: #{me} volume [COMMAND]\",\n '',\n 'Manage cyber-dojo setup volumes',\n '',\n 'Commands:',\n minitab + 'create Creates a new volume',\n minitab + 'rm Removes a volume',\n minitab + 'ls Lists the names of all volumes',\n minitab + 'inspect Displays details of a volume',\n minitab + \"pull Pulls the docker images inside a volume's manifest.json files\",\n '',\n \"Run '#{me} volume COMMAND --help' for more information on a command\",\n ]\n case ARGV[1]\n when 'create' then volume_create\n when 'rm' then volume_rm\n when 'ls' then volume_ls\n when 'inspect' then volume_inspect\n when 'pull' then volume_pull\n else show help\n end\nend", "def get_volumes\n volumes = get(\"cloud-instances/#{guid}/volumes\")[\"volumes\"] || []\n\n volumes.map do |volume|\n get_volume(volume[\"volumeID\"])\n end\n end", "def volume_from(name)\n volumes << VolumeFrom.new(name)\n end", "def attach_volumes(node, disk_sizes)\n if $provider == :virtualbox\n node.vm.provider :virtualbox do |v, override|\n disk_num = 0\n disk_sizes.each do |disk_size|\n disk_num += 1\n diskname = File.join(File.dirname(File.expand_path(__FILE__)), \".virtualbox\", \"#{node.vm.hostname}-#{disk_num}.vdi\")\n unless File.exist?(diskname)\n v.customize ['createhd', '--filename', diskname, '--size', disk_size * 1024]\n end\n v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', disk_num, '--device', 0, '--type', 'hdd', '--medium', diskname]\n end\n end\n end\n\n if $provider == :vmware_fusion\n node.vm.provider :vmware_fusion do |v, override|\n vdiskmanager = '/Applications/VMware\\ Fusion.app/Contents/Library/vmware-vdiskmanager'\n unless File.exist?(vdiskmanager)\n dir = File.join(File.dirname(File.expand_path(__FILE__)), \".vmware\")\n unless File.directory?( dir )\n Dir.mkdir dir\n end\n\n disk_num = 0\n disk_sizes.each do |disk_size|\n disk_num += 1\n diskname = File.join(dir, \"#{node.vm.hostname}-#{disk_num}.vmdk\")\n unless File.exist?(diskname)\n `#{vdiskmanager} -c -s #{disk_size}GB -a lsilogic -t 1 #{diskname}`\n end\n\n v.vmx[\"scsi0:#{disk_num}.filename\"] = diskname\n v.vmx[\"scsi0:#{disk_num}.present\"] = 'TRUE'\n v.vmx[\"scsi0:#{disk_num}.redo\"] = ''\n end\n end\n end\n end\n\n if $provider == :parallels\n node.vm.provider :parallels do |v, override|\n disk_sizes.each do |disk_size|\n v.customize ['set', :id, '--device-add', 'hdd', '--size', disk_size * 1024]\n end\n end\n end\n\nend", "def get_volume_id(sys_id,volume_name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/volumes\")\n status(response, 200, 'Failed to get Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n \t return vm['id'] if vm['name'] == volume_name\n \tend\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/thin-volumes\")\n status(response, 200, 'Failed to get thin Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n return vm['id'] if vm['name'] == volume_name\n end\n \tfalse\n end", "def setup_volumes\n # managing planned volumes is currently only needed in Windows and only if\n # this is not a reboot scenario.\n if !RightScale::Platform.windows? || RightScale::InstanceState.reboot?\n boot\n else\n RightScale::AuditProxy.create(@agent_identity, 'Planned volume management') do |audit|\n @audit = audit\n manage_planned_volumes do\n @audit = nil\n boot\n end\n end\n end\n true\n end", "def get_volume\n @volume\n end", "def detachvolume\n false\n end", "def volumes\n client = Aws::EC2::Client.new\n client.describe_volumes({\n filters: [{\n name: \"tag:backup\",\n values: [\"true\"]\n }]\n }).volumes\nend", "def retrieve_volumes\n dbg { \"retrieving #{pool_info}, #{hv_info}\" }\n\n volumes = pool.list_all_volumes\n dbg { \"list_all_volumes #{pool_info}, #{hv_info}\" }\n\n storage_volumes = volumes.map.with_index do |vol, index|\n id = \"#{uuid}--#{index}\"\n StorageVolume.new(vol, pool: self, id: id)\n end\n\n dbg { \"retrieved size=#{storage_volumes.size}, #{pool_info}, #{hv_info}\" }\n storage_volumes\n end", "def guess_usb_volume( dirs_to_sync )\n volumes = Dir.entries(@usb_volumes_dir).reject do |f|\n f.match(/\\.\\.?/) \n end\n volumes.sort_by { |v|\n puts \"Checking volume #{v}\"\n dirs_to_sync.select{ |dts|\n File.directory?( File.join(@usb_volumes_dir, usb, dts))\n }.size\n }[0]\n end", "def test_to_volumes\n v = CI::Container::DirectBindingArray.to_volumes(['/', '/tmp'])\n assert_equal({ '/' => {}, '/tmp' => {} }, v)\n end", "def find_volume(name)\n Volume.new pool.lookup_volume_by_name(name), self\n rescue Libvirt::RetrieveError\n nil\n end", "def volume _value, _abs=0\n send_cmd(\"volume #{_value} #{_abs}\")\n end", "def root_volumes\n volumes.select {|vol| vol.parent_id == nil}\n end", "def find_volume_service(filter)\n select(&service?(filter))\n .find(&volume_mount?)\n end", "def ebs_volumes\n @ebs_volumes ||= init_ebs_volumes.reject do |vol|\n vol.attachments.any? do |att|\n attached_instance = id_instances[att.instance_id]\n attached_instance.root_device_name == att.device\n end\n end\n end", "def exists?\n volumes = Hash.new\n qmgmt(['volume', 'list']).each_line { |l|\n if ( l.match(/^Name/) )\n next\n end\n line = l.split(/\\s{2,}/)\n volumes[line.shift()] = true\n }\n\n if ( volumes[resource[:name]] )\n return true\n else\n return false\n end\n end", "def volumes_list(state = \"active\", limit = \"1000\")\n case state\n when \"active\"\n api_call = {\n :method => \"ListActiveVolumes\",\n :params => {\n :startVolumeID => 0,\n :limit => limit\n }\n }\n when \"deleted\"\n api_call = {\n :method => \"ListDeletedVolumes\",\n :params => {}\n }\n end\n answer = query_sf(api_call)\n return answer[\"volumes\"]\n end", "def volinfo(compute,name)\n\t\tvolumes = compute.describe_volumes\n\t\tif (volumes.status == 200)\n\t\t\t# check each of the volumes in our availability zone which match our name.\n\t\t\tvolumes.body['volumeSet'].each {|x|\n\t\t\t\t# Match the name unless the volume is actually being deleted...\n\t\t\t\tif (x['tagSet']['Name'] == resource[:volume_name] )\n\t\t\t\t\t#print \"ebsvol[aws]->volinfo: Volume #{x['volumeId']} has Name = #{resource[:volume_name]}\\n\" if $debug\n\t\t\t\t\treturn x\n\t\t\t\tend\n\t\t\t}\n\t\telse\n\t\t\traise \"ebsvol[aws]->volinfo: I couldn't list the ebsvolumes\"\n\t\tend\n\t\tnil\n\tend", "def volume\n @cr[0xe] & 0x0f\n end", "def list(opts)\n opts = check_params(opts,[:volume])\n super(opts)\n end", "def lvm_volume_group(partition)\n %x{pvs --noheadings --separator ' ' #{partition} 2>/dev/null| sed -e 's/^\\s*//' | cut -d ' ' -f 2}.strip\nend", "def set_volume(volume)\n puts \"Setting volume to #{volume}\" if $verbose\n v='AG'+(('000'+volume.to_s)[-3..-1])+';'\n puts v if $verbose\n ret=send_cmd(v,'AG;',v,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^AG/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend", "def get_volume()\n return(get_cmd('AG;',0.1,0.5,3).gsub(/^AG/,'').gsub(/;$/,'').to_i)\nend", "def mounted?(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n system(\"mount | grep #{mount_loc}\")\nend", "def volume_create\n help = [\n '',\n \"Use: #{me} volume create --name=VOLUME --git=URL\",\n \"Use: #{me} volume create --name=VOLUME --dir=PATH\",\n '',\n 'Creates a volume named VOLUME from a git clone of URL',\n 'Creates a volume named VOLUME from a copy of PATH'\n ]\n # asked for help?\n if [nil,'help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n # unknown arguments?\n knowns = ['name','git','dir']\n unknown = ARGV[2..-1].select do |argv|\n knowns.none? { |known| argv.start_with?('--' + known + '=') }\n end\n if unknown != []\n show help\n unknown.each { |arg| puts \"FAILED: unknown argument [#{arg.split('=')[0]}]\" }\n exit failed\n end\n # required known arguments\n args = ARGV[2..-1]\n vol = get_arg('--name', args)\n url = get_arg('--git', args)\n dir = get_arg('--dir', args)\n if vol.nil? || (url.nil? && dir.nil?)\n show help\n exit failed\n end\n if vol.length == 1\n msg = 'volume names must be at least two characters long. See https://github.com/docker/docker/issues/20122'\n puts \"FAILED: [volume create --name=#{vol}] #{msg}\"\n exit failed\n end\n if volume_exists? vol\n msg = \"#{vol} already exists\"\n puts \"FAILED: [volume create --name=#{vol}] #{msg}\"\n exit failed\n end\n # cyber-dojo.sh does actual [volume create]\nend", "def child_volumes(name)\n parent = volume_by_name(name)\n volumes.select {|vol| vol.parent_id == parent.volume_id}\n end", "def test_lv_ops\n lvname = \"testlv_#{Time.now.to_i}\"\n bd = nil\n\n #\n # Test creating the LV\n #\n # vgroup does not exist\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('lkjwf99ex', lvname, 1024)\n bd.create\n end\n # invalid lv size\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 100000000024)\n bd.create\n end\n\n assert_nothing_raised do \n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 1024)\n bd.create\n end\n # device is formatted by default, check it\n if `blkid /dev/mapper/localvg-#{lvname}` !~ /TYPE=\"ext3\"/\n assert false\n end\n \n assert(bd.config_string == \"'phy:/dev/localvg/#{lvname},sda1,w'\")\n assert( File.exist? \"/dev/mapper/localvg-#{lvname}\")\n\n # lv already exists\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 1024)\n bd.create\n end\n\n\n #\n # Test formatting the LV\n #\n bd.format\n if `blkid /dev/mapper/localvg-#{lvname}` !~ /TYPE=\"ext3\"/\n assert false\n end\n \n #\n # Test mouting the LV\n #\n mdir = bd.mount\n assert(`mount | grep #{mdir}` =~ /#{mdir}/)\n assert_raises Exception do\n bd.mount\n end\n \n #\n # Test umounting the LV\n #\n bd.umount\n assert(`mount | grep #{mdir}`.strip.chomp.empty?)\n Dir.rmdir mdir\n\n #\n # Test deleting the LV\n #\n bd.delete\n assert( !File.exist?(\"/dev/mapper/localvg-#{lvname}\") )\n end", "def volume(volume_name, attrs={}, &block)\n volumes[volume_name] ||= Ironfan::Volume.new(:parent => self, :name => volume_name)\n volumes[volume_name].configure(attrs, &block)\n volumes[volume_name]\n end", "def volume_type\n return @volume_type\n end", "def create_lvm_volumes( opts = {} )\n opts = deep_merge_hashes( @aws_default_instance_options, opts )\n unless exist?( opts[ :lvm_volumes ].first[1] )\n create_lvm_volumes!( opts )\n end\n end", "def lvm_enable(volume_group)\n puts \"Making volume group available: #{volume_group}\"\n res = system \"vgchange -a y #{volume_group}\"\n raise \"Failed to enable volume group: #{volume_group}\" unless res\nend", "def get_volume(volume_id)\n get(\"cloud-instances/#{guid}/volumes/#{volume_id}\")\n end", "def lvm_root(volume_group)\n %x{lvdisplay #{volume_group} 2>/dev/null| grep root}.split(' ').last.strip\nend", "def is_unmanageable_volume?(mapping)\n case mapping[:volume_status]\n when 'attached', 'attaching', 'detached', 'detaching'\n false\n else\n true\n end\n end", "def volume_rm\n # Allow deletion of a default volume.\n # This allows you to create custom default volumes.\n help = [\n '',\n \"Use: #{me} volume rm VOLUME\",\n '',\n \"Removes a volume created with the [#{me} volume create] command\"\n ]\n\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'rm')\n\n run \"docker volume rm #{vol}\"\n if $exit_status != 0\n puts \"FAILED [volume rm #{vol}] can't remove volume if it's in use\"\n exit failed\n end\n\nend", "def determine_volume\n vol = currently_attached_volume(instance_id, new_resource.device)\n vol_id = new_resource.volume_id || volume_id_in_node_data || ( vol ? vol[:aws_id] : nil )\n raise \"volume_id attribute not set and no volume id is set in the node data for this resource (which is populated by action :create) and no volume is attached at the device\" unless vol_id\n\n # check that volume exists\n vol = volume_by_id(vol_id)\n raise \"No volume with id #{vol_id} exists\" unless vol\n\n vol\n end", "def volume_mount(local_dir, container_dir)\n local_dir = File.expand_path(local_dir, reference_dir)\n volumes << VolumeMount.new(local_dir, container_dir)\n end", "def name\n self['VolumeName']\n end", "def volume(volume_id)\n volumes(volume_id)[0]\n end", "def attach_volumes!(server, volumes_count, size)\n #create a new block storage connection obj\n volume_service = Fog::Volume::OpenStack.new(\n :openstack_api_key => @os_password,\n :openstack_username => @os_username,\n :openstack_auth_url => @os_auth_url,\n :openstack_tenant => @os_tenant,\n )\n base = 'sdd'\n volumes_count.times do |i|\n base = base.next!\n #create a new volume\n vol = volume_service.volumes.create(\n :size => size,\n :display_name => \"#{server.name}-#{i}\",\n :description => \"Volume attached to #{server.name} - managed by ankus\"\n )\n vol.reload\n vol.wait_for { status == 'available' }\n server.attach_volume(vol.id, \"/dev/#{base}\")\n vol.wait_for { status == 'in-use' }\n end\n end", "def mounts_ebs_volumes settings\n has_role settings, \"ebs_volumes_mount\"\nend", "def volume_inspect\n help = [\n '',\n \"Use: #{me} volume inspect VOLUME\",\n '',\n 'Displays details of the named cyber-dojo volume',\n ]\n # asked for help?\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n # TODO: check for unknown args\n\n exit_unless_is_cyber_dojo_volume(vol, 'inspect')\n\n command =\n [\n 'docker run',\n '--rm',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_inspect.rb /data'\"\n ].join(space=' ')\n\n print run(command)\nend", "def volumes_list(options = {})\n state = options.fetch(:state, 'active')\n startid = options.fetch(:startid, 0)\n limit = options.fetch(:limit, 1000)\n accounts = options.fetch(:accountid, nil)\n name = options.fetch(:name, nil)\n \n if name\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :VolumeName => name,\n :limit => 1\n }\n }\n elsif accounts\n accounts = [ accounts ] if accounts.class == String || Integer\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :accounts => accounts,\n :limit => limit\n }\n }\n else\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :VolumeStatus => state,\n :startVolumeID => startid,\n :limit => limit\n }\n }\n end\n\n answer = query_sf(api_call)\n return answer[\"volumes\"]\n end", "def extra_volumes(base_name)\n configs = []\n\n config[:extra_volumes].each_with_index do |data, index|\n disk_id = (index + 1).to_s.rjust(2, '0')\n data[:name] = \"#{base_name}-extra-#{disk_id}\"\n configs << data\n end\n\n configs\n end", "def domain_volumes\n # Use the domain name as our volume base name.\n base_name = domain_name\n\n if not config[:image_name]\n config[:image_name] = default_image\n end\n\n # Clone our root volume from our base image.\n root_volume = clone_volume(config[:image_name], \"#{base_name}-root\")\n\n # Return the array of created volumes\n [root_volume].concat(\n create_volumes(\n extra_volumes(base_name)\n )\n )\n end", "def volume; property('volume'); end", "def prompt_volumes(plan_info, provision_type, options={}, api_client=nil, api_params={})\n #puts \"Configure Volumes:\"\n # return [] if plan_info['noDisks']\n\n no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))\n volumes = []\n plan_size = nil\n if plan_info['maxStorage']\n plan_size = plan_info['maxStorage'].to_i / (1024 * 1024 * 1024)\n end\n root_storage_types = []\n if plan_info['rootStorageTypes']\n plan_info['rootStorageTypes'].sort {|x,y| x['displayOrder'] <=> y['displayOrder'] }.each do |opt|\n if !opt.nil?\n root_storage_types << {'name' => opt['name'], 'value' => opt['id']}\n end\n end\n end\n\n storage_types = []\n if plan_info['storageTypes']\n plan_info['storageTypes'].sort {|x,y| x['displayOrder'] <=> y['displayOrder'] }.each do |opt|\n if !opt.nil?\n storage_types << {'name' => opt['name'], 'value' => opt['id']}\n end\n end\n end\n\n datastore_options = []\n if plan_info['supportsAutoDatastore']\n if plan_info['autoOptions']\n plan_info['autoOptions'].each do |opt|\n if !opt.nil?\n datastore_options << {'name' => opt['name'], 'value' => opt['id']}\n end\n end\n end\n end\n if plan_info['datastores']\n plan_info['datastores'].each do |k, v|\n v.each do |opt|\n if !opt.nil?\n k = 'datastores' if k == 'store'\n k = 'clusters' if k == 'cluster'\n datastore_options << {'name' => \"#{k}: #{opt['name']}\", 'value' => opt['id']}\n end\n end\n end\n end\n # api does not always return datastores, so go get them if needed..\n if plan_info['hasDatastore'] && datastore_options.empty?\n option_results = options_interface.options_for_source('datastores', api_params)\n option_results['data'].each do |it|\n datastore_options << {\"id\" => it[\"value\"] || it[\"id\"], \"name\" => it[\"name\"], \"value\" => it[\"value\"] || it[\"id\"]}\n end\n end\n\n #puts \"Configure Root Volume\"\n\n field_context = \"rootVolume\"\n\n volume_label = options[:root_volume_name] || 'root'\n volume = {\n 'id' => -1,\n 'rootVolume' => true,\n 'name' => volume_label,\n 'size' => plan_size,\n 'sizeId' => nil,\n 'storageType' => nil,\n 'datastoreId' => nil\n }\n if options[:options] && options[:options]['volumes'] && options[:options]['volumes'][0]\n volume = options[:options]['volumes'][0]\n end\n\n if root_storage_types.empty?\n # this means there's no configuration, just send a single root volume to the server\n storage_type_id = nil\n storage_type = nil\n else\n default_storage_type = root_storage_types.find {|t| t['value'].to_s == volume['storageType'].to_s}\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'storageType', 'type' => 'select', 'fieldLabel' => 'Root Storage Type', 'selectOptions' => root_storage_types, 'required' => true, 'defaultFirstOption' => true, 'skipSingleOption' => true, 'description' => 'Choose a storage type.', 'defaultValue' => default_storage_type ? default_storage_type['name'] : volume['storageType']}], options[:options])\n storage_type_id = v_prompt[field_context]['storageType']\n storage_type = plan_info['storageTypes'].find {|i| i['id'] == storage_type_id.to_i }\n volume['storageType'] = storage_type_id\n end\n\n # sometimes the user chooses sizeId from a list of size options (AccountPrice) and other times it is free form\n root_custom_size_options = []\n if plan_info['rootCustomSizeOptions'] && plan_info['rootCustomSizeOptions'][storage_type_id.to_s]\n plan_info['rootCustomSizeOptions'][storage_type_id.to_s].each do |opt|\n if !opt.nil?\n root_custom_size_options << {'name' => opt['value'], 'value' => opt['key']}\n end\n end\n end\n\n if plan_info['rootDiskCustomizable'] && storage_type && storage_type['customLabel']\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => 'Root Volume Label', 'required' => true, 'description' => 'Enter a volume label.', 'defaultValue' => volume['name']}], options[:options])\n volume['name'] = v_prompt[field_context]['name']\n end\n if plan_info['rootDiskCustomizable'] && storage_type && storage_type['customSize']\n # provision_type['rootDiskSizeKnown'] == false means size cannot be changed\n if provision_type['rootDiskSizeKnown'] == false\n # volume['size'] = plan_size if plan_size.to_i != 0\n else\n if root_custom_size_options.empty?\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'size', 'type' => 'number', 'fieldLabel' => 'Root Volume Size (GB)', 'required' => true, 'description' => 'Enter a volume size (GB).', 'defaultValue' => volume['size']}], options[:options])\n volume['size'] = v_prompt[field_context]['size']\n volume['sizeId'] = nil #volume.delete('sizeId')\n else\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'sizeId', 'type' => 'select', 'fieldLabel' => 'Root Volume Size', 'selectOptions' => root_custom_size_options, 'required' => true, 'description' => 'Choose a volume size.', 'defaultValue' => volume['sizeId']}], options[:options])\n volume['sizeId'] = v_prompt[field_context]['sizeId']\n volume['size'] = nil #volume.delete('size')\n end\n end\n else\n # might need different logic here ? =o\n #volume['size'] = plan_size\n #volume['sizeId'] = nil #volume.delete('sizeId')\n end\n \n if !datastore_options.empty?\n default_datastore = datastore_options.find {|ds| ds['value'].to_s == volume['datastoreId'].to_s}\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'datastoreId', 'type' => 'select', 'fieldLabel' => 'Root Datastore', 'selectOptions' => datastore_options, 'required' => true, 'description' => 'Choose a datastore.', 'defaultValue' => default_datastore ? default_datastore['name'] : volume['datastoreId']}], options[:options])\n volume['datastoreId'] = v_prompt[field_context]['datastoreId']\n end\n\n volumes << volume\n\n if plan_info['addVolumes']\n volume_index = 1\n has_another_volume = (options[:options] && options[:options][\"dataVolume#{volume_index}\"]) || (options[:options] && options[:options]['volumes'] && options[:options]['volumes'][volume_index])\n add_another_volume = has_another_volume || (!no_prompt && Morpheus::Cli::OptionTypes.confirm(\"Add data volume?\", {:default => (options[:defaultAddFirstDataVolume] == true && volume_index == 1)}))\n while add_another_volume do\n #puts \"Configure Data #{volume_index} Volume\"\n\n field_context = \"dataVolume#{volume_index}\"\n\n volume_label = (volume_index == 1 ? 'data' : \"data #{volume_index}\")\n volume = {\n #'id' => -1,\n 'rootVolume' => false,\n 'name' => volume_label,\n 'size' => plan_size,\n 'sizeId' => nil,\n 'storageType' => nil,\n 'datastoreId' => nil\n }\n if options[:options] && options[:options]['volumes'] && options[:options]['volumes'][volume_index]\n volume = options[:options]['volumes'][volume_index]\n end\n\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'storageType', 'type' => 'select', 'fieldLabel' => \"Disk #{volume_index} Storage Type\", 'selectOptions' => storage_types, 'required' => true, 'defaultFirstOption' => true, 'skipSingleOption' => true, 'description' => 'Choose a storage type.', 'defaultValue' => volume['storageType']}], options[:options])\n storage_type_id = v_prompt[field_context]['storageType']\n volume['storageType'] = storage_type_id\n storage_type = plan_info['storageTypes'].find {|i| i['id'] == storage_type_id.to_i }\n\n # sometimes the user chooses sizeId from a list of size options (AccountPrice) and other times it is free form\n custom_size_options = []\n if plan_info['customSizeOptions'] && plan_info['customSizeOptions'][storage_type_id.to_s]\n plan_info['customSizeOptions'][storage_type_id.to_s].each do |opt|\n if !opt.nil?\n custom_size_options << {'name' => opt['value'], 'value' => opt['key']}\n end\n end\n end\n\n if plan_info['customizeVolume'] && storage_type['customLabel']\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => \"Disk #{volume_index} Volume Label\", 'required' => true, 'description' => 'Enter a volume label.', 'defaultValue' => volume['name']}], options[:options])\n volume['name'] = v_prompt[field_context]['name']\n end\n if plan_info['customizeVolume'] && storage_type['customSize']\n if custom_size_options.empty?\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'size', 'type' => 'number', 'fieldLabel' => \"Disk #{volume_index} Volume Size (GB)\", 'required' => true, 'description' => 'Enter a volume size (GB).', 'defaultValue' => volume['size']}], options[:options])\n volume['size'] = v_prompt[field_context]['size']\n volume['sizeId'] = nil #volume.delete('sizeId')\n else\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'sizeId', 'type' => 'select', 'fieldLabel' => \"Disk #{volume_index} Volume Size\", 'selectOptions' => custom_size_options, 'required' => true, 'description' => 'Choose a volume size.', 'defaultValue' => volume['sizeId']}], options[:options])\n volume['sizeId'] = v_prompt[field_context]['sizeId']\n volume['size'] = nil #volume.delete('size')\n end\n else\n # might need different logic here ? =o\n volume['size'] = plan_size\n volume['sizeId'] = nil #volume.delete('sizeId')\n end\n if !datastore_options.empty?\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'datastoreId', 'type' => 'select', 'fieldLabel' => \"Disk #{volume_index} Datastore\", 'selectOptions' => datastore_options, 'required' => true, 'description' => 'Choose a datastore.', 'defaultValue' => volume['datastoreId']}], options[:options])\n volume['datastoreId'] = v_prompt[field_context]['datastoreId']\n end\n\n volumes << volume\n\n volume_index += 1\n if options[:options] && options[:options]['volumes'] && options[:options]['volumes'][volume_index]\n add_another_volume = true\n elsif plan_info['maxDisk'] && volume_index >= plan_info['maxDisk']\n # todo: should maxDisk check consider the root volume too?\n add_another_volume = false\n else\n has_another_volume = options[:options] && options[:options][\"dataVolume#{volume_index}\"]\n add_another_volume = has_another_volume || (!no_prompt && Morpheus::Cli::OptionTypes.confirm(\"Add another data volume?\", {:default => false}))\n end\n\n end\n\n end\n\n return volumes\n end", "def provision_storage host, vm\n if host['volumes']\n # Lazily create the volume client if needed\n volume_client_create\n host['volumes'].keys.each_with_index do |volume, index|\n @logger.debug \"Creating volume #{volume} for OpenStack host #{host.name}\"\n\n # The node defintion file defines volume sizes in MB (due to precedent\n # with the vagrant virtualbox implementation) however OpenStack requires\n # this translating into GB\n openstack_size = host['volumes'][volume]['size'].to_i / 1000\n\n # Create the volume and wait for it to become available\n vol = @volume_client.volumes.create(\n :size => openstack_size,\n :display_name => volume,\n :description => \"Beaker volume: host=#{host.name} volume=#{volume}\",\n )\n vol.wait_for { ready? }\n\n # Fog needs a device name to attach as, so invent one. The guest\n # doesn't pay any attention to this\n device = \"/dev/vd#{('b'.ord + index).chr}\"\n vm.attach_volume(vol.id, device)\n end\n end\n end", "def volumes(value_only: true)\n varfields('v', value_only: value_only)\n end", "def volumes\n volumes = @ec2.volumes\n volumes.delete_if {|v| v.instance_id != id}\n end", "def create_default_volume()\n # Create a default application_volume using the volume attributes from the cookbook\n create_node_volume(:application_volume)\n end", "def volume; self.class.volume; end", "def getVolumes\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view volumes\" }, :unauthorized)\n return\n end\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/volume'\n\n # Create request for Service Manager\n stack = {\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, 200)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end", "def storage_volume(storage_volume_id)\n from_resource :storage_volume,\n connection.get(api_uri(\"storage_volumes/#{storage_volume_id}\"))\n end", "def storage_list(mixins = nil)\n storages = Occi::Core::Resources.new\n\n Backends::Ec2::Helpers::AwsConnectHelper.rescue_aws_service(@logger) do\n volumes = @ec2_client.describe_volumes.volumes\n volumes.each do |volume|\n next unless volume\n storages << storage_parse_backend_obj(volume)\n end if volumes\n end\n\n storages\n end", "def fetch_volume_by_id\n vol = storage_api.find_by_id(volume_id)\n data = vol.body.fetch(\"volume\")\n @name = data.fetch('display_name')\n @volume_type = data.fetch('volume_type')\n @size = data.fetch('size')\n\n # Sometimes the Rackspace API takes time to update,\n # and newly-attached volumes don't report any attachments\n # yet.\n attachments = data.fetch('attachments')\n if attachments.any?\n @device = attachments.first.fetch('device')\n end\n end", "def volume_adjustment_index(type=TagLib::ID3v2::RelativeVolumeFrame::MasterVolume)\n end", "def storage_use_nfs\n super\n end", "def currently_attached_volume(instance_id, device)\n ec2.describe_volumes.find{|v| v[:aws_instance_id] == instance_id && v[:aws_device] == device}\n end", "def create_volume(volume_name, config:, **kwargs)\n object = { name: volume_name }.merge(config).merge(kwargs)\n log.info \"Creating volume: #{object}\"\n volumes << object\n end", "def volume(level = nil)\n level.nil? ? Integer(connection.write(\"volume\", false)) : connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end", "def is_unmanaged_attached_volume?(mapping)\n case mapping[:volume_status]\n when 'attached', 'attaching'\n mapping[:management_status].nil?\n else\n false\n end\n end", "def update_volume_info\n\t\t#\t\t@pool = Pool.find(self.pool_id)\n\t\t#\t\t@host = Host.find(@pool.host_id)\n\t\t#\n\t\t#\t\tconnection = ConnectionsManager.instance\n\t\t#\t\tconnection_hash = connection.get(@host.name)\n\t\t#\t\tconn = connection_hash[:conn]\n\n\t\t# get pool reference in order to get a reference to the volume\n\t\t@pool = @conn.lookup_storage_pool_by_name(@pool.name)\n\t\tvolume = @pool.lookup_volume_by_name(self.name)\n\t\tvolume_info = volume.info\n\t\t\n\t\t# add some stats to pool object\n\t\tdivide_to_gigabytes = (1024 * 1024 * 1024).to_f\n\t\tself.allocation = (volume_info.allocation.to_f / divide_to_gigabytes).to_f\n\tend", "def manage_planned_volumes(&block)\n # state may have changed since timer calling this method was added, so\n # ensure we are still booting (and not stranded).\n return if InstanceState.value == 'stranded'\n\n # query for planned volume mappings belonging to instance.\n last_mappings = InstanceState.planned_volume_state.mappings || []\n payload = {:agent_identity => @agent_identity}\n req = RetryableRequest.new(\"/storage_valet/get_planned_volumes\", payload, :retry_delay => VolumeManagement::VOLUME_RETRY_SECONDS)\n req.callback do |res|\n res ||= [] # res is nil or an array of hashes\n begin\n mappings = merge_planned_volume_mappings(last_mappings, res)\n InstanceState.planned_volume_state.mappings = mappings\n if mappings.empty?\n # no volumes requiring management.\n @audit.append_info(\"This instance has no planned volumes.\")\n block.call if block\n elsif (detachable_volume_count = mappings.count { |mapping| is_unmanaged_attached_volume?(mapping) }) >= 1\n # must detach all 'attached' volumes if any are attached (or\n # attaching) but not yet managed on the instance side. this is the\n # only way to ensure they receive the correct device names.\n mappings.each do |mapping|\n if is_unmanaged_attached_volume?(mapping)\n detach_planned_volume(mapping) do\n detachable_volume_count -= 1\n if 0 == detachable_volume_count\n # add a timer to resume volume management later and pass the\n # block for continuation afterward (unless detachment stranded).\n Log.info(\"Waiting for volumes to detach for management purposes. \"\\\n \"Retrying in #{VolumeManagement::VOLUME_RETRY_SECONDS} seconds...\")\n EM.add_timer(VolumeManagement::VOLUME_RETRY_SECONDS) { manage_planned_volumes(&block) }\n end\n end\n end\n end\n elsif mapping = mappings.find { |mapping| is_detaching_volume?(mapping) }\n # we successfully requested detachment but status has not\n # changed to reflect this yet.\n Log.info(\"Waiting for volume #{mapping[:volume_id]} to fully detach. \"\\\n \"Retrying in #{VolumeManagement::VOLUME_RETRY_SECONDS} seconds...\")\n EM.add_timer(VolumeManagement::VOLUME_RETRY_SECONDS) { manage_planned_volumes(&block) }\n elsif mapping = mappings.find { |mapping| is_managed_attaching_volume?(mapping) }\n Log.info(\"Waiting for volume #{mapping[:volume_id]} to fully attach. Retrying in #{VolumeManagement::VOLUME_RETRY_SECONDS} seconds...\")\n EM.add_timer(VolumeManagement::VOLUME_RETRY_SECONDS) { manage_planned_volumes(&block) }\n elsif mapping = mappings.find { |mapping| is_managed_attached_unassigned_volume?(mapping) }\n manage_volume_device_assignment(mapping) do\n unless InstanceState.value == 'stranded'\n # we can move on to next volume 'immediately' if volume was\n # successfully assigned its device name.\n if mapping[:management_status] == 'assigned'\n EM.next_tick { manage_planned_volumes(&block) }\n else\n Log.info(\"Waiting for volume #{mapping[:volume_id]} to initialize using \\\"#{mapping[:mount_points].first}\\\". \"\\\n \"Retrying in #{VolumeManagement::VOLUME_RETRY_SECONDS} seconds...\")\n EM.add_timer(VolumeManagement::VOLUME_RETRY_SECONDS) { manage_planned_volumes(&block) }\n end\n end\n end\n elsif mapping = mappings.find { |mapping| is_detached_volume?(mapping) }\n attach_planned_volume(mapping) do\n unless InstanceState.value == 'stranded'\n unless mapping[:attempts]\n @audit.append_info(\"Attached volume #{mapping[:volume_id]} using \\\"#{mapping[:mount_points].first}\\\".\")\n Log.info(\"Waiting for volume #{mapping[:volume_id]} to appear using \\\"#{mapping[:mount_points].first}\\\". \"\\\n \"Retrying in #{VolumeManagement::VOLUME_RETRY_SECONDS} seconds...\")\n end\n EM.add_timer(VolumeManagement::VOLUME_RETRY_SECONDS) { manage_planned_volumes(&block) }\n end\n end\n elsif mapping = mappings.find { |mapping| is_unmanageable_volume?(mapping) }\n strand(\"State of volume #{mapping[:volume_id]} was unmanageable: #{mapping[:volume_status]}\")\n else\n # all volumes are managed and have been assigned and so we can proceed.\n block.call if block\n end\n rescue Exception => e\n strand(e)\n end\n end\n\n req.errback do |res|\n strand(\"Failed to retrieve planned volume mappings\", res)\n end\n\n req.run\n end", "def mount_ephemerals(attrs={})\n owner.volume(:ephemeral0, attrs){ device '/dev/sdb'; volume_id 'ephemeral0' ; mount_point '/mnt' ; tags( :bulk => true, :local => true, :fallback => true) } if flavor_info[:ephemeral_volumes] > 0\n owner.volume(:ephemeral1, attrs){ device '/dev/sdc'; volume_id 'ephemeral1' ; mount_point '/mnt2'; tags( :bulk => true, :local => true, :fallback => true) } if flavor_info[:ephemeral_volumes] > 1\n owner.volume(:ephemeral2, attrs){ device '/dev/sdd'; volume_id 'ephemeral2' ; mount_point '/mnt3'; tags( :bulk => true, :local => true, :fallback => true) } if flavor_info[:ephemeral_volumes] > 2\n owner.volume(:ephemeral3, attrs){ device '/dev/sde'; volume_id 'ephemeral3' ; mount_point '/mnt4'; tags( :bulk => true, :local => true, :fallback => true) } if flavor_info[:ephemeral_volumes] > 3\n end", "def vol_status(vs, vol_id)\n vol = vs.volumes.get(vol_id)\n unless vol.status == 'available'\n # puts \"vol status is not 'available' it is '#{status}' instead\"\n @log.error 'vol is not avaiable to delete'\n exit 2\n end\n end", "def adopt_existing_volumes!\n Volume.all.each do |ec2_vol|\n next if ec2_vol.deleted? || ec2_vol.deleting?\n instance = Instance.find(ec2_vol.attached_instance_id) ; p instance ; next unless instance\n cluster_node_id = instance.get_cluster_node_id(self.name) ; next unless cluster_node_id\n cluster_vol_id = cluster_node_id + '-' + ec2_vol.device\n volume_in_cluster = @all_volumes[cluster_vol_id] ; next unless volume_in_cluster\n ec2_vol.update! volume_in_cluster.logical_attributes\n @all_volumes[cluster_vol_id] = ec2_vol\n end\n end", "def volume_count\n return unless exists?\n Dir.glob(folder_pathname.join(\"**\")).count do |file|\n File.directory?(file)\n end\n end", "def get_osx_disk_name(options)\n message = \"Information:\\tGetting root disk device ID\"\n command = \"df |grep '/$' |awk '{print \\\\$1}'\"\n output = execute_command(options,message,command)\n disk_id = output.chomp\n message = \"Information:\\tGetting volume name for \"+disk_id\n command = \"diskutil info #{disk_id} | grep 'Volume Name' |cut -f2 -d':'\"\n output = execute_command(options,message,command)\n volume = output.chomp.gsub(/^\\s+/,\"\")\n return volume\nend", "def volume_create(name)\n @log.info \"Creating volume #{name} from offering id #{DISK_OFFERING}...\"\n ret = @cloud_stack.create_volume(name, ZONE, DISK_OFFERING)\n id = ret[\"createvolumeresponse\"][\"jobid\"]\n wait_for_job id\n vol_id = ret[\"createvolumeresponse\"][\"id\"]\n @log.info \"Created volume id: #{vol_id}\"\n vol_id\n end", "def volume(options)\n options[:width] * options[:height] * options[:depth]\nend", "def create\n properties = [ resource[:name],\n resource[:user],\n resource[:group],\n resource[:config],\n resource[:mode],\n ]\n\n qmgmt(['volume', 'create'] + properties)\n end", "def prepareVolumeUtils\n if (@VolumeUtils == nil)\n require 'WSK/VolumeUtils/VolumeUtils'\n @VolumeUtils = WSK::VolumeUtils::VolumeUtils.new\n end\n end", "def check_volume(volume) \n # Default warning_limit\n warning_limit=@warning_limit\n # Default critical_limit\n critical_limit=@critical_limit\n # Default nobackup_status\n nobackup_status=@nobackup_status\n\n puts \"Checking volume: #{volume}\" if @verbose\n\n if @objects.has_key?(volume) and not @objects[volume].has_key?(:skip)\n vol=DuplicityVolume.new(volume,@config_values,@objects[volume])\n vol.debug=@debug\n vol.testing=@testing\n vol.run(\"col\")\n\n puts \" Checking vol: #{volume} last backup: #{vol.last_backup}\" if @verbose\n warning_limit=@objects[volume][:warning_limit] if @objects[volume].has_key? :warning_limit\n\t puts \" warning_limit for #{volume} is #{warning_limit}\" if @debug\n critical_limit=@objects[volume][:critical_limit] if @objects[volume].has_key? :critical_limit\n\t puts \" critical_limit for #{volume} is #{critical_limit}\" if @debug\n nobackup_status=@objects[volume][:nobackup_status] if @objects[volume].has_key? :nobackup_status\n\t puts \" nobackup_status for #{volume} is #{nobackup_status}\" if @debug\n # Check backup age\n check_time=Time.now\n if vol.last_backup\n if check_time < vol.last_backup + warning_limit.to_i\n incstatus(\"OK\")\n elsif check_time >= vol.last_backup + warning_limit.to_i and check_time < vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"WARNING\")\n elsif check_time >= vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"CRITICAL\")\n end\n else\n @short+=\"no backups for #{vol.name}, \"\n @long+=\"No backups found for volume #{vol.name}\\n\"\n incstatus(nobackup_status)\n end\n else\n puts \"ERROR: Volume #{volume} is not defined\"\n return false\n end\n end", "def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end", "def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end", "def populate_volume(server)\n server.spot_check_command(\" echo \\\"blah blah blah\\\" > #{@mount_point}/data.txt\")\n end", "def set_volume(volume)\n %x{#{echo()} volume #{volume} 1 > #{fifo()}} if running?\n end", "def display_host(hostname, partitions)\n volume_groups = {}\n lvm_members = []\n\n puts hostname\n partitions.keys.sort.each do |partition|\n if partitions[partition]['filesystem'] == 'LVM2_member'\n lvm_members << partition\n next\n end\n next if partition == '/dev/mapper/rootvg-swap'\n next if partition == '/dev/mapper/rootvg-afscache'\n next unless partition.match(/^\\/dev\\/mapper\\/(\\S+)-(\\S+)/)\n\n vg = $~[1]\n short_partition = $~[2]\n volume_groups[vg] = [] unless volume_groups.key?(vg)\n volume_groups[vg] << partition\n end\n\n puts \"LVM partitions: \" + lvm_members.sort.join(', ')\n puts 'lvm::volume_groups:'\n volume_groups.keys.sort.each do |vg|\n puts \" #{vg}:\"\n puts ' logical_volumes:'\n volume_groups[vg].sort.each do |partition|\n\n next unless partition.match(/^\\/dev\\/mapper\\/\\S+-(\\S+)/)\n short_partition = $~[1]\n\n # Skip the partition if it's an expected size.\n space = format_space(partition, partitions[partition]['size'].to_s)\n next if space.nil?\n\n # Find if this is a known volume and set the mount to nil then, so we\n # don't print in useless data.\n mount = format_mount(partition, partitions[partition]['mount'].to_s)\n\n puts ' ' + short_partition + ':'\n puts ' ' + 'size: ' + space\n puts ' ' + 'mountpath: ' + mount unless mount.nil?\n puts ' ' + 'fs_type: ' + partitions[partition]['filesystem'].to_s unless mount.nil?\n end\n end\n\n puts\nend", "def list_partitions #by nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{print $1}'`.chomp.split\nend", "def create_volume(options)\n # Creating the volume is part of the server creation\n end", "def create_volume(options)\n # Creating the volume is part of the server creation\n end", "def all_devices search = nil\n partitions = []\n devices = []\n device = nil\n has_extended = false\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"lsblk\"\n params = \" #{search} -b -P -o VENDOR,MODEL,TYPE,SIZE,KNAME,UUID,LABEL,MOUNTPOINT,FSTYPE,RM\"\n end\n lsblk = CommandsExecutor.new command, params\n lsblk.execute\n raise \"Command execution error: #{lsblk.stderr.read}\" if not lsblk.success?\n\n lsblk.result.each_line do |line|\n data_hash = {}\n line.squish!\n line_data = line.gsub!(/\"(.*?)\"/, '\\1#').split \"#\"\n line_data.each do |data|\n data.strip!\n key, value = data.split \"=\"\n data_hash[key.downcase] = value\n end\n data_hash['rm'] = data_hash['rm'].to_i # rm = 1 if device is a removable/flash device, otherwise 0\n if data_hash['type'] == 'mpath'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n if device\n multipath_info = {'mkname' => data_hash['kname'], 'multipath' => true, 'size' => data_hash['size']}\n device.merge! multipath_info\n else\n data_hash['multipath'] = true\n device = data_hash\n devices.push device\n end\n next\n end\n if data_hash['type'] == 'disk'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n unless device.nil?\n device['partitions'] = partitions\n partitions = []\n devices.push device\n device = nil # cleanup the variable\n end\n device = data_hash\n next\n end\n if data_hash['type'] == 'part'\n data_hash.except!('model', 'vendor')\n data_hash.merge! self.usage data_hash['kname']\n\n partition_number = get_partition_number \"/dev/#{data_hash['kname']}\" # For reference: data_hash['kname'].match(/[0-9]*$/)[0].to_i\n extended_partition_types = ['0x05'.hex, '0x0F'.hex]\n if partition_type_hex(data_hash['kname']).in? extended_partition_types\n has_extended = true\n next\n end\n if has_extended and partition_number > 4\n data_hash['logical'] = true\n end\n # device['partitions'].nil? ? device['partitions'] = [data_hash] : device['partitions'].push(data_hash)\n partitions.push(data_hash)\n end\n end\n device['partitions'] = partitions if device\n devices.push device\n if search\n return devices.first || partitions.first\n else\n return devices\n end\n end", "def existing_kvms\n Dir.glob(File.join(KVM_HOME, 'storage', '*.qcow2')).map do |file|\n File.basename(file).sub('.qcow2', '')\n end\nend", "def take_snapshots\n snapped_volumes = []\n logger.debug \"Issuing sync command\"\n system 'sync'\n\n logger.debug \"Walking attached volumes\"\n attached_volumes.each do |vol|\n dir = device_to_directory device_name vol\n logger.debug \"Found #{vol.id} mounted on #{dir}\"\n unless should_snap vol\n logger.debug \"Skipping #{vol.id}\"\n next\n end\n\n fs_freeze dir if options[:fs_freeze]\n take_snapshot vol\n snapped_volumes.push vol\n fs_unfreeze dir if options[:fs_freeze]\n end\n snapped_volumes\n end" ]
[ "0.7116416", "0.67454046", "0.6697699", "0.6587313", "0.656973", "0.6462391", "0.6437726", "0.64210707", "0.64145184", "0.6413992", "0.6393829", "0.63899267", "0.6353122", "0.6324131", "0.6323875", "0.62404746", "0.62152493", "0.6207825", "0.6199918", "0.61632556", "0.6161689", "0.6105621", "0.6102063", "0.6069906", "0.60505986", "0.59938794", "0.598592", "0.5982433", "0.5966877", "0.5950895", "0.5926609", "0.5914062", "0.5912993", "0.59009326", "0.5888726", "0.58686036", "0.5861772", "0.58559734", "0.5854837", "0.5839014", "0.583305", "0.5830997", "0.5827824", "0.5824316", "0.5824081", "0.5821432", "0.58126014", "0.5802964", "0.5783934", "0.57804245", "0.5778821", "0.5727997", "0.5717089", "0.57162577", "0.5716231", "0.5715678", "0.5715032", "0.5712952", "0.5712098", "0.5707685", "0.5696401", "0.5692147", "0.56801045", "0.5679208", "0.5660723", "0.56551945", "0.5637102", "0.5628611", "0.5606179", "0.56002635", "0.55733544", "0.5569704", "0.55538285", "0.5542154", "0.55352265", "0.5526043", "0.5518908", "0.55046296", "0.55028015", "0.5502304", "0.5500732", "0.5498174", "0.5493958", "0.5491293", "0.54911", "0.54672396", "0.5467219", "0.5461662", "0.5455601", "0.5451928", "0.5451928", "0.54519075", "0.5439532", "0.5435121", "0.54346853", "0.5429954", "0.5429954", "0.54268736", "0.54256344", "0.5421179" ]
0.6624592
3
Return a list of ORFs delimited by STOP codons.
def get_stopstop_orfs get_codon_orfs1(Proc.new { | codon | STOP_CODONS.include?(codon) },false,true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_startstop_orfs \n get_codon_orfs2(\n Proc.new { | codon | STOP_CODONS.include?(codon) },\n Proc.new { | codon | START_CODONS.include?(codon) })\n end", "def orfs_from_start_stop_markers(start_markers, stop_markers, minimum_orf_length)\n # Split up the start and stop positions into 3 frames\n frame_starts = [[],[],[]]\n frame_stops = [[],[],[]]\n start_markers.each do |marker|\n frame_starts[marker.position_in_trail % 3].push marker\n end\n stop_markers.each do |marker|\n frame_stops[marker.position_in_trail % 3].push marker\n end\n\n # For each frame\n to_return = ORFsResult.new\n (0..2).each do |frame|\n frame_pairs = []\n\n # Sort arrays in descending order because Array#pop removes from the end of the array\n starts = frame_starts[frame].sort{|a,b| b.position_in_trail<=>a.position_in_trail}\n stops = frame_stops[frame].sort{|a,b| b.position_in_trail<=>a.position_in_trail}\n\n current_start = starts.pop\n current_stop = stops.pop\n if current_stop\n # Record first stop codon\n to_return.initial_stop_markers.push current_stop\n end\n if current_start and (current_stop.nil? or current_start.position_in_trail < current_stop.position_in_trail)\n # Record first start codon before any stop codons\n to_return.initial_start_markers.push current_start\n end\n\n while current_start and current_stop\n # Move to next start after current stop\n while current_start and current_start.position_in_trail < current_stop.position_in_trail\n current_start = starts.pop\n end\n\n if current_start\n # Move to next stop after current start\n while current_stop and current_stop.position_in_trail < current_start.position_in_trail\n current_stop = stops.pop\n end\n end\n\n if current_start and current_stop\n # This stop codon stops the current reading frame.\n if current_stop.position_in_trail - current_start.position_in_trail >= minimum_orf_length\n # Found a legit ORF\n to_return.start_stop_pairs.push [current_start, current_stop]\n end\n # Whether or not last ORF was long enough, search for the next start codon\n next\n else\n if current_start\n to_return.final_start_markers.push current_start\n end\n break\n end\n end\n end\n\n return to_return\n end", "def stopstop minsize=30\n type = \"XX\"\n orfs = []\n translate = Nucleotide::Translate.new(@trn_table)\n aa_frames = translate.aa_frames(@seq)\n num = 0\n aa_frames.each do | aa_frame |\n frame = aa_frame[:frame]\n aa = aa_frame[:sequence]\n aa_start = 0\n aa.split(/\\*/).each do | candidate |\n if candidate.size >= minsize and candidate.size > 0\n orf = ORF.new(num,type,@id,@descr,@seq,frame,aa_start*3,candidate)\n orfs.push orf\n num += 1\n end\n aa_start += candidate.size + 1\n end\n end\n orfs.sort\n end", "def getOr_ r\n or_= []; del_ = []; cur = []\n status = :start\n x = 0\n while x < r.length do\n if r[x] == OR_OPERATOR\n if status == :start\n cur = [r[x-1]]\n status = :cont\n del_.push x-1\n end\n cur.push r[x+1]\n del_ += [x, x+1]\n x += 2\n else\n if status == :cont\n status = :start\n or_.push cur\n cur = []\n end\n x += 1\n end\n end\n if not cur.empty?\n or_.push cur\n end\n return or_, del_\n end", "def getting_stops on_line, on_stop, off_line, off_stop\n\tstops = []\n\n\tif is_same_line(on_line, off_line)\n\t\texit if on_line.index(on_stop) == on_line.index(off_stop) \n\t\t\t\n\t\tstops << (on_line[ on_line.index(on_stop)..on_line.index(off_stop) ]) \n\t\t\"you have to travel through: #{ stops.join(\" -> \") }\"\n\n\telse\n\t\tif is_left_to_union(on_line, on_stop, \"Union Square\")\n\t\t\tstops << on_line[on_line.index(on_stop)..on_line.index(\"Union Square\")]\n\n\t\telse\n\t\t\tstops << on_line[on_line.index(\"Union Square\")..on_line.index(on_stop)].reverse\n\t\tend\n\n\t\tif is_left_to_union(off_line, off_stop, \"Union Square\")\n\t\t\tstops << off_line[off_line.index(off_stop)..off_line.index(\"Union Square\")].reverse\n\n\t\telse\n\t\t\tstops << off_line[off_line.index(\"Union Square\")..off_line.index(off_stop)]\n\t\tend\n\n\t\t# delete \"Union Square\" from stops[1] as it is duplicate with stops[0]\n\t\tstops[1].shift\n\n\t\t\"You have to travel through: #{ stops[0].join(\" -> \") }\\n Change at: Union Square\\n Your travel continues through: #{ stops[1].join(\" -> \") }\\n The total number of stops you have to travel is: #{ stops.flatten.length }\"\n\tend\nend", "def getStops(stopA, stopB, cL)\n $count += (stopA - stopB).abs;\n stopA < stopB ? cL[stopA..stopB][1..-1].join(\", \") : cL[stopB..stopA].reverse[1..-1].join(\", \") end", "def read_end_stops()\n start_command('F81', false, @status_debug_msg)\n end", "def read_end_stops()\n @ramps_arduino.execute_command('F81', false, @status_debug_msg)\n end", "def read_end_stops()\n execute_command('F81', false, @status_debug_msg)\n end", "def get_codon_orfs2 splitter_func, start_func\n orfs = get_codon_orfs1(splitter_func,true,true)\n orfs.find_all { | orf | start_func.call(orf[0]) }\n end", "def generate_OR_clauses(rule)\n #First, split rule into positive and negative sets of clauses.\n parts = rule.split(@NOT)\n positive_clauses = parts[0]\n negative_clauses = parts[1]\n\n @or_clauses_pos = positive_clauses.split('OR')\n @or_clauses_neg = negative_clauses.split('OR')\n end", "def get_stops (line, first_stop, last_stop)\n # puts \"line #{ line } stop #{ first_stop } -> stop #{ last_stop }\"\n first_index = lines[line.to_sym].index(first_stop)\n last_index = lines[line.to_sym].index(last_stop)\n if first_index <= last_index\n trip = lines[line.to_sym][first_index..last_index]\n else\n trip = lines[line.to_sym][last_index..first_index].reverse\n end\n trip.shift # remove first stop\n return trip\nend", "def list_stops(line)\n puts line\n return \"all the stops on a line\"\nend", "def stop_symbol\n STOP\n end", "def stops\n get '/gtfs/stops'\n end", "def second_trip(l2, s2)\n ## find index of stop s2 on line l2\n index_s2 = $lines[l2].index(s2)\n ## find index of Union Square Staion on line l2\n index_of_USquare = $lines[l2].index('Union Square')\n\n trip2 = []\n\n if index_s2 > index_of_USquare\n trip2 = $lines[l2][index_of_USquare..index_s2].drop(1) # drop(1) to exclude Union Square station from the list\n else\n trip2 = $lines[l2][index_s2..index_of_USquare].reverse.drop(1) # drop(1) to exclude Union Square station from the list\n end\n\n\n puts \">>> Your journey continues through the following stops on the #{l2} line: #{trip2.join(', ')}.\"\n\n trip2\nend", "def get_codon_orfs1 splitter_func,do_include_leftmost_orf,do_strip_leading_codon\n orfs = split(@codons,splitter_func)\n return [] if orfs.size == 0\n # Drop the first sequence, if there is no match on the first position\n orfs.shift if !do_include_leftmost_orf and !splitter_func.call(orfs.first[0])\n orfs = orfs.map { |codons| \n codons = codons.shift if do_strip_leading_codon and splitter_func.call(codons[0])\n codons\n }\n if @reversed == nil\n TrackSequenceTrait.update_sequence_pos(orfs,@ntseq_pos) # nail against parent\n else\n TrackSequenceTrait.update_reversed_sequence_pos(orfs,@ntseq_pos) # nail against parent\n end\n end", "def closed_end_list(list); end", "def startstop minsize=30\n stopstop(minsize).find_all { | orf | \n codon1= orf.nt.seq[0..2].upcase\n ['ATG','TTG','CTG','AUG','UUG','CUG'].index(codon1) != nil\n }\n end", "def orf_find(prediction = @prediction)\n\n if prediction.seq_type != \"nucleotide\"\n \"-\"\n end\n \n #stop codons\n stop_codons = [\"TAG\", \"TAA\", \"TGA\"]\n #minimimum ORF length\n orf_length = 100\n \n seq = prediction.raw_sequence\n stops = {}\n result = {}\n\n stop_codons.each do |codon|\n occurences = (0 .. seq.length - 1).find_all { |i| seq[i,3].downcase == codon.downcase }\n occurences.each do |occ|\n stops[occ + 3] = codon\n end\n end\n\n\n #direct strand\n stop_positions = stops.map{|x| x[0]}\n result[\"+1\"] = []\n result[\"+2\"] = []\n result[\"+3\"] = []\n result[\"-1\"] = []\n result[\"-2\"] = []\n result[\"-3\"] = []\n\n #reading frame 1, direct strand\n m3 = stops.map{|x| x[0]}.select{|y| y % 3 == 0}.sort\n m3 = [1, m3, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3: #{m3.to_s}\"\n (1..m3.length-1).each do |i|\n if m3[i] - m3[i-1] > orf_length\n# result[[m3[i-1], m3[i]]] = \"+1\"\n result[\"+1\"].push([m3[i-1], m3[i]])\n end\n end\n \n #reading frame 2, direct strand\n m3_1 = stops.map{|x| x[0]}.select{|y| y % 3 == 1}.sort\n m3_1 = [2, m3_1, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3 + 1: #{m3_1.to_s}\"\n (1..m3_1.length-1).each do |i|\n if m3_1[i] - m3_1[i-1] > orf_length\n# result[[m3_1[i-1], m3_1[i]]] = \"+2\"\n result[\"+2\"].push([m3_1[i-1], m3_1[i]])\n end\n end\n\n #reading frame 3, direct strand\n m3_2 = stops.map{|x| x[0]}.select{|y| y % 3 == 2}.sort\n m3_2 = [3, m3_2, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3 + 2: #{m3_2.to_s}\"\n (1..m3_2.length-1).each do |i|\n if m3_2[i] - m3_2[i-1] > orf_length\n# result[[m3_2[i-1], m3_2[i]]] = \"+3\"\n result[\"+3\"].push([m3_2[i-1], m3_2[i]])\n end\n end\n\n #reverse strand\n stops_reverse = {}\n seq_reverse = seq.reverse.downcase.gsub('a','T').gsub('t','A').gsub('c','G').gsub('g','C')\n stop_codons.each do |codon|\n occurences = (0 .. seq_reverse.length - 1).find_all { |i| seq_reverse[i,3].downcase == codon.downcase }\n #puts \"-1 #{codon}: #{occurences.to_s}\"\n occurences.each do |occ|\n stops_reverse[occ + 3] = codon\n end\n end\n\n stop_positions_reverse = stops_reverse.map{|x| x[0]}\n m3 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 0}.sort\n m3 = [1, m3, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3: #{m3.to_s}\"\n (1..m3.length-1).each do |i|\n if m3[i] - m3[i-1] > orf_length\n# result[[m3[i-1], m3[i]]] = \"-1\"\n result[\"-1\"].push([m3[i-1], m3[i]])\n end\n end\n\n m3_1 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 1}.sort\n m3_1 = [2, m3_1, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3 + 1: #{m3_1.to_s}\"\n (1..m3_1.length-1).each do |i|\n if m3_1[i] - m3_1[i-1] > orf_length\n result[\"-2\"].push([m3_1[i-1], m3_1[i]])\n end\n end\n\n m3_2 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 2}.sort\n m3_2 = [3, m3_2, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3 + 2: #{m3_2.to_s}\"\n (1..m3_2.length-1).each do |i|\n if m3_2[i] - m3_2[i-1] > orf_length\n result[\"-3\"].push([m3_2[i-1], m3_2[i]])\n# result[[m3_2[i-1], m3_2[i]]] = \"-3\"\n end\n end\n\n result\n end", "def exclude_ends list\n list[1..-2]\nend", "def next_fii_or_segment_index(segments, start_pos, end_pos=nil)\n find_index_by_regex(segments, start_pos, end_pos, /^FII\\+OR.*/)\n end", "def get_nearby_stops(lat, lon)\n # hit trimet api for stops near this location\n # https://developer.trimet.org/ws/V1/stops\n end", "def stop_times\n StopTimeVersion.where(:stop_identifier => identifier)\n end", "def trip(line, start_stop, end_stop)\n trip_line = s_line(line)\n p trip_line\n start_index = trip_line.index(start_stop)\n end_index = trip_line.index(end_stop)\n stops = \"\"\n\n if start_index < end_index\n until start_index == end_index\n stops += trip_line[start_index]\n start_index += 1\n end\n else\n until start_index == end_index\n stops += trip_line[start_index]\n start_index -= 1\n end\n end\n return stops\nend", "def order_list\n $tracer.trace(__method__)\n return GameStopOrderList.new(ToolTag.new(table.id(create_ats_regex_string(\"/ordersTable/\")).find.a.id(create_ats_regex_string(\"/lnkOrderDetail/\")), __method__))\n end", "def getLineStops (l)\n @lines[l][:stops]\nend", "def delimiters\n @delimiters ||= COMMON_DELIMITERS.inject({}, &count).sort(&most_found)\n end", "def ends\n ends = []\n vertices.each { |x| ends << x if x.neighbors.empty? }\n ends\n end", "def get_line_stops(lines, origin_line)\n lines[origin_line.to_sym]\nend", "def get_stopword_list\n list = []\n \n begin\n File.open(\"stopwords.txt\", \"r\") do |file|\n file.each_line { |line| list.push( line.chomp ) }\n end\n rescue\n puts \"The file 'stopwords.txt' was not found.\"\n exit\n end\n\n return list\nend", "def index\n @stops = Stop.all\n end", "def index\n @stops = Stop.all\n end", "def index\n @stops = Stop.all\n end", "def stops_by_stop_code(stop_code)\n get \"/gtfs/stops/stopCode/#{stop_code}\"\n end", "def stopGetter(stop_1, stop_2, line)\n if stop_1 > stop_2\n return line[stop_2..stop_1].reverse!\n else\n return line[stop_1..stop_2]\n end\nend", "def get_suffixes\n find_all{|entry| entry.type==Morpheme::SUFFIX}\n end", "def saw_end_list(list); end", "def lsep\n \"==================================================================================\"\n end", "def split_or_clauses(args)\n level = 0\n i = 0\n or_positions = []\n while i < args.length\n arg = args[i]\n if arg == BOOLEAN_OR && level == 0\n or_positions << i\n end\n if arg == OPEN_PAREN\n level += 1\n elsif arg == CLOSE_PAREN\n level -= 1\n if level == -1\n or_positions << i\n return or_positions\n end\n end\n i += 1\n end\n or_positions << args.length unless or_positions.empty?\n or_positions\nend", "def filtrarObstaculos(cad)\n aux=[]\n cad.each do |elemento|\n if (elemento[0] == \"O\")\n aux.push(stringObstaculos(elemento))\n end\n end\n return aux #[[\"O\",3,2],......]\nend", "def stopwords\n @stopwords ||= IO.readlines(@stopwords_file).map { |l| l.strip }\n end", "def stopwords\n @stopwords ||= IO.readlines(@stopwords_file).map { |l| l.strip }\n end", "def stopwords\n @stopwords ||= IO.readlines(@stopwords_file).map { |l| l.strip }\n end", "def stops_by_coordinates(lat, lon)\n stops('stops/bylatlon/' + ('%.6f' % lat) + '/' + ('%.6f' % lon))\n end", "def stops_by_id(stop_id)\n [Stop.from_json(query('stops/bystop/' + CGI.escape(stop_id)))]\n end", "def cow_list\n self.cows.split(' ').map do |cow|\n cow.split('-')[1]\n end.uniq.join(' ')\n end", "def make_list(options)\n list = []\n to_switches(options).split(\" \").each do |a|\n list << a.gsub('\"', \"\")\n end\n list\n end", "def custom_delimiters\r\n\t\toutput = []\r\n\t\toutput << input.split(\"]\\n\").first[3..-1].split(\"][\") if input.start_with?('//')\r\n\t\toutput.flatten\r\n\tend", "def roles\n @run_list.select do |rl|\n rl.start_with?('r_', 'p_', 'base_', 'os_', 'os-')\n end\n end", "def list_of_terminating_instances(list = remote_instances_list)\n list.reject {|i| true if !i.terminating? }\n end", "def list_operations()\n\t\treturn @service.operations\n\tend", "def display_stop_cycles(outname, ops, stamp_columns)\n tab = Array.new(8) { Array.new(12, \"-\") }\n stop_cycle = ops.first.output(outname).collection.get(\"stop_cycle\")\n\n if stop_cycle.present?\n stop_cycle[0].length.times do |cc|\n col = cc+1\n if stamp_columns\n if(stop_cycle[0][cc]>0)\n tab[0][cc] = {content: \"A#{col} cycle #{stop_cycle[0][cc]}\", check: \"true\"}\n (1..stamp_columns - 1).each do |rr|\n row = (rr+\"A\".ord).chr\n tab[rr][cc] = {content: \"cycle #{stop_cycle[0][cc]}\", check: \"false\"} # wells are connected\n end\n end\n else\n stop_cycle.length.times { |rr|\n if(stop_cycle[rr][cc]>0)\n row = (rr+\"A\".ord).chr\n tab[rr][cc] = {content: \"#{row}#{col} cycle #{stop_cycle[rr][cc]}\", check: \"true\"}\n end\n }\n end\n end\n end\n\n return tab\n end", "def separators\n @separators.merge(definition.separators(@children.find(&:segment?)))\n end", "def list_of_terminating_instances(list = remote_instances_list)\n list.reject {|i| true if !i.terminating? }\n end", "def scan_stop_all\n\t\t\tb=scan_list_uids\n\t\t\tb.each {|uuid|\n\t\t\t\tscan_stop(uuid)\n\t\t\t}\n\t\t\treturn b\n\t\tend", "def get_stops\n @agency = params[:agency]\n @route = params[:route]\n @direction = params[:direction] ? \"~\" + params[:direction] : \"\"\n\n request_url = \"http://services.my511.org/Transit2.0/GetStopsForRoute.aspx?token=#{@@token}&routeIDF=#{@agency}~#{@route}#{@direction}\"\n request_url = request_url.gsub(/ /,\"%20\")\n p parse_request(request_url)\n @stops = search_for_key(parse_request(request_url), \"Stop\") || []\n\n @stops = [@stops] unless @stops.kind_of?(Array)\n respond_to do |format|\n format.js {}\n end\n end", "def parsers\n p = []\n constants.each do |const|\n next unless const.match?(\"^USE_\")\n p << const\n end\n p\n end", "def sanitizeBusstop\n [@busstop, @endstop].each do |stop|\n stop = stop.split(/[ \\/]/)\n stop.delete(\"Metro\")\n stop.delete(\"Inbound\")\n stop.delete(\"Outbound\")\n stop = stop.join(\" \")\n end\n end", "def get_stop_word_array\n\t\treturn ['a','about','above','after','again','against','all','am','an','and','any','are',\"aren't\",'as','at','be','because','been','before','being','below','between','both','but','by',\n\t\t\t\t\"can't\",'cannot','could',\"couldn't\",'did',\"didn't\",'do','does',\"doesn't\",'doing',\"don't\",'down','during','each','few','for','from','further','had',\"hadn't\",'has',\"hasn't\",\n\t\t\t\t'have',\"haven't\",'having','he',\"he'd\",\"he'll\",\"he's\",'her','here',\"here's\",'hers','herself','him','himself','his','how',\"how's\",'i',\"i'd\",\"i'll\",\"i'm\",\"i've\",'if','in','into',\n\t\t\t\t'is',\"isn't\",'it',\"it's\",'its','itself',\"let's\",'me','more','most',\"mustn't\",'my','myself','no','nor','not','of','off','on','once','only','or','other','ought','our','ours',\n\t\t\t\t'ourselves','out','over','own','same',\"shan't\",'she',\"she'd\",\"she'll\",\"she's\",'should',\"shouldn't\",'so','some','such','than','that',\"that's\",'the','their','theirs','them',\n\t\t\t\t'themselves','then','there',\"there's\",'these','they',\"they'd\",\"they'll\",\"they're\",\"they've\",'this','those','through','to','too','under','until','up','very','was',\"wasn't\",\n\t\t\t\t'we',\"we'd\",\"we'll\",\"we're\",\"we've\",'were',\"weren't\",'what',\"what's\",'when',\"when's\",'where',\"where's\",'which','while','who',\"who's\",'whom','why',\"why's\",'with',\"won't\",\n\t\t\t\t'would',\"wouldn't\",'you',\"you'd\",\"you'll\",\"you're\",\"you've\",'your','yours','yourself','yourselves','zero']\n\tend", "def symbol_segments\n segments.select{ |s| s.is_a?(Symbol) }\n end", "def get_users_stops_by_line(line,origin_stop,destination_stop)\n # stop_list is an array which is line details\n stop_list = get_stop_details(line)\n origin_stop_index = stop_list.index(origin_stop)\n destination_stop_index = stop_list.index(destination_stop)\n\n if origin_stop_index < destination_stop_index\n stop_list[origin_stop_index + 1..destination_stop_index]\n\n else\n stop_list[destination_stop_index..origin_stop_index - 1].reverse()\n end\n end", "def stops_from_union(station, line)\n\n\tnum_stops = line.index(station) - line.index(\"Union Square\")\n\tnum_stops.abs\nend", "def lines(sep=$/) # added for 1.8.7\n return IoEnumerator.new(self, :each_line, sep)\n end", "def ooc_scan_type_list(gui_active_only = false)\n scan_types =OocScanType.find_by_sql(\"select ooc_scan_type\n from hip_ooc_scan_type_v #{\"where active_in_gui = 'y'\" if gui_active_only}\n group by grouping sets ((ooc_scan_type, ooc_group_type),(ooc_group_type))\n order by ooc_group_type, ooc_scan_type\")\n array=[]\n scan_types.each do |type|\n array.push(type['ooc_scan_type']) unless type['ooc_scan_type'].blank?\n array.push('--------------') if type['ooc_scan_type'].blank?\n end\n array.pop # remove the last blank line\n return array\n end", "def exclude_ends potato\n potato [1..-2]\nend", "def index\n @busstops = Busstop.all\n end", "def directions\n [\"Northbound\", \"Southbound\", \"Eastbound\", \"Westbound\"]\n end", "def codes\n [@attrs['Code'], @attrs['StationTogether1'], @attrs['StationTogether2']].compact\n end", "def flags\n match(/Flags\\s+:\\s+(.+)$/).split rescue []\n end", "def flags\n match(/Flags\\s+:\\s+(.+)$/).split rescue []\n end", "def terminal_events\n each_event.find_all { |_, e| e.terminal? }\n .map { |_, e| e }\n end", "def print_stops(array)\n for station in array\n puts station\n end\nend", "def right_delimiter\n @right_delimiter || World.right_delimiter\n end", "def splits\n []\n end", "def delim!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n\n\n type = DELIM\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 305:3: '|'\n match( 0x7c )\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__, 13 )\n\n\n end", "def list \n @@Ordenadores\n end", "def index\n @do_not_stops = DoNotStop.all\n end", "def fetchStopPositions\n\t\tfetchUri(\"http://api.wmata.com/Bus.svc/json/JStops?&api_key=#{@@apiKey}\")\n\tend", "def separator(type); end", "def stop_tones\n return @stop_tones\n end", "def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end", "def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end", "def get_rules\n rules = Array.new\n\n RULE_TYPES.each do |reg|\n ebtables_exit = `#{CONF[:ebtables]} -L FORWARD`\n\n rules << ebtables_exit.split(\"\\n\")[3..-1].collect do |l|\n line = l.strip\n m = line.match(reg)\n\n if m\n interface=m[1]\n {\n :interface => interface, \n :rule => line\n }\n else\n nil\n end\n end.compact\n end\n\n rules.flatten\nend", "def index\n @stop_requests = StopRequest.all\n end", "def station_codes\n [@attrs['StationCode1'], @attrs['StationCode2']].compact\n end", "def |(enum); end", "def structure_lines(lines)\n last_structure_line = lines.index{ |line| line =~ /\\AM END/ }\n lines[4..last_structure_line].join\n end", "def exclude_ends input\n\n input[1..-2]\n\n end", "def stop_menu(subway_lines, train)\n\treturn subway_lines[train]\nend", "def repo_names_for_dev_mode(list, devmode)\n if devmode =~ /\\//\n [devmode]\n else\n list[0..1]\n end\n end", "def stations\n stations = []\n CSV.foreach(LOCAL_DATA, :col_sep =>':') do |row|\n callsign, origin, destination, client = row[0].to_s, row[11].to_s, row[13].to_s, row[3].to_s\n for cs in @callsign\n stations << row if callsign[0...cs.length] == cs # && client == \"ATC\") unless @role == \"pilot\"\n # stations << row if (origin[0...icao.length] == icao || destination[0...icao.length] == icao) unless @role == \"atc\"\n end\n end\n stations\n end", "def build_leg(line, start, stop)\n trip = []\n until start == stop do\n start += (start < stop) ? 1 : - 1\n trip.push line[start]\n end\n return trip\nend", "def stop(klass)\n fetch(klass).stop rescue nil\n a = []\n find_dependencies(klass, [\"start\", \"stop\"]) { |s| a << s }\n a.reverse_each { |s| fetch(s).stop }\n end", "def terminals\n\t\treturn @production_rules.values.flatten.uniq.select { |x| /([a-z]+|\\$)/ =~ x and x != \"lambda\" }\n\tend", "def scan_stop_all\r\n\t\tb=scan_list_uids\r\n\t\tb.each {|uuid|\r\n\t\t\tscan_stop(uuid)\r\n\t\t}\r\n\t\treturn b\r\n\tend", "def list\n FileOperations.find_all(self)\n end", "def tokens\n tok_sequence = []\n until @scanner.eos?\n token = _next_token\n tok_sequence << token unless token.nil?\n end\n\n tok_sequence\n end", "def regex_stop_or_semicolon\n Regexp.new(\"(?:\\\\.line#{VM_PREFIX}|;line#{VM_PREFIX})\")\nend", "def index\n @roadstops = Roadstop.all\n end" ]
[ "0.61452353", "0.6030899", "0.5720502", "0.5501507", "0.52980685", "0.5287411", "0.52649814", "0.52113324", "0.5175097", "0.5095427", "0.5091915", "0.5048306", "0.5045769", "0.50185513", "0.49812138", "0.4937096", "0.4878456", "0.48067123", "0.47399545", "0.47248435", "0.4690207", "0.4673082", "0.46441212", "0.46381646", "0.46282583", "0.46029916", "0.4585889", "0.45832127", "0.45615733", "0.45488247", "0.45291114", "0.4504152", "0.4504152", "0.4504152", "0.4498245", "0.4493871", "0.4478166", "0.4472677", "0.44593993", "0.4442736", "0.44402665", "0.4437987", "0.44277364", "0.44275364", "0.44170243", "0.44092977", "0.43975395", "0.4396741", "0.43929827", "0.43889907", "0.43829924", "0.43798524", "0.43725076", "0.43709338", "0.43704355", "0.4364366", "0.43617314", "0.43512046", "0.4347758", "0.43430316", "0.4340935", "0.4332538", "0.43320352", "0.43315244", "0.43304774", "0.43221712", "0.4321247", "0.43134338", "0.42995209", "0.42935205", "0.42935205", "0.42749888", "0.42734313", "0.42626253", "0.42512402", "0.4250818", "0.42489773", "0.42466766", "0.4242814", "0.42366344", "0.42358446", "0.4235565", "0.4235565", "0.42311087", "0.42242995", "0.4221797", "0.42184114", "0.42177415", "0.42128348", "0.42082283", "0.4207166", "0.4190894", "0.41904503", "0.41894388", "0.41885898", "0.4183948", "0.4180208", "0.41762665", "0.41739023", "0.41738653" ]
0.69914395
0
Return a list of ORFs delimited by STARTSTOP codons
def get_startstop_orfs get_codon_orfs2( Proc.new { | codon | STOP_CODONS.include?(codon) }, Proc.new { | codon | START_CODONS.include?(codon) }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orfs_from_start_stop_markers(start_markers, stop_markers, minimum_orf_length)\n # Split up the start and stop positions into 3 frames\n frame_starts = [[],[],[]]\n frame_stops = [[],[],[]]\n start_markers.each do |marker|\n frame_starts[marker.position_in_trail % 3].push marker\n end\n stop_markers.each do |marker|\n frame_stops[marker.position_in_trail % 3].push marker\n end\n\n # For each frame\n to_return = ORFsResult.new\n (0..2).each do |frame|\n frame_pairs = []\n\n # Sort arrays in descending order because Array#pop removes from the end of the array\n starts = frame_starts[frame].sort{|a,b| b.position_in_trail<=>a.position_in_trail}\n stops = frame_stops[frame].sort{|a,b| b.position_in_trail<=>a.position_in_trail}\n\n current_start = starts.pop\n current_stop = stops.pop\n if current_stop\n # Record first stop codon\n to_return.initial_stop_markers.push current_stop\n end\n if current_start and (current_stop.nil? or current_start.position_in_trail < current_stop.position_in_trail)\n # Record first start codon before any stop codons\n to_return.initial_start_markers.push current_start\n end\n\n while current_start and current_stop\n # Move to next start after current stop\n while current_start and current_start.position_in_trail < current_stop.position_in_trail\n current_start = starts.pop\n end\n\n if current_start\n # Move to next stop after current start\n while current_stop and current_stop.position_in_trail < current_start.position_in_trail\n current_stop = stops.pop\n end\n end\n\n if current_start and current_stop\n # This stop codon stops the current reading frame.\n if current_stop.position_in_trail - current_start.position_in_trail >= minimum_orf_length\n # Found a legit ORF\n to_return.start_stop_pairs.push [current_start, current_stop]\n end\n # Whether or not last ORF was long enough, search for the next start codon\n next\n else\n if current_start\n to_return.final_start_markers.push current_start\n end\n break\n end\n end\n end\n\n return to_return\n end", "def get_stopstop_orfs \n get_codon_orfs1(Proc.new { | codon | STOP_CODONS.include?(codon) },false,true)\n end", "def get_codon_orfs2 splitter_func, start_func\n orfs = get_codon_orfs1(splitter_func,true,true)\n orfs.find_all { | orf | start_func.call(orf[0]) }\n end", "def stopstop minsize=30\n type = \"XX\"\n orfs = []\n translate = Nucleotide::Translate.new(@trn_table)\n aa_frames = translate.aa_frames(@seq)\n num = 0\n aa_frames.each do | aa_frame |\n frame = aa_frame[:frame]\n aa = aa_frame[:sequence]\n aa_start = 0\n aa.split(/\\*/).each do | candidate |\n if candidate.size >= minsize and candidate.size > 0\n orf = ORF.new(num,type,@id,@descr,@seq,frame,aa_start*3,candidate)\n orfs.push orf\n num += 1\n end\n aa_start += candidate.size + 1\n end\n end\n orfs.sort\n end", "def startstop minsize=30\n stopstop(minsize).find_all { | orf | \n codon1= orf.nt.seq[0..2].upcase\n ['ATG','TTG','CTG','AUG','UUG','CUG'].index(codon1) != nil\n }\n end", "def getting_stops on_line, on_stop, off_line, off_stop\n\tstops = []\n\n\tif is_same_line(on_line, off_line)\n\t\texit if on_line.index(on_stop) == on_line.index(off_stop) \n\t\t\t\n\t\tstops << (on_line[ on_line.index(on_stop)..on_line.index(off_stop) ]) \n\t\t\"you have to travel through: #{ stops.join(\" -> \") }\"\n\n\telse\n\t\tif is_left_to_union(on_line, on_stop, \"Union Square\")\n\t\t\tstops << on_line[on_line.index(on_stop)..on_line.index(\"Union Square\")]\n\n\t\telse\n\t\t\tstops << on_line[on_line.index(\"Union Square\")..on_line.index(on_stop)].reverse\n\t\tend\n\n\t\tif is_left_to_union(off_line, off_stop, \"Union Square\")\n\t\t\tstops << off_line[off_line.index(off_stop)..off_line.index(\"Union Square\")].reverse\n\n\t\telse\n\t\t\tstops << off_line[off_line.index(\"Union Square\")..off_line.index(off_stop)]\n\t\tend\n\n\t\t# delete \"Union Square\" from stops[1] as it is duplicate with stops[0]\n\t\tstops[1].shift\n\n\t\t\"You have to travel through: #{ stops[0].join(\" -> \") }\\n Change at: Union Square\\n Your travel continues through: #{ stops[1].join(\" -> \") }\\n The total number of stops you have to travel is: #{ stops.flatten.length }\"\n\tend\nend", "def get_codon_orfs1 splitter_func,do_include_leftmost_orf,do_strip_leading_codon\n orfs = split(@codons,splitter_func)\n return [] if orfs.size == 0\n # Drop the first sequence, if there is no match on the first position\n orfs.shift if !do_include_leftmost_orf and !splitter_func.call(orfs.first[0])\n orfs = orfs.map { |codons| \n codons = codons.shift if do_strip_leading_codon and splitter_func.call(codons[0])\n codons\n }\n if @reversed == nil\n TrackSequenceTrait.update_sequence_pos(orfs,@ntseq_pos) # nail against parent\n else\n TrackSequenceTrait.update_reversed_sequence_pos(orfs,@ntseq_pos) # nail against parent\n end\n end", "def getOr_ r\n or_= []; del_ = []; cur = []\n status = :start\n x = 0\n while x < r.length do\n if r[x] == OR_OPERATOR\n if status == :start\n cur = [r[x-1]]\n status = :cont\n del_.push x-1\n end\n cur.push r[x+1]\n del_ += [x, x+1]\n x += 2\n else\n if status == :cont\n status = :start\n or_.push cur\n cur = []\n end\n x += 1\n end\n end\n if not cur.empty?\n or_.push cur\n end\n return or_, del_\n end", "def next_fii_or_segment_index(segments, start_pos, end_pos=nil)\n find_index_by_regex(segments, start_pos, end_pos, /^FII\\+OR.*/)\n end", "def trip(line, start_stop, end_stop)\n trip_line = s_line(line)\n p trip_line\n start_index = trip_line.index(start_stop)\n end_index = trip_line.index(end_stop)\n stops = \"\"\n\n if start_index < end_index\n until start_index == end_index\n stops += trip_line[start_index]\n start_index += 1\n end\n else\n until start_index == end_index\n stops += trip_line[start_index]\n start_index -= 1\n end\n end\n return stops\nend", "def orf_find(prediction = @prediction)\n\n if prediction.seq_type != \"nucleotide\"\n \"-\"\n end\n \n #stop codons\n stop_codons = [\"TAG\", \"TAA\", \"TGA\"]\n #minimimum ORF length\n orf_length = 100\n \n seq = prediction.raw_sequence\n stops = {}\n result = {}\n\n stop_codons.each do |codon|\n occurences = (0 .. seq.length - 1).find_all { |i| seq[i,3].downcase == codon.downcase }\n occurences.each do |occ|\n stops[occ + 3] = codon\n end\n end\n\n\n #direct strand\n stop_positions = stops.map{|x| x[0]}\n result[\"+1\"] = []\n result[\"+2\"] = []\n result[\"+3\"] = []\n result[\"-1\"] = []\n result[\"-2\"] = []\n result[\"-3\"] = []\n\n #reading frame 1, direct strand\n m3 = stops.map{|x| x[0]}.select{|y| y % 3 == 0}.sort\n m3 = [1, m3, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3: #{m3.to_s}\"\n (1..m3.length-1).each do |i|\n if m3[i] - m3[i-1] > orf_length\n# result[[m3[i-1], m3[i]]] = \"+1\"\n result[\"+1\"].push([m3[i-1], m3[i]])\n end\n end\n \n #reading frame 2, direct strand\n m3_1 = stops.map{|x| x[0]}.select{|y| y % 3 == 1}.sort\n m3_1 = [2, m3_1, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3 + 1: #{m3_1.to_s}\"\n (1..m3_1.length-1).each do |i|\n if m3_1[i] - m3_1[i-1] > orf_length\n# result[[m3_1[i-1], m3_1[i]]] = \"+2\"\n result[\"+2\"].push([m3_1[i-1], m3_1[i]])\n end\n end\n\n #reading frame 3, direct strand\n m3_2 = stops.map{|x| x[0]}.select{|y| y % 3 == 2}.sort\n m3_2 = [3, m3_2, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3 + 2: #{m3_2.to_s}\"\n (1..m3_2.length-1).each do |i|\n if m3_2[i] - m3_2[i-1] > orf_length\n# result[[m3_2[i-1], m3_2[i]]] = \"+3\"\n result[\"+3\"].push([m3_2[i-1], m3_2[i]])\n end\n end\n\n #reverse strand\n stops_reverse = {}\n seq_reverse = seq.reverse.downcase.gsub('a','T').gsub('t','A').gsub('c','G').gsub('g','C')\n stop_codons.each do |codon|\n occurences = (0 .. seq_reverse.length - 1).find_all { |i| seq_reverse[i,3].downcase == codon.downcase }\n #puts \"-1 #{codon}: #{occurences.to_s}\"\n occurences.each do |occ|\n stops_reverse[occ + 3] = codon\n end\n end\n\n stop_positions_reverse = stops_reverse.map{|x| x[0]}\n m3 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 0}.sort\n m3 = [1, m3, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3: #{m3.to_s}\"\n (1..m3.length-1).each do |i|\n if m3[i] - m3[i-1] > orf_length\n# result[[m3[i-1], m3[i]]] = \"-1\"\n result[\"-1\"].push([m3[i-1], m3[i]])\n end\n end\n\n m3_1 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 1}.sort\n m3_1 = [2, m3_1, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3 + 1: #{m3_1.to_s}\"\n (1..m3_1.length-1).each do |i|\n if m3_1[i] - m3_1[i-1] > orf_length\n result[\"-2\"].push([m3_1[i-1], m3_1[i]])\n end\n end\n\n m3_2 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 2}.sort\n m3_2 = [3, m3_2, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3 + 2: #{m3_2.to_s}\"\n (1..m3_2.length-1).each do |i|\n if m3_2[i] - m3_2[i-1] > orf_length\n result[\"-3\"].push([m3_2[i-1], m3_2[i]])\n# result[[m3_2[i-1], m3_2[i]]] = \"-3\"\n end\n end\n\n result\n end", "def build_leg(line, start, stop)\n trip = []\n until start == stop do\n start += (start < stop) ? 1 : - 1\n trip.push line[start]\n end\n return trip\nend", "def get_stops (line, first_stop, last_stop)\n # puts \"line #{ line } stop #{ first_stop } -> stop #{ last_stop }\"\n first_index = lines[line.to_sym].index(first_stop)\n last_index = lines[line.to_sym].index(last_stop)\n if first_index <= last_index\n trip = lines[line.to_sym][first_index..last_index]\n else\n trip = lines[line.to_sym][last_index..first_index].reverse\n end\n trip.shift # remove first stop\n return trip\nend", "def second_trip(l2, s2)\n ## find index of stop s2 on line l2\n index_s2 = $lines[l2].index(s2)\n ## find index of Union Square Staion on line l2\n index_of_USquare = $lines[l2].index('Union Square')\n\n trip2 = []\n\n if index_s2 > index_of_USquare\n trip2 = $lines[l2][index_of_USquare..index_s2].drop(1) # drop(1) to exclude Union Square station from the list\n else\n trip2 = $lines[l2][index_s2..index_of_USquare].reverse.drop(1) # drop(1) to exclude Union Square station from the list\n end\n\n\n puts \">>> Your journey continues through the following stops on the #{l2} line: #{trip2.join(', ')}.\"\n\n trip2\nend", "def getStops(stopA, stopB, cL)\n $count += (stopA - stopB).abs;\n stopA < stopB ? cL[stopA..stopB][1..-1].join(\", \") : cL[stopB..stopA].reverse[1..-1].join(\", \") end", "def list_stops(line)\n puts line\n return \"all the stops on a line\"\nend", "def generate_OR_clauses(rule)\n #First, split rule into positive and negative sets of clauses.\n parts = rule.split(@NOT)\n positive_clauses = parts[0]\n negative_clauses = parts[1]\n\n @or_clauses_pos = positive_clauses.split('OR')\n @or_clauses_neg = negative_clauses.split('OR')\n end", "def read_end_stops()\n start_command('F81', false, @status_debug_msg)\n end", "def parsed_command_of(slits)\n even_odd_half_of(slits).map{|t| parsed_range(t)}\n end", "def find_stations(mta, start_station, end_station)\n\n # Find the lines the stations are on\n lines = find_lines mta, start_station, end_station\n\n # Find the indexes on the found lines\n origin_index = mta[lines[0]].index(start_station)\n origin_union_index = mta[lines[0]].index(\"Union Square\")\n dest_union_index = mta[lines[1]].index(\"Union Square\")\n dest_index = mta[lines[1]].index(end_station)\n\n # Return an array of the results\n stations = [lines[0], origin_index, origin_union_index, lines[1], dest_union_index, dest_index]\nend", "def scan_for_index_start_and_end(code, regex)\n res = []\n code.scan(regex) do\n res << {starts: Regexp.last_match.offset(0).first,\n ends: Regexp.last_match.offset(0).last}\n end\n res\nend", "def get_path_by_names(start, stop)\n s1 = get_node(start)\n s2 = get_node(stop)\n if s1 != nil && s2 != nil\n return get_path(s1, s2)\n end\n Array.new \n end", "def is_left_to_union line, on_stop, changing_stop\n\tif line.index(on_stop) <= line.index(changing_stop)\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend", "def split_or_clauses(args)\n level = 0\n i = 0\n or_positions = []\n while i < args.length\n arg = args[i]\n if arg == BOOLEAN_OR && level == 0\n or_positions << i\n end\n if arg == OPEN_PAREN\n level += 1\n elsif arg == CLOSE_PAREN\n level -= 1\n if level == -1\n or_positions << i\n return or_positions\n end\n end\n i += 1\n end\n or_positions << args.length unless or_positions.empty?\n or_positions\nend", "def plan_trip (first_s, last_s)\n stations = []\n beginning = $lineN.index(first_s.to_s)\n ending = $lineN.index(last_s.to_s)\n this_many = beginning + ending\n stations = $lineN[beginning, this_many]\n return stations\nend", "def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end", "def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end", "def resource_indexes\n @resource_indexes ||= Proc.new do\n result = []\n tokens.each_index do |token_idx|\n if tokens[token_idx].type == :COLON\n next_token = tokens[token_idx].next_code_token\n depth = 1\n if next_token.type != :LBRACE\n tokens[(token_idx + 1)..-1].each_index do |idx|\n real_idx = token_idx + idx + 1\n if tokens[real_idx].type == :LBRACE\n depth += 1\n elsif {:SEMIC => true, :RBRACE => true}.include? tokens[real_idx].type\n unless tokens[real_idx].type == :SEMIC && depth > 1\n depth -= 1\n if depth == 0\n result << {:start => token_idx + 1, :end => real_idx}\n break\n end\n end\n end\n end\n end\n end\n end\n result\n end.call\n end", "def closed_end_list(list); end", "def closed_begin_list(list); end", "def codes\n [@attrs['Code'], @attrs['StationTogether1'], @attrs['StationTogether2']].compact\n end", "def offsetsList(ast)\n ast.filter(StructOffset).uniq.sort\nend", "def stations\n stations = []\n CSV.foreach(LOCAL_DATA, :col_sep =>':') do |row|\n callsign, origin, destination, client = row[0].to_s, row[11].to_s, row[13].to_s, row[3].to_s\n for cs in @callsign\n stations << row if callsign[0...cs.length] == cs # && client == \"ATC\") unless @role == \"pilot\"\n # stations << row if (origin[0...icao.length] == icao || destination[0...icao.length] == icao) unless @role == \"atc\"\n end\n end\n stations\n end", "def stops_from_union(station, line)\n\n\tnum_stops = line.index(station) - line.index(\"Union Square\")\n\tnum_stops.abs\nend", "def starts_at_ends_at_combo(obj, format, options = {})\n separator = options[:separator] || \" - \"\n raise \"format is not set\" unless format\n starts_at_string = obj.starts_at && l(obj.starts_at, :format => format)\n ends_at_string = obj.ends_at && l(obj.ends_at, :format => format)\n \"#{starts_at_string}#{separator}#{ends_at_string}\"\n end", "def getLineStops (l)\n @lines[l][:stops]\nend", "def structure_lines(lines)\n last_structure_line = lines.index{ |line| line =~ /\\AM END/ }\n lines[4..last_structure_line].join\n end", "def find_stations(si, ei, line) # si is short for start index and ei is short for end index\n if ei >= si\n line_stop_count = ei - si\n passing_stations = line[(si+1)..ei].join(\", \")\n else\n line_stop_count = si - ei\n passing_stations = line[(ei)..(si-1)].reverse.join(\", \")\n end\n return {:num_stops => line_stop_count, :stops => passing_stations}\nend", "def find_lines mta, start_station, end_station\n lines = [[],[]]\n mta.each do |line, stations|\n lines[0].push line if stations.include?(start_station)\n lines[1].push line if stations.include?(end_station)\n end\n\n if lines[0] & lines[1] != []\n common_line = lines[0] & lines[1]\n return [ common_line[0], common_line[0] ] # The 1st line both stations are on\n else\n return [ lines[0][0], lines[1][0] ] # The 1st line the staions are found on\n end\nend", "def get_line_stops(lines, origin_line)\n lines[origin_line.to_sym]\nend", "def read_end_stops()\n execute_command('F81', false, @status_debug_msg)\n end", "def stations_in_between2 (end_lane)\n if ($end_connection>$end)\n puts \"then the stations to follow are:\"\n puts $mta[end_lane][$end+1...$end_connection]\n else\n puts \"then the stations to follow are:\"\n puts $mta[end_lane][$end_connection+1...$end].reverse\n end #end of the if\n end", "def stations\n [\n master_station,\n SLCStationReport.new(@fields[5..9], false),\n SLCStationReport.new(@fields[10..14], false),\n SLCStationReport.new(@fields[15..19], false),\n SLCStationReport.new(@fields[20..24], false),\n SLCStationReport.new(@fields[25..29], false)\n ]\n end", "def city_openings(start, ending)\n open_listing = []\n self.listings.each do |listing|\n if listing.available?(start, ending)\n open_listing << listing\n end\n end\n open_listing\n end", "def split codons, is_splitter_func\n list = []\n node = []\n codons.each_with_index do | c, pos |\n # p [c,pos]\n if is_splitter_func.call(c)\n node.push c\n size = node.size\n # p node\n list.push FrameCodonSequence.new(node,pos+1-size) if size > @min_size_codons\n node = []\n end\n node.push c # always push boundary codon\n end\n list\n end", "def station_codes\n [@attrs['StationCode1'], @attrs['StationCode2']].compact\n end", "def to_refflat\n [ gene_name, name, seqname, strand, start, stop, cds.map(&:start).min, cds.map(&:stop).max, exons.count,\n exons.map(&:start).sort.join(','),\n exons.map(&:stop).sort.join(',')\n ].join \"\\t\"\n end", "def read_end_stops()\n @ramps_arduino.execute_command('F81', false, @status_debug_msg)\n end", "def stops\n get '/gtfs/stops'\n end", "def stops_between_stations (start_line,start_staion ,end_line, end_station )\n \n lines{\n red =[ 'South Station','Park Street', 'Kendall','Central','Harvard', 'Porter', 'Davis', 'Alewife']\ngreen = ['Government Center','Park Street','Boylston','Arlington','Copley','Hynes','Kenmore']\norange =['North Station','Haymarket','Park Street','State','Downtown Crossing','Chinatown','Back Bay','Forest Hills']\n }\n \n\n # return \"You have #{start_station - red_line.index(\"South Station\")} to go \" \n if start_line == end_line # Both dests are in in same line \n return start_line.index(start_staion) - end_line.index(stop_station) # i'd use abs = absloute here to avoid negative values \n\n else puts 'I have no clue what to do here -.-'\n \n end \n \n end", "def directions\n [\"Northbound\", \"Southbound\", \"Eastbound\", \"Westbound\"]\n end", "def start_to_oxygen_commands\n discover_map\n @map.find_path_commands(@map.starting_location, @map.oxygen_location)\n end", "def first_trip(l1, s1)\n ## find index of stop s1 on line l1\n index_s1 = $lines[l1].index(s1)\n ## find index of Union Square Staion on line l1\n index_of_USquare = $lines[l1].index('Union Square')\n\n trip1 = []\n\n if index_s1 <= index_of_USquare\n trip1 = $lines[l1][index_s1..index_of_USquare]\n else\n trip1 = $lines[l1][index_of_USquare..index_s1].reverse\n end\n\n puts \">>> You must travel through the following stops on the #{l1} line: #{trip1.join(', ')}.\"\n puts \">>> Change at Union Square.\"\n\n trip1\nend", "def list\n @list ||= all.to_a\n \n TEXTUAL_FILTERS.each do |filter|\n filter_value = send(filter)\n filter_property = property_for_filter(filter)\n if !filter_value.to_s.empty?\n @list = @list.select do |task|\n value = task.send(filter_property)\n value.to_s.downcase.include?(filter_value.to_s.downcase)\n end\n end\n end\n \n filter_value = start_at_filter\n if filter_value\n @list = @list.select do |task| \n value = task.start_at\n filter_value.nil? ? true : value >= filter_value\n end\n end\n \n filter_value = end_at_filter\n if filter_value\n @list = @list.select do |task|\n value = task.end_at\n filter_value.nil? ? true : value <= filter_value\n end\n end\n \n @list\n end", "def |(parslet); end", "def |(parslet); end", "def get_stop_details(line)\nx = $subway_lines\n for i in x do\n if line == i[:line]\nline_details = i[:stops]\n end\nend\nline_details\nend", "def stops_by_coordinates(lat, lon)\n stops('stops/bylatlon/' + ('%.6f' % lat) + '/' + ('%.6f' % lon))\n end", "def search_for_codons(otrail)\n return SearchResult.new, SearchResult.new if otrail.trail.empty?\n onode = otrail[0]\n\n make_marker = lambda do |position|\n marker = Marker.new\n marker.position_in_node = position\n marker.node = onode.node\n marker\n end\n\n #log.debug \"Looking for codons #{words.to_a}\" if log.debug?\n words = Set.new(START_CODONS).merge(STOP_CODONS)\n\n # search within first / last node\n fwd_nodes_sequence, twin_nodes_sequence = get_sequences onode\n #log.debug \"Looking in #{fwd_nodes_sequence}\" if log.debug?\n fwd_within_first = word_search(fwd_nodes_sequence, words, CODON_LENGTH)\n #log.debug \"Found codons #{fwd_within_first.keys.join(',')} at positions #{fwd_within_first.values.join(',')} in #{fwd_nodes_sequence}\" if log.debug?\n #log.debug \"Looking in #{twin_nodes_sequence}\" if log.debug?\n twin_within_first = word_search(twin_nodes_sequence, words, CODON_LENGTH)\n #log.debug \"Found codons #{twin_within_first.keys.join(',')} in twin node at positions #{twin_within_first.values.join(',')} in #{fwd_nodes_sequence}\" if log.debug?\n\n # extend search along trail\n fwd_overlap_sequence, twin_overlap_sequence = get_overlap_sequences(otrail, CODON_LENGTH)\n #log.debug \"Looking in #{fwd_overlap_sequence}\" if log.debug?\n fwd_in_overlap = word_search(fwd_overlap_sequence, words, CODON_LENGTH)\n #log.debug \"Found codons #{fwd_in_overlap.keys.join(',')} in twin node at positions #{fwd_in_overlap.values.join(',')} in #{fwd_overlap_sequence}\" if log.debug?\n #log.debug \"Looking for stops in #{twin_overlap_sequence}\" if log.debug?\n twin_in_overlap = word_search(twin_overlap_sequence, words, CODON_LENGTH)\n #log.debug \"Found codons #{twin_in_overlap.keys.join(',')} in twin node at positions #{twin_in_overlap.values.join(',')} in #{twin_overlap_sequence}\" if log.debug?\n\n # offset positions in overlap to be relative to start of node / twin node\n offset = onode.node.length_alone\n fwd_in_overlap.each{|word, inds| fwd_in_overlap[word] = inds.collect{|pos| pos + offset}}\n twin_in_overlap.each{|word, inds| twin_in_overlap[word] = inds.collect{|pos| pos + 1 - CODON_LENGTH}}\n #log.debug \"Codons in overlap positions relative to start of first node #{fwd_in_overlap.values.join(',')}\" if log.debug?\n #log.debug \"Codons in overlap positions relative to start of first twin node #{twin_in_overlap.values.join(',')}\" if log.debug?\n\n # assemble result\n fwd_result = SearchResult.new\n twin_result = SearchResult.new\n\n push_mark_to_list = lambda do |list, word, positions|\n if positions.has_key? word\n list.push positions[word].collect{|pos| make_marker.call pos}\n end\n end\n\n fwd_positions = fwd_within_first.merge fwd_in_overlap\n twin_positions = twin_within_first.merge twin_in_overlap\n START_CODONS.each do |word|\n # fwd starts\n push_mark_to_list.call(fwd_result.start_markers, word, fwd_positions)\n # twin starts\n push_mark_to_list.call(twin_result.start_markers, word, twin_positions)\n end\n fwd_result.start_markers.flatten!\n twin_result.start_markers.flatten!\n #log.debug \"Positions of start codons #{fwd_result.start_markers.join(',')}\" if log.debug?\n #log.debug \"Positions of start codons in twin node #{twin_result.start_markers.join(',')}\" if log.debug?\n\n STOP_CODONS.each do |word|\n #fwd stops\n push_mark_to_list.call(fwd_result.stop_markers, word, fwd_positions)\n # twin stops\n push_mark_to_list.call(twin_result.stop_markers, word, twin_positions)\n end\n fwd_result.stop_markers.flatten!\n twin_result.stop_markers.flatten!\n #log.debug \"Positions of stop codons #{fwd_result.stop_markers.join(',')}\" if log.debug?\n #log.debug \"Positions of stop codons in twin node #{twin_result.stop_markers.join(',')}\" if log.debug?\n\n\n return fwd_result, twin_result\n end", "def symbol_segments\n segments.select{ |s| s.is_a?(Symbol) }\n end", "def timecodes\n return [] if start_time.nil?\n start_hour = start_time.strftime(\"%H\")\n start_min = start_time.strftime(\"%M\").to_i < 30 ? \"00\" : \"30\"\n curr_time = Time.parse(\"#{start_hour}:#{start_min}\")\n timecode_array = []\n while curr_time < Time.parse(\"#{end_time.strftime(\"%H\")}:#{end_time.strftime(\"%M\")}\") - 1.second\n timecode_array << \"#{curr_time.strftime(\"%H\").to_i}:#{curr_time.strftime(\"%M\")}\"\n curr_time = curr_time + 30.minutes\n end\n timecode_array_with_days = []\n %w(monday tuesday wednesday thursday friday saturday sunday).each do |day|\n timecode_array_with_days << timecode_array.collect{|t| \"#{t}_#{day}\"}.flatten if read_attribute(day)\n end\n timecode_array_with_days.flatten\n end", "def order_list\n $tracer.trace(__method__)\n return GameStopOrderList.new(ToolTag.new(table.id(create_ats_regex_string(\"/ordersTable/\")).find.a.id(create_ats_regex_string(\"/lnkOrderDetail/\")), __method__))\n end", "def bulk_oclc_query(oclc_nos)\n string = \"srw.no any \\\"#{oclc_nos.first}\\\"\"\n oclc_nos[1..-1].each do |num|\n string << \" or srw.no any \\\"#{num}\\\"\"\n end\n string\nend", "def stops_to(lines, start_stop, end_stop)\n\tstart_line = find_line(lines, start_stop)\n\tend_line = find_line(lines, end_stop)\n\n\tif start_line == end_line # Just calculate the one distance \n\t\treturn line_distance(lines, start_line, start_stop, end_stop)\n\t\n\telse # Calculate distance for each line and direction from US seperately then add\n\t\tfirst_distance = line_distance(lines, start_line, start_stop, \"Union Square\")\n\t\tsecond_distance = line_distance(lines, end_line, \"Union Square\", end_stop)\n\t\treturn first_distance[0] + second_distance[0], first_distance[1] + second_distance[1]\n\tend\nend", "def stops_to(lines, start_stop, end_stop)\n\tstart_line = find_line(lines, start_stop)\n\tend_line = find_line(lines, end_stop)\n\n\tif start_line == end_line # Just calculate the one distance \n\t\treturn line_distance(lines, start_line, start_stop, end_stop)\n\t\n\telse # Calculate distance for each line and direction from US seperately then add\n\t\tfirst_distance = line_distance(lines, start_line, start_stop, \"Union Square\")\n\t\tsecond_distance = line_distance(lines, end_line, \"Union Square\", end_stop)\n\t\treturn first_distance[0] + second_distance[0], first_distance[1] + second_distance[1]\n\tend\nend", "def linedefs\n return @linedefs unless @linedefs.nil?\n _pos = @_io.pos\n @_io.seek((offset * 2))\n @linedefs = []\n i = 0\n begin\n _ = @_io.read_s2le\n @linedefs << _\n i += 1\n end until _ == -1\n @_io.seek(_pos)\n @linedefs\n end", "def get_users_stops_by_line(line,origin_stop,destination_stop)\n # stop_list is an array which is line details\n stop_list = get_stop_details(line)\n origin_stop_index = stop_list.index(origin_stop)\n destination_stop_index = stop_list.index(destination_stop)\n\n if origin_stop_index < destination_stop_index\n stop_list[origin_stop_index + 1..destination_stop_index]\n\n else\n stop_list[destination_stop_index..origin_stop_index - 1].reverse()\n end\n end", "def make_list(options)\n list = []\n to_switches(options).split(\" \").each do |a|\n list << a.gsub('\"', \"\")\n end\n list\n end", "def bib_lc_calls\n return_val = []\n\n Traject::MarcExtractor.cached(\"050:055:060:090\").each_matching_line(source_record) do |line|\n separated_calls = line.inject([]) do |results, subfield|\n if subfield.code == 'a'\n results << []\n end\n\n if ['a', 'b'].include? subfield.code\n results.last && (results.last << subfield.value)\n end\n\n results\n end\n\n return_val.concat separated_calls.collect {|arr| arr.join(\" \")}\n end\n\n return return_val\n end", "def complete_token(complete_ary, prefix)\n complete_ary.select { |cmd| cmd.to_s.start_with?(prefix) }.sort\n end", "def build_all_starts_ends(theDottedItems)\n productions_raw = theDottedItems.map(&:production)\n productions = productions_raw.uniq\n all_nterms = Set.new\n productions.each do |prod|\n all_nterms << prod.lhs\n nterms_of_rhs = prod.rhs.members.select do |symb|\n symb.kind_of?(Syntax::NonTerminal)\n end\n all_nterms.merge(nterms_of_rhs)\n end\n all_nterms.each { |nterm| build_start_end_for(nterm) }\n end", "def flags\n match(/Flags\\s+:\\s+(.+)$/).split rescue []\n end", "def flags\n match(/Flags\\s+:\\s+(.+)$/).split rescue []\n end", "def slice_of_css(start, stop)\n start == stop ? [start] : [start, *slice_of_css(start.next, stop)]\nend", "def sequence_separator; end", "def cow_list\n self.cows.split(' ').map do |cow|\n cow.split('-')[1]\n end.uniq.join(' ')\n end", "def list_of_train_direction(direction,trains)\n train_list = []\n trains.each do |train|\n if direction == train[:direction]\n train_list << train[:train]\n end\n end\n return train_list\nend", "def ooc_scan_type_list(gui_active_only = false)\n scan_types =OocScanType.find_by_sql(\"select ooc_scan_type\n from hip_ooc_scan_type_v #{\"where active_in_gui = 'y'\" if gui_active_only}\n group by grouping sets ((ooc_scan_type, ooc_group_type),(ooc_group_type))\n order by ooc_group_type, ooc_scan_type\")\n array=[]\n scan_types.each do |type|\n array.push(type['ooc_scan_type']) unless type['ooc_scan_type'].blank?\n array.push('--------------') if type['ooc_scan_type'].blank?\n end\n array.pop # remove the last blank line\n return array\n end", "def stations_on_line(code)\n Station.get_on_line(code)\n end", "def get_stops\n @agency = params[:agency]\n @route = params[:route]\n @direction = params[:direction] ? \"~\" + params[:direction] : \"\"\n\n request_url = \"http://services.my511.org/Transit2.0/GetStopsForRoute.aspx?token=#{@@token}&routeIDF=#{@agency}~#{@route}#{@direction}\"\n request_url = request_url.gsub(/ /,\"%20\")\n p parse_request(request_url)\n @stops = search_for_key(parse_request(request_url), \"Stop\") || []\n\n @stops = [@stops] unless @stops.kind_of?(Array)\n respond_to do |format|\n format.js {}\n end\n end", "def plan_trip (first_l, first_s, last_l, last_s)\n# Get the program to work for a single line:\n# Different way to do global use $\n stations = [ ]\n start = $train_lines[first_l.to_s].index(first_s.to_s)\n finish = $train_lines[last_l.to_s].index(last_s.to_s)\n\n# 2.7.2 :012 > $train_lines.values\n# => [[\"Times Square\", \"34th\", \"28th\", \"23rd\", \"Union Square\", \"8th\"], [\"8th\", \"6th\", \"Union Square\", \"3rd\", \"1st\"], [\"Grand Central\", \"33rd\", \"28th\", \"23rd\", \"Union Square\", \"Astor Place\"]]\n# 2.7.2 :013 > $train_lines.keys\n# => [\"lineN\", \"lineL\", \"line6\"]\n\n if start < finish\n stations = $lineN[start..finish]\n elsif\n stations = $lineN[finish..start].reverse\n end\n\n return stations\n\nend", "def before_and_after begin_delimeter, end_delimeter\n\n Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]\n\n before_after_lines = []\n in_middle_bit = false\n\n self.each do |candidate_line|\n\n is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_delimeter.downcase)\n if is_middle_boundary\n in_middle_bit = true\n next\n end\n\n unless in_middle_bit\n before_after_lines.push candidate_line\n next\n end\n\n #--\n #-- Now we are definitely in the middle bit.\n #-- Let's check for the middle end delimeter\n #--\n if candidate_line.downcase.include? end_delimeter.downcase\n in_middle_bit = false\n end\n\n end\n\n return before_after_lines\n\n end", "def getTripString(line, startStop, endStop) \n lineArray = getLine(line)\n string = \"\" # to save the station \n start_point = lineArray.index(startStop) # save the index of start point\n end_point = lineArray.index(endStop) # save the index of end point\n # p start_point \n # p end_point\n if start_point > end_point\n start_point.downto(end_point) do |j| \n string += \"#{lineArray[j]}, \"\n end\n else\n start_point.upto(end_point) do |j|\n string += \"#{lineArray[j]}, \"\n end \n end \n return string[0...-2] \nend", "def subsequence(range_start, range_end, start_seen_cb=nil, end_seen_cb=nil)\n result = []\n start_seen = range_start.nil?\n @contents.each{|c|\n if range_end and range_end.object_id == c.object_id\n end_seen_cb.call if end_seen_cb\n break \n end\n if range_start and range_start.object_id == c.object_id\n start_seen = true\n start_seen_cb.call if start_seen_cb\n next\n end\n if start_seen\n if c.is_a? XML\n break_me = false\n result += c.subsequence(nil, range_end, nil, lambda{break_me=true})\n break if break_me\n else # String/XML_PI/XML_Comment\n result << c\n end\n else\n # String/XML_PI/XML_Comment cannot start a subsequence\n if c.is_a? XML\n break_me = false\n result += c.subsequence(range_start, range_end, lambda{start_seen=true}, lambda{break_me=true})\n break if break_me\n end\n end\n }\n # Include starting tag if it was right from the range_start\n # Otherwise, return just the raw sequence\n result = [XML.new(@name, @attrs, result)] if range_start == nil\n return result\n end", "def saw_end_list(list); end", "def list_operations()\n\t\treturn @service.operations\n\tend", "def join_list(delim, list) { :'Fn::Join' => [ delim, list ] } end", "def filtrarObstaculos(cad)\n aux=[]\n cad.each do |elemento|\n if (elemento[0] == \"O\")\n aux.push(stringObstaculos(elemento))\n end\n end\n return aux #[[\"O\",3,2],......]\nend", "def run_list; end", "def separated_by1(sep, sym, &block)\n _defmetasyntax(\"separated_by1\", _intern(sym), block) {|target|\n seq(sym) {|x| [x] }\\\n | seq(target, sep, sym) {|list, _, x| list.push x; list }\n }\n end", "def exclude_ends list\n list[1..-2]\nend", "def custom_delimiters\r\n\t\toutput = []\r\n\t\toutput << input.split(\"]\\n\").first[3..-1].split(\"][\") if input.start_with?('//')\r\n\t\toutput.flatten\r\n\tend", "def get_splits\n @logical_splits\n end", "def split_range(range)\n start, finish = range.begin, range.end\n start += length if start < 0\n finish += length if finish < 0\n \n [start, finish - start - (range.exclude_end? ? 1 : 0)]\n end", "def start_dotted_items()\n start_symbol = grammar.start_symbol\n start_items = dotted_items.select do |anItem|\n (anItem.lhs == start_symbol) && anItem.at_start?\n end\n \n return start_items\n end", "def initialize(stops:)\n @stops = stops.scan(/\\b[\\w\\s\\/]+/im)\n convert_to_proper\n end", "def split_segments(data)\n pos = 0\n segments = []\n segments.append(data[pos...pos += RECORD_SIZE]) while pos < data.length\n segments\n end", "def get_runs str\n return nil if str.length < 2\n return [str] if str.length == 2\n result = []\n (2..str.length).each do |n|\n rest = str.dup\n start = rest.slice! 0, n\n runs = get_runs(rest)\n result << [start, runs] if runs\n end\n result+[str]\nend", "def roles\n @run_list.select do |rl|\n rl.start_with?('r_', 'p_', 'base_', 'os_', 'os-')\n end\n end", "def direction(compass, trainlist)\n nsew = []\n\n trainlist.each do |train|\n if train[:direction] == compass\n nsew << train[:train]\n end\n end\n return nsew\nend" ]
[ "0.6551506", "0.6436381", "0.5877394", "0.5872888", "0.5794939", "0.55063105", "0.54942244", "0.5348923", "0.529648", "0.51855886", "0.5170651", "0.5106918", "0.50936687", "0.504723", "0.5045142", "0.5041984", "0.5006834", "0.48837626", "0.4877997", "0.48402274", "0.4820959", "0.47402334", "0.47365916", "0.47276667", "0.47239628", "0.46820745", "0.46820745", "0.46799403", "0.46731883", "0.46636814", "0.4651049", "0.46454602", "0.46410388", "0.4640282", "0.46327004", "0.46315598", "0.46310526", "0.4621598", "0.4599939", "0.45922682", "0.45898113", "0.45776558", "0.45715564", "0.45615315", "0.4549546", "0.45425135", "0.45410866", "0.45375228", "0.45279598", "0.4522107", "0.45184085", "0.45098278", "0.45078984", "0.45054483", "0.4502934", "0.4502934", "0.45027837", "0.44989064", "0.44925886", "0.4486772", "0.44867462", "0.4481181", "0.44745046", "0.44731885", "0.44731885", "0.44699728", "0.4468678", "0.4465071", "0.4459219", "0.44512936", "0.4450007", "0.4446956", "0.4446956", "0.44332582", "0.44209144", "0.44003925", "0.4395738", "0.43946114", "0.4386889", "0.43845358", "0.4383762", "0.4380769", "0.43804696", "0.4379472", "0.43704253", "0.4366365", "0.4357635", "0.43532485", "0.43460825", "0.4345953", "0.434397", "0.43423524", "0.43423384", "0.4336205", "0.43257132", "0.43214512", "0.43192047", "0.43181345", "0.43175566", "0.43137306" ]
0.6950187
0
Splitter for one delimiter function. +include_leftmost+ decides the first sequence is returned when incomplete. +strip_leading+ is used to remove the shared codon with the last sequence.
def get_codon_orfs1 splitter_func,do_include_leftmost_orf,do_strip_leading_codon orfs = split(@codons,splitter_func) return [] if orfs.size == 0 # Drop the first sequence, if there is no match on the first position orfs.shift if !do_include_leftmost_orf and !splitter_func.call(orfs.first[0]) orfs = orfs.map { |codons| codons = codons.shift if do_strip_leading_codon and splitter_func.call(codons[0]) codons } if @reversed == nil TrackSequenceTrait.update_sequence_pos(orfs,@ntseq_pos) # nail against parent else TrackSequenceTrait.update_reversed_sequence_pos(orfs,@ntseq_pos) # nail against parent end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_and_after begin_delimeter, end_delimeter\n\n Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]\n\n before_after_lines = []\n in_middle_bit = false\n\n self.each do |candidate_line|\n\n is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_delimeter.downcase)\n if is_middle_boundary\n in_middle_bit = true\n next\n end\n\n unless in_middle_bit\n before_after_lines.push candidate_line\n next\n end\n\n #--\n #-- Now we are definitely in the middle bit.\n #-- Let's check for the middle end delimeter\n #--\n if candidate_line.downcase.include? end_delimeter.downcase\n in_middle_bit = false\n end\n\n end\n\n return before_after_lines\n\n end", "def split(pattern=$;, limit=0) end", "def split(pattern=$;, limit=0) end", "def split(parts); end", "def split; end", "def __split_string_on(delim, limit, limited, suppress_trailing_empty)\n results = []\n delim_length = delim.__size\n\n count = start = current = 0\n num = limited ? limit - 1 : 0\n lim = self.__size\n\n first_char = delim.__at(0)\n\n while current < lim\n if self.__at(current).eql?(first_char) and self.__at(current, delim_length).eql?(delim)\n results << self.__at(start, (current - start))\n count += 1\n start = current + delim_length\n current = start\n break if limited and count == num\n else\n current += 1\n end\n end\n\n results << self.__at(start, (lim-start)) unless limited and count > limit\n if suppress_trailing_empty\n while s = results.last and s.empty?\n results.pop\n end\n end\n results\n end", "def left_delimiter\n @left_delimiter || World.left_delimiter\n end", "def stripped_step(step, left_delimiter, right_delimiter)\n unless left_delimiter.nil? || right_delimiter.nil?\n pattern = Regexp.new(Regexp.escape(left_delimiter) + '.*?' + Regexp.escape(right_delimiter))\n step = step.gsub(pattern, left_delimiter + right_delimiter)\n end\n\n step\n end", "def make_delimiters\n ((self).split(//)*2+['',''])[0,2] # *2 doubles up single delimiters\n end", "def delimiter_tokeniser\n -> delimiter, f, enum { f.(enum).join(delimiter) }.curry\n end", "def preferred_delimiters; end", "def delimiter_never_precedes_last!\n options[:'delimiter-precedes-last'] = :never\n self\n end", "def delimiter_always_precedes_last!\n options[:'delimiter-precedes-last'] = :always\n self\n end", "def split_by_delimiter(delimiter = self.class.parsing_delimiter)\n return '' if body.nil? || body.empty?\n lines = body.split(\"\\n\")\n delim_line = last_line = found_empty = nil\n \n lines.each_with_index do |line, i|\n next if delim_line\n delim_line = i if line.include?(delimiter)\n end\n \n while !last_line && delim_line.to_i > 0\n delim_line = delim_line - 1\n if found_empty\n last_line = delim_line if lines[delim_line].strip.size > 0\n else\n found_empty = true if lines[delim_line].strip.size.zero?\n end\n end\n \n if last_line\n lines[0..delim_line] * \"\\n\"\n elsif delim_line.nil?\n body.strip\n else\n ''\n end\n end", "def split\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 38 )\n\n\n return_value = SplitReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_SPLIT197__ = nil\n __LPAR198__ = nil\n __RPAR200__ = nil\n __Identificador201__ = nil\n __EOL203__ = nil\n string199 = nil\n var_local202 = nil\n\n\n tree_for_K_SPLIT197 = nil\n tree_for_LPAR198 = nil\n tree_for_RPAR200 = nil\n tree_for_Identificador201 = nil\n tree_for_EOL203 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 184:4: K_SPLIT LPAR string RPAR ( Identificador | var_local ) EOL\n __K_SPLIT197__ = match( K_SPLIT, TOKENS_FOLLOWING_K_SPLIT_IN_split_872 )\n if @state.backtracking == 0\n tree_for_K_SPLIT197 = @adaptor.create_with_payload( __K_SPLIT197__ )\n @adaptor.add_child( root_0, tree_for_K_SPLIT197 )\n\n end\n\n __LPAR198__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_split_874 )\n if @state.backtracking == 0\n tree_for_LPAR198 = @adaptor.create_with_payload( __LPAR198__ )\n @adaptor.add_child( root_0, tree_for_LPAR198 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_string_IN_split_876 )\n string199 = string\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, string199.tree )\n end\n\n __RPAR200__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_split_878 )\n if @state.backtracking == 0\n tree_for_RPAR200 = @adaptor.create_with_payload( __RPAR200__ )\n @adaptor.add_child( root_0, tree_for_RPAR200 )\n\n end\n\n # at line 184:29: ( Identificador | var_local )\n alt_28 = 2\n look_28_0 = @input.peek( 1 )\n\n if ( look_28_0 == Identificador )\n alt_28 = 1\n elsif ( look_28_0 == DOUBLEDOT )\n alt_28 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 28, 0 )\n\n end\n case alt_28\n when 1\n # at line 184:30: Identificador\n __Identificador201__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_split_881 )\n if @state.backtracking == 0\n tree_for_Identificador201 = @adaptor.create_with_payload( __Identificador201__ )\n @adaptor.add_child( root_0, tree_for_Identificador201 )\n\n end\n\n\n when 2\n # at line 184:44: var_local\n @state.following.push( TOKENS_FOLLOWING_var_local_IN_split_883 )\n var_local202 = var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, var_local202.tree )\n end\n\n\n end\n __EOL203__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_split_886 )\n if @state.backtracking == 0\n tree_for_EOL203 = @adaptor.create_with_payload( __EOL203__ )\n @adaptor.add_child( root_0, tree_for_EOL203 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 38 )\n\n\n end\n\n return return_value\n end", "def split_and_strip(s, delimiter: \"|\", filter_blanks: true)\n if s && s.length > 0\n pieces = s.split(delimiter).map { |atom| atom.strip }\n else\n # blank str should split into 1 item list\n pieces = [\"\"]\n end\n if filter_blanks\n pieces = pieces.select { |atom| !atom.nil? && atom.length > 0 }\n end\n pieces\n end", "def code_splitter(code)\n student_code = []\n code = code.split('startTraceNow();')\n new_code = code[1].split('endTraceNow();')\n executed_code = new_code[0]\n executed_code_list = executed_code.split('\\\\n')\n flag = false\n counter = 0\n until flag\n if executed_code_list[counter] == '' || executed_code_list[counter] == ' '\n flag = false\n counter += 1\n elsif executed_code_list[counter] != ''\n flag = true\n end\n end\n x = counter\n while x < executed_code_list.length\n temp = executed_code_list[x]\n temp = temp.strip\n student_code << executed_code_list[x] unless temp.empty?\n\n x += 1\n end\n student_code\nend", "def split codons, is_splitter_func\n list = []\n node = []\n codons.each_with_index do | c, pos |\n # p [c,pos]\n if is_splitter_func.call(c)\n node.push c\n size = node.size\n # p node\n list.push FrameCodonSequence.new(node,pos+1-size) if size > @min_size_codons\n node = []\n end\n node.push c # always push boundary codon\n end\n list\n end", "def split_definition(raw_def)\n # TODO: your implementation here\n\n #breaks down the non-terminal and the elements for the non-terminal\n raw_def = raw_def.map {|x| x.sub(/>/, '>;')}\n raw_def = raw_def.map{|x| x.strip}\n raw_def = raw_def.map{|x| x.split(/;/).flatten.map{|y| y.strip}}\n raw_def = raw_def.map{|x| x.map{|x| x.strip}}\n\nend", "def delimiters\n @delimiters ||= COMMON_DELIMITERS.inject({}, &count).sort(&most_found)\n end", "def _sep\n\n _save = self.pos\n while true # sequence\n\n _save1 = self.pos\n while true # choice\n _tmp = apply(:_end_hyphen_of_hyphen_line)\n break if _tmp\n self.pos = _save1\n _tmp = apply(:_comma)\n break if _tmp\n self.pos = _save1\n break\n end # end choice\n\n unless _tmp\n self.pos = _save\n break\n end\n while true\n\n _save3 = self.pos\n while true # choice\n _tmp = apply(:_space)\n break if _tmp\n self.pos = _save3\n _tmp = apply(:_comment)\n break if _tmp\n self.pos = _save3\n _tmp = apply(:_end_hyphen_of_hyphen_line)\n break if _tmp\n self.pos = _save3\n _tmp = apply(:_comma)\n break if _tmp\n self.pos = _save3\n break\n end # end choice\n\n break unless _tmp\n end\n _tmp = true\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_sep unless _tmp\n return _tmp\n end", "def split_first_line(line)\n title, date, tags = line.split('|')\n tags = tags.strip.split(',')\n return title, date, tags\nend", "def splitter (start, stop, separator)\n\n\t\tif not ((start == nil) or (@tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == start))\n\t\t\tthrow_error(\"You should not be here splitter() expected #{start} and got #{@tokens.peak}.\", @tokens.peak)\n\t\tend\n\n\t\tvars = []\n\t\tif start != nil\n\t\t\[email protected]\n\t\tend\n\t\tif @tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == stop\n\t\t\[email protected]\n\t\t\treturn nil # No arguments, not error\n\t\tend\n\t\twhile true\n\t\t\tnext_ast_node = parse_next\n\t\t\tif is_operation\n\t\t\t\tnext_ast_node = parse_operation(next_ast_node, true) # Place tuple in left side of operation.\n\t\t\tend\n\n\t\t\tif not next_ast_node \n\t\t\t\tthrow_error(\"Closing token '#{stop}' not found, reached EOF.\", vars[0]) \n\t\t\telse\n\t\t\t\tvars.append(next_ast_node)\n\t\t\tend\n\t\t\tif @tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == stop\n\t\t\t\[email protected]\n\t\t\t\tbreak\n\t\t\telsif not ((@tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == separator) or separator == nil)\n\t\t\t\tthrow_error(\"Expected seperator '#{separator}', found: #{@tokens.peak}\", @tokens.peak)\n\t\t\tend\n\n\t\t\tif not separator == nil\n\t\t\t\[email protected] # Remove separator token\n\t\t\tend\n\t\tend\n\n\t\treturn vars\n\tend", "def extract_parts\n parts_regex = /\n (?: # non-capturing group\n \\A | # start of string OR\n \\r\\n # line break\n )\n (\n --#{Regexp.escape(boundary || \"\")} # boundary delimiter\n (?:--)? # with non-capturing optional closing\n )\n (?=\\s*$) # lookahead matching zero or more spaces followed by line-ending\n /x\n parts = raw_source.split(parts_regex).each_slice(2).to_a\n parts.each_with_index { |(part, _), index| parts.delete_at(index) if index > 0 && part.blank? }\n\n if parts.size > 1\n final_separator = parts[-2][1]\n parts << [\"\"] if final_separator != \"--#{boundary}--\"\n end\n parts.map(&:first)\n end", "def _strip seq\n seq.shift while (tok = seq.first) && tok.type == :endline\n end", "def _tokenize_from_delimiterized(delimiter)\n d = Regexp.escape(delimiter)\n p = /[a-z]+#{d}?(?![a-z])/\n\n self.scan(p).compact\n end", "def split_by_delimiter\n dn_string.split(delimiter).reject(&:empty?)\n end", "def split_code\n index = self.code_index\n self.split_at index if index\n end", "def skip_list_continuation\n if [email protected]? && @lines.first.chomp == '+'\n @lines.shift\n end\n\n nil\n end", "def split_by(array, delim)\n ret = []\n a = []\n array.each do |i|\n if i == delim then\n ret << a\n a = []\n else\n a << i\n end\n end\n ret << a unless a.empty?\n return ret\n end", "def split(position)\n end", "def split(position)\n end", "def splitter(str)\n @madlib = str.split\n end", "def parse_input(line)\n prefix, suffix = line.split '|'\n prefixes = unless prefix.nil? then prefix.split(';') else [] end\n suffixes = unless suffix.nil? then suffix.split(';') else [] end\n return prefixes, suffixes\nend", "def split_identifier_and_qualifier(sf_value)\n sf_value.split(/[\\(\\)\\[\\]]/).map(&:strip).delete_if { |str| str.empty? }\n end", "def initial_Headers_Split(initial_and_headers)\n\tif initial_and_headers.include?(\"\\r\\n\") # if body exist, a blank line must exist\n\t\tinitial,headers = initial_and_headers.split(\"\\r\\n\",2)\n\telse\n\t\tinitial,headers = initial_and_headers,''\n\tend\nend", "def separator\n nil\n end", "def tokenize; end", "def tokenize; end", "def on_call_substring_before(context, haystack, needle)\n haystack_str = on_call_string(context, haystack)\n needle_str = on_call_string(context, needle)\n\n before, sep, after = haystack_str.partition(needle_str)\n\n return sep.empty? ? sep : before\n end", "def extract_separator\n if meta_tags[:separator] == false\n # Special case: if separator is hidden, do not display suffix/prefix\n prefix = separator = suffix = \"\"\n else\n prefix = extract_separator_section(:prefix, \" \")\n separator = extract_separator_section(:separator, \"|\")\n suffix = extract_separator_section(:suffix, \" \")\n end\n delete(:separator, :prefix, :suffix)\n\n TextNormalizer.safe_join([prefix, separator, suffix], \"\")\n end", "def delimiter\n \" \"\n end", "def delimiter\n \" \"\n end", "def sequence_separator; end", "def separator; end", "def split pattern=$;, *more\n arr = super\n i = 0\n interval = 0\n interval = (self.length - arr.join.length) / (arr.length - 1) if\n arr.length > 1\n\n arr.map do |str|\n ds = self.class.new str\n ds.meta = @meta[i,str.length]\n i += str.length + interval\n ds\n end\n end", "def readlines(sep=$/) end", "def split_ions\n self.ions.split(',') rescue []\n end", "def readlines(sep=$/) end", "def separated_by1(sep, sym, &block)\n _defmetasyntax(\"separated_by1\", _intern(sym), block) {|target|\n seq(sym) {|x| [x] }\\\n | seq(target, sep, sym) {|list, _, x| list.push x; list }\n }\n end", "def delimiter_contextually_precedes_last!\n options[:'delimiter-precedes-last'] = :contextual\n self\n end", "def auto_trim?; end", "def left_strip(str)\n output = \"\"\n whitespace = \"\\n\\t \"\n i = 0\n left = true\n while i < str.length\n if !left\n output << str[i]\n elsif !whitespace.include? str[i]\n left = false\n output << str[i]\n end\n i+=1\n end\n return output\nend", "def separar_Bloques(bloque)\n bloques_lista = []\n auto_instruccion = \"\"\n salto_de_linea = 0\n saltos_de_linea = bloque.count(@@separador_linea)\n while (bloque!=\"\")\n fin_de_linea = bloque.index(@@separador_linea)\n if (fin_de_linea==nil)\n if (auto_instruccion!=\"\")\n cantidad_de_separadores = bloque.count(\",\") + bloque.count(\" \")\n if (cantidad_de_separadores == 2)\n bloques_lista.push(auto_instruccion)\n auto_instruccion = \"\"\n bloques_lista.push(bloque)\n end\n if (cantidad_de_separadores == 0)\n bloques_lista.push(auto_instruccion+@@separador_linea+bloque)\n auto_instruccion = \"\"\n end\n else\n bloques_lista.push(bloque) \n end\n bloque=\"\"\n next\n end\n linea = bloque[0..fin_de_linea-1]\n cantidad_de_separadores = linea.count(\",\") + linea.count(\" \")\n if (cantidad_de_separadores == 2)\n if (auto_instruccion!=\"\")\n bloques_lista.push(auto_instruccion)\n auto_instruccion = \"\"\n end\n auto_instruccion = linea\n end\n if (cantidad_de_separadores == 0)\n auto_instruccion = auto_instruccion+ ((auto_instruccion!=\"\")? @@separador_linea : '') + linea\n bloques_lista.push(auto_instruccion)\n auto_instruccion = \"\"\n end\n bloque = bloque[fin_de_linea+(@@separador_linea.length())..bloque.length()] \n end\n\n auto_instruccion = auto_instruccion+ ((auto_instruccion!=\"\")? @@separador_linea : '') + bloque\n bloques_lista.push(auto_instruccion)\n return bloques_lista\nend", "def lstrip() end", "def tokenize ; end", "def tokenize ; end", "def split_definition(raw_def)\n # removes extra newlines\n tokens = raw_def.strip.split(\"\\n\")\n tokens2 = tokens.map {|element| element.delete(\";\").strip}\nend", "def delimited_mode(param_1=nil)\n if param_1.class == String && !block_given?\n return @j_del.java_method(:delimitedMode, [Java::java.lang.String.java_class]).call(param_1)\n elsif param_1.class.method_defined?(:j_del) && !block_given?\n return @j_del.java_method(:delimitedMode, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(param_1.j_del)\n end\n raise ArgumentError, \"Invalid arguments when calling delimited_mode(param_1)\"\n end", "def sequence_separator=(_arg0); end", "def sequence_separator=(_arg0); end", "def custom_delimiters\r\n\t\toutput = []\r\n\t\toutput << input.split(\"]\\n\").first[3..-1].split(\"][\") if input.start_with?('//')\r\n\t\toutput.flatten\r\n\tend", "def lsep\n \"==================================================================================\"\n end", "def no_auto_trim!; end", "def split(pattern = $; || ' ', limit = undefined)\n `#{self}.split(pattern,limit)`\n end", "def split(pattern = $; || ' ', limit = undefined)\n `#{self}.split(pattern,limit)`\n end", "def split(separator)\n lambda do |rec, acc|\n acc.replace( acc.flat_map { |v| v.split(separator) } )\n end\n end", "def sep; end", "def sep; end", "def separa(tira)\n\t#función usada para separar album | banda\n\ttira = tira.split('|')\n\treturn tira\nend", "def line_splitter(tsv)\n tsv.split(\"\\n\")\n end", "def split_header_from_body(lines)\n\t\thead, tail = \n\t\t\tlines\n\t\t\t.each_with_index # iterate with indexes (generates pairs)\n\t\t\t.partition{|x,i| i < lines.rindex('---')} # split into before and after the final '---'\n\t\t\t.collect{|i| i.collect{|j| j.first}} # flatten inner array, discarding indexes\n\t\t\n\t\t# discard first element of both arrays\n\t\t# (those are just the '---' lines)\n\t\thead.shift\n\t\ttail.shift\n\t\t\n\t\treturn head, tail\n\tend", "def auto_trim!; end", "def deconcatnating\n puts \"The Deconcatenated String is:\"\n val = @value.split(/\\s/)\n end", "def readline(sep=$/) end", "def readline(sep=$/) end", "def split_into_start_and_end(string)\n super(string)\n string = string.split(\"-\")\n string = string[0].split(\"and\") if string.size == 1\n string = string[0].split(\"&\") if string.size == 1\n string = string[0].split(\"through\") if string.size == 1\n string = string[0].split(\"to\") if string.size == 1\n string\n end", "def left_strip(str)\n chars = \"\\n\\t \"\n i = 0\n while i < chars.length\n if str[0] == chars[i]\n str.slice!(0)\n end\n i += 1\n end\n return str\nend", "def split(pat, limit)\n end", "def key_splitter(lines)\n lines[0].split(\"\\t\")\n end", "def split(*args)\n ::StricterGlobalUsage::Strategy.apply('String#split') if args.length.zero?\n split_without_global_check(*args)\n end", "def _FrontmatterSeparator\n\n _save = self.pos\n while true # sequence\n _tmp = apply(:__hyphen_)\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = match_string(\"---\")\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:__hyphen_)\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:_Nl)\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_FrontmatterSeparator unless _tmp\n return _tmp\n end", "def separator(type); end", "def tokenize\n \n end", "def leading; end", "def alignContinuations(theLines)\n\n\tsplitAndAlign(theLines, /^(.*?)\\s+(\\\\)$/, \"\");\n\nend", "def _tokenize_from_camelized(delimiter, raw_first)\n d = Regexp.escape(delimiter)\n p = /(?:[A-Z]+|[A-Z]?(?:[a-z]{2,}#{d}?|[a-z]))(?![a-z])/;\n # (?: : token body\n # [A-Z]+ : acronym\n # | : or\n # [A-Z]?(?:[a-z]{2,}#{d}?|[a-z]) : usual word|first in camelCase|\n # )\n # (?![a-z]) : break word same as (?=[A-Z]|_|$)\n tokens = self.scan(p)\n\n # Upcase for acronym of first word in camelCase.\n tokens[0] = tokens[0].studly_caps(delimiter) unless raw_first\n\n tokens\n end", "def even_splitters(string)\r\n\r\nend", "def split_words(line)\n return line.scan(%r{[,;:]+|[^;: ,]+|(?=[ ]+)}).reject { |e| e.empty? }\n end", "def splits\n []\n end", "def get_codon_orfs2 splitter_func, start_func\n orfs = get_codon_orfs1(splitter_func,true,true)\n orfs.find_all { | orf | start_func.call(orf[0]) }\n end", "def split_header\n self.fields = raw_source.split(HEADER_SPLIT)\n end", "def left_strip(string)\n whitespaces = [\"\\n\", \"\\t\"]\n i = 0\n output = \"\"\n while i<=string.length-1\n if string[i] == whitespaces[1] || string[i] == whitespaces[2]\n i+=1 \n else\n while i<=string.length-1\n output += string[i]\n i+=1\n end\n return output\n end\n end\n return output\nend", "def my_split(string, divider)\n array = []\n current_element = ''\n\n formatted_string = string.clone\n formatted_string.strip!\n\n formatted_string.each_char do |char|\n if char == divider\n array << current_element\n current_element = ''\n else\n current_element << char\n end\n end\n\n array << current_element\n\n array\nend", "def chomp!(sep=$/)\n return nil if sep._equal?(nil)\n my_size = self.__size\n return nil if my_size._equal?(0)\n sep = Maglev::Type.coerce_to(sep, String, :to_str)\n if sep == \"\\n\"\n last_ch = self.__at(-1)\n diminish_by = 0\n if last_ch.eql?( ?\\n )\n diminish_by += 1 if self.__at(-2).eql?( ?\\r ) && my_size > 1\n elsif last_ch.not_eql?( ?\\r )\n return nil\n end\n diminish_by += 1\n self.__size=(my_size - diminish_by)\n else\n separator_sz = sep.__size\n if separator_sz._equal?(0)\n sz = my_size\n while sz > 0 && self.__at(sz-1).eql?( ?\\n )\n if sz > 1 && self.__at(sz-2).eql?( ?\\r )\n sz -= 2\n else\n sz -= 1\n end\n end\n return nil if sz._equal?( my_size )\n self.__size=(sz)\n else\n sep_size = separator_sz\n sz = my_size\n return nil if sep_size > sz\n sep_size = -sep_size\n while sep_size < 0\n return nil if sep.__at(sep_size) != self.__at(sep_size)\n sep_size += 1\n end\n self.__size=(sz - separator_sz)\n end\n end\n self\n end", "def shell_split; end", "def sonde_data_filter(iterator)\n cut_line(iterator)\n head1 = cut_line(iterator)\n head1_csv = CSV.parse(head1).flatten\n head1_csv.collect!{|str| str.strip}\n \n head2 = cut_line(iterator)\n head2_csv = CSV.parse(head2).flatten\n head2_csv.collect!{|str| str.strip}\n cut_line(iterator)\n \n merged_str = merge_headers(head1_csv, head2_csv, \" \", \"[\", \"]\")\n \n new_head = merged_str.join(',')\n new_head << \"\\r\\n\"\n new_iterator = new_head << iterator\n #puts new_iterator\n return new_iterator\n end", "def split\n p @rev_name\n @split_name = @rev_name.split('')\n p @split_name\nend", "def delim!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n\n\n type = DELIM\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 305:3: '|'\n match( 0x7c )\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__, 13 )\n\n\n end", "def split_header_list\n %w[artist copyright character general meta]\n end" ]
[ "0.5947802", "0.59163254", "0.59163254", "0.57690996", "0.57373065", "0.5653975", "0.5632193", "0.5561947", "0.5527968", "0.5478926", "0.5458706", "0.5455709", "0.5450381", "0.5428848", "0.5418789", "0.54041255", "0.5402338", "0.53792846", "0.5364278", "0.53293383", "0.5325308", "0.53245157", "0.53139263", "0.5290431", "0.5255071", "0.52202755", "0.5216219", "0.5153336", "0.5152476", "0.513659", "0.5121128", "0.5121128", "0.51009375", "0.5079712", "0.50772846", "0.50746655", "0.50482523", "0.50471723", "0.50471723", "0.5040257", "0.50387216", "0.5036981", "0.5036981", "0.5012314", "0.5007422", "0.5002035", "0.50015694", "0.50013053", "0.5001212", "0.498054", "0.49707225", "0.49688196", "0.4957757", "0.49520668", "0.49452156", "0.49324483", "0.49324483", "0.4927479", "0.49233028", "0.49176005", "0.49176005", "0.49169824", "0.49017537", "0.49008447", "0.48936865", "0.48936865", "0.48912534", "0.4884118", "0.4884118", "0.48838168", "0.48833504", "0.48826346", "0.48627955", "0.4851997", "0.4832473", "0.4832473", "0.48305193", "0.4827204", "0.48256505", "0.48221034", "0.48217484", "0.48147807", "0.4812967", "0.48061034", "0.48005855", "0.47979024", "0.4790902", "0.4787733", "0.4781785", "0.4778186", "0.47685915", "0.47674525", "0.4761368", "0.47595492", "0.47567543", "0.47506252", "0.4746849", "0.47460964", "0.4742608", "0.47395313" ]
0.60272354
0
Splitter for two delimeter functions
def get_codon_orfs2 splitter_func, start_func orfs = get_codon_orfs1(splitter_func,true,true) orfs.find_all { | orf | start_func.call(orf[0]) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split(parts); end", "def split; end", "def split(pattern=$;, limit=0) end", "def split(pattern=$;, limit=0) end", "def make_delimiters\n ((self).split(//)*2+['',''])[0,2] # *2 doubles up single delimiters\n end", "def splitter(data)\n data.split(%r{(?:@)[^\\s]+|(?:http)s?:\\/[^\\s]+|\\W}).reject(&:empty?)\n end", "def even_splitters(string)\r\n\r\nend", "def split(separator)\n lambda do |rec, acc|\n acc.replace( acc.flat_map { |v| v.split(separator) } )\n end\n end", "def delimiter_tokeniser\n -> delimiter, f, enum { f.(enum).join(delimiter) }.curry\n end", "def split_string(filter)\n filter.split('-')\n end", "def parse_input(line)\n prefix, suffix = line.split '|'\n prefixes = unless prefix.nil? then prefix.split(';') else [] end\n suffixes = unless suffix.nil? then suffix.split(';') else [] end\n return prefixes, suffixes\nend", "def preferred_delimiters; end", "def seperate (foo, bar=\"-\")\n foo.split(\"\").join(bar)\nend", "def split pattern=$;, *more\n arr = super\n i = 0\n interval = 0\n interval = (self.length - arr.join.length) / (arr.length - 1) if\n arr.length > 1\n\n arr.map do |str|\n ds = self.class.new str\n ds.meta = @meta[i,str.length]\n i += str.length + interval\n ds\n end\n end", "def splitter (start, stop, separator)\n\n\t\tif not ((start == nil) or (@tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == start))\n\t\t\tthrow_error(\"You should not be here splitter() expected #{start} and got #{@tokens.peak}.\", @tokens.peak)\n\t\tend\n\n\t\tvars = []\n\t\tif start != nil\n\t\t\[email protected]\n\t\tend\n\t\tif @tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == stop\n\t\t\[email protected]\n\t\t\treturn nil # No arguments, not error\n\t\tend\n\t\twhile true\n\t\t\tnext_ast_node = parse_next\n\t\t\tif is_operation\n\t\t\t\tnext_ast_node = parse_operation(next_ast_node, true) # Place tuple in left side of operation.\n\t\t\tend\n\n\t\t\tif not next_ast_node \n\t\t\t\tthrow_error(\"Closing token '#{stop}' not found, reached EOF.\", vars[0]) \n\t\t\telse\n\t\t\t\tvars.append(next_ast_node)\n\t\t\tend\n\t\t\tif @tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == stop\n\t\t\t\[email protected]\n\t\t\t\tbreak\n\t\t\telsif not ((@tokens.peak and @tokens.peak.type == \"Punctuation\" and @tokens.peak.value == separator) or separator == nil)\n\t\t\t\tthrow_error(\"Expected seperator '#{separator}', found: #{@tokens.peak}\", @tokens.peak)\n\t\t\tend\n\n\t\t\tif not separator == nil\n\t\t\t\[email protected] # Remove separator token\n\t\t\tend\n\t\tend\n\n\t\treturn vars\n\tend", "def splitter(str)\n @madlib = str.split\n end", "def split_into_start_and_end(string)\n super(string)\n string = string.split(\"-\")\n string = string[0].split(\"and\") if string.size == 1\n string = string[0].split(\"&\") if string.size == 1\n string = string[0].split(\"through\") if string.size == 1\n string = string[0].split(\"to\") if string.size == 1\n string\n end", "def seperate strings, seperator=\"-\"\n strings.downcase.split(\"\").join(seperator)\nend", "def seperate(word, seperator=\"-\")\n word.downcase.split(\"\").join(seperator)\nend", "def custom_delimiters\r\n\t\toutput = []\r\n\t\toutput << input.split(\"]\\n\").first[3..-1].split(\"][\") if input.start_with?('//')\r\n\t\toutput.flatten\r\n\tend", "def split_identifier_and_qualifier(sf_value)\n sf_value.split(/[\\(\\)\\[\\]]/).map(&:strip).delete_if { |str| str.empty? }\n end", "def tokenize; end", "def tokenize; end", "def shell_split; end", "def seperate(str,seperator='-')\n str.split('').join(seperator)\nend", "def seperate (string, seperator=\"-\")\n string.downcase.split(\"\").join(seperator)\nend", "def split(str, on)\n str.split(on)\n end", "def tokenize ; end", "def tokenize ; end", "def tokenize_string(input_string, delimiter_list) \n\tinput_string.sub(\",\", \"\").sub(\".\", \"\").split(delimiter_list)\nend", "def tokenize\n return @value.split(/\\s+/)\n end", "def splitter(input)\n array = input.downcase.split('')\nend", "def scan_for_commas(token); end", "def split_merged_tag_values!(key1, key2, seperator)\n if self[key1] =~ Regexp.new(\"([^#{seperator}]+)#{seperator}([^#{seperator}]+)\")\n self[key1],self[key2]= $1,$2\n end\n end", "def split(pat, limit)\n end", "def split_by_delimiter\n dn_string.split(delimiter).reject(&:empty?)\n end", "def seperate string, seperator=\"-\"\n string.split(\"\").join(seperator)\nend", "def _tokenize_from_delimiterized(delimiter)\n d = Regexp.escape(delimiter)\n p = /[a-z]+#{d}?(?![a-z])/\n\n self.scan(p).compact\n end", "def split_definition(raw_def)\n # TODO: your implementation here\n\n #breaks down the non-terminal and the elements for the non-terminal\n raw_def = raw_def.map {|x| x.sub(/>/, '>;')}\n raw_def = raw_def.map{|x| x.strip}\n raw_def = raw_def.map{|x| x.split(/;/).flatten.map{|y| y.strip}}\n raw_def = raw_def.map{|x| x.map{|x| x.strip}}\n\nend", "def seperate(str, separator=\"-\")\n str.split(\"\").join(separator)\nend", "def my_split(string, divider)\n array = []\n current_element = ''\n\n formatted_string = string.clone\n formatted_string.strip!\n\n formatted_string.each_char do |char|\n if char == divider\n array << current_element\n current_element = ''\n else\n current_element << char\n end\n end\n\n array << current_element\n\n array\nend", "def before_and_after begin_delimeter, end_delimeter\n\n Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]\n\n before_after_lines = []\n in_middle_bit = false\n\n self.each do |candidate_line|\n\n is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_delimeter.downcase)\n if is_middle_boundary\n in_middle_bit = true\n next\n end\n\n unless in_middle_bit\n before_after_lines.push candidate_line\n next\n end\n\n #--\n #-- Now we are definitely in the middle bit.\n #-- Let's check for the middle end delimeter\n #--\n if candidate_line.downcase.include? end_delimeter.downcase\n in_middle_bit = false\n end\n\n end\n\n return before_after_lines\n\n end", "def split_phrase(phrase, delimeter = ' ')\n phrase.blank? ? [\"\"] : phrase.split(delimeter).collect(&:strip)\n end", "def set_delimiter delim\n @lt2_delimiter = case delim\n when Regexp\n delim\n else\n delim.to_s\n end\n end", "def normalize_delimiters!\n @content.each { |item| item[:delimiter] = default_delimiter if item[:type] == :value }\n end", "def split_by_separator(affi_string, auth_id)\n tokens = []\n if affi_string.include?(\",\") and affi_string.include?(\";\")\n tokens = affi_string.split(\";\")\n tokens.each do |token|\n if token.include?(\",\")\n split_idx = tokens.find_index(token)\n temp_tkns = token.split(\",\")\n tokens = tokens[1..split_idx-1].concat(temp_tkns).concat(tokens[split_idx+1..])\n end\n end\n elsif affi_string.include?(\",\")\n tokens = affi_string.split(\",\")\n elsif affi_string.include?(\";\")\n tokens = affi_string.split(\";\")\n end\n\n if tokens != []\n return create_affi_obj(tokens, auth_id)\n else\n return nil\n end\nend", "def key_splitter(lines)\n lines[0].split(\"\\t\")\n end", "def split_and_sub(sep,multi_def,multi)\t\n\t\t\t\tcmd_line = []\n\t\t\t\tmulti.split(sep).each do |sample_name|\n\t\t\t\t\tcmd_line << sub_placeholders(multi_def,self.samples_obj[sample_name])\n\t\t\t\tend\n\t\t\t\tcmd_line.join(sep)\n\t\t\tend", "def my_split(string, delimiter)\n\n array = []\n el = ''\n string.each_char{|char|\n if char != delimiter\n el = el + char\n else\n array << el\n el = ''\n end\n }\n array << el\n array\nend", "def set_delimiters(start, stop)\n @start_delim = start\n @stop_delim = stop\n puts \"FileGenTask: Setting token delimeters to #{@start_delim}, #{@stop_delim}\" if @verbose\n end", "def split(_ = $;, _ = 0, &blk)\n parts = Timestamp.split_stamp(@str)\n if blk.nil?\n parts\n else\n parts.each { |p| yield p }\n self\n end\n end", "def split(pattern = $; || ' ', limit = undefined)\n `#{self}.split(pattern,limit)`\n end", "def split(pattern = $; || ' ', limit = undefined)\n `#{self}.split(pattern,limit)`\n end", "def _separate args, pattern=nil #/^[a-zA-Z]/ \n tag = nil\n items = []\n args.each do |arg| \n if arg =~ /^[0-9\\.]+$/\n items << arg\n else\n tag = arg\n if pattern\n die \"#{@action}: #{arg} appears invalid.\" if arg !~ pattern\n end\n end\n end\n items = nil if items.empty?\n return tag, items\n end", "def fields(text) \n p text.split(/[,\\s]+/)\nend", "def split\n p @rev_name\n @split_name = @rev_name.split('')\n p @split_name\nend", "def tokenize\n \n end", "def extract_separator\n if meta_tags[:separator] == false\n # Special case: if separator is hidden, do not display suffix/prefix\n prefix = separator = suffix = \"\"\n else\n prefix = extract_separator_section(:prefix, \" \")\n separator = extract_separator_section(:separator, \"|\")\n suffix = extract_separator_section(:suffix, \" \")\n end\n delete(:separator, :prefix, :suffix)\n\n TextNormalizer.safe_join([prefix, separator, suffix], \"\")\n end", "def stripped_step(step, left_delimiter, right_delimiter)\n unless left_delimiter.nil? || right_delimiter.nil?\n pattern = Regexp.new(Regexp.escape(left_delimiter) + '.*?' + Regexp.escape(right_delimiter))\n step = step.gsub(pattern, left_delimiter + right_delimiter)\n end\n\n step\n end", "def parse( line )\r\n line.split(';')\r\nend", "def line_splitter(tsv)\n tsv.split(\"\\n\")\n end", "def fields(string)\n string.split(/[,\\t ]+/)\nend", "def split(*args)\n ::StricterGlobalUsage::Strategy.apply('String#split') if args.length.zero?\n split_without_global_check(*args)\n end", "def split_name\n\t\t@full_name.split('')\n\tend", "def sep; end", "def sep; end", "def separate word7, separator=\"-\"\n word7.split(\"\").join(separator)\nend", "def split_line(line)\n line.split(Mergeit::Config::FILE_FORMAT[:delimeter], Mergeit::Config::SUPPORTED_PARTS[:size])\n end", "def fields(string)\n string.split(/[\\t, ]+/) #split on all one or more instances of tabs, commas, or spaces\nend", "def split_first_lastname s\n last,first = s.split(/,/,2)\n first = '' if first == nil\n return first,last.capitalize\n end", "def split_path(path)\n path.strip.split(/[,;:\\ \\n\\t]/).map{|s| s.strip}\n end", "def process(value)\n split(value).collect {|val| super(val) }\n end", "def split_words(line)\n return line.scan(%r{[,;:]+|[^;: ,]+|(?=[ ]+)}).reject { |e| e.empty? }\n end", "def deconcatnating\n puts \"The Deconcatenated String is:\"\n val = @value.split(/\\s/)\n end", "def split_definition(raw_def)\n # removes extra newlines\n tokens = raw_def.strip.split(\"\\n\")\n tokens2 = tokens.map {|element| element.delete(\";\").strip}\nend", "def separator(type); end", "def splitter_params\n params.fetch(:splitter, {})\n end", "def parse_element_delim(str)\n (str && str.kind_of?(String)) ? str.slice(3,1) : \"|\"\n end", "def split_and_strip(s, delimiter: \"|\", filter_blanks: true)\n if s && s.length > 0\n pieces = s.split(delimiter).map { |atom| atom.strip }\n else\n # blank str should split into 1 item list\n pieces = [\"\"]\n end\n if filter_blanks\n pieces = pieces.select { |atom| !atom.nil? && atom.length > 0 }\n end\n pieces\n end", "def split_words(str)\n\nend", "def split(input_field, regex, into_fields, options = {})\n output = options[:output] || all_fields # Overrides Cascading default\n\n input_field = fields(input_field)\n raise \"input_field must declare exactly one field, was '#{input_field}'\" unless input_field.size == 1\n\n each(\n input_field,\n :function => Java::CascadingOperationRegex::RegexSplitter.new(fields(into_fields), regex.to_s),\n :output => output\n )\n end", "def split(str)\n str.split(/\\.+(?=[^0-9])|[,\\r\\n]/).reject { |s| s.blank? || s == '.' }.map { |s| s.gsub(/\\s+/, ' ').strip.downcase }\n end", "def parse_item_delim(str)\n (str && str.kind_of?(String)) ? str.slice(4,1) : \"^\"\n end", "def split_function_name(line)\n /(\\s*def\\s*)(\\S[^\\(]*)(\\(.*)/.match(line)\nend", "def split_name(name)\n name.split(/(?<=\\S)(?=\\s)|(?<=\\s)(?=\\S)|\\b/)\n end", "def split_path; end", "def gets(sep=$/) end", "def gets(sep=$/) end", "def parse str = nil, type = nil\n if str and !str.empty? \n str.split( get_separator( type ) )\n elsif @items and [email protected]?\n @items\n else\n raise ArgumentError.new \"Bad parameter passed to method!\"\n end\n end", "def separated_by(sep, sym, &block)\n option(separated_by1(sep, sym), [], &block)\n end", "def tokenize_string(input_string, delimiter_list=\" \")\n input_string.split(delimiter_list)\nend", "def string_splitter( string )\n\n array = []\n array = string.split(\"\")\n p array\n return array\n\nend", "def split(position)\n end", "def split(position)\n end", "def seperate(string, seperator = \"-\")\n arr = string.downcase.split(\"\")\n arr.join(seperator)\nend", "def split_arguments!(arguments)\n \n if arguments.any? { |arg| arg.strip == 'of' }\n command = arguments.delete('of')\n elsif arguments.any? { |arg| arg.strip == 'convert' }\n command = arguments.delete('convert')\n end\n \n command\nend", "def delimiters\n @delimiters ||= COMMON_DELIMITERS.inject({}, &count).sort(&most_found)\n end", "def tokenize # rubocop:disable Metrics/MethodLength\n if match = TOKENIZE_REGEXP.match(@string) # rubocop:disable Lint/AssignmentInCondition\n pre = match.pre_match\n post = match.post_match\n tokens = match[1].split(TOKENIZE_SEPARATOR)\n tokens.each do |token|\n yield(self.class.new(\"#{pre}#{token}#{post}\"))\n end\n else\n yield(self.class.new(@string))\n end\n\n nil\n end", "def split_line(line)\n tmpLine = line.clone\n chunks = []\n\n while tmpLine != ''\n tmpLine.sub!(/^\\s*/,\"\")\n tmpLine.sub!(/^([a-z0-9_\"]+)(\\((([^()]+|\\([^()]*\\))*)\\))?/i,\"\")\n break if $&.nil?\n chunks.push $& unless $& == ''\n end\n\n chunks\n end", "def split_first_line(line)\n title, date, tags = line.split('|')\n tags = tags.strip.split(',')\n return title, date, tags\nend", "def split_by_delimiter(delimiter = self.class.parsing_delimiter)\n return '' if body.nil? || body.empty?\n lines = body.split(\"\\n\")\n delim_line = last_line = found_empty = nil\n \n lines.each_with_index do |line, i|\n next if delim_line\n delim_line = i if line.include?(delimiter)\n end\n \n while !last_line && delim_line.to_i > 0\n delim_line = delim_line - 1\n if found_empty\n last_line = delim_line if lines[delim_line].strip.size > 0\n else\n found_empty = true if lines[delim_line].strip.size.zero?\n end\n end\n \n if last_line\n lines[0..delim_line] * \"\\n\"\n elsif delim_line.nil?\n body.strip\n else\n ''\n end\n end" ]
[ "0.70868903", "0.6954385", "0.67158985", "0.67158985", "0.6710254", "0.6663027", "0.63858867", "0.63685197", "0.632007", "0.61797607", "0.61695415", "0.6163385", "0.6155966", "0.6146926", "0.6142181", "0.61408603", "0.61347556", "0.60366005", "0.59695476", "0.5968167", "0.59602624", "0.5959365", "0.5959365", "0.5958163", "0.5951049", "0.59241563", "0.5895769", "0.5895633", "0.5895633", "0.58898026", "0.58856404", "0.58796626", "0.5876218", "0.58633167", "0.5855164", "0.58532053", "0.5850522", "0.5835377", "0.5818286", "0.5781596", "0.577552", "0.5763334", "0.5758815", "0.57579225", "0.5757389", "0.57545865", "0.57528603", "0.5732642", "0.5727945", "0.57194775", "0.5710189", "0.56885743", "0.56885743", "0.5666717", "0.5659155", "0.56536984", "0.56315404", "0.5627394", "0.56228167", "0.56167746", "0.5615899", "0.56087875", "0.5601886", "0.55852824", "0.5576319", "0.5576319", "0.5575828", "0.55611193", "0.55536026", "0.55532557", "0.55528533", "0.55390465", "0.5536428", "0.5535493", "0.5522415", "0.55157113", "0.55085987", "0.5504768", "0.5490811", "0.5485628", "0.5480897", "0.54725486", "0.54718626", "0.5462465", "0.54614234", "0.545128", "0.54473466", "0.54473466", "0.54454637", "0.5439498", "0.5437588", "0.54279834", "0.54273057", "0.54273057", "0.54231524", "0.5409062", "0.5393533", "0.5390163", "0.53882456", "0.5381244", "0.5379834" ]
0.0
-1
Return list of codon sequences, split on the +is_splitter+ function.
def split codons, is_splitter_func list = [] node = [] codons.each_with_index do | c, pos | # p [c,pos] if is_splitter_func.call(c) node.push c size = node.size # p node list.push FrameCodonSequence.new(node,pos+1-size) if size > @min_size_codons node = [] end node.push c # always push boundary codon end list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_codon_orfs1 splitter_func,do_include_leftmost_orf,do_strip_leading_codon\n orfs = split(@codons,splitter_func)\n return [] if orfs.size == 0\n # Drop the first sequence, if there is no match on the first position\n orfs.shift if !do_include_leftmost_orf and !splitter_func.call(orfs.first[0])\n orfs = orfs.map { |codons| \n codons = codons.shift if do_strip_leading_codon and splitter_func.call(codons[0])\n codons\n }\n if @reversed == nil\n TrackSequenceTrait.update_sequence_pos(orfs,@ntseq_pos) # nail against parent\n else\n TrackSequenceTrait.update_reversed_sequence_pos(orfs,@ntseq_pos) # nail against parent\n end\n end", "def splits\n []\n end", "def block_splitter(array)\n answer_array = []\n\n answer_array << array.select { |word| word.yield }\n answer_array << array.reject { |word| word.yield }\n\n return answer_aray\nend", "def split_code\n index = self.code_index\n self.split_at index if index\n end", "def split; end", "def get_codon_orfs2 splitter_func, start_func\n orfs = get_codon_orfs1(splitter_func,true,true)\n orfs.find_all { | orf | start_func.call(orf[0]) }\n end", "def split_by(array, delim)\n ret = []\n a = []\n array.each do |i|\n if i == delim then\n ret << a\n a = []\n else\n a << i\n end\n end\n ret << a unless a.empty?\n return ret\n end", "def split_sequence(sequence)\n pieces = sequence.split('.') \n case pieces.size\n when 3\n pieces\n when 2\n if pieces[0].size > 1 ## N termini\n ['-', pieces[0], pieces[1]]\n else ## C termini\n [pieces[0], pieces[1], '-']\n end\n when 1 ## this must be a parse error!\n [nil,nil,nil]\n when 0\n [nil,nil,nil]\n end\n end", "def is_split_order\n end", "def split(position)\n end", "def split(position)\n end", "def split(parts); end", "def split_by(arr, divider)\n arr.inject([[]]) {|results, element|\n (divider == element) ? (results << []) : (results.last << element)\n results\n }\n end", "def my_array_splitting_method(source)\n new_array = []\n new_array << source.select { |i| i.is_a? Integer }\n new_array << source.select { |i| i.is_a? String }\n new_array\nend", "def split\n\t\t\tcond = pop\n\t\t\tarray = pop\n\t\t\traise ArgumentError, \"SPLIT: first element is not an Array.\" unless cond.is_a? Array\n\t\t\traise ArgumentError, \"SPLIT: second element is not an Array.\" unless array.is_a? Array\n\t\t\tyes, no = [], []\n\t\t\tarray.each do |e|\n\t\t\t\tsave_stack\n\t\t\t\tpush e\n\t\t\t\t~cond.dup\n\t\t\t\tpop ? yes << e : no << e\n\t\t\t\trestore_stack\n\t\t\tend\n\t\t\tpush yes\n\t\t\tpush no\n\t\tend", "def my_array_splitting_method(source)\n new_array =[]\n new_array.push(source.select {|item| item.is_a? Integer})\n new_array.push(source.select {|item| item.is_a? String})\n p new_array\n\nend", "def my_array_splitting_method(source)\nend", "def code_splitter(code)\n student_code = []\n code = code.split('startTraceNow();')\n new_code = code[1].split('endTraceNow();')\n executed_code = new_code[0]\n executed_code_list = executed_code.split('\\\\n')\n flag = false\n counter = 0\n until flag\n if executed_code_list[counter] == '' || executed_code_list[counter] == ' '\n flag = false\n counter += 1\n elsif executed_code_list[counter] != ''\n flag = true\n end\n end\n x = counter\n while x < executed_code_list.length\n temp = executed_code_list[x]\n temp = temp.strip\n student_code << executed_code_list[x] unless temp.empty?\n\n x += 1\n end\n student_code\nend", "def split_ions\n self.ions.split(',') rescue []\n end", "def split_into_sequences(number)\n [\n [number[0..2], number[3..-1]], #-1 referees to the last element of the array\n [number[0..3], number[4..-1]],\n [number[0..4], number[5..-1]],\n [number[0..5], number[6..-1]],\n [number[0..6], number[7..-1]]\n ]\n end", "def my_array_splitting_method(source)\n integer_array = Array.new\n string_array = Array.new\n \n source.each do |piece|\n if piece.is_a?(Integer)\n integer_array << piece\n else\n string_array << piece\n end\n end\n master_array = integer_array,string_array\n return master_array\nend", "def get_splits\n @logical_splits\n end", "def prepare_sequence(sequence)\n nv = remove_non_amino_acids(sequence)\n split_sequence(nv)\n end", "def split(separator)\n lambda do |rec, acc|\n acc.replace( acc.flat_map { |v| v.split(separator) } )\n end\n end", "def my_array_splitting_method(source)\n a = source.partition { |x| x.is_a? Integer }\n return a.to_a\nend", "def split?\n\t\treturn @is_split\n\tend", "def my_array_splitting_method(source)\n source.partition{|element| element.is_a?(Integer)}\nend", "def inside_chunks(chunk_types)\n chunk_types.each{|chunk_type| chunk_type.apply_to(self) }\n \n chunk_types.each{|chunk_type| @chunks_by_type[chunk_type].each{|hide_chunk|\n scan_chunkid(hide_chunk.text){|id| yield id }\n }\n } \n end", "def split?() triangulated? and complement.triangulated?; end", "def my_array_splitting_method(source)\n source.partition { |x| x.is_a? Integer }\nend", "def separar_Bloques(bloque)\n bloques_lista = []\n auto_instruccion = \"\"\n salto_de_linea = 0\n saltos_de_linea = bloque.count(@@separador_linea)\n while (bloque!=\"\")\n fin_de_linea = bloque.index(@@separador_linea)\n if (fin_de_linea==nil)\n if (auto_instruccion!=\"\")\n cantidad_de_separadores = bloque.count(\",\") + bloque.count(\" \")\n if (cantidad_de_separadores == 2)\n bloques_lista.push(auto_instruccion)\n auto_instruccion = \"\"\n bloques_lista.push(bloque)\n end\n if (cantidad_de_separadores == 0)\n bloques_lista.push(auto_instruccion+@@separador_linea+bloque)\n auto_instruccion = \"\"\n end\n else\n bloques_lista.push(bloque) \n end\n bloque=\"\"\n next\n end\n linea = bloque[0..fin_de_linea-1]\n cantidad_de_separadores = linea.count(\",\") + linea.count(\" \")\n if (cantidad_de_separadores == 2)\n if (auto_instruccion!=\"\")\n bloques_lista.push(auto_instruccion)\n auto_instruccion = \"\"\n end\n auto_instruccion = linea\n end\n if (cantidad_de_separadores == 0)\n auto_instruccion = auto_instruccion+ ((auto_instruccion!=\"\")? @@separador_linea : '') + linea\n bloques_lista.push(auto_instruccion)\n auto_instruccion = \"\"\n end\n bloque = bloque[fin_de_linea+(@@separador_linea.length())..bloque.length()] \n end\n\n auto_instruccion = auto_instruccion+ ((auto_instruccion!=\"\")? @@separador_linea : '') + bloque\n bloques_lista.push(auto_instruccion)\n return bloques_lista\nend", "def split_consonant_cluster\n coda = consonant_queue.clone\n onset = []\n while POSSIBLE_ONSETS.include?([coda.last.try(:symbol)] + onset.map {|phoneme| phoneme.symbol}) do\n onset.unshift coda.pop\n end\n [coda, onset]\n end", "def split(inputs=nil, outputs=nil)\n inout \"split\", inputs, outputs\n end", "def get_categories_to_split\n categories_to_split = []\n @distinct_categories.each do |category_type|\n categories_to_split << category_type if category_needs_split?(category_type)\n end\n categories_to_split\n end", "def split_partitions\n partition_names = @list.map { |bin| bin.partition_names }.flatten\n partition_names.select { |name| partition_names.index(name) != partition_names.rindex(name) }.uniq\n end", "def split\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 38 )\n\n\n return_value = SplitReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_SPLIT197__ = nil\n __LPAR198__ = nil\n __RPAR200__ = nil\n __Identificador201__ = nil\n __EOL203__ = nil\n string199 = nil\n var_local202 = nil\n\n\n tree_for_K_SPLIT197 = nil\n tree_for_LPAR198 = nil\n tree_for_RPAR200 = nil\n tree_for_Identificador201 = nil\n tree_for_EOL203 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 184:4: K_SPLIT LPAR string RPAR ( Identificador | var_local ) EOL\n __K_SPLIT197__ = match( K_SPLIT, TOKENS_FOLLOWING_K_SPLIT_IN_split_872 )\n if @state.backtracking == 0\n tree_for_K_SPLIT197 = @adaptor.create_with_payload( __K_SPLIT197__ )\n @adaptor.add_child( root_0, tree_for_K_SPLIT197 )\n\n end\n\n __LPAR198__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_split_874 )\n if @state.backtracking == 0\n tree_for_LPAR198 = @adaptor.create_with_payload( __LPAR198__ )\n @adaptor.add_child( root_0, tree_for_LPAR198 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_string_IN_split_876 )\n string199 = string\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, string199.tree )\n end\n\n __RPAR200__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_split_878 )\n if @state.backtracking == 0\n tree_for_RPAR200 = @adaptor.create_with_payload( __RPAR200__ )\n @adaptor.add_child( root_0, tree_for_RPAR200 )\n\n end\n\n # at line 184:29: ( Identificador | var_local )\n alt_28 = 2\n look_28_0 = @input.peek( 1 )\n\n if ( look_28_0 == Identificador )\n alt_28 = 1\n elsif ( look_28_0 == DOUBLEDOT )\n alt_28 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 28, 0 )\n\n end\n case alt_28\n when 1\n # at line 184:30: Identificador\n __Identificador201__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_split_881 )\n if @state.backtracking == 0\n tree_for_Identificador201 = @adaptor.create_with_payload( __Identificador201__ )\n @adaptor.add_child( root_0, tree_for_Identificador201 )\n\n end\n\n\n when 2\n # at line 184:44: var_local\n @state.following.push( TOKENS_FOLLOWING_var_local_IN_split_883 )\n var_local202 = var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, var_local202.tree )\n end\n\n\n end\n __EOL203__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_split_886 )\n if @state.backtracking == 0\n tree_for_EOL203 = @adaptor.create_with_payload( __EOL203__ )\n @adaptor.add_child( root_0, tree_for_EOL203 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 38 )\n\n\n end\n\n return return_value\n end", "def my_array_splitting_method(source)\n\n split_array = []\n array_1 = []\n array_2 = []\n\n source.each do | item |\n if item.is_a?(Integer)\n array_1.push(item)\n else\n array_2.push(item)\n end\n end\n\n split_array.push(array_1)\n split_array.push(array_2)\n\n return split_array\n\nend", "def bandsplit\n (0...bands).map { |i| extract_band i }\n end", "def combos\n result = []\n radixs = reverse.map(&:size)\n inject(1){|r, i| r * i.size}.times{ |step|\n result << foldr(lambda{ |i, r|\n radix = radixs[r.size]\n r.unshift i[step % radix]\n step /= radix unless radix.nil?\n r\n }, [])\n }\n result\n end", "def lists\n lines.inject([]){ |lists, line| lists << split(line) }\n end", "def my_array_splitting_method(source)\n source.partition { |item| item.class == Fixnum}\nend", "def even_splitters(string)\n result = [] \n\n string.chars.uniq.each do |c|\n result << c if element_same_length?(string.split(c))\n end\n \n p result\nend", "def is_split()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.TextComponentState_is_split(@handle.ptr)\n result\n end", "def split_code(codes)\n arr = []\n num = codes.scan(/\\d/).join('')\n str = codes.scan(/[a-zA-Z]+/)\n arr << str\n arr << num.to_i\n arr.flatten\nend", "def parts\n return unless isbn13\n\n group = prefix = nil\n\n RANGES.each_pair do |g, prefixes|\n next unless isbn13.match(\"^#{g}\")\n group = g\n\n pre_loc = group.length\n prefixes.each do |p|\n number = isbn13.slice(pre_loc, p[:length]).to_i\n next unless p[:range].include?(number)\n\n prefix = p.merge(:number => number)\n break\n end\n\n break\n end\n\n # In the unlikely event we can't categorize it...\n return unless group && prefix\n\n prefix = sprintf(\"%0#{prefix[:length]}d\", prefix[:number])\n [group[0..2], group[3..-1], prefix, isbn13[(group.length + prefix.length)..-2], isbn13[-1..-1]]\n end", "def getCandidates (data, len)\n\t\tresult = Array.new\n\t\tdata.each do |s|\n\t\t\tlst = Array.new\n\t\t\tsumChars = self.charsSum (s)\n\n\t\t\tprep = s.split(//).collect{|x| repeat(self.letterToInt(x),\"1\")} #list of blocks\n\n\t\t\tself.genSequence(prep, len - sumChars + 1).each do |r|\n\t\t\t\tbits = r[1,r.size-1].split(//)\n\t\t\t\tbitset = Array.new(bits.size,false)\n\t\t\t\tfor i in 0...bits.size\n\t\t\t\t\tbitset[i] = (bits[i]=='1')\n\t\t\t\tend\n\t\t\t\tlst.push(bitset)\n\t\t\tend\n\t\t\tresult.push(lst)\n\t\tend\n\t\treturn result\n\tend", "def my_array_splitting_method(source)\n divide = source.sort_by{|x| x.to_s}\n total = divide.find_all{|item| item % 1 == 0 }.count \n total -= 1\n divide.partition.with_index { |_, index| index <= total }\nend", "def my_split(array) \n splitted = []\n array.each do |element|\n element.split(//).each { |each_splitted| splitted << each_splitted }\n end\n splitted\n end", "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 basic_split(*bonds)\n if bonds.size > 0\n delete_and_restore_bonds(*bonds) do |mol|\n mol.ob.separate.map(&:upcast)\n end\n else\n self.ob.separate.map(&:upcast)\n end\n end", "def consecutive_collapse(nums)\n found_pairs = true\n collapsed = nums\n\n while(found_pairs)\n found_pairs = false\n new_iterration = []\n\n (0...collapsed.count-1).each do |i|\n if consecutive?(collapsed[i], collapsed[i+1])\n new_iterration.concat(collapsed[i+2..-1])\n found_pairs = true\n break\n else\n new_iterration << collapsed[i]\n end\n end\n collapsed = new_iterration if found_pairs\n end\n collapsed\nend", "def shell_split; end", "def split(pattern=$;, limit=0) end", "def split(pattern=$;, limit=0) end", "def string_splitter( string )\n\n array = []\n array = string.split(\"\")\n p array\n return array\n\nend", "def split_cand(cand)\n n = cand=~/\\d/\n [cand[0...n],cand[n+1..-1]]\nend", "def is s, d, done, i\n return 0, [] if i == s.length\n return done[i] if !!done[i]\n cuc, cs = is s, d, done, i + 1\n muc = 1 + cuc\n msplit = cs\n d.each do |w|\n if w == s[i...i + w.length]\n cuc, cs = is s, d, done, i + w.length\n if cuc < muc\n muc = cuc\n msplit = [i - 1, i + w.length - 1] + cs\n end\n end\n end\n done[i] = [muc, msplit]\n return [muc, msplit]\nend", "def split(str, on)\n str.split(on)\n end", "def split(max)\n return yield self if @length <= max\n first, *mid, last = @payload.chunk(max)\n yield Frame.craft(type_value: @type_value, stream_id: @stream_id, payload: first, flags_value: @flags_value & ~4)\n mid.each { |slice|\n yield Frame.craft(type: :continuation, stream_id: @stream_id, payload: slice, flags_value: 0)\n }\n yield Frame.craft(type: :continuation, stream_id: @stream_id, payload: last, flags_value: @flags_value & 4)\n end", "def id_split(item)\n case item\n when Array then array = item.flat_map { |v| id_split(v) }\n when String then array = item.split(/[ \\t]*[,;\\n]+[ \\t]*/)\n when PublicationIdentifier then array = Array.wrap(item)\n else array = Array.wrap(item).map(&:to_s)\n end\n array.compact_blank!\n end", "def map_scm(scm_list, &proc)\n return [] if null?(scm_list)\n return [] unless list?(scm_list)\n\n result = []\n tail = scm_list\n until null?(tail)\n head, tail = tail.scm_decompose\n result.push(yield head)\n end\n\n result\n end", "def build_primer_lists\n operations.each { |op| op.temporary[:length] = (op.output(\"Primer\").sample.properties[\"Overhang Sequence\"] + op.output(\"Primer\").sample.properties[\"Anneal Sequence\"]).length }\n \n primers_over_60 = operations.select do |op| \n length = op.temporary[:length]\n length > 60 && length <= 90\n end.map do |op| \n primer = op.output(\"Primer\").sample\n \"#{primer} (##{operations.index(op) + 1})\"\n end.join(\", \")\n \n primers_over_90 = operations.select do |op| \n length = op.temporary[:length]\n length > 90\n end.map do |op| \n primer = op.output(\"Primer\").sample\n \"#{primer} (##{operations.index(op) + 1})\"\n end.join(\", \")\n \n [primers_over_60, primers_over_90]\n end", "def consecutive_collapse(arr)\nend", "def subscript_codeseparator(separator_index)\n buf = []\n process_separator_index = 0\n chunks.each do |chunk|\n buf << chunk if process_separator_index == separator_index\n process_separator_index += 1 if chunk.ord == OP_CODESEPARATOR && process_separator_index < separator_index\n end\n buf.join\n end", "def split(lines) \n out = [] \n lines.each do |l| \n next if l[1..100].all? &:blank? # skip sku placeholder \n if l[1].blank? \n out.last.push l \n else \n out.push [l] \n end \n end \n out \nend", "def apply_splits( inputs, &block )\n result = inputs.pairs.map {|t1,t2| self.apply_split( t1, t2 )}\n if not block\n return result\n else\n result.each {|v| yield v}\n end\n end", "def commontator_split_paragraphs(text)\n return [] if text.blank?\n\n text.to_str.gsub(/\\r\\n?/, \"\\n\").gsub(/>\\s*</, \">\\n<\").split(/\\s*\\n\\s*/).reject(&:blank?)\n end", "def split_blocks(array)\n array.inject( [ [] ] ) do |array_of_blocks, val|\n if val == -1\n array_of_blocks << [-1]\n array_of_blocks << [] \n else \n array_of_blocks[-1] << val\n end\n array_of_blocks\n end\nend", "def my_array_splitting_method(source)\nnew_arr = Array.new(2)\n new_arr[0] = source.select {|item| item.is_a?(Integer) }\n new_arr[1] = source.reject {|item| item.is_a?(Integer)}\n return new_arr\nend", "def split_with\n Logger.info \"Splitter configured with a chunk size of #{chunk_size}MB \" \\\n \"and suffix length of #{suffix_length}.\"\n yield split_command\n after_packaging\n end", "def separate(array)\n idxs = getidx(\"Operate on which? \",1, array.size)\n print \"Separator? \"\n sep = $stdin.gets.chomp\n narr = Array.new\n rem = Array.new\n idxs.each do |idx|\n narr << array[idx - 1].split(sep)\n rem << array[idx - 1]\n end\n return array - rem\nend", "def split national_number\n [nil, false, national_number]\n end", "def createAvailable(split) \n start = CHUNKS*2+3\n available = []\n \n while(start < split.length)\n available.push split[start].chomp.to_i\n start += CHUNKS+1\n end\n return available\nend", "def splitter(input)\n array = input.downcase.split('')\nend", "def my_array_splitting_method(source)\n new_arr = Array.new(2)\n new_arr[0] = source.select {|item| item.is_a?(Integer) }\n new_arr[1] = source.reject {|item| item.is_a?(Integer)}\n return new_arr\nend", "def separators\n @separators.merge(definition.separators(@children.find(&:segment?)))\n end", "def can_split\n if @cards.length == 2\n if @cards[0].symbol == @cards[1].symbol\n return 1\n end\n end\n return nil\n end", "def bit_split(x, lens)\n ret = []\n lens.each {|l|\n ret << (x & ((1 << l)-1))\n x >>= l\n }\n ret\n end", "def split\n raise NotImplementedError, \"#{__method__} has to be implemented in #{self.class}.\"\n end", "def find_paid_splits(array)\n # [[5, true, 0], [8, true, 0], [\"new\", false, 27.78]] =>\n # [[5, true, 0]] => [ [5, true, 0], []]\n # [[5, true, 0], [8, true, 0]]\n # [[5, true, 0], [8, true, 0], [8, true, 0], [\"new\", false, 27.78]]\n # [[\"new\", false, 27.78]] => [ [], [\"new\", false, 27.78]]\n # [[16, false, 20.22]]\n\n counter = 0\n array.each do |split|\n if split[2] == 0\n counter += 1\n end\n end\n\n if counter == 0\n return array.unshift([])\n else\n\n paid_splits = array.slice(0, counter)\n\n if array.length > counter\n paid_splits.push(array[array.length - 1])\n else\n paid_splits.push([])\n end\n\n paid_splits\n end\n\n\n end", "def consecutive_collapse(nums)\n collapsed = Array.new(nums)\n can_be_collapsed = true\n\n while can_be_collapsed\n\n can_be_collapsed = false\n iterator = 0\n while iterator < collapsed.length-1\n\n if collapsed[iterator] == collapsed[iterator+1]-1 || collapsed[iterator] == collapsed[iterator+1]+1\n can_be_collapsed = true\n collapsed.slice!(iterator..iterator+1)\n break\n end\n \n iterator += 1\n end\n end\n collapsed\nend", "def split_by_condition(array, condition, omit_single_element_groups = true)\n groups = []\n group = []\n\n until array.empty?\n element = array.shift\n if group.empty? || condition.call(group[0], element)\n group << element\n else\n groups << group unless omit_single_element_groups && group.size == 1\n group = [element]\n end\n end\n groups\n end", "def map_to_chunks(frames)\n frames.each_cons(1 + BONUS_LOOKAHEADS.max).to_a\n end", "def before_and_after begin_delimeter, end_delimeter\n\n Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]\n\n before_after_lines = []\n in_middle_bit = false\n\n self.each do |candidate_line|\n\n is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_delimeter.downcase)\n if is_middle_boundary\n in_middle_bit = true\n next\n end\n\n unless in_middle_bit\n before_after_lines.push candidate_line\n next\n end\n\n #--\n #-- Now we are definitely in the middle bit.\n #-- Let's check for the middle end delimeter\n #--\n if candidate_line.downcase.include? end_delimeter.downcase\n in_middle_bit = false\n end\n\n end\n\n return before_after_lines\n\n end", "def sequence_separator; end", "def possible_sequences(state, turn)\n board = JSON.parse(state)\n sequences = []\n\n board.each_with_index do |row, i|\n board[i].each_with_index do |col, j|\n if board[i][j].downcase == turn\n sequences.concat self.move_sequences_for_piece(board, [i, j])\n end\n end\n end\n\n # remove single sequences if there are bigger\n # ones available\n sequences_copy = Marshal.load(Marshal.dump(sequences))\n jump_found = false\n \n sequences_copy.each_with_index do |sequence, i|\n if sequence[0].length > 1\n jump_found = true\n break\n elsif sequence[0].length == 1\n src, dst = sequence[0]\n\n if (src[0] - dst[0]).abs == 2 && (src[1] - dst[1]).abs == 2\n jump_found = true \n end\n end\n end\n\n if jump_found\n sequences_copy.each_with_index do |sequence, i|\n if sequence[0].length == 1\n src, dst = sequence[0]\n\n if (src[0] - dst[0]).abs == 1 && (src[1] - dst[1]).abs == 1\n sequences.delete(sequence)\n end\n end\n end\n end\n\n return sequences \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 get_braille_arrays\n string = braille_to_string\n lines = string.scan(/.{1,80}/)\n pairs = lines.map do |string|\n string.scan(/../)\n end\n end", "def odd_lines(array, split_pattern)\n array.each do |l|\n yield(l) if l.split(split_pattern).count.odd?\n end\nend", "def split(element=nil)\n result,current = [],[]\n if block_given?\n each do |e|\n if yield(e)\n result << current\n current = []\n else\n current << e\n end\n end\n else\n each do |e|\n if e == element\n result << current\n current = []\n else\n current << e\n end\n end\n end\n result << current if not current.empty?\n result\n end", "def get_startstop_orfs \n get_codon_orfs2(\n Proc.new { | codon | STOP_CODONS.include?(codon) },\n Proc.new { | codon | START_CODONS.include?(codon) })\n end", "def partition(data)\n result = []\n i = 0\n while i < data.count\n block_partitions = data[i].split('|')\n result[i] = Block.new(\n block_partitions[0].to_i,\n block_partitions[1],\n block_partitions[2],\n block_partitions[3],\n block_partitions[4]\n )\n i += 1\n end\n result\n end", "def split(p, pstate)\nm = []\nr = p[0]\npn = []\np.each{|p0| pn.push(p0)}\npn.delete(p[0])\ntag = 0\npn.each{|p0|\[email protected]{|a|\nt1 = get_transition(r, a)\nt2 = get_transition(p0, a)\ntag = 0\nif t1 != nil && t2 != nil\npstate.each{|s|\nif !(t1 == t2)\nif !(m.include?(p0))\nif s.include?(t1[0]) && s.include?(t2[0])\ntag = 1\nend\nend\nelse\ntag = 1\nend\n}\nif tag == 0\nm.push(p0)\nend\nelsif t2 == nil && t1 == nil\nnext\nelsif t1 != nil || t2 != nil\nm.push(p0)\nend\n}\n}\nm.each{|o| p.delete(o)}\np = p.sort\nresult = [p, m]\nresult\nend", "def split_number(number)\n if number.length > 4\n tokens = []\n\n # reverse & split by doubles\n number.reverse.scan(/.(?:.|$)/) do |token|\n token.reverse!\n if token.length == 1\n tokens.last.prepend token\n else\n tokens << token\n end\n end\n\n # merge back\n tokens.reverse!\n tokens.tap do |tokens|\n tokens.map! { |token| yield token } if block_given?\n end\n else\n yield number if block_given?\n [number]\n end\n end", "def my_array_splitting_method(source)\n big_array = []\n first_array = []\n second_array = []\n source.each do |thing|\n if thing.to_i == thing\n first_array.push(thing)\n else\n second_array.push(thing)\n end\n end\n return big_array.push(first_array).push(second_array)\nend", "def split_segments(data)\n pos = 0\n segments = []\n segments.append(data[pos...pos += RECORD_SIZE]) while pos < data.length\n segments\n end", "def separated_by1(sep, sym, &block)\n _defmetasyntax(\"separated_by1\", _intern(sym), block) {|target|\n seq(sym) {|x| [x] }\\\n | seq(target, sep, sym) {|list, _, x| list.push x; list }\n }\n end", "def folds\n\t\[email protected]{|l| l.folded_lines}\n\tend", "def split_tags\n set_tagged_bool\n self.tagged ? self.tag.split(\" \") : []\n end", "def split(text)\n test = text.split(/\\|(?!\\|)/);\n test.each_with_index do |value, index|\n if(value[-1,1] == \"|\")\n value << test[index+1];\n test.delete_at(index+1);\n redo;\n end\n end\n end" ]
[ "0.63078845", "0.5879941", "0.56280047", "0.5411079", "0.54092115", "0.53848314", "0.52199364", "0.52010715", "0.5199242", "0.5153911", "0.5153911", "0.51255774", "0.5019994", "0.49772936", "0.49729", "0.49275488", "0.49167195", "0.48985064", "0.48963857", "0.4894775", "0.4891293", "0.48893034", "0.48378354", "0.4819884", "0.48152798", "0.47974682", "0.47913355", "0.47875452", "0.47838205", "0.4744368", "0.47370824", "0.47194055", "0.47062433", "0.47031903", "0.46944776", "0.4686201", "0.46844897", "0.46731302", "0.46685052", "0.46604764", "0.46593606", "0.46531767", "0.4643787", "0.46394056", "0.4636877", "0.46319783", "0.46280265", "0.4622774", "0.46213394", "0.46211907", "0.45949537", "0.45868164", "0.4575212", "0.4575212", "0.45710048", "0.45405433", "0.454042", "0.45191067", "0.45181194", "0.451738", "0.45120138", "0.45079508", "0.4500296", "0.4490467", "0.44879764", "0.44821236", "0.44819355", "0.44671527", "0.44663587", "0.44648868", "0.44594574", "0.44323036", "0.4430864", "0.4427834", "0.4425348", "0.4424501", "0.44190478", "0.44150645", "0.44075266", "0.43999314", "0.43992466", "0.4388102", "0.43872535", "0.43866706", "0.43855587", "0.43681577", "0.43619725", "0.4361142", "0.43563756", "0.43558407", "0.4351894", "0.43393654", "0.4324632", "0.43162808", "0.43013704", "0.4299338", "0.42981493", "0.42969796", "0.42961472", "0.4286046" ]
0.8017075
0